Shop OBEX P1 Docs P2 Docs Learn Events
Basic stamp and Xigbee — Parallax Forums

Basic stamp and Xigbee

dsouzadsouza Posts: 3
edited 2008-05-13 23:50 in Propeller 1
Hello everyone
My name is ·Dsouza and I am working on a project which involves two way wireless communication between 2 basic stamp microcontrollers which are placed in a room. To communicate between them I am using a xigbee radio. The project goes this way, On one end ( Switch side) there is a switch connected to the basic stamp,which when pressed should send a command·( here i am using a decimal 1 as command) through the basic stamp over the Xigbee to the other·xigbee which is also connected·to a basic stamp which has an LED connected to it. Now·when the other end ( Light side) receives the command it sends a reply (i am using decimal 2 as reply) ·asking for confirmation. When the Switch side receives the·acknowledgement it sends a confirmation ( I send the same decimal 1 again as confirmation) and when the· confrirmation is received by the· Light side LED has to blink.
I have used serial communication between·basic stamp and xigbee radio. It has been possible for me to·send the command when the switch is pressed and then receive it on the light side and·ask for acknowledgement. BUT the switch side is not receiving the reply it just waits there and the program gets stuck. I tried·various ways like using· a TIMEOUT in the serial in command but still it waits for that time and goes into timeout.· I was not able to·establish a 2 way communication between them .·I have put the code of both the switch side and light side in this email. I would realy appreciate it if some one would go throught it and help me out. Thank you.


······································ ' THE SWITCH SIDE
' {$STAMP BS2}
' {$PBASIC 2.5}
' ****************************************
' * Accept_Character.bs2 *
' * Illustrates accepting a Byte *
' * received as a character *
' ****************************************

myAddr CON $1 ' Node Address
DestAddr CON $0 ' Destination address
Baud CON 84 ' Baud rate, 9600, 8-N-1, non-inverted, on BS2.
RX PIN 0 ' Receive Pin
TX PIN 2 ' Transmit Pin
RTS PIN 6 ' Flow control Pin
btn1 PIN 13
RFin VAR Byte
HIGH TX ' Set TX pin to idle state
DEBUG CLS, "Configuring XBee..."
PAUSE 2000 ' Guard time for command sequence
SEROUT TX,Baud,[noparse][[/noparse]"+++"] ' Enter command mode
PAUSE 2000 ' Guard time for command sequence
SEROUT TX,Baud,[noparse][[/noparse]"ATNI BS2 Test Node",CR, ' Set description
"ATMY ", HEX myAddr,CR, ' Set node address
"ATDL ", HEX DestAddr,CR, ' Set destination node address
"ATD6 1",CR, ' Use RTS for flow control
"ATCN",CR] ' Exit command mode
PAUSE 1000
DEBUG "Configuration Complete!", CR
main:
IF (btn1 = 1 )THEN········· ' Check if the first button was pressed
PAUSE 100
SEROUT TX, Baud, [noparse][[/noparse]DEC 1]
DEBUG DEC 1
SERIN RX\RTS,Baud,[noparse][[/noparse]RFin]···· ' Receive acknowledgement
DEBUG DEC RFin
· IF ( RFin = 2) THEN
· SEROUT TX, Baud, [noparse][[/noparse]DEC 1]···· ' Confirm that the button was pressed
· DEBUG DEC 1
· ELSE
· GOTO main
· ENDIF
· ENDIF
· GOTO main


············································ ' The LIGHT SIDE

' {$STAMP BS2}
' {$PBASIC 2.5}
' ****************************************
' * Accept_Character.bs2 *
' * Illustrates accepting a Byte *
' * received as a character *
' ****************************************
myAddr CON $1 ' Node Address
DestAddr CON $0 ' Destination address
Baud CON 84 ' Baud rate, 9600, 8-N-1, non-inverted, on BS2.
RX PIN 0 ' Receive Pin
TX PIN 2 ' Transmit Pin
RTS PIN 6 ' Flow control Pin
btn PIN 12
RFin VAR Byte
HIGH TX ' Set TX pin to idle state
DEBUG CLS, "Configuring XBee..."
PAUSE 2000 ' Guard time for command sequence
SEROUT TX,Baud,[noparse][[/noparse]"+++"] ' Enter command mode
PAUSE 2000 ' Guard time for command sequence
SEROUT TX,Baud,[noparse][[/noparse]"ATNI BS2 Test Node",CR, ' Set description
"ATMY ", HEX myAddr,CR, ' Set node address
"ATDL ", HEX DestAddr,CR, ' Set destination node address
"ATD6 1",CR, ' Use RTS for flow control
"ATCN",CR] ' Exit command mode
PAUSE 1000
DEBUG "Configuration Complete!", CR
main:
SERIN RX\RTS,Baud,[noparse][[/noparse]RFin] ' Accept and view as character
IF (RFin = 1 )THEN········· ' Check if the first switch is pressed
SEROUT TX, Baud, [noparse][[/noparse]DEC 2]··· 'Acknowledge and ask for confirmation
PAUSE 100
SERIN RX\RTS,Baud,[noparse][[/noparse]RFin]
···· IF ( RFin = 1 ) THEN······ 'Verify if the first switch was pressed and then light LED
···· HIGH 100·················· ' Blink the LED's
···· PAUSE 100
···· LOW 100
···· ENDIF
···· GOTO main
ELSE
PAUSE 100
ENDIF
GOTO main

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2008-05-13 19:19
    Hello Dsouza,

    i'm sorry - but you posted in the PROPELLER-chip-forum

    the BASIC-STAMP-forum is here

    forums.parallax.com/forums/default.aspx?f=5

    best regards

    Stefan
  • dsouzadsouza Posts: 3
    edited 2008-05-13 23:16
    Ya sorry , I realised it after posting it here. I have made a post in the basic stamp post now. Thanks.

    Regards

    Dsouza
  • tpw_mantpw_man Posts: 276
    edited 2008-05-13 23:50
    Next time, as soon as you realize it, as long as nobody has posted in the thread, there is a red X in the top right corner of your post. Click that to delete the thread.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1011, so be surprised!


    Advertisement sponsored by dfletch:
    Come and join us on the Propeller IRC channel for fast and easy help!
    Channel: #propeller
    Server: irc.freenode.net or freenode.net
    If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
    tongue.gif
Sign In or Register to comment.