Hey guys, I am trying to make a speedometer that measures the rpm of a wheel.
Basically, I will be getting a pulse each time a spoke of the wheel passes a sensor.
I want to measure the time interval between each pulse but I do not know how to do so as I am unfamiliar with the software.
How can I continuously measure the time difference between pulses?
Any help is greatly appreciated.
mistergiggle:
Hey guys, I am trying to make a speedometer that measures the rpm of a wheel.
Basically, I will be getting a pulse each time a spoke of the wheel passes a sensor.
I want to measure the time interval between each pulse but I do not know how to do so as I am unfamiliar with the software.
How can I continuously measure the time difference between pulses?
Any help is greatly appreciated.
You don't. You count the number of pulses in one minute and that is the RPM. Or you can count the pulses for 1 second and multiply that number by 60.
Paul
mistergiggle:
Hey guys, I am trying to make a speedometer that measures the rpm of a wheel.
Basically, I will be getting a pulse each time a spoke of the wheel passes a sensor.
I want to measure the time interval between each pulse but I do not know how to do so as I am unfamiliar with the software.
How can I continuously measure the time difference between pulses?
Any help is greatly appreciated.
You can but each time there is some + or -, you know? The thing to watch out for is adding those to get a whole time, the small differences can add up. Still from one spoke to the next (assuming even spokes or corrective code) you can get speed to within 1 kph or mph.
Arduino has a micros() function that returns an unsigned long value of microseconds since startup to 4 microsecond granularity, the low 2 bits always zero.
To get the elapsed time between events we record the start and end times and then subtract the start time from the end time. The difference will be elapsed time. This method is only good for about 70 minutes using micros(). Using millis() the max interval is 49.7-some days but for short timing, millis() is not accurate and you are timing short events.
If I have a start time and I want to know if 1 second has passed since then;
if ( micros() - start >= 1000000 )
{
// 1 second or more has passed, do the thing
}
All timer variables should be unsigned integers, it is unsigned subtraction that makes this always work even across rollover it always works.
Your code has to be fast enough to catch these events. How many spokes (evenly spaced?) and what max rpm are you working with? Chances are you can work with how long a spoke is sensed.
Sorry, I missed the "spoke" reference in the original post. But the same thing applies. Easier to count the spokes than to measure the time between them.
Paul