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.

navveed

New Member
hi,
i am new to PIC and dont know nothing about PIC so could you let me know how to use C-programming to programe PIC so as to convert the number of pulses to a unit of speed that is either Km/h or miles/h. these puses
Well the summary is somewhat like this, magnetic sensors to be used passing the pulses picked up from a rotating wheel and passing it to the counter and then finally to the display that is a seven segment display. In words it seems simple but I am confused in last part that is the display part. I have figured out what type of sensor to use, what type of counter to use and but the display will only show the number of pulses coming in but not the speed so is there any way that the pulses after being counted be converted in to a unit of speed either km/h or miles/h. well someone did suggested me to use PIC so if possible can you help me in this matter. Further more can you explain how will I be able to connect two 7-seg displays to show speed when it reaches above 9th integer.

If you have any suggestion for using a better sensor for counting the rotations of the wheel, please do mention. It should measure a bit high speed as it’s a car speedometer and should have a digital output. It should be a magnetic sensor using Halls effect.


thnkx

navveed@lycos.co.uk
 
The simplest way is to use a lookup table to convert the pulse count to speed. This table could convert binary to bcd conversion at the same lookup. You only need to have two tables, KPH and MPH. With a two digit display, you only need 100 items per table.

The mid range PIC has the capture/counter/pwm modules to count the pulses and to accurately fix the time duration.
 
thnkx for your reply, but can you please explain your suggastion and further more where can i find this lookup table to convert the pulse count to speed(any internet source).

and can you please specify what exact type of PIC to use.

thanx once again.
navveed@lycos.co.uk
 
You would not use a lookup table since this is a simple math operation. This can be done in assembly but you mention C which is simpler still.

There are 2 ways to get your reading. One is you use an external interrupt pin for taking in the pulses. Those interrupts advance a counter. You have a hardware timer set up to go off every half sec or sec and when it does it counts to see how many pulses have happened in that interval. The disadvantage is there may be poor resolution with this strategy, particularly at low pulse rates. It can be improved by extending the sample period. The screen update rate need not be the same as the sample period though. For example, you could collect pulses over a 2 sec interval while still updating the screen every half sec. In this case the code would save a history of how many counts it's seen over the last 4 of the 1/2-sec timer intervals and use that as the basis for the new reading.

The other is the Capture input. It's not available on all PICs. This copies a timer's value when the pulse comes in so it can calculate the time difference between any two pulses with good resolution, provided you have chosen your time periods wisely. The result is immediate and it does not require another timer resource on top of the one it is using as a counter. It does not work well if not all pulses have the same shape since the input may trigger at unpredictable points on the pulse thus rendering the time between them unreliable. Such a case might arise if you had 3 features on the shaft which trigger a Hall effect sensor and they are not all exactly 120 deg apart or even magnetically different from each other so they trigger the sensor at a slightly different phase. In this case taking 3 known sequential samples and averaging them will eliminate the problem.

In either case simple unsigned integer math will be used to generate mph or kph out of the reading.
 
Status
Not open for further replies.

Latest threads

Back
Top