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.

Digital Speedometer .

Status
Not open for further replies.

altra22

New Member
Hi iam working to make digital speedometer to my car
the old speedo is down :) i want to make now digital one
i use PIC16F84A i got readings from digital pulse wire (frequency) i want to transform it to pic then to 7segment the problem is how to read that pulses i read that you must use a regular counter and others say you must use gates !
guys iam a programmer not electronics engineer :) and iam new to pics :)

please help me :) i want to understand how to read frequency to pic and do some calculations from Hz to Km/h and i will provide the readings :

Code:
KM/h > hz
40 > 2000
.
.
.
80 > 6000
90 > 7000
100 > 8000
110 > 9000
120 > 10000
 
As usual, I would suggest using a more modern device, rather than the long obselete 16F84?, but if you've already got one - fair enough.

All you need to provide the PIC is a squarewave pulse from the sensor, then simple measure it's frequency - or, more likely, it's period - the time between two pulses. From this it's simple to calculate the speed - assuming you know the relationship between the pulses and speed?.

You can do this is many ways, you might check the really old MicroChip application for a frequency counter, or the magazine EPE have done a number of projects like this (check PIC Agoras, which is a speedometer for any wheeled device).

But essentially, wait for the a start of a pulse, then start counting - while counting check for the start of the next pulse - when you find the start of the next pulse stop counting. The counter now contains a value representing the period of the incoming frequency - simple maths can convert that to frequency or speed.
 
I did exactly this about six months ago. I wanted it to be SIMPLE. I used a 16F628, you could mod it to work with 16F84, but it doesn't have the timer1 module I used. I used interrupts to update the multiplexed 7-seg displays and Timer1 to count pulses.

Then what I did was take a GPS receiver and drove 100km/h according to it and adjusted the counting delay so that it would show the correct value. I ended up with a 1.5 sek delay, but that doesn't disturb me. I'm patient enough to wait 1.5 seks for the next update.

My meeters pointer got stuck so that it didn't move anywhere, but otherwise it was ok. So I removed the whole "display" part of my meter and left the spinning magnet where it was (Old meters have a spinning magnet inside them, that moves the pointer when it is turned). Next I put a magnetic sensor fom an old dc fan next to it, and voila I had my signal source. It gives 4 pulses per revolution.

You'll notice that the shematic isn't exactly what's on the PCB board because I did some fine tuning after I already had made the board.

I attached some pictures and the software below. Yes I know it isn't the best way to do it, but I built myself a very accurate speedometer that works, that's all I need.

Maybe this will give you some ideas.
 

Attachments

  • saab_nopmit.txt
    12.3 KB · Views: 1,144
  • mittar.jpg
    mittar.jpg
    105.7 KB · Views: 1,451
  • shem.png
    shem.png
    28.1 KB · Views: 2,416
akg said:
Nigel Goodwin said:
akg said:
or count the pulses per second...

Not much use for a speedometer, the pulses are of too low a frequency.
i didn't understand ..

Code:
KM/h > hz
40 > 2000
he gets 2000 0-1 (or 1-0) transitions per sec .

As the speed lowers the pulse frequency obviously lowers, so by having a fixed sample time the resolution gets worse. By measuring the period between pulses you get good resolution at all speeds, and faster updates.
 
lets see, assuming it is linear, 1 Km/H is 50 hz. assuming worst case (starting just after a pulse and ending just before a pulse), that would be 4% error.

Now considering that 10 Km/H is probably the lowest speed you care about about, that is .4% error. I'm not sure that's much of an issue.

I think the better argument is update speed. I'd want something like 200-400 mS update frequency. That would appear to be instantaneous. A 1 second delay would drive me crazy. You could use table look-up if the math is an issue.
 
Thanks guys
but Nigel ...
"By measuring the period between pulses"
i can't figure it out while the car is moving according to the acceleration of car :) please tell me how to do that
thanks

hantto did you used a schmitt trigger in your project ?
 
Last edited:
altra22 said:
Thanks guys
but Nigel ...
"By measuring the period between pulses"
i can't figure it out while the car is moving according to the acceleration of car :) please tell me how to do that
thanks

Simply measure the period between two pulses, acceleration is irrelevent, a speedo shows the instantaneous speed.
 
hantto what did you use as a pulse generator ??? for your electronic speedo?? will a magnet and a reed switch work, or magnet and hall efect device???
 
Hall sensor

You want to know more about pulse generation by magnet and Hall sensors, read this app note.

BTW Nigel is right, measuring the time between two edges of the pulses is much better than couting pulses in 1 (or more) seconds.
 

Attachments

  • an27701_hallsensorapplicationguide.pdf
    791.7 KB · Views: 856
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top