circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

February 2005, Issue 175

Zeroing in on ZigBee (Part 1)
Introduction to the Standard


by Pete Cross

MAC LAYER

Discovery is the dynamic process that involves keeping track of other devices in range. ZigBee does this quickly. When you plug a USB device into your computer, or when you approach it with a Bluetooth device, it can take up to 10 s before you can start using it. Joining a network takes as little as 30 ms with ZigBee.

The network, application support, and higher functions of the MAC layer are provided as part of the software development tool chain. C code API functions from lower levels provide functions like setEncryption, sendPacket, Scan, and so on. packetReceived is a typical callback function that your code implements.

The MAC coordinates transceiver access to the shared radio link. It also schedules and routes data frames. This provides address generation and address recognition, and it verifies frame check sequences. A data frame is shown in Figure 3.

(Click here to enlarge)

Figure 3—The packet types defined in 802.15.4 are data (shown here) beacon, acknowledge, and MAC command packets. In most implementations, frame processing automatically happens in hardware on the same chip that incorporates the modem and RF transceiver functions.

To schedule the frame transmissions in Beacon-less mode, 802.15.4 uses a form of carrier sense multiple access collision avoidance (CSMA-CA). Each device listens before transmitting to decrease the likelihood of two transmissions occurring at once. If a transmitting node suspects that it has clashed with another transmission, it will roll back and reschedule itself to transmit later. Of course, the previously transmitted node will do the same, but the likelihood of the nodes rescheduling the same time slot is small because they base their retransmission delay on the output of a random number generator. If the network is busy, it could mean that the nodes waste a lot of time backing off and continually trying again.[1] For this reason, Battery Life Extension (BLE) mode can limit the back-off exponent to a maximum of two.

With the CSMA-CA scheme in place, nodes only have to expend power transmitting when they have something to say. This enables huge savings in power compared to time-synchronized-only systems such as Bluetooth. In Bluetooth, devices have to keep transmitting periodically to remain synchronized with the network, even if they aren’t sending application data. There are various modes to conserve power, but these parking, sniffing, and sleeping modes add a great deal of complexity.

Of course, some devices periodically require guaranteed access at a high rate, and they will be designed with the increased energy capacity to do so. They may be part of mains powered equipment or simply have bigger batteries. To cater for this, there’s an optional mixed frame format called a superframe, which consists of 16 time slots of equal width chaperoned by a beacon (see Figure 4 on page 20). Any node can grab each of the first nine slots. This gives rise to the possibility of contention. The last seven slots can be reserved for individual nodes, which are then known as a guaranteed time slot (GTS). The coordinator may allow a single node access to more than one GTS in a frame if it has to send a lot of data per frame.

(Click here to enlarge)

Figure 4—If superframes are used, the coordinator will transmit a beacon frame to synchronize the attached devices, identify this particular network, and tell the other nodes how the frames are structured. Any devices wishing to reply in an ad hoc fashion using the CSMA-CA approach can reply in the contention access period (CAP).

Low-powered devices can still use the beacon frame to gain guaranteed first-time access. The beacon superframes can occur with a period ranging from 15 ms to 252 s. Peel-and-stick infrared alarm monitors might use this type of long period beacon frame to provide a presence-check heartbeat.

All of the higher-level stuff has been worked out at this point (locations, interconnections, action implementation, and responses). You have the PHY protocol data unit (bits to send), but how do you put them in the air? All prior layers are embodied by the code inside the same microcontroller used for your application.