Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Aim
To transfer the data by implementing Zigbee protocol using sensors
Specification
RF module (Coordinator& End Device)
Debugger module
Battery boards
IAR Embedded workbench evaluation version 5.71
Smart RF programmer
WinX talk
Theory
ZigBee is a wireless communication protocol for low power, low rate, reliable, and
secured wireless personal area network, developed by ZigBee Alliance based on IEEE 802.15.4
standard. A ZigBee network is a multi-hop network with battery-powered devices. This means
that two devices that wish to exchange data in a ZigBee network.
Device Types
There are three logical device types in a ZigBee network. (i) Coordinator (ii) Router and
(iii) End-device. A ZigBee network consists of a Coordinator node and multiple Router and End
device nodes.
Coordinator
This is the device that starts a ZigBee network. It is the first device on the network. The
coordinator node chooses a channel and a network identifier (also called PAN ID) and then starts
the network. The coordinator node can also be used, optionally, to assist in setting up security
and application-level bindings in the network. Note that the role of the Coordinator is mainly
related to starting up and configuring the network. Once that is accomplished, the Coordinator
behaves like a Router node (or may even go away). The continued operation of the network does
not depend on the presence of the Coordinator due to the distributed nature of the ZigBee
network.
Router
A Router performs functions for (i) allowing other devices to join the network (ii) multi
hop routing (iii) assisting in communication for its child battery-powered end devices. In general,
Routers are expected to be active all the time and thus have to be mains-powered. A special
mode of network operation, called Cluster Tree, allows Routers to operate on a periodic duty
cycle and thus enables them to be battery-powered.
End Device
An end-device has no specific responsibility for maintaining the network infrastructure,
so it can sleep and wake up as it chooses. Thus it can be a battery-powered node. Generally, the
memory requirements (especially RAM requirements) are lower for an end-device.
Sensor
Temperature Sensors are the key to read temperatures correctly and to control
temperature in industrials applications.
+5V
GND
GND
OUTPUT
LM35
Figure 1 Circuit diagram for the LM35 temperature sensor functional module
In the temperature functional module we developed, we use the LM35 series of temperature
sensors. The LM35 is an integrated circuit sensor that can be used to measure temperature with
an electrical output proportional to the temperature (in
o
C).It has an output voltage that is
proportional to the Celsius temperature.
Program
Program for Coordinator
void Example_MessageMSGCB( afIncomingMSGPacket_t *pkt )
{
uint8 buf[11];
uint8 d1,d2,d3,d4,d5;
uint8 buf2[3];
buf2[0]=0x0d;
buf2[1]=0x0a;
switch ( pkt->clusterId )
{
uint8 seqnb;
/******* FORCE SENSOR **********/
case EXAMPLE_PERIODIC_CLUSTERID1:
HalLedSet (HAL_LED_1, HAL_LED_MODE_OFF);
seqnb = pkt->cmd.TransSeqNumber;
d1=pkt->cmd.Data[0];
d2=d1/100;
d3=d1%100;
d4=d3/10;
d5=d3%10;
buf[0]=d2+0x30;
buf[1]=d4+0x30;
buf[2]=d5+0x30;
HalUARTWrite( HAL_UART_PORT_1, buf2, 2 );
HalUARTWrite( HAL_UART_PORT_1, buf, 3 );
HalUARTWrite( HAL_UART_PORT_1, buf2, 2 );
break;
case EXAMPLE_FLASH_CLUSTERID :
break;
}
}
Program for End device
void Example_SendPeriodicMessage( void )
{
uint8 buf1[2];
/********* FORCE SENSOR ***********/
HalLedSet(HAL_LED_1,HAL_LED_MODE_TOGGLE);
//buf1[0]='A';
buf1[0]=2*HalAdcRead ( HAL_ADC_CHANNEL_2, HAL_ADC_RESOLUTION_8 );
if ( AF_DataRequest( &Example_Periodic_DstAddr, &Example_epDesc,
EXAMPLE_PERIODIC_CLUSTERID1,
//EXAMPLE_PERIODIC_CLUSTERID2 for motion sensor and touch sensor
1,
&buf1[0],
&Example_TransID,
AF_DISCV_ROUTE,
AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
{
}
else
{
// Error occurred in request to send.
}
count++;
if(count == 0xFF)
{
count = 1;
}
}
Result
Implementation of Zigbee protocol using ADC for data transfer applications.
Aim
To transfer the data by implementing Zigbee protocol using ADC
Specification
RF module (Coordinator& End Device)
Debugger module
Battery boards
IAR Embedded workbench evaluation version 5.71
Smart RF programmer
WinX talk
Theory
An analog-to-digital converter is a device that converts a continuous quantity to a
discrete digital number. Typically, an ADC is an electronic device that converts an input
analog voltage (or current) to a digital number proportional to the magnitude of the
voltage or current. The resolution of the converter indicates the number of discrete values
it can produce over the range of analog values. The values are usually stored
electronically in binary form, so the resolution is usually expressed in bits. In
consequence, the number of discrete values available, or "levels", is usually a power of
two.
Program for Coordinator
void Example_MessageMSGCB( afIncomingMSGPacket_t *pkt )
{
uint8 buf[11];
uint8 d1,d2,d3,d4,d5;
uint8 buf2[3];
buf2[0]=0x0d;
buf2[1]=0x0a;
switch ( pkt->clusterId )
{
uint8 seqnb;
/******* FORCE SENSOR **********/
case EXAMPLE_PERIODIC_CLUSTERID1:
HalLedSet (HAL_LED_1, HAL_LED_MODE_OFF);
seqnb = pkt->cmd.TransSeqNumber;
d1=pkt->cmd.Data[0];
d2=d1/100;
d3=d1%100;
d4=d3/10;
d5=d3%10;
buf[0]=d2+0x30;
buf[1]=d4+0x30;
buf[2]=d5+0x30;
HalUARTWrite( HAL_UART_PORT_1, buf2, 2 );
HalUARTWrite( HAL_UART_PORT_1, buf, 3 );
HalUARTWrite( HAL_UART_PORT_1, buf2, 2 );
break;
case EXAMPLE_FLASH_CLUSTERID :
break;
}
}
Program for End device
void Example_SendPeriodicMessage( void )
{
uint8 buf1[2];
/********* FORCE SENSOR ***********/
HalLedSet(HAL_LED_1,HAL_LED_MODE_TOGGLE);
//buf1[0]='A';
buf1[0]=2*HalAdcRead ( HAL_ADC_CHANNEL_0, HAL_ADC_RESOLUTION_8 );
if ( AF_DataRequest( &Example_Periodic_DstAddr, &Example_epDesc,
EXAMPLE_PERIODIC_CLUSTERID1,
//EXAMPLE_PERIODIC_CLUSTERID2 for motion sensor and touch sensor
1,
&buf1[0],
&Example_TransID,
AF_DISCV_ROUTE,
AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
{
}
else
{
// Error occurred in request to send.
}
count++;
if(count == 0xFF)
{
count = 1;
}
}
Result