Shop OBEX P1 Docs P2 Docs Learn Events
How to get around cog lock up with pulsin (BS2 Functions) — Parallax Forums

How to get around cog lock up with pulsin (BS2 Functions)

Daniel Lloyd-WoodDaniel Lloyd-Wood Posts: 14
edited 2009-07-21 07:55 in Propeller 1
Hello,

I'm using the PULSIN command (from Martin Hebel's BS2 Functions on obex) to read servo pulses from a receiver. It works really well except that the cog running PULSIN will lock up if there is no input signal when PULSIN is called. The receiver needs to be able to be turned on/off independently of the propeller so they're not always going to be in synch i.e there isn't always going to be a signal. I need some way to prevent/handle this lock up to make things a bit more robust. Is there any way around this?

Thanks,

Dan

Comments

  • JonnyMacJonnyMac Posts: 9,197
    edited 2009-07-20 18:25
    Using waitpeq and waitpne for a pin that doesn't change will cause a program to snag; you could create a PASM object that is able to measure the pulse in the background and let you know when the measurement is ready. You could check the ready flag instead of holding for a measurement that isn't coming.
  • W9GFOW9GFO Posts: 4,010
    edited 2009-07-20 19:29
    I recently uploaded an object that might work. RX Input.

    A pulse needs to be present when started but you can remove the pulse without anything hanging. If the input has no pull down, you may get erratic readings when no pulse is being sent.

    Rich H
  • SamMishalSamMishal Posts: 468
    edited 2009-07-20 19:53
    Instead of a WaitPQE/PNE use a Timeout loop while testing for the pin state and checking for a time out.

    This works OK in SPIN if your timing is not too tight. If it is then use PASM to do the same thing.

    Sam
    ·
  • LawsonLawson Posts: 870
    edited 2009-07-20 20:31
    Another option would be to use WAITPNE on TWO pins at once. One pin would be the input, while the other pin would be driven by a counter in NCO mode an FRQx of 1 and PHSx would then be set to -Timeout_seconds * CLKFREQ (this is negative number) before every WAITPNE. A quick check for a low on the counter driven pin would tell if the WAIT timed out. Could be done from spin with single clock precision, but needs a spare pin and counter.

    Lawson

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Lunch cures all problems! have you had lunch?
  • Daniel Lloyd-WoodDaniel Lloyd-Wood Posts: 14
    edited 2009-07-21 07:55
    Thanks for all the suggestions. Timing is quite important, the faster ,the better. Looks like I might need to look into learning some PASM! I'll post what I come up with - it may take a while though, I haven't looked at PASM yet.

    Dan
Sign In or Register to comment.