View Full Version : How long does PULSIN wait for a pulse?
Byte_Butcher
- 29th January 2010, 03:10
I just know this has been covered before. Or maybe not because the answer is too obvious and I'm just too blind to see...
The manual states:
" The measured width is placed in Var. If the pulse edge never happens or the width of the pulse is too great to measure, Var is set to zero. "
So how long is "never happens" or "too great to measure"?
When I use PULSIN inside a loop to look for an IR signal it really slows things WAY down.... :(
Thanks
steve
rmteo
- 29th January 2010, 03:29
The resolution of PULSIN is dependent upon the oscillator frequency. If
a 4MHz oscillator is used, the pulse width is returned in 10us increments.
If a 20MHz oscillator is used, the pulse width will have a 2us resolution.
Defining an OSC value has no effect on PULSIN. The resolution always
changes with the actual oscillator speed.
PULSIN normally waits a maximum of 65535 counts before it determines
there is no pulse.
With a 4MHz clock that works out to be 655mS (or 131mS at 20MHz).
dhouston
- 29th January 2010, 03:57
DEFINE PULSEIN_MAX counts will specify the time to wait.
Byte_Butcher
- 29th January 2010, 04:50
PULSIN normally waits a maximum of 65535 counts before it determines
there is no pulse.
Thanks rmteo,
I kind of guessed that from the length of time it took, but I didn't find it in my search. The "help" file in MCS didn't really go there.
Dave,
Bingo!
"DEFINE PULSEIN_MAX counts" is exactly what I needed. I only need to look for 500 counts, so 65K+ was a bit much.
The DEFINE sped my loop up a LOT and works great. A bit embarrassed I didn't find it on my own. Thanks to both you guys for pulling the blindfold off . :o :)
steve
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.