datasheets.com EBN.com EDN.com EETimes.com Embedded.com PlanetAnalog.com TechOnline.com  
Events
UBM Tech
UBM Tech

Design Article

Comment


Tim.Gillman

8/30/2010 1:37 AM EDT

To find out more about ZigBee and Wireless Sensor Networking, go to Drew's ...

More...

ZigBee applications - Part 3: ZigBee PANs

Drew Gislason

7/23/2010 10:50 AM EDT

ZibBee Channels Example
In the example, Example 4-2 ZigBee Channels, I demonstrate scanning all the channels and then scanning a single channel for comparison. Notice how much longer it takes to scan all of the channels versus only one. (It's actually 16 to 1 in this case, since the example scans all 16 channels, then only 1 channel).

This example will use two ZigBee nodes: one to form the network (the ZigBee Coordinator), and one to join the network (a ZigBee End-Device). They happen to be a Home Automation light and switch, but they could be any application for the purposes of channel selection.

To follow the example with actual hardware, open the following two projects inside CodeWarrior:

• Chapter04\Example4-2ZigBeeChannels\NcbZcHaOnOffLight.mcp
• Chapter04\Example4-2ZigBeeChannels\SrbZedHaOnOffLight.mcp

If this process is still new to you, read Chapter 3, "The ZigBee Development Environment," which describes how to download images to the Freescale boards, step-by-step.

Load the two programs into the NCB and SRB boards, respectively. If this process is not familiar to you, go back to Chapter 3 and read about developing for the Freescale platform.

Then reset both boards. Press SW1 on both boards to form/join the network. Notice how long the running lights on the LEDs chase each other. This is the amount of time it takes to scan all 16 channels. The actual channel chosen is random (the channel is the third field, line 2 on the NCB board's LCD display), depending on how noisy each channel is. But, usually, channel 11 (the first one tried) is quiet enough to form the network on that channel.

The NCB display may look something like this:

Ha OnOffLight
Cfg 3bab 11 000

Next, reset both boards. This time, press SW4 on the NCB board to select a channel. Select channel 15. The channel number will change on the LCD display. Note also the hex pattern on the LEDs. Press SW4 on the other (SRB) board to select the same channel. Since the SRB doesn't have a display, make sure the channel pattern on the LEDs match what is on the NCB. Only then, press SW1 on both boards to form/join the network. Notice how much more quickly the network forms?

In the code, channel selection is made through a bit mask set of channels, decided initially at compile time. This channel mask can also be adjusted at run-time like it was using SW4 in the example. The bit mask uses a set of 32 bits to represent channels. Recall that the channels are numbered 11 through 26 by 802.15.4, so bits 11 through 26 are used to represent the channel mask. The comment shows how to set the bits properly, but it's much easier in BeeKit where it provides a check-box for each channel:

/*
    The default channel list defines which channels to scan when forming
    or joining a network. Default = 0x02000000 = channel 25. The channel list
    is a bitmap, where each bit describes a channel (for example bit 12
    corresponds to channel 12). Any combination of channels can be included.
    ZigBee supports channels 11-26.
    3 2 2 2 1 1 0 0 0
    1 8 4 0 6 2 8 4 0
    0000 0000 0000 0000 0000 1000 0000 0000 = 0x00000800 = channel 11
    0000 0100 0000 0000 0000 0000 0000 0000 = 0x04000000 = channel 26
    0000 0010 0000 0000 0000 0000 0000 0000 = 0x02000000 = channel 25 (default)
    0000 0111 1111 1111 1111 1000 0000 0000 = 0x07fff800 = all channels 11-26
    0000 0000 1000 0000 0001 0000 0000 0000 = 0x00801000 = channels 23 and 12
*/
#ifndef mDefaultValueOfChannel_c
#define mDefaultValueOfChannel_c 0x06000800
#endif

If your application wishes to set this at run-time, and you are not using the common user ASL interface used in all of the Freescale applications, simply set the global variable gSelectedChannel to the desired set of channels prior to calling ZDO_Start().

The scan duration is found in BeeStackConfiguration.h and is just a number, 0 through 14. See Table 4.2, "MAC Scan Durations," for how this number translates into actual time. Scan duration is set at compile-time in the Freescale solution. ZigBee does not mandate a particular scan time for nodes:

/*Scan Duration*/
#ifndef gScanDuration_c
#define gScanDuration_c 3
#endif

Often, when defining a private profile application, I'll select channels 15, 20, 25, and 26, as these channels aren't the same as on common WiFi installations. I do this not for ZigBee's sake, but for WiFi's. If the application gets too chatty, it could cause WiFi to miss a packet or two, and degrade the performance of WiFi.

As mentioned before, ZigBee 2007 includes the ability to switch channels. Like forming or joining a network, this is designed to be a rare event for most ZigBee applications. I'll explain that feature in a bit more detail in Appendix A, "ZigBee 2007 and ZigBee Pro."

Channels are a portion of the RF spectrum.

Of the 16 channels, ZigBee selects the channel with the fewest networks by default.


Next: PAN IDs




Tim.Gillman

8/30/2010 1:37 AM EDT

To find out more about ZigBee and Wireless Sensor Networking, go to Drew's website: www.sanjuansw.com

Sign in to Reply



Please sign in to post comment

Navigate to related information

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)