PDA

View Full Version : Decoding OBDII trouble codes



retepsnikrep
- 31st August 2011, 07:13
I'm recieving two bytes of data on a serial interface.

They are structured as follows and I'm wondering about the most PBPro code size efficent way of converting them into meaningful data?



'Each trouble code requires 2 bytes to describe.
'The text description of a trouble code may be decoded as follows.
'The first character in the trouble code is determined by the first two bits in the first byte:

'A7 A6 First DTC character
'-- -- -------------------
' 0 0 P - Powertrain
' 0 1 C - Chassis
' 1 0 B - Body
' 1 1 U - Network

'The four following digits are BCD encoded.

'The second character in the DTC is a number defined by

'A5 A4 Second DTC character
'-- -- --------------------
' 0 0 0
' 0 1 1
' 1 0 2
' 1 1 3

'The third character in the DTC is a number defined by

'A3 A2 A1 A0 Third DTC character
'-- -- -- -- -------------------
' 0 0 0 0 0
' 0 0 0 1 1
' 0 0 1 0 2
' 0 0 1 1 3
' 0 1 0 0 4
' 0 1 0 1 5
' 0 1 1 0 6
' 0 1 1 1 7
' 1 0 0 0 8
' 1 0 0 1 9

'The fourth and fifth characters are defined in the same way as the third,
'but using bits B7..B4 and B3..B0. The resulting five-character code should
'look something like "U0158" and can be looked up in a table of OBD-II DTCs.
Anyone done this before and have any sample code?

I could do it with If/Then and bit testing but that didn't sound very efficient?

BCD maths is not my strong point.

HenrikOlsson
- 31st August 2011, 10:27
Hi,
This compiles (to 122 words for a 16F628) but I've got no hardware to try it out, "should" work though ;-)


Diag VAR BYTE[5] ' Array for complete message

DTC_High VAR Byte ' Upper byte of message
DTC_Low VAR Byte ' Lower byte of message

i VAR BYTE ' General purpose

'Get the top two bits of the high byte and shift it down so
'it becomes 0-3. Then convert to the correct character.
i = (DTC_High & %11000000) >> 6 ' Temp now 0-3 (borrow Diag[1] for this op)
Lookup i, [32,19,18,37], Diag[0]

' Now extract the next four "digits" in the same way.
Diag[1] = DTC_High & %00110000 ' Isolate bits 4,5
Diag[1] = Diag[1] >> 4 ' Shift down to bits 0,1
Diag[2] = DTC_High & %00001111 ' Isolate bits 0-3
Diag[3] = DTC_Low & %11110000 ' Isolate upper four bits
Diag[3] = Diag[3] >> 4 ' Shift down
Diag[4] = DTC_Low & %00001111 ' Isolate lower four bits


' Now, if Diag[0] is 32 we add 48 to it and it becomes 80 which
' is the ASCII code for "U". If Diag[1] is 2 we add 48 to that
' so it becomes 50 which is the ASCII code for "2" and so on.
HSEROUT["Error code: "]
For i = 0 to 4
HSEROUT[Diag[i] + 48]
Next

/Henrik.

retepsnikrep
- 31st August 2011, 10:48
Very nice thanks I'll study that.

retepsnikrep
- 1st September 2011, 11:14
Much appreciated Henrik that seems to work very well. :)

I will post my pbpro OBDII code for ISO9141 vehicles when finished for those who may want to make their own reader?
All been done before probably and much better than i have done it i'm sure, a good learning experience for me though.
My gizmo now reads DTC codes, send/receives PID's and can clear codes etc. All using the trusty 12F683

Demon
- 10th September 2011, 04:38
I bought an OBD-II reader thinking I could get access to as much information as my mechanic; I was wrong.

My reader reported no codes while his Snap-On unit went into detail about individual wheelspin and pointed to a problem with the sensor in one of the front wheels.

Is it possible for us to get into that much detail? Or is there some sort of "licensing" lock-out preventing us to such detailed information?

