![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
Hi iam working to make digital speedometer to my car the old speedo is down i want to make now digital onei 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 | |
| |
| | #2 |
|
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. | |
| |
| | #3 |
|
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." | |
| |
| | #4 | |
| Quote:
| ||
| |
| | #5 |
|
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. | |
| |
| | #6 |
|
hantto, Very nice job... Bravo Sir... Kind regards, Mike | |
| |
| | #7 | ||
| Quote:
Code: KM/h > hz 40 > 2000
__________________ 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." | |||
| |
| | #8 | |||
| Quote:
| ||||
| |
| | #9 |
|
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. | |
| |
| | #10 |
|
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." | |
| |
| | #11 |
|
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. | |
| |
| | #12 | |
| Quote:
| ||
| |
| | #13 |
|
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???
| |
| |
| | #14 |
|
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. | |
| |
|
| Tags |
| digital, speedometer |
| Thread Tools | |
| Display Modes | |
| |