This is Ben and I's final project for Embedded Systems. Our goal was to create a car diagnostic system that interfaces with the CAN bus in all US sold cars newer than 2008. We aimed to request data such as RPM, Vehicle speed, engine temp, etc and then display our findings. This software was succussful in communicating with the car and reading and writing, however it fails to accomplish it's task when dealing with certain makes of cars, specifically Honda. Included are various PID codes, functions, and files that interface with a car's CAN bus system.
Dependencies: UniGraphic mbed
You are viewing an older revision! See the latest version
Car Diagnostics with CAN Communication
Device Description¶
Using CAN communication protocol we sought to connect to a vehicle's computing unit in which we would obtain real time data that would be displayed on an LCD screen. A mbed LPC1768 micro controller was used for this project.
Hardware¶
ARM microcontroller (mbed LPC1768), IC Transceiver CAN (MCP2551), DB9 breadboard adapter , OBDII cable, LCD display/resistive touch 2.4” 240x320 (DM-TFT24-104), 220 Ohm resistors (x 2)
Software¶
Five files in the project: globals.h, globals.cpp, OBDII.h, OBDII.cpp, and main.cpp. The main.cpp just serves to call the functions in the rest of the files, and only features a few lines of code. The global files are used just for making the CANMessage and CAN output, as well as a few other miscellaneous items. The OBDII files are where most of the magic happens, this is where the PID codes are defined, as well as the majority of the code, which still is much. The reading, writing, and decoding of the CAN information is all done in these OBDII files.
Program Flow¶
Key Functions¶
We don't actually have many functions in the program, which in turn means that the functions that we do have are very important. First and foremost, the set_frequency function enables us to talk with the different ECU's in the car based on their frequency. The majority of our PID requests were requesting information from the Engine Management ECU which operates at a frequency of 500 kbps. Other frequencies include, 125 and 250 kbps. The other key function is the request function. It takes in a PID char byte that is then sent to the Car and used to ask for specific information and to make sure that the information that we receive back is valid. Once we are able to read the data that comes back, we then determine what type of data is sent and compare it to what we were expecting. Depending on the PID and data received various equations are done to return the desired information.