PDA

View Full Version : Basic stamp and Xigbee



dsouza
05-14-2008, 12:54 AM
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,["+++"] ' Enter command mode
PAUSE 2000 ' Guard time for command sequence
SEROUT TX,Baud,["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, [DEC 1]
DEBUG DEC 1
SERIN RX\RTS,Baud,[RFin]···· ' Receive acknowledgement
DEBUG DEC RFin
· IF ( RFin = 2) THEN
· SEROUT TX, Baud, [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,["+++"] ' Enter command mode
PAUSE 2000 ' Guard time for command sequence
SEROUT TX,Baud,["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,[RFin] ' Accept and view as character
IF (RFin = 1 )THEN········· ' Check if the first switch is pressed
SEROUT TX, Baud, [DEC 2]··· 'Acknowledge and ask for confirmation
PAUSE 100
SERIN RX\RTS,Baud,[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

StefanL38
05-14-2008, 03:19 AM
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 (http://forums.parallax.com/forums/default.aspx?f=5)

best regards

Stefan

dsouza
05-14-2008, 07:16 AM
Ya sorry , I realised it after posting it here. I have made a post in the basic stamp post now. Thanks.

Regards

Dsouza

tpw_man
05-14-2008, 07:50 AM
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 (http://www.mibbit.com)
http://forums.parallax.com/images/smilies/tongue.gif