0
votes

I have connected OBD2 and getting the can data (11bit 500kpbs CAN) using atmel can controller. I get data.

Now, how do I get the mode and PIDs from this data? For example, my data looks like this:

15164A8A-FF088B52 -- Data: 00,00,00,86,9C,FE,9C,FE,

I could see RPM changing, ignition on/off etc... on the data fields. I don't want to use ELM chips. I need to handle the raw data directly.

1

1 Answers

2
votes

HINT: All of my numbers are in HEX.

OBD2 protocol sends you responses in bytes (8 bits). responses are subdivided into header (or called ID as well) and data.

IDs are the address of the ECU and data is "response data" from ECU and it is always 8 bytes (in CAN Bus protocol?!).

8 Bytes of data will be divided into PCI (which can be one or two bytes) and values. PCI will show you what is your frame type (single, First, consecutive or flow control frame) and how many bytes are incoming.

to make it easier I make an example only for single frame:

you might send an OBD request to main ECU like this:

7DF 02 01 0C 00 00 00 00 00

7DF is ECU address for diagnose tester device.

02 is number of sending data bytes

01 is the mode (which you might be interesting in!) 01 is current data, 02 is freeze frame and etc.

0C is rpm PID.

The response from ECU would be something like (single frame):

7E8 04 41 0C 12 13 00 00 00

7E8 is the ECU that responding.

04 number of incoming data bytes.

41 the data are in response to 01 PID

0C response to this PID

12 13 are two byte in response to 0C. Please keep in mind that you have to decode these two bytes with OBD II ISO protocol. you can also find some of conversion rates on Wikipedia.

Other bytes are useless.

To make it short: you have to parse each response from ECU and try to convert the useful bytes to readable decimal value. It depends on which programming language you are using. in C/C++ the best practice in my opinion would be unsigned char which is guaranteed by compiler to be 8 bits and in JAVA it can be Byte. Moreover, try to use bitwise operators to make your life a bit easier.

By more questions do not hesitate to ask.