Pulse measurement

RobertN

Member
What is the best way to measure the time between 2 pulses, one each on an input? The pulse pair repetition rate is about 80Hz., with the time between pulses from near 0ms to near 12.5ms. The output would be a 20 - 30 Hz PWM proportional to the time between input pulses. For best response, the input measurement and output PWM must run concurrently. Also would like to use the smallest PICAXE possible.
Any discussion and suggestions appreciated.
 

alband

Senior Member
I'm not quite sure what the input will be.

You will have two separate pulses on two different pins?
These two pulses will repeat about 80 times per second?
And the gap between the pulses (the bit you want to measure?) will be <= 12.5ms?

If the above is correct, I would experiment with either interrupts ("Setint" command) or a combination of "pulsin" command (which can detect a rising or falling edge).

For the output, I would suggest "PWMOUT" command; it keeps a constant PWM going in the background during the other commands which sounds like what you need.
 

RobertN

Member
Alband, you stated the pulse conditions correctly.
The pulses can get very close together and in some cases one or both may not be present. I would be concerned interrupts may cause some unknown response if the pulses are too close for processing, or require a work around for missed or missing edges. Would an internal timer work?
Pulse in and pulse out can not function concurrently in the smallest PicAxe's, Is it possible with the larger ones?
 
Top