AVR to Arduino - VPW

Ecu Hardware Modifications
User avatar
Posts: 4986
Joined: Sun Mar 01, 2009 2:54 pm
Location: Perth, WA

Re: AVR to Arduino - VPW

Postby VL400 » Tue Aug 12, 2014 10:18 pm

Check out the ELM datasheet, has the suggest circuit showing how the bus voltage is managed.

As for your scopes, check out the Rigol DS1052E/DS1102E. Great value and runs rings around the ones you listed, but is more expensive. A logic analyser with serial decode will ultimately be more useful for this project though.

User avatar
Posts: 1801
Joined: Thu May 17, 2012 8:53 pm
Location: WA

Re: AVR to Arduino - VPW

Postby Tazzi » Wed Aug 13, 2014 1:26 am

VL400 wrote:Check out the ELM datasheet, has the suggest circuit showing how the bus voltage is managed.

As for your scopes, check out the Rigol DS1052E/DS1102E. Great value and runs rings around the ones you listed, but is more expensive. A logic analyser with serial decode will ultimately be more useful for this project though.

Sooo something like this: Logic16 - USB Logic Analyzer
Or Iv always wanted an excuse to get a saleae logic analyzer: Logic pro 8 ($150 from sparkfun)

Obviously.. both are.. getting expensive.. especially considering the open board logic sniffer for $60, but after reading the amount of comments of people having issues.. Im going to steer clear of that one.



Back to the main aim.. So I now offically hate timers, prescalers and interrupts :evil: . Bugger them... causing more issues then good!
So after all this pain in thinking I need to sort the crystal out ect... seems I overlooked a "relatively" new function micros().. and its great addition delayMicroseconds(). This essentially removes all needs for timers as we can manually fine the SOF,data and EOF. Micros seems to output very accurately which seems to be also supported by fellow arduino gurus.

I wacked a quick piece of code together to identify the SOF (start of frame) from the ELM327. My timing values are based off of those produced by Michael example.. where RX_SOF_MIN = 163 and RX_SOF_MAX = 239. I made a very rough menu to select read and write.. once read is selected, the arduino will poll the bus until bus becomes active (high) due to SOF. From here, it takes initial micros reading and then keeps polling BUS until it becomes passive (Low) indicating SOF section has ended. At this point, another micros reading is taken and the difference between start and end are taken. Here is a little example:

Code: Select all
Please select action:
    1. Read All Data on VPW BUS
    2. Write Data to VPW BUS
Read Data Selected
Initializing Read...
Checking Bus State...
SOF = 200us


After doing multiple readings, it seems the SOF varies between 190 - 210, but for safety I will maintain Micheals timing values. So now the SOF can be identified... now to move onto obtaining data and finally EOF.


Oh, and Arduinos Serial is interrupt driven, thus cannot (from what I have found) make a serial.received interrupt. This feature would have been nice, but adding a few checkpoints throughout the code isnt an issue since it would be found in a matter of microseconds.. so it will be manually polled like this: if(Serial.available() > 0) //Do This...;

User avatar
Posts: 1801
Joined: Thu May 17, 2012 8:53 pm
Location: WA

Re: AVR to Arduino - VPW

Postby Tazzi » Wed Aug 13, 2014 1:29 am

And before I forget to note it down (and I will forget!). Utilizing the standard digitalRead() and digitalWrite() is too slow. at roughly 4.1us, this will significantly affect the messages as they are very time sensitive. Thus direct port manipulation must be engaged.. cuts down the time to 0.41us (or less I think).

Finally its all making sense...kinda.

User avatar
Posts: 1801
Joined: Thu May 17, 2012 8:53 pm
Location: WA

Re: AVR to Arduino - VPW

Postby Tazzi » Wed Aug 13, 2014 3:39 am

3hours later.. and I think iv got it reading :thumbup: . I can send multiple messages from the ELM and successfully grab them on the arduino Mega.
On a side note.. its extremely hard to perform debugging on the arduino as any writing to Serial causes significant delays in the timing.. Anyone have ideas on other 'faster' ways to communicate? Or is it best to define some errors/statistics that will display once activity is completed.. which is what Im currently doing back is annoying filtering the data.

Eh.. I think that is enough for today anyways.. will start adding major functionality tomorrow.
Code: Select all
Please select action:
    1. Read All Data on VPW BUS
    2. Write Data to VPW BUS
Read Data Selected
Initializing Read...
Checking Bus State...
Array completed
6C,F1,10,6A,FE,0,0,0,0,20,0,19

User avatar
Posts: 1801
Joined: Thu May 17, 2012 8:53 pm
Location: WA

Re: AVR to Arduino - VPW

Postby Tazzi » Wed Aug 13, 2014 3:04 pm

Alright below is the wiring diagram for the elm327.. the bottom left quadrant contains the J1850 (VPW) section.. but for the life of me I dont understand what is happening there. Theres so many transistors and resistors its confusing!
Image

Is it possible that the 5v from the arduino mega is *enough* to count as a high along the bus? I know I shouldn't be slack..
I like to simplify things.. heres something I prepared earilier:
elm327circuit.jpg
elm327circuit.jpg (154.31 KiB) Viewed 4457 times

