Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Speedometer (planning)

Status
Not open for further replies.

Clayton

New Member
This is just the highlevel planning I'm using to design my speedometer based on a vehicle speed signal output. If you see any glaring or enormous errors or a better way to do this, let me know. My chip of choice, since its what I have, is a 16F628A. A 2007 Ford Crown Victoria has a vss wire in easy access that is not being used so that will be used.

My best information, so far, is that the vss either pulses 4000 or 8000 times per mile. Based on 1hour = 3600sec, the vss would pulse once at .9sec (3600/4000) Therefore, if my final output were simply a count of pulses until .9sec I should not need to do any math, just put the number on the lcd display. If it were to pulse 8k/sec then just divide the number by 2.

.9seconds, though, is too slow of a refresh rate. I was thinking of having 9 counters. The idea being, start each one .1sec later than the prior one. When the first gets to .9sec take it out, manipulate it, display it, clear it, go to the next one. This will assure that the counter being manipulated is the counter of the last .9sec but will be refreshed every .1sec. The vss would be on the int pin.

Again this is just thinking right now, but I figured I'd run it by you guys and see what you think or maybe suggest.
 
There are two ways to do this.

One is to count the pulses (use RB0 and an interrupt on INT0 to detect the pulses) in a preset time. This time is easily and consistently definable if you use one of the timers with an appropriate prescaler and an interrupt.

So ..........

Pulse -> jump to interrupt
increase counter
check if counter has overflowed - if it has then you are either going too slowly or standing still.
return from interrupt
Timer interrupt
Load counter into a temp counter variable
reset counter
return from interrupt
while everything else is still going on then calculate the MPH from the temp counter variable - this will be pulses/time

The other way is to set the prescaler on the timer to a value which will cover the time period between your desired pulses. Every time a pulse is detected you load the timer value into a temp register, reset the timer and work out your speed by the time interval between the pulses.

I have a commercial product which uses both these methods and the timer interval allows for rapid updating while the pulse counts allow for the accuracy.
 
I am looking for the pulses/time, I believe. The reason for the 9 counters is to allow a suitibly long samply time, 0.9sec with a decent refresh time of 0.1 seconds.

Is there a better way of accomplishing this goal, or am I on the right track?
 
Slight omission in your "spec"...
While there may be 4000 pulses per mile, you seem to have missed the fact that the pulse train will speed up as the car goes faster... That's why most commercial digital speedos dont actually start reading until you get above walking speed.

1mph = 0.9sec between pulses
5mph = 0.18sec
30mph = 0.03sec etc etc etc...

Your best option would be to set a timer, and count the pulses in a prescribed amount of time, say 0.5 sec.. The low end resolution will be crap, but with increasing speed, the accuracy will go up...

BTW, I am also working on a speedo, but mine is based on GPS.. Completely portable, and useable on bikes, skateboards, skis, freefall etc etc etc....

Hope this helps...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top