View previous topic :: View next topic |
Author |
Message |
hayee
Joined: 05 Sep 2007 Posts: 252
|
Zigbee Network |
Posted: Tue Jul 28, 2009 4:28 am |
|
|
Hi,
I want to make a network having one coordinator and two sensors board. Coordinator sends data to both sensors. Have anyone any example how to make a network and sends data?
I am using CCS Ember Zigbee and CCS compiler. |
|
|
adesport
Joined: 03 Apr 2008 Posts: 18 Location: France
|
|
Posted: Tue Jul 28, 2009 10:03 am |
|
|
For my Zigbee apps I'm using a module with its own Ember stack and drive the network from my PIC through AT command. |
|
|
hayee
Joined: 05 Sep 2007 Posts: 252
|
|
Posted: Tue Jul 28, 2009 11:19 pm |
|
|
Thanks adesport.
Can you send me some example files. |
|
|
adesport
Joined: 03 Apr 2008 Posts: 18 Location: France
|
|
Posted: Wed Jul 29, 2009 1:42 am |
|
|
Code: |
ATSend("AT+DASSL"); //Disconnect ZigBee Network
ATSend("AT+JN"); // Join any ZigBee PAN
//...
|
ATSend uses PIC UART to send command to a ZigBee module.
AT command answers are catch by an ISR with the UART as well. |
|
|
hayee
Joined: 05 Sep 2007 Posts: 252
|
|
Posted: Wed Jul 29, 2009 3:08 am |
|
|
I am using "CCS ember zigbee". I brought development kit from CCS. It interfaces with pic controller through SPI. There is no option for UART. |
|
|
adesport
Joined: 03 Apr 2008 Posts: 18 Location: France
|
|
Posted: Wed Jul 29, 2009 3:11 am |
|
|
So I guess CCS provides example files as usual... |
|
|
hayee
Joined: 05 Sep 2007 Posts: 252
|
|
Posted: Wed Jul 29, 2009 6:34 am |
|
|
I have made a network but it is not working properly. Coordinator sends data to both sensors one by one and both sensors receive data.
Problem starts here:
When I switch off sensor 1, sensor 2 stops receiving data
but
When I switch off sensor 2, sensor 1 receives data.
I want that both sensors do work independently. Whenever I switch off any of the sensors the other sensor receives data. |
|
|
adesport
Joined: 03 Apr 2008 Posts: 18 Location: France
|
|
Posted: Wed Jul 29, 2009 9:17 am |
|
|
Which kind of ZB devices are your sensor ? SED or FFD ? |
|
|
hayee
Joined: 05 Sep 2007 Posts: 252
|
|
Posted: Wed Jul 29, 2009 11:01 pm |
|
|
If "SED means Sleepy End Device" then I have two sleepy end devices,
and the Coordinator is acting as a FFD. |
|
|
adesport
Joined: 03 Apr 2008 Posts: 18 Location: France
|
|
Posted: Thu Jul 30, 2009 1:08 am |
|
|
If both your sensors are SED, their parent is your FFD. In this case, if one of your sensor goes off the other one will still be able to communicate.
Post your code to see if something is missing. |
|
|
hayee
Joined: 05 Sep 2007 Posts: 252
|
|
Posted: Thu Jul 30, 2009 1:22 am |
|
|
the codes are as follows
COORDINATOR SIDE:
Code: |
#include <18f452.h>
#fuses HS,NOWDT,NOLVP,PUT,NOBROWNOUT
#use delay(clock=20000000)
#use rs232(xmit=PIN_C6, rcv=PIN_C7, baud=9600)
#define COORDINATOR 1
#define APP_CHANNEL 0x0B
#define APP_PANID 0x1111
#define APP_POWER 0xFF
#include <E:\abdul hayee\pic controller\my examples\ember_zigbee\sending 1byte\sender\em260.h>
#include <E:\abdul hayee\pic controller\my examples\ember_zigbee\sending 1byte\sender\ember_utilities.c>
int a,b;
void main ()
{
EmberEUI64 emLocalEui64;
EmberStatus Status;
int16 childID;
EmberEUI64 childEui64;
EmberNodeType childType;
EmberApsFrame apsframe;
int8 messagetag=0x01;
int8 messagedata1;
int8 messageLength;
int16 indexOrDestination;
if (EmberInitialization())
{
EmberConfig();
EmberInitializeBinding();
ezspGetEUI64(&emLocalEui64[0]);
EmberAddEndPoint();
EmberFormNetwork();
Status=ezspPermitJoining(0xFF);
apsframe.profileID=0xC00F;
apsframe.clusterID=0x0001;
apsframe.sourceEndPoint=0x01;
apsframe.destinationEndPoint=0x01;
apsframe.options=0x0000;
apsframe.groupID=0x0000;
apsframe.sequence=0x00;
messageLength=1;
while (1)
{
EM260Tick();
sinkApplicationTick();
if(!input(PIN_A2))
{
ezspLeaveNetwork();
while(1)
{
delay_ms(10);
}
}
a=1;
status=ezspGetChildData(0,&childID,childEui64,&childtype);
if(status==0)
{
indexOrDestination=childID;
messagedata1=a;
status=ezspSendUnicast(EMBER_OUTGOING_DIRECT,indexOrDestination,
&apsframe,messagetag,messageLength,&messagedata1);
}
b=1;
status=ezspGetChildData(1,&childID,childEui64,&childtype);
if(status==0)
{
indexOrDestination=childID;
messagedata1=b;
status=ezspSendUnicast(EMBER_OUTGOING_DIRECT,indexOrDestination,
&apsframe,messagetag,messageLength,&messagedata1);
}
}
}
} |
SLEEPY_SENSOR_1:
Code: |
#include <18f452.h>
#fuses HS,NOWDT,NOLVP,PUT,NOBROWNOUT
#use delay(clock=20000000)
#use rs232(xmit=PIN_C6, rcv=PIN_C7, baud=9600)
#define SLEEPY_SENSOR 1
#define APP_CHANNEL 0x0B
#define APP_PANID 0x1111
#define APP_POWER 0xFF
#include <E:\abdul hayee\pic controller\my examples\ember_zigbee\sending 1byte\reciver_1\em260.h>
#include <E:\abdul hayee\pic controller\my examples\ember_zigbee\sending 1byte\reciver_1\ember_utilities.c>
int8 value1,value2,x;
void main()
{
EmberEUI64 emLocalEui64;
if(EmberInitialization())
{
EmberConfig();
EmberInitializeBinding();
ezspGetEUI64(&emLocalEUI64[0]);
EmberAddEndPoint();
EmberJoinNetwork(EMBER_SLEEPY_END_DEVICE);
while(1)
{
sensorApplicationTick();
EM260Tick();
if(!input(PIN_A4))
{
ezspLeaveNetwork();
while(1)
{
delay_ms(10);
}
}
value1=(rcvdata[x]);
value2=value1;
if(value2==1)
{
output_high(PIN_D0);
delay_ms(10);
output_low(PIN_D0);
delay_ms(10);
}
value2=0;
}
}
} |
SLEEPY_SENSOR_2:
Code: |
#include <18f452.h>
#fuses HS,NOWDT,NOLVP,PUT,NOBROWNOUT
#use delay(clock=20000000)
#use rs232(xmit=PIN_C6, rcv=PIN_C7, baud=9600)
#define SLEEPY_SENSOR 2
#define APP_CHANNEL 0x0B
#define APP_PANID 0x1111
#define APP_POWER 0xFF
#include <E:\abdul hayee\pic controller\my examples\ember_zigbee\sending 1byte\reciver_2\em260.h>
#include <E:\abdul hayee\pic controller\my examples\ember_zigbee\sending 1byte\reciver_2\ember_utilities.c>
int8 value1,value2,x;
void main()
{
EmberEUI64 emLocalEui64;
if(EmberInitialization())
{
EmberConfig();
EmberInitializeBinding();
ezspGetEUI64(&emLocalEUI64[0]);
EmberAddEndPoint();
EmberJoinNetwork(EMBER_SLEEPY_END_DEVICE);
while(1)
{
sensorApplicationTick();
EM260Tick();
if(!input(PIN_A4))
{
ezspLeaveNetwork();
while(1)
{
delay_ms(10);
}
}
value1=(rcvdata[x]);
value2=value1;
if(value2==1)
{
output_high(PIN_D0);
delay_ms(10);
output_low(PIN_D0);
delay_ms(10);
}
value2=0;
}
}
} |
|
|
|
adesport
Joined: 03 Apr 2008 Posts: 18 Location: France
|
|
Posted: Thu Jul 30, 2009 1:49 am |
|
|
Your code doesn't have any comment at all nice
Did you read "Wireless-Ember ZigBee™ Exercise Book Table Of Contents" provided by CCS? There may be some example.
Quote: | value1=(rcvdata[x]); |
Normally, a Sleepy End Device has to poll its parent in order to get messages from the network. I can't see this in your code, but again I'm not familiar with CCS Wireless - Ember ZigBee. |
|
|
hayee
Joined: 05 Sep 2007 Posts: 252
|
|
Posted: Thu Jul 30, 2009 7:24 am |
|
|
Ya I have read "Wireless-Ember ZigBee™ Exercise Book Table Of Contents". In the example SLEEPY SENSOR is sending data to the COORDINATOR, and in this example there is only one Coordinator and one Sleepy Sensor. No such example which have two sleepy sensors. I want to send data from Coordinator to Sleepy Sensors. I am only confused why one sensor is not responding when other is off. I referred to the CCS Team but they said that your code have no error.
Can you help me out or have you any examples which can solve my problem? |
|
|
adesport
Joined: 03 Apr 2008 Posts: 18 Location: France
|
|
Posted: Thu Jul 30, 2009 7:34 am |
|
|
Give me a link to all the CCS Zigbee documentation. I'll check it out. |
|
|
hayee
Joined: 05 Sep 2007 Posts: 252
|
|
Posted: Mon Aug 03, 2009 2:50 am |
|
|
I have only "CCS wireless-Ember Zigbee Exercise Book". |
|
|
|