retepsnikrep
- 10th September 2011, 07:05
OBDII readers are not created equal, there are lots of manufacturer specific codes that can only be obtained at vast expense or reverse engineering.

Demon
- 10th September 2011, 14:30
Can I chose another answer? :D

That's what I was afraid of. That the Snap-On and other professional tools have a catalogue of codes that is not accessible to the public.

Cause right now that OBD-II codereader is not very useful. It tells me that me catalyser is finished, no surprise on a 2002 Buick Rendezvous with over 200K km. It wouldn't even report a generic code for the ABS while the light came on in the dash.

That's where the Snap-On tool shined, it had info on each individual wheel sensor.

Demon
- 12th September 2011, 16:05
You are right when it comes to manufacturer specific codes. Just looking at ScanXL, there's different software add-ons by manufacturer. I have a Buick Rendezvous and it's staggerring how many more codes I can get to and the ABS ones that interested me are here (ScanXL links to Palmer for their references):

http://www.palmerperformance.com/support/supported_vehicles/gm_enhanced.php



Engine Parameters, 2100 parameters
Transmission Parameters, 491 parameters
Fuel Pump Parameters, 15 parameters
ABS Parameters, 304 parameters
Airbag Parameters, 69 parameters
Hybrid Battery Parameters, 56 parameters
Hybrid Powertrain Parameters, 186 parameters


And this is the subset that I probably have in my OBD-II reader:


Generic OBD-II Parameters, 229 parameters


I cannot see myself trying to reverse-engineer formulas for each individual sensor, the task is staggerring. The only good thing is that I have a Buick and my wife has a Pontiac, so the codes would work for both cars.

Robert

retepsnikrep
- 12th September 2011, 18:44
Thanks for the ideas so far.

Here is some more data for a few functions.

'MPI_MDL Temp C
'$9C $97 = 21C
'$88 $77 = 29C
'$83 $80 = 31C
'$6B $76 = 40C
'$67 $73 = 42C

'DC-DC Converter Temp C
'$97 $22 = 22C
'$7F $41 = 33C
'$77 $41 = 36C
'$76 $6F = 37C
'$72 $6F = 39C

'BAT_MDL Volts
'$91 $10 = 152V
'$95 $00 = 155V
'$98 $0C = 158V
'$9A $05 = 160V
'$9C $00 = 162V
'$9D $00 = 163V
'$9E $00 = 164V

'MPI_MDL Volts
'$97 $7F = 157V
'$98 $B2 = 158V
'$9B $99 = 162V
'$9C $80 = 163V

'MPI_MDL Amps
'$7F $9E = 2A
'$7C $9C = 8A
'$78 $9B = 16A
'$83 $9F = -6A
'$83 $9A = -6 to -8A

TORQUE NM
'$2D $5A = 0 NM
'$3A $5A = 8.4NM
'$41 $5A = 28 to 30 NM
'$2A $5A = -8.4 NM
'$29 $5A = -11.2 NM

Any further ideas?

retepsnikrep
- 13th September 2011, 08:57
Thanks for those ideas.

Some more resarch has revealed this data is all a single byte so I have deleted the second red herring byte that should make it a lot easier.

'MPI_MDL Temp C
'$9C = 21C
'$88 = 29C
'$83 = 31C
'$6B = 40C
'$67 = 42C

'DC-DC Converter Temp C
'$97 = 22C
'$7F = 33C
'$77 = 36C
'$76 = 37C
'$72 = 39C

'BAT_MDL Volts
'$91 = 152V
'$95 = 155V
'$98 = 158V
'$9A = 160V
'$9C = 162V
'$9D = 163V
'$9E = 164V

'MPI_MDL Volts
'$97 = 157V
'$98 = 158V
'$9B = 162V
'$9C = 163V

'MPI_MDL Amps
'$7F = 2A
'$7C = 8A
'$78 = 16A
'$83 = -6A

TORQUE NM
'$2D = 0 NM
'$3A = 8.4NM
'$41 = 28 to 30 NM
'$2A = -8.4 NM
'$29 = -11.2 NM

Any further ideas?