By: David Cohen & Gadi Gilad
Instructor: Boaz Mizrahi
Project Final Presentation
CAN Bus Logger
Spring 2011
IntroductionThe CAN (Controller Area Network) bus is an automotive communications system developed by Robert Bosch specifically for data exchange between electronic control units, switches, sensors and actuators in vehicles. CAN is also used in industrial microcontroller networks.. It allows for data supply between measurement, control and display functions and super ordinate computers, as well as for connecting sensors, actuators and controls.
The device is divided into three layers. Physical layer to connect to a CAN network, Data Link layer to manage messages to\from other CAN nodes, and a processing unit to run applications.
Processing Unit
Data Link Layer
Physical Layer
CAN Module
MCP2551MCP2515
The CAN Module
SPI
To
MCU
CANH
CANL
To
CAN Bus
RX
TX
PIC18
Main Goals
Learning: reading previous projects, the CAN protocol,
datasheets and source code. Understanding the MPLAB environment. Performing a loopback test to the device,
checking and debugging the hardware.
Making a conversation between 2 devices. Car testing and operation.
Getting the vehicle data.
Preforming the LoopbackSend and immediately receive a message in the same device. This operation uses only the MAC layer – it’s sending a test message from the PIC to one of transmit buffers, and getting it in one of the receive buffers.
TransmitBuffer
ReceiveBuffer
PIC
LCD Screen
Conversation Between Two Devices
TransmitBuffer
ReceiveBuffer
PIC
LCD Screen
Physical Layer
TransmitBuffer
ReceiveBuffer
PIC
LCD Screen
Physical Layer
Sending a CAN message from one device and receiving it in the other device.
Conversation Between Two DevicesProblems and solutions
• The MAC layer needs 3.3V to operate properly, but the physical layer needs 5V, and we didn’t know it. We fixed it in our code
• The physical layer needs an input load. After adding a resistor of 75Ω we saw on the scope that the message had been delivered from the sending device, but still not the other device.
Conversation Between Two DevicesProblems and solutions (cont.)
• We noticed that there’s an open circuit on the main board of one of the devices. It prevented the communication between the PIC and the MAC. We showed this to Bruria and she fixed it. Now we could send and receive messages between the devices!
• The sensitivity of the LCD screen caused us a lot of problems – the connector got torn many times.
OBD II ConnectorThe signaling method is differential because we only deal with the CAN protocol. So we ordered the used the pins number 5, 7 and 14.
Getting Messages From The Vehicle
• When we first connected the device to the car we couldn’t receive messages from it.
• After connecting the scope to the OBD connector we saw that the frequency of the bits in the car (500 KHz) is different from the frequency the device was configured initially (2 MHz).
Problems and solutions
Getting the Job Done… Outside
Getting Messages From The VehicleProblems and solutions (cont.)
• In order to match the physical constrains, we changed the configuration registers. We needed to configure propagation delay, hold time and the time quantum (TQ).
• After the configuration the device was able to get the valid CAN messages. However, we couldn’t understand what they mean!
Getting The Job Done… Inside
Getting Messages From The VehicleProblems and solutions (cont.)
• In order to check the car messages, we used a different device: ELM327. This device is an industrial tool that get CAN messages. Then we saw that the messages received in it were identical to those received in our device.
Getting Messages From The VehicleProblems and solutions (cont.)
• After working with the ELM327 we understood that the most simple way to work with the CAN is to send queries and get their response.
• Now, finally, we can send queries about the car condition, such as speed, throttle, engine temperature, RPM etc. and get the results on our device!!!
The Device at WorkMeasuring the RPM
~2200 rpm!!!
The Device at WorkMeasuring the RPM
~1700 rpm!!!
The Device at WorkMeasuring the RPM
~1000 rpm!!!
Notes…