Global Sources
EE Times-Asia
Stay in touch with EE Times Asia
?
EE Times-Asia > RF/Microwave
?
?
RF/Microwave??

Selecting the right MAC for Zigbee

Posted: 18 Dec 2006 ?? ?Print Version ?Bookmark and Share

Keywords:Zigbee 802.15.4 wireless? MAC Zigbee standard? low data rate? wireless protocol?

By Chris Baumann
Atmel Corp.

Zigbee and 802.15.4 are low data rate wireless standards that can be used as the communication link in industrial control systems. Using a wireless protocol, provides much more flexibility in the industrial control application. In fact, equipment can be moved around without affecting the functioning of the system because the wireless network is always able to identify and communicate with the various nodes in the system. Zigbee networks can have up to 65,000 nodes, each of which has an 802.15.4 radio, a microcontroller and 802.15.4 media access control (MAC) software. Choosing the right MAC is as important as selecting the right radio or microcontroller for your application.

The 802.15.4 MAC is the software that provides the interface between the network security layer and the 802.15.4 radio. How the MAC is implemented can have a substantial effect on system complexity, performance, power consumption, cost and the scalability of system features.

There is a trade-off between the "fullness" of the MAC and system cost because a complete 802.15.4 MAC can require up to 24KBytes of memory. The larger the MAC is, the more memory it takes and the more expensive will be the controller that runs it. Vendors want to keep the MAC as small as possible to remain competitive. There are several approaches used to keep the MAC small.

Some vendors optimize the MAC code, hand crafting it in assembly language, to produce the smallest memory footprint for the target controller while keeping the full MAC feature set. Others vendors eliminate features that are deemed not to be critical for their target applications. While this latter approach may reduce costs by allowing the use of a microcontroller with a smaller flash memory, it can have an adverse impact on system scalability to next generation applications. For example, some vendors have eliminated the "Guaranteed Time Slot" (GTS) feature of 802.15.4 because they do not believe Zigbee applications will need it. GTS allows network systems to poll nodes at specific intervals to lower the node "on" time and increase battery life.

A typical hardware/software configuration.

If an application using a MAC without GTS evolves to a future generation that requires GTS, at least the MAC, and possibly the entire network layer, will have to be redesigned. If it is a Zigbee application, the entire design will have to be re-certified. Therefore, it is very important to be sure that future system scalability and flexibility are not sacrificed to keep the cost down.

It may be preferable to address the code density issue by selecting a C/C++-friendly microcontroller and compiler that provide the most compact compiled code. The choice of microcontroller can have an enormous impact on the size (and therefore cost) of the MAC. For example, 802.15.4 code that has been compiled for an 8051-based microcontroller may require 55KBytes of flash. The same C-code, compiled for an AVR microcontroller requires only 30KBytes of memory. In fact, the AVR is the dominate controller in Zigbee/802.15.4 applications, partly because of exceptionally high density of compiled code on it.

The controller architecture makes a difference, but so does the compiler. IAR compilers are known to compile 802.15.4 code that is 20 percent denser than the same code compiled using GCC's GNU compiler. Check with your compiler vendor to locate the most efficient compiler for your microcontroller.

The architecture of the MAC, and how it is integrated with the application software, also can have a significant impact on system performance. The MAC sub-layer must share processor resources with the network layer (which provides network configuration, manipulation, and message routing), and the application layer (which provides the intended function of the device). How resources are share can have a significant impact on system complexity and reliability There are basically two approaches to scheduling: cooperative multitasking and pre-emptive multitasking.

In cooperative multitasking, every task voluntarily cedes the microcontroller to the next task. This approach results in lower program code size, because no complicated scheduling algorithm needs to be implemented. In addition, there is no requirement for context switching so there is less latency and smaller memories can be used.

The drawback of cooperative multitasking is that there is a lot of "trust" involved. Each process must regularly give processor time to other processes. A poorly designed program or a "hung" task can effectively bring the system to a halt. Designing a system so that it avoids these pitfalls can be onerous and may result in irregular or inefficient use of system resources.

In pre-emptive multitasking, the scheduler can initiate a context switch to satisfy the scheduling policy's priority constraint, thus pre-empting the active task and effectively preventing a "hung" task from halting the system. However, this requires a great deal more code and introduces latencies into the system. A typical 802.15.4 application will not usually need this level of protection and can generally go with the smaller code size and lower latency of a cooperative multitasking scheme.

In short, cooperative multitasking gives the application designer control over scheduling while pre-emptive multitasking gives scheduling control to the operating system and software stack.

IEEE 802.15.4 MAC libraries are available that provide a set of non-blocking functions that can be called to pass the IEEE 802.15.4 MAC layer management entity (MLME) primitives to the MAC task. These non-blocking functions return the microcontroller immediately to the next task, using a cooperative multitasking scheme. In this architecture, the higher layer task calls the lower layer task periodically. The higher layer passes back the IEEE 802.15.4 MLME primitives using a set of callback functions, which are also non-blocking. This ensures that the application has maximum control over the microcontroller. In fact, a pre-emptive task scheduler could be added to these applications.

Another important element in selecting a MAC is to look for one with a hardware abstraction layer that is common to multiple different controllers. This thin layer of the MAC will provide flexibility in terms of memory density and peripheral set, as well as facilitate system integration. For example, a controller node will have different peripheral and memory requirements than an end-node. A MAC with a HAL that seamlessly supports a wide range of controllers allows the designer to optimize the balance between cost and feature set for each piece of the 802.15.4 network.

Relative code density for MCUs.

Choosing the right 802.15.4 MAC can be extremely important for system performance, cost, and reliability. One can begin by choosing a C-friendly microcontroller, such as the AVR, along with a compiler that is known to provide dense implementations of the 802.15.4 MAC. Some vendors are now offering hand-crafted MACs that are optimized for their controller architecture. Small code size is important to keep memory size and cost to a minimum. However, don't sacrifice scalability by using a MAC with a stripped down feature set. Be sure it is a fully-compliant 802.15.4 MAC.

Simpler is better. Cooperative multi-tasking provides a simple, code efficient method of sharing system resources between the application, the network security layer and the 802.15.4 layer, with the MAC acting as a callable function from industrial control application. Choosing the right MAC will provide a better performing, lower cost system.

About the author
Chris Baumann
is Director of Atmel's BiCMOS Products business unit. Prior to his joining Atmel in 1989, he held various positions at Texas Instruments and Honeywell. Baumann received his B.S. degree in Electrical Engineering and his M.S.E.E. degree from the University of Notre Dame.




Article Comments - Selecting the right MAC for Zigbee
Comments:??
*? You can enter [0] more charecters.
*Verify code:
?
?
Webinars

Seminars

Visit Asia Webinars to learn about the latest in technology and get practical design tips.

?
?
Back to Top