On-Board Diagnostics

Overview:

I designed a GUI( C# ) and hardware( AVR Micro-controller ) to monitoring the communication between Car’s ECU and diagnostic tools.
This software helps us for understand the protocols of different cars and ECUs,it could show, record, save(in MS Excel format), learn, simulate( ECU Or Diagnostic tool) and etc.

Description:

My hardware is very simple, it just has two serial port to getting the data from PC and sends to OBD and K-Line pin and vice versa,but each serial port has different baud rate.

My software is a little complex, it can work in three main mode, ECU mode, Monitor Mode and Diag Mode and save all data into Microsoft Excel format.

Diagnostics Application

OBD main protocol:

For start you should have a few knowledge about OBD, K-Line and ECU:

If you didn’t know about OBD and ECU, i recommended you to read about these in Wikipedia website.

The serial communication between ECU and Diagnostics tools is base on Master and Slave and always Diagnostics is Master and ECU is Slave, So always the diagnostics tools starts requesting data from ECU and then ECU replies to it.

Each of them has an unique address:ECU address and Tester address.

The protocol is like this:

Bye 1         ,             Byte 2          ,          Byte 3       ,  Byte4, …..  ByteN,     ByteN+1

(0x80 | dataLen), Destination Address, Source Address,  Data0, …, DataN, CheckSum

Example: To Clear Errors in Pegout 405( with Sagem ECU ) Diagnostics must send:

0x83 , 0x10 , 0xF1 , 0x14 , 0xFF , 0x00 , 0x97

0x83 is Start Byte + Data Len ( data len is 3 )

0x10 is ECU Address

0xF1 is Tester Address

0x14 and 0xFF , 0x00 are Data

and 0x97 is ChechSum( 0x83+0x10+0xF1+0x14+0xFF+0x00 = 0x97 )

ECU reply like:

0x83 , 0xF1 , 0x10 , 0x54 , 0xFF , 0x00 , 0xD7

At all,this software helps us for understand the protocols of different cars and ECUs

The Modes:

 

  1. Monitor Mode: in this mode the software just listens to OBD data and saves all data, and it is learning what they( ECU and Diagnostics Tools) say.
  2. ECU Mode: in this mode the software can reply all tester requests with saved data exactly like real ECU.This mode suitable for getting ECU parameters formula,Errors code and etc from ECU.
  3. Diag Mode: in this mode the software can work like a tester and sends request to ECU With the help of information stored before.In this mode the software can send a selected command to ECU sequentially with definable time for Tester’s Present State.

With these modes the user might understand all information about the protocol.

Also User can change the ECU and Diagnostics data in real time and see what happened ( of curse  the software calculates the check sum automatically ), this feature is very useful when you want to getting formula of ECU and Engine Parameters and data locations of them.

Edit

One of my project goals is Exporting and importing saved data from Microsoft Excel and viewing data sheets in a formatted design.

save

Features:

  • 3 Working Mode
  • Define the name of each communicate command
  • Define the name of each byte in package
  • Define the ECU address and Tester Address
  • Save and Load in Microsoft Excel format( XLSX and XML )
  • Counting each communicate between ECU and Tester
  • Calculates the check sum automatically