Zigbee Development Board (Z- DB001) - H-2...
-
Upload
truongduong -
Category
Documents
-
view
222 -
download
4
Transcript of Zigbee Development Board (Z- DB001) - H-2...
Z-DB001
Rhode-Island-Allee 49, Karlsruhe, Germany D-76149 +49 721 6624655/+49 1797087228
www.h-
2technik.com
Zigbee Development Board (Z-
DB001)
with Z-001 or Z-002 Module
H-2 Technik UG (haftungsbescgränkt) www.h-2technik.com
Z-DB001
Rhode-Island-Allee 49, Karlsruhe, Germany D-76149 +49 721 6624655/+49 1797087228
www.h-
2technik.com
Version Information
Version Date Modified By Introduction
1.1 05.2017 Wang Release
Inhalt 1. Hardware Description ............................................................................................................. 3
1.1 Base Board ............................................................................................................................... 3
1.2 Zigbee Module ......................................................................................................................... 4
1.3 Emulator .............................................................................................................................. 4
2. Set up IDE ................................................................................................................................ 5
2.1 Installation Software and Driver .............................................................................................. 5
2.2 Test Project .............................................................................................................................. 6
2.2.1 Create new project in IAR ........................................................................................................ 6
2.2.2 Create new file ........................................................................................................................ 6
2.2.3 Programming ........................................................................................................................... 7
2.2.4 Options .................................................................................................................................... 7
2.2.5 Make and debug ...................................................................................................................... 9
3. Application example using TI “RF Basic” library .................................................................... 10
3.1 UART communication ............................................................................................................ 10
3.2 Remote Control (LED) ........................................................................................................... 13
4. Application Example using Z-Stack ........................................................................................ 14
4.1 UART configuration in Z-Stack ............................................................................................... 14
4.2 Testing Z-Stack ....................................................................................................................... 15
Z-DB001
Rhode-Island-Allee 49, Karlsruhe, Germany D-76149 +49 721 6624655/+49 1797087228
www.h-
2technik.com
1. Hardware Description
1.1 Base Board Z-DB001 can use Nr-7 (3.7V lithium) battery through the LDO regulator as power supply. In
this case Z-DB001 turns into Zigbee mobile node. The design greatly improves the node's
working time and saves user expenses. Add on lithium battery charging circuit, makes USB
Plug & Play for charging.
Features:
Base plate size: 7 * 5 cm
Serial communication: comes with USB to serial port function (PL2102)
Power supply: square port USB, DC2.1 power supply (5V). 7 lithium battery (3.7V)
Interface: Debug interface, compatible with TI standard simulation tool, leads to all IO port,
commonly used serial port pin and 5V / 3.3V pin
Buttons: Reset, 2xButton
LEDs: Power Indicator, Network Indicator and Common LED
Core Module Support: Supports Z-001 and Z-002
Sensor module: Temperature/Smoke/Humidity and so on.
Z-DB001
Rhode-Island-Allee 49, Karlsruhe, Germany D-76149 +49 721 6624655/+49 1797087228
www.h-
2technik.com
1.2 Zigbee Module Z-DB001 Base board supports two types of Zigbee modules: Z-001 and Z-002. The key
difference between the two modules is PA circuit.
Z-001 ( without PA circuit. Please refer to http://www.h-
2technik.com/online/webee/ZigBee/Z-001/Z-001.pdf) for detail;
Z-002 (with PA circuit. Please refer to http://www.h-
2technik.com/online/webee/ZigBee/Z-002/Z-002.pdf) for detail;
1.3 Emulator User programs can be downloaded and debugged by using emulator. SmartRF Studio and
packet sniffer function are also supported.
Key Feature: 4.7 x 2.3 cm, USB interface, Power supply for base board.
Z-DB001
Rhode-Island-Allee 49, Karlsruhe, Germany D-76149 +49 721 6624655/+49 1797087228
www.h-
2technik.com
2. Set up IDE
2.1 Installation Software and Driver
IAR: To programming Z-DB001 development kit is IAR (8.10, https://www.iar.com/)
recommended. The advantage of using IAR as IDE is that Z-Stack
(http://www.ti.com) library can be imported/referred in project very easily.
Install Zstack-CC2530-2.5.1a(Download): Please note that all of examples in this
documentation are based on Z-Stack-CC2530-2.5.1a (Zigbee 2007).
Emulator (SmartRF04EB) driver (http://h-
2technik.com/online/webee/ZigBee/Dongle/Driver/cebal.zip). After installation,
you insert the emulator into PC USB port, in device manager following should be
seen:
To test if emulator can recognize CC2530 Zigbee chip, you connect emulator to base
board (with Z-001 or Z-002) and press “Reset” button, LED2 is ON (blue) meaning
CC2530 has been detected.
Install Driver for USB to UART(http://h-
2technik.com/online/webee/USB_TTL/CH340G_Driver%26Tool.zip): Z-DB001 board
integrated CP2102 USB to serial chip, we can install the corresponding driver for
developing and debugging. After successful installation, in device manager you can
see following:
Z-DB001
Rhode-Island-Allee 49, Karlsruhe, Germany D-76149 +49 721 6624655/+49 1797087228
www.h-
2technik.com
2.2 Test Project
After development environment has been set up, we can start with a simple project and
test.
2.2.1 Create new project in IAR Open IAR, project->Create New Project, accept all default settings and save project.
2.2.2 Create new file
File->new File to create a new file and input “#include <ioCC2530.h>” at the beginning of
file, saving file with “.c” suffix under project path.
Z-DB001
Rhode-Island-Allee 49, Karlsruhe, Germany D-76149 +49 721 6624655/+49 1797087228
www.h-
2technik.com
2.2.3 Programming You type following code in your c file:
After saving, right clicking on project in workspace and “add” this file into project.
2.2.4 Options Project->Options, opening options configuration windows and selecting “General
Options”. Now you have to select “CC2530F256” in “Device” from <Texas Instruments>
directory.
Z-DB001
Rhode-Island-Allee 49, Karlsruhe, Germany D-76149 +49 721 6624655/+49 1797087228
www.h-
2technik.com
Selecting Linker on left side, open “Config” register, choosing “Ink51ew_cc2530F256.xcl”
from as Linker command file from <Texas Instruments> directory.
Selecting Debugger on left side, changing driver to “Texas Instruments” (emulator) and
choosing “io8051.ddf” as Driver Description file from “_generic” directory.
Z-DB001
Rhode-Island-Allee 49, Karlsruhe, Germany D-76149 +49 721 6624655/+49 1797087228
www.h-
2technik.com
2.2.5 Make and debug You can start to compile first project. If there is neither Error nor Alarm, you can connect
emulator to Z-DB001 base board, click Project->Download and Debug (You find short-cut
key in IAR as well).
Z-DB001
Rhode-Island-Allee 49, Karlsruhe, Germany D-76149 +49 721 6624655/+49 1797087228
www.h-
2technik.com
Debugging process is started after download is over. You will see the LED1 is turned on.
After debugging, the program has been already written into flash of CC2530.
3. Application example using TI “RF Basic” library
After IDE is set up and tested, you can create applications. Following examples show basic
communication functions based CC2530 (Z-DB001 + Z-001).
3.1 UART communication
This example runs on Z-001 and sends string continuously to PC through UART.
Creating a new project and a “.C” source file (refer to 2.2 for detail). You can copy
following code into source file.
#include <ioCC2530.h>
#include <string.h>
#define uint unsigned int
#define uchar unsigned char
#define LED1 P1_0
#define LED2 P1_1
//function declaration
void Delay_ms(uint);
void initUART(void);
void UartSend_String(char *Data, int len);
Z-DB001
Rhode-Island-Allee 49, Karlsruhe, Germany D-76149 +49 721 6624655/+49 1797087228
www.h-
2technik.com
char Txdata[18]; //buffer storing "Hello H-2 Technik"
//delay function
void Delay_ms(uint n)
{
uint i, j;
for (i = 0; i<n; i++)
{
for(j=0; j<1774; j++);
}
}
void IO_Init()
{
P1DIR = 0x03; //output
LED1 = 0; //close
LED2 = 0;
}
//init UART
void InitUART(void)
{
PERCFG = 0x00; //set P0 port
P0SEL = 0x0c; //Function setting P0_2, P0_3 as UART
P2DIR &=~0xc0; //P0 as UART0 preferentially
U0CSR |= 0x80; // setting UART mode
U0GCR |= 11; //with U0BAUD together set Baud rate = 115200
U0BAUD |=216; // with U0GCR together set Baud rate = 115200
UTX0IF = 0; // UART0 TX interrupt init value 0
}
//sending chars
void UartSend_String(char *Data, int len)
{
int j;
for (j=0; j<len; j++)
{
U0DBUF = *Data++; //Sending/Receiving buffer
while(UTX0IF == 0);
UTX0IF = 0; //flag bit of sending interrupt
}
}
Z-DB001
Rhode-Island-Allee 49, Karlsruhe, Germany D-76149 +49 721 6624655/+49 1797087228
www.h-
2technik.com
void main(void)
{
CLKCONCMD &=~0x40; //set system-clock to 32MHZ
while(CLKCONSTA & 0x40); // waiting for stable 32MHZ
CLKCONCMD &=~0x47; //setting QUARZ to 32 MHZ
IO_Init();
InitUART();
strcpy(Txdata, "Hello H-2 Technik");
while(1)
{
UartSend_String(Txdata, sizeof("Hello H-2 Technik")); //UART sending
Delay_ms(500); //delay
LED1 = !LED1; //status for sending
}
}
Make Program and download it to Z-001 using emulator. You connect TxD, RxD of UT-001
to RxD, TxD of UART1 pins on base board ( Z-DB001) and connect USB cable (power supply)
to Z-DB001. On PC you can start Serial-Monitor application and create connection to given
COM port. You can see the message sent by Z-001. During sending message, LED1 on base
board is blinking to indicate this action. Please refer picture below.
Z-DB001
Rhode-Island-Allee 49, Karlsruhe, Germany D-76149 +49 721 6624655/+49 1797087228
www.h-
2technik.com
3.2 Remote Control (LED) In this application two Z-DB001s are required. One Z-DB001 works as Sender, another one
works as Receiver.
This application is based on CC2530_BasicRF package from TI ( In this package, IEEE
802.15.4 Data sending/receiving is implemented, but not all Zigbee Protocoll stack ). You
can download the complete application package from here. For detail specification of Basic
RF Library you can refer to the documentation under path “./docs”.
The complete folder structure of CC2530_BasicRF shows below:
Please notice that CC2530_BasicRF examples are tested based on TI development borad. To
use them on Z-DB001, some modification are necessary.
Now you can open project under “.\ide\srf05_cc2530\iar\light_switch.eww” (remote
control LED) in IAR. As mentioned before, you have to modify source code firstly. To do so,
clicking node “application” and open “light_switch.c” source file.
You can find two statements in main function:
…
appSwitch(); // handler for S1 pressed
appLight(); // handler for turning ON/OFF LED1
…
For Sender, please comment statement “appLight()” out; for Receiver, the statement
“appSwitch()” has to be commented out. At final, make and download modified projects to
sender, receiver separately.
Z-DB001
Rhode-Island-Allee 49, Karlsruhe, Germany D-76149 +49 721 6624655/+49 1797087228
www.h-
2technik.com
4. Application Example using Z-Stack
In this example, you will use Z-Stack (Zigbee protocol is implemented completely) package,
which has been installed (please refer to 2.1 for detail).
Two Z-DB001 are required for this example, one is Zigbee coordinator, another is end
device.
After coordinator detects the end device, it sends “I found a device …” message to its UART
which can be viewed in serial monitor on PC.
4.1 UART configuration in Z-Stack
Finding and opening project “SampleApp.eww” from installed TI Z-Sack package in IAR.
Open “MT_UART.c” file which can be found under “MT” and perform following
modification:
change default baud rate from 38400 to 115200 bps:
#define MT_UART_DEFAULT_BAUDRATE HAL_UART_BR_38400
replaced by: #define MT_UART_DEFAULT_BAUDRATE HAL_UART_BR_115200
close overflow control: #define MT_UART_DEFAULT_OVERFLOW TRUE
replaced by:
#define MT_UART_DEFAULT_OVERFLOW true
Open “SampleApp.c” file and locate function “SampleApp_Init(…)”, add following two
statements into:
Z-DB001
Rhode-Island-Allee 49, Karlsruhe, Germany D-76149 +49 721 6624655/+49 1797087228
www.h-
2technik.com
Please add header file “MT_UART.h” at the beginning of “SampleApp.c” file.
To test your configuration, please download project to Z-DB001 with setting
“CoordinatorED” in workspace.
4.2 Testing Z-Stack In SampleApp.C file you add following statement after “case
SAMPLEAPP_PERIODIC_CLUSTERID”:
HalUARTWrite(0, “I found device…\n”, 18);
Downloading project with “CoordinatorEB” Setting and “EndDeviceEB” to two Z-DB001
separately.
Connection UART (coordinator) to PC serial monitor and power on two Z-DB001s, you can
see the message sent by coordinator “I found device…” continuously.