Shop OBEX P1 Docs P2 Docs Learn Events
Pulse measurement, timing — Parallax Forums

Pulse measurement, timing

jeffjohnvoljeffjohnvol Posts: 197
edited 2007-04-19 01:27 in BASIC Stamp
I have a need to count pulses and the time in between. I would be using the falling edge of the pulse, and plan on using the BS2px stamp. I don't care about the width of each pulse, just the time in between falling edges.

I don't believe I can't use the PULSIN command because the pulse width may be quite long, especially if the rotary position magnet finishes up on the sensor. I understand that the PULSIN is limited to 0.13 seconds maximum pulse width, and as the rotation starts slow I could miss several pulses.

I was considering putting a PAUSE 10 (or PAUSE 9) in the loop with counters to 0.01 second each loop. Then by checking the state, watch for a trailing edge. Testing on the PC should reveal how long each loop's processing takes and I may need to adjust my PAUSE value.

Does anyone see an issue with this, or is there a better way?

Thanks.

Jeff

Comments

  • DufferDuffer Posts: 374
    edited 2007-04-18 20:36
    Would your application permit you to use COUNT over a given duration (18+ seconds max for the BS2px) and then calculate the average time between pulses?

    Using COUNT in this way provides a number of interesting options. Calculating RPM, determine when a certain· or steady state RPM is reached (you said the pulses might come in slowly at first)·, has rotation·gone above/below·a certain RPM or stopped.

    Post Edited (Duffer) : 4/18/2007 11:33:34 PM GMT
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2007-04-19 01:27
    Duffer said...
    Would your application permit you to use COUNT over a given duration (18+ seconds max for the BS2px) and then calculate the average time between pulses?

    Using COUNT in this way provides a number of interesting options. Calculating RPM, determine when a certain· or steady state RPM is reached (you said the pulses might come in slowly at first)·, has rotation·gone above/below·a certain RPM or stopped.
    Yes, it just might.· I will try to start with that command.· The only condition I would need to worry about is if the position is sitting on the switch, but I can check that the first time.· Thanks!
Sign In or Register to comment.