Pink to propeller communication Via Xbee [SOLVED]
Dgswaner
Posts: 795
I've tried for Hours over many days to get the syntax right but I just can't make this work. here is my line of communication PINK> Propeller>Xbee
Xbee<Propeller
I need to read a string from the pink, and get it to the end propeller, the communication works the only problem is that I can only send one letter at a time. I've stripped down my code and I still can't get this to work. It appears that no matter what I do I can't get more than one character from the PINK.
My ultimate goal is to read a value from the pink (255 for example) and Xmit it to my bot, right now all my that my bot is getting is a 2. I know I need to convert the string value of "255" to a decimal value, which I can do but I'm not receiving the whole "255" to begin with. I know there has to be something that I am missing. I would really appreciate some help before I pull the rest of my hair out.
Thanks, DGS
The code below is partial code each run on a different propeller.
I've tried many many variations of this! and still can't get it to work.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
Post Edited (Dgswaner) : 5/9/2008 5:17:42 AM GMT
Xbee<Propeller
I need to read a string from the pink, and get it to the end propeller, the communication works the only problem is that I can only send one letter at a time. I've stripped down my code and I still can't get this to work. It appears that no matter what I do I can't get more than one character from the PINK.
My ultimate goal is to read a value from the pink (255 for example) and Xmit it to my bot, right now all my that my bot is getting is a 2. I know I need to convert the string value of "255" to a decimal value, which I can do but I'm not receiving the whole "255" to begin with. I know there has to be something that I am missing. I would really appreciate some help before I pull the rest of my hair out.
Thanks, DGS
The code below is partial code each run on a different propeller.
pub GETX ' PINK Code repeat myPink.readVar(myPink#Nb_var25,@XVAL) 'gets Pink Value comm.tx(Xval) ' send Xval to PC XB.str(Xval) 'send Xval via Xbee waitcnt (10_000_000+cnt) 'wait 1/10 sec
'Bot Code Repeat y := XB.RX ' recieve data from Xbee comm.tx(y) ' send to PC Waitcnt (10_000_000+cnt)
I've tried many many variations of this! and still can't get it to work.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
Post Edited (Dgswaner) : 5/9/2008 5:17:42 AM GMT
Comments
pub·GETX·····'·PINK·Code
···repeat
·····myPink.readVar(myPink#Nb_var25,@XVAL)······'gets·Pink·Value
·····comm.str(@Xval)····································'·send·buffer Xval·to·PC
·····XB.str(@Xval)········································'send·buffer Xval·via·Xbee
·····waitcnt·(10_000_000+cnt)····················'wait·1/10·sec
'Bot·Code
Repeat
······y·:=·XB.RX···'·recieve·data·from·Xbee
······comm.tx(y)··'·send·to·PC
······Waitcnt·(10_000_000+cnt)
You must pass the buffer address to both comm.str (I think comm.tx just sends one byte)
and to XB.str
regards peter
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
Post Edited (Dgswaner) : 5/8/2008 2:27:44 AM GMT
I've tried what I think should work and tried ever combination of sending and converting and I can't get it to work. this is to control a home brew PTZ camera base 0-255 is going to be the position of a slider on the Pink interface, and needs to get converted to a value on the bot side. Is there an easier way to do this?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
Post Edited (Dgswaner) : 5/8/2008 12:26:18 PM GMT
atoi converts the decimal string into a binary value.
regards peter
can I get clarification of my thought process on how I think this should work? perhaps there is something I'm missing.
if NBVAR25 = 123 (this is a string value)
myPink.readVar(myPink#Nb_var25,@XVAL) 'gets the value and stores it in @Xval still in string format
XB.str(@Xval) 'would send the entire string "123"
X := XB.TX would recieve the "123" as a string, there is not option for receiving a value that isn't stored as a value, so there shouldn't be any need to convert the string to a value on the sending propeller.
format.Atoi(@Xval,@X) converts "123" to 123 (an actual number)
I can then use X to control the position of a servo.
Thanks for your help
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
So you would do
myPink.readVar(myPink#Nb_var25,@XVAL) 'gets the value and stores it in @Xval still in string format
value := format.atoi(@XVAL) 'value now holds binary value of decimal string in XVAL
XB.tx(value)· 'transmit byte value
On the receiver side you then get simple binary values.
regards peter
Thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
Pink Code: This reads NBVAR20 from the pink converts it and then sends out via XBEE and to a PC.
Bot Code: receives the value from the pink uses the 0-255 value to set the servo to 400-2200.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner