Shop OBEX P1 Docs P2 Docs Learn Events
Using Xbee Multiple_Decimal_Receive — Parallax Forums

Using Xbee Multiple_Decimal_Receive

GrantmcFGrantmcF Posts: 30
edited 2015-02-20 19:12 in Accessories
I'm using two Xbee modules and two propeller modules to talk to each other. I'm trying to pass two variables from one module to another. I can pass them and read them using serial pass through on the receiving side, but I can't save them as global variables. I have tried using Multiple Decimal Receive, but can't get it to work. Any suggestions?

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2015-02-18 15:07
    Hello,

    How are you receiving the variables? If you receive them into global variables then you can probably save a step, but without seeing the code I couldn't guess where the issue might be. Can you post your code as an attachment (archive)?
  • GrantmcFGrantmcF Posts: 30
    edited 2015-02-20 19:12
    I figured it out. The problem was on my sending side. Multiple Decimal Receive uses the XBee object library and rxDec requires a comma or a carriage return from the sending side after the data is sent. I did not have either one on the sending side so it wasn't reading it properly. I was viewing it on the serial terminal with serial pass through which doesn't care about separators. This code works. FDs is full duplex serial, XBr is XBee object

    Sending
    FDs.str(string("!"))
    FDs.dec(out_Temp)
    FDs.str(string(","))
    FDs.dec(out_Rh)
    FDs.str(string(","))

    Receiving

    Pub cog_Rx | DataIn, Val1,Val2
    'Receives data and posts it to global variables

    Repeat
    DataIn := XBr.RxTime(100) ' Wait for byte with timeout
    If DataIn == "!" ' Check if delimiter
    Val1 := XBr.RxDecTime(3000) ' Wait for 1st decimal value with timeout
    Val2 := XBr.RxDecTime(3000) ' Wait for next decimal value with timeout
    out_Temp:= Val1
    out_Rh:= Val2
Sign In or Register to comment.