Shop OBEX P1 Docs P2 Docs Learn Events
Hearth Beat between TX and RX — Parallax Forums

Hearth Beat between TX and RX

Capt MagellanCapt Magellan Posts: 6
edited 2007-02-01 16:44 in BASIC Stamp
Hi Guys,

Need some help....

I need to create a device that is constantly sending an heart beat to a receiver. If the receiver for wathever reason looses contact with the transmitter (say is to far away) then the receiver will trigger an alarm.

The hardware I am using are 2 Basic Stamp 2 and TX and RX Parallax modules.

Do we have any kind of watch dog commands ? so that if the "SERIN 1, 16780, [noparse][[/noparse]WAIT("XYZ"), PONG]" doens't receive anything withing 10 secs whould then continue·and trigger an alarm

Any suggestion will be greatly appreciate.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2007-01-30 04:20
    I believe there is a timeout feature to keep a wait from hanging the system.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Capt MagellanCapt Magellan Posts: 6
    edited 2007-01-30 04:23
    Hi,

    Thank you for your reply.

    I checked the commands listed for the BASIC STAMP SX and I couldn't find this... any hint ?
  • FranklinFranklin Posts: 4,747
    edited 2007-01-30 04:31
    SERIN Rpin {\Fpin}, Baudmode, {Plabel,} {Timeout, Tlabel,} [noparse][[/noparse]InputData]

    Take a look at the help file under serin.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Capt MagellanCapt Magellan Posts: 6
    edited 2007-01-30 04:33
    Steph, THANK YOU A MILLION !!!! I am leaving in few months to a sailing trip across the pacific and I am trying to design a man overboard device.....

    Thank you appreciate your help !

    /Dino
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-01-30 04:44
    Be aware the you can't use a time out combined with a wait. Just a heads-up.

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    StampPlot - GUI and Plotting, and XBee Wireless Adapters
    Southern Illinois University Carbondale, Electronic Systems Technologies
  • Capt MagellanCapt Magellan Posts: 6
    edited 2007-01-30 04:51
    Thank you Martin...



    In my solution I may have multiple transmitters... is there a way to don't make interfeer with each other now that I cannot use the WAIT in combination with the pause...?
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-01-30 05:16
    Oh, good, I get to make a sales pitch!

    I recommend XBee transcievers. They use clear channel assesment prior to sending data (like WiFi) to prevent data collision, and they also can buffer data so the BASIC Stamp doesn't need to worry about missing the data when not 'looking'.

    There's BS2 code and examples are in the docs I wrote for adapter boards for these units I make. - see the bottom of the page for docs. The devices also have a sleep mode that BS2 can control to limit current draw helping that battery life. Just don't put your receiving unit to sleep or it will miss the data.

    http://www.selmaware.com/appbee

    Safe journey when you go!
    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    StampPlot - GUI and Plotting, and XBee Wireless Adapters
    Southern Illinois University Carbondale, Electronic Systems Technologies
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-01-30 05:51
    Martin Hebel said...
    Be aware the you can't use a time out combined with a wait. Just a heads-up.
    Martin, that was a new one on me, so I had to try it for myself. Here's the program I used:

    ' {$STAMP BS2pe}
    ' {$PBASIC 2.5}
    
    Value VAR Word
    
    Start:
      DO
        SERIN 16, 84, 5000, NoData, [noparse][[/noparse]WAIT("xyz"), DEC Value]
        DEBUG "Value = ", DEC Value, CR
      LOOP
    
    NoData:
      DEBUG "Timeout", CR
      GOTO Start
    
    
    


    It worked as I would have expected it to, despite your caveat. Is there something I've misunderstood?

    -Phil
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-01-30 06:46
    Phil -

    Did you try sending data other than "xyz" or send "xyz" without any additional data? That may be the bogus case.

    Bruce

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-01-30 07:07
    Bruce,

    Yes, to both. It just works.

    Of course, you have to remember that, if you send it "xy", let it time out, then send "z" and a number, it doesn't remember the "xy", since it's starting over. But in a typical application, the pattern you're looking for occurs in a burst anyway, so this is not an issue.

    -Phil
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-01-30 07:08
    I've often used WAIT with timeouts. I'm pretty sure it works. But the timeout does not apply to the "xyz" (or whatever) as a total unit., as in, "timeout after x milliseconds if 'xyz' is not received. The timeout is reset by _any_ character or even noise, as in, "timeout in x milliseconds if nothing at all is received, dead silence".

    That behavior can be a flaw when used with a noisy communication channel, such as a radio link. Some radios increase their gain, agc, when nothing is coming in, until the data slicer finds some noise to slice. No squelch. So serin never times out. That is the cheapest AM radios. That does not apply to more sophisticated radios or to devices like the xbee's that Martin likes, because they send only valid data through to the receiver.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-01-30 07:14
    Tracy,

    Now that you mention it, what Martin probably meant to say is that the timeout doesn't apply to the WAIT pattern, per se, but operates at a lower level on any data received.

    -Phil
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-01-30 10:18
    Phil -

    That makes perfect sense and seems logical as well.

    Bruce

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-01-30 13:18
    Ok, I was just plain wrong. Seems I had tried it before and it didn't work, and that there was something in the help file about that. Must have dreamt it, sorry.

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    StampPlot - GUI and Plotting, and XBee Wireless Adapters
    Southern Illinois University Carbondale, Electronic Systems Technologies
  • Capt MagellanCapt Magellan Posts: 6
    edited 2007-01-30 15:15
    Hi Guys,

    Thank you all for your great help !



    BR/Dino
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-02-01 04:15
    Readdressing the pattern matching capabilities of WAIT, I wondered if it were possible to fool it. Indeed, it is. Here's the program I used:

    ' {$STAMP BS2pe}
    ' {$PBASIC 2.5}
    
    DO
      SERIN 16, 84, [noparse][[/noparse]WAIT("aabaac")]
      DEBUG " Got it!", CR
    LOOP
    
    
    



    And here's the output, with my keyboard input echoed:
      aabaac Got it! baabaac Got it! a
    aabaacaabaac Got it!
    aabaabaacaabaac Got it!
    The patterns that it "should" have recognized, but didn't, are in red. What this means is that the pattern matcher never backtracks. When a match fails, it just starts over from the beginning of the pattern. This is okay in most situations, as long as you keep in mind that that's the way it works.

    -Phil
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-02-01 16:44
    Interesting insight into the underlying state machine, Phil. It would be more of a problem if it it could be tricked into responding to something that did not contain the correct sequence at all. I often use the WAIT string as a password or security key to preface a command. Or as a match string for parsing data. The insight about the state machine will be a good thing to keep in view when choosing the match string.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.