U1=ELM327
U2=MCP2551
U3=78L05(5V, 100mA regulator)
U4=317L (adj. 100 mA regulator)
Q1=2N3904(NPN Transistor)
Q2=2N3906(PNP Transistor)
D2=1N4148 Diode
(Taken from http://pinoutsguide.com/CarElectronics/ ... nout.shtml)

Looking at PIN4, look like it is what drives the bus high. So when PIN4 goes high, this will cause the NPN transistor (Q1) to connect up allow a gound connection causing the PNP transistor (Q2) to connect up passing the 7.5v connection (I think!), So no addition inversion is needed (Sending high on pin 4 results in high on BUS).

From sparkfun: https://cdn.sparkfun.com/assets/learn_t ... M327DS.pdf
So PIN 3 controls the bus voltage.. which really.. is unnecessary on our behalf. We can toss PIN3 and keep the voltage constant.. So something like this (also taken from above link)
VPW_Only.PNG
VPW_Only.PNG (23.13 KiB) Viewed 4457 times

Where our 78L08 is an 8v regulator. So after going through all that... Im only left with this 10K ohm resistor.. which I guess connects the 8v line to ground when PIN4 drives high.. so it must slightly lower the 8v to 7.5v? (Is that right?) :thumbup:

User avatar
Posts: 1801
Joined: Thu May 17, 2012 8:53 pm
Location: WA

Re: AVR to Arduino - VPW

Postby Tazzi » Wed Aug 13, 2014 5:36 pm

Good old jaycar has all the parts needed... except the 8v regulator... I could make do with a 5v regulator + two 1.5v batteries maybe? nice little dodgy hackery. :lol:
I also got the big adjustable voltage regulator I can use.. although the readings are analogue and not very exact.. so that may be a last resort. Hope the aussie seller for the 8v reg will ship quickly.

Next up, refining the write procedure and testing it out with the elm327.

User avatar
Posts: 1801
Joined: Thu May 17, 2012 8:53 pm
Location: WA

Re: AVR to Arduino - VPW

Postby Tazzi » Fri Aug 15, 2014 6:14 pm

So the ELM cable can see the responses from the VPWduino (Yes.. Im giving it a name). And the received frames are correct! woop woop!. But, can't try in car or on a proper LS1 pcm yet.. even then I'd prefer to have it all setup correctly with the 8v regulator.
For shits and gigs, iv chucked a "rough" 4x VPW mode in.. but have no clue how to test it out! Might be time for an AVT cable finally, or logic analyser.. or oscilloscope! Id imagine all 3 can be used to monitor the bus and see whats going on.

Im going to try and follow michaels foot steps and get the module elm327 compatible. But hopefully with 8k sram (on the mega) or 2k sram (on a mini), we wont be seeing any buffer full messages.
What confuses me though.. is that if we are reading frames at a microsecond level.. wouldnt this mean that the time required to send over serial (to the PC) could cuase us to miss frames on the bus? so... sending 1 byte at 115200baud = 1 / 115200 = 8.68x10^-6 seconds = 8.68microseconds. Therefore a 12frame message = 104.16 microseconds.. so 1/10th of a millisecond.

Soooo whats the normal delay between frames on the VPW line? Based off of my ELM327 software development saga.. looks like theres plenty of time between frames on the bus.. even when doing PDID requests which spams out requests. Looks like a good 200ms of space... unless anyone else knows different?
[09:06:18:120] Received: 6C 10 F1 2C FE 4B 12 55 11 92 F3
[09:06:18:285] Received: 6C 10 F1 2C FE 62 00 05 11 6F AB
[09:06:18:449] Received: 6C 10 F1 2C FE 71 00 0F FF FF A6
[09:06:18:613] Received: 6C 10 F1 2C FD 4B 00 0B 00 10 AE
[09:06:18:776] Received: 6C 10 F1 2C FD 63 12 50 19 70 D4
[09:06:18:939] Received: 6C 10 F1 2C FC 4A 11 9D 00 11 FA
[09:06:19:102] Received: 6C 10 F1 2C FC 5A 11 43 00 0E D3

Site Admin
User avatar
Posts: 5523
Joined: Sat Feb 28, 2009 8:34 pm

Re: AVR to Arduino - VPW

Postby antus » Sat Aug 16, 2014 3:07 pm

Im not sure about timing as my work has been with the avt which handles collisions and timings for me. But I can tell you the original elm circuit has 4 pins because its used to create a voltage step to round off the corners of the square wave (much like how non-pure sine wave power inverters work). Its to prevent some of the harmonics on the bus generated with a square wave.
Have you read the FAQ? For lots of information and links to significant threads see here: viewtopic.php?f=7&t=1396

User avatar
Posts: 4986
Joined: Sun Mar 01, 2009 2:54 pm
Location: Perth, WA

Re: AVR to Arduino - VPW

Postby VL400 » Sat Aug 16, 2014 5:02 pm

The different voltage options are not for pulse shaping, its for VPW or PWM (Ford). VPW is 8V while PWM is 5V.

Site Admin
User avatar
Posts: 5523
Joined: Sat Feb 28, 2009 8:34 pm

Re: AVR to Arduino - VPW

Postby antus » Sat Aug 16, 2014 5:53 pm

Ahh thanks for the heads up :)
Have you read the FAQ? For lots of information and links to significant threads see here: viewtopic.php?f=7&t=1396

PreviousNext

Return to Hardware Modification and Development

Who is online

Users browsing this forum: No registered users and 3 guests