Shop OBEX P1 Docs P2 Docs Learn Events
xbee running only at 9600?? — Parallax Forums

xbee running only at 9600??

RNRN Posts: 28
edited 2010-09-17 09:24 in Propeller 1
I am trying wireless communication using stingray. I have written this code

CON

_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
XB : "XBee_Object"


var
byte Value

Pub Start
XB.start(9,8,0,9600) ' XBee Comms - RX,TX, Mode, Baud
XB.AT_Init ' Initialize for fast AT command use - 5 second delay to perform
XB.AT_ConfigVal(string("ATMY"),$5) ' Set MY address to 5


repeat
XB.str(string("demo"))
waitcnt(clkfreq + cnt)
XB.Dec(10)
waitcnt(clkfreq + cnt)

On the computer i am using bray's terminal. Surprisingly it is running only at 9600bps. At any baud it is giving garbage data. i am changing the baud in the bray's terminal also. what can be the possible reasons

thanks
RN

Comments

  • sylvie369sylvie369 Posts: 1,622
    edited 2010-09-15 06:16
    It's not clear what your issue is. It looks like you're setting the interface rate at 9600 and then saying that you're surprised that it communicates at 9600. Of course it runs at the baud rate you set it for (and you have to set the XBee to the corresponding baud rate as well - have you done that?)

    Now, I imagine what you're saying is that it works at 9600, but not when you try a higher speed. But you also say that you're getting garbage at any speed, so that part sounds like you're saying it never works. I'm confused about the issue.

    When you use an XBee, the XBee itself must be set to a particular serial interface rate. The default value is 9600 baud. If you want a different rate, you have to make the change and save it, which you can do either through XCTU (the Digi software for XBees) or using a terminal program and AT commands:

    +++ ' Enter command mode
    ATBD 5 ' Set interface rate to 38,400: 6 would be 57,600, other rates in the docs.
    ATWR ' Write the changes to the XBee's memory

    You _also_ have to set the interface rate in your software, which is what your line XB.start(9,8,0,9600) does. If you try to set a different rate in software but haven't changed the XBee's rate, you won't be able to communicate with it.

    It is important to understand that this is only about the exchange of data between your computer or processor and the XBee. The rate of RF data between one XBee and another is determined by other things (nominally 250,000 bps, but probably dramatically affected by conditions, retries, etc.).
  • ElectricAyeElectricAye Posts: 4,561
    edited 2010-09-15 06:24
    RN,

    it's best to post your code between code tags. They look like this

    [ code ]

    [/ code ]

    but you need to remove all the spaces inside the brackets for it to work properly.
    That way your
      indentation, etc. is preserved.
    

    Also, there is a Wireless Forum on here. Just click on Public Forums in the upper left corner and you will see it listed. You might try posting there for anything related to the Xbee since non-Propeller forum members use the Xbee, too. Just a thought. :)

    cheers,
    Mark
  • RNRN Posts: 28
    edited 2010-09-16 04:24
    sylvie

    i am changing the baud in the code. where i have written 9600 in the spin code i am writing 38400 or 115200 etc. then i am changing the baud in the bray's terminal to which the wireless is connected through usb interface but at any other baud than 9600 it is not working. isnt is all it needs to do wireless communication other than 9600 bps
  • sylvie369sylvie369 Posts: 1,622
    edited 2010-09-16 10:09
    Okay, it sounds like you're not changing the XBee's settings. It's not enough just to change the settings of the devices connected to it - you also have to change the XBee's own serial communications rate, using one of the methods I described.
  • RNRN Posts: 28
    edited 2010-09-17 03:08
    sylvie,

    Thanks its working now. You know i am working on xbee for quite a time but never knew that to change the baud rate is not just a button click. It took time to write the new settings.
    I used the XCTU software to do it. well thanks again

    RN
  • sylvie369sylvie369 Posts: 1,622
    edited 2010-09-17 09:24
    Glad to hear it's working.

    Remember that when you change the XBee's serial communications rate, you won't be able to communicate with it - even through XCTU - except at the new rate. Be sure you know what rate you've set it to.

    It's worth skimming through the XBee manual to see how all of this stuff works. There's a lot of things in there about what you can do.
Sign In or Register to comment.