PDA

View Full Version : pic16f88, xbee's & point-2-point comms



rdxbam
- 31st January 2009, 09:54
i have 6 endpoints that have sensor data to send to the xbee coordinator. i'm looking for ideas on how do i ensure that each endpoint/pic sends it's data point-to-point to the coordinator and also have the coordinator "ack" the received data back to the correct sender, and also avoid collisons?

if the base communicates point-to-point via "serout & serin" will i need to set the destination address in that block of code? i guess the sending endpoint could include it's address so i wouldn't need to hard code that in the code for the base?

below is the xbee configs for ver and addressing along with some PBP pseudo code hoping this illustrates what i'm trying to accomplish

any thoughts/advice will help me brainstorm
tia


=================================
Modem = XB24
Function Set = xbee 802.15.4
Version = 1084

[Coordinator]
CE - Coordinator Enable = 1
DL - Destination Addr Low = FFFF
MY - 16-bit Src Addr = 0
PAN = 3332

[End Points; 6 total]
DH = 0
DL = 0
MY = 1
.
.
.
MY = 6
=================================


;--[base]----------------------------------------------------------------

XB_Base_MYAddr CON $0 ' Node Address Base
XB_DestDLAddr CON $1 ' Destination address

SERIN2 RX\RTS, baud, [WAIT("A"), DATAIN]

'if FirstChar = "A" then 'do something on "A"
' SEROUT2 TX, Baud,["B", Dec Z,13] 'send a char to E1 remote
' Pause 2000 'pause due to a timing issue with buffers i think
'else
'if FirstChar = "C" then 'do someting on "C"
' SEROUT2 TX, Baud,["D", Dec Z,13] 'send a char to E2 remote
' Pause 2000 'pause due to a timing issue with buffers i think
'else
' etc., up through remote E6 unit
'endif



;--[EP1]--------------------------------------------------------------------

XB_E1_MYAddr CON $1 ' Node Address E1
XB_BASE_DestDLAddr CON $0 ' Base Destination address

SEROUT2 TX, Baud,["A", Dec Z, 13] 'send char "A" + data to xbee base
SERIN2 RX\RTS, baud, 2500, TimeOut1, [Wait("B"), Dec DataIn]

;--[EP2]--------------------------------------------------------------------

XB_E2_MYAddr CON $2 ' Node Address E2
XB_BASE_DestDLAddr CON $0 ' Base Destination address

SEROUT2 TX, Baud,["C", Dec Z,13] 'send char "C" + data to xbee base
SERIN2 RX\RTS, baud, 2500, TimeOut1, [Wait("D"), Dec DataIn]

[...]
E3 .. E6 remotes
[...]
;------------------------------------------------------------------------

aratti
- 31st January 2009, 19:37
I will think loud on how I would solve the problem.


Six XBee sensors are all slave addresses are : S01 S02 .... S06

XBee coordinator is the master, so no address is needed

Slave S01 has data to send so, "S01" + Data will be Tx out

Immediatly after Tx action, Slave S01 go to RX loop count routine and here waits master ACK.


LoopCount:

Count=Count+1
if Count=XX then
Count=0
Time= Time +1
goto Tx again
endif

If Time=YY then error

SERIN2 RX\RTS, baud, 2500, LoopCount, [Wait("S01"), Data]

If Data=6 then main

goto LoopCount


This action will be repeated so many time as judged feasible using variable XX while variable YY will trigger an error in case of no response.

Master receive address + data then answer with received slave address + ACK

Slave Receive the proper address + ACK then delete data and return to main loop. (This will avoide to disturb the other slaves which will ignore the Tx)

Collisons are not avoided but ignored since Slaves will continue to Tx address + Data till it receives its address + ACK

The same will apply for all the other slaves.

Al.

rdxbam
- 2nd February 2009, 08:43
Al, many thanks for the brainstorm.

Thinking out loud here....

I see where I was getting hung up, the "ack" and the addressing.

My xbee's are series-1 so as long as my remote sensors set the xbee [DL] value to the xbee coordinator [MY] value they'll talk point-to-point, which is what i want.

I can prefix an incoming data packet with an "identifier" so the coordinator knows which remote and thus that data is to follow. And when the coordinator recieves data along with an end of message character I can have it send an "ack" back to the sending remote thus qualifying the data sent.

I can see where I was stuck in my thinking, thanks for clearing the picture.

Cheers!