Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 30th April 2006, 11:32 AM   #1
Default Digital Speedometer .

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
altra22 is offline  
Old 30th April 2006, 12:39 PM   #2
Default

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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 2nd May 2006, 07:52 AM   #3
Default

or count the pulses per second...
__________________
Gods own Country
Incredible !ndia

www.flickr.com/photos/_akg/

"Give a man a fish, and he will eat for a day. Teach that man to fish, and he will eat for a lifetime."
akg is offline  
Old 2nd May 2006, 09:17 AM   #4
Default

Quote:
Originally Posted by akg
or count the pulses per second...
Not much use for a speedometer, the pulses are of too low a frequency.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 2nd May 2006, 09:48 AM   #5
Default

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.
Attached Thumbnails
Digital Speedometer .-shem.png   Digital Speedometer .-mittar.jpg  
Attached Files
File Type: txt saab_nopmit.txt (12.3 KB, 313 views)
hantto is offline  
Old 2nd May 2006, 10:01 AM   #6
Default

hantto,

Very nice job... Bravo Sir...

Kind regards, Mike
Mike, K8LH is offline  
Old 2nd May 2006, 10:47 AM   #7
Default

Quote:
Originally Posted by Nigel Goodwin
Quote:
Originally Posted by akg
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 .
__________________
Gods own Country
Incredible !ndia

www.flickr.com/photos/_akg/

"Give a man a fish, and he will eat for a day. Teach that man to fish, and he will eat for a lifetime."
akg is offline  
Old 2nd May 2006, 10:55 AM   #8
Default

Quote:
Originally Posted by akg
Quote:
Originally Posted by Nigel Goodwin
Quote:
Originally Posted by akg
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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 3rd May 2006, 05:21 PM   #9
Default

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.
philba is offline  
Old 4th May 2006, 06:43 AM   #10
Default

4% error at 1kmph is negligible ..and who cares for it..? also the i meant a const period (not to be 1 sec) it could be 250ms interval too..
__________________
Gods own Country
Incredible !ndia

www.flickr.com/photos/_akg/

"Give a man a fish, and he will eat for a day. Teach that man to fish, and he will eat for a lifetime."
akg is offline  
Old 9th May 2006, 08:32 AM   #11
Default

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 by altra22; 9th May 2006 at 08:37 AM.
altra22 is offline  
Old 9th May 2006, 09:01 AM   #12
Default

Quote:
Originally Posted by altra22
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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 19th May 2006, 01:58 AM   #13
Default

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???
mataston is offline  
Old 19th May 2006, 06:48 AM   #14
Default 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.
Attached Files
File Type: pdf an27701_hallsensorapplicationguide.pdf (791.7 KB, 312 views)
mcs51mc is offline  
Reply

Tags
digital, speedometer

Thread Tools
Display Modes




All times are GMT. The time now is 08:18 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker