Shop OBEX P1 Docs P2 Docs Learn Events
correct digit being replaced by a zero — Parallax Forums

correct digit being replaced by a zero

jruthroffjruthroff Posts: 38
edited 2011-03-26 05:20 in BASIC Stamp
The attached program receives data from a remote unit that transmits temp and humidity. The transmitter sends a delimiter character, a "!", to supress spurious data. I've verified that the xbee unit on the receiver is indeed receiving the data properly...by using the X-CTU utility, I can see that the data is being received in a format similar to this...

!71
!53

The problem I'm having is that on the receiving end the leftmost character of the temp data is being read by the program as a zero. So, instead of seeing, for example a temperature and humidity of "71" and "53" debugged at the receiver, I'm seeing "01" and "53". Regardless of what the leftmost diget of the temperature actually is, it debugs as a zero. Since I'm seeing the data properly formatted at the receiving xbee, I don't think the transmit software or the wireless link is the issue.

The humidity always debugs correctly.

I'm pretty new at all this, so any other constructive comments about the code are welcome.

Thanks in advance,

John

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-03-22 14:57
    Try this:
    SERIN Rx,Baud,3000,Timeout, [WAIT("!"), DEC2 temp, WAIT("!"), DEC2 H]       'accept temp and humidity
    

    The problem is that, by checking for the "!" and reading the data in multiple statements, the Stamp is not able to keep up with the input datastream. Also, it appears that the XBee is not responding to the RTS fast enough (i.e. on a character-by-character basis), which the BASIC Stamp demands for handshaking to work, so you might as well not use it.

    I'm a little concerned, however, that since both readings are preceded by a "!", you could get out of sync and end up reading swapped values. Is there any way to precede one of them with a different cue?

    -Phil
  • jruthroffjruthroff Posts: 38
    edited 2011-03-26 05:20
    Thanks for the suggestion Phil. Not sure why, but when I implemented that line of code it wouldn't transmit anything! I was able to get it to work properly be stripping out all the DEC formatters. So instead of having formatting such as "DEC2 temp...", I found that if I just put "DEC temp" (and so on in other parts of the code" all the digits would appear as they shoud.

    I did take your suggestion and impliment another delimiter to try and keep the temp from getting confused with the humidity. So far that feature seems to be working also.

    I have a few other issues, but I'll post those on the XBee section as they don't really have to do with the BS code.

    Regards,

    John
    ""
Sign In or Register to comment.