结合了微控制器、传感器和无线功能,ZSTAR3评估套件能够成为您下一个项目伟大的起点。除了一个无线的加速度传感器外,它还包括一个USB即插即用无线集线器以及易于操作的计算机应用软件。
A Healthy Mix of MCUs, Sensors, and Wireless Technology
With a combination of MCUs, sensors, and wireless capabilities, the
ZSTAR3 evaluation kit could be a great starting point for your next
project. In addition to a wireless accelerometer, it includes a USB
plug-in wireless hub and handy PCbased utility software.
What are three of the tastiest ingredients in an embedded
designer’s pantry?
The first is that modern-age miracle-worker, the MCU, packing the
intelligence needed to give formerly ho-hum applications a silicon
enhancement. Thanks to the fact Moore’s law continues to deliver on
the promise of more for less, ever better MCUs are finding their
way into practically any gadget with moving electrons.
On another shelf we find ever-smarter sensors that give those fancy
MCUs some realworld data to chew on. After all, it’s the sensors
that single-handedly enable, or not, potential applications. It’s
game over if you can’t sense, because then you can’t control (at
least very well).
Thanks to these high-integration, easy-to-use MCUs and sensors,
wiring up a new design is simple. It’s even simpler if you skip the
wiring part altogether by taking advantage of lowcost radio chips
that are proliferating like bunnies.
Combine all three ingredients and you can cook up an endless
variety of innovative embedded applications. This month, let’s take
a look at an excellent example of the trend courtesy of Freescale
Semiconductor. Read on and I think you’ll agree that mixing MCUs,
sensors, and wireless together, seasoned with a healthy dash of
designer creativity, is the recipe for success.
XYZ“Just ask the Axis, He knows everything…”
—The Jimi Hendrix Experience, “Bold as Love,” Axis: Bold as Love,
MCA Records, 1968.
There is no better example of “It’s the sensors, stupid” than the
MEMS accelerometer. From their humble high-g airbag roots, low-g
accelerometers have emerged to single-handedly enable vast new
applications (i.e., Nintendo Wii), as well as, pardon the pun,
shaken up existing ones (i.e., Apple iPod Nano “shake to shuffle”).
Indeed, low-g accelerometers have come full circle, now back on the
road in active suspension systems reunited with their high-g airbag
ancestors.
Figure 1—Add some e-motion to your designs with a Freescale Semiconductor
MMA7456L smart, three-axis, low-g MEMS accelerometer.
I got my feet wet with a first-generation low-g MEMS accelerometer
way back in 1995 (“A Saab Story: A Tale of Speed and Acceleration,”
Circuit Cellar 57). Since then, it’s been the usual silicon story
with the newest-generation parts, such as the Freescale MMA7456L
(see Figure 1), offering better specs, more features, and, above
all, a much lower price (just $2.87 in 1,000-unit quantities).
In the beginning, accelerometers measured a single axis (X),
followed later with dual-axis (XY) versions. It is not surprising
that the latest and greatest like the MMA7456L have upped the ante
with full three-axis (XYZ) capability. Remember that even
applications that can get by with a single- or dual-axis part can
take advantage of an extra axis to enhance features, reliability,
and ease of use.
For instance, in “A Saab Story,” I described how I used the
accelerometer as the basis for a time/speed/distance display (i.e.,
using time and acceleration to calculate speed and distance). But
the gadget would work only on a reasonably level road, lest a
change in the Z-axis orientation be falsely interpreted as
acceleration in the X-axis. Traveling at a fixed speed, going up
hill would appear faster, and downhill slower, than on a level
road. With a Z-axis, I could have dynamically compensated the speed
calculations based on the pitch (i.e., heading up or down hill)
information.
Figure 2—Measuring tilt with a single-axis accelerometer is complicated by
the fact that sensitivity varies with the tilt angle, and is poor
at the extreme. Using a second axis, and a bit of trigonometry,
sensitivity is boosted and linearized across the tilt angle range.
[1]Another more-is-better situation is using an accelerometer as an
inclinometer to measure tilt, as in the “electronic levels” you’ll
find in the tool department these days. Sure, you can measure tilt
with a single-axis accelerometer, but the problem is that the
g-output is quite nonlinear over the range of 0° to 90° (see Figure
2). Getting a feel for this phenomenon is as easy as dropping and
giving me 10 pushups. (Consult your doctor first.) Now stand up and
lean against a wall at a slight angle and give me 10 more. A lot
easier, huh? By adding an extra axis, you can use whichever sensor
is in its sweet spot for better resolution across the full range
and especially near the extremes (i.e., 0° and 90°).
The accelerometer I used back in 1995 had an analog output, albeit
thankfully signal-conditioned to provide a decently high-level
signal. By contrast, the MMA7456L is fully digital with on-board
10-bit ADCs and a SPI. In my book, digital is generally preferred
because it minimizes susceptibility to noise and enables “smart”
features. However, there may be scenarios where an analog version
still makes sense. An obvious one is when you’re connecting to an
MCU that has unused ADC inputs. Some applications may require
higher resolution and are willing to trade-off bandwidth and signal
processing MIPS to get it. Also, an analog part can work
stand-alone in hardwired applications that don’t need an MCU.
Letting you have it your way, Freescale also offers the MMA7361L, a
part that’s similar to the MMA7456L except it has analog outputs
with a healthy 800-mV/g swing.
Figure 3—Configuring the MMA7456L single- and double-“shake” (i.e., pulse)
detection feature is simply a matter of setting up registers that
define the threshold and timing.
But it’s the digital smarts (offset correction and programmable
threshold, motion, freefall, and single-/dualpulse detection) that
set the MMA7456L apart. The pulse detection feature is particularly
useful for user interface applications as the shaken-not-stirred
equivalent of single- and double-click on a mouse. There is a set
of registers to adjust the pulse threshold and timing like you
would with the mouse control panel on your PC (see Figure 3). In
applications that need it, pulse detection is a big time (and
power) saver for the MCU, which would otherwise be burdened having
to constantly be on the lookout for properly formed pulses.
Low-power is all the rage and the MMA7456L obliges by sipping a
mere 0.5 mA during normal operation. The chip has separate digital
and analog power rails, but you can run both from a single supply
anywhere between 2.4 and 3.6 V. Thanks to the low power and wide
voltage range, powering the MMA7456L from an MCU output pin is a
viable option. There’s also a standby mode that slashes power
consumption to just a few microamps. Do keep in mind there’s a bit
of latency entering and exiting standby (up to 20 ms each way).
ON THE AIRWith a sensor in hand, now we need an MCU and a radio to pull it
all together. Freescale makes that especially easy with their
MC1321x, which combines an ’S08 flash memory MCU with their
802.15.4-compatible 2.4-GHz radio on a single chip (see Figure 4).
Figure 4—The two-die “System-in-Package” MC13213 looks like a typical ’S08
MCU, just one that happens to have a complete 2.4-GHz radio
built-in.
The MC1321x line-up comprises three parts that differ only in the
MCU’s flash memory/RAM capacity with the MC13211 offering 16/1 KB,
the MC13212 32/2 KB, and the MC13213 at 60/4 KB. Besides addressing
applications of different scope and complexity, each part is
semi-tailored to fit three different wireless protocols.
At the low end, Freescale offers their own “Simple MAC” (SMAC)
solution. Supporting basic point-topoint and star networks, SMAC
easily fits in an MC13211. Stepping up a notch is a full IEEE
802.15.4 MAC that supports all that standard’s features, such as
fancy topologies (e.g., mesh and tree) and bulletproof security
(128-bit AES encryption). Finally, at the top of the stack so to
speak, is Freescale’s “BeeStack” fully ZigBee-2006-compliant
platform. Note that the SMAC source code is available for adding
your own proprietary protocol tweaks while 802.15.4 and Zig-Bee are
delivered only as object-code.
The MCU and radio work well together. For example, because the
radio needs a precise clock, it uses a 16-MHz crystal and a
trimmable oscillator. In turn, the radio’s clock can be output to a
pin for use as the MCU clock, so only a single crystal is required.
Besides flash memory and RAM, the protocol software consumes some
of the MCU I/O resources (e.g., using some of the timer channels
for scheduling radio activity). That leaves plenty of MCU I/O
resources (e.g., SPI, I
2C, UART, 8 × 10-bit ADC, GPIO, and more) free for your application.
Just add a 16-MHz crystal, a single voltage (thanks to on-board
regulators) 2- to 3.4-V power supply, an antenna, and a few
discretes, and you’ve got a complete wireless gadget (aka
“Wadget”). What could be easier?
WELL ROUNDEDWhat could be easier indeed? How about just heading over to the
Freescale web site and ordering the ZSTAR3 evaluation kit (see
Photo 1). In addition to the wireless accelerometer (versions are
available with the digital MMA7456L or the analog MMA7361L), the
kit includes a USB plug-in wireless hub and some cool PC-based
utility software.
Photo 1—The ZSTAR3 evaluation kit provides a quick and easy way to
taste-test Freescale’s wireless sensor recipe, and the price is
right at just $99. The network supports up to 16 sensors.
Additional sensor boards (using the digital MMA7456L or analog
MMA7361L) are available for $59.
The ZSTAR3 wireless scheme supports up to 16 sensors
simultaneously, each delivering data at 30 Hz. The protocol is
based on the aforementioned SMAC upgraded with some new
timing-related features for efficient scheduling (see Figure 5).
Figure 5—One advantage of centralized (i.e., hub) network control is the
ability to schedule activity efficiently. Each ZSTAR3 node
schedules radio activity (i.e., transmit/receive “windows”), which
avoids interference and steadies data throughput. Scheduling also
minimizes superfluous radio activity and allows the node to sleep
most of the time, extending battery life.
I experimented with the original version of the ZSTAR software back
in 2006 (“Three-Axis Foursome,” Circuit Cellar 191). It was fine
for getting up and running and playing around a bit, but certainly
nothing to write home about. But it’s apparent that the Freescale
folks have been hacking their hearts out in the interim because the
ZSTAR3 software has a lot of new features to exercise the hardware
and show off applications ideas.
Not that the version “0.2.3.0” of the software didn’t come with
some quirks and head scratching. I had to poke at it a bit to get
the sensor linked in and bumped over some dubious error-message
potholes from time to time, but nothing that was a showstopper.
Photo 2—The ZSTAR3 evaluation kit’s PC GUI software provides a complete set
of MMA7456L hardware utilities and demo applications.
The splash screen aggregates the 16-sensor display with tabs at the
top to exercise various features (see Photo 2). The “RF Overview
and Control” tab enables you to manually or automatically select
the RF channel frequency and shows the energy in each band. A
dynamic RSSI display is useful for evaluating signal strength and
range, which are well-known challenges for 2.4-GHz radios with
teensy PCB antennas (see Photo 3).
Photo 3—Range for low-cost 2.4-GHz radios using passive PCB trace antennas
can be limited. Even the device’s packaging (e.g., batteries) can
block the signal. The ZSTAR3 RSSI utility makes it easy to monitor
signal strength in real time and experiment with
installation-specific alternatives.
“General Sensor Tasks” start with calibration (i.e., zeroing out
XYZ offsets while the sensor is motionless) to compensate for
variations, such as mechanical misalignment and temperature drift.
Naturally, there’s a “Scope” display that traces acceleration in
real time, and also offers the ability to log data to an Excel
file.
Photo 4—A little signal processing goes a long way to filter noise, as
demonstrated by this “electronic level” demo.
The “Tilt” tab demonstrates the technology at work in demo
applications, such as PDA scrolling or switching a display
automatically between portrait and landscape modes. There’s a
“Filtered Tilt” demo that highlights the ability of some simple
signal processing to boost accuracy (see Photo 4). Using raw
accelerometer data there’s a noticeable jitter in the tilt reading
on the order of 2° to 3°. But all it takes is a little bit of
filtering (i.e., moving average) to cut the jitter to a fraction of
a degree.
Likewise, the “Motion” tab demonstrates how you can use the
threshold feature to give applications longer battery life (i.e.,
using motion as an on-off switch) and antitheft security. For
instance, office equipment could be designed to sound an alarm if
it’s moved in a suspicious way or at an unusual time.
Photo 5—Today, the “I’ve fallen, and I can’t get up” lady has to tell
someone she’s in trouble verbally. Err, kind of hard to do if
you’re unconscious. Tomorrow, an electronic fall detector will make
the 911 call for her.
The “Freefall” tab exercises a feature that could prove useful in a
variety of reliability, safety, and health applications. A neat
feature is the software takes a decent stab at determining the
distance of the fall based on the elapsed time (see Photo 5).
Before you get carried away, keep in mind the 5,000-g maximum spec,
which is less than it sounds (the “Drop Test” spec is 1.8 m beyond
which permanent damage may occur). The demo works fine if you drop
the gadget onto something soft, all the better to be safe than
sorry.
Similarly, the “Shock” tab has demos of interest in blue-collar
applications such as shipping and handling. For example, how many
packages have you received with a “This Side Up” label? Wouldn’t it
be interesting to actually know if (and when, and where) it got
tipped upside down along the way? Finally, the “Digital” tab pops
the hood on the chip so you can probe and configure all of the
accelerometers, registers, and options.
ONE FROM COLUMN A …So there you have it, the recipe for your next killer app. Like the
menu in a Chinese restaurant, all you have to do is choose one item
from column A, one from column B, and one from column C.
Column A is an MCU. There are so many delicious choices here you
can’t go wrong, everything from 50-cent, 8-bit appetizers to
MIPS-laden 32-bit entrees.
Column B is the radio. Here you have a choice of standard favorites
like ZigBee, Wi-Fi, and IEEE 802.15.4, along with a variety of
boutique alternatives. Options cover the spectrum from low-speed
point-to-point “wire-replacement” to emerging “smart dust” mesh
networks with hundreds or thousands of nodes. You can spice up your
wireless offering with cellular broadband, RFID, or GPS for a new
and improved taste.
Finish off with dessert, always my favorite part of the meal, by
choosing a sensor from Column C. Or, for that matter, why not
indulge with two or three of them. Thanks to the march of silicon,
your designs can be both less filling and taste great.
Tom Cantrell has been working on chip, board, and systems design
and marketing for several years. You may reach him by e-mail at
tom.cantrell@circuitcellar.com.
REFERENCE[1] K. Tuck, “AN3461: Tilt Sensing Using Linear Accelerometers,”
Freescale Semiconductor, Inc., 2007.
SOURCEMC13213 MCU and IEEE 802.15.4 Radio, MMA7361L accelerometer,
MMA7456L accelerometer, and ZSTAR3 accelerometer evaluation kit
Freescale Semiconductor, Inc. |
www.freescale.com