Capturing a VPW Class2 Serial pulse
In attempting to make an Arduino interface I found a few interesting things. Perhaps these are obvious to many others but for me they weren't. The first thing to know is that the Pulse from the GM ECU (at least an older LS1 style ECU) is NOT square.
On this graph I put an orange line down low. If measuring the pulse widths here you can see the widths would not be per the specifications. See the lines I've added to the first pulse. In VPW the up AND down pulses are measured. That means that if not measuring at the mid point, the pulse going up will not measure the same length as the pulse coming down. This will give 2 different pulse widths measured for the physically same pulse width. On the diagram above I've added lines and labels to two short pulses. If measured at the orange line it produces two very different pulse widths for the same width pulse. One being up and the other being down.
The graph above is showing timer values of a data stream from an ECU as captured by an Arduino mega. Notice the double peak of times. This is due to not measuring the times at the mid point of the wave.
The upper limit for J1850 spec VPW is 4.25V and the Lower is 3.50V. To get rid of the double peak we need the upper and lower limits of the VPW spec to equal the upper and lower limits for the Arduino triggers. Reading the Arduino spec sheets it appears that the Arduino upper and lower trigger points should be 3.0V and 1.5V respectively. Measuring an Arduino mega using digital read we measured the upper and lower limits to be 2.18V and 2.16V. Interesting. We then tested again using interrupts. Interrupts is how we normally capture the wave. This resulted in 2.15 V upper and 2.12 lower. Specs are great but I'll go with the actual measurements.
Since we plan to capture the pulse using interrupts we will use the upper and lower voltages for that. We want to get the VPW trigger voltages down to the Arduino trigger voltages.
Or in other words:
4.25V --> 2.15 V
3.50V --> 2.12 V
A simple voltage divider could do this for us. Using a 10K resistor for the first resistor (from the high voltage side) the 2nd resistor would be 10.2K and 15.3K:
4.25V --> 2.15 V -->10.2K
3.50V --> 2.12 V -->15.3K
Having a separate circuit for both the up pulse and down pulse would be possible but is likely not needed. We could just average the 2 resistors. This gives us 12.7 K. Alternatively we could take the mid point voltage of the VPW (3.875V) and Arduno (2.135V) that gives is 12.25 K
4.25V --> 2.15 V -->10.2K
3.875V --> 2.135 V -->12.25K
3.50V --> 2.12 V -->15.3K
Theory is great and all but how does this all work out in real life? Below is a graph of the timings vs various resistors. 10K being the first resistor in the voltage divider. Then the resistor listed on the graph as the second.
The 22K resistor has a distinct double peak. the 13k, 12k and 11k results are all basically on top of each other. This all appears to match up closely with the theoretical.
In reality we started with the actual results and then worked backwards to explain why the 13k-11k resistor worked the best. Either way I suggest using 10k-12K voltage divider. So far it appears to work very well. If using a device with different toggle voltages recalculate in a similar manner what the resistor for those voltages should be.
No comments:
Post a Comment