Shop OBEX P1 Docs P2 Docs Learn Events
Pulsein stop program in absence of input pulses — Parallax Forums

Pulsein stop program in absence of input pulses

FXFX Posts: 4
edited 2010-03-22 21:27 in Propeller 1
Hi All,

I have a problem with BS2 Functions Library Object Version 1.5.1 primary author Martin Hebel

PUB PULSIN (Pin, State) : Duration
{{
Reads duration of Pulse on pin defined for state, returns duration in 2uS resolution
Shortest measureable pulse is around 20uS
Note: Absence of pulse can cause cog lockup if watchdog is not used - See distributed example
x := BS2.Pulsin(5,1)
BS2.Debug_Dec(x)
}}

in absence of input pulses the program does not proceed.

Where can I find instructions / example in note for use watchdog and avoid program stop ?

Thanks in advance

Francesco

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2010-03-22 21:27
    I think the best way would be to include the watchdog into the function itself, but that might also lead to lowering the resolution ... and it's propably to much for newbies.

    So, what you can to is have a simple function (e.g. measure) for the measurement. You add a variable for example named pulseinOK and set it to false before running the measure-function.
    The function itself calls x:=BS2.Pulsin ... and then sets puseinOK to true.

    In the place where you are interested in the measurement you don't call the function directly. You use a COGNEW( measure, @somestack)

    Now you have to wait until either the pulseinOK is set to true or the time you want to wait has passed. If the time has passed you can stop the COG.

    Without knowing more about your problem and what you need the pulsein for, this can only be a general advice, which might turn out to be usefull or maybe not (in case your timings are though the additional COGNEW might be no option).
Sign In or Register to comment.