Comparing two input pulses

Hi all,

I'm working on a project where I need to take two input pulses and calculate the difference in speed expressed as a percentage, something similar the the way ABS works, compares the speed of front and rear wheels based on pulses.

The pulses will be fairly frequent as the item being measured will be spinning somewhere in the realms of 4000RPM max, I suspect there will be ~16 pulses per revolution.

I suspect I will have to count the number of pulses over a given time (or since the last count) find the difference and convert it into a percentage.

I'm just not sure the best way to accomplish the last bit, any help/ideas would be appreciated :)

Hi Nath,

I’m a noob, but I’ve rigged a motor control circuit that used that Arduinos 2 available interrupt handlers to keep track of timing info on 2 separate motors. Each interrupt handler could set a last_pulse variable to the millis() after calculating the difference from the previous value.
Alternately, if you only need to poll the speed diff you could spin a little loop that would check the timing on each sensor.

I suggest an instrumented run where you can see your timing information using Serial.print statements (you may need to use faster than 9600 baud!) Look at the data and see if it varies much sample to sample, i.e what is the noise level. If the noise is low enough then it’s a simple task to take the ratio of t1/t2*100 for your percentage.