Shop OBEX P1 Docs P2 Docs Learn Events
Best Way to Wait for pin Transition — Parallax Forums

Best Way to Wait for pin Transition

bdickensbdickens Posts: 110
edited 2010-07-17 21:56 in Propeller 1
I have 3 different hall effect speedometers on my project, one is a motor, one is windspeed, one is WaterSpeed.

In my first incarnation of the program, I simply sent each one into it's own cog, but there are now lots of other things and I need the cogs back. So my first cut was to simply wait for the pin to transition. But when the motor is stopped, I end up waiting forever. So my second version looped for 2 seconds and counted the transitions. This allowed me to control how long I "waited".

Is there a more elegant way to wait for a pin to change state that does not hold the program hostage forever. I looked at WaitPeQ and that would work except I need a timeout value.

Is there a more elegant way to solve besides loop for a fixed time period and count ?

Thanks

Comments

  • T ChapT Chap Posts: 4,223
    edited 2010-07-17 21:56
    You could look at the counters and the ap note 001. There could be 3 counters looking at the pins in the background and updating a variable if there was a trigger. The counters can tell you how long the pins are high as long as you don't roll.

    Have the some method check the 3 variables in a loop, if there is a change on the variable then you have an input. Then reset the counter and variable back to 0.
Sign In or Register to comment.