Best Way to Wait for pin Transition
bdickens
Posts: 110
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
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
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.