Xbee problems
Crosswinds
Posts: 182
Hello!
I have just recieved my two xbee series 1 units.
Hooked everything up on seperate boards.
And run these test programs on them:
Reciever:
i do get a "OKOK" in the PST after starting the reciever up.
But nothing else..
Any ideas?
Probably did something stupid since i was in a hurry to get this going
I have just recieved my two xbee series 1 units.
Hooked everything up on seperate boards.
And run these test programs on them:
Sender: CON _xinfreq = 5_000_000 _clkmode = xtal1 + pll16x OBJ XB : "XBee_Object" Pub Start DIRA[16]~~ XB.start(6,7,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 OUTA[16]~~ waitcnt(clkfreq/2 + cnt) XB.str(string("Hello!",13)) ' Send a string outa[16]~ waitcnt(clkfreq/2 +cnt)
Reciever:
CON _xinfreq = 5_000_000 _clkmode = xtal1 + pll16x VAR long Mystr OBJ XB : "XBee_Object" pst : "Parallax Serial Terminal" Pub Start XB.start(16,17,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 pst.Start(115_200) repeat XB.rxStr(MyStr) pst.str(Mystr)
i do get a "OKOK" in the PST after starting the reciever up.
But nothing else..
Any ideas?
Probably did something stupid since i was in a hurry to get this going
Comments
Fixed.
I'm not familiar with the string usage though I bet it's correct.
Maybe a picture of your setup will let someone catch something you're not seeing?
Hello!
The code is taken from the very beginning of the xbee object. There´s an example there.
Sorry dont have a picture on it. But it is connected like so:
Sender:
Xbee pin 1 -> 3.3v
Xbee pin2 -> prop 7
Xbee pin3 -> Prop 6 (note i have tried to invert these.)
xbee pin 10 -> GND
Same way for reciever but different prop pins. And i do get a "OKOK" from that one.
XB.AT_ConfigVal(string("ATMYDL"),$5) ' Set DL address to 5
Thank you! So i should replace MY with DL?
In the example code, it is the sender i think?
By the way, XBees series 1 as they come from the factory are set with both MY=0 and DL =0, so they can communicate with one another out of the box.
Thank you again!
So this means that if i didnt include that setting from the beginning, it should have worked right away?
If i want bi-directional i should set these on both ends, right?
I noticed another problem with your rx routine. The following code does not add up:
Mystr as a long consists of 4 bytes, but your tx routine is trying to send "hello",CR, which needs 6 bytes. The usual way to define that is
byte MyStr[7]
One extra byte so that it can hold a null at the end, which is what signals the end of string.
Furthermore, commands that act on strings usually require the address of the string, like this:
XB.rxStr(@MyStr)
pst.str(@Mystr)
Good luck! You have a couple of new things going on here!
Thank you for your input and tips! Very helpful.
Have to change the things you pointed out! As soon as i find a new project for spin, i always struggle a bit comming back to Spin. Make alot more projects in C++. Even though, i find the spin language a lot easier to learn.