7
9
25274 75349
1 0>
CIRCUIT
CELLAR
®
ww
ww
ww
..cc
iirr
cc
uu
iitt
cc
ee
llll
aa
rr
..cc
oo
mm
T H E M A G A Z I N E F O R C O M P U T E R A P P L I C AT I O N S
$4.95 U.S. ($5.95 Canada)
# 1 3 5 O C T O B E R 2 0 0 1
ANALOG TECHNIQUES
Implementing An Analog Filter
Fine-Tune A Speedometer
A Sensor Controller
Simplifying USB
• 2 Channel Digital Oscilloscope
•
• Advanced Math options
• FFT Spectrum Analyzer options
Probes, Interface Cable, Power
Adapter, and software for
Win95/98, WinNT, Win2000
and DOS.
Optional 100 MSa/s Pattern Generator
LA2124-128K (100MSa/s, 24CH)
Clips, Wires, Interface Cable, AC
Adapter and Software
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
3
Simultaneous Analog-to-Digital
Conversions
The Need for Speed
An Accurate Speedometer
Robot Sensor Controller Board
Part 1: The Brain
Telling Time and Temperature
Building an All-Purpose Portable Device
ABOVE THE GROUND PLANE
Learning from the Past
Replacing Mercury with a Thermistor
An Up and Coming Micro Supplier
COLUMNS
ISSUE
New Product News
edited by Rick Prescott
Advertiser’s Index
November Preview
Priority Interrupt
Steve Ciarcia
No Unpopulated Territory
135
FEA
TURES
ChipCenter: The Web’s Definitive Electronics Resource
http://www.chipcenter.com/circuitcellar
THE MAGAZINE FOR COMPUTER APPLICATIONS
Circuit Cellar Online offers articles illustrating creative solutions
and unique applications through complete projects, practical
tutorials, and useful design techniques.
(no Internet connection required)
S.O.S...SHOWING OFF THE SEQUENCER
Getting the Most Out of Your New Product Ideas
Lessons from the Trenches
Transistor Signal Amplification
Technically Speaking—
It was about time to communicate with the world again and Lloyd was the best person to
start with.
"Yeah, I suppose you're right. But I've been screwing around with some home comput-
6
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
EDITORIAL DIRECTOR/PUBLISHER
Steve Ciarcia
WEB GROUP PUBLISHER
Jack Shandle
MANAGING EDITOR
Rob Walker
EDITORIAL PRODUCTION COORDINATOR
Jennifer Huber
TECHNICAL EDITORS
Jennifer Belmonte
Rachel Hill
WEST COAST EDITOR
Tom Cantrell
CONTRIBUTING EDITORS
Ingo Cyliax
Fred Eady
George Martin
George Novacek
NEW PRODUCTS EDITOR
Rick Prescott
PROJECT EDITORS
Steve Bedford
David Tweed
ADVERTISING
ADVERTISING SALES MANAGER
Kevin Dows
Fax: (860) 871-0411
(860) 872-3064
E-mail: kevin.dows@circuitcellar.com
ADVERTISING COORDINATOR
Valerie Luster
Fax: (860) 871-0411
(860) 875-2199
E-mail: val.luster@circuitcellar.com
ADVERTISING CLERK
Sally Collins
Fax: (860) 871-0411
(860) 875-2199
E-mail: sally@circuitcellar.com
CONTACTING CIRCUIT CELLAR
SUBSCRIPTIONS:
INFORMATION: www.circuitcellar.com or subscribe@circuitcellar.com
To Subscribe: (800) 269-6301, www.circuitcellar.com/subscribe.htm, or
subscribe@circuitcellar.com
PROBLEMS: subscribe@circuitcellar.com
GENERAL INFORMATION:
TELEPHONE: (860) 875-2199 Fax: (860) 871-0411
INTERNET: info@circuitcellar.com, editor@circuitcellar.com, or www.circuitcellar.com
EDITORIAL OFFICES: Editor, Circuit Cellar, 4 Park St., Vernon, CT 06066
NEW PRODUCTS: New Products, Circuit Cellar, 4 Park St., Vernon, CT 06066
newproducts@circuitcellar.com
AUTHOR CONTACT:
E-MAIL: Author addresses (when available) included at the end of each article.
CIRCUIT CELLAR®, THE MAGAZINE FOR COMPUTER APPLICATIONS (ISSN 1528-0608) and Circuit Cellar Online are published
monthly by Circuit Cellar Incorporated, 4 Park Street, Suite 20, Vernon, CT 06066 (860) 875-2751. Periodical rates paid at Vernon, CT
and additional offices.
One-year (12 issues) subscription rate USA and possessions $21.95, Canada/Mexico $31.95, all other
countries $49.95. Two-year (24 issues) subscription rate USA and possessions $39.95, Canada/Mexico $55, all other countries
$85.
All subscription orders payable in U.S. funds only via VISA, MasterCard, international postal money order, or check drawn on U.S.
bank.
Direct subscription orders and subscription-related questions to Circuit Cellar Subscriptions, P.O. Box 5650, Hanover, NH
03755-5650 or call (800) 269-6301.
Postmaster:
Send address changes to Circuit Cellar, Circulation Dept., P.O. Box 5650, Hanover, NH 03755-5650.
For information on authorized reprints of articles,
contact Jeannette Ciarcia (860) 875-2199 or e-mail jciarcia@circuitcellar.com.
Circuit Cellar® makes no warranties and assumes no responsibility or liability of any kind for errors in these programs or schematics or for the con-
sequences of any such errors. Furthermore, because of possible variation in the quality and condition of materials and workmanship of reader-
assembled projects, Circuit Cellar® disclaims any responsibility for the safe and proper function of reader-assembled projects based upon or from
plans, descriptions, or information published by Circuit Cellar®.
The information provided by Circuit Cellar® is for educational purposes. Circuit Cellar® makes no claims or warrants that readers have a right to
build things based upon these ideas under patent or other relevant intellectual property law in their jurisdiction, or that readers have a right to con-
struct or operate any of the devices described herein under the relevant patent or other intellectual property law of the reader’s jurisdiction. The
reader assumes any risk of infringement liability for constructing or operating such devices.
Entire contents copyright © 2001 by Circuit Cellar Incorporated. All rights reserved. Circuit Cellar and Circuit Cellar INK are registered trademarks of
Circuit Cellar Inc. Reproduction of this publication in whole or in part without written consent from Circuit Cellar Inc. is prohibited.
CHIEF FINANCIAL OFFICER
Jeannette Ciarcia
CONTROLLER
Howard Geffner
CUSTOMER SERVICE
Elaine Johnston
ART DIRECTOR
KC Prescott
GRAPHIC DESIGNERS
Cindy Siegmund
Mary Turek
STAFF ENGINEERS
Jeff Bachiochi
John Gorsky
QUIZ COORDINATORS
David Tweed
Michael Smith
EDITORIAL ADVISORY BOARD
Ingo Cyliax
Norman Jackson
David Prutchi
TASK
MANAGER
or those of you who might be wondering, no, the
inspiration for this month’s cover was not a result of
the Harry Potter craze. The fact is, the mysterious chal-
lenges of analog design have been a common topic among
engineers for years. With the advent of the digital age, understanding ana-
log took a back seat as many training facilities and industries focused more
on digital techniques. Analog might have become a lost art until digital-cen-
tric engineers began to realize that understanding basic analog techniques
doesn’t mean you are old-fashioned, it means you are well-rounded.
In the last few years we’ve had some great articles about analog circuit
design written by readers. Those articles always generated a healthy
amount of feedback so it’s clear that one reader’s insight can be another
reader’s project lifesaver. And while we’re talking about the warm fuzzy
community effort that goes into
Circuit Cellar, I’d like to remind you that it’s
not too early to start thinking about writing an article for 2002. We’ve got the
usual suspects among our theme list, so take a look at the deadlines for our
new editorial calendar at www.circuitcellar.com/authors/info/calendar.htm.
If you’ve got an idea for an article that might not fit into an upcoming
theme, don’t hesitate to send it my way because a good article on wireless
communications doesn’t have to wait until next December to get published.
After all, the list of topics is just a guideline, the real theme of every issue is
quality engineering content. And it’s that commitment to quality that has
made
Circuit Cellar a household commodity.
OK, maybe we haven’t achieved household commodity status, but the
appearance of
Circuit Cellar products on eBay was just the beginning.
Earlier this year, Steve received a call from Miramax Films. An upcoming
film has a technological slant and they wanted to use the magazine as a
prop! Fame and fortune had smiled upon us. As it turns out, the star of the
movie is a well-known hacker…not exactly of the software variety.
Personally, if I want to see something that slices and dices, I’ll watch a
late-night infomercial, however if we wanted a break on the big screen, the
eighth movie in the series of Halloween horror films would have to be our
moment of glory. The movie was originally scheduled to be released this
fall, but from the information I found on the Web, it might get pushed off
until 2002. Not being a big horror film fan, I can’t exactly say that I’m anx-
iously awaiting the movie’s release, but it will be interesting to see if any
images of
Circuit Cellar magazines make the final film cuts.
Whether we owe our good fortune to the props intern who was told to go
to the local newsstand and get a copy of every magazine in the computer
section or whether our name was dropped by a member of the tech crew
(you never know,
Circuit Cellar readers are everywhere, including the “imag-
ineering” department at Walt Disney), this might be the beginning of great
things. Just imagine, the knife-wielding sanitarium escapee gets caught by
the knowledgeable
Circuit Cellar reader’s HCS system….
rob.walker@circuitcellar.com
Cover photograph Ron Meadows—Meadows Marketing
PRINTED IN THE UNITED STATES
f
It’s Magic
© October 2001
1 Parallel, 1 Serial, 2 USB ports
ATI Radeon Vivo 64MB DDR Video Card
P4 Mid Tower Chassis & 300W PS
Yamaha Sound Card & 120 WATT Speakers
Windows 2000, Logitech Wheel Mouse
Netgear 10/100 Ethernet Adapter
Cutting edge technology at rock-bottom
1 Parallel, 1 Serial, 2 USB ports
ATI Xpert 2000 32MB AGP Video Adapter
P4 Mid Tower Chassis & 300W PS
Yamaha Sound System & 120WATT Speakers
Windows '98, PS/2 Mouse & Keyboard
56K v.90 Lucent PCI Modem w/Fax
1 Parallel, 1 Serial, 2 USB ports
P4 Mid Tower Chassis & 300W PS
Yamaha Sound System & 120WATT Speakers
Windows 98, PS/2 Mouse & Keyboard
56K v.90 Lucent PCI Modem w/Fax
AMD Athlon 4 Processor, 266MHz Bus
60GB 7200 RPM ATA 100 Hard Drive
ATX Professional Tower Chassis
1 Parallel, 2 Serial, 2 USB ports
Yamaha Sound System & 120WATT Speakers
Windows 2000, PS/2 Mouse & Keyboard
56K v.90 Lucent PCI Modem w/Fax
1 Parallel, 2 Serial, 2 USB ports
Integrated AGP Video Adapter
Integrated Sound & 120 WATT Speakers
Logitech PS/2 Mouse & Keyboard
56K v.90 Lucent PCI Modem w/Fax
1 Parallel, 2 Serial, USB & PS/2 Port
ASUS Geforce 2 GTS 32MB DDR Video Card
Creative Labs Live Value & 520 WATT Spkrs
Windows ME, MS Intellimouse & Keyboard
56K v.90 Lucent PCI Modem w/Fax
ATX Professional Tower Chassis
Up to 1.5GB using 3x168-pin SDRAM
UltraATA/100, 2 IDE channels
2 serial ports & 1 parallel port
NEWS
8
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
NEW PRODUCT
RIBBON CONNECTOR
The EECOM-Insulated Displacement Connector
(IDC) uses a plastic assembly to terminate discrete
wires and ribbon cables of up to 40 wires on 0.050
″
(1.27 mm) centers to printed circuit boards via plated
through-holes, without the need for a second, female
connector part. This reduces parts-count and assembly-
time costs for a wide variety of electronic products
including home appliances, office equipment, industrial
controls, tele-communications, automobiles, and other
electronic products.
On the top, a simple hand tool terminates a ribbon
cable to its connector in just 10 s. On the bottom,
Electrically Encircled Compression (EECOM) connector
technology eliminates the need for a female connector.
Only another 5 s is required for mating the entire
assembly to its circuit board. This reduces the cost of
connecting ribbon cable to a circuit board to just one
part and 15 s of labor.
The top of the connector uses a V-shaped knife con-
tact to terminate the ribbon cable. The connection is
made by terminating the ribbon cable to the IDC contact
with either a hand tool or automated termination tool.
The tool forces the wire into the wedge, displacing its
insulation as it enters the gap. The wire strands force
the jaws apart, thus making a secure connection on both
sides of the wire, which is held captive by the IDC con-
tact. The benefit is there is no need for wire preparation.
The IDC connection is renewable and robust, with-
standing mechanical shock up to 50 g in all three axes.
Contact resistance is 10 m
Ω
or better. Contact voltage
rating is 250 VAC minimum and per-line current rating
is 1 A. Insulation resistance is specified at 500 M
Ω
min-
imum. Dielectric withstanding voltage is 1500 VAC for
1 min. Contacts on both the top and the bottom are tin-
lead plated over copper alloy.
Mate-demate lifetime is rated at 500 cycles for the
bottom EECOM pins. Pricing for the EECOM-IDC con-
nectors is based on quantity.
Ranoda Electronics Inc.
(812) 945-2280
Fax: (812) 945-2286
www.ranoda.com
INDUSTRIAL ENCODERS
The F14 and F18 series encoders provide high per-
formance feedback for stepper and servo motor controls.
The encoders feature compact 1.4
″
or 1.8
″
diameter
package dimensions and a pin header that’s plug-com-
patible. A compliant tether allows easy mounting with
high tolerance to motor shaft movement and 30° of
adjustment to align the signal
outputs to the shaft position. A
clamping system, available in top
or bottom locations, will not mar
the shaft nor loosen over time
and provides superior clamping
force. No special tools are
required for installation.
The optical configuration pro-
vides generous internal compo-
nent clearance eliminating
potential damage at high ambi-
ent operating temperatures to 120°C. High temperature
rated grease is standard for extended bearing life. A
phased array sensor and low current demand provide
stable output signals over a wide range of input voltage
and output frequencies to 500 kHz. The encoders also
offer a wide choice of incremental pulses-per-revolution
(to 10,000 PPR) and four, six, or
eight pole commutation chan-
nels. Electrical outputs are pro-
tected from short circuits and
operate on 5-VDC power.
Pricing for the devices starts at
$140.
Danaher Controls
(847) 662-2666
Fax: (847) 662-6633
www.dancon.com
Edited by Rick Prescott
NEWS
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
9
NEW PRODUCT
ETHERNET-ENABLED SBC
The BL2000 series is the first in a new generation of
single-board computers with Ethernet connectivity for
the OEM market. Ideally suited for embedded control
and monitoring applications, these full-featured boards
are powerful Ethernet-enabled SBCs. The compact
board size of 3.43 × 4.15
″
allows for easy integration.
Features include up to 28 digi-
tal I/O (including five or seven
dual-purpose A/D inputs), four
RS-232/485 serial ports, 22-
MHz microprocessor, 128-KB
SRAM and 256-KB flash memo-
ry (expandable), onboard relay,
LEDs, seven timers, and bat-
tery-backed time/date clock.
Available in four configurations
(two with Ethernet, two with-
out), models feature nine or 11
channels of A/D, and two mod-
els also offer D/A capability.
All models can be programmed and debugged over
Ethernet/Internet using accessory hardware. In addition,
systems with built-in l0BaseT Ethernet can be directly
controlled and monitored across any network or the
Internet and can also open sockets to remote devices,
serve web pages, or send e-mail. Non-Ethernet versions
allow for cost-effective imple-
mentation or parallel develop-
ment of non-Ethernet systems.
The device is also ideal for use
as a network-enabled service
processor for larger systems.
Pricing for the Bl2000 starts
at $199 with Ethernet and $159
without Ethernet.
NEWS
10
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
NEW PRODUCT
CAPACITIVE ACTUATOR
The CSE series capacitive actuators are ideal for use
in externally exposed environments such as traffic
light systems, elevators, and public information ter-
minals. They also work well in industrial environ-
ments such as electronic measuring equipment,
marine, military, and construction equipment.
Capacitive actua-
tors possess no
mechanical parts that
could lead to a func-
tional failure as a
result of damage,
freezing, or wear and
tear. They can provide
pulse, momentary,
and latching action.
The lifetime of capaci-
tive actuators is
greater than 50 mil-
lion cycles. Actuation
is by touch to the
front side. Capacitive
actuators can be sensi-
tive to water, dirt, and
EMC. The electronics
of the CSE incorpo-
rates an adaptive function that is slow to change. For
example, dirt particles and water drops are registered
and disregarded by the actuator, thus avoiding unin-
tentional actuation or functional failure.
The CSE is available in two types: the CSE 16
(mounting hole diameter) and the CSE uG (under
glass). The CSE 16 is a flush-mount beveled actuator,
made up of anodized aluminum. It is fastened to the
front panel with an M16xl nut. An O-ring ensures an
impermeable seal. It features ring illumination in red
or green. The actuator can be permanently illuminat-
ed or may be connected to a switching signal. The
CSE uG is a square switch with an LED in each of the
four corners. Its actuators and switches can be
installed under a nonconductive overlay material of
up to 20-mm thickness, such as glass, wood, or tile.
Pricing for the CSE starts at $40 each for 100 pieces.
Schurter Inc.
(707) 778-6311
Fax: (707) 778-6401
www.schurterinc.com
EMBEDDED PENTIUM III
The EmCORE-i6315 is an embedded Pentium III
miniboard that is the latest addition to a full range of
industrial computers based on the ProSavage chipset
that combines PG/PC-133 core logic and high-end S3
Savage4 3D graphics. Additional onboard functions
include Intel’s popular 82559 Ethernet interface,
UltraDMA100 IDE, audio, flat panel support and four
serial ports. A PC/l04-Plus (PCI/ISA) interface lets you
extend the board’s functionality with PC/l04-Plus multi-
ple-LAN modules, PC/l04-Plus SCSI modules, or ISA-
based PC/l04 function modules.
With its compact 5.25
″
design and clear price advan-
tages over RAMBUS Pentium III designs, the EmCORE-
6315 is great for POS, Panel PC, kiosk, workstation,
telecom terminal, and network applications.
The EmCORE-i6315’s VIA ProSavage PM133 dual-
chipset consists of the VT8605 Northbridge and
VT82C686B Super Southbridge that combines the
VIAApollo Pro133A chipset with a 4XAGP 32-MB S3
Savage4 and S3 Savage2000 2D graphics core. The
chipset supports PC-133 SDRAM and CPU speeds of up
to 1 GHz. VIA’s Super Southbridge supports high-speed
PCI Ultra ATA/l00 enhanced IDE. Optionally the board
can be equipped with a C&T 69000 controller to facili-
tate flat panel displays. Especially for POS applications
serial ports have jumper-selectable 5- and 12-V power
pins, allowing you to power serial POS devices such as
displays and printers directly, without further need for
separate power cabling.
The EmCORE-i6315 is compatible with all popular
operating systems including MS-DOS, Linux, Windows/
9x/NT/2000, OS/2 Warp, QNX, SC0 UNIX, and Novell.
NEWS
NEW PRODUCT
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
11
ELECTRONIC KEY
This electronic key consists of a DB9 connector with
an EEPROM housed in a rugged overmolded case and is
a program-as-needed electronic key, also known as a
software lock. Programmable by either the OEM or by
manufacturer, this electronic key can be used to enable
software or software features, or to store electronic sig-
natures such as when a piece of equipment was made,
its serial number, its original configuration settings, and
other data. The electronic key also can be used any-
where a small amount of OEM-programmable, easily-
removable data storage is needed.
Ease of programming allows the electronic key to
offer a high degree of flexibility. Each electronic key
can be programmed differently, allowing for high secu-
rity in software lock applications. In electronic signa-
ture applications, it is likely that each electronic key
would require a completely different program. The key
is offered with a choice of 1 or 2 KB of EEPROM, in
either preprogrammed or unprogrammed versions. All
units are 100% electronically tested.
Key pricing varies depending on connector style,
amount of internal memory, and programming need.
For the DB9 version
with 2 KB of memory
(unprogrammed), pric-
ing is approximately
$11 each in quantities
of 10,000.
Methode Electronics, Inc.
(708) 867-6777
Fax: (708) 867-3149
www.methode.com
CANDELABRA-SCREW BASED LAMPS
The S6 Candelabra-Screw Based LED Lamps are
designed to replace incandescent S6 candelabra-screw
based lamps in miniature utility switches, industrial
control panels, and other applications that demand
durable and energy-efficient light sources. This new
generation of LED lamps integrates the latest LED chip
technology for the brightest illumination, and is plug-
compatible with illuminated switches and indicators
from major manufacturers.
The lamps are offered in single
and multi-chip types, which pro-
vides continuous light even if one
or more emitters fail. The follow-
ing colors and derivations thereof
are available: green (10,000 mcd),
white (6000 mcd), blue (3000 mcd),
yellow (7000 mcd), red (3500 mcd),
and orange (6500 mcd).
Their solid-state construction
makes the lamps ideal for industri-
al installations that are subjected
to vibration, shock, and environ-
mental stress, all of which reduce the life of incandes-
cent lamps. The LEDs feature almost instantaneous
turn-on and turn-off without transients.
Applications include indicators for process controls,
aircraft instrumentation, elevator panels, automobile
lighting, medical and scientific equipment, and panel-
mount indicator lamps.
LED lamps last 30 to 50 times longer that the incan-
descent lamps they replace, and their low-current, high-
efficiency operation delivers power savings of 80% or
more. Additionally, LED lamps produce little or no heat
resulting in lighted panels and switches that are cool to
the touch unlike those lit by incandescent lamps.
LED lamps can be supplied for all common indicator
supply voltages from 5 V to 220 VDC or VAC. These
products feature built-in current-
limiting resistors and polarity-pro-
tection diodes to assure that circuit
modifications are not required. A
typical LED lamp provides an
intense beam of colored light. The
viewing angle depends on the shape
of the epoxy lens and the LED
chip’s position within the epoxy
lens. The intensity and wavelength
remain stable over the lamp’s life-
time of l00,000-plus hours.
Prices for S6-Based LED lamps
range from $6.56 to $13.80 in quan-
tities of 100, depending on LED color and cluster size.
LEDtronics, Inc.
(800) 579-4875
(310) 534-1505
Fax: (310) 534-1424
www.ledtronics.com
12
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
ot all signal fil-
tering problems can
be solved with a DSP
chip and some fancy soft-
ware. An analog filter often does a bet-
ter job and needn’t be hard to design.
In an electronics world dominated
by digital processing it’s easy to forget
that analog filters still have a part to
play. Digital filters are compact, their
performance is closely specified, and
they can implement filter types that
simply don’t exist in the analog
domain. Unfortunately, they process
numbers not signals.
THE LIMITS OF DIGITAL
Before you can use a digital filter,
you have to convert real-world signals
into numerical form. Analog-to-digital
conversion has a limited resolution and
dynamic range. It also introduces quan-
tization noise. The filtered result often
must be converted back to analog form
before it can do anything useful. But,
D/A conversion introduces more
errors and generates a spurious high-
frequency output; this could defeat
the original object of the filter.
The whole process—sampling, pro-
cessing, and reconversion—depends on
clock frequency. Not only does this
limit the highest input frequency that
FEATURE
ARTICLE
As the ever-changing
tech market continues
to top itself, Tom
reminds us not to for-
get the classics. Right
now, all eyes are on
digital processing, but
analog filters are still
useful. After hearing
about the various
types and benefits,
you’ll find analog fil-
ters simple to boot.
can be handled, it also introduces alias-
ing, a phenomenon with no equivalent
in an analog filter. Aliasing arises
because sampling the input inherently
converts signals and noise from fre-
quencies higher than the sampling rate
into the frequency band of interest.
Unless frequencies higher than half of
the sampling rate are filtered out of
the input signal before conversion,
they appear distorted in the output.
The reverse process occurs during
the output conversion. Wanted signals
are aliased into the frequency region
higher than the output clock rate.
Thus, a practical digital filter may
require analog filters both at its input
and output to do its job. That’s when
you have to ask yourself whether or
not it would be simpler and less expen-
sive to stay in the analog domain.
WHY FILTER?
A filter passes the band of frequen-
cies in which your signal of interest
lies and rejects noise and interfering
signals. For example, radio receivers
use narrowband intermediate frequen-
cy filters to pick out just one signal.
Filters also can shape signal wave-
forms to adapt them for further pro-
cessing. Space data receivers use
pulse-shaping filters to maximize the
output signal-to-noise ratio.
Filters can be built to pass only low
frequencies, only high frequencies, or
a band of frequencies. You can build a
notch filter that passes all frequencies
except a particular one. Filters can be
passive (i.e., containing only induc-
tors, capacitors, and resistors) or they
can be active, using amplifiers and
feedback connections.
CLASSIC FILTERS
Analog filters used to be designed as
if they were matched transmission
lines. Many inductors and capacitors
were connected together with a termi-
Tom Napier
Lacoste
Considering
an Analog Filter
n
Butterworth
Bessel
L1
0.50650
0.26439
L2
1.56543
1.05449
C1
0.63880
0.39739
C2
1.97432
1.71653
Table 1—
Component values for a four-pole LCR filter
are normalized to –3 dB at 1 rad/s.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
13
nation resistor at one end. The
more inductors and capacitors
you added, the sharper you
could make your filter discrim-
inate between wanted and
unwanted signals. Filter design
became complicated. Most
engineers simply looked up
pre-calculated designs in a
huge book that gave the com-
ponent values and performance
of each configuration.
Inductance/capacitance (LC)
filters for audio frequencies were
bulky and expensive. The early equip-
ment to frequency-multiplex many
phone lines on one cable needed fer-
rite-cored inductors up to 2
″
in diame-
ter. Then, in the 1950s, two engi-
neers, R. P. Sallen and E. L. Key, dis-
covered how to make low-pass filters
from resistors, capacitors, and unity-
gain (cathode-follower) amplifiers.
The introduction of these active fil-
ters greatly decreased the size of tele-
phone exchange equipment.
Active filters are easier to design,
build, and tune than traditional LC
filters. Because they incorporate buffer
amplifiers, sections can be linked in
series without mutual interaction.
The basic Sallen and Key filter shown
in Figure 1 is a two-pole, low-pass
stage, an ideal building block for many
filter designs. Figure 2 shows how it
behaves as the damping is changed.
To get predictable results, the buffer
amplifier must have a bandwidth
many times greater than the filter.
Active filters have two limitations,
they can’t easily be made to work
above about 50 MHz and they can be
overloaded by interfering signals. If
there’s a 1000x stronger interfering
signal on a frequency near your want-
ed signal, a passive filter could sepa-
rate the two. In an active filter, the
strong signal would saturate the
amplifier, destroying the smaller signal.
FILTER TYPES
Early filter designers were working
with audio modulation of radio fre-
quency carriers, so generally they
wanted to pass a narrow range of fre-
quencies while rejecting all others.
Their ideal was the brick wall filter
and much ingenuity went into
approximating it. These days we more
often transmit broadband digital sig-
nals. Preserving the signal shape is
more important than sharply chop-
ping off high frequencies.
This brings us to Murphy’s Law of
filters: A filter with sharp frequency
cutoff causes ringing, which distorts the
shape of the signal. To get clean rising
and falling edges, you must use a con-
stant delay (a.k.a., linear phase) filter.
This has a rounded frequency response.
There is a compromise. You can
build a sharp cutoff filter and follow it
with an all-pass filter, which has no
effect on the amplitude of a signal but
does phase shift and delay it. A sharp
cutoff filter has a low delay at low fre-
quencies but a high delay near the cut-
off frequency. You can add an all-pass
filter with a high delay at low frequen-
cies to equalize the delay. Equalization
can easily double the complexity
of a filter so it’s not done unless
you absolutely must have both
a sharp cutoff and constant
delay. (Uniform delay makes
digital filters popular.)
The basic filter is a low-pass
filter that removes high fre-
quencies from the signal. If you
want a high- or band-pass filter,
you usually start by designing
a low-pass filter, then trans-
form it mathematically to give
the configuration and component val-
ues for the filter you want. Over the
years, people invented filters having
different characteristics, each opti-
mized for a different task. These clas-
sic filters are known by the names of
their inventors—Butterworth, Bessel,
Paynter, and Chebychev. The excep-
tion is the elliptical filter.
The Butterworth filter is the basic
low-pass filter. It has a flat response
up to its cutoff frequency and then
rolls off smoothly. But, it distorts the
signal edges by introducing ringing. If
signal shape is important, the best fil-
ter is the Bessel filter. This filter has a
constant delay for all frequencies
below its cutoff frequency. Although
it delays and rounds a signal, it does-
n’t change its fundamental shape.
Unfortunately, achieving this delay
characteristic forces it to roll off slow-
+1
Buffer amplifier
C1
C2
1
Figure 1—
The basic Sallen and Key filter has two poles. This filter can be
designed for a variety of corner frequencies and damping factors and is
easily assembled into multi-pole filters.
Decibels
Z = 0.354
6
3
0
–3
–6
–9
–12
–15
–18
–21
–24
Milliseconds
1000
1
800
600
6
400
200
0
0.1
1.0
Normalized frequency
10
Z = 0.707
7
Z
Figure 2—
The amplitude response and delay of a Sallen and Key filter vary with the damping factor. The product
of the two capacitors sets the corner frequency and their ratio controls the damping.
14
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
ly. Frequencies below –3 dB are atten-
uated more than in a Butterworth fil-
ter. Frequencies above the cutoff fre-
quency are attenuated less. Figure 3
contrasts these two filters.
You can use an Chebychev or ellip-
tical filter if you want a sharp fre-
quency cutoff. The elliptical filter
achieves a sharper cutoff at the price of
a low-frequency response that isn’t
flat. The Chebychev filter uses one or
more notch sections to achieve a sharp
cutoff. This can be useful when there
is a particular frequency, such as a
carrier, which you want to eliminate.
Both of these filters have a dreadful
effect on the shapes of pulses.
BUILDING FILTERS
Mathematically the behavior of a
filter can be expressed by the ratio of
two polynomials in s, the operator
that represents differentiation with
respect to time. The phase and ampli-
tude response of the filter can be
derived by replacing s with j
ω
, where
j
is the square root of –1 and
ω
is 2
π
times the frequency in hertz.
In a low-pass filter, the numerator
is usually unity. The highest power of
s
in the denominator governs the ulti-
mate rate at which the filter response
falls with frequency. The asymptotic
slope is 6 dB per octave times the
highest power of s.
For mathematical reasons, the high-
est power of s in the denominator is
referred to as the number of “poles”
of the filter and the highest power of s
in the numerator is the number of its
“zeros.” These numbers make a handy
way of classifying filters; for example,
a filter with only poles is a low-pass
filter. The more the number of poles
exceeds the number of zeros, the
steeper the ultimate filter response.
Unfortunately, increasing complexity
makes the filter performance critical-
ly dependent on the precise compo-
nent values. Eight poles represent the
practical limit for most purposes.
The constants multiplying the pow-
ers of s can be derived from the com-
ponent values and, with somewhat
more difficulty, the component values
can be calculated from the polynomi-
als. Analysis programs such as the
shareware program XFUNC simplify
these conversions immensely. Micro-
Cap IV also is helpful in analyzing the
performance of filters.
NORMALIZATION
The idea behind normalization is
that you don’t have to design every
filter from scratch. For any given con-
figuration, you compute the compo-
nent values once for some standard
frequency and impedance. For exam-
ple, you can select 1 rad/s or 1 Hz as
the standard frequency and 1
Ω
as the
standard impedance. If you use 1 rad/s
as the reference, the numerical values
often turn out to be ratios of small
integers. This is the standard I used,
although using 1 Hz may be handier
in practice. It is useful to normalize
low-pass filters to unity DC gain (in
other words, the numerical term in
the denominator is unity).
A filter for any particular applica-
tion can be calculated quickly from
these standard values. First, the
inductor and capacitor values are
divided by the desired frequency (in
radians per second). Next, the induc-
tor and resistor values are multiplied
by the desired impedance and the
capacitor values are divided by the
impedance. Of course, the values you
get rarely correspond to conveniently
available components, but often it’s
possible to juggle the impedance to
make at least the capacitor values
come out right. Tunable inductors are
common enough components.
Decibels
6
3
0
–3
–6
–9
–12
–15
–18
–21
–24
Milliseconds
1000
1
800
600
400
200
0
0.1
1.0
Normalized frequency
10
Butterworth amplitude
Figure 3—
Four-pole Bessel and Butterworth filters are compared here. The Butterworth filter has a sharper corner
and the Bessel filter has a constant delay.
Two-pole Butterworth:
Four-pole Butterworth:
Two-pole Bessel:
Four-pole Bessel:
Figure 4—
Equations and capacitors for active filters are normalized to –3 dB at 1 rad/s.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
15
DESIGNING FILTERS
Both the simple LCR filter and basic
active filter have two poles. In most
cases, a multi-pole filter can be syn-
thesized from a series of two-pole sec-
tions. If you want a filter with an odd
number of poles, you must add an extra
RC roll-off. If the denominator of a fil-
ter can be factored into quadratic (two-
pole) terms, the design becomes easy.
Whereas LCR filters can’t be readily
stacked in series, active filters can be.
Figure 4 gives the equations and the
normalized component values for two
types of two- and four-pole active fil-
ters. I recalculated all the values from
the first principles (published tables
sometimes contain significant inaccu-
racies). Of course, component tolerances
create errors of a few percent. These
generally don’t matter, but it’s com-
forting to start from reliable inputs.
The equations are given for a fre-
quency of 1 rad/s. Take this into account
when calculating the component values
for a particular frequency. Suppose you
wanted a two-pole Butterworth filter
with a –3-dB frequency of 10 kHz and
decided that 10 k
Ω
would be a nice
resistor value. (By the way, changing
the 1:1 ratio of the resistors changes
the damping factor, but usually isn’t
worth the bother.)
For a Butterworth filter, the damp-
ing factor (Z) is 0.7071,
The normalized product of the capaci-
tors is 1 and their ratio is 1:2. That is,
if the resistors are 1
Ω
and the corner
frequency is 1 rad/s, then C1 is
0.7071F and C2 is 1.4142F.
Actually, you want the corner fre-
quency to equal 10 kHz, 62,832 rad/s.
To calculate the real capacitor values,
you divide the normalized values by
62,832 to get to 10 kHz and by anoth-
er 10,000 to make the resistors 10 k
Ω
.
These calculations make C1 = 1125 pF
and C2 = 2251 pF, both reasonable
values. In practice, you would use,
say, 2200-pF capacitors for C2 and
1000-pF and 100-pF capacitors in par-
allel for C1. The resistors should be
changed to 10.2 k
Ω
to compensate for
the capacitors’ values.
INPUTS AND OUTPUTS
Most textbook filter designs assume
that the input and output of the filter
are voltages. Some configurations con-
vert currents to voltages or vice versa.
This is helpful when the related equip-
ment supplies or requires a current.
Fast DAC chips have current outputs
and may need filtering to remove steps
at the clock frequency. That’s when a
current-to-voltage filter is useful, par-
ticularly because the output capaci-
tance of the DAC chip can be absorbed
into the filter’s input capacitance.
The same trick is handy when put-
ting an anti-aliasing filter in front of a
flash ADC. The ADC’s input capaci-
tance, which would otherwise be a
significant load on the driving circuit,
becomes an inherent part of the filter.
The classic two-pole passive LCR
filter is a transimpedance device that
converts a current to a voltage or vice
versa. The current is treated as a volt-
age because it flows through the resistor.
Two LCR stages put back to back,
sharing a common damping resistor,
results in a practical four-pole filter
+1
Buffer amplifier
ffer am lifier
C1
C2
Voltage
Voltage
output
L2
L1
Current
source
input
Figure 5—
For fixed frequency applications, this four-pole LC filter is particularly easy to design. It must be driven
from a current source and be followed by a voltage buffer.
16
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
that can be used in a low-, band-, or
high-pass configuration. It requires an
input current to drive it and a buffer
amplifier to drive whatever follows it.
Figure 5 shows this useful filter. You
may recognize it as the one I used on
the DAC output of my NCO genera-
tor project (Circuit Cellar 89, 90). It is
easy to design because the resistor
effectively isolates the two halves of
the filter. Table 1 shows the normal-
ized component values for this filter.
TUNING FILTERS
So far I’ve been assuming that the
filter components never change. When
equipment must operate over a range
of input frequencies, you need a tun-
able filter. Luckily the Sallen and Key
configuration is readily tuned by
changing its two resistors in unison. The
tuning can be electrically controlled
over several decades. One way to do it
is by using CdS photoresistors illumi-
nated by LEDs as the tuning elements.
You do not need to use variable
resistors. A switched-capacitor filter
emulates the resistors by sending
pulses of charge through capacitors.
Changing the pulse rate changes the
filter’s cutoff frequency.
The most versatile tuning compo-
nents are analog multiplier chips. [1]
Many have a voltage input and cur-
rent output, which are ideal for driv-
ing an integrator. Two integrators in
the so-called “state variable” configu-
ration make a versatile two-pole fil-
ter. It has simultaneous high-, band-,
and low-pass outputs. These can be
combined to make special-purpose fil-
ters such as a tunable notch filter.
Changing the control voltage applied
to the multipliers linearly tunes the
cutoff frequency. Multiplier chips
often have differential inputs that can
simplify the filter. [2]
Any of these devices are capable of
controling the cutoff frequency of a
filter over one or two decades. Wider
ranges can be achieved by switching
the tuning capacitors with relays or
analog switches. I have designed
equipment that incorporates pulse-
shaping filters tunable over a six-
decade range. [3] Traditionally, active
filters were limited to cutoff frequen-
cies less than 100 kHz. With modern
REFERENCES
[1] C. Siu, “Design innovations pro-
vide for voltage-tunable, state-
variable active filters for mega-
hertz ranges,” EDN, September
28, 1995.
[2] T. Napier, “Multipliers imple-
ment tunable filters,” EDN,
March 16, 1992.
[3] ———, “Sifting Signals from
Noise,” Electronics Now
Magazine
, April 1999.
[4] ———, “Take tunable low-pass
filters to new heights,” EDN,
January 15, 1998.
[5] W. Hill and P. Horowitz, The
Art of Electronics
, 2nd ed.,
Cambridge University Press,
Cambridge, England, 1989.
SOURCE
Micro-Cap IV
Rainbow Software
+44 0 208 2954500
www.micro-cap.co.uk
Tom Napier was a principal engineer
in the Signal Recovery Group of
Aydin Corp. He designed tunable
pulse shaping filters into the single-
board bit synchronizer selected by
NASA for use in Space Shuttles. He is
now a consultant and writer.
multiplier chips and fast unity-gain-
stable amplifiers, this range can be
extended to at least 20 MHz. [4]
FILTERED OUT
I can’t cram a filter design course
into one article, but I hope I’ve given
you an understanding of what types of
analog filters exist and what they can
do. The best sources for more infor-
mation are trade magazines and appli-
cation notes. With one exception, The
Art of Electronics
, there’s a void in
the textbook market. [5] Many books
discuss the elementary LCR filter.
Beyond those are the highly mathe-
matical theoretical treatments, which
overlook that someone might actually
want to build a filter for a real appli-
cation. One last thing I should tell
you is that practical topics like filters
that use nonideal auxiliary compo-
nents or nonstandard configurations
are omitted from both sources.
I
aving a micro-
controller capable
of simultaneous con-
versions could benefit
any number of applications. Just
imagine the possibilities. In this arti-
cle, I want to introduce the queued
analog-to-digital converter (QADC)
architecture and explain how to pro-
gram the modules to perform conver-
sions. I will explain how to perform
simultaneous conversions by trigger-
ing QADCs together externally.
The QADC is a versatile module
that is flexible and easy to program.
The “64” sometimes added as a suffix
(QADC64) refers to the maximum
number of entries that can be created
in the queue. The QADC64E is an
enhanced QADC64 with some addi-
tional features, such as an alternate
reference source. The MPC565 has
two QADC64E modules, and I will
refer to them as QADCs throughout
the rest of the article.
Architecturally, the module is a
10-bit, unipolar, successive-approxi-
mation converter with built-in ana-
log multiplexing. The conversions
are controlled by a 64-entry instruc-
tion queue that programs how to con-
vert a particular channel. The instruc-
tions in the queue are called conver-
18
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
FEATURE
ARTICLE
After introducing
queued analog-to-
digital conversion,
Andrew will have all
of us programming
modules and perform-
ing conversions in no
time. As he shows us,
versatility and flexibili-
ty are at the heart of
QADC modules. And
the result in your
application is synergy.
sion command words, or CCW. When
converting, the QADC module per-
forms the conversion instructions it
finds sequentially in the queue. The
64 instruction spaces can be divided
into two queues that can have differ-
ent priorities and execution methods.
On the MPC565, there are 40 analog
input pins, each of which can be con-
verted by either QADC (i.e., the ana-
log inputs go to both modules). Figure 1
shows the integration of the QADC
modules on the MPC565.
As a successive-approximation con-
verter, the module samples and holds
an applied voltage and then duplicates
the held voltage using a D/A convert-
er fed by a combination of resistive
and capacitive dividers. A high-resolu-
tion comparator compares the sam-
pled voltage to the internally pro-
duced voltage to determine the exact
code required for input into the DAC.
The QADC has a resolution of 10 bits
(1024 points) over a 5-V range (approx-
imately 5 mV each), which it can
compare to the sampled voltage. The
module has a specified accuracy of
±2 counts (±10 mV) across 5 V. Figure 2
is a block diagram of the analog sub-
system in the QADC module.
On the QADC64E module, you can
select an alternate reference over
which you can apply the 10 bits of
resolution. This means that instead of
using 10 bits across 5 V, you can use
10 bits across 2.5 V, which provides
an LSB approximately equivalent to
2.5 mV. This is useful, for example, if
you’re sampling the output of a sensor
with an output range of 0 to 2.5 V and
would like to use the full 10-bit reso-
lution of the QADC across 2.5 V.
The two modules on the MPC565
share the trigger input pins, there-
fore, they can be triggered simultane-
ously. This is particularly useful for
electric motor control, where infor-
mation is required simultaneously
with consumption of current and
applied voltage. These measurements
can be used to calculate the power
factor of a running motor.
Another example is the use of the
QADC in a wind-power electricity
generator. In these systems, continu-
ous measurements of power output,
wind speed and direction, and blade
Andrew Lillie
Simultaneous Analog-to-
Digital Conversions
h
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
19
revolutions and pitch need to be made
and adjusted. Real-time control or
data acquisition can be accomplished
easily using the QADC module.
Now that you know the basics, let’s
program the modules for simultane-
ous conversions.
SETTING UP THE MODULES
The MPC565 microcontroller was
originally designed for controlling
today’s high-efficiency automotive
engines and has strict requirements
for the state of the pins at initializa-
tion. For this reason, the micro has
internal pull-ups and pull-downs on
many of the pins because they can be
multiplexed as general-purpose inputs
and outputs. The QADC module is no
exception. Unused analog inputs can
be used as digital I/O, therefore they
must exit the reset state in a known
condition. The analog input channels
to the QADC module on the MPC565
have internal pull-ups. Because you’ll
convert analog voltages on these pins,
you must disable these pull-ups. To
do so, write to the pad module config-
uration register (PDMCR) and set the
PULL_DIS (11) and PRDS (6) bits:
write –l 0x2FC03C = 0x02100000
The QADC modules are referred to
as module A and B, or QADC_A and
QADC_B. The modules are controlled
by a series of registers beginning with
the module configuration register
(MCR) shown in Table 1. For the pur-
pose of this application, use the MCR
to put both modules into Master
mode, which causes the modules to
derive the module clock, QCLK,
internally. At this step, you also need
to place both modules into Supervisor
mode so that you can access all the
registers by setting the SUPV bit (8).
To program QADC_A as master, set
bit 9 (MSTR) and bit 8 (SUPV):
write –w 0x304800 = 0xC0
The QCLK is so called because it
clocks the traversal of the CCW
queue and operates the successive
approximation state machine.
QADC_B can be programmed the
same as QADC_A:
write –w 0x304C00 = 0xC0
The next step is to program the
modules to divide the system clock to
create an appropriate
QCLK. The system
clock on the
MPC565 can typical-
ly run at 40 MHz or
as high as 56 MHz.
The QADC can run
as fast as 2 MHz and
as slow as 500 kHz.
For this example,
program the clock
divider to divide by
28 so that a 56-MHz
system clock will
create a 2-MHz
QCLK. If it’s running
at 40 MHz, this
would run the
QADC at 1.4 MHz.
The period of the
QCLK determines
the amount of time
that a voltage can
settle on the sample capacitor and
also the length of time that it takes to
perform the 10 cycles of the approxi-
mation using the comparator and suc-
cessive approximation register.
To program the QCLK, use the last
seven bits of control register zero
(QACR0) shown in Table 2. Then, you
need to set the prescaler value to 28
for both modules:
write –w 0x30480A = 0x001B
write –w 0x304C0A = 0x001B
CONVERSION COMMANDS
The heart of the QADC is its con-
version command word (CCW)
queues. This is where you can pro-
gram the module to convert a chosen
channel according to a particular
AN44
AN45
AN46
...
...
...
AN59
AN64
AN65
AN66
...
...
...
AN87
VRH
VRL
ALTREF
ETRIG1
ETRIG2
Trigger
jumper
f
eference
R
Re
s
System
b
u
s
and
cloc
ks
System
bu
s
and
cloc
ks
QADC_A
0×304800
QADC_B
0×304C00
Figure 1—
The two QADC modules on the MPC565 share the analog and refer-
ence inputs. The two modules also share the trigger inputs, which allows simul-
taneous conversions to be started.
Bit(s)
Name
Description
0
STOP
Set enables low-power Stop mode
1
FRZ
Freezes module operation after completion of current conversion
2–7
Reserved
8
SUPV
Supervisor/unrestricted data space. When zero, only MCR, test register, and interrupt register are configured as supervisor-only data
space.
When one, all QADC64E registers are designated supervisor-only
9
MSTR
Master/slave operation. When zero, the module is the slave and QADCMCR EXTCLK should be used to select the conversion clock
source. When one, the module is the master and QADCMCR EXTCLK should be left clear.
10
EXTCLK
External clock selection. When zero, the internal conversion clock will be used to clock the converter. When one, input from the
EXT_CLK pin will be used to clock the converter.
9–11
Reserved
Table 1—
The QADC master configuration register configures the QADC module operation, including access to the clocks and register. The address of QADC_A QADCMCR
is 0x304800 and the address of QADC_B QADCMCR is 0x304C00.
20
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
requirement. The queues are created
by writing CCWs into the CCW table
in the register memory. The queues
are controlled by the three control
registers (QACR0–QACR2), and their
status can be read from status regis-
ters (QASR0–QASR1). As conversions
are completed, the digital value is
written into the corresponding loca-
tion in the result word table. Note
that the conversion result is stored in
the result table at the same relative
location that the CCW used to per-
form the conversion. Figure 3 shows
the relationship between the queues
and the result table.
The next step is to program the
queue with the CCWs for the chan-
nels you wish to convert. Because
you’re building a simultaneous con-
version example, you’ll program
QADC A and B similarly. In the
CCW, the conversion cycle time can
be adjusted for the required settling
time on Csample.
Each conversion consists of three
steps: initial sample, final sample, and
resolution. During the first step, the
selected input voltage is applied to
the sample capacitor for two QCLK
cycles. For the next step, the selected
input charges the sample capacitor
directly. Each CCW can specify a final
sample time of two or 16 QCLK
cycles. Finally, during the third step,
the DAC and comparator match the
charge on the sample capacitor. This
step executes for 10 QCLK cycles
(once per bit of resolution).
For this example, let’s program the
QADC modules to perform conver-
sions on channels AN44 and AN64.
You will also convert an internal
channel to make debugging easier.
Each QADC has several internal
channels. The voltage reference high
(VRH), voltage reference low (VRL),
and mid-reference channel:
[1]
all are available for conversion.
Add the mid-reference channel on
channel 62 to your queue. You’ll leave
the input sample time bit clear in
each of the CCWs for this case.
Depending on the source signal and
its output impedance, you can set this
bit to have the sample capacitor
charged for 16 QCLK cycles during
the final sample in step two. Because
this example won’t fill all 64 entries
in the queue, you must program the
last entry with channel 63 to indicate
the end of the queue (see Listing 1).
Notice that you have not pro-
grammed the two QADCs to convert
the same channel simultaneously.
QADC_A converts channel 44 then
64 and QADC_B converts 64 then 44.
Converting the same external channel
at the same instant isn’t advisable
because the input pins are shared and
essentially you would be connecting
both sample capacitors together and
halving the input resistance to the
QADC. If this kind of operation is
necessary, it would be a good idea to
increase the input sample time (IST)
in the CCW to 16 QCLKs. Both
QADCs will convert channel 62
simultaneously; this is permissible
because each QADC creates its own
internal mid-reference channel.
It will be easier to verify that the
module is working correctly if you
clear the result registers before per-
forming any conversions. You can
clear the result table by writing zero
to each register that you plan to use
(see Listing 2).
TRIGGERING THE CONVERSIONS
Having programmed the queues and
cleared the result registers, next you
need to determine how to trigger the
conversions for simultaneous execu-
Input mux
CDAC
S A R
S.A.R.
QCL
QCL
Comparator
–
CRH
CRH
CRL
7
3
3
C sample
C s
C
Figure 2—
The analog subsystem of the QADC64E drawn as a block diagram shows the sample capacitor, com-
parator, and successive approximation blocks.
Bit(s)
Name
Description
0
MUX
Externally multiplexed mode
1–2
Reserved
3
TRIG
Trigger assignment. When zero, ETRIG1 triggers queue one, ETRIG2
triggers queue two. When one, ETRIG1 triggers queue two and ETRIG2
triggers queue one
4–8
Reserved
9–17
PRESCALER
Determines the QCLK frequency. The QCLK is specified to operate from
500 kHz to 2 MHz. To keep the QCLK within specification, the
PRESCALER divides the system clock to create the QCLK frequency.
Sample values include:
0001001 = Fsys/10
0010011 = Fsys/20
0011011 = Fsys/28
1000111 = Fsys/40
1010111 = Fsys/56
Table 2—
The QADC control register zero (QACR0) configures the QCLK with prescaler parameter fields and
defines whether or not external multiplexing is enabled. Note that the QACR0 is located at 0x30480A for QADC_A
and 0x304C0A for QADC_B.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
21
tion. The modules can begin execu-
tion in several different ways. When
you set a bit using software, both an
external trigger and interval timer can
initiate execution of the queue. To
ensure a truly simultaneous event, it’s
necessary to trigger both modules
simultaneously. This rules out any
command line entries in the debugger
for a software trigger. Use an external
trigger that is input to both QADCs
to commence scanning the CCWs.
Usually, an internal periodic inter-
val timer (PIT) drives the QADC, but
you need to provide an external trig-
ger for simultaneous conversions. In a
normal application, you might use a
time processor unit (TPU) or the
MIOS (Circuit Cellar 130) on the
MPC565 to trigger the QADC mod-
ules, but covering that would be a
whole article in itself! You need
something simpler to get started.
Remember how the QADC analog
inputs also can be used as digital I/O?
Let’s configure one of the unused ana-
log input pins to be a digital output
pin. You can jumper this pin to one of
the external trigger pins and then tog-
gle the pin to trigger the queue execu-
tion. I used channel AN59, which
corresponds to digital I/O A7 on
QADC_A. First, you need to configure
the pin to be an output using the data
direction register (DDRQA). Setting
the MSB in this register sets
AN59/A7 to an output:
write –w 0x304808 = 0x8000
It’s a good idea to clear this pin so
that you know what state it starts in.
Do this by writing a zero to the port
data register (PORTQA):
write –w 0x304806 = 0x0
Make sure you don’t forget to
jumper AN59 (A_A7) to the external
trigger (ETRIG1). You can check out
the process in Figure 1. Notice that
for this to work, ETRIG1 has to be a
shared input for both QADC modules,
which it is! So, you can now trigger
both QADC modules with the same
software write. In the QACR0 regis-
ter, where you set the system clock
prescaler for the module, there is a
TRG bit that assigns either trigger
one or two to either queue one or
two. Leaving the TRG bit cleared
assigns trigger one to queue one.
The last step is to configure the
queue one control register (QACR1)
for an appropriate queued instruction
execution method. There are several
execution options available to choose
from. The queue can be executed
once and then wait for another trig-
ger (single scan), or it can execute
continuously after receiving the trig-
ger (continuous scan). The polarity of
the trigger also can be programmed
using the QACR1.
Table 3 shows the QACR1 bit
assignments. There is also an option
to have a gated trigger in either
Continuous or Single Scan mode. A
gated trigger allows the queue to be
scanned whenever a trigger is high;
execution will stop if the trigger goes
low (gate closes) or the end of the
queue is reached.
For simplicity’s sake (and to give
you a chance to read your results) pro-
gram the queue to operate in Single
Scan mode. You will use Gated
Trigger mode and use the AN59 digi-
tal output to open and close the gate.
The QACR1 register needs to be pro-
grammed for both QADC modules.
For QADC_A, write:
write –w 0x30480C = 0x2F00
For QADC_B, write:
Begin queue 1
End of queue 1
Begin queue 2
End of queue 2
Result 0
Result 63
Channel select,
sample, hold, and
A/D conversion
Conversion command
word table
Result
word table
10-bit Result word
(ccw0)
BQ2
(ccw63)
10-bit CCW word
P REF
IST
CHAN
6
7
8
9:16
Result
7 8
0 0 0 0 0 0
0
15
Right justified, unsigned
Result
7 8
0 0 0 0 0 0
0
15
Left justified, signed
S
Result
7 8
0 0 0 0 0 0
0
15
Left justified, unsigned
IST—Input sample time: 0 = 2, 1 = 16 QCLKs
BYP—Bypass sample buffer
REF—Use alternate reference voltage
P—Pause until next trigger
Figure 3—
The associations between the CCW queue and result table are shown here.
QADC_A CCW queue:
write -w 0x304A00 = 0x002C
/# channel AN44
write -w 0x304A02 = 0x0040
/# channel AN64
write -w 0x304A04 = 0x003E
/# channel AN62 (VRH-VRL)/2
write -w 0x304A06 = 0x003F
/# channel 63 (End Of Queue)
QADC_B CCW queue:
write –w 0x304E00 = 0x0040
/# channel AN64
write –w 0x304E02 = 0x002C
/# channel AN44
write –w 0x304E04 = 0x003E
/# channel AN62 (VRH-VRL)/2
write –w 0x304E06 = 0x003F
/# channel 63 (End Of Queue)
Listing 1—
Program each conversion command word into the queue in the order in which they need to be
executed. Only internal module channels (62 and 63) are converted at the same time on each module.
22
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
write –w 0x304C0C = 0x2F00
Note that the single scan enable
(SSE1) bit must be set for the gate
position to be sensed and cleared fol-
lowing the completion of the scan of
the queue. This means that to per-
form another conversion using the
same queue, you must set the SSE1
bit in both QADC modules before
opening the gate.
The QADC module is capable of
managing two CCW queues with dif-
fering priorities and execution strate-
gies. To keep things simple for this
example, disable queue two on both
modules using the QACR2.
You must program the beginning of
queue two to a memory location that
is beyond the end of queue one so
that queue one does not pause while
waiting for queue two to finish. The
following is the code to program
QACR2 for each module:
write –w 0x30480E = 0x0040
write –w 0x304C0E = 0x0040
READY, SET, CONVERT
OK, you’re almost ready to push the
button. Before continuing, let’s take a
minute to review. You have turned off
the internal pull-ups, set QADC_A
and QADC_B to be masters, and set
the QCLK to a prescaler of 28. Also,
you created a trigger using AN59 in
Digital Output mode, which you con-
nected to the EXTERNAL TRIGGER 1
pin. The queues were programmed to
convert the AN44 and AN64 inputs
and the internal channel AN62. Both
modules were programmed to perform
single scans using an external gated
trigger. And finally, the gate is closed
because you wrote a zero to the digi-
tal output on pin AN59.
So, what’s missing? Inputs! You
haven’t connected a signal to AN44 or
AN64. Begin by applying a fixed volt-
QADC_A:
write -w 0x304A80 = 0x0
write -w 0x304A82 = 0x0
write -w 0x304A84 = 0x0
write -w 0x304A86 = 0x0
QADC_B:
write -w 0x304E80 = 0x0
write -w 0x304E82 = 0x0
write -w 0x304E84 = 0x0
write -w 0x304E86 = 0x0
Bit(s)
Name
Description
0
CIE1
Queue one completion interrupt enable
1
PIE1
Queue one pause interrupt enable
2
SSE1
Single scan enable bit. SSE1 enables a single scan of queue one to start
after a trigger event occurs. The SSE1 bit may be set to a one during
the same write that the MQ1 bits are programmed. The QADC64E
clears the SSE1 bit when the single scan is complete.
3–7
MQ1
Queue one Operating mode:
00000 = Queue one disabled
00001 = Software-triggered Single Scan mode (started with SSE1)
00010 = Externally triggered rising edge Single Scan mode
00011 = Externally triggered falling edge Single Scan mode
01111 = External gated Single Scan mode
10010 = Externally triggered rising edge Continuous Scan mode
10011 = Externally triggered falling edge Continuous Scan mode
11111 = External gated Continuous Scan mode
8–15
Reserved
Table 3—
The QADC control register one is the mode control register for the operation of queue one. QACR1 is
located at 0x30480C for QADC_A and 0x304C0C for QADC_B.
Listing 2—
Clearing the result register locations before execution will help to debug results between succes-
sive program executions. Also, it will be easier to check if the module is working properly.
24
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
age to make sure everything is work-
ing. If so, you can connect a sine wave
or other varying amplitude signal.
Connect AN44 and AN64 to different
fixed voltages. A voltage divider will
work and not much current is needed
because the multiplexers connect the
inputs to the sample capacitor, creat-
ing a high-impedance input.
To begin conversions (simultane-
ously!) open the gate by writing a one
to the AN59 pin:
write –w 0x304806 = 0x8000
Having triggered the scan by opening
the gate, the QADCs execute each
CCW in each queue sequentially. The
modules perform the execution
simultaneously because they were
triggered by the same event.
How long should you leave the gate
open? Well, let’s figure it out. It will
take 14 QCLK periods per channel to
convert the input (four QCLKs for the
sample and 10 QCLKs for the conver-
sion resolution). You’ll convert three
channels, so that makes 42 QCLKs
total. If the MPC565 is clocking at a
Results QADC_A
0x28A
0x0B5
0x282
QADC_B
0x1F0
0x230
0x1FF
Tr
Trigger
Channel B
B
Channel A
Figure 4—
QADC_A
and QADC_B are
triggered simultane-
ously and convert
their respective
channels. The
results record the
levels of each wave-
form simultaneously
allowing real-time
control of the device
using data from both
channels.
QADC_A right justified results:
read -w 0x304A80=short /# QADC_A converting AN44
read -w 0x304A82=short /# QADC_A converting AN64
read -w 0x304A84=short /# QADC_A converting (VRH-VRL)/2
QADC_B right justified results:
read -w 0x304E80=short /# QADC_B converting AN64
read -w 0x304E82=short /# QADC_B converting AN44
read -w 0x304E84=short /# QADC_B converting (VRH-VRL)/2
Listing 3—
The results are read in the same order that they were programmed into the queue and executed.
Right-justified results are preceded by zeros.
QADC64 A convert AN44 result
(0x304A80) = 270 = 0x10E
QADC64 B convert AN64 result
(0x304E80) = 269 = 0x214
QADC64 A convert AN64 result
(0x304A82) = 272 = 0x214
QADC64 B convert AN44 result
(0x304E82) = 272 = 0x10D
QADC64 A (VRH-VRL)/2
(0x304A84) = 513 = 0x201
QADC64 B (VRH-VRL)/2
(0x304E84) = 512 = 0x200
Listing 4—
Results are displayed in decimal and hexadecimal by the debug code. The decimal values are
fractional values of 1024 counts with 1024 as the full-scale reference.
The red/black banner is a trademark of Texas Instruments. 45-5216R
Choose, don’t compromise. The MSP430F12x from Texas Instruments is the latest addition to
the expanding portfolio of Flash-based 16-bit RISC MCUs. From $0.99 to 60 kB, the MSP430
family provides a range of exceptional cost/performance solutions to meet the rigorous
requirements of low-power applications. See for yourself: order your development tool today.
TI MSP430: the choice in
ultra-low-power Flash MCUs.
■ Ideal for battery-powered applications such
as utility metering, intelligent sensing and
portable measurement
■ Ultra-low power consumption –
250-µA active mode, 0.8-µA standby mode
at 2.2 V (typ.)
■ Integrated analog peripherals
ideal for precision data conversion
applications at a fraction of the code size
■ In-system programmable Flash allows
last-minute code changes and remote
field upgrades
Flash RAM I/O WDT Comp_A Timer_A USART Timer_B
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
27
SOFTWARE
The code is available on the Circuit
Cellar
SOURCE
MPC565
Motorola, Inc.
(512) 328-2268
Fax: (512) 891-4465
www.mot-sps.com
Andrew Lillie works in the 32-bit
Embedded Controller Division,
Mixed Signal Team of the Motorola
SPS Transportation and Standard
Products Group. You may reach him
at andrew.lillie@motorola.com.
rate of 56 MHz and you have a
prescaler of 28, the QCLK is 2 MHz,
or 500 ns per period. Therefore, you
know it will take 21 µs to perform
the three conversions.
For debugging purposes you may
find it helpful to verify that the queue
has been completed. The QADC sta-
tus registers are useful for this pur-
pose. Status register zero (QASR0) in
Tables 4 and 5 contains a queue one
completion flag. After the last conver-
sion has been completed and the end
of the queue is reached, the comple-
tion flag (CF1) is set.
CF1 is the most sigfinicant bit in
the QASR0. This register also shows
information on the status of the
queue using bits 6 to 9 (QS). Five
queue status conditions, idle, active,
paused, suspended, and trigger pend-
ing, are reflected between the two
queues. Before reading the results,
close the gate by clearing AN59:
write –w 0x304806 = 0x0000
To check the status of queue one
(module A), input:
read –w 0x304810
For module B, the address for the
QASR0 is 0x304C10.
THE RESULTS
The QADC modules store the
results in several formats. Right-justi-
fied unsigned, left-justified signed,
and left-justified unsigned results are
available. Because the QADC module
is a 10-bit converter, the results are
10 bits long with the remaining six
bits in the 16-bit entries read as zero.
Results are stored in the same order
that channels were converted in the
queue. Listing 3 shows the code to
read right-justified results from
QADC_A and QADC_B.
Listing 4 shows my results with 1.3
and 2.6 V applied to AN44 and AN64,
respectively. To convert from these
hexadecimal results to voltages, con-
vert your hexadecimal results to deci-
mal, divide by 1024, and then multi-
ply by the reference voltage of 5 V.
To really test the
simultaneous conver-
sions, apply the same
sinusoid to the AN44
and AN64 inputs and
perform the conversions
again. The results should
be within four counts of
each other for all four
conversions. Figure 4
shows a possible input
and result scenario.
Remember to set the
SSE1 bit (2) in the
QACR1 register before
you open the gate again.
The CCW entries in the queues will
remain programmed until they are
overwritten or the part is reset.
Another way to apply the trigger is
to connect a (debounced) switch to a
5-V supply and connect the output to
the Trigger one input. To try some-
thing different, see if you can set the
alternate reference bit in the CCWs
for the conversions in one of the mod-
ules. Apply voltages (less than the
alternate reference) to both modules
and see how the increased resolution
over the applied voltage range affects
your results.
The QADC64E module is a flexible
and versatile A/D converter. Synergy
is created when two modules are used
together. Motorola’s MPC565 micro
further blurs the boundaries between
the two modules because either
QADC can convert any analog chan-
nel. The QADC also can be easily
connected to an external multiplexer
to provide 32 additional inputs.
I
Bit(s)
Name
Description
0
CF1
Queue one completion flag. CF1 indicates that a queue one scan is completed and the result has been entered in the result table.
1
PF1
Queue one pause flag. PF1 shows that the queue has reached a pause.
2
CF2
Queue two completion flag
3
PF2
Queue two pause flag
4
TOR1
Triggers overrun for queue one. A trigger event generated by a transition on the external trigger pin has been received while a queue
is executing and before the scan is completed or paused. TOR1 has no effect on queue execution.
5
TOR2
Triggers overrun for queue two
6–9
QS
Queue status is a 4-bit read-only field indicating the current status of the queue. Table 5 shows the 4-bit status codes.
8–15
CWP
The command word pointer indicates the current location in the queue.
Table 4—
The status registers contain information about the state of each queue and the current conversion. QASR0 is located at 0x304810 and 0x304C10 for QADC_A and
QADC_B, respectively. It contains a queue one completion flag, which is set after the last conversion.
QS [9:6]
Queue one, queue two states
0000
Queue one idle, queue two idle
0001
Queue one idle, queue two paused
0010
Queue one idle, queue two active
0011
Queue one idle, queue two trigger pending
0100
Queue one paused, queue two idle
0101
Queue one paused, queue two paused
0110
Queue one paused, queue two active
0111
Queue one paused, queue two trigger pending
1000
Queue one active, queue two idle
1001
Queue one active, queue two paused
1010
Queue one active, queue two active
1011
Queue one active, queue two trigger pending
1100–1111
Reserved
Table 5—
The queue status bits indicate the current execution mode each
one of the queues.
28
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
lectronics in
automobiles can be
a blessing and a curse,
depending on whom you
ask. For my particular situation, it
was both. The project I’m about to
explain began when I changed tires
from a 75 series tire to a smaller
diameter 60 series on my 1995 truck.
Initially, my electronic speedometer
was accurate (within 1 mph); I veri-
fied it with a mobile radar speed dis-
play set up on the side of the road.
However, after replacing the tires, I
assumed the speedometer would be
affected. And in the future, I may
install a lower rear axle ratio, which
will further increase speedometer
error. Other truck owners I’ve talked
to said they have the same sort of
errors, especially after monster mud
tires are installed. In fact, errors
greater than 10 mph when traveling
60 mph are common.
Electronic speedometers in many
1995 and later vehicles are factory-
tweaked with calibration values
stored in the vehicle’s powertrain con-
trol module (PCM). Some older vehi-
cles don’t have this calibration, and
instead use a separate calibration box
to allow fine-tuning for different rear
axle and tire combinations.
FEATURE
ARTICLE
Problems often fuel
great projects. Eric’s
trouble with gauging
his truck’s speed lead
to a design that is
both interesting and
practical. With elec-
tronics in vehicles,
complications are a
given. But, with some
engineering know-
how, you can devise
workable solutions.
I asked a couple GM dealers about
correcting the speedometer by repro-
gramming the PCM, but both said if
it isn’t a factory combination, they
cannot/will not correct it. I figured
that would be the answer. After that,
it was time to learn about what I can
do to fix it myself.
I pulled out the GM shop manual,
which revealed that the speed signal
path begins at a variable reluctance
speed sensor located in the transmis-
sion, then heads to the PCM, and
then to the speedometer. A signal
that’s 4000 pulses per mile is sent to
the speedometer from the PCM.
However, little information describes
the signal to the PCM, which caused
me some trouble later on.
When surfing the Internet, I uncov-
ered a few aftermarket devices that
can electronically calibrate speedome-
ters. Most of the devices are installed
between the speedometer and its
input signal, which can be an AC sine
wave or DC square wave signal. A sig-
nal enters the unit at a specific fre-
quency and is processed by increasing
or decreasing frequency according to a
user-selected ratio. This modified sig-
nal is then sent to the speedometer.
Information on digital and analog cali-
bration devices shows few details on
operating temperatures, accuracy, and
speed/input frequency range.
After this basic research, it was
time to plan the project. Looking at
the existing products, missing fea-
tures, and installation requirements
helped me refine my wish list. First
of all, I had to be able to mount the
device under the hood or outside the
vehicle. I did not want to run addi-
tional wires inside the glove com-
partment; there’s little room for a
hole or wires in there.
The device must be capable of
detecting AC sine wave and DC
square wave input signals. I also
wanted the ability to bypass a factory
speed limiter. On-the-fly ratio adjust-
ment from 50% to 150% of input
frequency in increments of 0.5% or
less is important because it helps
quickly adjust speed.
Accuracy better than 0.5% made
the wish list. Accuracy beyond 0.5%
is difficult to detect with an analog
Eric Kesselring
The Need for Speed
e
An Accurate Speedometer
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
29
(needle) speedometer. I noted that the
output signal must be compatible
with AC and DC speed sensors. The
device has to operate from 1 mph to
faster than 100 mph. And, I wanted
the unit to run from an 8- to 15-VDC
power source and have an indicator
for troubleshooting.
The entire package had to be small
for easy mounting in small crevices.
The plan was to use low-cost parts
available in small quantities from cat-
alog distributors. And finally, the last
important item to round out my wish
list was to develop the project with
low-cost or free tools.
When I started checking off the
wish list, I discovered that no existing
products have speed limiter bypass or
my necessary features. So, my two
options were to modify one of these
products or roll my own. Either
choice would take more time than I
wanted to spend, but at least with the
latter option I would have more con-
trol over the details.
INTERCEPTING THE SIGNAL
Grabbing the signal between the
speed sensor and PCM is required
when correct vehicle speed is used for
automatic transmission shift points
and to disable the speed limiter. Hall
Effect, optical, and variable reluctance
types are the most common. Most of
the two-wire speed sensors are vari-
able reluctance, and the three-wire are
Hall Effect or optical. The Ford,
Universal (see Photo 1), and GM sen-
sors I tested were variable reluctance
sensors. The output signal character-
istics are listed in Table 1.
A circuit with an input range of 0.5
to 30 V
p-p
should fit the bill. Optical
and Hall Effect sensors may have 0 to
5-V or 0 to 12-V outputs. A reed switch
or simple contact sensor may require
a pull-up resistor for proper sensing.
The comparator circuit in Figure 1 will
detect all three input signal types.
R9, R10, C7, D1, and D2 keep volt-
ages to U1 at a safe level and filter
out transients and pull-up resistor R6
allows non-powered contact opera-
tion. R2 through R5 set the set point
to approximately 0.25 V with 100 mV
hysteresis when combined with R1.
Installing R15/JP1 raises the trip to
2.5 V and drops hysteresis to approxi-
mately 50 mV for Hall Effect, optical,
or other high-level output sensors.
The final output to the microcon-
troller is a 5-V square wave.
INTERFACING THE OUTPUT
Generating the output voltage sig-
nal is simple. Most variable reluc-
tance sensor outputs vary quite a bit
over the operating range (from hun-
dreds of millivolts to more than tens
of AC volts), so something within
that range should work. A square
wave output should work well for
most sine wave VR inputs as long as
the output is AC coupled and goes
through a zero crossing.
Hall Effect or optical sensors with 0
to 5-V or 0 to 12-V output are easily
created with an open collector output.
Figure 1—
As you can see, there are no spare gates or I/O lines shown in this adapter schematic.
30
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
The PCM processing signal most like-
ly consists of an input circuit, such as
shown in Figure 1, although opti-
mized for a specific range. To make
the output universal, both an AC- and
DC-coupled open collector transistor
output need to be included.
You should be able to pick 5 V, 12 V,
or no pull-up. The output also should
be something close to a 50/50 duty
cycle just in case heavy filtering that
might miss a narrow output pulse is
inside that PCM.
REMAINING HARDWARE
The hostile automotive electrical
environment demands some consider-
ation of spikes, surges, EMI, and all
sorts of potential gremlins. On the
input power side, a series resistor and
zener shunt keep surges below the
maximum rating of the 78M05 regula-
tor and open collector driver transis-
tor. A 1N4001 series diode provides
reverse polarity protection, because an
approximate 8-V total dropout should
be fine for this application.
To prevent complications with volt-
age sags and other unknowns, a
DS1232 voltage watchdog device
overlooks things and expects periodic
notification to hold off hardware reset
from a properly operating software
loop. An LED tied to the output via
the other half of the comparator fol-
lows the output frequency. At low
input frequencies, flashing is visible.
Check out the schematic of the
device in Figure 1.
Picking a processor normally
involves a biased opinion, and this case
was not an exception. Access to cheap/
free development tools, availability in
small quantities, and enough I/O were
minimum requirements. Two timers,
preferably 16 bits, and at least one
interrupt and hardware multiplier
would speed software development.
The fact that I’m familiar with the
8051 family of devices also influenced
my choice. Because 12 switches, one
input, and one output were the bare
minimum, I could use an Atmel
89C2051 device with 15 I/O lines.
Figure 2 displays a diagram of the
device. [1] Two nice things about this
device are the flash memory and com-
patibility with the 8051 family. This
compatibility became useful during
software simulation and development.
Flash memory is a pleasure when cor-
recting mistakes before anyone notices.
TRANSFORMING THE SIGNAL
Now that I had a nice square wave
signal, I was ready for the further pro-
cessing. One method to modify the
signal for calibration is measuring the
time period between falling edges of
input signals (t), multiply it by a
selected ratio, and create a new peri-
od. I used two microcontroller timers,
one to capture the input period and one
to control the modified output period.
Most low-end microcontrollers don’t
have fast floating-point multiplication
or division capability, so special scal-
ing is required to keep calculation
time minimal. An easy method to
accomplish this is using a scaled frac-
tional multiply. Division by 2
N
(2048,
4096, 8192…) can be quick by shifting
the result 11, 12, or 13 bits right.
One hardware restriction to consid-
er is the number of switches to use
for ratio selection. I suggest a 12-posi-
tion DIP switch (large and readily
available). Reserving one switch for
function selection leaves 2048 adjust-
ment steps to cover the desired ratio
range. This narrows choices to a mul-
tiple of 2048 divided by 2
N
. Larger
ranges give larger adjustment steps.
You may achieve a balance with
binary division by 4096 (dropping
three LSBs), and it’s quick when using
a multiplier between 1024 and 16,384.
The output period adjustment range
will be 0.25 to 4.25t. Using 11 posi-
tions of the switch (2
11
), the range 0 to
2048 gives 2048 possible ratios between
1024 and 16384. The basic formula to
determine the output period is:
The maximum timer period, t,
restrictions keep the result within the
40-byte limit of the multiply routine.
RAM Address
register
RAM
B
Register
ACC
TMP2
TMP1
PSW
ALU
Interrupt, serial port,
and timer blocks
Timing
and
control
Instruction
register
Port 1
latch
Port 3
latch
Port 1 drivers
Port 3 drivers
Stack
pointer
Flash
memory
DPTR
Program
counter
PC
Incrementer
Buffer
Program
address
register
+
–
OSC
Analog
Analog
com
mparator
RST
V
cc
P1.0 – P1.7
P3.0 – P3.5
P3.7
Figure 2—
The two 16-bit timers, hardware multiply, and flash memory of the 89C2051 helped simplify the code. [1]
32
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
A range of 0.25 to 4.25t is possible,
and increments are less than 0.5%
between 1.5 to 0.5t. The disadvantage
of this method is that increments are
not uniform, increasing at higher
ratios and decreasing at lower ratios.
Range can be easily expanded or con-
tracted depending on the area of inter-
est. Note these are period values, so
frequency output will be reciprocal.
FIRMWARE TASKS
The program consists of three major
tasks, input capture/timer interrupt
handler, output period timer interrupt
handler, and signal processing/main
loop. The code is in assembly for fast
calculations and interrupt
response. It’s also small, just
under 620 bytes.
The 89C2051 timers run
from the processor clock value
divided by 12, giving 500-ns
resolution with a 24-MHz
clock. Because 16 bits overflow
in 32 ms, an additional byte in
T0 and T1 interrupts is used to
extend the period to a more rea-
sonable 8 s before overflow.
Input capture is handled by
Interrupt 0, which grabs the
value in T0 and resets the
timer to zero. T0 also checks
and sets the flag for a time-out
condition. A counter to track
the number of output pulses
per input pulses is also reloaded
during this task.
The output period timer
interrupt handler task loads the
calculated output period, toggles the
output bit if the output pulse counter
isn’t zero, and decrements the output
pulse counter. This stops extra output
pulses when an input time-out occurs.
The main processing continuously
loops in the background, reads the
ratio from input switches, calculates
the new output period, checks the
speed limit, and initiates the watch-
dog. Half of the corrected time period
is loaded into the timer because I
want a 50/50 duty cycle output wave-
form. If this portion of the time peri-
od is less than the limit, the adapter
speed limit is exceeded and the device
does one of three things.
Photo 1—
You can use Universal (left) and Ford (right) speed
sensor for testing. Both sensors work with speedometer cables.
Most recent vehicles, including my 1995 truck, do not use
speedometer cables.
Photo 2—
The aluminum
enclosure, assembled
board house, and etched
prototype PCBs are
ready to be installed in
the enclosure. A couple
beads of RTV silicone
hold the PCB inside. The
grommet for the cable
fits in the hole on the
short side. Another hole
on the long side is filled
with silicone and creates
a window for the LED.
A monthly magazine for the
electronics enthusiast, amateur
or professional.
described and illustrated
projects in each issue, includ-
ing full p.c.b. layout and wiring
diagrams.
Ingenuity Unlimited – read-
ers’ circuit ideas
New Technology Update –
keeping you informed of
advances in technology
Circuit Surgery – readers’
circuit problems answered.
FEATURES describing how
electronics monitors and
controls the world around us.
You can also order printed
issue subscriptions or buy a
wide range of electronics
books and CD-ROMs.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
33
I used a Dallas DS1230, with 32-KB,
battery-backed RAM that holds every-
thing during power down. An 8000h
offset is added in the linker because
the RAM is mapped to start at loca-
tion 8000h. Small programs like this
The first option is to do nothing if
the bypass switch is on. The second
option is loading the entire time peri-
od for sending twice the period, or
half the frequency. Manual transmis-
sion vehicles can tolerate half the fre-
quency output, which will simply cut
the indicated speed in half and double
the range of the speedometer.
However, automatic transmission
vehicles might have a fit with a sud-
den change from say a 90 to 45 mph
reading and might try to downshift.
So, option number three involves
clamping instead of halving the out-
put so that the apparent speed never
increases after it exceeds the preset
value. After the correct value is ready
and processing is complete, an update
flag is set and a short loop waits for
the next input period interrupt to
clear the flag, indicating the next
sample is ready to process.
CHEAP EMULATOR
A great low-cost way to emulate
most 8051 devices in real time is using
an SBC with a monitor program to
download code into external memory-
mapped RAM. A NMIY-0031 board
from New Micros with an 8051 proces-
sor costs less than $50 and allows
direct downloading of 8-KB hex files
into memory-mapped RAM right out
of the box. Jumpers on the board allow
upgrades to 32-KB RAM and ROM.
take less than 15 s over a 9600-bps con-
nection with HyperTerminal. After
the hex file download is complete, an
X8000 <CR> command begins executing.
One drawback is the restricted I/O,
as only one 8-bit port is available for
dedicated I/O. Because 14 lines are
needed, switch values were hard-
coded for testing ratios and software
debugging. Interrupt vectors are
remapped with this offset as well,
which adds a few extra cycles to the
interrupt response.
Offsets and compensations for
interrupts will be slightly different
from development to the target code.
When basic operation is satisfactory,
simply remove the offset and compile
again for testing the target system. A
few
$IF and $ELSE switches in the
source code add correct I/O assign-
ment for the switches and constants
when they’re compiled.
I used Franklin’s Proview32 to link
and compile this program. I’ve also
used the full-function evaluation ver-
sion for small projects. That version
has a 4-KB limit, which is plenty for
Photo 3—
During testing, the unit should be semipermanentely installed in your vehicle. I plan to replace the tie
wrap when I pick up a hose clamp. The adapter wiring is spliced in between the PCM and speed sensor. The
adapter receives power (12 V) from the ignition.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
35
the <700-byte code in this project.
You can download Proview32 for free
from the company’s web site.
PUTTING IT ALL TOGETHER
To keep the unit small, I used a
two-sided board. Most devices are sur-
face-mounted and all are on the top-
side. Larger components and tracks
were easier to work with because I
knew I would make at least the first
PCB using the laser printer toner
transfer and etching process. I stayed
with 1206- and SO-8-size devices
except for two capacitors. The tracks
were at least 0.015
″
. Parts smaller
than 1206 make it tough to pass a
trace this large between pads. In addi-
tion, tiny parts make it more difficult
to hand assemble.
Adding an alignment line on both
the top and bottom patterns to cut
along provided two nice alignment
edges. I then placed both patterns and
the PCB on a raised flat piece of
0.375
″
aluminum plate and pushed
them into a right-angle corner formed
with two perpendicular blocks of
wood to align all three pieces. For
visual aid, think of forcing all three
pieces as a sandwich into a corner of a
room. This setup allowed the patterns
to float a little, and some of the heat
applied to the topside of board
reached the bottom and secured it
enough to hold alignment.
After the top pattern was trans-
ferred, I flipped over the board to heat
the other pattern. I didn’t have to use
tape or alignment holes. Alignment
between the top and bottom pattern
was surprisingly good, and I was able
to hit every via and component
through the hole between the sides
using a 0.028
″
drill.
This is only the eighth board I’ve
made, so I’m not an expert by any
means. I touched up some minor
defects with a Sharpie marker. And,
after etching, I had to add extra solder
in a couple spots to connect tracks
etched completely through. A flux
pen was a big help when tinning the
bare copper tracks.
Under-the-hood temperatures can
easily exceed 100°C, therefore, low-
cost plastic enclosures were not an
option. Polycarbonate can handle this
kind of heat, but small, inexpensive
versions are not commonly available.
I opted instead for a 1590 WA cast
aluminum box sold by Hammond.
This small (1.52
″
× 1.375
″
× 3.64
″
) box
has a removable four-screw lid and a
sealing gasket at a reasonable cost.
Case dimensions are available at
Hammond’s web site.
I had trouble fitting the PCB
because I made it before having an
enclosure to measure. The PCB had
little clearance anyway, and the draft
causes the bottom to be smaller than
the top. Luckily, the same file used
for the surge testing was still opera-
tional and helped massage the PCB to
fit nicely inside the enclosure. What a
great dual-purpose tool! A coating of
clear spray polyurethane over the PCB
with the connector and DIP switch
helped seal out moisture. The PCB is
held tight with a couple beads of sili-
cone caulk along the bottom of the
case (see Photo 2).
TEST AND DEBUG
With an assembled and tested PCB,
I was ready for real-life experiment-
ing. I verified basic operation by sup-
plying a 1000-Hz, 5-VAC square wave.
Ideally, a 100% ratio output should be
exactly as the input. At first it wasn’t,
instead the input and output traces
would chase each other across the
screen when viewed with an oscillo-
scope. But, burn-and-learn adjust-
ments to compensate for interrupt
response and timing errors were easy
thanks to the flash memory of the
89C2051. After a handful of trials,
both waves stayed in phase for an
exact 1:1 input-to-output ratio from
less than 1 Hz to more than 5 kHz.
Two factors that limit the high-
frequency response are the interrupt
response time and fighting over the
processor time. Looking at the out-
put on the oscilloscope shows that
up to 10-µs output jitter occurs
when an input pulse is received
simultaneously as the output pulse
interrupt is being serviced or if an
output pulse interrupt requests serv-
ice while an input pulse interrupt is
being serviced.
This limits the maximum output
frequency to about 4 kHz while main-
taining 0.1% accuracy. With even
multiples of adjustment such as 25%,
0.70%
0.60%
0.50%
0.40%
0.30%
–0.20%
0.00%
0.10%
0.20%
–0.10%
Error %
13
30
26
6
1
65
5
2
7
882
104
43
130
0
4
1
4
334
156
6
4
169
95
208
86
182
25
234
46
260
0
7
286
68
3
1
228
365
50
39
1
1
500
00
Input frequency (Hz)
0.10%
0.00%
–0.10%
–0.20%
–0.30%
–0.80%
–0.60%
–0.50%
–0.40%
–0.70%
Error %
13
30
65
5
2
104
43
1
4
33
4
169
95
208
86
260
0
7
3
12
8
3
91
1
Input frequency (Hz)
Figure 3—
Check out the accuracy versus input frequency. Compare the –5%
(a)
and 5%
(b)
adjustment error ver-
sus frequency data. The dip at 3128 Hz may be caused by a combination of the 0.1-Hz limited display resolution
and difficulty adjusting precise frequencies with a dirty potentiometer on the signal generator.
a)
b)
36
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
100%, and 200%, jitter is greatly
reduced because interrupts don’t fight
each other at varying intervals.
The charts in Figures 3a and b show
how accuracy decreases when fre-
quency increases above 4 kHz. I meas-
ured for accuracy using two separate
1/Tau rate meters with minimum-
maximum display, one each on the
input to and output from adapters.
Jitter doesn’t appear to be a problem
in actual use because the speedometer
indicator is heavily damped, either
electrically, mechanically or both.
The PCM most likely takes several
samples, because the speed sensor
output itself could have some jitter
from drivetrain backlash, speed varia-
tions over bumps, etc.
Some home-brew surge and
brownout testing did not show any
errant operation. Dragging the power
supply wire in series with a fine-
stranded wire over a dirty file simu-
lated basic surge testing. Plenty of
nasty signals appeared. Adding a
1000-µH inductor in series generated
even nastier stuff, with peaks above
60 V to below –30 V with a 20-V
power supply. Neither of those or a
slowly rising/falling supply voltage
would kill it. As long as the voltage
stays above 7.2 V, it’s perfectly happy.
Excellent so far….
HIDDEN UNDER THE HOOD
Now that the prototype skipped
through some basic tests and torture,
it was time to let the hostile real
world have a shot at it. Photo 3 shows
the semipermanent mounting loca-
tion tied to the cruise control servo
bracket. With the engine running, rear
wheels off the ground and turning,
the first hook-up resulted in a hum-
bling unsuccessful result. The LED
was working, however, the speedome-
ter indicated nothing. A handful of
things were amiss.
First, the speed sensor input to the
PCM has a 5-V, 8-µA pull-up current,
so the output coupling capacitor of
the adapter charges but never crosses
zero. Apparently, the PCM is expect-
ing a zero crossing. Adding a 10-k
Ω
terminator between the AC output
and ground took the bias off and
brought the zero crossing back.
After that fix, a reading showed up
on the speedometer, but much too
fast. Energy from the ignition system
was causing false triggers on the
adapter’s input. Adding a 1000-k
Ω
ter-
minator across the speed sensor input
at the adapter screw terminal strip
halted the interference and still
allowed below 2-mph speed detection.
Another surprise came when testing
the speed limiter bypass: it was active
at very low speeds. Closer examina-
tion revealed the signal to the PCM
was not 4000 pulses per mile as stated
in the manual, but rather a much
higher number. So, now I had to
determine that number. I started by
taking the signal generator out to the
garage, hooked it to PCM speed sen-
sor input, and adjusted frequency to
speedometer for readings of 100, 90,
80, on down to 0 mph at 10-mph
intervals while recording the input
frequency applied. Averaging the read-
ings gave a result of 26.07 Hz/mph,
which works out to:
60 s/min. × 60 min./hour × 26.07
Hz × miles per hour = 93,582 pulses
per mile
That’s a significant difference from
the 4000-pulse-per-mile, 111.1-Hz,
100-mph (1.11 Hz/mph) trip point
first tested. Because I wanted a speed
limiter half-value function to begin at
95 mph with 10-mph hysteresis, the
high trip and release points needed to
be 2476.6 Hz and 2215.9 Hz, respec-
tively. So, I tweaked the set points,
and was ready to test again.
With the new software in place and
switches set to 100% ratio, I started
the jackstand speed test. The speedome-
ter ran up to 94 mph then dropped to
48 mph as it should. I continued run-
ning until close to 5000 rpm, which
came to an indicated 75 mph. Slowing
down, the speedometer dropped until
it reached about 40 mph, then jumped
back up to 84 mph.
Now, I had to verify that the speed
limiter in the PCM was still function-
al by switching off bypass. Sure
enough, 5 s after the speedometer read
above 100 mph (maximum reading),
the engine would die until speed
dropped below about 95 mph. An
interesting observation I noticed was
the up-shift indicator light illumi-
nates when the adapter’s half-frequen-
cy function engaged. Apparently the
PCM has a map of the revolutions per
minute versus vehicle speed and
knows the current gear.
Tests on the alternate mode pro-
gram that clamps frequency output
also operated properly. When I set the
compiler switch and limits for the
maximum reading (95 mph, 10 hys-
teresis), the speedometer would reach
95 mph and stay there as the engine
ran close to the redline in fifth gear.
After the speed decreased, normal
operation returned as if there was
nothing there. I didn’t have a volun-
teer for testing with an automatic
transmission, but I assume those
operate correctly in most cases.
Now that the basics were working,
I needed a beginning adjustment set-
ting to compensate for the smaller
tire. Some tire research uncovered the
overall diameter for both the old and
new tires. Unfortunately these are not
Sensor type
Resolution
Output level
DC impedance
Ford E3AF-9E731-AB 8 pulses-per-sensor
1.3 V
p-p
at10 rpm,1.3 Hz
208
Ω
from T-5 manual
revolution. 8000 pulses-
1.8 V
p-p
at 60 rpm, 8 Hz
transmission
per-mile configuration
4.8 V
p-p
at 200 rpm, 27 Hz
7.5 V
p-p
at 300 rpm, 40 Hz
10 V
p-p
at 1500 rpm, 200 Hz
Universal cruise
8 pulses-per-sensor
0.28 V
p-p
at 30 rpm, 4 Hz
42
Ω
control
revolution
0.52 V
p-p
at 60 rpm, 8 Hz
1 V
p-p
at 120 rpm, 16 Hz
1995 GM S-10 truck,
40 pulses-per-driveshaft
1 V
p-p
at 144 Hz, 216 rpm
1440
Ω
5-speed stick
revolution
6 to 7 mph indicated on speedometer
GM Shop manual
0.5 V min. per shop manual spec for
spec
troubleshooting
Table 1—
The output characteristics for the speed sensors are variable reluctance or AC generator sensors.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
37
REFERENCE
[1] Atmel, “8-bit Microcontroller
with 2K bytes Flash—
AT89C2051,” rev., 0368E,
February 2000.
Eric Kesselring is an electrical design
engineer at Northstar Technologies in
Ohio. He develops and tests industri-
al encoders, instrumentation, and
sensors. Eric’s other technical inter-
ests include robotics, electronic
engine controls and instrumentation,
and fast-scan amateur TV (N8WLP).
You may reach him at ekesselring@
northstar-tec.com.
SOFTWARE
The code is available on the Circuit
Cellar
SOURCES
Sensors
Ford Motor Co.
(800) 392-3673
(800) 232-5952 (TDD)
www.ford.com
General Motors Corp.
www.gm.com
Universal Sensors, Inc.
(504) 885-8443
www.intel.ucc.ie/sensors/
universal/index.html
AT89C2051, AVR
Atmel Corp.
(408) 441-0311
Fax: (408) 436-4200
www.atmel.com
DS1230
Dallas Semiconductor, Inc.
(972) 371-4000
Fax: (972) 371-3715
www.dalsemi.com
ProView32
Franklin Software, Inc.
(408) 296-8051
Fax: (406) 296-8061
www.fsinc.com
NMIY-0031 board
New Micros, Inc.
(214) 339-2204
Fax: (214) 339-1585
www.newmicros.com
the best numbers; the static load radius
would be a better comparison. Only
the new tire data included this number,
so the overall diameter was the best I
could find. Comparing the new (numer-
ator) and old (denominator) tires:
I created a chart in Excel to list all
2048 possible adapter ratios and
switch settings. I chose the closest
(0.962), and then observed the engine
revolutions per minute increase about
75 rpm at 65 mph.
Fine calibration can be implement-
ed many different ways. I considered
three options. Maintaining a steady
speed and timing mile markers is one
choice. The more averaged markers,
the better. The second option is to
travel a known distance, possibly by
counting mile markers, and then
compare the odometer reading with
actual distance. However, the resolu-
tion of rolling number odometers is
poor, so I would have to drive a long
distance to minimize error. The last
option is following someone going a
known speed and adjusting the
adapter settings so the speedometer
reads same speed. (Police are not
always a good example!)
For starters, I chose the first
method. Massive road construction
limited the number of mile markers,
so I had a limited sample size.
Traveling 60 mph for 5 miles required
4 min. 58 s according to my stop-
watch. This put my calculated speed
at close to 60.4 mph. It’s difficult to
maintain a steady speed over 5 miles
so I expected some error. I intend to
do additional fine-tuning after more
mile markers are installed or on my
next long road trip.
LOOKING BACK
I concluded the majority of the
work during the long, cold winter
months inside a nice, warm house.
My unheated garage made me post-
pone most of the in-vehicle testing
until reasonable temperatures arrived.
I was fortunate to have a couple speed
sensors for testing. A great little five-
pole DC motor and a 6:1 planetary
geartrain salvaged from a dead elec-
tric toothbrush along with a piece of
silicon surgical tubing made a work-
ing vehicle speed simulator.
A variable power supply controlled
the speed surprisingly well from less
than 30 to >1500 rpm. It sounded
frantic at about 10 V, 1500 rpm, so I
didn’t test the limits of the motor or
gearbox. I used a variable speed drill
for slow-speed tests, but it was diffi-
cult to maintain a speed.
Everything worked well under the
hood as soon as the true speed sensor
resolution and ignition interference
problems were solved. So far, the
adapter has run flawlessly in my
truck for several months. High tem-
peratures have not been a problem
during 95°F-plus summer weather.
The accuracy is slightly better than
what I required. Unfortunately, I was
hoping for less jitter and higher speed
operation, proving the real-world
accuracy is still in progress, and prob-
ably exceeds the accuracy of the
speedometer movement.
Only about half of the code space
in the microcontroller is used, leaving
room for creeping featurism. The cur-
rent processor is running as fast as it
can at 24 MHz. A brain transplant
with a Philips 87LPC or Atmel AVR
device for faster interrupt response
would be an interesting enhance-
ment. The AVR is an inviting choice.
Some versions appear pin-compatible
with the 89C2051 and have on-chip
EEPROM for interesting possibilities
with simpler semi-automated calibra-
tion and limit adjustments.
I have a few PCB boards left and a
kit of parts is available for those of
you who are not afraid of surface-
mount assembly. Anyone whom is
interested in assembled and tested
units should contact me.
I
RESOURCE
87LPC
Philips Semiconductor
(212) 536-0500
Fax: (212) 536-0559
www.philips.com
38
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
he sensor con-
troller board is the
central nervous sys-
tem or brain of a robot,
and as such, it enables the robot to
see, hear, and touch. In fact, the sen-
sory mechanisms used by the most
complex and sophisticated robots sim-
ulate the functions of the human cen-
tral nervous system.
Robots interpret sensory data by
using artificial synapses and neurons
called neural networks, fuzzy logic,
and artificial intelligence algorithms.
This process is known as sensor
fusion and sensor interpretation in
the world of AI. Algorithms are used
in image processing to interpret fea-
tures and improve image quality. They
are used also in advanced signal pro-
cessing applications for pattern recog-
nition, MRI, ultrasound, and interpre-
tation of sonar and radar signatures.
In order to reduce cost and increase
ease of construction, a sensory system
for a homemade robot ideally would
be smaller and simpler than its com-
mercial cousins. For example, Dragon
Systems offers a product called Point
and Speak, which uses neural net-
works to recognize voice commands.
The drawback to using neural net-
works is that they require the use of a
FEATURE
ARTICLE
What’s the difference
between a robot and
the Scarecrow? The
brain, of course. In
this two-part series,
Daniel focuses on
what makes a robot
tick—artificial intelli-
gence. By adding this
sensor controller
board, you get to be
the great and power-
ful Wizard of Oz.
laptop or PC to run the voice recogni-
tion software, but there are other
products that may be embedded into
small appliances that are able to per-
form similar functions in voice recog-
nition. These are called voice recogni-
tion integrated circuits or boards.
One such board is Sensory’s Voice
Direct voice recognition module.
Voice Direct is used in automobile,
home automation, and cellular phone
systems. Unfortunately, this board
has limited voice recognition vocabu-
lary and is a little costly.
However, there is an inexpensive,
DIY, modular sensor board that you
can assemble that meets all the
requirements for home projects. It is
based on the PIC18C452 processor
and is used for collecting and process-
ing sensory data. Because of its modu-
lar nature, the board can be adapted
for other applications.
In fact, presently I’m in the process
of integrating this board into my
“antique” Heathkit Hero I Robot.
(The Hero I robot is a small, R2-D2-
type robot kit that first appeared in
the mid ’80s.) My Hero I is still oper-
ating, complete with an arm, wrist,
gripper, a head that rotates nearly
360°, and a teaching pendant. This
three-wheel robot is powered with a
sturdy front wheel geared motor. It
also has a sensor suite consisting of
one Polaroid 6500 sonar ranger, a light
sensor, motion detector, microphone,
optical encoder for the drive motor,
and voice synthesizer.
I plan to update the electronics and
sensors, because in its current config-
uration, the Hero I fails to recognize
obstacles in time to avoid collision. I
anticipate this upgrade will relieve
the currently overburdened 6808
microprocessor from this task and
improve its performance. The Hero I
robot I’m modifying is shown in
Photos 1 and 2. Photos 3 and 4 are
snapshots of another small robot that
could use the sensor board.
The sensor controller board has
many uses. For example, you could
combine it with a PC to create a data
logger for collecting environmental
data such as temperature, humidity,
wind speed, rain level, and pressure.
In addition, the board can digitize
Daniel Ramirez
Robot Sensor Controller
Board
t
Part 1: The Brain
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
39
voice, music, or sounds. Digitizing
video, however, which isn’t practical
with this design, requires a fast ADC.
THE SILICON BRAIN
The PIC18C452, one of Microchip’s
best 8-bit RISC microprocessors, is
the brain of the board. It is extremely
fast compared to others in its class.
Although the ’452 is an 8-bit proces-
sor, it has both fixed- and floating-
point libraries supplied by Microchip.
The ’452 has 73 RISC instructions
that are backward compatible with
PIC16Fxxx units. It also has in-circuit
serial programming capability (ICSP)
which allows the new PIC18Fxxx to
be programmed using only two pins. [1]
BOARD ARCHITECTURE
The controller board shown in
Figure 1 and Photo 5 features a 20-MHz
PIC18C452 with built-in A/D ports
that can collect and process data from
as many as eight analog sensor inputs
and eight digital I/O inputs. The ana-
log A/D pins (AN0–AN7) are used by
the A/D conversion experiments and
are shielded by resistors to prevent
large current surges from destroying
the internal A/D hardware.
The eight analog lines and eight
port B digital I/O lines are brought
out to two convenient pin headers.
The board features a Microchip
24LC16 serial EEPROM that can store
or log sensor data such as calibration
gains and offsets, temperature, pres-
sure, voltage, and resistance. A
MAX233 IC, which is used for serial
RS-232 interface to the host or master
controller, is included as well.
The PCB board real estate was
tight because of Eagle CAD demo lim-
itations and the fact that I kept the
PCB one-sided to make it easier to
Photo 1—
A front shot of the Hero I shows the hex key-
pad and robot arm. It also shows the Hero I experimen-
tal board that I’m going to use to interface the sensor
controller board to read and process the six Sharp
GP2D12 IR ranger sensors.
Figure 1—
To build the PIC18C452 sensor controller board, use this complete schematic. You can connect the unused port C and D bits to pin headers for extra digital I/O
lines if the board is going to be wire wrapped.
Photo 2—
You can see the robot’s arm, wrist and grip-
per in this side view of the Hero I.
40
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
build. I decided to use a separate 5-V
regulated power supply to enable the
board to be powered from a 9- to 12-V
battery or wall transformer if a regu-
lated 5-V supply isn’t available (see
Figure 2). I had the power supply cir-
cuit built-in on the wire-wrap version
of this board.
The sensor board uses the analog
inputs to interface to various analog
transducers and sensors. Depending
on the application, these sensors can
be based on resistance, capacitance, or
voltage for their measurements. The
readings may be digitized by the inter-
nal A/D hardware with a resolution of
either 8 or 12 bits in order to be digi-
tally processed by the PIC.
Most of the extensive digital I/O
capabilities of the PIC18C452 are
used in this design, including eight of
the 32 digital I/O lines to read the
states of switches, bumpers, proximi-
ty sensors, and any other sensor that
returns a binary value. The remaining
digital I/O lines are available, but I
used them only in the wire-wrap ver-
sion of the board because of the PCB
real estate limitations.
The sensor board also uses the digi-
tal I/O lines of port B to handle dis-
crete events such as contact with the
proximity sensor to indicate the pres-
ence of an obstacle and generate an
interrupt for the event. Other PIC
microcontroller hardware features
that may be used for this application
include extensive interrupt capabili-
ties with two levels of interrupt prior-
ity (high and low), interrupt on
change of port B status, and a parallel
slave port (port B). An optional hex
keypad may be connected to port B
digital I/O pin headers on the board.
I included an I
2
C serial EEPROM in
the board design to write configura-
tion and sensor calibration data to it.
This allowed it to be used in data log-
ging, security, and robot diagnostic
applications. I plan to include a
Philips PCF8583 I
2
C real-time clock
IC to log each event by writing a time
and date stamp to a serial EEPROM.
The additional 256 bytes of SRAM
that this IC provides will be conven-
ient for storing volatile data. The
real-time clock will be an extra I
2
C
module tied to the SDA and SCL lines
of the board. A schematic of the board
is displayed in Figure 3.
Embedded applications that may
benefit from this board design in a
stand-alone configuration are data log-
gers, alarms, DC motor controllers,
and servo motor controllers. For these
applications, you may use the capture
hardware of the PIC18C452 to read
optical encoder counts, and the ana-
log-to-digital hardware to read the
Photo 3—
I plan to integrate a PCB version of the sen-
sor controller board to this robot in order to perform
obstacle avoidance experiments with it.
Adjust Speed and/or Direction
Easy Serial Interface
Tachometer/Counter Input
Solutions Cubed (530) 891-8045 phone www.solutions-cubed.com
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
41
analog sensors so that the sensors
may be time stamped and logged to
either a serial EEPROM or flash disk.
SIGNAL CONDITIONING
Voltage to the analog inputs of the
board should be kept at 0 to 5 V to
avoid damage to the PIC18C452 IC.
Signal conditioning of analog inputs
ensures that safe voltage levels are
maintained while improving the sen-
sor’s dynamic range by amplifying the
voltage to levels between 0 and 5 V
for maximum A/D resolution. The
conditioning is easily accomplished
using analog amplifiers.
Voltage reference, noise reduction,
and noise immunity issues are han-
dled with signal conditioning hard-
ware such as voltage reference ICs,
analog filters, single-ended inputs, and
differential inputs. Note that these
A/D related topics are essential for
understanding and operation of the
sensor controller board. [2]
MOBILE DATA COLLECTION
Data collection and logging used to
be the domain of mini-computers and
dedicated PCs, which used data col-
lection boards that were either S100-,
VME-, ISA-, EISA-, or PCI-based.
Laptop computers now make it possi-
ble for mobile data collection although
the laptop has limited bus expansion
slots (if any). A laptop computer in
the office, car, school, or factory can
collect environmental data from the
sensor controller board setup in a
stand-alone configuration. Sensor data
is received by the laptop via the serial
port or RF link.
THE POPULAR I
2
C INTERFACE
The I
2
C is a popular protocol that
has been around for years, and is used
by manufacturers of televisions,
radios, CD players, and cell phones.
I
2
C was developed by Philips as a
means of communication between
Photo 4—
From this angle, you can see the Polaroid
6500 sonar ranger mounted on an RC-actuated sensor
platform on the small robot I built.
Photo 5—
The topside view of the sensor board shows
my recommended site for component placement.
Robots, machines, your systems, or ours!
Header fits standard breadboard
www.quanser.com or contact us at:
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
43
integrated circuits and electronic sub-
systems in order to reduce the num-
ber of interconnections and busses.
The purpose of using the I
2
C proto-
col in this case, is to take advantage
of its capacity to network the robot’s
electronic modules, including the sen-
sor controller board. The advantage of
doing this is that it reduces the inter-
connections from 8- or 16-bit buses to
two wires (clock and data). I plan to
use the I
2
C interface as the corner-
stone to the integration of the robot’s
electronic subsystems. Figure 3 illus-
trates the networked modules using
the I
2
C interface for this protocol.
The I
2
C interface hardware of the
PIC18C452 is used to accept com-
mands and data from the host, the I
2
C
master controller, or the I
2
C slave
controller. The interface hardware
then transfers the information among
them. I plan to use the I
2
C for embed-
ded debugging, using my version of
the C print function. By doing this, I
can debug my application without
expensive in-circuit emulators (ICE)
used by commercial developers.
Another advantage to using the I
2
C
protocol is the wide variety of inte-
grated circuits and sensors available
for connection to the board, such as
temperature sensors, real-time clocks,
and serial EEPROM. The I
2
C protocol
allows you to build low-cost systems
with multiprocessing capabilities.
TURNING LEAD TO GOLD
Algorithms are the recipes for
robotics experimentation. The board
allows for the execution of algorithms
that filter noise and perform such
robotics behaviors as light seeking,
light avoidance, obstacle avoidance,
and voice recognition. Let me list the
algorithms I have completed.
The sensor calibration procedure
shown in Listing 1 computes mini-
mum, maximum, and average sensor
readings. These statistics can be used
to determine the gain and offset
required to scale raw sensor values to
a preselected window (range). You
may compute other statistics such as
median, standard deviation, variance,
and covariance to interpret the cali-
bration results. Note that these statis-
tics are usually computed as part of
*******************************************************************
This routine performs the sensor calibration procedure on any type
of sensor, by determining the min, max and average readings of the
sensor. It will also plot the values using the Stamp Plot pro-
gram.
*******************************************************************
void
CalibrateSensor(byte SensorID)
{
int i,
j;
// Loop index variables
static int RawSensorReading;
// Raw sensor calibration reading
static int MinSensorReading;
// Minimum sensor calibration reading
static int MaxSensorReading;
// Maximum sensor calibration reading
static float
Sum;
// Used to compute the average scaled sensor value
// Initialize calibration variables for the current sensor
Sum = 0.0;
MinSensorReading = 4095;
MaxSensorReading = 0;
for (j = 0; j < NumberOfSamples; j++)
{
// Read the raw sensor value using the selected A/D
channel
RawSensorReading = ReadSensor(SensorID);
// Determine the minimum and maximum reading for the set
// of data collected
if (RawSensorReading < MinSensorReading)
{
MinSensorReading = RawSensorReading;
}
if (RawSensorReading > MaxSensorReading)
{
MaxSensorReading = RawSensorReading;
}
// Accumulate the raw sensor readings, in order to compute
// the average raw sensor reading.
Sum = Sum + RawSensorReading;
}
// Save the minimum and maximum raw sensor readings
SensorTable[SensorID].MinSensorValue = MinSensorReading;
// Minimum raw sensor value
SensorTable[SensorID].MaxSensorValue = MaxSensorReading;
// Maximum raw sensor value
// Compute average raw sensor reading value
SensorTable[SensorID].AverageSensorValue = Sum / (float)
NumberOfSamples;
// Compute the sensor gain (scale factor)
SensorTable[SensorID].SensorGain = (float) (MaxSensorReading -
MinSensorReading) / (float) (SensorTable[SensorID].
WindowMax - SensorTable[SensorID].WindowMin);
SensorTable[SensorID].SensorOffset = 0.0;
// Write sensor calibration results to EEPROM and to scratch
pad RAM for future reference by other applications
WriteCalibrateSensor();
// Read the latest sensor calibration data
ReadCalibrateSensor();
}
Listing 1—
This sensor calibration procedure computes minimum, maximum, and average sensor readings.
44
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
the data reduction process using a PC
or laptop and a data analysis tool.
After the gain and offset calibration
constants have been determined and
saved to EEPROM, it’s easy to make
the PIC18C452 map the raw sensor
readings to scaled sensor readings.
The sensor averaging function,
shown in Listing 2, may be used to
filter noisy readings by collecting a
number of samples and computing
their average value. I found this algo-
rithm adequate for reading the six
Sharp GP2D12 IR ranger sensors as
well as Polaroid 6500.
Now, I’ll give you some other algo-
rithm options to try. Light/look
behavior (think of a moth) compares
the brightness of two light sensors
and turns the robot toward the
brighter side. Light avoidance behav-
ior compares the brightness of two
light sensors and turns the robot
toward the darker side. [3]
You also could choose a line-follow-
ing algorithm, which enables your
robot to follow a line drawn on the
floor. [4] Tracking algorithms are
used to follow a target and determine
its trajectory. [5]
Obstacle avoidance algorithms are
used for obstacle detection and avoid-
ance by using the sonar or IR range
sensor. Specifically, reflexive behavior
algorithms and advanced algorithms
such as vector field histograms (VFH)
and virtual force fields (VFF) enable
the robot to avoid obstacles. [3, 5, 6]
Another possibility is navigation
algorithms, which compare the
robot’s position to a local or global
map using techniques such as bea-
cons, circumnavigation, dead reckon-
ing, and triangulation. [5, 6] And, if
you want to determine the approxi-
mate position of your robot, use an
odometry algorithm. [3, 6]
FFT algorithms require large memo-
ry buffers for fixed- or floating-point
numbers. The PIC has a limited amount
of memory (1536 bytes) that can be
used for workspace. In the near future,
Microchip plans to provide PIC units
with more memory (up to 4-KB
SRAM) which will allow small (up to
256 points) FFTs to be implemented
for experimentation. Covering a design
that would allow larger FFTs is beyond
the scope of this article, because you
would need additional RAM or SRAM
******************************************************************
This code reads the raw sensor value from the selected A/D chan-
nel for a number of samples and filters it using an averaging
filter.
******************************************************************
;
int AverageSensor(byte SensorID)
{
float
AverageSensorValue;
// Averaged sensor value
int i;
// Loop index
AverageSensorValue = 0.0;
for (i = 0; i < NumberOfSamples; i++)
{
AverageSensorValue = AverageSensorValue + (float)
ReadSensor(i);
}
AverageSensorValue = AverageSensorValue / (float)
NumberOfSamples;
return ((int) AverageSensorValue);
}
Listing 2—
To filter noisy readings, you use this sensor averaging function. It works by collecting a number of
samples and computing their average value. This algorithm is adequate for reading the Sharp GP2D12 IR
sensors and Polaroid 6500 sonar ranger.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
45
and the PIC would need to be run in
Microprocessor mode, with external
memory hardware enabled. Instead,
use DSPs or high-end microprocessors
to get better performance.
CONSTRUCTION TECHNIQUES
My first step was to wire wrap the
prototype sensor controller board in
order to debug the design using the
techniques I described in “Optimize
Your PIC” ( Circuit Cellar 133). I
found this useful as part of validating
the board’s design, but the size turned
out to be undesirable for the applica-
tion I had in mind (namely, upgrading
the Hero I sensors). With that in
mind, I assembled the PCB board to
make it more suitably compact and
rugged for robotics applications.
For the lighter, sturdier prototype
boards required for mobile robots, I
recommend a PCB construction
method that requires a positive or
negative etching kit, despite the fact
that this method involves messy
chemicals and requires several extra
steps (e.g., drilling holes). You can buy
decent kits that include all of the nec-
essary equipment for positive artwork
etching. I recommend checking out
the M.G. Chemical kit.
BUILDING THE PIC BOARD
Use the schematic in Figure 1 to
build the sensor board pictured in
Photo 5. This design is based on a
board also described in “Optimize
Your PIC.” If you’ve already built the
prototype board, only minor modifica-
tions are needed to convert it into the
sensor controller board.
Parts placement and board fabrica-
tion techniques are not critical. Wire
wrap, point-to-point, and PCB board
construction techniques all may be
used for this project with the 8-bit
ADC. For optimal results, I suggest
the PCB technique. When using
point-to-point or wire wrap, be sure to
lay out the board with a good analog
ground plane. Pay particular attention
to the ground planes for the analog
A/D inputs (AN0–AN7) to minimize
noise. A good 12-bit ADC design is
beyond the scope of this article
because of complex noise issues, how-
ever, the article “Breadboarding,” by
Stuart Ball, covers the details (Circuit
Cellar Online
December 2000).
If you’re using the single-sided PCB
board, begin by etching the board
with the Eagle layout files provided
on Circuit Cellar’s web site. First,
carefully inspect the board with a
magnifying glass to make sure that
there are no shorts or trace breaks.
Shorts may by repaired by cutting the
traces with an Exacto knife and
breaks may be repaired with wire
jumpers. Next, begin soldering all dis-
crete components and sockets onto
the PCB board, beginning with the
smallest capacitors and resistors and
working up to the LEDs. Then, solder
the pin headers, DIP switches, and
terminal strips. Finally, screw PCB
standoffs to the PCB board and crazy-
glue or solder the RS-232 connector
directly to the PCB board (see Photo 5).
At this point, the circuit should be
examined for shorts or open lines by
using the DVM to check continuity
on power, ground, and logic signals.
You can inspect a PCB board or wire
wrap board using either a magnifying
glass or a digital video camera with a
macro zoom capability. A JPEG photo
viewer on a PC can be used to magni-
fy pictures of the board. Pictures look
great on a TV screen or computer
monitor (it is also handy for soldering
tiny surface-mount components).
Before populating the board with
the ICs, first check for shorts to
ground using the ohm meter, then
power the board by connecting the
separate 5-V power supply module to
the sensor board. Next, connect a 9-V
battery to the positive and negative
power terminals of the 5-V power
supply board and check to see if the
power LED displays. If it does, check
Figure 2—
Use this schematic to build your 5-V power
supply board. You can integrate the power supply on-
board with the sensor board if you plan to wire wrap it.
. Shipping and handling for the
Limited. NO COD. Prices subject
Cherokee International # MQT154A1
Input: 100 - 240 Vac, 3 Amp
Outputs: +5 Vdc @ 26 A, 3.3 Vdc @ 8 A,
BHC Aerovox # ALC10D1001DF
-10 +30%. 1.4” diameter x
2” high. 0.4” pin spacing.
46
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
Author’s Note: Thanks to my wife
Pamela for her time and assistance
with this article.
Daniel Ramirez is a senior software
engineer with more than 10 years of
experience working on real-time
embedded systems. His hobbies
include travel, golf, treasure hunting,
and robotics.
SOURCES
MAX233
Maxim Integrated Products, Inc.
(408) 737-7600
(800) 998-8800
Fax: (408) 737-7194
www.maxim-ic.com
PIC18C452, 24LC16
Microchip Technology Inc.
(480) 786-7200
Fax: (480) 899-9210
www.microchip.com
WARP-13 programmer
Newfound Electronics
+61 3 5224 1833
www.new-elect.com
PCF8583
Philips Semiconductor
(212) 536-0500
Fax: (212) 536-0559
www.philips.com
6500 sonar ranger
Polaroid Corp.
(781) 386-2000
www.polaroid.com
Voice Direct
Sensory, Inc.
(408) 327-9000
Fax: (408) 727-4748
www.sensoryinc.com
GP2D12 IR Ranger sensors
Sharp Electronics Corp.
(201) 529-8200
(800) 237-4277
www.sharp-usa.com
REFERENCES
[1] Microchip Technology Inc.,
“High-Performance
Microcontrollers with 10-bit
A/D,” DS39026C, 2000.
[2] P. Horowitz and W. Hill, “The
Art of Electronics,” 2nd ed.,
Cambridge University Press,
Cambridge, England, July 1989.
[3] J. Jones, “Mobil Robots:
Inspiration to Implementation,”
2nd ed., AK Peters, Ltd., Natick,
MA, 1999.
SOFTWARE
The board layouts and a parts list
are available on the Circuit Cellar
web site.
for 5 V at the V
DD
or V
CC
pin of each
IC and check for 0 V at the V
SS
pin of
each IC. After this step, the board can
be populated with the ICs and is
ready for use.
In the future, I plan to include a
double-sided PCB in order to produce
a better layout, integrate the 5-V
power supply, add a new ground plane
to reduce noise, and bring out all the
I/O pins of the PIC18C452 to a pin
header. I also may increase the clock
speed from 20 to 40 MHz in order to
improve floating point processing.
Replacing the 24LC16 serial EEPROM
with a larger capacity serial EEPROM
for increased data logging capacity is
another option to think about.
The hardware tools and wire wrap-
ping techniques required to build the
sensor controller board include a
WARP-13 programmer, UV eraser, and
test equipment and wire wrap assem-
bly tools (read “Optimize Your PIC”
for more information).
ADD IT UP
The sensor controller board may be
used as an add-on module to distrib-
ute the processing from the main con-
troller on any medium to large robot.
It also may be used as a stand-alone
platform for carrying out sensor-relat-
ed experiments using the C compiler
of the PIC18C452. In Part 2 of this
article, I will describe exactly how the
main sensor controller software works
[4] K. Lunt, “Build Your Own
Robot!” AK Peters, Ltd., Natick,
MA, 2000.
[5] H.R. Everett, “Sensors For
Mobile Robots: Theory and
Application,” AK Peters, Ltd.,
Natick, MA, 1995.
[6] J. Borenstein et al., “Where am
and how to program the PIC18C452
in C. In addition, I’ll include a brief
tutorial on using the Microchip soft-
ware development tools to compile,
link, simulate, debug, and burn an
application onto the PIC18C452.
I
Figure 3—
Notice how the sensor controller board may be connected to various Hero I electronic modules via the
I
2
C interface. In the future, I intend to add a Philips PCF8583 I
2
C real-time clock IC to log each event.
48
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
’ve heard of
USB. I’ve read
books about the sub-
ject in hopes that a
divine light would bring forth some
type of USB project that would help
change the way the world computes.
Well, it hasn’t happened yet. Besides,
I took one look at the cable and
decided this technology is pretty use-
less because the cable won’t plug into
my guitar or amp.
My Sony digital camera has an
integral diskette drive, so there’s no
room for USB there. Although most
of the Florida-room PCs have USB
capability, all of my standard PC
peripherals are non-USB, so there’s
no need for USB there. Eventually I
did find something USB was good
for: my Handspring Visor.
IMPRACTICAL USB
As far as the design and implemen-
tation of USB devices go, there is
absolutely nothing practical about it.
If it’s so easy to spit out USB devices,
why are there so many books and
white papers about it? The market is
filled with USB devices that are mod-
erately priced and easy to use. That’s
nice, but what if you want to roll our
own USB applications?
APPLIED
PCs
I can tell you that the first things to
do are sign up to get a high-speed
Internet connection and head to a
bookstore. When you understand USB
language, the next step is to invest in
some not-so-inexpensive development
kits. Adding insult to injury in that
area, if you don’t already have the
software tools to exploit the USB
hardware, you’ll have to pull out the
plastic. Then, if you decide you want
commercial hardware, go ahead and
shell out a couple hundred more
bucks to join the I-can-make-a-com-
pliant-USB-device club. Geez!
If you’ve gone this far with me,
you’re probably interested in doing
some USB work or waiting to see how
badly I can bash USB. However, I
have an open mind about most tech-
nology that can help all of us become
more productive. With that said, let’s
forge ahead and classify my candid
observations by examining the facts.
My goal is to know what it really
takes to be a successful USB hardware
and software designer.
USB SPEAK
Conveniently, you can download
the updated USB 2.0 specification
and legacy USB 1.1 specifications
from www.usb.org. There’s the option
of reading the total 500-plus pages or
just getting the condensed version.
USB requires an operating system
that can support its intentions. Both
Win98 and W2K are perfect for the job
because they were designed with USB
connectivity in mind. That’s not sur-
prising if you take a look at the PC 99
requirements for Intel. Of course,
Fred Eady
The Basics of USB
i
The technology of
USB won’t plug into
Fred’s guitar, but the
effort did give him an
opportunity to impart
his knowledge of USB
basics. Although his
work didn’t change the
world, you’re in for a
valuable lesson. And,
as always, Fred’s proj-
ect isn’t complicated,
it’s embedded.
Photo 1—
Everything needed to get into USB quickly is
housed in the TM1000 base unit. For those of us who
tend to let the smoke out of DAC and ADC ICs, there’s
a cooling fan to help disperse the smoke.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
49
is a lot like Ethernet except USB
devices normally don’t talk unless
spoken to and don’t think of each
other as peers.
Another difference between USB
and Ethernet is the distance between
devices and the host. Five feet is
pushing it for USB. All of you MCSEs
and CCNAs out there know that Cat 5
can carry Ethernet signals reliably up
to 100 meters. As for a speed compari-
son, it all depends on what you’re
looking for. Low-speed USB is rated
for a maximum of 1.5 Mbps and high-
speed (pre-USB 2.0) USB will max out
at 12.0 MBps if the wind is right.
I’ve read about future releases of the
USB specification that will allow data
rates just over 3 Gbps. Currently, the
USB 2.0 introduction page states that
480 Mbps is the latest and greatest
speed. Compare this with Ethernet’s
standard 10/100 Mb/1 Gbps standards
and, like I said, it depends on what
you want. Raw bandwidth doesn’t
take into account the overhead need-
ed to sustain it, and overhead is
dependent on the conditions at hand.
This is my disclaimer on speed.
Only during a remote wake-up will
the USB device make contact with
the host on its own. Remote wake-up
is a USB feature that allows
the unit to signal the host
when it wishes to continue
communications. Usually,
and by design, the everyday
USB device responds to con-
trol and data sent by the host
and isn’t allowed to capture
the bus. This type of com-
mand and control puts most
of the smarts at the host
level, allowing the USB unit
to be less complex in terms of
software and hardware.
The simplicity factor
makes USB devices inexpen-
sive. Keep in mind though,
the fact that USB devices
tend to be less complicated
and inexpensive doesn’t
mean that you don’t have to
put some concerted effort
into creating a USB device.
A bare-bones USB device
consists of a serial interface
engine (SIE) and a transceiver
What’s a USB hub? It’s a
device. A USB hub allows other
USB devices to plug into it or
be included in the hub elec-
tronics. Much like an Ethernet
hub, the USB signals received
by the hub are repeated. Unlike
an Ethernet hub, the USB hub
also manages the attached
device’s power, segregates high-
and low-speed devices, and
reports on the status of the
devices attached to it.
Each connection on a USB
hub is called a port. USB ports
are different than standard PC
ports, which are designated by
IRQ numbers and I/O address-
es. USB ports all share time on
a single serial data bus, whereas a typ-
ical PC peripheral has its own serial
or parallel data path to the target con-
troller. So, even though each USB unit
will connect to a hub or controller
with its own cable, it’s simply plugging
into a single-path serial USB link.
Hence, what you have is a star con-
figuration that uses hubs to attach
USB devices, which are combinations
of hardware and software that all talk
eventually to a host that controls
what you have defined as a bus. This
Linux is in there, too. Win95 can be
coaxed to do USB, but you have to
have the right OSR.
Don’t lose sight of the fact that USB
is just another way of moving data
from one place to another. The basic
idea is to transfer data between the
Win-whatever or Linux-whatever PC
and USB device over a short distance.
The PC is the host and houses the USB
root hub and host controller. The USB
host controller is responsible for data
formatting and data transfer between
the bus and operating system.
The root hub handles device
connections; its duties include
sensing the devices, performing
command operations initiated
by the host, and passing data
among the devices and host.
Before I define a USB device,
I must define a USB function.
Simply stated, a function is a
device that can do only one
task as far as the host is con-
cerned. A USB device is a func-
tion that can be addressed in
some manner. It can be logi-
cal or physical. At the lowest
level, a device may be a single
hardware component. This
implies that a USB device can
be logical, physical, and elec-
trical. A USB device can con-
tain multiple logical or elec-
trical functions within its
physical confines and still
connect to a USB hub with a
single USB connector.
Photo 3—
The smaller window is the system manager display. The “P” denotes
the presence of a base unit and the “T” indicates the module is running cool.
“No Module” is displayed because there is no module attached and no associ-
ated module application running. The TMTest window tells you that the base
unit is DeviceId 1 and the USB port pins are configured for input.
Photo 2—
The right-angle connector board is actually an exten-
der card. TM1102 enables you to mount the module board (with-
out the lid) at right angles so that the parts on the fan side of the
board can be probed easily.
If you think of a device endpoint as
a buffer area (chunk of memory) and
look at this from the USB device’s
perspective, the IN endpoint is a stag-
ing area for data to be sent to the host.
The OUT endpoint is a memory-based
staging area for information sent from
the host. To move data into and out of
these memory areas, you need a data-
moving unit like a microprocessor.
This notes a powerful point in favor
of USB. You have the capability of
creating a USB device that can talk to
anything you attach to it using any
communications format. Also,
because the USB and host are intelli-
gent, the data that flows into or out of
the USB can be of any format. Data
format conversion as well as commu-
nications format conversion become a
simple matter of programming.
The USB specification allows for
data to flow quickly between the
USB device and host. That leaves
overhead, transfer speed, distance,
and your imagination as the only
constraints of USB device attach-
ment. USB will not work every-
where in every situation, but the
existence of inexpensive and easy-to-
use audio and video devices that use
USB architecture say it all.
Getting back to the USB language
lesson, recall I stated that a USB unit
could be a single physical device with
many functions. Applying what you
have now learned about device end-
points, it makes sense that a collec-
Photo 4—
The TM1000-BUS is functionally identical to
the base unit. It uses the same API and can be evalu-
ated and examined using
TMTest
. It can be plugged
into a device to provide instant USB connectivity.
(physical interface). You can speak
USB to it but it won’t do much real
work. To add functionality and spark
to a USB device, the SIE and trans-
ceiver must be supported by intelli-
gence, which is why popular USB ICs
have on-chip microprocessors.
A typical USB device interfaces
between the host application and
outside world. Again, proving that
USB is host-centric, IN is used in
USB speak to indicate data that
should be returned to the host from
the addressed USB device. On the
other hand, OUT indicates data
that should be received by the
addressed USB device.
IN and OUT bring up some more
jargon you need to know about, name-
ly device endpoints. Per the USB 2.0
specification, a device endpoint is a
uniquely addressable portion of a USB
device that is the source or sink of
information in a communication flow
between the host computer and
device. I like the “source or sink”
simile, for us hardware guys it makes
this easy to understand.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
51
Before any data exchange occurs,
the USB unit must be recognized and
enumerated. Because it comprises
hardware with controlling firmware,
assume that some initialization must
occur at the USB device and host lev-
els. To do this, a common device end-
point is defined and used.
This special endpoint is called the
control endpoint or endpoint zero and
is standard issue for every USB
device. This special endpoint is bidi-
rectional, uses its own control pipe,
and is used by the operating system
to find out all it can about the newly
discovered USB device. Enumeration
is the process of performing the inter-
rogation of the USB device. I’m not
going into the bits and pieces of enu-
meration but I will tell you that
when the operation is finished, the
host knows everything it needs to
know to successfully communicate
with the enumerated USB device.
I could go on and on about how
USB works and how many types of
transfers can occur. And, there are a
multitude of other technical items
tion of IN and/or OUT endpoints
constitutes a USB interface. You
also know that the USB interface is
controlled by an intelligent device
that is most likely running code to
move data between the interface
(device endpoints) and host. The
host is doing the same thing, run-
ning code to move host data and
commands via USB to the desired
device interface or endpoint.
The path used to move this data
and control information back and
forth between the host and device
endpoints is called a data pipe. At the
host end, a device driver sits at the
mouth of the data pipe and the USB
device interface has its mouth open
at the device end. As you know from
experience with Windows, the device
driver is a complex piece of software
designed to mediate peripheral prop-
erties and their datastreams with a
target host application or system
function. Using Windows, a simple
INF file can be used to form a rela-
tionship between a USB device inter-
face and Windows device driver.
A1
GND
B1
*PD0
C1
GND
A2
+5 V
B2
+5 V
C2
+5 V
A3
GND
B3
GND
C3
GND
A4
+24 V
B4
+24 V
C4
+24 V
A5
GND
B5
GND
C5
HSC5
A6
–12 V
B6
–12 V
C6
–12 V
A7
GND
B7
GND
C7
GND
A8
+12 V
B8
+12 V
C8
+12 V
A9
GND
B9
GND C9
GND
A10
Reserved
B10
Reserved
C10
Reserved
A11
FUNCT1
B11
FUNCT0
C11
*RESET
A12
FUNCT3
B12
FUNCT2
C12
*S1
A13
FUNCT5
B13
FUNCT4
C13
*S2
A14
FUNCT7
B14
FUNCT6
C14
*BUSY
A15
WDATA00
B15
RDATA00
C15
*LAM
A16
WDATA01
B16
RDATA01
C16
*X
A17
WDATA02
B17
RDATA02
C17
*Q
A18
WDATA03
B18
RDATA03
C18
CLK
A19
WDATA04
B19
RDATA04
C19
USR0
A20
WDATA05
B20
RDATA05
C20
USR1
A21
WDATA06
B21
RDATA06
C21
USR2
A22
WDATA07
B22
RDATA07
C22
Reserved
A23
WDATA08
B23
RDATA08
C23
Reserved
A24
WDATA09
B24
RDATA09
C24
Reserved
A25
WDATA10
B25
RDATA10
C25
Reserved
A26
WDATA11
B26
RDATA11
C26
Reserved
A27
WDATA12
B27
RDATA12
C27
Reserved
A28
WDATA13
B28
RDATA13
C28
Reserved
A29
WDATA14
B29
RDATA14
C29
GND
A30
WDATA15
B30
RDATA15
C30
GND
A31
SCL
B31
SDA
C31
GND
A32
GND
B32
*PD1
C32
GND
Table 1—
Here’s everything you need to know about interfacing USB and your project. The 96-pin DIN is a blessing
in that you can use a jumper to drive input pins and see the results immediately in the TMTest window.
like transmission modes, descriptor
tables, commands, error checking,
USB chip types, and device drivers.
However, I’m going to end my USB
technical discussion here because
there are books written by USB
experts like Jan Axelson on the mar-
ket for you to read. [1]
If you’re interested in inventing a
USB device from scratch, you should
read the USB specifications and study
the wealth of USB documentation
available on the Internet and in book-
stores. On the other hand, if you’re a
scientist, systems engineer, or design-
er who needs to add USB functionality
to an existing product, you can forget
about the downside and hazards of
developing USB devices and device
drivers from scratch.
EASY USB
Major manufacturers of USB silicon
have gone to great lengths to make
USB development less stressful. Data
Design took the bull by the horns and
put USB development within reach of
anyone who can do simple coding in
Visual Basic or C.
The Data Design TM1000 is a
peripheral instrument platform
designed around the AN2131QC, an
EZ-USB IC, by Cypress. The EZ-USB
is a unique USB engine in that it con-
tains no on-chip ROM for program
storage. Instead, the EZ-USB has built-
in USB enumeration smarts that allow
it to put the companion on-chip 8051
in reset while it gets some special boot-
strap code from the host. In a nutshell,
the EZ-USB electronics knows how to
respond to USB queries from the host
without microprocessor intervention.
After the designer-intended setup
code has been transferred from the
host to the EZ-USB RAM, the 8051
is released from reset and the host is
fooled into thinking a new device
has just entered the bus. Then, when
the enumeration process kicks off
again, the host receives the informa-
tion it downloaded to the USB unit.
Cypress calls this “reenumeration.”
This RAM-load process allows you to
update the firmware of the USB by
simply changing the code that is
downloaded to the EZ-USB IC during
startup. The EZ-USB IC also allows
DeviceId parameter. The best way to
show the simplicity of using the func-
tions within the
TMWIN32.DLL is to
explain the workings of each of the
frames in the TMTest panel window
you see in Photo 3.
When invoked,
TMTest searches for
available base units. In this case,
there is only one and it is called
DeviceId 1. The revision level of the
base unit is one. If more base units
were detected, the Next ID button
would scroll through them.
The status byte is a result of the
API function
TM_GetStatus. P1 and P0
are module presence detected bits.
To indicate its presence, the module
should ground these pins on the DIN
52
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
module identity become automatic
when system manager functionality
is exploited in your module code.
This frees you from having to write
code to identify modules, their asso-
ciated applications, and base units.
This feature also closes a DeviceId
(base unit identifier) and its associat-
ed application if power is removed
from that base unit.
An
include file for C is supplied
with the TM1000. Listing 1 is the
same API definition table translated
to VB call format. The first two
entries in the API table open and
close a communications path between
a base unit and host. Up to four base
units can be accessed using the
the operating code or startup parame-
ters to be loaded via I
2
C from an
external serial EEPROM.
The TM1000 base unit pictured in
Photos 1 and 2 is designed to replace
the cumbersome IRQ and I/O address
mechanisms used to communicate
with custom external instrumenta-
tion. Instead of relying on (and run-
ning out of) standard PC serial and
parallel ports or building special ISA
or PCI interface cards, the TM1000
allows the instrument to be designed
and attached using USB technology.
Here’s the kicker: You don’t have to
know anything about USB. All you
have to do is build your instrument
to interface with the 96-pin DIN con-
nector. The pinout for the 96-pin DIN
is shown in Table 1. The TM1000
base supplies power and provides pro-
tective circuitry for automatic hot-
swap and module-controlled hot-swap
operation at the DIN connector (the
module is the instrument connected
to the 96-pin DIN). The idea is to
assemble the module electronics on
the prototype board that mates to the
electronics of the USB base unit using
the 96-pin DIN connectors. The fan
shown in Photo 1 is there to help cool
your hot designs.
Just in case you don’t already have
a module ready to go, you can learn
about USB and TM1000 operation by
running the VB6 program
TMTest that
comes with the hardware. USB driver
development agony is relieved by an
API contained within a standard
Windows DLL, which supports the
TM1000 peripheral instrument plat-
form hardware. Looking again at
Photo 1, notice the spring-loaded
thumbscrews on the base unit’s right
side. This allows multiple base units
to be physically connected.
Another software tool included
with the package, the system manag-
er, keeps watch over each of the indi-
vidual base units. Use of the system
manager is not mandatory, however,
employing it in your software design
is a good idea if you plan to run a
complex set of modules and base
units. The system manager constant-
ly scans for modules and base units.
Many of the housekeeping chores
like environmental monitoring and
‘TM1000 API functions
Declare Function TM_OpenDevice Lib “tmwin32.dll” (ByVal aDeviceId
As Byte) As Long
Declare Function TM_CloseDevice Lib “tmwin32.dll” (ByVal
aDeviceId As Byte) As Long
Declare Function TM_RequestOwnership Lib “tmwin32.dll” (ByVal
aDeviceId As Byte) As Long
Declare Function TM_ReleaseOwnership Lib “tmwin32.dll” (ByVal
aDeviceId As Byte) As Long
Declare Function TM_QueryOwnership Lib “tmwin32.dll” (ByVal
aDeviceId As Byte) As Long
Declare Function TM_WriteWord Lib “tmwin32.dll” (ByVal aDeviceId
As Byte, ByVal aFunction As Byte, aData As Long) As Long
Declare Function TM_WriteBlock Lib “tmwin32.dll” (ByVal aDeviceId
As Byte, ByVal aFunction As Byte, ByVal aFlags As Byte, ByVal
aDataLength As Long, aData As Long) As Long
Declare Function TM_ReadWord Lib “tmwin32.dll” (ByVal aDeviceId
As Byte, ByVal aFunction As Byte, aData As Long) As Long
Declare Function TM_ReadBlock Lib “tmwin32.dll” (ByVal aDeviceId
As Byte, ByVal aFunction As Byte, ByVal aFlags As Byte, ByVal
aDataLength As Long, aData As Long) As Long
Declare Function TM_GetStatus Lib “tmwin32.dll” (ByVal aDeviceId
As Byte, aStatus As Byte) As Long
Declare Function TM_USRConfig Lib “tmwin32.dll” (ByVal aDeviceId
As Byte, aConfigValue As Byte) As Long
Declare Function TM_USRWrite Lib “tmwin32.dll” (ByVal aDeviceId
As Byte, aDataValue As Byte) As Long
Declare Function TM_USRRead Lib “tmwin32.dll” (ByVal aDeviceId As
Byte, aDataValue As Byte) As Long
Declare Function TM_GetBaseUnitRevisionLevel Lib “tmwin32.dll”
(ByVal aDeviceId As Byte) As Long
Declare Function TM_Identify Lib “tmwin32.dll” (ByVal aDeviceId
As Byte, ByVal aModel As String, ByVal aVendor As String, ByVal
aRevision As String, ByVal aDescription As String) As Long
Declare Function TM_ProgramModuleIdentity Lib “tmwin32.dll” (ByVal
aDeviceId As Byte, ByVal aModel As String, ByVal aVendor As
String, ByVal aRevision As String, ByVal aDescription As
String) As Long
Declare Function TM_ReadCalData Lib “tmwin32.dll” (ByVal
aDeviceId As Byte, CalData As Byte) As Long
Declare Function TM_ProgramCalData Lib “tmwin32.dll” (ByVal
aDeviceId As Byte, CalData As Byte) As Long
Listing 1—
Instead of trying to keep up with the bits and bytes of native USB operation, all you have to
know is how to call the functions to read, write, and query your USB-capable module using C, VB, or
LabView. The internals of USB become a black box when the API is used.
Fred Eady has more than 20 years of
experience as a systems engineer. He
has worked with computers and com-
munication systems large and small,
simple and complex. His forte is
embedded-systems design and com-
munications. Fred may be reached at
fred@edtp.com.
SOURCES
AN2131QC EZ-USB IC
Cypress Semiconductor Corp.
(408) 943-2600
Fax: (408) 943-6841
www.cypress.com
TM1000
Data Design Corp.
(301) 670-1157
Fax: (301) 926-6441
www.datadesigncorp.com
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
53
connector. If the attached module
temperature rises higher than 40°C,
the T bit is set. Likewise, if the
module decides it needs more cur-
rent than you intended, the over-
flow current (C) bit is set. Bits Q, X,
and B are signal bits that can be used
by the module’s application to deter-
mine the various states of the mod-
ule and its firmware.
The module identification frame
uses API calls to read and write to
the identity EEPROM, which is nor-
mally a 128-byte device, such as the
AT24C01. Listing 1 also states a
couple of API calls that are related
to calibration data. If your module
requires a place to store calibration
data, a 256-byte serial EEPROM can
house the data in the extra 128-byte
area. Using the TM1000 API and
TMTestPanel code in conjunction
with the system manager eliminates
the need to write any EEPROM iden-
tity firmware. “N/A”
in the text boxes indi-
cates no valid data was
found in the 128-byte
EEPROM identity area
(see Photo 3).
The bottom area of
the TMTest window is
dedicated to manipula-
tion of the module I/O.
There are three user
port I/Os that can be
set as input or output
and of course, be read
and written. The bit
indicators are updated
twice per second with
yellow representing one
and gray representing
zero. A one can be out-
put from this register
set by checking the
Out Driver and Out
Value boxes. Otherwise,
the user port inputs
are pulled up as indi-
cated by the yellow In
Value boxes.
What you don’t see in
the TMTest window is
eight outputs, FUNCT0
through FUNCT7, des-
ignated by the F text
box, 16 WDATA out-
puts, and 16 RDATA inputs that are
accessed using the read and write
command buttons.
The FUNCT bits are supposed to
be used as a command byte for the
module. Placing a hexadecimal value
in the F text box and clicking Write
will initiate an S1 cycle and place
the data in the F text box out on the
FUNCT pins. A hexadecimal word
entered in the R/W area can be writ-
ten to the WDATA pins by clicking
on the Write button. To read the
16-bit value of the RDATA pins, a
simple click on Read puts the word in
the R/W text box.
In a real-world module application,
block reads and writes can occur
for x number of bytes beginning at
address y. The
TMTest version of
the block operations is a simulation
of this process. You can find the
source code for
TMTest included with
the TM1000 hardware. The source
code implements all of the API func-
tions and may be used as a basis for
your application code.
PRACTICAL USB
USB…Yes, I’ve heard of it, written a
column about it, and found a way to
use it. My intent was to give you some
basic knowledge of USB and show you
an easy method of applying it using the
TM1000. What I haven’t shown you
is the little bugger in Photo 4. The
TM1000 bus module you see in the
photo is affectionately called the
TM1000 on a stick. The 96-pin DIN
connector on the base unit is replaced
by 72 pins of standard 0.1
″
headers.
The bus pinout is shown in Table 2.
Although the TM1000 is geared
toward providing an easily implement-
ed instrumentation interface to USB, I
like the idea that I can use the smaller
bus to add USB capability to anything
I can interface to the module I/O pins.
USB technology has been accepted in
the desktop world with open arms. And
now, the TM1000 has shown that USB
is indeed a practical replacement for
the legacy ISA architecture. The API
and PLD-assisted bus have proven that
USB isn’t complicated, it’s embedded.
I
Table 2—
The presence bits P0 and P1 are combined into a single PD pin
and the 24-V power pins are absent. The TM1000-BUS can be powered
externally or from the USB by tying the +5V_USB pin to the 5-V pins.
1
GND
72
+5 V
2
GND
71
+5 V
3
SCL
70
OVER_TEMP
4
SDA
69
*POWER_FAULT
5
+3.3 V
68
+5V_USB
6
FUNCT0
67
*PD
7
FUNCT1
66
*RESET
8
FUNCT2
65
*S1
9
FUNCT3
64
*S2
10
FUNCT4
63
*BUSY
11
FUNCT5
62
*LAM
12
FUNCT6
61
*X
13
FUNCT7
60
*Q
14
Reserved 59
CLK
15
Reserved 58
USR0
16
Reserved 57
USR1
17
Reserved 56
USR2
18
WDATA00
55
RDATA00
19
WDATA01
54
RDATA01
20
WDATA02
53
RDATA 02
21
WDATA03
52
RDATA03
22
WDATA04
51
RDATA04
23
WDATA05
50
RDATA05
24
WDATA06
49
RDATA06
25
WDATA07
48
RDATA07
26
WDATA08
47
RDATA08
27
WDATA09
46
RDATA09
28
WDATA10
45
RDATA10
29
WDATA11
44
RDATA11
30
WDATA12
43
RDATA12
31
WDATA13
42
RDATA13
32
WDATA14
41
RDATA14
33
WDATA15
40
RDATA15
34
GND
39
GND
35
GND
38
GND
36
GND
37
GND
RESOURCE
[1] J. Axelson, USB Complete, 2nd
ed., Lakeview Research,
Madison, WI, 2001.
54
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
our years ago,
while in the process
of moving back to
Poughkeepsie, we looked
at a house that suited just about all of
our needs. Except, alas, it was full of
stuff the previous owners decided they
didn’t want. So we made them a deal:
for a nominal service charge, we’d
take the place as is and clear it out.
Three 15-yd
3
trash containers, two
weeks, and a huge yard sale later, we
were done. One man’s trash being
another’s treasure, we skimmed a few
items from the waste stream. Memo
to self: Make the service charge a lit-
tle less nominal next time. But, the
deal worked out to my advantage any-
way. Among other basement treasures,
I found the gorgeous Astatic D-104
chrome lollipop crystal microphone
shown in Photo 1. The deal would
have been worth it for the mic alone!
The mic case is heavy, machined,
chrome-plated brass. In fact, the
removable head (the part above the
upper knurled ring) weighs 10 oz and
the cast-iron base brings the whole
affair to just under 3 lbs. There’s
absolutely no plastic here!
Although you’ll almost certainly
use electret mics in your new designs,
the problems posed by a crystal mic
remain relevant: high impedance,
wide bandwidth, and low noise.
Sound useful? Then read on.
CRYSTAL BASICS
Back in the bad old days, when
electronic equipment glowed in the
dark, crystal microphones were the
next new thing. They combined a
high output level with good frequency
response and low noise, and were
much better than carbon-granule
mics. The Astatic D-104, based on an
early 1930s design, became the stan-
dard mic for two generations of radio
amateurs and other audio fanatics.
However, it recalls the era when
vacuum-tube circuits imposed hun-
dreds of volts across megohm resis-
tors. The D-104 works best when
plugged into a high-impedance ampli-
fier like the grid of a mic amplifier
tube with a 10-M
Ω
bias resistor.
While vacuum tubes live on in high-
end audio, today’s transistor circuits
use voltages and resistances 99%
lower than the D-104 expects.
A crystal microphone converts sound
into voltage using the same piezoelec-
tric effect that governs quartz crystal
oscillators. A diaphragm in the mic
applies sound energy to a crystal, per-
haps through a mechanical linkage
that trades displacement for force.
Metal contacts deposited on opposite
faces of the crystal conduct the result-
ing voltage to the output cable.
The D-104 has a substantial output,
at least compared to an electret mic.
Holding it ~1
″
from the side of my
mouth and talking in a normal voice
produces a 200-mV
pp
signal. My plosive
bursts range up to 300 mV
pp
, although
more forceful speakers may outdo that.
The original D-104 design used a
Rochelle salt crystal as the piezoelec-
tric element. Rochelle salt has a volt-
age-to-mechanical strain ratio roughly
one order of magnitude higher than
quartz, which makes it an ideal choice
for a sensitive microphone. Unlike
quartz, however, Rochelle salt dis-
solves in water, which makes it a ter-
rible choice for outdoor events and
high-humidity locations.
Piezoelectric mics built since about
1960 use PZT (lead zirconate titanate)
ceramic elements that won’t melt in
When you accept
anything as is, it’s
always a gamble.
Luckily for Ed, his
gamble payed out
and it meant finding a
true treasure among
the trash. His find: an
Astatic D-104 chrome
crystal microphone.
Check out the circuit
exercise that followed
the finding.
Ed Nisley
Learning from the Past
f
A Look at a Chrome Lollipop
ABOVE THE
GROUND
PLANE
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
55
the rain and have roughly the same
sensitivity. My D-104 doesn’t have a
manufacturing date, so I have no way
to identify the material within it. The
microphone has been either well
cared for or has a ceramic element.
The equivalent circuit for a crystal
mic element has an AC voltage
source in series with a small capaci-
tor, which makes the frequency
response depend on both the mechan-
ical design of the mic and the input
impedance of the amplifier. The
equivalent series capacitance is on the
order of 1 nF, which, at 100 Hz, looks
like a 1.6-M
Ω
resistor.
You can see why simply plugging
the mic into a contemporary radio’s
600-
Ω
input won’t work. As a rule of
thumb, a voltage amplifier should
have an input impedance about an
order of magnitude higher than the
source’s output impedance. The rules
for power amplifiers are different, but
we’re not working in that domain.
As you troll the Web, you’ll find a
wide variety of D-104 interface cir-
cuits, ranging from single-FET buffers
to op-amps. In most cases, their input
resistance is far too low or their cir-
cuit topology doesn’t take advantage
of the properties of the D-104. So,
let’s move on and see what a different
solution looks like.
IT TAKES TWO
Unlike the electret mics I intro-
duced last time, a crystal mic requires
no power supply. As a result, its out-
put has no DC component and does-
n’t require a connection to a common
circuit. Although you could ground
one side, it makes more sense to use
an amplifier that converts the mic’s
isolated voltage into a single-ended
signal referred to ground. With no
ground connection, there’s no risk of
hum or RF injection from an inadver-
tent ground loop.
The differential op-amp circuit
illustrated in Figure 1a approaches
this ideal. The ratio R2/R1 deter-
mines the voltage gain, so a quartet of
matched resistors produces a unity-
gain differential amplifier.
The output of a differential amplifi-
er should not depend on the common-
mode voltage present at both inputs.
For example, if you have 2.1 V at IN+
and 2.0 V at IN–, the output should
be 0.1 V. Changing the inputs to
–0.9 and –1.0 V won’t change the out-
put voltage as long as those inputs are
within the common-mode voltage
range of the op-amp.
A differential amplifier’s ability to
reject common-mode voltages is
measured by its common-mode rejec-
tion ratio expressed in decibels. A
100-dB CMRR implies that shifting
both input voltages in unison will
produce an output change of 100 dB
lower (10 µV for a 1-V input shift).
Remember that unless you’re told dif-
ferently, measurements given in decibels
imply power ratios not voltage ratios.
Now, delivering the raw CMRR rat-
ing of an op-amp to the rest of the cir-
cuit depends on perfect matching
between those two resistor pairs. I’ll
let you figure out how much mis-
match will reduce a 100-dB CMRR to
94 dB (for voltage, that’s a factor of
two). Hint: Include source resistance
and its variations, too, for the case
where the input isn’t a pure differen-
tial mic element.
If your circuit will handle moder-
ately high frequencies, your CMRR
calculations must also take into
account the capacitance presented by
the op-amp’s inputs and any parasitic
effects. Fortunately, at audio frequen-
cies, a few picofarads one way or the
other do not make much difference.
The D-104 microphone presents no
inherent common-mode voltage and,
given its conductive armor, heavy
grill, and short wiring, I doubt if any-
thing electrical can get through to the
mic element or wiring. For mics
located remotely from their ampli-
fiers, however, power-line hum rejec-
tion becomes critical and you’ll need
as much CMRR as you can get.
The amplifier’s input resistance
poses another, more critical, problem
for this application. The differential
resistance between the two input ter-
minals is essentially 2 × R1, because
the feedback network of the op-amp
holds its input terminals at the same
voltage. If you want both high input
resistance and decent CMRR, you def-
initely need to have well-matched,
high-value resistors.
Figure 1b shows another way to
achieve that goal, with three op-amps
forming what’s called an instrumenta-
tion amplifier. The two noninverting
op-amp inputs have essentially infi-
nite DC input resistance and low
capacitance. A single resistor, RG,
sets the overall gain and can be omit-
ted for unity gain. The REF input sets
the DC output level.
You can hammer out an instrumen-
tation amp from a trio of op-amps, a
handful of matched resistors, and a
square centimeter of board space or
purchase them as single ICs from
Maxim, TI, Analog Devices, and oth-
ers. Integration on a single die pro-
vides well-matched resistors, balanced
circuitry, and performance you’d be
hard-pressed to achieve on your own.
In normal use instrumentation,
amplifiers extract millivolt differen-
tial signals from many-volt DC (at
least 3 VDC) biases. You’ll find them
applied to strain gauge bridges, ther-
mocouples, and other applications
that demand very high common-mode
rejection and moderate bandwidth.
A crystal mic demands exceedingly
high input resistance and, depending
on the cable length, high CMRR. The
Photo 1—
In person, it’s easy to see why Astatic D-
104 crystal microphones are known as “chrome lol-
lipops,” but how do you photograph a mirror? Some D-
104s have a fancy grip-to-talk lever along the stem but
mine has only a simple push button.
56
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
latter, as I’m sure
you know, is not
vital for this D-104
amplifier, but it
doesn’t hurt. I
picked a Maxim
MAX4195ESA
unity-gain instru-
mentation amplifi-
er in an 8-pin SOIC package.
SMALL PARTS
The schematic in Figure 2 and the
board in Photo 2 show the circuitry
required to make it work. I’ll leave
the details of the push-to-talk circuit-
ry and mechanics required to stuff the
hardware into the cast-iron micro-
phone base to your imagination. You
can download the complete schematic
and board layout files from the
Circuit Cellar
web site.
The MAX4195 can’t drive a capaci-
tive load well, therefore I added a
MAX4322 buffer to isolate it from the
cable. You may choose R8 and R9 to
attenuate the signal or add R11 to
amplify it. C7 and C9 block the DC
paths so the attenuation and amplifi-
cation apply only to the signal. My
radios expected less audio than the
D-104 produces, so the values shown
knock it back by 10 dB.
Although it would be nice to sim-
ply hitch the mic element to the
inputs of the MAX4195, it won’t
work that way. All op-amps require a
DC path from each input to conduct
the bias current. Even vacuum tubes
have bias current; remember that grid
resistor? Although contemporary op-
amps have bias current in the nano-
to pico-amp range, you cannot allow
the inputs to float.
Generally, the strain gauge bridge or
other sensor provides a low-imped-
ance DC path to common. When you
use isolated sensors or transducers,
you must add components that don’t
seem necessary and, worse, don’t
appear in the usual application notes.
Watch out for this
error on the Internet
in particular!
R5 and R6, both
10-M
Ω
resistors,
carry the 20-nA max-
imum bias current of
the MAX4195.
Simple multiplica-
tion tells you that
20 nA through
Figure 1a—
The input resist-
ance of a differential amp is
limited by the gain-setting
resistors.
b—
An instrumenta-
tion amplifier uses three op-
amps to achieve nearly infinite
input resistance and CMRR.
a)
b)
Photo 2—
The two 10-M
Ω
SMD resistors to the left of
the MAX4195 handle its
~3-nA amplifier bias current
while maintaining a high
input impedance. Clean the
board thoroughly to remove
soldering flux and prevent
current leakage.
58
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
10 M
Ω
produces 200 mV. The differ-
ential bias current won’t exceed 3 nA,
which means the offset voltage will
be less than 30 mV. Of course, that’s
if the two resistors match. I hand-
selected two resistors to 0.1%, which
was the limit of my meter, and
brought the offset voltage under 1 mV.
The result was close enough.
Other amps in the MAX4195 family
have voltage gains up to 100 that
amplify any input offset accordingly.
Consider, for example, an input offset
of 30 mV and a gain of 100 on an op-
amp with a 5-V power supply.
R5 and R6 also reduce the amplifi-
er’s differential input resistance to
20 M
Ω
, which is still high enough for
the D-104. Note that you need only
two resistors rather than the four
required by a conventional differential
amplifier. And, these resistors are not
in the direct signal path.
High-value resistors raise the issue
of noise. Johnson noise, which is inde-
pendent of the resistor’s construction,
varies as the square root of both
resistance and bandwidth:
where k is Boltzmann’s constant, T is
the absolute temperature in kelvin, R
is the resistance in ohms, and B the
bandwidth in hertz. At room tempera-
ture, you have:
Thus, a 10-M
Ω
resistor produces
40 µV
RMS
of noise in a 10-kHz band-
width, roughly 60 dB below the output
of the D-104. Depending on your appli-
cation, that can be a lot or a little.
Shot and flicker noise are also pres-
ent, but the Johnson noise from high-
value resistors tends to swamp their
effects. The MAX4195 specifications
include its input-referred noise per-
formance, which I have evaluated at a
10-kHz bandwidth. The noise voltage,
about 7 µV
RMS
, is low compared to the
Johnson resistor noise. The 50-pA
noise current of the amplifier, howev-
er, produces 500 µV
RMS
through those
10-M
Ω
resistors. Their RMS sum is
only 40 dB below the audio signal of
the microphone.
I also checked out the bandwidth
using an audio transformer feeding the
inputs through a pair of 2-nF caps. The
response turned out to be flat at least
from 20 Hz to 35 kHz, which are the
limits of the transformer. That’s much
wider than the D-104 needs and allows
more noise, but it will be chopped
down by the radio’s input circuitry.
Keep in mind, the combination of
wide bandwidth, high input imped-
ance, high CMRR, high gain, and low
noise remains difficult to achieve,
even with integrated amplifiers. The
design I present in this article suf-
fices for communication-grade audio,
but may be inadequate for instrumen-
tation-grade applications.
POWER ON
This microphone will feed a desk-
top radio, which typically has a DC
supply voltage on a mic connector
Figure 2—
The MAX4175 instrumentation amp converts the differential mic signal into a single-ended voltage. The MAX4322 buffer drives the mic cable to the radio. Choosing
R8 through R11 appropriately can either attenuate or amplify the audio signal as needed to suit the input of the radio. The pin numbers correspond to a Yaesu FT-747GX
radio. The TPS7701 produces 4.75 V for the op-amps. The TLE2426 splits that in half to set the MAX4175 DC output level and R3 and R4 bias its inputs slightly below V
CC
/2.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
59
SOFTWARE
The schematic and board files are
available on the Circuit Cellar web
site.
Ed Nisley, PE, is an electrical engi-
neer. He also is a ham radio operator
(call sign KE4ZNU). You may reach
him at ed.nisley@ieee.org.
SOURCES
D-104 crystal microphone
Astatic Corp.
(800) 421-3161
Fax: (440) 593-5395
www.astatic.com
MAX4195ESA
Maxim Integrated Products
(408) 737-7600
Fax: (408) 737-7194
www.maxim-ic.com
TLE2426, TPS7701
Texas Instruments, Inc.
(800) 336-5236
www.ti.com
Eight-band audio equalizer
W2IHY Technologies
(877) 739-2449
(845) 889-4933
www.w2ihy.com
FT-767GX
Yaesu/Vertex Standard
(562) 404-2700
(562) 404-4828
www.yaesu.com
pin. Unfortunately, each radio manu-
facturer provides a different voltage
on a different pin, so I’ll leave you to
figure out how yours works. The
power supply circuitry regulates the
radio’s supply down to 4.75 V, then
splits that in half to bias the output of
the MAX4195 to the middle of the
supply range through its REF input
pin (see Figure 2).
The input voltages of the MAX4195
must be no less than 200 mV greater
than the negative supply and no more
then 1.1 V less than the positive sup-
ply. Setting the common-mode level
to the midpoint of that range (1.93 V)
provides the maximum differential
voltage range. R3 and R4 generate
the maximum differential voltage,
which the MAX4195 sees through the
10-M
Ω
bias resistors.
This situation seems typical of ana-
log circuitry in general. The ICs may
run from a single power supply, but
the circuitry also demands several DC
bias voltages. The TLE2426 is a ves-
tigial remnant of a previous, more
complex, design; you may replace it
with a resistive divider.
With everything soldered and
tucked into the mic’s base, I connect-
ed the cable to my Yaesu FT-767GX,
ran the transmitter output to a
dummy load, and listened on another
radio. It sounded terrible.
CONTACT RELEASE
As it turns out, that unique sound
is perfectly normal for a D-104, a
microphone that features what
Astatic calls “super talk-power.” In
plain English, that means the compa-
ny tailored its frequency response for
clear speech communication with no
regard for overall fidelity.
The mic’s response ranges from
about 200 Hz to 4 kHz, dropping off
abruptly beyond those limits. There’s
a pronounced, nearly 10-dB, peak
around 3 kHz that emphasizes the fre-
quencies most important for under-
standing speech. The flat response
you expect from general-purpose
microphones like electrets is conspic-
uously absent.
Although it doesn’t sound natural,
the D-104 remains a fine microphone
for single-sideband (SSB) radio com-
munication and, combined with an
instrumentation amplifier to extract
the full range of its output, serves as
an interesting circuit exercise.
If you’re concerned about your
mic’s sound, an 8-band audio equaliz-
er from W2IHY Technologies can
make any microphone sound better.
The company’s web site contains sev-
eral before-and-after audio clips that
demonstrate what an equalizer can
do. I’ve known the owner for a while,
and he does nice analog work.
I have one final note for you.
Although many radios use a circular
8-pin mic connector, remember that
each manufacturer has a unique
pinout and those familiar 8-pin DIN
connectors won’t fit.
I
60
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
ave you ever
missed your bus
because you’ve been a
few minutes late? Ever
wondered, is it hot in here or is it me?
Needless to say, two of the most use-
ful pieces of information to have on a
regular basis are time and tempera-
ture. Because we like to have this
data readily available, a battery-pow-
ered, portable device that can display
this information is a logical choice.
When designing such a device, any
engineer worth his cells tries to
extend the battery life as much as
possible. In this article, I’ll explain
how to build a circuit that maximizes
battery life and uses single-slope ana-
log conversion to measure a sensor.
This is achieved using an ultralow-
power microcontroller, which opti-
mizes standby modes.
The only external component needed
for the timebase of the circuit is an
inexpensive 32-kHz crystal, like those
used in most electronic watches. The
MCU uses the stable frequency from
the crystal to increment a counter.
The counter generates an interrupt
once per second and increments even
while the MCU is in Ultralow Power
mode three (<2 µA). After it’s inter-
rupted, the MCU switches to Active
FEATURE
ARTICLE
Do you have the time
and temperature? Ah,
the most often asked
questions. Well, how
about a battery-pow-
ered portable device
that displays both
measurements using
single-slope conver-
sion? Armed with this
this unit, you’re pre-
pared for small talk
anytime, anywhere.
mode and runs off an internal, high-
speed, digitally controlled oscillator.
While in Active mode, the software
updates the real-time clock and meas-
ures the temperature if the circuit is
in Temperature mode.
The temperature sensor used is a
simple thermistor that is measured
using the single-slope analog conver-
sion method. The slope method dis-
charges a capacitor through a known
resistor and the thermistor, and
records time required do each. The
resistance of the thermistor, and
therefore the temperature, can be
determined from a simple calculation.
Two switches provide user control.
The first switch allows you to select
one of four modes—Time, Seconds,
Temperature, or Set Point. These
modes determine what is displayed on
the LCD. The second switch allows
you to set the correct time or adjust
the temperature set point, which is
automatically stored in flash memory.
A four and a half-digit, seven-seg-
ment LCD displays the time, seconds,
temperature, or set point. A dedicated
MCU module that constantly displays
data (even if the MCU is in Ultralow
Power Standby mode) directly drives
the LCD. This is possible because the
LCD of the MCU runs independently
of the CPU and is clocked by the 32-
kHz crystal that remains active.
All of this functionality is accom-
plished using the Texas Instruments
MSP430F413 microcontroller and a
small number of external compo-
nents. While operating with the
LCD on, the entire circuit averages
less than 7 µA in Time, Seconds, or
Set Point mode, and less than 10 µA
in Temperature mode.
HARDWARE
The MSP430 line of microcon-
trollers is relatively new on the
microcontroller scene. The product
line consists of a variety of code-com-
patible, 16-bit, RISC-like MCUs with
a variety of peripheral and memory
options. The major differentiating fac-
tor of these controllers is their bot-
tom-up design that maximizes
ultralow-power operation. Key aspects
of the design are ultralow operating
currents, peripherals that can run
Brian Merritt
Telling Time and
Temperature
h
Building an All-Purpose Portable Device
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
61
with the CPU off, and the ability to
jump in and out of ultralow-power
standby modes in less than 6 µs.
The time and temperature func-
tions can be implemented on any
member of the MSP430 product line. I
chose the MSP430F413 from the vari-
ous flash memory, OTP, and ROM
options in the product line because of
its ability to write its own flash mem-
ory. As a result, the circuit is able to
store and retain the temperature set
point even if power is removed. In
addition, the slope conversion tech-
nique is straightforward when imple-
mented using the Comparator A mod-
ule of the device, because that module
was designed with slope conversion in
mind. The ’F413 also includes a built-
in LCD driver that can support up to
96 display segments.
The entire circuit is implemented
without using many parts, as you can
see in Figure 1. Three components are
used for the temperature measure-
ment (I’ll come back to this later).
And, six additional resistors are used:
three for the LCD voltage divider, two
for pull-ups on the switches, and one
to pull-up the reset line. A capacitor
debounces one of the switches and a
single 32-kHz watch crystal provides
the time base for the real-time clock
and can provide a reference for the
internal high-speed oscillator.
The display I used is a three-multi-
plex-rate Varitronix LCD. The MSP430
can drive static, two-mux, and four-
mux rate LCDs, as well. The whole
circuit is powered from a single 3-V,
190-mAh coin cell battery, which is
projected to last for more than two
years with the circuit in continuous
use. The simplicity of the circuit
allowed the prototype to be construct-
ed on a two-sided PCB, with all of the
components easily fitting on the top-
side of the board (see Photo 1).
SINGLE-SLOPE CONVERSION
So, what’s this slope-analog conver-
sion technique? In this implementa-
tion, single-slope conversion refers to
a method that relies on the discharge
time of a capacitor through different
resistors. One resistor is a fixed 10-k
Ω
reference resistor. The capacitor is
first charged to the logic high of an
output then discharged through this
known resistance. While discharging,
the counter in the Timer A module of
the MSP430 is incremented and the
device is placed in Low Power mode
zero. When the voltage on the capaci-
tor drops below an internal reference
voltage of the comparator, an inter-
rupt occurs, the counter is stopped,
and the time to discharge the capaci-
tor through the known resistor is
recorded (see Figure 2).
The next step is to repeat this
process but this time discharge the
capacitor through the unknown
resistor of the thermistor. When
both steps are complete, the dis-
charge times for the two resistive
paths are known. Because the value
of the capacitor and the voltages the
capacitor was charged to remained
the same for both steps, the expo-
nential equation to determine the
value of the resistive sensor conve-
niently reduces to:
[1]
The next logical question is how
many bits of resolution can be
obtained from this type of technique?
The level of resolution is dependent
on how fast the capacitor is dis-
charged and how fast the clock,
which increments the counter, is
running. As the value of the capaci-
tor and/or resistors rise, so does the
time required to discharge the capaci-
tor. Because the nominal value of a
resistive sensor is often based on
other requirements, it’s more practical
to vary the value of the capacitor. The
following equations can be used to
estimate the resolution:
t
convert
≅
5 × C × R
sensor
[2]
2
n
≅
t
convert
× f
counter
[3]
where n is the bits of resolution.
When you calculate using these
equations, the example circuit yields
about 10 bits of resolution.
As many as 16 bits can be obtained
using the single-slope technique. Of
course, the conversion time increases
as the number of bits increases. To
minimize noise and power required
during the conversions, you can turn
off the CPU, leaving the internal
high-speed oscillator running to incre-
ment the counter. The interrupt gen-
erated by crossing the internal refer-
Figure 1—
The MSP430F41x microcontroller is the heart of the design. The project requires only a few external
components. The LCD is directly driven by the MSP430, which maintains the display.
62
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
the software branches to the appropri-
ate routine depending on which
mode the circuit is currently in.
In either of the clock modes, the
current time or seconds are dis-
played on the LCD. If the circuit is in
Temperature mode, a measurement of
the thermistor is taken, a conversion
to degrees Fahrenheit is performed,
and the result is displayed on the
LCD. In Set Point mode, the current
set point is displayed and can be
updated using the set switch.
The Basic Timer (BT) module,
which is clocked by the 32-kHz crys-
tal, generates the 1-s interrupt. The
BT module is also programmed to
continuously send out the required
framing frequency for the LCD. The
ISR for the BT module first updates
the clock, then it changes the status
register that was pushed to the stack
just before the MSP430 went into
Low Power mode. By changing the
status register value stored on the
stack, the processor returns to the
main program in Active mode after
the interrupt routine is completed.
When the software returns from the
ISR, it checks a CPU register to deter-
mine which mode the circuit is cur-
rently in. A branch to the appropriate
software routine is then performed
based on the value in the register.
If the program branches to the time
routine, the current hours and min-
utes are retrieved from the RAM loca-
tions where they are stored. The LCD
is then cleared, and a routine to dis-
play the time is initiated. When the
LCD is updated, the code returns to
the main loop and the system reverts
back to Low Power mode three.
During the next 1-s interrupt, the
main loop checks to see if the system
is still in Time mode. If so, the rou-
tine is repeated. In Time mode, the
display appears to be simply display-
ing the time, however, the period
between the hours and minutes
blinks as an indication that the clock
is running. The current time setting
can be updated via the set switch only
while the circuit is in Time mode.
When the program switches to
Seconds mode, the software works
similarly to when it’s in Time mode.
The current seconds count is
retrieved from its corresponding RAM
location and displayed on the LCD.
During each 1-s interrupt, the RAM
location that stores seconds is updat-
ed and the new count is displayed.
When the program is in Temperature
mode, the software required is more
involved. The code first initiates a
measurement routine to charge the
capacitor while the MCU is in Low
Power mode zero. After a preset
amount of time for the capacitor to
charge, the MCU becomes active again
ence voltage of the comparator brings
the CPU out of standby in less than 6 µs
to process the acquired data
.
SOFTWARE
The normal operating mode of the
CPU in this application is Low Power
mode three, in which it spends most
of its time. The CPU is brought back
to Active mode, running off the high-
speed oscillator, by a periodic 1-s
interrupt. During the interrupt, the
real-time clock is updated, and then
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
63
and the Timer A and Comparator A
configurations are changed to dis-
charge the capacitor through the refer-
ence resistor or thermistor.
When discharging begins, the
counter in Timer A begins counting
and the CPU is switched off to further
conserve power. When the voltage
level on the capacitor drops below the
internal reference voltage, the counter
value is automatically captured by the
Timer A hardware and an interrupt is
generated. The interrupt routine
clears the CPU Off bit of the status
register that was pushed to the stack.
By doing so the processor comes out
of the ISR in Active mode. After both
counts are acquired, the thermistor
value is calculated using Equation 1.
The measured value of the thermis-
tor is then compared against a table of
values stored in memory. As the pro-
gram moves down the table, a register
is decremented one count at a time
starting from 99. When a match is
made, the temperature is equivalent
to the value remaining in the register.
For example, if the twenty-ninth table
entry matches the measured value,
the temperature is 70° (99 – 29 = 70).
A look-up scheme is used in this
application for several reasons.
Because the change in resistance of
the thermistor isn’t linear across tem-
perature, the look-up table is an easy
way to convert the calculated resist-
ance directly to a corresponding tem-
perature. Also, the MSP430 is able to
access table data stored anywhere in
its memory, so the table can be
included in the program and the
members addressed directly using the
table’s name as a relative address. A
final reason is that the instruction set
and addressing modes of the MSP430
make it easy and efficient to deal
with tabular data.
The temperature resulting from the
table look-up is then converted to
binary coded decimal for display on
the LCD. A routine is then called to
display the degree sign and the letter
“F.” Next, the BCD temperature val-
ues are displayed.
Temperature mode has some addi-
tional features to consider. The degree
sign toggles on and off with each 1-s
interrupt to indicate that measure-
ments are being made, even if the
temperature reading isn’t changing.
And, the software will automatically
revert back to Time mode after 20 s
to conserve power. A third feature is
that the whole display will flash on
and off every second if the tempera-
ture is at or above the current set
point to indicate a high-temperature
condition. All of these features are
part of the software so they can be
modified or deleted as desired.
When the circuit is in Set Point
mode, the current set point is dis-
played and you are able to update it.
The value is stored in flash memory
in order to retain the set point even if
the circuit is powered off. The 256 bytes
designated as information memory are
used for this purpose. The informa-
tion flash memory in MSP430 devices
always starts at address 1000 hex for
compatibility among devices, but all
flash memory on the parts functions
the same way. As a result, you may
use the information memory to hold
the program and the main flash mem-
ory for data (or they can contain any
combination of the two).
A memory pointer is maintained to
track the set point location in flash
memory. Each time Set Point mode is
exited, the software checks to see if
the set point has been updated. If it
has been updated, the program first
checks to see if the pointer is at the
end of the information memory seg-
ments. If it is at the end, the seg-
Photo 1—
The prototype circuit illustrates the low parts
count and the direct connection between the MSP430
and external components. The connector allows in-cir-
cuit debugging and programming via JTAG.
64
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
ments are erased and the
pointer is reset to the begin-
ning of information memory.
After they’re erased or if the
pointer isn’t at the end of the
segments, the pointer is
incremented and the new set
point is written to flash mem-
ory. By using all 256 bytes of
the information memory, which
can be written and erased
10,000 times at 25°C, the set
point may be changed more
than two million times before
any flash memory errors occur.
If the circuit isn’t powered
up, the software is able to
determine the last set-point
value when power is applied again.
The last set point is found by quickly
incrementing through the information
memory and testing the values of the
contents. Because the data is written
starting at the lowest address and the
flash memory bytes erase to all ones
(FF hex), the first information memo-
ry location to contain this value was
the first unused memory location just
clock setting from being
inadvertently changed while
in other modes.
When the circuit is in
Time mode and the switch
is pressed, the ISR for the
associated I/O pin initiates a
250-ms interval timer using
the watchdog module config-
ured in Timer mode. The
clock setting is increased by
1 min. when the watchdog
timer interrupt occurs. As
long as the switch is pressed,
the ISR will continue to
increment the minutes/hours
at a rate of four times per
second until the desired set-
ting is displayed. When in Set Point
mode, the set point is incremented 1°
at a time. At 99° the set point is reset
to 32 and increments from there.
The second push-button switch
changes the operating mode of the cir-
cuit. Each time the mode switch is
pressed, the ISR checks to make sure
the LCD is on (just in case it was
flashing), then it increments the CPU
before the circuit was powered off.
The value in the location just prior to
it is the last set point and the memo-
ry pointer is set to that location.
The user input to the circuit is
accomplished using two push-button
switches. The set switch adjusts the
time and set point. It actually works
only if the circuit is in Time or Set
Point mode. This rule prevents the
0
0
V
Voltage
Time
tt
charge
tttt
reference
tt
charge
tt
sense
V
ref
CC
Figure 2—
The capacitor for the slope ADC is charged to near V
CC
twice and
then discharged—once through the reference resistor and once through the
resistive sensor (thermistor). The sensor reading is determined from the refer-
ence resistor value and the two discharge times.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
65
RESOURCES
L. Bierl “MSP430 Application
Report Book,” SLAA024, Texas
Instruments, Inc., 2000.
Texas Instruments, Inc.
“MSP430F41 x Mixed Signal
Microcontroller,”
SLAS340A, May 2001.
Texas Instruments, Inc.
“MSP430 x4xx Family User’s
Guide,” SLAU056, May 2001.
SOURCES
MSP430F413, MSP-FET430P410
Texas Instruments, Inc.
(972) 995-2011
Fax: (972) 995-4360
www.ti.com
LCD
Varitronix International Ltd.
(852) 2197-6000
Fax: (852) 2343-9555
www.varitronix.com
Brian Merritt currently works for
Texas Instruments. His interests
include embedded control, robotics,
and electrical lighting display tech-
nologies. You may reach him at
b-merritt@ti.com.
SOFTWARE
The code is available on the Circuit
Cellar
register that is used to indicate the
mode. When the return from the ISR
is performed, the main loop sees that
the mode has been changed and exe-
cutes the appropriate routines.
PROGRAMMING
I used the MSP430F41x flash mem-
ory emulation tool (MSP-
FET430P410) to develop and debug
the code and program the device.
Optionally, you can use the MSP430
serial programmer (MSP-PRGS430) to
program the parts. Both tools use the
JTAG standard to communicate with
and program any of the MSP430 OTP,
flash memory, and EPROM devices.
The programming can be done in a
stand-alone socket, on the FET target
board, or in circuit via the JTAG con-
nections. Third-party programmers
and distributor programming services
are also available.
BUILDING ON THIS
This circuit and software use only
a small fraction of the MSP430’s
resources. The processor is in Standby
mode more that 99% of the time and
less than 1.5 KB of the 8 KB of avail-
able memory on the MCU is used.
Numerous I/O pins are unused as
well as two more capture compare
registers of Timer A and an additional
input to the Comparator A module.
It isn’t difficult to imagine how the
circuit and software could be expand-
ed to take extra measurements and
perform other functions in addition to
those presented here. Or you could
easily modify the circuit and software
to build a low-power thermostat or
data logger. Another possible option is
incorporating the temperature, time,
and flash memory write functions
into other designs whose main pur-
pose is something totally different but
would benefit from having these fea-
tures easily built-in.
I
Call 530-297-6073 Fax 530-297-6074
See our new site www.jkmicro.com
DOS & Web server pre-installed
Realtime multitasking available with eRTOS
In-Circuit-Programmable Xilinx CPLD
512K SRAM, 512K Flash standard
Many expansion board combinations
AD422 (Requires 9VDC) $79.00
AD422-1 for 110VAC
ADA485 (requires 9VDC) $79.00
ADA485-1 for 110VAC
CMC’s low cost converters adapt any
use with RS422 or RS485
devices
• Adds multidrop capability to
ADA425 (requires 9VDC) $89.00
ADA425-1 for 110VAC 99.00
Mention this ad when you order and deduct 5%
Use Visa, Mastercard or company purchase order
WWW.2CMC.COM Fax:(203)775-4595
PO BOX 186, Brookfield,CT 06804
Connecticut microComputer, Inc.
66
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
emember when
mom used to stick
that glass rod ther-
mometer under your
tongue and you had to keep your
mouth shut for what seemed like
hours? As a parent, I’ve had the pleas-
ure of using this torture stick on my
kids as well. I always have difficulty
reading that thing, twisting the shaft
in the light until the ribbon-thin
blade of mercury becomes visible. You
need to get just the right angle to be
able to see both the mercurous point-
er and the calibrated scale’s digits.
Think back to two months ago
when I introduced the MSP430F1121’s
comparator to measure sensor data.
Last month I showed you how to con-
trol the ISD4002 solid-state recorder
in a memory management scheme.
We’ve finally reached the point when
you can incorporate both of these into
a single project (see Photo 1). Using a
replaceable thermistor as the sensor,
you can measure temperature and
report it without the need for inter-
preting the expansion of mercury.
THERMISTOR
The thermistor, or thermal resistor,
is a ceramic semiconductor made
from transition metals that exhibits
either a large positive temperature
coefficient (PTC) or negative tempera-
ture coefficient (NTC). This semicon-
ductor property normally causes grief
when you’re creating temperature-sta-
ble circuits. Here, you use this proper-
ty to your benefit.
Resistance and temperature coeffi-
cients can be modified by carefully
controlling the combination of differ-
ent metal oxides and how they are
sintered (i.e., heated to just below
melting). Although thermistors can be
manufactured in many shapes, the
bead type is the most common.
Protective coatings, especially her-
metically sealed glass, allow the ther-
mistor to be used in extreme tempera-
ture applications.
The small physical size of the bead-
type NTC thermistors allows for fast
response time and low cost. Their rel-
atively high resistance eliminates the
lead resistance as a concern. Although
the temperature coefficient is nonlin-
ear over the usable range, thermistors
are sensitive, stable, and accurate.
The thermal properties of a ther-
mistor are similar to that of any resis-
tive load. Any current running
through the device will dissipate
power as heat. When trying to meas-
ure an ambient temperature, any sig-
nificant thermistor self-heating will
affect the sensor’s analysis of ambient
temperature. Needless to say, it is
important to keep self-heating to a
minimum or negligible level.
[1]
Because these thermal properties
look like a change in ambient temper-
ature, they directly affect the resistive
value of a thermistor. A change in
resistive value affects the current
through the device. This change in
current will affect the power dissipa-
tion, and thus the self-heating. And so
it goes, until an equilibrium is
reached where the self-heating equals
the heat dissipation.
The self-heating cycle of thermis-
tors can be used in circuits to limit
current or provide overload protec-
tion. The delay, or self-heating cycle,
and maximum currents are controlled
Jeff Bachiochi
A New Thermometer
r
FROM THE
BENCH
Two
months,
two proj-
ects.
Now
you can
combine them as one
using a replaceable
thermistor as a sen-
sor. Perhaps auditory
input from our appli-
ances will be neces-
sary someday.
Replacing Mercury with a Thermistor
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
67
through the physical properties in the
manufacturing process and generally
require physically larger thermistors.
The self-heating mode may be used
in situations where you might wish to
sense the flow of a gas or liquid.
When the thermistor has reached a
state of equilibrium (at a
set temperature above
ambient), the flow materi-
al by the thermistor alters
the thermistor circuit’s
dissipation factor. The sen-
sor’s value changes as the
thermistor loses or gains
heat as a result of the
change in the dissipation
constant, and therefore
varies with the flow rate.
This project measures
temperature directly, so
you want the self-heating
to be negligible. Even so,
the nonlinear temperature
coefficient of thermistors
must be compensated for
usually. When used with a
microprocessor, a thermis-
tor’s (nonlinear) value can
be corrected (linearized)
using a look-up table. (I
won’t get into the ways to
improve linearity outside
of the micro here.)
CANDY STORE
I chose to limit my thermistor
selection to only what is available
through Digi-Key. Digi-Key consider-
ately gives manufacturers’ part num-
bers and its own, which makes it easy
to be able to go to a web site for more
information. Although a few devices
were listed touting 1% accuracy, at
100°F that’s a whole degree (not what
I’d like to see for this project).
The MA100 series thermistor by
Thermometrics is listed as a biomet-
ric thermistor. It is designed to be
interchangeable over a 0–50°C range
with tolerances of <0.1% available.
This is what I was hoping to find.
When I visited the Thermometrics
web site, I was able to get a specifica-
tion sheet on the MA100, including a
resistance versus temperature table
(see Figure 1). Of course, this is not
the least expensive thermistor, but
the cost is only a bit more than some
of the other devices. Considering the
tolerance and accuracy, it’s well
worth the small premium.
10K REFERENCE
When I discussed using the com-
parator on TI’s MSP430F1121 flash
microprocessor in “MSP430 News
Flash: Recognizing the Flexibility of
Reprogramming” ( Circuit Cellar 133),
I used an RC combination of a 10-k
Ω
0.1% resistor and 1-µF capacitor. The
close-tolerance 10-k
Ω
resistor value
was chosen because that would close-
ly match the 10-k
Ω
ther-
mistor I planned to use.
The thermistor’s 10-k
Ω
value is based on 25°C and
an increase in temperature
lowers the thermistor’s
resistance (NTC).
For this project, temper-
atures from ~95 to 102°F
(~35–39°C) must be detect-
ed. The thermistor’s value
will therefore range from
6.6–5.5 k
Ω
. Even with this
short portion of the ther-
mistor’s interchangeable
range (0–50°C), the device
is nonlinear.
Using the resistance val-
ues and corresponding
temperatures listed in the
specification sheet, I used
Microsoft Excel to plot the
points on a graph, as illus-
trated Figure 2. As you can
see, I plotted resistance
(vertical tic = 10
Ω
) versus
temperature (horizontal tic
0˚C
5˚C
10˚C
15˚C
20˚C
25˚C
30˚C
35˚C
40˚C
45˚C
50˚C
55˚C
0
5,000
10,000
15,000
20,000
25,000
30,000
35,000
Resistance
Figure 1—
The temperature versus resistance for the MA100 thermistor (highly nonlinear) are displayed here.
670
00
660
00
650
00
640
00
630
00
620
00
610
00
600
00
590
00
580
00
570
00
560
00
550
00
540
00
530
00
520
00
510
00
500
00
95 F
95 F
96.8 F
96 8 F
100.4 F
100 4 F
98.6 F
98 6 F
102.2 F
102 2 F
Resistance
˚˚
˚
˚
˚
˚
Figure 2—
Although this area from Figure 1 looks linear, it’s actually off by ~±0.3%.
68
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
= 0.1°F). A straight edge on the table
shows a maximum nonlinearity of
approximately 20
Ω
out of 6 k
Ω
(~0.3% or –0.3°F). To eliminate this
error I used a graph to interpolate
between specification sheet table
entries and created a look-up table for
the project. The table has approxi-
mately 72 entries covering every 0.1°F
from 95.0°F to 102.2°F.
COMPARING RESISTANCES
You may recall parts of Figure 3 from
my article on using a micro’s com-
parator to measure resistance, capaci-
tance, voltage, or current. This project
calls a measurement routine to perform
a charge and discharge cycle. The rou-
tine can be called using either the ref-
erence resistor or the thermistor as the
R of the RC input. One time constant
(TC) is equal to 10 ms (1 µF × 10 k
Ω
).
TimerA is set up to run from the digi-
tally controlled oscillator (DCO) at
~4.9 MHz. The capture control regis-
ter (CCR1) will count up to 65535
(~13 ms, slightly longer than one TC).
The charging cycle simply config-
ures P2.0 (R
REF
) as an output of logic 1
and uses CCR1 to overflow four times
(4 × 13 µs = 52 µs, or five TCs) for a
99.9% charge of C. Then P2.0 is
reconfigured as an input (hi-z).
The discharge cycle begins with
configuring the comparator to inter-
rupt when the capacitor discharges to
0.25 VCC. The present value of the
TimerA Register (TAR) is saved. Either
the P2.0 (R
REF
) or P2.1 (R
SEN
) is config-
ured as an output if logic 0 and the
capacitor begin discharging through
R
REF
or R
SEN
. When an interrupt occurs,
the TAR is again read and the differ-
ence between the two times becomes
either the reference count for R
REF
or
the sensor count for R
SEN
P2.0 (or
P2.1). It is then reconfigured as an
input (hi-z) and the routine returns.
After this measurement routine is
completed (once using R
REF
and once
using R
SEN
), the resulting counts have
a relationship based on the same capac-
itor. To get the value of R
SEN
, use:
[2]
Figure 4—
You can use the circuit for the ISD4002 for any projects that require audio recording/playback. A piezo device (shown here) doesn’t have sufficient volume.
Figure 3—
You can see here how the MSP430F1121 microprocessor connects to the sensor for temperature
measurements. JP4 is the interface to the audio player (recorder).
www.saelig.com • saelig@aol.com
English for happy, prosperous &
blessed -- which is what I want my
customers to be!) to bring unique,
easy-to-use control and instrumenta-
tion products to USA from Europe.
• Over 50 different DIN-modules for:
analog i/p & o/p, thermocouple i/p,
digital i/p, relays, on 2000m network!
9pin > 9pin . . . . . . . . . . .
self-powered . . . . . . . . .
digital data on
PC FlashATA cards
software function
modules—finish quickly.
RS232, interrupts, sleepmode,
pre-emptive multitasking, easy to
attach LCD or keypad.
• CANbus adapter—recompile or log
Self-contained in
2" x 3" plastic box,
logging/alarm system
standalone or with PC.
see what’s new at www.saelig.com!
Industry-standard
card for PC’s
• Master, Slave or Bus monitor
• Low volt ICA93LV for 3V ic’s . .
power & information on 2-wires!
Boards for PCI/ISA/PCMCIA/PC104/VME/compPCI
Drivers for WIn95/98/NT,VxWORKS, pSOS, Lynx,
70
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
Now, remember the table Excel
helped to build? Step through the
table comparing R
SEN
to the table
entry and stop when R
SEN
is less than
the table entry or you reach the end
of the table. Subtract the table offset
from 1022 (102.2°F, the first entry in
the table), and you get the tempera-
ture (times 10). So, just throw that up
on a display and you’re done, right?
Naw, that would be too easy.
VISUALLY CHALLENGED
For those of you who find it
increasingly difficulty to read the fine
print, this is where my discussion
from last month comes in. The
remainder of this project dissects the
temperature value into digits that can
be spoken using the ISD4002 solid-
state recorder as a phrase playback
module (see Figure 4). This time
around you won’t need any fancy con-
trol over the ’4002. Its basic mode,
which takes care of marking mes-
sages and incrementing its memory
automatically, simply uses the micro-
processor’s SPI port.
Although this project does not con-
cern itself with the recording of
phrases (just their playback), those
phrases need to get into the ISD4002
somehow. In a production unit, the
recording function would not be need-
ed because the devices would be mass
programmed before assembly.
However, I needed to get the phrases
(see Table 1) into the ’4002. So I
included some code to make this hap-
pen. If the Record button (which is
not installed in the finished product)
is pressed, Record mode begins by
sending a
REC command.
The ISD4002 will automatically
record until it’s told to stop. Releasing
the Record button pulls it out of
Record mode by sending a
STOP com-
mand. At this time, the ISD4002
automatically places a marker in
memory to signal the end of message
and increments its memory pointer to
get ready for the next record cycle. If
the Record button is pressed again, a
new phrase can be recorded. However,
if the On button is pressed, further
recording is canceled.
The ISD4002 has the ability to
index quickly to any prerecorded
phrase by pointing to the beginning of
memory and searching through mem-
ory for the markers indicating the end
of a message. The use of the message
cue (MC) command instructs the
’4002 to skip to the beginning of the
next message. When used in a loop,
you can move to any message quickly.
This allows concatenation of phrases.
SAY WHEN
Just getting a temperature reading
from the thermistor isn’t good
enough. There are thermal transfer
characteristics that must be taken
into consideration. Certainly a tiny
bead sensor will attain an ambient
temperature quicker than one with a
larger mass, even when located under
the tongue. Protecting this bead with
various coatings and coverings insu-
lates the bead somewhat from the
heat source you wish to measure.
All this adds to the time it takes
the thermistor to reach ambient tem-
perature. Should you wait 1 s or 10 s?
72
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
the temperature one digit at a time.
Each digit’s value branches to a rou-
tine, which cues the appropriate
phrase (see Table 1) and then com-
mands the ’4002 to speak the phrase.
After the third digit, the phrase
“point” is spoken to indicate the fol-
lowing digit will be tenths of a degree.
Following the last digit, the phrase
“degrees Fahrenheit” closes the con-
catenation sequence. Certainly a sec-
ond conversion table could be includ-
ed to allow the temperature response
in degrees Centigrade if you prefer.
SAY GOODNIGHT
TI has built a number of different
levels of sleep into the MSP430 series.
As expected, the more clocking that
can be suspended, the lower power
the device can become. The lowest
power mode is LP4. In this state only
the RAM contents, I/O ports, and reg-
isters are maintained. Wake-up is pos-
sible only via enabled external inter-
rupts (pushing the On button in this
case). So, when power is first applied,
the micro goes into an initialization
Well, a conversion cycle takes ~1/4 s.
I let the thermistor temperatures
speak for themselves, so to speak. At
some point the change in temperature
will cease to waver (or slow to what
could be considered stable). I’d like to
wait until that happens and declare
that value the actual temperature.
To help assure that any movement
of the probe doesn’t give a false read-
ing, I will take 10 samples and aver-
age them. Ten is an easy number with
the ’1121 as I’m storing BCD informa-
tion in the form of four digits from
the resistance to temperature table
(remember 1022 = 102.2°F). The
DADC (decimal add to destination
with carry) instruction makes the
math simple. To average the 10 sam-
ples, just shift four bits to the right
(shifts the digits once to divide by 10).
Note that when the previous average
equals the new average, the tempera-
ture is considered stabilized.
SAY WHAT
Just as the 10 samples were aver-
aged by shifting right one digit, the
ultimate temperature can be shifted
left (four bits at a time) to evaluate
Photo 1—
Audio playback using the IDS4002 (
a
) and thermistor (
b
) make up the digital talking thermometer.
a)
b)
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
73
sequence to set up all the registers
and peripherals appropriately and then
goes to sleep until the On button is
pressed. In this mode, the processor
requires as little as 0.1 µA. Standby
current for the ISD4002 is also low at
1 µA. Even National Semiconductor’s
LM4861 1.1-W audio amplifier is less
than 1 µA when disabled.
SILENCE IS GOLDEN
The golden droid from the Star
Wars series, C-3PO, is known for
always getting the last word in (even
when flatly told to shut up). Luke
Skywalker’s uncle tried shutting him
up and he responded, “Shutting up,
sir.” Having our appliances continual-
ly announcing their status is not the
path to sanity. But, there are times
when auditory input may prove useful
or even necessary. It’s a fine line we
are walking. After all, one person’s
pleasure is another’s pain.
I
SOURCES
MSP430F1121 mixed signal MCU
Texas Instruments Inc.
(800) 336-5236
Fax: (972) 995-2011
www.ti.com
ISD4002 ChipCorder
Winbond Electronics Corp. America
(408) 943-6666
Fax: (408) 544-1789
www.isd.com
Jeff Bachiochi (pronounced BAH-key-
AH-key) is an electrical engineer on
Circuit Cellar’s engineering staff. His
zero
equ
0
one
equ
1
two
equ
2
three
equ
3
four
equ
4
five
equ
5
six
equ
6
seven
equ
7
eight
equ
8
nine
equ
9
ten
equ
10
eleven
equ
11
twelve
equ
12
thirteen
equ
13
fourteen
equ
14
fifteen
equ
15
sixteen
equ
16
seventeen
equ
17
eighteen
equ
18
nineteen
equ
19
twenty
equ
20
thirty
equ
21
forty
equ
22
fifty
equ
23
sixty
equ
24
seventy
equ
25
eighty
equ
26
ninety
equ
27
one_hundred
equ
28
point
equ
29
degrees_fahrenheit
equ
30
signon_message
equ
31
Table 1—
I pre-recorded this table of 32 phrases for
input into the ISD4002.
background includes product design
and manufacturing. He may be
reached at jeff.bachiochi@circuitcel-
lar.com.
ccording to their
web site, STMicro-
electronics is the
sixth largest semicon-
ductor company in the world. Not
bad, especially considering that
they’re up against competition from
semiconductor divisions of global
conglomerates like IBM, NEC, and
Samsung, not to mention perpetual
number-one Intel.
In fact, according to the Dataquest
figures, ST is right up there with U.S.
powerhouses like Texas Instruments
(rated number five) and Motorola
(rated number seven),
and has consistently
outperformed the
market (18.6% CAGR
versus 15.1% for the
IC biz as a whole).
Nevertheless, I sus-
pect ST isn’t a house-
hold name for most
Americans. Likely,
that’s because only
18% of the company’s
sales are in North
America, far less than
in Europe and Asia.
Take the statistics
as a reminder to
throw off your geo-
74
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
centric blinders. Yes, we Yanks may
have invented a lot of this stuff and
still call a lot of the shots, but the
rest of the world isn’t sitting around.
For instance, on the 32-bit front no
one can deny that the SH architec-
ture, pioneered by Hitachi, subse-
quently licensed and jointly advanced
with ST (recently spun out as inde-
pendent SuperH Inc.) has done well.
Meanwhile, hoist a pint for our UK-
based ARM friends who’ve done an
admirable job promulgating that 32-
bit architecture (also licensed by ST),
going head-to-head with hot shots
like Motorola, MIPS, and IBM. Jolly
good show, I say.
Actually, if you trace STMicro’s lin-
eage far enough back, you’ll find a
second cousin in the U.S. Until
recently, ST was known as SGS-
Thomson Microelectronics, reflecting
the company’s birth in a 1987 merger
between Italy’s SGS and Thomson
Semiconductor of France. But prior to
that, Thomson had acquired one of
the original U.S. chip companies,
Mostek. In fact, one of their more
well-known STMicroelectonics prod-
uct lines, the STPC family of embed-
ded ’x86 chips, can trace its roots
back to an old licensing deal between
Intel and Mostek.
With the SH, ARM, and STPC in
their corner, it’s clear that ST has
their 32-bit ducks in order. As all of
you know by now, I’m more partial to
the 8- and 16-bit no-nonsense chips
that are still the mainstays of the
embedded market.
SILICON
UPDATE
Tom Cantrell
High Five
a
Tom has
dabbled in
fuzzy logic
before, but
this time
the claim that it does
not live up to the hype
may be the fault of
impractical implemen-
tations, not absence
of virtue for the con-
cept. See what has
him rethinking it.
Photo 1—
FuzzyStudio is a well-polished, seasoned (V.4.1) tool chain that
stands out from the crowd with a graphical approach to developing and
organizing the application of your choice.
An up and Coming Micro Supplier
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
75
Figure 1). That sounds interesting, so
let’s download a datasheet or two and
take a closer look.
EPROM LIVES
For some time now, chip suppliers
have been racing to migrate their
MCUs to on-chip flash memory. You
know the story—fix bugs in the field
or over the Internet, streamline pro-
duction flow, and incorporate adap-
tive (i.e., self-modifying) features to
deal with calibration, aging, and drift.
Then live happily ever after.
So, I was a bit surprised to discover
that the ST5 and ST6 parts continue
to rely on EPROM technology, OTP
for production and windowed for
development. This is despite the fact
that ST offers plenty of higher-end
(i.e., ST7+) flash memory MCUs.
Don’t chuck your UV eraser just yet!
My interest was piqued enough to
place a call to ST to get their take on
the EPROM versus flash memory
story. As I write this, I still haven’t
received word from ST. In the mean-
time, I’m free to speculate based on
my own experience and observations
of what’s going on in the market.
The debate boils down to valuing
the cost and benefits of flash memory
versus EPROM for a particular appli-
cation. For instance, consider
the bug-fix and upgrade bene-
fit of flash memory. The
value depends on a lot of fac-
tors including the likelihood
of bugs, the value of a fix or
upgrade, and the additional
cost to implement a down-
load connection.
In turn, the likelihood of
bugs surely relates to the size
and complexity of the code.
Similarly, the value of a fix or
upgrade depends on the
degree to which overall func-
tionality is compromised or
improved, respectively.
So, does it make sense to
use flash memory for, say, an
automotive engine controller?
You bet your bippy! It’s likely
that the 0.5 MB or so of code
may eventually be re-flashed
to fix bugs, improve perform-
ance, or equally likely, adapt
in a dynamic regulatory environment.
There is essentially no cost to add the
download link because communica-
tions utilize the existing control net-
work (CAN, J1850, etc.). Meanwhile,
it’s a heck of a lot easier for the dealer
(and, in turn, cheaper for you) to plug
in to the connector under the dash
versus the traditional option—pull
and replace the entire ECU box.
But, topping out at 8-KB code space
and targeting the most mundane
motor and thermal control applica-
tions, the ST5 is a different story.
When was the last time your blender
or toaster crashed? And, even if a bug
managed to sneak past design test and
verification (how hard can it be to
check if a blender blends and a toaster
toasts?), how are you going to down-
load the new code? Last time I
looked, few toasters, blenders, or any
other low-cost (<$100) gadgets with
motors have modems or Ethernet
ports. The rare likelihood of show-
stopper bugs, limited opportunity for
meaningful upgrades, and lack of a
download connection diminish the
value of in-system programming that
flash memory offers.
As for streamlining production, it’s
true that eliminating extra handling is
nice, especially for the latest and
Surfing the ST web site, I
can see they’ve got the entire
field covered. Right alongside
the high-end 32-bit chips,
you’ll find the ST100 family
of MCU/DSP hybrids with
super-duper Scoreboarded-
Long Instruction Word (SLIW)
architecture and more MIPS,
MOPS, and MACs than you
can shake a stick at. As an
aside, ST is doing R&D with
HP on the concept of applica-
tion-specific, synthesized
VLIW cores, a neat idea for
the rocket science crowd.
Drop the trailing zero from
your search request and you’ll
come up with the ST10, an
upper mid-range, pipelined,
144-pin, 16-bit MCU. The
ST10 has all the trimmings:
256-KB flash memory, 12-KB
RAM, MAC unit, two CAN
2.0b ports, 5- × 16-bit multi-
function timers, 16- × 10-bit 200k
samples/s A/D conversion, and four-
channel PWM. There’s a watchdog,
PLL, and serial ports including sync,
async, and probably a kitchen sync too.
Moving into single digits, there’s
the ST9, an interesting lineup of parts
that purport to combine the best of
both 8- and 16-bit worlds. Although
the ST9 core has an 8-bit ALU, it
tops it off with a 16-bit bus and
instruction set and addressing capabil-
ity beyond 64 KB.
When it comes to pure-play 8-bit
chips, the ST7 gets the destinction.
With its classic accumulator and dual
X and Y index register architecture,
the ST7 looks a lot like the 68xx
chips of yore. Perhaps this is not a
surprise because ST was a second-
source supplier of Motorola parts.
While we’re in the loop, just keep
decrementing the part number and
check out the ST6. Now we’re talking
tiny program memory (1–8 KB), pack-
age (mostly 16–28 pins), and price
(will run you about $1), like the PIC
or AVR you’re probably familiar with.
Finally, you arrive at the ST5 fami-
ly which, perhaps reflecting its lean
and mean aspirations, is also known
as simply “Five” with the tagline,
“intelligent controller units” (see
I/O Port
Analog
comparator
User program
EPROM
8 KB
Control
units
Timer
watchdog
ALU and
fuzzy core
AIN 1
MA
MA
AIN 2
MA
MA
RIAC
TR
TR
OUT
TR/STP
ST
ST
ESET
RE
RE
XT CLK
EX
EX
MER
TIM
TIM
IMER
*T
OUT
OUT
Triac driver
Timer/PWN
PC
256-byte
2
RAM
RAM
INT
Oscilatorr
Powerup reset
RST
OSCIB
O
OSCIA
VSS
V
VPP
V
VDD
Figure 1—
The ST52T440 is a member of ST’s Five family of entry-level 8-bit
MCUs. Key points to ponder include fuzzy, high-current I/O, and EPROM.
76
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
greatest ultrahigh pin count, fine-
pitch, surface-mount parts. But the
ST5 family uses simple 20- to 44-pin
packages (including the venerable
DIP) for which the high-volume pro-
gramming infrastructure (handlers,
etc.) is well entrenched.
For all its purported streamlining,
flash memory can actually clog the
production line if you’re not careful.
Take a close look at the programming
specifications. Over the many years
since the invention of flash memory,
chip designers have well-tuned EPROM
for fast programming. Judging from
the ST5 specifications, it shouldn’t
take more than 1 or 2 s to program
and verify even the largest 8-KB part.
By contrast, some of the less mature
flash memory designs have exhibited
programming times on the order of 10
or even 100 times slower.
There very well may be nonobvious
electrical considerations. For example,
reflecting the needs of the targeted
applications, many of the ST5 parts
feature high-current I/O for driving
power transistors. We’re talking a
whopping 50 mA, or five to 10 times
the typical TTL-compatible part. I
don’t know all the facts, but it really
isn’t difficult to imagine there might
be issues combining brute force I/O
and finessed flash memory circuits
on the same die.
This brings up the issue of memory
reliability, including senility (data
retention time) and lobotomy (inad-
vertent or malicious modification).
Although I didn’t find an ST5 data
retention specification, it isn’t hard to
imagine that an EPROM might do
better in this regard than flash memo-
ry, especially given the inexorable
push for faster flash memory write
speed and stretched endurance specifi-
cations. The more designers stretch
flash memory to look like RAM
rather than ROM, the more concerned
I’d be about reliability.
Finally, although conventional wis-
dom dictates that the raw silicon cost
(i.e., die size and process complexity)
for flash memory is closing the gap
with EPROM, whether or not the gap
will be completely eliminated (and
when) will vary from company to
company. You’ll find that ST is still
aggressively pursuing the commodity
EPROM business; their web site
states that they’re, “Backed by contin-
uous innovations in technology, com-
bined with a strong commitment to
provide excellent delivery and serv-
ice.” For ST, it may make sense to
piggyback micros on the EPROM
process as long as they’re pumping
EPROM memories out the door.
FRISC?
Let’s start this journey under the
hood by noting that there are two dis-
tinct branches of the ST5 family tree.
The ST52T301 (T3) and ST52T440
(T4) variants share a common philoso-
phy, but are not compatible. I think a
history lesson is in order.
A unique differentiating factor for
the ST5 family is the incorporation of
both conventional Boolean and fuzzy
logic instructions (see Table 1), an
approach ST calls “DualLogic.”
The fuzzy logic story goes back to a
previous stand-alone, fuzzy-only chip,
the Weight Associative Rule Processor
(WARP). Both T3 and T4 carry forward
the guts of the WARP concept, includ-
ing the sophisticated FuzzyStudio
development environment that has
evolved over the years.
Longtime readers know I’ve been
around the dance floor more than
once with fuzzy logic. [1, 2] It’s safe to
say that fuzzy has never lived up to
the hype. However, I wonder if that
might not be more about too much
hype and impractical implementa-
tions rather than a complete absence
of virtue for the concept.
For the basics of the fuzzy story,
refer to any number of other sources,
including a good presentation on
STMicro’s web site. Suffice to say, the
addition of dedicated fuzzy hardware
boosts performance dramatically (see
Table 2). But then again, it always
has. The issue isn’t fuzzy perform-
ance, but that earlier fuzzy-only or
fuzzy-mostly chip designs were in
kind of a digital denial complex. In
reality, even the fuzziest thinkers
have to admit the need to do ones-
and-zeroes stuff from time to time.
Enter the DualLogic approach. By
cleanly integrating the fuzzy features
with an MCU, the ST5 line (and, giv-
ing credit where it’s due, Motorola’s
’HC12) presents a much more palat-
able option than a fuzzy-only chip.
Now, designers are free to explore the
fuzzy option without facing a high-
stakes fuzzy-or-bust situation.
Triac/PWM driver core
Programmable
counter
Prescaler
16-bit
REG_PERIPH_9
REG CONF8
REG_CONF9
RIAC
TR
OUT
MAIN
N1
MAIN
N2
8
8
0
0
1
2
2
3
3
4
4
5
5
6
6
7
Pulse
generator
REG_CONF10
REG CON
REG
R
RESET
START
MODE
÷
÷ 2
ck
Tc
MCLK
PRECLK
P
6
6
6
16
6
16
MCLK
EXTCLK
50/60 Hz
ck
Tc
POL
Figure 2—
The ST52T440 is especially well-suited for motor control, with a specialized PWM that includes high-
current output for direct connection to a TRIAC and MAIN inputs to detect the AC zero crossing.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
77
With EPROM, fuzzy, and many of
the peripheral functions in common,
the T3 and T4 variants diverge rather
dramatically on the digital side.
If RISCs are reduced, the first
DualLogic part, the ST52T301, might
be considered anorexic. Even the
miniscule couple of dozen instruc-
tions shown in the datasheet over-
states the matter because more than a
few of them are special-purpose or
hardware-specific in nature.
Forget
MUL or DIV instructions
(although the fuzzy hardware incorpo-
rates such arithmetic hardware), the
’T301 doesn’t even have shift instruc-
tions! In fact, as far as I can tell,
you’re supposed to do everything with
AND, ADD, and SUB.
I suppose you could argue that you
don’t need a lot of different instruc-
tions because there isn’t much extra
room for them in the 2 KB of EPROM.
And the 16-byte register file may
seem relatively luxurious to you now,
but that’s the end of the road for
RAM and I suspect it’s only enough
for the leanest of applications.
I’m all for minimalism, but the T3
is pushing it. I suspect other people
agree because the recently announced
T4 parts, while remaining true to the
theme, are a significant upgrade.
Although still streamlined, the
instruction set has practically doubled
to 46 (including shifts,
MUL, DIV, and
other usual suspects), program memo-
ry quadrupled (up to 8 KB), and the
data register file boosted by a factor of
eight or 16 with 128- and 256-byte
versions, respectively. Make no mis-
take, T4 is still an econo-box, but it
makes the T3 look like a moped.
POWER PERIPHERALS
The T3 and T4 versions of the ST5
family consist of permutations of
memory size, pin count, package type,
and selections drawn from a pool of
common peripherals that includes the
Instruction
Description
MBFn_mbf lvd v rvd
Stores the Mbf n_mbf with the shape identified by the parameters lvd, v, and rvd.
LDP n m
Fixes the alpha value of the input value
n Mbf and stores it in internal registers.
LDN n m
Calculates the neglected alpha value of the input
n with the Mbf m and stores the
result in internal registers.
FZAND
Implements the fuzzy operation AND between the last two values stored in internal
registers.
FZOR
Implements the fuzzy operation OR between the last two values stored in internal
registers.
LDK
Stores the result of the last fuzzy operation executed in internal registers.
SKM
Stores the result of the last fuzzy operation executed in internal registers.
LDM
Copies the value of register M in the data stack.
CON crisp
Multiplies the crisp value with the last weight.
OUT n_out
Performs “defuzzification” and stores the fuzzy output in the RAM n_out location.
FUZZY
Starts the fuzzy algorithm.
Table 1—
The ST Five fuzzy coprocessor includes instructions to handle “fuzzification” (LDP, LDN), inference
(FZAND, FZOR), and “defuzzification” (CON, OUT).
standard fare: power-on reset, watch-
dog, brownout detector, timer/PWMs
(8- with 16-bit prescaler), and so on.
Reflecting the target market
(motors, heaters, and such), it’s the
analog options that deserve a closer
look. Some parts (e.g., T301, T420,
T430) come with a four- or eight-
channel 8-bit ADCs. The T440 lineup
takes a different tack, with four- or
six-channel multiplexed analog com-
parator, 2.5-V bandgap reference, and
a dedicated timer implementing a
slope A/D conversion with up to 12-
bit accuracy. That’s impressive for a
penny-pinching micro.
As noted earlier, one of the more
notable features is the high-current
TRIAC/PWM driver found on the
T301 and T440 parts (see Figure 2).
It’s designed specifically for motor
and heating applications with various
modes (PWM, Burst, Phase-angle) and
the horsepower (50 mA) to directly
drive a power transistor, TRIAC or
MOSFET. ST offers a variety of demo
boards covering various types of
motors (i.e., DC brushless, AC single-
phase, AC three-phase, switched
reluctance, and more).
Besides motors and heaters, don’t
forget that a high-current output is
useful elsewhere. It’s handy for things
like LEDs, buzzers, relays, and even
powering other chips.
FUZZY BUSINESS
Technically, the ST5 seems like it
should be able to hold its own rela-
tive to competition in the entry-level
8-bit arena. The only limitation
would be for designers who absolutely
require built-in flash memory or EEP-
ROM. Those people have to turn to
one of the many chips (including
those higher up on the ST parts list)
that have made the switch from
EPROM. On the other hand, the ana-
log and high-current I/O features are a
relatively unique advantage for the
ST5 that may prove compelling in
certain applications.
But with so many aggressive and
worthy competitors, my attention
turned from the chip to its develop-
ment tools. A micro is only as strong
as its weakest link, and all too often
in the past I’ve seen decent silicon
brought to its knees by primitive,
buggy, inadequately documented,
poorly supported tools.
In fact, I have to confess that before
I committed to writing this article, I
downloaded and installed the evalua-
tion version of the FuzzyStudio devel-
opment suite just to make sure. No
sense getting too far down the road
with ST5 if the tools were so clunky
as to prove a showstopper.
Obviously, the fact that you’re read-
ing this implies that they passed
muster, at least for my cursory exami-
nation. In fact, like the analog and
high-current features of the chip, the
tool chain also goes a step beyond the
conventional text-oriented IDE
accompanying most 8-bit parts.
Despite its name, FuzzyStudio isn’t
especially fuzzy-centric. Rather, it’s a
complete graphical environment
78
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
Component
Bench1 (ms)
Bench2 (ms)
Bench3 (ms)
ST52
0.02
0.0531
0.2918
PC 80486 (33 MHz)
0.05/0.07
0.05/0.08
0.09/0.12
8C196
0.19/0.23
0.24/0.33
0.44/0.64
80C166
0.05/0.06
0.06/0.08
0.1/0.14
68HC11
1.1/1.3
1.4/1.9
2.6/3.5
68HC12
0.09
0.14/0.15
0.4/0.41
TMS320C52 (50 MHz)
0.02/0.022
0.023/0.03
0.039/0.049
80C51
1.0/1.2
1.4/1.9
4.4/4.9
PIC16C74
0.4
0.7/0.8
2.5/2.7
PLC Moller PS4/401
1.6
1.6
1.6
Bench1: Seven rules, two input (three M.F.), one output (five M.F.)
Bench2: 20 rules, two input (five M.F.), one output (five M.F.)
Bench3: 80 rules, three input (three M.F.), one output (five M.F.)
Table 2—
Clearly, fuzzy significantly affects performance. The ST Five fuzzy performance equals that of higher-
end 16- and 32-bit chips. In addition, the ST Five is approximately 10 to 100 times faster than most 8-bit MCUs,
with the exception of the Motorola ’HC12, which also includes fuzzy instructions.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
79
addressing all aspects of ST5 develop-
ment. Indeed, the thing I like about
the tool is that the fuzzy aspects are
seamlessly integrated, easily at hand
if you’re interested, but not in your
face if you aren’t.
Take a look at an example project
and I think you’ll see what I mean.
You can download the project and
application note in addition to
FuzzyStudio if you want to follow
along at home. [3]
It is apparent from Photo 1 that
FuzzyStudio adopts a graphical pro-
gramming environment. Usually, I’m
skeptical of the approach, having
found in the past that such tools can
be more about eye candy than getting
your work done. But I must say, I’m a
bit less skeptical after my experience
with FuzzyStudio.
First, like the fuzzy features, the
graphics options are used sparingly
and appropriately rather than being
shoved down your throat. Simply
double-click on the objects to reveal
their true form.
Most often that’s likely to be a rou-
tine written in ST’s proprietary ver-
sion of a C-like language, which you
can see in Photo 2. Admittedly, it
doesn’t come close to ANSI compati-
bility, but that isn’t surprising consid-
ering the confines of the chip. As
well, an ASM object can be pro-
grammed in ST assembler directly.
Other neat, helpful objects include
configuration and initialization dialog
boxes for all the peripherals (see
Photo 3). I suppose nobody wants to
be bothered reading datasheets any-
more, so automatic setup and driver
generators have become more popular
in recent years. I think having the
functionality built in to FuzzyStudio
is much more convenient than having
to work with (not to mention pur-
chase) a separate program.
Of course there are also fuzzy
objects, such as the ones handling fre-
quency and slip control in the exam-
ple. As you can see in Photo 4,
FuzzyStudio lets you have it your way
using either graphics, text, or both to
refine your fuzzy routine.
The version of FuzzyStudio that
comes with the starter kit is said to
include an integrated debugger and
simulator that isn’t in the free version
I downloaded from the ’Net. I would
have to check out those critical func-
tions before passing final judgment.
Nevertheless, I was impressed with
what I did see of FuzzyStudio.
Interestingly, the tool seemed to be
simultaneously friendly (including
copious documentation and built-in
help), flexible, fast, powerful, and
solid. It has always been rare to find
software that isn’t lacking in one or
more of these virtues.
That’s especially true for IC manu-
facturer-supplied tools, which more
often than not simply demonstrate
that knowing how to produce an IC
doesn’t make you a tool expert.
Indeed, the trend at chip companies
like Motorola, Analog Devices, and TI
is “If you can’t beat ’em, buy ’em,” as
they snap up formerly independent
third-party tool suppliers.
ST = STAY TUNED?
There’s one final piece of the puzzle
to solve before the ST parts can be
blessed as worthy for prime time. It
boils down to whether or not ST
wants you as a customer.
What kind of business wouldn’t
want customers? Most companies
have a warm and fuzzy mission state-
ment posted somewhere in the board-
80
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
room. Some of the tried-and-true you
might recognize are “Customer is
King,” “We Aim to Please,” “Like
Mom and Apple Pie,” yadda, yadda….
You know that familiar scenario
with the clerks who blab on the
phone with their friends while you
wait? They work for a company that
boasts something similar to one of
these mission statements. The same
goes for the outfit that sends you to
voicemail hell. And, it’s no different
in the fast food joint serving up the
hockey puck they call a hamburger
(and forgetting your fries to boot).
No doubt if you’re a Fortune 500
company, ST will take care of you.
But what about the zillions of small
and mid-size American companies
that consume half of the MCUs sold
here? Is ST interested in them? For
their sake, I hope so because as the IC
market has evolved, I’ve come to a
couple of conclusions.
First, no company can hope to suc-
ceed as a broad-based supplier of ICs
without offering micros in the mix.
The product is too strategic, perva-
sive, and permanent to ignore.
Second, any company that wants
to be a player in the microcontroller
market better be prepared to serve
the unwashed masses (i.e., distribu-
tor customers buying hundreds to
thousands of parts), not merely a few
big, focus accounts. If your chip does-
n’t have thousands of customers
now, it’s only a matter of time before
it has zero customers.
Is ST up for the challenge? There’s
only one way to find out and that’s to
give them a try. See what it takes to
buy a starter kit, give technical sup-
port a query, call a distributor. Find
Photo 3—
Quick and easy configuration of on-chip peripherals is another neat feature built into FuzzyStudio.
Photo 2—
FuzzyStudio relies on so-called FSCode, a low-level, high-level language (would you call that LLHLL?)
with a C-like veneer. It doesn’t come close to ANSI compatibility, but that isn’t a surprise.
82
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
out if they have the interest, means,
and will to pursue your design-in.
ST has some worthy chips. Now,
let’s see if they have what it takes to
run with them.
I
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.
RESOURCE
STMicroelectronics fuzzy logic tuto-
rial: us.st.com/stonline/prodpres/
fuzzy/pdf/fuzzyint.pdf.
SOURCES
’HC12
Motorola, Inc.
(512) 328-2268
Fax: (512) 891-4465
www.motorola.com
ST5x 8-bit DualLogic MCU
STMicroelectronics
+613 820 6060
Fax: +613 768 7910
www.st.com
REFERENCES
[1] T. Cantrell, “Fuzzy Buster,”
Circuit Cellar
67, February 1996.
[2] ——— “Fuzzy PID-Pong,”
Circuit Cellar
69, April 1996.
[3] M. Di Guardo and V. Marino,
“Slip Control of an Asynchronous
Three Phase Motor with ST52x
420,” AN1291, STMicro-
electronics, July 2000.
Photo 4—
FuzzyStudio lives up to its name, making it easy to examine and tweak your fuzzy membership func-
tions and rules. You can use graphics, text, or both to refine your fuzzy routine.
CIRCUIT CELLAR
Test Y
Your E
EQ
What’s your EQ?
—The answers
and 4 additional questions and
answers are posted at
www.circuitcellar.com
You may contact the quizmasters
at eq@circuitcellar.com
8
more EQ
questions
each month in
Circuit Cellar Online
see pg. 4
Problem 1
—What is the function of
the ALE (address latch enable) pin in
8051, 8085 and 8086/8088 micro-
processors?
Contributed by Naveen PN
Problem 2
—What is a "page fault" in
a virtual memory system? What is an
"invalid page fault?"
Contributed by Naveen PN
Problem 3
—What are the three common
ways of doing I/O (input/output) in a com-
puter system?
Contributed by Naveen PN
Problem 4
—Explain the difference between
virtual addressing and virtual memory.
Contributed by David Tweed
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
83
....by using real-time emulators.
HC12, HC11
8051
C166
C500
ST10
Super10
Philips XA
68300 family
Ubicom
” info see www.nohau.com/howto
Insert-ready sub-mini SBCs (small as 47x55 mm.) supporting the
Philips
achieved via GND circuitry, 6 to 8 layer PCB, by-
32 KB to 8 MB external SRAM & Flash (controller-dependent)
FlashTools enable on-board in-system (ISP) programming
C & CAN interfaces; ADC; Chip-Select signals
PHYTEC America LLC ■ 255 Ericksen Avenue ■ Bainbridge Island, WA ■ USA 98110
IDEA BOX
THE
DIRECTORY
OF
PRODUCTS AND
SERVICES
AD FORMAT
: Advertisers must furnish digital submission sheet and digital files that meet the specifications on the digital submission sheet.
ALL TEXT AND OTHER ELEMENTS MUST FIT WITHIN A 2
″″ ××
3
″″
FORMAT
. Call for current rate and deadline information. Send your disk and digital submis-
sion sheet to: IDEA BOX, Circuit Cellar, 4 Park Street, Vernon, CT 06066 or email kc@circuitcellar.com. For more information call Kevin Dows at (860) 872-3064.
Suppliers Directory now available online. Check out our web site
www.circuitcellar.com to see who has what and how to get it!
84
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
Real Time Control and reading analog signals.
High speed Serial Port Interface
24 digital I/O (TTL compatible)
11 Analog Channels with 12 bit ADC
4 channels with signal conditioning
Embedded stepper motor controller
32 bit DLL free source code,
Real Time Logging
Control up to 16 STEPPER MOTORS simultaneously
Up to 8500 Steps/sec with linear Accel/Decel.
Chopper driver up to 48V/2A for 4,5or 6 wire motors.
Software Winding Current Setup.Shaft encoder input
Internal FIFO for linear, cubic or Spline Interpolation.
24 digital I/O,2 SPI, 11 analog channels on-board.
FREE SOURCE CODE in C++ and VBASIC
300-3665 Kingsway
Vancouver, BC, Canada V5R 5W2
Tel: (604) 299-5173 Fax: (604) 299-5174
Web:
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
85
56&RQWUROOHGRU&DQQHG&\FOHG&RQWUROOHG
6KRUW&LUFXLWDQG2YHU7HPS3URWHFWLRQ
3URJUDPPDEOHELWRSWLFDOO\LVRODWHGLQSXWV
%XLOWLQ$FFHOHUDWLRQ'HFHOHUDWLRQUDPSLQJ
6RIWZDUH&XUUHQW$GMXVWPHQWYLD56
Visit our new site www.jkmicro.com
Call 530-297-6073 Fax 530-297-6074
6 Serial Ports
Ethernet
33Kbaud
Modem-Option
Starts at $369
86
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
Need to quickly get up to speed with the
PICmicro
172 Harvard Road
Waterloo, ON, N2J 3V3
Canada
519.886.4462
519.886.4253(fax)
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
87
88
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
89
PC Based Data Acquisition & Control Products
PCI-9812, 20 MHz Simultaneous
4-Ch Analog Input Card
PCI-7300A, Ultra-High Speed 32-Ch
Digital I/O Card
for EXTENSIVE DETAILS. Much broader selection online!
1-800-528-1417/ Fax: 480-464-5824
• Full duplex
• 422 or 485 4 wire
• Short haul modem
Connecticut microComputer, Inc.
PO BOX 186, Brookfield,CT 06804
(203)740-9890 Fax:(203)775-4595
90
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
91
2900-1 Crescent Drive
Tallahassee, FL 32308
Options: 8-ch 12-bit ADC, flash disks up to 288 MB, 1 RS-485
Tiny Size, Low Power: 2”x2.6”, 5V @ 200 mA at full speed.
Visit http://www.bagotronix.com for info, prices, and FAQs
• Easy to Use
• Low Cost
• Low Power
• Tiny Size
• High Speed
• DOS Environment
Integrated Development Systems:
Compilers, Simulators, Programmers,
Non-intrusive, with trace feature, hardware unconditional & complex
breakpoints, triggers, programmable clock, memory mapping &
banking, full project & source level support for C compilers…
92
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
94
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
48 Sword St
Auburn MA, 01501
Fax: 508-798-4782
800-587-5069
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 135 October 2001
95
INDEX
63
ADAC
85
Abacom Technologies
92
Abia Technology
86
Ability Systems Corp.
86
ActiveWire, Inc.
90
Advanced Embedded Systems, Inc.
44,78
Advanced Transdata Corp.
45
All Electronics Corp.
85
Amazon Electronics
9
Amulet Technologies
84
Andromeda Research
92
AP Circuits
50
Arcom Control Systems
72
ATOP Technologies
91
Bagotronix, Inc.
86
Baritek
86
Bay Area Circuits
86
CCS-Custom Computer Services
90
Cedar Technologies, Inc.
89
Circuit Specialists, Inc.
92
Conitec Data Systems
65,89
Connecticut mircoComputer Inc.
85
Copeland Electronics Inc.
86
Cyberpak Co.
57
Cygnal Integrated Products
93
Data Design Corp.
C4
Dataman Programmers, Inc.
93
Dataprobe Inc.
86
DataRescue
83
Decade Engineering
81
Design MSP430 Contest
The Advertiser’s Index with links to their web sites is located at www.circuitceller.com under the current issue.
Page
87 Designtech Engineering
88
Digital Products
7
Dreamtech Computers
77
Earth Computer Technologies
16
ECD (Electronic Controls Design)
84
EE Tools
(Electronic Engineering Tools)
64
EMAC, Inc.
79
Embedsys.com
16
Engineering Express
32
Everyday Practical Electronics
84
FDI-Future Designs, Inc.
86
HVW Technologies Inc.
84
Hagstrom Electronics
41
HI-TECH Software,LLC
88
ICE Technology
89
IMAGEcraft
89,93
Intec Automation, Inc.
25
Interactive Image Technologies Ltd.
88
Intronics, Inc.
65,85
JK microsystems
22
JR Kerr Automation & Engineering
47
Jameco
94
LabMetric, Inc.
87,88
Laipac Technology, Inc.
59
Lakeveiw Research
94
Lemos International
2
Link Instruments
94
Lynxmotion, Inc.
91
MCC (Micro Computer Control)
64
MaxStream
83
MetaLink Corporation
89
MJS Consulting
88
Micro Digital Inc
91
microEngineering Labs, Inc.
72
Microcross, Inc.
24,71
Micromint Inc.
22
Midwest Micro-Tek
34,70
MVS
93
Mylydia Inc.
15
NetBurner
90,93
Netmedia, Inc.
83
Nohau Corp.
90
OKW Electronics Inc.
62
On Time
92
Ontrak Control Systems
91
PCB Express, Inc.
C2,1
Parallax, Inc.
87
Phelps Inc.
83
Phytec America LLC
91
Phyton, Inc.
93
Picofab Inc.
93
Prairie Digital Inc.
90
Pulsar Inc.
91
Quadravox
41
Quanser Consulting Group
31
R4 Systems Inc.
84
R.E.Smith
90
RLC Enterprises, Inc.
84
RMV Electronics Inc.
23
Rabbit Semiconductor
17
Radiotronix, Inc.
73
Remote Processing
An RF Lap-Scoring System
Choosing the Right IR Technology
Build a Wireless Weather Station
Does Your PIC Quack?:
Adding Sound to a Training Device
Robot Sensor Controller Board:
Part 2—How the Brain Works
I From the Bench
: Probe This
I Silicon Update
: The Last Micro?
I Applied PCs:
PICing a Place on the LAN
Page
Page
Page
Wireless Communication
PREVIEW
136
ADVERTISER’S
85
SMTH Circuits
69
Saelig Company
87
Scidyne
5
Scott Edwards Electronics Inc.
88
Sealevel Systems Inc.
93
Senix Corp.
87
Sensory, Inc.
85
Sigg Industries
83
Signum Systems
86
Sirius MicroSystems
89
SmartHome.com
22
Softools
40
Solutions Cubed
92
Spectrum Engineering
83
Square 1 Electronics
92
Street Rod Digital
33,73
Technologic Systems
93
Technological Arts
C3
Tech Tools
88
Tern Inc.
26
Texas Instruments
70
Trilogy Design
94
Vantec
94
Vetra Systems Corp.
92
Weeder Technologies
84
Xilor Inc.
87
Z-World
nce upon a time our homes were much more mundane. We didn’t have automatic lighting, distributed audio
and video systems, projection televisions, satellite receivers, wireless security surveillance systems, distributed
control nodes everywhere, and so on. Back then you also didn’t need to have a backup power generator to flush the
toilet, enough surge suppression to shunt a lightning bolt, or need an engineering degree to start the coffee maker. Call it
ranting, but even we high-tech junkies have limits. I love all this technological overkill but I get testy when I start experiencing incompatibility.
There was a time when we all had just a TV. That rapidly expanded to being a stereo surround-sound system with a TV, DVD, VCR, and
satellite receiver. Although elaborate in some installations, the fact that it was a logical direct-wired configuration kept it manageable in concept
as well as function. Overkill being the culture, however, if you’re like me you soon found yourself cloning complete entertainment systems for
the bedroom and office, TVs in the kitchen, and even the bathroom. Now, we need a LAN to connect the HDTV, the office computer, and the
kitchen (for recipes). Did I mention home control and surveillance?
If you build a house from scratch it’s easy to plan for additional wiring needs. If you own a house where no thought was given to distributed
electronics, it’s a mess to retrofit the place. I gave up trying to hard-wire everything and jumped on the wireless bandwagon quite early. I should
have thought about this stuff like an engineer but it was too easy to be a naive consumer. Let me explain.
I’ve been rather happy with wireless devices. I’ve used a number of phones and worked my way up the frequency spectrum with each new
model. I experienced the reality of distance limitations, but wireless technology worked for me so I gradually added more. Rather than hard-
wire a new DSS satellite receiver through the house, I used a 2.4-GHz microwave transmitter and infrared remote control repeaters to broad-
cast it to TVs and audio systems. The picture was so perfect with 2.4 GHz that it convinced me that even my hardwired HCS Sony camera sys-
tem could use an upgrade. I ordered a bunch of X10 wireless cameras and a new 2.4-GHz wireless phone. That was the beginning of the end.
Except for the occasional interference when the microwave oven was turned on (intermittent, but definitely a wave band blitzer) my 2.4-GHz
video and audio system has worked flawlessly. The instant I attached the new SST Panasonic 2.4-GHz phone, it all turned into an interference
nightmare. The phone had pulsing noises and the video channels had static bars. I thought all this spread spectrum stuff was supposed to
make wireless devices work better!
Use of the unlicensed 2.4-GHz industrial, scientific, and medical (ISM) band has been growing at a tremendous pace. Once thought of as
unpopulated territory, the 2.4-GHz band is now cluttered with IEEE 802.11-compliant wireless LAN (WLAN) systems, Bluetooth devices, home
RF solutions, video extenders, cordless phones, and a ton of other wireless systems. With everyone claiming it is an uncluttered band and the
perfect solution to all the interference on 900 MHz, it will only get worse.
I don’t know a lot about wireless network technology (this is a great opportunity for someone to pen an informative tutorial article for us all),
but I sense a basic incompatibility between analog and digital systems. Spread spectrum products are so named because they spread their
transmitted signal over a wide range of the spectrum. There are two techniques—Direct Sequence Spread Spectrum (DSSS) and Frequency
Hopping Spread Spectrum (FHSS). The primary advantage shared by both spread spectrum technologies is that many radios are supposed to
operate in this band with a minimum amount of interference.
The 2.4-GHz video extenders (and X10 cameras, I suspect) are entirely analog and extremely broadband. This makes them one big traffic
hazard for spread spectrum devices. At the receiving end, pure analog devices feel every hop and spread that crosses their path. Spread
spectrum digital devices like a WLAN contain error checking and retransmission if a frequency is blocked. There might be reduced throughput
in an interfering environment, but data will get through.
Probably the only interference solution for 2.4 GHz is for it to be a pure digital world. We sit in the office reading our e-mail totally uncon-
cerned about the endless arbitration going on in our network connections. It should be the same way for all wireless devices. As the rules
become less restrictive, there are no foreseeable barriers to the creation of wireless home networks that can support any kind of voice, multi-
media, and data applications that we can currently envision. I just hope someone remembers that we need to make them work together.
No Unpopulated Territory
INTERRUPT
o
steve.ciarcia@circuitcellar.com
PRIORITY
96
Issue 135 October 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
odular design for easy, low-cost expansion &
ully emulates the selected PICmicro, including pro-
gram memory, register memory, EEPROM, I/O activity,
SLEEP mode and all peripherals.
ses specialized Microchip “Bondouts” for accurate
upports unlimited “NO SKID” Hardware Breakpoints.
Get the TOTAL Package for only
CONTACTS: (972) 272-9392 Fax: (972) 494-5814 Email: sales@tech-tools.com
ntuitive, Easy to Learn full-featured environment
with integrated ClearView Debugger.
ource-level debugging for ALL popular Compilers
See why Engineers choose TechTools
Visit our website at www.tech-tools.com and request your FREE CDROM!
Complete 12bit Development System from $699
Complete 14bit Development System from $749
Combined 12bit & 14bit Development System from $899
Add additional device support for $75 to $200
Add a PICwriter Programmer for $199
Add Data Breakpointing for $50
Orders received by 4pm will normally be despatched same day.
• Plugs straight into parallel port of PC or
• Programs and verifies at 2, 2.7, 3.3 & 5V
• True no-adaptor programming up to 48
• Free universal 44 pin PLCC adaptor
• Built-in world standard PSU - for go-
• Package adaptors available for TSOP,
• Programs 8 and 16 bit EPROMs,
EEPROMs, PEROMs, 5 and 12V FLASH,
Boot-Block FLASH, PICs, 8751
microcontrollers and more
• Rechargeable battery power for total
• All-in-one price includes emulation
leads, AC charger, PC software, spare
library ROM, user-friendly manual
• Supplied fully charged and ready to use
• Programs wide range of 20 and 24 pin
logic devices from the major GAL vendors
• Supports JEDEC files from all popular
• 3 year parts and labor warranty
• Windows/DOS software included
• Free technical support for life
• Next day delivery - always in stock
Order via credit card hotline - phone
today, use tomorrow.
If you do not agree that these truly are the
most powerful portable programmers you can