Log in

View Full Version : Problem converting data to what I need



oldcarguy85
- 23rd November 2007, 22:06
Hi all,
i am currently working on an LCD controller which interfaces with OBD2 vehicles (96-up). www.obd2lcd.com

Here is my problem. For the OBD2 interfacing, i am using a chip called an ELM323. My main controller is a pic16f877a. I send commands to the ELM chip and recieve the requested info back. The problem I am having, is how to format the data i am recieving back from the elm

let's take for example this scenario:

i send the String "010F" to the ELM
this is a request for intake air temperature

the ELM sends back the response "41 0F 3C"
the "3C" is the info i am interested in, as this represents the value i want

here is the problem. The ELM was intended to be used with terminal type programs on a computer, therefore, it sends its data as ASCII characters. I need a way to take the characters "3" and "C" and treat them as the hexadecimal value 3C so i can do some math on it and output it in Decimal format.

Any ideas?

thanks,
Jordan Cary

oldcarguy85
- 23rd November 2007, 22:43
I think i answered my own questions...

((char1-48) * 16) + (char2 -48)

thanks anyway! let me know if there is a flaw in that