VSS Code
-
- Posts: 9
- Joined: Tue Oct 04, 2011 1:21 pm
- cars: Pontiac Fiero GT
- Location: Walden, Colorado United States
VSS Code
Hello, I have been lurking for a few months as well as using the 12P code in a Pontiac Fiero and I now have a question.
How does the code go about calculating the vehicle speed and if someone could sum this up . I am making a digital instrument cluster and would like to know how GM wrote their code. So far I am using a count over a period of time but the refresh rate is to slow for a digital speedometer as well as jumps around from lack of resolution.
How does the code go about calculating the vehicle speed and if someone could sum this up . I am making a digital instrument cluster and would like to know how GM wrote their code. So far I am using a count over a period of time but the refresh rate is to slow for a digital speedometer as well as jumps around from lack of resolution.
Re: VSS Code
If you're making a digital cluster, why not plug in to the ALDL stream and get all the data from there?
That would save a lot of the calculations, and it's all over a single wire.
That would save a lot of the calculations, and it's all over a single wire.
- VL400
- Posts: 4991
- Joined: Sun Mar 01, 2009 2:54 pm
- cars: VL Calais and Toyota Landcruiser. Plus some toys :)
- Location: Perth, WA
- Contact:
Re: VSS Code
Oher than what festy said, which is by far the best option for a dash, just use a capture channel on a micro. You then get instant updates on every VSS pulse. The capture channel gives you a time between pulses so can work out speed from that, its also much more accurate than the number of pulses over a fixed time period. GM uses a variation of the capture method.
The VSS filtering is also done like antus mentioned, its a first order lag filter which most items use.
The VSS filtering is also done like antus mentioned, its a first order lag filter which most items use.
- antus
- Site Admin
- Posts: 8253
- Joined: Sat Feb 28, 2009 8:34 pm
- cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B - Contact:
Re: VSS Code
Sorry, I deleted my post as I thought your answer was more accurate before I realised you mentioned mine! So yeah, inputs are read and filtered (averaged) by only allowing small changes to the previous value rather than taking the new value as an absolute. This way if you get a fram thats miles out in one direction the value wont be too far wrong, and the next value will also be out in the other direction, so overall you wont see the huge jumps when it adjusts a little up and a little down.
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
-
- Posts: 9
- Joined: Tue Oct 04, 2011 1:21 pm
- cars: Pontiac Fiero GT
- Location: Walden, Colorado United States
Re: VSS Code
Averaging is taken care of through software by taking several samples and doing the math. I am working with a controller that is operating at 80MHz if this helps any. So what you are saying is that measuring the time between pulses would be the best way to go. Now I need to go about figuring out the formula to get speed from the time period. Any pointers? I am drawing a blank at this time, being up over 24 hrs doesn't help any.
Forgot to mention that connecting to the aldl is not an option due to the plethora of engine and controller choices out there. Besides, a 77 FJ40 landcruiser does not have an aldl. Maybe later though.
Forgot to mention that connecting to the aldl is not an option due to the plethora of engine and controller choices out there. Besides, a 77 FJ40 landcruiser does not have an aldl. Maybe later though.
- antus
- Site Admin
- Posts: 8253
- Joined: Sat Feb 28, 2009 8:34 pm
- cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B - Contact:
Re: VSS Code
Guess a value (say 2000 PPK or PPM - pulses per km, or mile) and observe the results and compare to speed from a GPS. Then work out the % you are out at a given speed, and adjust your calculation by the same percentage.
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
-
- Posts: 9
- Joined: Tue Oct 04, 2011 1:21 pm
- cars: Pontiac Fiero GT
- Location: Walden, Colorado United States
Re: VSS Code
Simple enough.
Re: VSS Code
If there's say 1250 pulses per kilometer, then the distance travelled per pulse would be 80cm. So you know how far was travelled, and how long it took to travel that distance.chetw77cruiser wrote: Now I need to go about figuring out the formula to get speed from the time period. Any pointers? I am drawing a blank at this time, being up over 24 hrs doesn't help any.
So if the time between pulses is 0.05s, then 1/0.05 * 80 = 1600cm/sec, or 57.6km/h
-
- Posts: 9
- Joined: Tue Oct 04, 2011 1:21 pm
- cars: Pontiac Fiero GT
- Location: Walden, Colorado United States
Re: VSS Code
[/quote]
If there's say 1250 pulses per kilometer, then the distance travelled per pulse would be 80cm. So you know how far was travelled, and how long it took to travel that distance.
So if the time between pulses is 0.05s, then 1/0.05 * 80 = 1600cm/sec, or 57.6km/h[/quote]
The math is sound, but the problem I am running into is that my micro does not do floating point math without alot of extra code. I will let you know what I come up with. Curious what the GM code for this looks like, but assembly is one of my weak points.
If there's say 1250 pulses per kilometer, then the distance travelled per pulse would be 80cm. So you know how far was travelled, and how long it took to travel that distance.
So if the time between pulses is 0.05s, then 1/0.05 * 80 = 1600cm/sec, or 57.6km/h[/quote]
The math is sound, but the problem I am running into is that my micro does not do floating point math without alot of extra code. I will let you know what I come up with. Curious what the GM code for this looks like, but assembly is one of my weak points.
Re: VSS Code
without floating point you could do it as 1000/50 * 80 * 36 / 100 but you'll lose a bit of accuracy with rounding the divisions if the result isn't an integer.