Shop OBEX P1 Docs P2 Docs Learn Events
how to determine when data is not being received — Parallax Forums

how to determine when data is not being received

jruthroffjruthroff Posts: 38
edited 2011-03-31 04:31 in Accessories
I'm working on a wireless thermometer project that is basically complete except for one large issue.

The project uses 1 xbee module to transmit temp and humidity data to a second xbee. The second module sends the data to a BS2 which then sends it to a Maxim 7219 to drive four 7-segment LED displays. When it's operational, the transmitter will send the data once every minute.

My problem is this, when the transmitter stops transmitting (say because of a power failure), the receiver will obviously stop receiving. However, the displays will still show the most recent temp and humidity until either the transmitter starts transmitting again or until the receiver is power cycledtemp receiver new.bs2. I would like them to show zeros, dashes, or in some other way indicate that they are no longer receiving data. I'm not sure how to do this since most of the time the receivers normal state is not receiving data. I've tried initializing the digits to display zeros on each loop of the program (which works), but then the data alternates between showing zeros and showing the temp/humidity, which is not very elegant.

I've attached the code if anyone would care to pass along suggestions...thanks!

John

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-03-30 08:23
    The timeout acts as your clock tick. Each time you successfully receive a set of data, you set a timer variable to zero. Each time you get a timeout, you increment that timer variable. If the timer variable reaches some particular value, you've given up on your transmitter and you set the display to whatever special indication you want ... and you undo the increment you just made (by decrementing the variable). This way, whenever the program receives a set of data, the display gets updated with the correct values.
  • jruthroffjruthroff Posts: 38
    edited 2011-03-31 04:31
    Thanks Mike. Your suggestion has been implemented and does the job nicely. I've just one other "mystery" that needs solving, but I'll address that in a separate post. Thanks again.
Sign In or Register to comment.