Getting Started: Running the ZigBeetm-2006 Demo
RUNNING
THE APPLICATION USING PUSHBUTTONS
RUNNING
THE APPLICATIONS via the HYPER-TERMINAL CONSOLE
The Microchip ZigBee 2006
Residential protocol stack, version v2.0-2.6.xx, provides wireless connectivity
based on the standards set by the ZigBee Alliance. The ZigBee standard uses the IEEE 802.15.4
for the Physical and MAC layer definitions.
The remaining layers are defined by the ZigBee Alliance. Customization on the Application Layer allows
users to develop a wide range of applications based on the ZigBee protocol.
The application that is included as part of version v2.0-2.6.xx of the Stack, demonstrates several network connectivity features. These features include:
· The ability to enable or disable devices from joining other devices that are on a network. This feature is useful in assisting the configuration of a specific network topology when first forming a network.
· The capability for sending data to, or requesting data from, a specific device – unicast addressing, and sending to, or requesting from all the devices in the network – broadcast addressing.
· Multicasting – The capability for sending data to, or requesting from, devices that are members of a specific group. A group ID is used to reference the devices that are part of a given group.
· The capability for adding or removing a device from membership in a Group. Later in this Guide, instructions are provided on how to add and/or remove a device to and/or from groups.
· The ability to display the Neighbor Table information for each device.
All of the above features are available to the user via the Stack Application’s menu driven system.
The following features are available via two Push Buttons on both the PICDEM Z and Explorer 16 platforms:
· Multicasting – Sending data to, or requesting from, devices that are members of Group 0x0004.
·
Adding or removing a device from membership in
Group 0x0004.
Group 0x0004 is hard coded in the current push button application in order to simplify the code and to illustrate the Multicasting feature as simply as possible. However, from the menu driven application, the user has the option of choosing Group IDs within the range of 0x0001 to 0x00f0.
Individual nodes can include themselves as a member of a Group
by creating and maintaining a Group Table. The Group Table contains both the
Group ID and associated Endpoints of the group(s) to which the node is a member
of.
In order to set up a simple network consisting of two nodes, two hardware platforms chosen from any of the two configurations is required.
Hardware
Platform Set 1 (8-bit platform):
PICDEM Z 2.4 Demo Kit (DM163027-4 OR DM163027-5)
PICDEM
Z MRF24J40 2.4GHz Daughter Card (AC163027-4) OR
MRF24J40MA
PICDEM™ Z 2.4GHz RF Card (AC163028)
Hardware Platform Set 2 (16-bit platform):
Explorer
16 (DM240001)
PIC24FJ128GA010
Plug-In-Module (PIM) (MA240011)
PICDEM
Z MRF24J40 2.4GHz Daughter Card (AC163027-4) OR
MRF24J40MA
PICtail™ Plus 2.4GHz RF Card (AC164134)
Miscellaneous
Hardware
At least one RS-232 Serial Cable
Personal Computer with RS-232 COM port or USB to RS232 adapter
Environment
MPLAB C18 compiler v3.20 or higher for the PICDEM Z PIC18F Platform
MPLAB C30 compiler v3.10 or higher for the PIC24F Explorer 16 Platform
MPLAB IDE v8.10 or later
A programmer such as MPLAB REAL ICE or ICD 2,
This section describes how to set up the various configurations of hardware to run this demo.
1) Connect the MRF24J40 2.4GHz RF Card to the PICDEM Z demo board as shown below
1) Before attaching the PIM to the Explorer 16 board, insure that the processor selector switch (S2) is in the “PIM” position as seen in the image below.
2) Short the J7 jumper to the “PIC24” setting
3) Before connecting the PIM to the Explorer 16 board, remove all attached cables from both boards. Connect the PIM to the Explorer 16 board. Be careful when connecting the boards to insure that no pins are bent or damaged during the process. Also insure that the PIM is not shifted in any direction and that all of the headers are properly aligned.
4) Connect the MRF24J40 2.4GHz Daughter Card or MRF24J40MA PICTail™ Plus 2.4GHz RF Card to the first slot of edge card connector.
The entire source code for the ZigBee2006 Stack is included as part of the release. The picture below depicts the directory structure for the code. The ZigBee device types – Coordinator, Router and Reduce Function End Device (RFD) are included as part of the application. A separate project file is provided for each device type such that each device can be built and be customized for specific operations. The code is suitable for development on both the PICDEM Z and the Explorer 16 platforms.
In the application provided:
Push Button RB4/RD6 is used to add or remove the node from group 0x0004
Push Button RB5/RD7 is used to send a group broadcast message to any device that is a member of group 0x0004. The group broadcast message requests each of the devices in the group to send back ten bytes of the data to the requester. The data that is returned to the requester will be the byte pattern [00 01 02 03 04 05 06 07 08 09 0A].
LED RA0/D10 is turned ON whenever the device is a member Group 4; and turned OFF otherwise.
LED RA1/D09 is used as a toggle on/off indicator. It indicates that the node has received and responded to messages addressed to it whenever it is a member of the Group 0x0004. Therefore, whenever a node is a member of Group 0x0004 and it receives a request from another device to send data, after it sends the data it will toggle this LED. This is a useful and simple way to visually ascertain that the communication link between devices is working.
When the node is connected to a hyper terminal console, then the contents of the received messages are displayed whenever the node is a member of Group 0x0004.
Note: There may be a slight inconsistency in the
feel of the pushbuttons from device to device, so please press and release the
buttons firmly, to get a consistent result across all the devices.
In order to run the sample demo
applications that are included in version v2.0-2.x of the ZigBee Stack, the
appropriate software must be downloaded onto the hardware platform. The Coordinator and the Router and/or RFD
devices must be programmed with the proper device type selected in MPLAB. There two are two methods available for downloading the demo applications: Using
the Precompiled Demo Applications and building the source code from the
projects that are provided.
Using the Precompiled Demo Applications
The Precompiled Demo Applications are available at
the following location:
“<Install
Directory>\ZigBee2006Res\ Microchip\PreBuilt Hex
Files \DemoPIC24FCoordinator.hex”
“<Install Directory>\ZigBee2006Res\
Microchip\PreBuilt Hex Files\DemoPIC24FRouter.hex”
“<Install Directory>\ZigBee2006Res\Microchip\PreBuilt Hex Files\DemoPIC24FRFD.hex”
There are similar sub-directories of the PIC18 platform as well.
Use the File –> Import menu from MPLAB® IDE to
import the .hex file and then use
the MPLAB® Programmer to program the
demo applications, first into the Coordinator and then either to the Router or
RFD device.
This guide explains the Zigbee communication between the Coordinator and
the Router.
Building the Demo Applications
The source code for this demo applications are
available in the following folders:
“<Install Directory>\ZigBee2006Res\DemoPIC24FCoordinator”
“<Install Directory>\ZigBee2006Res\DemoPIC24FRouter”
“<Install Directory>\ZigBee2006Res\DemoPIC24FRFD”
In these directories, you will
find all of the application level source and header files as well as the project
and workspace files for each of the hardware platforms.
Double click on the .mcw workspace files in the appropriate folders to
launch MPLAB® IDE. After selecting the
appropriate programmer that is to be used, select the Project > Build-All option to build. Program the created firmware to the devices.
For those who are not familiar with using MPLAB
IDE, the following link to the MPLAB User’s Guide will provide the help needed
to set up the environment. The guide can be found at http://www.microchip.com/mplab
You will need:
·
A pair of PICDEM Z and/or Explorer 16 devices, which
are loaded with the correct demo application. One of the devices must be a Coordinator. The other device can be either a Router or a RFD.
1.
Plug in the ZENA Network analyzer into the personal
computer’s USB port and configure it to monitor network traffic on channel 26.
2.
Apply power to the Coordinator device with a 9V wall
adapter or 9V battery. Press and release
the pushbutton labeled MCLR. The two LEDs labeled RA0/D10
and RA1/D09 will be turned ON,
indicating that the device has formed a network. Observe the Beacon Request Packet on
Zena. The Coordinator is now ready to
accept other devices on its network.
3. Apply power to the Router device with a 9V wall adapter or 9V battery. Press and release its MCLR pushbutton. Two LEDs labeled RA0/D10 and RA1/D09 will be turned ON, indicating that the device has joined the network. Observe on Zena the Association Request packet from the Router and the successful Association Response packet from the Coordinator. The Router has now successfully joined the network.
Both Devices are up and running but
neither is yet a member of the Group 0x0004. When a router receives a group
broadcast message, first, it rebroadcasts this message so that other nodes in
the network can receive the broadcast message. Secondly, it also checks if one
of its endpoints is in the same group and if so, it responds to the broadcast
request by responding. As none of the
nodes are in any specific group at reset, if Coordinator sends messages to Group
0x0004 the Router will only rebroadcast these messages, but it will not respond
with the requested 10 bytes that the Coordinator asks for.
4. On the Coordinator, press and release the button labeled RB5/RD7. Observe the traffic on Zena. The messages will be broadcast messages with destination address 0xffff; Source Address 0x0000(from the Coordinator), and a tag that labels the messages as group addressed broadcast messages. The Router will rebroadcast the messages but does not respond to the Coordinator, since it is not yet a member of Group 0x0004.
Now add the Router to Group 0x0004
by doing the following:
5.
Press and release the RB4/RD6 button on the Router
device and observe the RA0/D10 LED toggling on and off as RB4/RD6 is pressed
and released. Press and release the RB4/RD6
push button such that RA0/D10 remains ON after the button is released. When RA0/D10 is ON, this indicates that the
Router has added itself as a member of Group 0x0004. There is no associated traffic on Zena
since this is an internal operation and nothing is transmitted over the air.
6.
Press and release RB5/RD7 on the Coordinator. This will
send a group broadcast message to all nodes that are in Group 0x0004.
Observe that the message is broadcast to destination address 0xFFFF, Group
Address 0x0004 on Zena.
Observe that the RA1/D09 LED on the Router toggles on/off each
time RB5/RD7 on the Coordinator is
pressed. This indicates that the Router
is now responding to messages sent from the Coordinator to Group 0x0004 because
it is now a member of that group.
7.
Press and release the RB4/RD6 button on the Router once
again until its RA0/D10 LED is turned off.
This indicates that the Router has removed itself from Group 0x0004. Further messages to Group 4 from the
Coordinator will not be responded to.
8.
The User may add the Coordinator to Group 0x0004 as
well by repeating the steps outlined above, and send messages to it from the
Router by pressing the Router’s RB5/RD7 push button.
The application works bi-directionally – i.e. in exactly same way on all the
ZigBee device types – Coordinators, Routers and Reduce Function End Devices.
Summary of Push Button Operation:
Button: RB4/RD6: Adds a node to, or removes a node from Group 0x0004. The Group ID 0x0004 is hard coded in the application.
Led: RA0/D10: Used to indicate if a node is a member of Group 0x0004 (ON – yes; OFF – no)
At startup the devices are not in
any group, and the LEDs are ON to indicate the device are on the network.
Button: RB5/RD7 : Is used to send a messages to nodes in Group 0x0004. The actual message is a request for all the Group 0x0004 nodes to send back to the requester 10 bytes.
Led: RA1/D09 : Toggles to indicate that the receiving node is in Group 0x0004 and received requests for data.
To operate the application from the hyper terminal menu system please do the following:
1. Follow
steps 1 to3 from the Operating via Pushbutton section to get the devices load
with the firmware and joined onto a network.
2. Connect
a RS-232 cable from the Coordinator device to the PC.
3. Open up a Hyper Terminal window on the PC to the COM port to which the RS-232 is connected. The Hyper-terminal configuration should be:
· Baud Rate: 19200
· Data bits: 8-bits
· Parity: None
· Stop bits 1
· Flow Control: None
4. Hit
the Carriage Return/Line Feed <Enter> Key and the following menu system
will be displayed on the PC console.
Note the seven menu options 1 - 7 that are available.
5. Please
press the <MCLR> button on the Router device. This will force the Router to rejoin the
network. Note the 16-bit Network and
the 64-bit MAC addresses of Router are displayed on the Coordinator’s
console. In a typical two device
network, the network address of the Router is 0x0001.
6. To request data from the Router via the
Coordinator menu, do the following:
From the menu select menu option < 2 >:
2: Request Data
From Another Device
How many bytes are you requesting(hex): 0a
What is the short address of device you want data from:
0001
or whatever the network address of the
router is
This will send a data request to the Router via a unicast – directly and only to
the Router asking for 0x0a bytes of data to be returned.
The response from the Router will be:
Len: 0a
From Address:: 0001
00000102030405060708090A
i.e. A payload of length 0x0a bytes is returned from the device at
network address 0001, followed by the raw payload bytes that was requested. The
payload is preceded by a one-byte status byte which has a value 00.
7. To request data from a devices that are members of a particular group do the following:
· Press and release the RB4/RD6 button on the Router device several times. Observe that theRA0/D10 LED toggling on/off as RB4/RD6 is pressed and released. Press and release the RB4/RD6 button such that RA0/D10 remains ON after the button is released. This will place the Router in Group 0x0004.
·
From the Coordinator menu select menu option
<3>
3. Please enter
the Group ID of the Data Request: 0004
The response from the Router will be:
Len: 0a
From Address:: 0001
0000010203040506070809
The Router is part of Group 0x0004 so it responds with the above
information.
8. To
send data directly to the Router from the Coordinator menu use menu option <4>:
4: Request Data From Another Device
Please enter the number of bytes to send (hex): 0a
Please enter the short address of the destination
device: 0001
This will send ten bytes of data directly to Router. The Coordinator will display: Message sent
successfully. Observe the traffic
on Zena to confirm that the message is successfully sent.
9. To
add the Coordinator to Group 0x0004, do the following from the
Coordinator menu. Select menu option 6.
6: Add/Remove Device to/from a Group
What Group Activity do you want to do ?
0=Add Device to a Group
1=Remove Device from a Group
2=Remove Device from All Groups: 0
Enter 16-bit Group ID (Hex): 0004
this will add the Coordinator to Group ID 0x0004. Now by pressing the RB5/RD7 on the Router
will result in the Coordinator responding by sending 10 bytes of data back to
the Router.
Use the same menu and choose sub-option 1 or 2 to remove the Coordinator from a
Group.
10. To see what devices are currently stored in
the Coordinator’s Neighbor Table choose menu option ‘7’ on the Coordinator
menu:
7: Dump
Neighborhood Information
The information that will be displayed is the following -
Short MAC Type Rntlship
0001 0000000100000000 RTR CHILD
This means that the Router with the noted network address 0001 and MAC address 0000000100000000 is a child of the Coordinator.
As more devices join the network, this table will contain more entries.
Index |
Symptom |
Solution |
1 |
The LEDs are OFF on Coordinator |
Press the <mclr> button to reset the Coordinator node |
2 |
The LEDs are OFF on Router/RFD node |
First reset the Coordinator, followed by resetting the node. |
3 |
No Traffic on Zena |
Ensure that Zena is operating on channel 26. Ensure that the Coordinator has formed the network by connecting a hyper terminal and hitting the <CR><LF> several times until the menu is displayed on the Coodinator. Press and release the RB5/RD6 push-button on the node. |
4 |
No data is received from another node when RB5/RD6 is pressed and released |
Ensure that at least one other node on the network is a member of Group 0x0004 |
5 |
The RFD LEDs are not blinking |
The RFD has lost contact with its parent. Move RFD node closer to a Coordinator/Router node that is on the network and pressed the <mclr> button. |
|
|
|
The Microchip name and logo, the Microchip logo, MPLAB, and PIC
are registered trademarks of Microchip Technology Incorporated in the
PICDEM, PICTail and MiWi are registered trademarks of Microchip Technology
Incorporated in the
IEEE 802.15.4 is registered trademarks of IEEE 802.15 working
group