View previous topic :: View next topic |
Author |
Message |
Matrixx
Joined: 30 Nov 2005 Posts: 158
|
Posted: Sun Jul 24, 2011 11:20 pm Post subject: OBDII J1850 VPW -Started Project- |
|
|
[July 24th, 2011]
Hello All
I have just started a some years idea about build a on-board LCD OBDII data display for my car. I had past experience on building an ALDL 8192 kbps interface for OBDI vehicles. Altough OBDI is kind simple, for OBDII VPW protocol the things are a little bit more complicated as it ueses variable pulse NRZ data format. Timings are crucial in this protocol running at 10.4 kbps.
For the project I will use my workhorse, a M2560 module. Because I have it and if project goes well, could be used on a less-resources smaller chip I guess.
By now, I have ready a LS1 ECU pulled from a same model-year-egine Junk car. I tested the ECu on my own car, it worked fine. This ECU will serve as workbench to test the project. I have salvaged the ECU connectors too, and the OBDII connector. Full wiring schematics comes from Mitchell On Demand.
Tomorrow I will try to listen to J1850 VPW bus and try to capture some packets. |
|
Back to top |
|
|
Matrixx
Joined: 30 Nov 2005 Posts: 158
|
Posted: Mon Jul 25, 2011 6:04 pm Post subject: |
|
|
I don know what happen but this editor keeps me scrolling up when I have >24 lines written.. I will have to post in fragments
[July 25th, 2011]
J1850 VPW uses single wire for bidirectional data interchange. It uses logical voltages as follows:
* Idles LOW at ground
* HIGH nominally 7V, Range 4.5V up to 20V
* LOW nominally < 3.5V, Range 3.5V to 0V
But HIGH and LOW does not mean "1" and "0" respectively. instead, J1850 VPW handles the "1" as LOW 128uS pulse and also HIGH 64uS pulse. Respectively, it handles "0" as LOW 64uS pulse and HIGH 128uS pulse.
So to summarize:
"1" = LOW 128uS = HIGH 64uS
"0" = LOW 64uS = HIGH 128uS
Don't be confused. I mean the "1" and "0" can be expressed two way each one. It depends on what state is the bus.
Example:
If last data bit was "1" (LOW 128uS) then if we need to represent another "1" we can not stay in the same state (LOW 128uS). We have to represent the new "1" as HIGH 64uS pulse. This way the zeros and ones are indicated for the duration and the state of the pulses,and the bus keeps changing between HIGH and LOW so data is never indicated by a double duration of a pulse.
Instead, the long duration pulses serves as data frame signaling. A HIGH >=200uS pulse indicates SOF (Start Of Frame) while a LOW >= 200uS pulse indicates EOF (End Of Frame).
The pulses widht have some tolerances, also the wave shape should be not squared to avoid EMI interference in the car. Specs recommend to "soften" the wave corners. Data is transmited as Bytes of 8 bit.
Another important thing is the bus manage Arbitration. The devices should check at every bit if another node is trying to talk, and implements a priority states.
For more information about the signaling take a look to:
http://download.intel.com/design/intarch/papers/j1850_wp.pdf |
|
Back to top |
|
|
Matrixx
Joined: 30 Nov 2005 Posts: 158
|
Posted: Mon Jul 25, 2011 6:15 pm Post subject: |
|
|
I don know what happen but this editor keeps me scrolling up when I have >24 lines written.. I will have to post in fragments
[July 25th 2011]
For the interest of this project I will not do wave shaping, and in this first part will not include arbitration too.
----
I forgot to mention in the first post for those new to this; this is an interface that plugs to the OBDII port from vehicle and only translate the J1850vpw data to 19200 kbps RS232 output, as is. At this time it only do that, listen to the bus and show the data. Is planned to be part of a onboard data display for GM vehicle.
---
************************************************
This part of project will listen to bus communications only.
in the second part I will implement interaction but I need
to develop some arbitration checking first
************************************************
Ok, too many words. Now to the stuff.
I borrowed a DSO (Digital Storage Oscilloscope) and try to get a waveform sample directly from my car. with only the key on "ACC" position, I find too many activity at the bus. Definitely there is a lot of data interchange as soon as you put the key to "ACC". As my DSO only capture 4096 samples I set it to 0.2mS and captured one complete Byte waveform. I would be liked to capture more packets but the DSO memory gets full with just one.
At home, I observed the nicely J1850 VPW waveform. I printed it and based on the specs I could easyly decode every bit on the paper. It was amazing to get
1110100011111111010000000000001111101101
this is 5 bytes: 11101000, 11111111, 01000000, 00000011, 11101101
To be short, in hex it will be:
E8 FF 40 03 ED
I exported the DSO data to Excel so you can take a look of my first waveform.
[img][/img]
Last edited by Matrixx on Wed Jul 27, 2011 1:19 pm; edited 1 time in total |
|
Back to top |
|
|
Matrixx
Joined: 30 Nov 2005 Posts: 158
|
Posted: Mon Jul 25, 2011 6:21 pm Post subject: |
|
|
I don know what happen but this editor keeps me scrolling up when I have >24 lines written.. I will have to post in fragments
[July 25th 2011]
Code: |
'IF SOF then start to read the bytes
If A > Sof_low And A < Sof_high Then
'Print "SOF!"
Bitcounter = 0 : Mstring = ""
Do
Do
'Wait for bit high
Loop Until Pinf.0 = 1
B = Timer1
Timer1 = 0
If B > Short_low And B < Short_high Then
' Print "0";
Incr Bitcounter
Mstring = Mstring + "0"
End If
If B > Wide_low And B < Wide_high Then
' Print "1";
Incr Bitcounter
Mstring = Mstring + "1"
End If
If Bitcounter = 8 Then
Bitcounter = 0
' Print ""
Incr Packetcount
Strarray(packetcount) = Mstring
Mstring = ""
End If
Do
'Wait for bit low
Loop Until Pinf.0 = 0
A = Timer1
Timer1 = 0
If A > Short_low And A < Short_high Then
' Print "1";
Incr Bitcounter
Mstring = Mstring + "1"
End If
If A > Wide_low And A < Wide_high Then
' Print "0";
Incr Bitcounter
Mstring = Mstring + "0"
End If
If Bitcounter = 8 Then
Bitcounter = 0
Incr Packetcount
Strarray(packetcount) = Mstring
Mstring = ""
End If
Timer3 = 0 : Start Timer3
Do
'Wait for bit high <--- Detect EOF
If Timer3 >= Sof_high Then 'I handle SOF and EOF timings with the same value
'too much time on low, EXIT!!
Mstring = ""
Bitcounter = 0
' Print "EOF!"
For I = 1 To Packetcount
' Print Strarray(i) ; " ";
Tmpbyte = Binval(strarray(i))
Print Hex(tmpbyte) ; " ";
Next I
Packetcount = 0
Print ""
Goto Startagain
End If
Loop Until Pinf.0 = 1
Stop Timer3
Loop
|
I setup a Proteus simulation to do the tests. I added a signal stimulus in Proteus that uses the HDL script, and put my hand-decoded single packet as bitbang timing. This way we can test the Proteus simulation with a "real" waveform every time, without physicall hardware. Well, at least only until the decoding procedure gets ready to catch the massive data at car environment
After some try and some cofees, I get to this stable and reliable code. I replaced the Bitwait states with Do-loop's in order to check for EOF timeout. Also I had to add an array to catch the bytes as printing every one get me some others lost (I have added serial-out buffering, that helped to reduce the lost packets a bit but not eliminate it..).
Using Bytes array it did the trick and I do not loose packets anymore.
In the zipped file you will find the Bascom code, the proteus simulation ready to run with a single J1850 VPW packet repeating 1 times by second. Also the excel data from my first captured packet waveform.
J1850VPW_2.bas will show data as binary + Hex.
For easy display I added also J1850VPW_2_ShowHex.bas that show in hex only.
Compile with constant Proteus = 1 to try the proteus simulation, otherwise
compile with constant Proteus = 0 and calculate the required timing values based on your xtall.
I have included a xcel file with timings and xtall input, it will provide you the timer values. change it in the real hardware #define.
Next day, I will add more decoding to the code, as verbose indication of header byte, and From/To addresing, Pysically/Functional, etc. I have some fun to do [/code] |
|
Back to top |
|
|
Matrixx
Joined: 30 Nov 2005 Posts: 158
|
Posted: Mon Jul 25, 2011 9:18 pm Post subject: |
|
|
I think what keeps me scrolling up the editor is something about the PC or the mouse. In a different PC this does not happen..
Ok here is a output from the interface. Now I'm programmed the M2560 and used with the real workbench PCM.
This data appears as soon as I put the "KEY" to "ACC" position. The PCM is stand-alone, no other modules are on the bus so I suspect is trying to handshake Air bag, ABS, Radio etc.
I show the result of both sourcecodes.
I need to look for the SAE HS3000 document, it will describe the message significance... anyone?
Quote: |
J1850VPW 1.34
01001000 48
11101010 EA
00010000 10
00001010 0A
00000000 00
01110010 72
11101000 E8
11111111 FF
00010000 10
00000011 03
10110011 B3
01001000 48
11101010 EA
00010000 10
00001010 0A
00000000 00
01110010 72
01001001 49
10010010 92
00010000 10
00000001 01
10111110 BE
01001001 49
10010010 92
00010000 10
00000001 01
10111110 BE
01001000 48
11101010 EA
00010000 10
00001010 0A
00000000 00
01110010 72
01001001 49
10010010 92
00010000 10
00000001 01
10111110 BE
|
Quote: |
J1850VPW 1.34
48 EA 10 0A 00 72
E8 FF 10 03 B3
48 EA 10 0A 00 72
49 92 10 01 BE
49 92 10 01 BE
48 EA 10 0A 00 72
49 92 10 01 BE
48 EA 10 0A 00 72
E8 FF 10 03 B3
49 92 10 01 BE
48 EA 10 0A 00 72
49 92 10 01 BE
48 EA 10 0A 00 72
49 92 10 01 BE
E8 FF 10 03 B3
48 EA 10 0A 00 72
49 92 10 01 BE
48 EA 10 0A 00 72
49 92 10 01 BE
48 EA 10 0A 00 72
E8 FF 10 03 B3
48 EA 10 0A 00 72
E8 FF 10 03 B3
after this line it keeps sending the same packet almost every second..
E8 FF 10 03 B3
E8 FF 10 03 B3
E8 FF 10 03 B3
|
|
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Tue Jul 26, 2011 2:17 am Post subject: |
|
|
I think you should start a blog on this project, then Bascomers who are interested can follow it, but not necessarily the rest of us. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Tue Jul 26, 2011 2:39 am Post subject: |
|
|
I am very interested in this project I would like to build a display for my GM truck. It is good to see some one that will put the code there for others to use as most others who have done this keep it to themselves. I think there will be many who will be interested in this (very many) it costs big money to get units (cost me $700 AU for interface to PC) so intrest will be high.
Matrixx I have a number of 128x64 KS0108 displays that would look good on the dasboard dispalying info if you were not so far away I would send you one (would get smashed in the post) I will follow with great interest.
Why not move this to Bascom Related |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Tue Jul 26, 2011 9:49 am Post subject: |
|
|
Very interesting indeed. It reads like a blog and i have no problems with that. It is a nice idea .
But it might be better to move this to a new forum.
I will ask Tomi to create a new forum where one can blog/interact on a project. _________________ Mark |
|
Back to top |
|
|
Matrixx
Joined: 30 Nov 2005 Posts: 158
|
Posted: Tue Jul 26, 2011 2:41 pm Post subject: |
|
|
Hello Mark, Adrian
Yes I was tough of making a blog too. I have never created one but maybe is good time to start.
I think I'll keep your advice
Paulvk, thank you for your offer but I think we're pretty far away
I have done some projects with T6963C based lcds. I haven't try with KS0108's.
I'm just concentrating info and data, examples from some others interested on this theme. But most of the projects I have found are in C and I'm not good reading C. As I have done PCM repair for some years I find interesting to do something with the data.
Michael from Mictronics has been done an interface, compatible with many software that uses ELM chips.
In a first try, I had the intention of translate his code but I have started from scratch. I thing I will use his example as a guide at some point.
http://www.mictronics.de/projects/j1850-vpw-interface/
Another great guy that have done **a lot** of research is Paul Blackmore, that now sells EFILive. He has published code in C very well explained.
Thanks for moving the post, in fact I'm surprised you open a new section
I will keep the research, but as Adrian say maybe it will better to do in a blog
Could you recommend some hosting with free service and no Ads ? |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Tue Jul 26, 2011 3:42 pm Post subject: |
|
|
I want to do the same but with CAN but without special chips.
I collected hardware and a lot of info. Maybe i will start a blog myself here _________________ Mark |
|
Back to top |
|
|
Matrixx
Joined: 30 Nov 2005 Posts: 158
|
Posted: Tue Jul 26, 2011 5:46 pm Post subject: |
|
|
I'm not new to the internet but belive or not I did not known the blog concept very well. After read a bit more I find a bit embarrasing to post here all the sucessive things about the project.
(blogs are preferently for personal every day people life..)
I prefer the idea of a web page. I have setup a free account to ZobyHost. Will populate page content to have the project availabe.
Anyway I think maybe I can publish news or important things about the project here in this new opened section.
|
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Tue Jul 26, 2011 9:11 pm Post subject: |
|
|
I am not new either and it seems i do not understand the concept as well
I did not knew that the blog was personal.
Then maybe i should call it Project Log ?
Basicly the idea is the same : but instead of personal, it is just about the project. _________________ Mark |
|
Back to top |
|
|
Matrixx
Joined: 30 Nov 2005 Posts: 158
|
Posted: Tue Jul 26, 2011 9:27 pm Post subject: |
|
|
hey, I think a forum is a forum. Thinking about, it is likely the place to write questions and look for answers. This forum is great as is, I think it does not need any kind of blog or wheteaver
An yes... I'm still resisting to facebook and some others no matter my wife keeps inviting me |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Tue Jul 26, 2011 11:49 pm Post subject: |
|
|
Blogs do not have to be just personal, but its true that the owner has to give permission for anyone else to post. Marks suggestion of a new forum section is at least as good, and it means that other Bascomers can dip into it easily. Would be good to have links to what other outside people are doing too. Sometimes a piece of code in C or whatever can lead to a whole new way of looking at a problem. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Wed Jul 27, 2011 12:33 am Post subject: |
|
|
Yes blogs are very much one way and do not give the oportunity to interact which this section will give also its a lot of work to run an interactive forum/blog so we must give a big thanks to those who look after this one!!!! Also having all of the resource (bascom projects)in one place I think is the best way. |
|
Back to top |
|
|
|