PDA

View Full Version : Hearth Beat between TX and RX



Capt Magellan
01-30-2007, 11:07 AM
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, [WAIT("XYZ"), PONG]" doens't receive anything withing 10 secs whould then continueˇand trigger an alarm

Any suggestion will be greatly appreciate.

Franklin
01-30-2007, 12:20 PM
I believe there is a timeout feature to keep a wait from hanging the system.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

Capt Magellan
01-30-2007, 12:23 PM
Hi,

Thank you for your reply.

I checked the commands listed for the BASIC STAMP SX and I couldn't find this... any hint ?

Franklin
01-30-2007, 12:31 PM
SERIN Rpin {\Fpin}, Baudmode, {Plabel,} {Timeout, Tlabel,} [InputData]

Take a look at the help file under serin.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

Capt Magellan
01-30-2007, 12:33 PM
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 Hebel
01-30-2007, 12:44 PM
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 (http://www.selmaware.com/)
Southern Illinois University Carbondale, Electronic Systems Technologies (http://www.siu.edu/~isat/est)

Capt Magellan
01-30-2007, 12:51 PM
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 Hebel
01-30-2007, 01:16 PM
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 (http://www.selmaware.com/)
Southern Illinois University Carbondale, Electronic Systems Technologies (http://www.siu.edu/~isat/est)

Phil Pilgrim (PhiPi)
01-30-2007, 01:51 PM
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, [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 Bates
01-30-2007, 02:46 PM
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)
01-30-2007, 03:07 PM
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 Allen
01-30-2007, 03:08 PM
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 (http://www.emesystems.com)

Phil Pilgrim (PhiPi)
01-30-2007, 03:14 PM
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 Bates
01-30-2007, 06:18 PM
Phil -

That makes perfect sense and seems logical as well.

Bruce

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->

Martin Hebel
01-30-2007, 09:18 PM
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 (http://www.selmaware.com/)
Southern Illinois University Carbondale, Electronic Systems Technologies (http://www.siu.edu/~isat/est)

Capt Magellan
01-30-2007, 11:15 PM
Hi Guys,

Thank you all for your great help !



BR/Dino

Phil Pilgrim (PhiPi)
02-01-2007, 12:15 PM
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, [WAIT("aabaac")]
DEBUG " Got it!", CR
LOOP





And here's the output, with my keyboard input echoed:aabaac Got it!
baabaac Got it!
aaabaacaabaac 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 Allen
02-02-2007, 12:44 AM
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 (http://www.emesystems.com)