Page 1 of 1

Decoding J1850 VPW signal

Posted: Fri Aug 23, 2024 5:13 am
by weinerschizel
Anybody have code from a microcontroller (and or circuit design) to decode J1850 VPW? I assume most elegant design is actually whatever the manufacturer uses... Has anybody reverse engineered that? Been searching it out but haven't found a solution I like. Most of the designs I've found purchase a stand alone preprogrammed microcontroller to do the decoding. Then that preprogrammed microcontroller is a black box with UART interface to computer system / software. I want to decode the signal with a microcontroller of my choosing though...

Forgive me if this is already posted. I searched the web and the forum here and good solution has eluded me. I see there's a few dedicated processors / microcontrollers for decoding OBDII data. Basically they program a PIC variant so it will operate using the ELM / J2534 interface (I'm not 100% sure of my nomenclature yet - industry standard OBDII interface).

I've currently got a P01 PCM hooked up to a power supply and can probe the J1850 data line. Signal is pretty straight forward. I'm feeding that signal into an ESP32 development board... and tripping an interrupt for a decoder routine (have to write decoder routine yet). However, my idea is to come up with a slick way that's not literally polling the line and calculating time periods for the pulses. There's got to be a better way, as that would be a waste of resources.

Backstory: I am assuming / think, there would be a signal from the radio head unit for player controls when AUX input is selected. I see there's a class 2 data line on head unit and want to see what data's coming out / to that. I need to get ahold of the player control signal (without opening the head unit up itself). System is a 2001 Chevy Tahoe. I'm designing a aftermarket Bluetooth interface where those player signals would be really helpful. Either way I want to develop some libraries for embedded controllers to decode OBDII data starting with J1850 VPW if not already done. Would be nice to have a built in bluetooth OBDII / J1850 adapter so I could read codes without having to constantly plug in the stupid dongle.

Re: Decoding J1850 VPW signal

Posted: Fri Aug 23, 2024 5:48 am
by ironduke
It's been years since I've messed with it, I used code from Michael Wolf, he wrote up some c or c++ code to mimic the elm322 using an atmega chip, I screwed around with it and got it working on an arduino, trying to find even my notes is not looking good.

Below is a couple files I found. One of them I think is just mimicking the elm322 and the other polls for coolant temp once a second. At one point I had one reading coolant temp, a/c request and vehicle speed and would turn on the cooling fans as needed for my 2004 S10 but I haven't found any further work. VPW is documented fairly well as far as timings and such if I remember right. It's not real easy and I haven't touched in arduino in a long time so no ideas if I'd even be able to help.
works_recieve.7z
(7.45 KiB) Downloaded 271 times
sketch_oct07a.7z
(4.27 KiB) Downloaded 245 times
sketch_oct14b.7z
(3.75 KiB) Downloaded 248 times
// Found some of my fan control code. no idea if this is a working version or not.

I'm not 100% positive but I believe this is with the atmega connected Directly to the vpw pin 2. The VPW schematics I had found and used did work but I found thru trial and error that the atmega could run it directly. Supposed to be higher voltage than 5 volts to talk but found out that it still works. I did have to reverse the output in the code for the communication pin. I don't remember which pin is which but the receive pin stayed the same and it was the transmit pin I reversed the output in the code. doing this directly is probably very iffy but I know it worked, lol.. Could probably do it with 1 pin but the code had 2 pins with the schematic so I was trying things and ran with it.

Did some googling and actually had a few posts hear already viewtopic.php?t=3456&start=60

Well damn.. Wonder how well documented this library is? https://www.arduino.cc/reference/en/lib ... r-library/

Re: Decoding J1850 VPW signal

Posted: Fri Aug 23, 2024 6:10 am
by weinerschizel
Wow super cool! Thanks for sharing. I'll look through this. Yesterday I spent several hours and got something going but then realized the bits were variable width *duh* so need to rewrite it. Will be awesome to see how you did it there. No worries on platform. Fiddled with most of them over the years.

Re: Decoding J1850 VPW signal

Posted: Fri Aug 23, 2024 11:13 am
by antus
There is another implementation for the open hardware allpro adapter in C here https://github.com/abhishekoct18/allpro ... dapter/obd

If you just want decode on a common arduino there is a project here: https://github.com/LegacyNsfw/ArduinoVpw

Re: Decoding J1850 VPW signal

Posted: Fri Aug 23, 2024 12:37 pm
by weinerschizel
AWESOME thanks @antus.