Best way to measure time between two pulses

hugoxp1

Member
Hi,

Can you help me decide what is the best way to have the time elapsed between two pulses (picaxe 20X2 or picaxe 18M2)?

Every pulse as a 1ms duration, and I think I can have up to 5 pulses per second.

I was considering to use the count command but if I use count C.1, 5000, w1, I only be able to know how mutch pulses occurred.

I think I will use setint and timer command, but will be the 1ms enough to trigger the interrupt? and can picaxe 20x2 or 18M2 deal with up to 5 interrupts per second?


thank you

(this post is related with: http://www.picaxeforum.co.uk/showthread.php?t=16542)
 

westaust55

Moderator
The pulsein command is also an option.
If the pulses are low to high (and back to low) the use the state keyword accordongly. If State is set to 0 then it will measure from a high to low transition and so measure the low period.

If the pulses are always exactly 1ms and you want leading edge to oleading edge then just add 1 msec.

You need to consider whether the pulses are relatively regularly spaced in time.
At 5 per second that is an average of 200 ms between each so a clock speed of 4MHz (with up to 600ms between two pulses) will be okay and tentatively 8MHz will also be okay unless (with up to 300ms between 2 consecutive pulses.
 
Top