Home Forums EasyTransfer Library Support Forum How to check connection

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2993
    Anonymous
    Inactive

    Hi, I have built a remote control to a machine here at work, using arduino fio and arduino uno with two xbees, it’s working fine, except for the fact that if the remote control loses connection while sending a command the receiver will hold the command up until the connection is restored, this could mean harm depending on the situation, I wanted to know how can I make the receiver identify a lost connection, so it can stop all movements whenever the remote control lose signal.

    #2994

    The ET library is Asynchronous, In other words it only sends data when it needs to. Hence your sending application will need to generate periodic heartbeats and your receiver will need to expect them. Where if it misses too many of them then it will need to perform a graceful shutdown.

    On the receiver this similar to the Arduino Debounce example http://arduino.cc/en/Tutorial/Debounce. Same concept of timing and function. Actually more like a WatchDog, in that it expects a serial receive message to update the timeout before it times out.

    #2995
    Anonymous
    Inactive

    I was thinking on using a two way communication, where the receiver “ask” if the remote control is responding, if it takes too much time to respond then it stops all movements, it might work, thanks for your answer Michael.

    #2997
    Bill
    Member

    Michelterres,

     

    The easiest way to to implement a ‘watchdog timer’ like Michael suggests. It’s simple, here in sudo-code:

    //check and see if a data packet has come in.
    //This function only returns true when a new message has come in
      if(ET.receiveData()){
    last_message=mills()
    ….}
    else if((millis() – last_message) >= 1000) {
    //this is true when no message has been received for 1 second.
    failsafe code here
    It is more intensive to implement a query system like you are thinking.
    #2998
    Anonymous
    Inactive

    Thank you, I will try that, but, what kind of variable do I declare “last_message”?

    #2999
    Bill
    Member

    last_message records what returns from the millis() function. So if you go lookup millis() in the reference pages:

    http://arduino.cc/en/Reference/Millis

    You see what it returns is a unsigned long. That is what you should declare it as.

     

     

     

    #3000
    Anonymous
    Inactive

    I’ve tested the code now, works perfect, thank you for helping me!

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.