7
9
25274 75349
0 6>
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 1 J U N E 2 0 0 1
COMMUNICATIONS
A Wireless Data Link
The SCUBA DiveMate
Design2K Winner:
Electronics Lab Tool
Ethernet Home Networking
Premier GPS Inc., (403) 295-8879, Fax: (403) 274-3021, tabsha@premier-gps.com
computer systems in tiny modules
DIP-type modules with 28 - 92 pins
cut consumption (50mA @ full speed),
cut components, cut system cost
Digital, analog and serial I/O channels in module
Expansion Bus for up to 4,096 I/O lines
160 kB ... 6 MB FLASH + SRAM, RTC, Watchdog
BASIC Tigers™ deliver what developers and manufacturers
really want:
Sound good? You bet! Test the Tiger at no risk today.
Contact your local dealer:
• 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 131 June 2001
3
High-Performance Oscilloscope
Amplitude Calibrator
Mariano Barron & Javier Martinez
The Road to Success
Driven to Design Contest Winners
ABOVE THE GROUND PLANE
Can’t Set Your Clock
APPLIED PCS
Working with a Player
Fred Eady
Intelligible HUBbub
Ethernet Home Networking
Jeff Bachiochi
SILICON UPDATE
Power Tripped
Tom Cantrell
COLUMNS FEA
TURES
ISSUE
New Product News
edited by Rick Prescott
Advertiser’s Index
July Preview
Priority Interrupt
Steve Ciarcia
Still Doing the Old Stuff Better
131
ChipCenter
RESOURCES
• Internet Phones
Rick Prescott
• DVD-R, DVD-RAM,
and DVD+RW
Brant Schroeder
• Wireless Networks
Brant Schroeder
ASK
US
THE ENGINEERS
TECH-HELP
RESOURCE
Let us help keep your
project on track or simpli-
fy your design decision.
Put your tough technical
questions to the ASK US
team.
The Ask Us research
staff of engineers has
been assembled to share
expertise with others.
The forum is a place
where engineers can
congregate to get some
tough questions
answered, or just browse
through the archived
Q&As to broaden their
own intelligence base.
★★★★★★★★★★
Test Your EQ
8 Additional Questions
AN HC11 FILE MANAGER
Part 2: All of the Details
by Walter Krawec
Picking up where he left off last month, Walter now takes on the task of building the full file
manager. Taking us through the ins and outs of managing the development of projects on the
processor and then sharing procedures among projects, you quickly realize how useful this
project really is. It's always a good idea to get "all the details" before plunging in.
May
2001
KNOCK! KNOCK! "WHO'S THERE?"
Using UPnP to Respond to Inquiries
by Edward Steinfeld
UPnP is an architecture of peer-to-peer networking of intelligent machines, appliances, wire-
less devices, and computers of varying form factors. Edward shows us that UPnP succeeds
in answering such questions as what machines are on the Internet, how are operations con-
trolled, and will the machines notify when they have a significant event? With the
power of UPnP and the right tools, it can only be easy times ahead.
May 2001
USING A WELL-DESIGNED BOOT MONITOR IN EMBEDDED SYSTEMS
Part 1: Constructing the Platform
by Ed Sutter
Beginning his series this month, Ed addresses the lack of enthusiasm for monitors. Whether
you're a monitor champion or resister, you will benefit from looking at both sides of the equa-
tion in this article. Bootroms may be overrunning the monitors, but you can come up with a
design that enhances the embedded system and endures for years to come. The reward is
improvement in your current implementation, or renewed interest in monitor use.
May
2001
COMMUNICATIONS PROTOCOLS IN AERONAUTICS
by George Novacek
Airplanes are like one big computer network. To have a multitude of embedded controllers
communicate with each other, what you need in the air is the same as what you need on
land-throughput and reliability. Still running strong after 30 years, ARINC 429 is the most
popular communications protocol. Take your pick of any number of reasons for this,
because it is well-defined, reliable, easy to implement, and inexpensive.
May 2001
ANALOG SYSTEM DESIGN
Part 2: Putting Theory into Practice
Lessons from the Trenches—
by George Martin
George likes poking fun at Windows98, comparing it to a challenging computer game, but
this month he turns his attention to an analog design project involving a custom car.
Transducer interfaces and thermocouples became the topic of discussion for his article,
along with noise and filtering. Get set for another analog endeavor as he takes us
through the many considerations that come with the territory.
May 2001
ROBOTICA
Silicon Update Online—
by Tom Cantrell
As Tom describes it, L.A. is the epitome of "sun and fun overdone." Still, the heart of the
entertainment industry sells a lot of hardware. Sponsoring a group of local college students
for the Robotica competition and supplying them with the necessary snacks, Tom goes
behind the scenes to follow the trials and tribulations of "Noll." A steady stream of
M&Ms can only help foster a kid's imagination.
May 2001
RETRO HUMOR CIARCIA STYLE
Part 2—
by Steve Ciarcia
Way back at the dawn of the microcomputer age, Steve Ciarcia was blazing a trail (some-
times literally) through the hardware and software issues of the era. At the request of many
of our readers, we've brought back a series of articles, written by Steve, chronicling the
design adventures of those early days in the Circuit Cellar. This month, it's chapter
one from Take My Computer, Please!
May 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
6
Issue 131 June 2001
EDITORIAL DIRECTOR/PUBLISHER
Steve Ciarcia
MANAGING EDITOR
Rob Walker
TECHNICAL EDITORS
Jennifer Belmonte
Rachel Hill
Jennifer Huber
WEST COAST EDITOR
Tom Cantrell
CONTRIBUTING EDITORS
Ingo Cyliax
Fred Eady
George Martin
George Novacek
NEW PRODUCTS EDITOR
Rick Prescott
PROJECT EDITORS
Steve Bedford
Bob Paddock
David Tweed
ADVERTISING
ADVERTISING SALES MANAGER
Kevin Dows
Fax: (860) 871-0411
(860) 872-3064
E-mail: kevin.dows@circuitcellar.com
ADVERTISING SALES REPRESENTATIVE
Elyshia Gottier
Fax: (860) 871-0411
(860) 875-2199
E-mail: elyshia.gottier@circuitcellar.com
ADVERTISING COORDINATOR
Valerie Luster
Fax: (860) 871-0411
(860) 875-2199
E-mail: val.luster@circuitcellar.com
ADVERTISING CLERK
Sally Collins
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
CUSTOMER SERVICE
Elaine Johnston
ART DIRECTOR
KC Prescott
GRAPHIC DESIGNERS
Naomi Hoeger
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
bout a month and a half before the Embedded
Systems Conference in April, the effects of a long
New England winter had set in and I was so desperate
for exercise that I agreed to join some friends for “recre-
ational” basketball once a week. As a point of background, during my fresh-
man year of college I had a growth spurt and shot up to 5
′
4
″
and in light of
that, never really got into basketball. Instead, I found other sports, primarily
soccer, that were more forgiving for people of lesser stature (getting tram-
pled on a grass field seemed so much more promising than getting tram-
pled on a hardwood floor).
Anyway, after playing basketball for a couple of weeks without any major
incidents, I was starting to get a feel for the game. Five days before I was
supposed to get on the plane to go to ESC, I joined the guys for our weekly
basketball meeting. In a moment of Jordan-like acrobatics (at least that’s
what it felt like), I found myself soaring through the air on defense to block a
shot. The next thing I knew, someone cut under my legs and I was doing an
aerial cartwheel—that only went halfway around. Seems “heads up” is not
just good advice on a baseball diamond, it’s also good advice when prepar-
ing to crash dive onto a basketball court. While on the way to the emer-
gency room, I thought about the fact that my theory on the forgiving quali-
ties of a grass playing surface had held true, however I didn’t say anything
about it lest my witty remarks be confused with signs of head trauma. So, it
was off to the show with an eyebrow full of stitches and a swollen eye that
turned a different shade of purple almost every day.
With such a convenient conversation piece, I had no trouble drumming
up talk at the
Circuit Cellar booth. As always, it was great to meet a number
of readers and hear about the projects that you’re working on or that you
would like to see in
Circuit Cellar. With the downswing of tech stocks at the
time, my conversations with some of the vendors contained overtones of
hesitancy and I got the feeling that there were definitely people there who
were attending the show as somewhat of a job fair.
The most interesting and lively conversations that I was involved with
had to do more with the business of quality content and information. In spite
of the stock market situation, people still want to read good technical con-
tent in a variety of formats, and providing that information is turning into a
hot business prospect. We had discussions with book publishers, web pub-
lishers, and even overseas magazine publishers—all of whom wanted to
discuss potential publishing opportunities. But, with the excitement of being
recognized for our success comes the challenge of maintaining the same
level of quality that earned us that recognition. For now, it’s business as
usual for
Circuit Cellar, but who’s to say a 13-year veteran can’t show the
new guys a thing or two? After all, quality technical content is our game.
rob.walker@circuitcellar.com
Cover photograph Ron Meadows—Meadows Marketing
PRINTED IN THE UNITED STATES
a
In the Right Game
1.888.941.2224 www.arcomcontrols.com
Your Embedded Controller SHOULD:
be industrial enough to survive even the harshest environments
have long term availability and support
be reliable enough for continuous operation
not only simplifies development of the power manage-
ment firmware for the microprocessor, but also allows the
microprocessor to enter standby, thereby reducing system
power consumption.
The MAX1773 is available in a
space-saving, 20-pin TSSOP pack-
age. It is specified for the extend-
ed industrial temperature range
(–40° to 85°C).
Pricing starts at $2.82.
Maxim Integrated Products
(800) 998-8800
Fax: (408) 737-7194
www.maxim-ic.com
NEWS
8
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
NEW PRODUCT
NEW PRODUCT
Edited by Rick Prescott
ANALOG OUTPUT MODULE
The WTDAC-M is a member of the new stackable RS-
232 data modules. Four analog output channels span –10
to l0 VDC using a 12-bit DAC. You can set distinct DC
voltage levels on an output using simple ASCII character
strings containing the desired voltage listed in standard
engineering units, no conversion necessary.
Automatic generation of trapezoidal and S-curve ramp
functions simplify complex multi-point cyclic operations.
Individual power-up voltages for each channel can be pro-
grammed. Calibration is performed in software, eliminat-
ing the need for user- adjustable trim-pots. Gain and offset
coefficients are stored in nonvolatile memory.
All modules in this series can be plugged end-to-end on
a common RS-232 cable attached to the serial port of a
host PC. An onboard 32-position DIP switch sets the
address of each module, which is used for identifying data
transmitted from it, as well as directing data transmitted
by the host. The data bus supports full anti-collision disci-
pline between connected modules and will allow up to 32
modules to share the same communications line. Power is
supplied by an external 15 to 25 VDC to the first module
in the chain and is carried down the RS-232 cable to suc-
cessive modules.
The WTDAC-M sells for $79.
Weeder Technologies
(650) 663-5723
www.weedtech.com
POWER SOURCE SELECTOR
The MAX1773 is a highly integrated IC that serves as
the control logic for a system with multiple power sources.
The device directly drives external P-channel MOSFETs to
select from an AC adapter and dual bat-
tery sources for charge and discharge. The
selection is based on the presence of the
power sources and the state of the batter-
ies.
The IC is designed for use with a buck-
topology charger. It provides a simple and
easily controlled solution to a difficult
analog power control problem. The IC pro-
vides most of the power source monitoring
and selection, freeing the power manage-
ment microprocessor for other tasks. This
VIRTUAL SYSTEM MODELING TOOL
LabCenter has released the latest tool in their PROTEUS
Electronic Design Package. The Virtual System Modeling
(VSM) component complements the PROTEUS package
enabling the user to develop their microcontroller software
without the need for a physical prototype. It does this by
simulating the complete system, including the micro-
processor and its peripherals. Moreover, the simulation is
fully interactive, with animated components such as LED
displays, switches, pots, keypads, and such. The simulation
itself is carried out using a true mixed-mode SPICE3F5 cir-
cuit simulator such that all manner of electronics may be
simulated in conjunction with the processor itself.
Currently the 8051/8052, MC68HC11, PIC, and Atmel
AVR are supported.
The VSM module integrates with LabCenter’s schematic
capture tool ISIS, the mixed-mode circuit simulator
PROSPICE, and the PCB design tool ARES. With the addi-
tion of VSM, the user can design the schematic, simulate
and graph the design, and, using the netlist, quickly design
and route the PCB.
LabCenter products are distributed in the USA, Canada,
and Mexico by R4 Systems Inc. Pricing for the PROTEUS
system starts at $229.
R4 Systems, Inc.
(905) 898-0665
Fax: (905) 898-0683
www.r4systems.com
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
9
NEW PRODUCT
NEWS
FLAT-PANEL/CRT GRAPHICS ACCELERATOR
The PCIX-993RP PCI video adapter card is designed for
the remote operation of flat panel displays (FPDs) and
touchscreen interfaces. The card is unique in that both the
LCD panel and touchscreen may be operated up to 33
′
from the host CPU via the digital
PanelLink interface, without degra-
dation of picture quality or touch-
screen data. The accelerator imple-
ments the flat-panel display,
industry-standard transition mini-
mized differential signaling
(TMDS) digital PanelLink inter-
face (DVI-compatible) to ensure
high-noise immunity and low
emissions over long cable
lengths. Using the device
results in a simple and reliable
connection between the host
CPU and a remote LCD and
touch screen.
The card supports a wide variety of 3- and 5-
V monochrome and color single-panel, single-drive, dual-
panel, dual-drive, standard and high resolution passive
STN, and 36-hit active matrix TFT LCD panels.
A variety of programmable features to optimize display
quality are also offered. Vertical centering and stretching
algorithms are provided for handling modes with less than
480 lines. Horizontal and vertical stretching capa-
bilities are also available for both
text and graphics modes for optimal
display of VGA text and graphics
modes on 800 × 600, 1024 × 768, and
larger panels.
Pricing for the PClX493RP is not
yet available.
10
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
his article will
describe the hard-
ware and software
design and implementa-
tion of a low-power, wireless RF data
link. We will discuss a robotic appli-
cation in which the RF link facilitates
the command and control functions
of a tele-operated miniature robot.
The RF Monolithics (RFM) TR-3000
chip is the core of the transceiver
design. We use a straightforward
interface to a PIC controller, so you
should be able to use or
adapt much of this appli-
cation for your needs.
We are part of a team of
researchers and develop-
ers led by Dr. Nikos
Papanikolopoulos at
University of Minnesota’s
Center for Distributed
Robotics. Our mission for
this DARPA-sponsored
project was to develop a
miniature, self-contained
robot for distributed
robotics applications.
The robot, called Scout,
is packed in a 38-mm
diameter tube with coaxi-
al-mounted wheels at
each end, approximately
110-mm long. The robot is shown in
Photo 1. (For additional information,
see the “Key Specifications for Scout
Robot” sidebar.) Scout carries a
miniature video camera and video
transmitter, allowing you to tele-oper-
ate the robot by sending it steering
commands while watching video
images sent back from Scout. The
video transmitter and data transceiver
contained on the robot are separate
devices, operating at 915 and
433MHz, respectively. Also contained
on Scout are dual-axis magnetometers
(for compass functions) and dual-axis
accelerometers (for tilt/inclination
measurement).
One of Scout’s unique features is its
ability to hop. Not frequency hop, but
physically hop. This allows the robot
to drive up to an obstacle and leap
over it. Scout accomplishes this feat
by using an onboard winch to retract
a spring tail and then quickly release
it. The tail slaps the ground and the
robot flies into the air. By using the
wheels to control the prerelease tilt
angle of the robot and the accelerome-
ters to measure it, the robot’s flight
trajectory can be varied from shallow
to nearly vertical.
Packing all of that hardware into a
small area was no easy task. In order
to get any height to the hop, a lot of
energy had to be put into the spring
tail. The winch mechanism has to be
strong enough to cock the spring,
which means it has to be beefy, which
FEATURE
ARTICLE
As part of U of MN’s
team of researchers
and developers, Tom
and Don are working
on a miniature, self-
contained robot. Their
experience lead to a
short-range wireless
data link design that
you may modify for
your own applications.
So, get ready to scout
for helpful details.
Tom Dahlin &
Donald Krantz
Wireless Data Link
t
Photo 1—
The robot measures a little over 4
″
. Designed for tele-operated
remote surveillance, it contains a video camera and transmitter. Scout
can hop over obstacles by hoisting its tail spring (shown extended) and
quickly releasing it to slap the ground and propel the robot into the air.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
11
PIC is only able to keep up with a
2400-bps encoding rate using our data
encoding scheme.
The radio board hardware is a copy
of the RFM development kit design,
repackaged for our application. We
required a lower data rate than the
development kit supported. So, we
had to recalculate component values.
We also stripped out many of the
development kit components that
were unnecessary in our application.
These unnecessary components were
in the manufacturer’s design to
demonstrate and support all of the
capabilities of the chip, however, we
wanted kept the design as simple as
possible. There was limited time to
pull off this effort, so it was best not
to stray far from a proven design.
TRANSCEIVER CHIP
The radio transmit and receive
functions are done by a single inte-
grated circuit and a handful of passive
components. The transceiver is the
TR3000 ASH (amplified sequenced
hybrid). The transceiver package is
0.28
″
× 0.40
″
, making it possible to
package the device into tiny spaces,
such as this robot, a PDA, or pen.
The transceiver requires a 3-VDC
power source, and draws 6 mA when
transmitting and between 2 and 7 mA
when receiving (depending on config-
uration). It is a single-channel device
with a fixed frequency (433.92 MHz).
The TR3000 can use either ASK
(amplitude shift keying) or OOK
(on/off keying) modulation, depending
on setup. It solves many of the prob-
lems associated with amplitude mod-
ulation schemes by using a narrow-
band SAW filter in the receive chain
to reject interference.
TRANSCEIVER CHIP OPERATION
The heart of the transceiver is the
amplifier sequenced receiver section,
which provides more than 90 dB of
stable RF and detector gain without
requiring special shielding or decou-
pling provisions. Stability is achieved
by distributing the total RF gain over
time. This is in contrast to a super-
heterodyne receiver, which achieves
stability by distributing RF gain over
multiple frequencies.
requires more energy to lift, which
means more energy put into the
spring, which requires a stronger
winch…. Designing the mechanism is
an exercise in optimizing a positive
feedback system.
The electronic packaging has to
wrap around the space claimed by the
electromechanical components and
video camera. Scout’s winch and cam-
era occupy the central part of the
robot and are mounted to a circuit
board containing Scout’s main proces-
sor, a PIC16F877. This board is
mounted horizontally within the tube
with two round end cap boards
attached at right angles, one at each
end. One of these boards contains the
magnetometers and accelerometers
and the other contains another PIC
serving as a radio controller.
The radio RF board stacks onto the
radio processor board, and power sup-
ply boards stack onto the radio and
magnetometer boards. Finally, end
caps containing lithium battery cells
and wheel servo motors stack onto
the power supplies. A polycarbonate
tube holds everything together.
Obviously, we could write an entire
article about the robot. Actually,
there are research papers that discuss
Scout [1, 2] and more are in progress;
check the University of Minnesota
web site for links to these and other
published works. Now, let’s get back
to the subject of our article, the wire-
less data link.
HARDWARE ARCHITECTURE
Scout’s hardware and software were
designed to be modular. The wireless
data link is physically partitioned
onto two separate boards, one con-
taining a PIC processor for radio con-
trol, message formatting, and data
encoding (see Figure 1). The other
board contains the RF hardware, con-
sisting of the RFM TR3000 chip and
supporting discrete components (see
Figure 2). By separating the two
boards, we were able to keep the digi-
tal noise and trash away from the
radio. Although unnecessary, we
could have wrapped a little metal
shield around the radio.
The PIC processor hardware design
is minimal. The PIC16F877 provides
8 KB of flash programmable program
memory, and 368 bytes of RAM in a
surface-mount package. Obviously, a
socketed part was out of the question
because of space constraints. The
radio controller PIC’s hardware UART
lines are connected directly to the
corresponding pins on the Scout’s
main PIC processor for a tightly
linked asynchronous serial interface.
On the radio side, we used discrete
PIC lines to connect to the RFM
chip’s TxD, RxD, and two control
lines. The radio controller PIC uses an
8-MHz crystal, providing low-power
(approximately 2- to 4-mA) operation.
The choice of crystal frequency was a
trade-off between power consumption
and data bandwidth. At 8 MHz, the
Figure 1—
For the radio processor board, a PIC16F877
provides the horsepower to perform transceiver control,
Manchester encoding, and packet formatting.
Let’s take a closer look at this
amplifier sequencing because it’s con-
fusing at first. Referring to the receiv-
er and timing block diagrams (Figures
3a and b, respectively), note that the
incoming signal is first filtered by a
narrowband SAW filter. The output of
this filter is then fed to the first of
two RF amplifiers, RFA1, which is
followed by a delay line, and RFA2.
A pulse generator module independ-
ently controls these amplifiers. The
SAW delay line connecting them has
a delay of approximately 0.5 µs. The
pulse generator first turns on RFA1
for approximately 0.5 µs via pulse P1.
The delayed output from the delay
line starts to become available just as
RFA1 is turning off, at which time
RFA2 is pulsed on by P2 for approxi-
mately 0.5 µs. Thus, the incoming
signal sees the effect of two stages of
amplification.
The system is inherently a sam-
pling type, and the sample width
(duration RFA1 is on) is chosen such
that you get at least 10 samples over
the narrowest RF input pulse. For
example, the 2400-bps rate used by
the robot has a 416-µs bit time, or a
minimum pulse width of 208 µs. If a
minimum of 10 samples is to be
obtained, set the sampling interval to
about 20 µs. This interval and the
width of the pulses are determined by
the external resistors Prate and
Pwidth (Rx and Ry, respectively).
Now, take a closer look at the inter-
nals of the transceiver (see Figure 4).
The RF interface to the chip is via the
12
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
antenna connection, pin 20. The
antenna series matching coil RFIO
and the shunt tuning/ESD protection
choke go between the antenna and
chip. By adjusting the values of each,
it is possible to match antennas that
are outside of the nominal 50-
Ω
impedance the chip wants to see.
The incoming signal is filtered and
amplified as it passes through the
chain leading to RFA2’s output. The
signal is now fed to a detector to full-
wave rectify the signal. The output of
the detector is fed into a low-pass
gyrator filter whose bandwidth can be
adjusted from 4.5 kHz to 1.8 MHz via
resistor RLPF. The low-pass filter’s
output is then connected to a base
band amplifier. The output of this
amplifier is brought out to a pin so
that coupling capacitor CBBO can be
used to AC couple the signal to the
data slicer comparators DS1 and DS2
and the peak detector.
The data slicers convert the analog
signal from the coupling capacitor
back into a bitstream. You can use
either of the two available slicers.
DS1 is the simplest, a basic threshold
type. DS2 is more complex, compar-
ing the incoming signal to a threshold
value that can be set up to 12 dB
below the signal’s peak level as
detected by the peak detector block.
The peak detector’s output rises rapid-
ly to follow the incoming signal but
decays slowly (1:1000 ratio, set by
CPKD). Resistors RTH1, RTH2, and
RREF set up the various comparator
thresholds. RFM suggests using DS1
Figure 2—
An RFM TR3000 device han-
dles all of the RF dirty work, requiring
only a handful of discrete components.
for low-signal to noise applications, so
that’s what we used. Leave out RTH2
to disable DS2.
The ASH transceiver also contains
an AGC function to extend the
dynamic range of the receiver. This
allows a pair of transceivers to com-
municate while in proximity without
the transmitted signals overloading
the receivers. If a saturation condition
is detected in the first RF amplifier
(RFA1), an AGC set signal is pro-
duced, which causes the AGC control
block to select a 5-dB gain mode for
RFA1. This is 30 dB less than the nor-
mal 35-dB gain of RFA1. The AGC
comparator will send a reset signal to
restore the high gain mode when the
peak detector output falls below the
fixed reference voltage for DS1.
Capacitor CAGC prevents AGC chat-
tering. We elected not to use the AGC
function and disabled it by connecting
the AGCCAP pin to V
CC
.
Now, let’s switch over to the trans-
mitter side of the device. The SAW
delay line used in the receiver section
is reused as part of an oscillator in
conjunction with transmit amplifier
TXA1. The output of this stage is
connected to the buffer amplifier
TXA2, which is also used to apply
transmit modulation.
Two modulation schemes, OOK
and ASK, are supported by the chip.
During OOK, the transmitter output
is either fully on or off, depending on
the logic state of the bit being sent.
During ASK, the transmit power is
varied from fully on to a lower power
level. ASK modulation is required
when you want to use high data rates
(data pulses less than 30 µs). We used
the OOK modulation scheme.
The block labeled modulation and
bias control handles transmitter con-
trol and modulation selection. You
use pins CNTRL1 and CNTRL2 to
determine which of the four operation
modes you want. The three modes are
Receive, Transmit ASK, and Transmit
OOK/Sleep. These are CMOS-compat-
ible inputs. The transmitter RF out-
put voltage is proportional to the
input current to the TXMOD pin,
which modulates TXA2. A resistor in
series with TXMOD allows you to
adjust the transmitter power.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
13
HARDWARE CONSTRUCTION
When building the radio, you have
to lay out and use a PCB because of
the RFM chip packaging and need for
a good ground plane. The chip comes
in a 20-pin SMT package with the
pads located under the package. They
do not protrude beyond the edge of
the package. There is no DIP or lead-
ed version of the device because of
the high-frequency operation.
In order to solder the device to your
board, you need to do an SMT solder
paste reflow operation or cheat as we
did. The cheating way is to lay out
your pads so that they extend a little
from under the chip. Then, you can
touch them with a fine-tip soldering
iron and wick the
solder up and
under the device.
This, of course, is
for prototype and
debug construc-
tion. A steady
hand is required.
A two-sided
board for the radio
works fine. We
used the backside
of the board as a
ground plane, and
placed the TR chip
in the middle of
the component
side. The physical
component layout
(see Photo 2) is
similar to the schematic representa-
tion. Most of the chip’s pins go to
either ground or V
CC
, either directly or
through a resistor or capacitor.
Therefore, you can place these dis-
crete components close to the pin
they connect to and tie the other end
to ground or V
CC
with a via.
The processor board has a four-layer
construction like most of our PIC
designs. This allows a good ground
plane and a clean, well-bypassed V
CC
.
This is important to prevent digital
noise from messing up the radio.
ANTENNA CONSIDERATIONS
A key part of a wireless system
design is the antenna. Whenever pos-
sible, you want to locate the antenna
on the outside of your product, away
from metal objects that can untune it,
and as far above ground as possible.
With our robot application, we had
two strikes against us. We operated at
ground level and had to integrate the
antenna into Scout’s plastic shell,
directly over several motors and bat-
teries. Our solution was to design an
end-fed antenna, approximately one-
quarter wave in length, out of copper
tape. We started with a theoretically
correct design and trimmed the tape
with a razor for a good impedance
match. This was done using a net-
work analyzer.
You should try to design the prod-
uct with the antenna on the outside
of the unit. To make regulatory com-
pliance easier, it should be fixed to
the product and not have a connector.
This is so that you can’t substitute a
yagi array with 20 dB of gain. We also
advise you to locate the antenna far
away from you if the product is worn
on your body or hand-held. RFM pro-
vides a reference antenna design, so
the company’s web site is a good
place to start.
RADIO SOFTWARE
The complexity of software for the
radio link falls somewhere between
analog signal processing for modem
communication and protocol devel-
opment for serial asynchronous
links. If you have written software
Figure 3a—
The receive section of the transceiver comprises a narrow band-pass
SAW filter, two gain stages, and an AM detector. A delay line temporally separates
the gain stages. The timing block diagram is shown in
(b)
.
Antenna
SAW
Filter
RFA1
RFA2
SAW
Delay line
Detector and
low-pass
filter
RF Input
RF Data pulse
P1
RFA1 Out
Delay line
out
P2
P1
P2
Data
out
t
PW1
t
PW2
t
PRI
t
PRC
Pulse generator
a)
b)
Antenna
RFIO
ESD
Choke
SAW
CR Filter
20
Modulation and
bias control
TXMOD
8
17
18
R
TXM
TX
IN
CN
TRL1
CN
TRLO
Power down
control
TXA2
RFA1
TXA2
SAW
Delay line
Pulse generator
and RF amp bias
Prate
14
R
PR
15
Pwidth
Gain select
AGC Set
RFA2
Detector
Log
AGC
control
AGCCAP
3
C
AGC
Low-pass
filter
LPFADJ
BB
Peak
detector
PKDET
4
AGC
AGC Reset
DS1
DS2
Threshold control
13
11 12 THLD2
Ref
THLD
AND
RXDATA
7
dB Below
peak third
R
TH1
R
TH2
R
REF
THLD1
R
PW
9
R
LPF
5
6
BBOUT
C
LPF
C
PKD
Ref
V
CC1:
Pin 2
V
CC2:
Pin 16
GND1:
Pin 1
GND2:
Pin 10
GND3:
Pin 19
R
REF:
Pin 11
CMPIN:
Pin 6
Figure 4—
The complete block diagram of the RFM3000 trans-
ceiver shows transmit, receive, and detection functions.
14
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
to process analog signals such as
speech, RF, or modems, you will find
the RFM hardware easy to use. If you
have never ventured away from
direct-connect digital communication,
such as RS-232 or TCP/IP (above the
protocol stack), you’re in for an ugly
surprise.
The digital base band signal coming
out of the RFM receiver is full of
noise, asymmetric waveforms, and
other annoyances. The link layer soft-
ware must be designed to operate reli-
ably in the face of these complica-
tions. Be warned: This software
implementation has only a modest
amount of error detection capability
built-in. Before using this type of
implementation for critical applica-
tions, you need to add a significant
amount of overhead to reduce errors.
We describe here a reference imple-
mentation for a simple multi-station,
master-slave packet protocol. We’ll
suggest a few enhancements later.
The RFM software designer’s guide
has nice signal and timing diagrams
and an excellent in-depth discussion
of many of the issues involved with
designing RF software. [3] The guide
also has an implementation of an
alternative communications protocol
for the 8051 family.
SOFTWARE DESIGN CONSIDER-
ATIONS
The receiver hardware doesn’t sup-
ply a carrier-detect signal, which
means that the decoding software
needs to be able to pick out a message
from the constant stream of random
noise present when there is no trans-
mitter within range. In addition, this
means that it is difficult to determine
when another station is transmitting
a message if you want to arbitrate
access to the spectrum with other
transmitting stations.
The system sensitivity is signifi-
cantly improved if the transmitted
signal is DC-balanced. This means
that no matter what data is being
sent, the average time the transmitter
is on and off is the same (always 50%
on, 50% off) over relatively short
averaging windows. The windows are
on the order of 10 to 20 bit times,
preferably less.
System performance is improved if
the narrowest pulse width in the
transmitted signal is not much differ-
ent in size than the widest pulse
width. This lets the hardware design-
er use better and more selective filters
in the receiver.
Given these constraints, it isn’t
practical to just hook up a hardware
UART to each end of the radio link.
The random RF noise will continu-
ously trigger the receiver to start.
Also, the signal won’t be DC-balanced
without additional software encoding.
Finally, many UARTs cannot tolerate
the bit edge jitter that is usually pres-
ent in the received data. Therefore, it
is necessary to either get a special
radio UART or encode the data in
software. We used software encoding
in order to save hardware dollars and
power consumption.
There are two common data encod-
ing schemes that can be used for sys-
tems like this (can be implemented in
hardware or software). The more effi-
cient scheme uses 12-bit symbols to
encode each 8-bit data byte. Given all
possible bit patterns representable in
12 bits, there are more than enough
with six ones and six zeros to assign
one to each possible 8-bit value.
Because each 12-bit symbol is DC-
balanced (has the same number of
ones and zeros), each entire trans-
mission is DC-balanced. And,
because there are extra DC-balanced
12-bit symbols, you can choose sym-
bols such that a 111111000000 sym-
bol is never sent next to a
000000111111 symbol. So the widest
pulse width can be limited to about
six bit times, and the narrowest is
one bit time.
A disadvantage of this scheme is
that after 12-bit symbols are assem-
bled from the radio, they must be
decoded into their 8-bit equivalents
using a look-up table or similar decod-
ing system. This is made easier by
breaking 8-bit data into 4-bit nibbles
and mapping them to 6-bit symbols,
which saves on look-up table size and
time at the expense of adding more
operations. The RFM software design-
er’s guide describes an implementa-
tion of this scheme for the Atmel
AT89C2051 microcontroller. [3]
16
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
The second common scheme
is called Manchester encoding.
The Manchester encoding
technique maps each data byte
to a 2-bit symbol, typically
symbols 10 and 01 representing
data bits 1 and 0, respectively.
Using Manchester coding, mes-
sages are DC-balanced at the
data bit level. The widest pos-
sible pulse time is only 2-bits
long, and the narrowest is 1-bit
long (thus, a 2:1 ratio). Because
there is always a transition in
the middle of each Manchester
symbol, the data clock is easy
to recover. We chose to use the
Manchester encoding scheme
for our data link.
Choosing a coding scheme is
only the first step. Although not
essential, it is almost always benefi-
cial to design a packet protocol for
simple RF data links. We used a sim-
ple packet scheme whereby a master
station sends a packet to either a sin-
gle slave or to all slaves. In the case of
a broadcast to one slave, the slave
will respond with a return packet that
serves both as an acknowledgment of
receipt and a method to return data to
the master from the slave.
We do not allow more than one
master on the network, and we do not
allow slaves to initiate a broadcast.
The reason is that there is no way to
avoid occasional collisions among sta-
tions initiating messages. This prob-
lem is shared by many protocols, and
there are lots of ways to recover from
collisions, but collision sensing and
recovery algorithms complicate the
software more than what we need for
our application. Most books about
networking have several algorithms
for designing multiple-access net-
works. (Later in the article, we’ll dis-
cuss a method for sensing activity on
the network.)
Each packet begins with a sync pre-
amble. The preamble is a series of 1
Manchester symbols that has two
purposes. First, the sync preamble
trains the bit slicer in the receiver to
the proper DC level. Depending on
the filter parameters used by the hard-
ware designer, this should take eight
to 16 symbol times. And second, it
allows the receiver software to syn-
chronize with the data clock by find-
ing the 1
→
0 transition in the
received data. In our case, this can
happen in as little as one bit time.
For a more robust system (one less
susceptible to false triggering), several
perfect 1 symbols in a row may be
required. This also would cause the
receiver to reject more good messages.
Remember that the RFM chip has no
carrier detect capability. In many digi-
tal RF systems, carrier detect is used
to gate the receiver logic when hunt-
ing for synchronization. Without car-
rier detect, you see a stream of ran-
dom noise and often a valid 1 fol-
lowed by a valid 0, which results in
falsely detecting a start of packet. If
the triggering threshold is raised by
requiring multiple perfect ones, the
probability of false triggers is reduced
(but not eliminated).
A start bit follows the sync pream-
ble. This is a single 0 bit, and its sole
purpose in life is to divide the end of
the sync preamble from the data in
the packet. Figure 5 shows the packet
preamble graphically.
The packet data is 16-bytes long.
We chose this length to make it fit
easily into the banked data RAM of
the earlier PIC chips (the first imple-
mentation of this protocol was writ-
ten for the SX processor, which looks
like a PIC12C5x family device). The
packet data consists of a header, data
payload, and error detection.
The header contains three
bytes, a sequence number, to
address, and from address. The
destination uses the sequence
number to ensure that dupli-
cate messages are ignored (a
duplicate message can occur if
an acknowledge from the desti-
nation to the source is lost and
the source resends the original
message). The source uses the
sequence number to determine
which message was acknowl-
edged. Our implementation
uses the convention that a zero
address in the to field is a
broadcast message to all slaves.
The data payload is 11-bytes
long and free-form. Note that
any data may be contained in
the payload.
The error detection field is a 2-byte
CRC. Back in 1982 or so, Don lifted
the algorithm and CRC polynomial
from an 8080 assembly language ver-
sion of Ward Christensen’s XMODEM
protocol. It’s been implemented sever-
al times since then and it now
appears as a hybrid of C and PIC
assembly language.
The error detection covers the head-
er and the data payload bytes. A valid
CRC assures you that the received
message is probably intact (odds are
better than the 1 in 65536 implied by
the 16-bit number because errors are
not typically randomly distributed).
However, if using this for a critical
application, you should add better
error detection.
SOFTWARE IMPLEMENTATION
The software is written in a combi-
nation of Byte Craft PIC-C and PIC
assembly languages. It is written in
the tradition of the CP/M user’s group
of the late 1970s and early 1980s (“It
was hard to write, it should be hard to
understand.”) We chose to sample
each Manchester bit eight times, and
even with optimized assembly lan-
guage we can only manage a burst
rate of about 600 bps. Using a 50-
MHz Scenix SX, we ran this algo-
rithm much faster (9600-bps burst
rate). Most of the interesting software
is available on Circuit Cellar’s web
site in
radioisr.c.
Photo 2—
The radio transceiver chip is the large package in the middle of
the board. Supporting discrete components are placed conveniently near
their connections to the transceiver chip.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
17
The software is structured to run
the receiver decoding and transmitter
encoding at interrupt level. The
timer0 interrupt is set up to execute
at 4800 Hz. The receiver software
uses a simple state machine with six
states. Initially, the state machine is
set to hunt for sync.
During the sync hunt state, the
receiver is sampled during each inter-
rupt and a bit is shifted into one end
of an 8-bit register. After the shift, we
look at the shift register to find a per-
fect 1 symbol, which looks like bina-
ry 11110000. Whenever this pattern is
detected (it will happen for noise as
well as for real 1 bits), the state is set
to wait for eight interrupts (still sam-
pling and shifting but doing nothing
else) and then look again. If it’s anoth-
er pretty good 1 symbol, we wait
eight more interrupts and repeat. If
it’s a pretty good 0 symbol, we switch
state into Data Acquisition mode.
We measure “pretty good” by look-
ing at the bit pattern in the shift reg-
ister and comparing it to an ideal 1. A
perfect 1 has the binary bit pattern
11110000 in the shift register.
However, if the waveform is not sym-
metric or if the data recovery clock is
not well phased, a 1 can easily look
like 1110000x or x1111000. If there’s
a little bit of RF noise, a 1 can look
like 10110000, 11010000, 11110100,
or 10110010.
Combining noise and clock phase
jitter results in more patterns. It’s dif-
ficult to find all of the patterns that
would be a pretty good 1 or 0 and
compare them to the shift register. A
look-up table can be used but is
bulky, and 256-byte look-up tables are
messy in PIC implementations.
So, you examine each bit position
in the shift register. Count how many
shift register bits correspond to a per-
fect 1. If the register contains a per-
fect 1, the count will be eight. If the
register contains a
pretty good 1, the
count will be seven
or maybe six. If it’s
a perfect 0, the
count will be zero.
A pretty good 0 will
have a count of one
or maybe two.
The rest of the software is straight-
forward. The only part whose func-
tion may not be obvious is called
rf_rx_line_up_edge. Its function is to
look for the clock edge in the middle
of the Manchester symbol. If the
clock edge in an otherwise perfect
symbol is found shifted one way or
the other, this function shifts it back.
This is an unintelligent method, but
it can be improved by integrating
errors over several bits before making
a correction.
SOFTWARE ENHANCEMENTS
There are many ways this imple-
mentation can be improved with
respect to particular applications. For
example, network sensing can be sim-
ulated to reduce collisions in a multi-
ple-access network (but, note that
even hardware carrier detection is not
100% certain to avoid collisions).
A simple yet reliable network sens-
ing scheme is to simply look at the
state of the receive software. If not in
state 0 (sync hunt state), then wait to
transmit. This will always prevent
transmitting over a valid incoming
message after the first sync bit is
detected, but it will also prevent
transmitting during false noise trig-
gers. In some respects, the false noise
triggers is a benefit, because if fre-
quent enough they will simulate the
random back off used in several mul-
tiple-access networking schemes.
Another potential enhancement is
better error detection. A higher order
CRC can be used to reduce the
chance of accepting a damaged mes-
sage. Anyone math-challenged, be
sure to use an established CRC poly-
nomial (and observe that the CCITT-
16 polynomial is shifted one bit),
because not all polynomials of the
same order give equivalent results.
1
1
1
1
1
1
0
X
X X
X
X
X
Transmitter on
Transmitter off
Sync preamble
Start of packet data
Start
bit
Figure 5—
The packet preamble shows Manchester encoded ones and zeros.
Experience your Dream Computer
CREATE AUDIO & DATA CDs WITH EASE!
CREATIVE LABS CDRW & 30GB HD DELIVERS
HIGH PERFORMANCE ON A BUDGET.
PRODUCE, COMPILE & BURN! A COMPLETE P4
WORKSTATION WITH 17” MONITOR, 40GB HD & CDRW.
EXPERIENCE THE NEXT GENERATION
OF HIGH-PERFORMANCE DREAM COMPUTERS BUILT WITH INTEL’S PENTIUM 4 PROCESSOR.
RELIABLE, POWERFUL WORKSTATION AT
AN UNBELIEVABLY LOW PRICE. WITH 40GB
HD & 32MB VIDEO CARD!
NETWORK-READY WITH WINDOWS
2000 PROFESSIONAL & NETWORK
ADAPTER FOR UNBEATABLE
BROADBAND PERFORMANCE.
www.circuitcellar.com
Issue 131 June 2001
19
CIRCUIT CELLAR
®
Alternatively, signature bytes can be
added at various points in the data
packet, which can also increase the
error detection percentage.
You can move beyond better error
detection into error detection and cor-
rection by trading bandwidth.
Although beyond the scope of this
article, Hamming codes can correct
all 1-bit errors and detect all 2-bit
errors in bytes. Furthermore, by using
time-dispersal coding (TDC) as well
as Hamming codes, you can recover
from the burst errors that are com-
mon to RF data communication.
COMPLIANCE ISSUES
Any device that intentionally radi-
ates RF requires regulatory compli-
ance of some sort. If you are a hobby-
ist and just want to mess around in
the experimental mode, you probably
don’t have to worry much, as long as
you use the basic design presented
here and a one-quarter wave antenna.
All bets are off if you add a power
amp and/or a high gain antenna.
If you’re working on a product
application that eventually will be
mass-produced and sold, you need to
be cognizant of applicable U.S. and
worldwide regulatory compliance
issues. For U.S. and European mar-
kets, certification testing is required
in an open field range with 3 m sepa-
rating the device and receiver (spec-
trum analyzer) antenna. There are
numerous labs in all parts of the
Tom Dahlin has 20 years of electronic
and microcontroller design experi-
ence. He is a design engineer in 3M’s
corporate research department. He
has written for
Circuit Cellar and
EDN. He and Don won an award in
the 1991
Circuit Cellar design contest
for their entry, “A MIDI Controlled
Sound Sampler/Playback Unit.”
REFERENCES
[1] Hougan et al, “A Miniature
Robotic System for
Reconnaissance and
Surveillance,” from The IEEE
International Conference on
Robotics and Automation, San
Francisco, CA, April 2000,
501–507.
[2] P. Rybski et al, “A Team of
Robotic Agents for Surveillance,”
Fourth International Conference
on Autonomous Agents,
Barcelona, Spain, June 2000, 9–16.
[3] RF Monolithics, Inc., ASH
Transceiver Software Designer’s
Guide
, December 12, 2000.
[4] ———,
Virtual Wire
Development Kit Manual for
DR1300-DK,
rev. B, May 12,
1999.
RESOURCE
SOURCES
PIC Assembly language
Byte Craft Limited
(519) 888-6911
Fax: (519) 746-6751
www.bytecraft.com
TR-3000
RF Monolithics, Inc.
(800) 704-6079
(972) 233-2903
Fax: (972) 387-8148
www.rfm.com
SX
Ubicom, Inc.
(650) 210-1500
Fax: (650) 210-8715
www.ubicom.com
SOFTWARE
The code is available on Circuit
Cellar
’s web site.
world that perform these tests
(approximately $2K to $10K depend-
ing on the lab and amount of services
rendered.) The RFM Virtual Wire
Development Kit Manual
contains an
excellent section on compliance with
several references to regulations, stan-
dards, and agencies. [4]
YOUR TURN
Well, there you have it. Armed with
the information we’ve provided, you
should be able to successfully imple-
ment a short-range wireless data link
using the RFM chip. It’s exciting that
the black art of UHF RF design has
been reduced to a chip level solution
that allows designers to use this tech-
nology without a comprehensive
background in RF. Good luck with
your applications!
I
Authors’ note: The opinions and
ideas presented in this article are
those of the authors and not necessar-
ily of their employers.
software since 1978 and programming
since ’69. He has a Ph.D in Computer
and Information Sciences from
University of Minnesota, but it hasn’t
held him back much. Don is current-
ly a vice president at MTS Systems.
He has about 60 publication credits.
Key Specifications for Scout Robot
Here are some key specifications for the scout robot
(a)
and its internal data radio
(b)
. For more information, visit
the University of Minnesota web site listed in the Resource section.
Size
Approximately 38 × 110 mm
Weight
250 grams
Propulsion
Geared DC servo motors, one per wheel
Power
Eight Lithium batteries, Kodak K58L
Payload
CMOS video camera and 915-MHz video transmitter
Sensors
Dual-axis magnetometer, dual-axis accelerometers
Special feature
Ability to hop by winding up a spring steel tail and releasing it to slap the floor
Operating frequency
433.92 MHz (fixed)
Modulation
OOK (on/off keying)
Antenna impedance
50
Ω
Data rate
2.4 kbps
Transmit power
Approximately 1 mW
Typical range
Up to 50 m
Power supply
2.7 to 3.5 VDC
a)
b)
Don Krantz has been designing
microcontrollers and writing 8-bit
20
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
ike many engi-
neers, I’ve accumu-
lated a collection of
used test gear over the
years, including a variety of oscillo-
scope plug-ins and a couple of main-
frames. Although repairing gear can
be educational and rewarding in itself,
my main reason for buying it is to use
it, so I’ve always wanted to run a
quick, but comprehensive functional
check prior to purchase. Some ’scopes
(notably Tektronix’s 7000 series) come
with built-in amplitude calibrators
that are sufficient for this purpose,
but not all equipment has this fea-
ture, and what if the calibrator
doesn’t work?
Tekronix used to make a wonderful
calibration instrument, PG506, that
did all I wanted and more, but when
it turns up used, it’s still rather
expensive and requires a TM500
series power module, making the
ensemble bulky. I finally gave up
looking for a PG506 and decided to
design a simple instrument, with
functionality between an in-scope cal-
ibrator and a PG506, to serve both
checkout and calibration purposes.
DESIGN PHILOSOPHY &
OBJECTIVES
For simplicity, I decreed that the
output would be a crystal-derived 1-
kHz square wave. Taking a cue from
Tek’s in-scope calibrators, I decided
that the unit should produce a display
four divisions high and, like the
PG506, be able to do so on any verti-
cal setting from 1 mV/division to 5
V/division in a 1-2-5 sequence, imply-
ing a 4-mV
PP
to 20-V
PP
output capabil-
FEATURE
ARTICLE
If you’re like Stephan,
you probably have a
closet filled with vari-
ous used test equip-
ment. Some work
well, but others
require time and effort
to fix. In order to
make these purchas-
es more beneficial,
Stephan designed a
simple tool to test the
products.
Stephan Goldstein
High-Performance
Oscilloscope Amplitude
Calibrator
l
Clock and
reference
1/2/5
Divider
15-V
pp
Square wave
1.000 kHz
5 V
pp
2 V
pp
1 V
pp
÷ 10
÷ 10
÷ 10
Decade attenuators
Main
amp
x4
Auxiliary
amp
x1.6
Main output
4 mV
pp
to 20 V
pp
into high-Z
400 µV
pp
10 2 V
pp
into 50
Ω
Auxiliary output
4 V
pp
into 50
Ω
when main
output is set to 20 V
pp
Output selector and amplifiers
Control logic
Power supply
1-V Range
100-mV Range
10-mV Range
1-mV Range
Figure 1—
This diagram shows the main functional blocks and signal flow in the calibrator. For these switch set-
tings, the main output is 20 mV
pp
(four divisions at 5 mV/division).
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
21
ity. This would realistically allow
checking up to 20-V/division sensitiv-
ity. The output rise and fall had to be
fast compared to 1 ms so the dis-
played waveform would look square,
and it had to be free of pre-shoot,
overshoot, undershoot, ringing, and
settling tails. The variability feature
of the PG506 was more complex than
I needed, as was the fast (1-ns) edge,
so I omitted these. A final require-
ment, especially critical in light of the
20-V output capability, was that the
unit be safe for use with high-speed
50-
Ω
inputs, which typically have a 5-
V absolute maximum input capabili-
ty. I didn’t want to accidentally
destroy a perfectly good piece of
equipment because of carelessness in
setting the output level.
In addition to the basic specifica-
tions outlined so far, I set several
design goals for myself. First and fore-
most, the instrument had to achieve
the necessary accuracy (all errors well
under 1%) at modest cost and using
readily available components, which
ruled out ultra-precision resistors and
other exotica. I accepted that this
would probably result in the need for
trim pots, so it was important that
the adjustment procedure be straight-
forward, without interactions.
The design had to be simple to
understand and debug, tolerate over
250 pF of capacitive loading (6
′
of
cable plus a scope input), and be able
to survive an indefinite short circuit
on the output. Range switching was
to be “cold” (i.e., only DC control sig-
nals allowed on front-panel switches
and AC signals had to stay on the
board (except for outputs!)). Because
most oscilloscopes still require AC
power, it seemed that battery-powered
operation was unnecessary.
FUNCTIONAL DESCRIPTION
Figure 1 shows the system’s archi-
tecture. The clock and reference sec-
tion produces a precise 5-V
PP
(0 to 5 V),
1-kHz square wave with rise and fall
times under 250 ns. Attenuated ver-
sions of this signal are produced in
the 1-2-5 divider. One of the divider’s
three outputs is selected, buffered,
and sent to the decade dividers.
Additional switching directs the
appropriate decade’s output to the x4
main output amplifier. A second x1.6
output amplifier is active only when
the 5-V range is selected.
REFERENCE SQUARE WAVE &
MAIN DIVIDER
Figure 2 shows the clock, precision
square wave generator, and 1-2-5
divider and selector. The master 5-V
reference is U7, an AD586KN. This
low-drift Zener-based reference has a
5-mV maximum untrimmed output
error, which is only 0.1% of the basic
5-V signal. An optional trim pot can
adjust the calibrator’s overall accuracy
to compensate for gain errors accumu-
lated in the signal chain.
The 5-V reference signal goes to one
input of SPDT analog switch U6
(ADG419BN); the switch’s other input
is grounded. This switch is driven by
a 1.000-kHz square wave from the
clock circuitry composed of
74HC4060 oscillator/divider U5,
4.096-MHz crystal X1, C5, C6, R3,
R4, and U4C (one-quarter of a
74HC86 exclusive-or gate). U6’s out-
put is a precise 5-V
PP
square wave
Figure 2—
A crystal-controlled 1-kHz oscillator driving an analog switch generates a 5-V square wave by alternately routing the reference output or ground to the AD711
buffer. The multiplexer selects the appropriate divider string tap to produce a 1-, 2-, or 5-V square wave. R11, R12, and R17 ensure that the driving source resistance seen by
the next stage is constant regardless of the amplitude. The 0-V position (multiplexer input D2) is used during instrument calibration.
22
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
with no offset. Although U6’s inputs
can never go below ground, I powered
its negative supply terminal (pin 7)
from the –5-V supply to reduce
switching time. S2A and S2B are used
only during calibration, and are left
open for normal operation.
U8, an AD711JN, is the reference
square wave buffer. Its input is slight-
ly attenuated by the resistive divider
composed of the on-resistance of U6
and resistor R8, but the error intro-
duced is negligible. C10 cleans up the
waveform by removing charge-dump-
ing artifacts created by U6’s switch-
ing, and R8 provides a DC path for
U8’s input while U6 switches states.
R9 reduces the offset error caused by
U8’s input bias currents by providing
an impedance to the inverting input
roughly equal to that seen by the non-
inverting input. Although this isn’t
necessary with a JFET-input amplifier
such as the AD711, I used this
approach throughout the design to
give myself the freedom and opportu-
nity to try non-FET op-amps.
Resistors are cheap.
The amplitude error caused by the
U6-R8 divider amounts to about
–0.002%, well below the observable
level. The AD711’s 2-mV maximum
offset causes no amplitude error, and
at 0.04% of the total signal, its contri-
bution can be ignored, although I did
include the option for an offset trim.
Figure 3—
A series of buffers and precision attenuators creates copies of the input divided by 1, 10, 100, and 1000. The buffers provide a low source impedance for all sig-
nals; the resistances at each buffer's inverting and non-inverting input are matched. R56 provides a DC path for U10's input current when U9 switches.
Figure 4—
A final multiplexer passes the appropriate decade’s output to
the two composite output amplifiers. The main amplifier (bottom) is
always active, and the high-power (20-V
PP
, 50-
Ω
output impedance, top)
amplifier is enabled only when the 5-V/division range is selected. You
can eliminate U15 and connect U14’s outputs directly to R52 if you find
this feature unnecessary.
24
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
You may wonder why I went to the
trouble of producing both a 5-V refer-
ence and a 5-V logic supply; why not
use an accurate 5-V reference as the
74HC4060’s supply and use its 1-kHz
output directly? I considered this, but
rejected the idea when I looked at the
transient settling of precision 5-V ref-
erence ICs. The ’4060 will have sup-
ply switching transients at 4.096 MHz
and all its sub-multiples. Precision
references are not supply regulators,
and have relatively poor transient
response, even with bypassing, so a
buffer would have been needed for the
supply. My approach adds one analog
switch and an inexpensive 5-V regula-
tor and ensures clean waveforms with
no hair pulling because it keeps power
and reference well separated.
Five 1.00-k
Ω
resistors (R13–R16 and
R18) form the main divider string.
The buffered reference 5-V square
wave is applied at the top of the
string, producing a 2-V square wave at
the junction of R15 and R16 and a 1-V
square wave at the junction of R16
and R18. One of these three signals is
selected by analog switch U9
(ADG444BN). R11 and R17 equalize
the output impedance at each tap of
the divider string. Again, this isn’t
necessary because I used an FET-input
op-amp to buffer U9’s output, but it’s
a habit. One of U9’s switch sections is
grounded through impedance-match-
ing resistor R12; this path is selected
during calibration.
Errors in the divider string con-
tribute directly to overall instrument
accuracy because there’s no simple
way to trim the 1-, 2-, and 5-V ranges
individually. One percent tolerance
resistors will give a comparable
amount of error, which is already bet-
ter than you can visually resolve on
most oscilloscope displays (typically
3%). This can be improved by match-
ing five resistors out of a batch. I was
able to find a source for 0.1% surplus
resistors for under $0.20 each, so I
took the easy way out.
DECADE DIVIDERS
U10 through U13 and their associ-
ated resistors make up three series-
connected precision 10:1 dividers (see
Figure 3). Although this may look like
an extravagant use of components,
there’s a good reason for doing it this
way; it’s much easier to calculate (and
find) the needed resistor values
because the decades don’t interact.
U10 buffers the signal from the 1-2-5
divider, with R56 providing a DC path
during U9’s switching. R22 and R24
provide the bulk of the attenuation
for the first decade. Because R22 is
9.09 K
Ω
(not the required 9.00 K
Ω
), it
gets tweaked down 1% by R23. R23’s
tolerance isn’t critical; a 5% resistor
would only contribute an error of
0.05%. R20 is the bias current com-
pensator. The first decade divider’s
output is a square wave of 100-, 200-,
or 500-mV amplitude, depending on
which of the 1-2-5 divider’s outputs is
selected. Note that the output imped-
ance is fairly high at about 900
Ω
(attenuator output was buffered so
that its output impedence had no
deleterious effect).
The two remaining decade dividers
are identical, with buffers driving a
resistive attenuation network, and the
last decade’s output is also buffered.
This results in four buffered signals,
one of which will be selected and
passed to the main output amplifier.
Each buffer has the provision for off-
set nulling, although this is really
only necessary in the last two decades
as each decade attenuates the offset of
the one(s) before it. No adjustment is
required if you can do without
absolute DC accuracy.
The decade dividers are the second
main source of instrument error, and
unfortunately this error accumulates
as the signal travels down the chain.
A little time spent matching resistors
here can yield big dividends in overall
accuracy, or just use 0.1% resistors for
the 1.00 K
Ω
and 9.09 K
Ω
values and
don’t worry about it.
OUTPUT AMPLIFIER
The preceding circuitry develops
precise square waves with amplitudes
from 1 mV
PP
to 5 V
PP
(see Figure 4).
Because the goal is a 20-V
PP
square
wave (four divisions at 5 V/division), a
gain-of-four output amplifier with low
input offset voltage, high slew rate,
clean signal dynamics, and at least 40
mA of output drive is needed. It has
The red/black banner is a trademark of Texas Instruments. 39-6800
Join in the latest revolution: ultra-low-power Flash MCUs at ultra-low prices from
Texas Instruments. The MSP430 is the ultra-low-power solution for mixed-signal processing.
The F1101, a Flash MCU with a modern 16-bit RISC architecture, combines TI’s expertise in
analog and digital signal processing. Its ultra-low power consumption makes the F1101 ideal
for battery-powered applications such as utility metering, intelligent sensing and portable
measurement. On-chip emulation simplifies application development. Best of all, all of the
MSP430 devices, including the F1101, are source code compatible.
MSP430F1101: a 16-bit RISC
Flash MCU for only $0.99
■ Ultra-low power consumption –
250-µA active mode, 0.8-µA standby
mode at 2.2 V (typ.)
■ Integrated analog comparator ideal for
precise mixed-signal measurement
■ 16-bit RISC architecture enables new
applications at a fraction of the code size
■ 16-bit PWM timer allows highly flexible
multichannel capture and compare
■ In-system programmable Flash
permits last-minute code changes and
field upgrades
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
27
to be short circuit proof and must
remain stable with several hundred
picofarads of capacitive loading (3
′
of
50-
Ω
cable is about 100 pF).
I could not find a single device to
meet all these requirements, so I used
a composite amplifier as the output
stage. In a composite amplifier, the
input and output functions are per-
formed by distinct circuits which are
coupled together to function as a sin-
gle “super-amplifier,” combining the
best characteristics of each device. In
this case, the input stage is U16 and
the output stage is part of U17.
U14, another ADG444 quad analog
switch, selects the appropriate decade
output and presents this signal to
U16, an AD744 BiFET op-amp, a
decompensated (faster) version of the
AD711. This gives a little more speed
than an AD711 and will be quite sta-
ble because the composite amplifier’s
gain is 4×. One half of U17, an
AD815AY ADSL driver, drives the
load. This device has high output cur-
rent capability, is extremely fast, and
easier to heatsink than a DIP-type
package. (It will dissipate nearly 1 W
under some conditions, so this is a
real concern.) U17 operates inside the
loop at unity gain; the overall amplifi-
er gain is set by R43 and R42 (with a
tiny bit of fudging provided by R44) to
be precisely 4×. Gain error here
affects every range equally, so R44
isn’t needed, and the error can be
compensated by tweaking the master
5-V reference. However, using
matched (or 0.1%) resistors here and
including R44 makes it possible to
build a no-adjustments instrument
with errors much less than 1%.
The AD744’s input offset voltage is
another error source. I’ve shown pro-
vision to null this using R41,
although this adjustment is actually
redundant (see the calibration proce-
dure). The DC path to ground provid-
ed by R37 is only needed during the
calibration procedure if R41 is used.
The calibrator’s output impedance
is set to 450
Ω
by the parallel combi-
nation of R45 through R48. This pro-
duces negligible (–0.045%) attenua-
tion when checking typical high
impedance (1-M
Ω
) oscilloscopes and
forms a 10× divider when loaded by a
50-
Ω
scope input, limiting the maxi-
mum available signal in that case to a
safe 2 V
PP
. This loss of signal ampli-
tude isn’t really an issue because 50-
Ω
oscilloscope inputs are generally lim-
ited to just a few volts. Exceeding this
causes some very expensive damage.
The high output impedance also pro-
tects the calibrator’s output against
indefinite shorts to ground or either
supply, and ensures that it won’t
oscillate with capacitive loading. The
output resistance is the last major
error source, and even then is only
problematic when working with 50-
Ω
’scopes. Here again 0.1% resistors for
R45 and R48 made life easier.
There’s the potential for a lot of
power dissipation in the output resis-
tors. In the worst case (i.e., output
shorted to negative supply, 20-V
PP
set-
ting, 4-MHz clock disabled by S2A,
and U17a’s output at 20 V), it could
total almost 1.4 W. With the instru-
ment operating at its normal 50%
duty cycle driving a 50-
Ω
load to
Figure 5—
Range selection logic is straightforward. I
included the LED as a reminder when the high-power out-
put is selected. Increasing R19 would reduce the ~0.5-V
drop in the 5-V supply (VQ5) when the 5 V/division setting
is selected, although the unit operates fine with the
reduced supply voltage. The variation was unnerving until I
realized that R19 and R2, along with U4D’s output resist-
ance, created a voltage divider that affected VQ5! If I had-
n’t already drilled the panel when I found this, I would have
eliminated the LED and the problem.
28
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
ground, the maximum dissipation in
the R45 and R48 is 360 mW each. I
used 0.5-W resistors to provide a safe-
ty margin for normal operation,
although permanent shorts to ground
or the supplies during adjustment are
never a good idea.
The one shortcoming of the 450-
Ω
output impedance and 20-V maxi-
mum signal is that the unit can’t pro-
duce a four-division-high display
when driving a 50-
Ω
input at 1-V/divi-
sion, typically the highest deflection
factor. U15, U18, and the other half of
U17 form a second composite amplifi-
er that is only active when the main
output is 20 V
PP
. The gain of this aux-
iliary circuit is 1.6, and its output
impedance is 50
Ω
, so a 50-
Ω
scope on
1 V/division will display a four-divi-
sion-high signal. Because the overall
gain is lower, an AD711 is appropriate
for U18.
An offset adjustment isn’t needed
here because the signal is 4 V
PP
at its
input. Output resistors R50 and R51
can also dissipate a good amount of
power—0.5-W parts are again called
for, and should have no worse than
1% tolerance.
The main amplifier’s 450-
Ω
output
impedance doesn’t match 50-
Ω
cables.
This mismatch doesn’t become criti-
cal until the signal’s rise time is com-
parable to or shorter than twice the
propagation time of the cable. With a
250-ns rise time, matching isn’t a
worry as long as the cable length is
much less than 80
′
.
CONTROL LOGIC
A handful of AND gates selects
which of the 12 possible square waves
(4 mV
PP
to 20 V
PP
) appears at the cali-
brator’s main output (see Figure 5).
All gate inputs are pulled up to the
logic supply by 10 K
Ω
resistors in net-
works RS1 and RS2. U4a’s output is
normally low, so the 12-position
rotary switch selects the desired set-
ting by pulling the appropriate gate
inputs low. U1–U3 decode the state
and close the appropriate switches in
U9 and U14. U4d enables the second
output amplifier when the 5-V setting
is selected and can be used to turn on
an optional LED to signal this fact,
and U4b and S2c ground the input to
the decade divider (through U9) for
calibration purposes.
POWER SUPPLY
Most analog circuitry uses 15 and
–5 V, with 24 V needed for the com-
posite output amplifiers and 5 V for
the clock oscillator and control logic
(see Figure 6). The 24- and –5-V sup-
plies need to provide a decent amount
of current, about 100 and 55 mA,
respectively, at full load (2-V
PP
square
wave into 50
Ω
). The current require-
ments become more symmetrical
when the calibrator drives a high-
impedance load. The 15-V supply only
needs to handle about 25 mA, and the
load on the 5-V supply is negligible.
The large difference between posi-
tive and negative supply voltages
posed an interesting challenge. A
transformer with dual 24-V secondar-
ies would be just right for the positive
side, but would cause the –5-V regula-
tor to dissipate over 2 W and exceed
the negative regulator’s absolute max-
imum input voltage. On the other
hand, 12-V secondaries would be suf-
ficient on the negative side, but inade-
quate for the 24-V supply. A trans-
former with dual 24-V center-tapped
secondaries resolved this problem.
The positive supply uses a full-wave
bridge across the secondary and the
negative supply uses a center-tapped
full-wave rectifier arrangement.
The 50- to 100-mA supply currents
mean the main filter capacitors need
to be large to keep the ripple voltage
manageable and ensure that the 24-V
regulator doesn’t drop out. The 24-
and –5-V regulators dissipate around
0.5 W under a full load, so each uses a
TO-220 package with heatsink to
keep down the temperature.
The 15-V supply is derived from the
24-V supply with a TO-92 regulator.
A small heatsink is a good idea, and
the 5-V logic supply is obtained from
the 15-V supply using a second small
Figure 6—
The power supply uses a dual 24-VCT transformer and three terminal regulators to
generate the necessary voltages. I used a small (LM340LAZ-15, TO-92 case) device for U20
that became too hot, so I stuck a heatsink on it. A regulator in a TO-220 package would have
been a better choice. There are two 5-V outputs: VP5 powers the 4-MHz/1-kHz oscillator and
VQ5 supplies the control and signal switching. The dual 5-V supplies may be overkill, but they
help keep 4-MHz noise out of the analog section at the lower output settings.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
29
more than sufficient accuracy, espe-
cially with 0.1% resistors in the criti-
cal locations. Note that unless you
use a calibrated DVM with at least
4.5-digit resolution, you may end up
adding error with the fourth step! If
you don’t have access to such an
instrument, it’s better to eliminate R7
and skip step four; overall accuracy
will still be better than 1%. If you
choose to go without adjustments,
simply omit all the trim pots. The
procedure below assumes that the
basic functionality of the unit has
been verified.
Step one: If R41 is used with S2A
closed, S2b open, and S2c closed, null
the offset of the main output amplifi-
er using R41. It may be helpful to
jumper across R37 during this step to
reduce the effects of U16’s low-fre-
quency noise current. The position of
S1 doesn’t affect this adjustment. Skip
this step if R41 isn’t used.
Step two: With S2A closed, S2B
open, and S2C closed, null the offset
of square wave buffer U8 (TP3) using
R10. The position of S1 doesn’t affect
this adjustment.
Step three: With S2A
closed, S2B open, S2C
open, and S1 set to 1 V,
null U10’s offset using
R21 while measuring at
the main output. Change
S1 to 100 mV and null
U11 using R26. Change
S1 to 10 mV and null
U12 using R31. Finally,
change S1 to 1 mV and
null U13 using R36.
These adjustments cor-
rect for residual offset in
the main output amplifi-
er, which explains why
R41 and step one are
redundant.
Step four: With S2A
closed, S2B closed, S2C
open, and S1 set to 5 V,
adjust R7 for 20.000 V at
the main output. Verify
8.00 V at the auxiliary
output. Then verify the
main output voltage for
the other settings of S1.
(If the instrument will
be used primarily with
50-
Ω
loads, this step should be per-
formed with a load connected, and
the voltage across the load should be
adjusted to 2.000 V using R7).
Step five: Return S2A, S2B, and S2C
to their open positions. Put a small
dab of nail polish on each pot’s adjust-
ment screw to prevent inadvertent
movement.
Have fun!
I
regulator. This way the higher voltage
parts of the circuit power up first, pre-
venting ESD diodes from turning on
and latching up. The logic supply is
further split in two parts, with the
noisy side running U5 (the 4-MHz
oscillator) and the quiet side serving
all other CMOS needs through the
low-pass filter formed by R2 and the
various bypass capacitors sprinkled
around the board. Diodes D1, D2, D5,
D6, and D7 provide discharge paths
during power down to prevent latch-
up and to protect the regulators from
excessive reverse voltage.
I briefly considered using switching
regulators for the supplies to simplify
the transformer choice and improve
electrical efficiency, but I rejected this
approach because I didn’t want to
have to worry about potential noise-
injection problems. Mouser had the
transformer I needed.
CALIBRATION
Calibration requires only an accu-
rate DVM. Most or all of these steps
can be ignored while still providing
Figure 7—
These attenuators can be used on the main output to pro-
vide low-level signals. Although each has a 50-
Ω
output impedance, I
chose the resistor values assuming outputs would drive a high imped-
ance load. You can use a five-turn loop in series with 50
Ω
to produce
a four-division signal of 1 µA/division to 50 mA/division in a 1-2-5
sequence. Multiple turns allow a high apparent current even though the
main amplifier has a high (450-
Ω
) output impedance.
SOURCE
7000 series, TM500, PG506
Tektronix Inc.
(800) 835-9433
www.tektronix.com
Stephan Goldstein received BSEE and
MS degrees from MIT in 1977 and
1979, respectively. Since 1982 he has
worked for Analog Devices in
Wilmington, MA in a variety of
capacities. As Staff Engineer there, he
designs high-speed custom analog
bipolar ICs used in the automatic
test equipment industry. You may
reach him by e-mail at steve.gold-
stein@analog.com.
30
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
obbies often pro-
duce the inspira-
tion for some of the
most interesting proj-
ects. This project is the result of the
cross-pollination of my interest in
embedded systems and love of
SCUBA diving. It’s important to men-
tion that SCUBA has inherent risks,
however, these risks may be mini-
mized with proper training from any
one of the major certifying agencies.
With that said, let’s begin at the
end—the completion of a dive.
Following a dive, it is customary
practice to log it. This typically con-
sists of recording the maximum depth
reached, elapsed dive time, air con-
sumed, water temperature, and post-
dive pressure group (a diving concept
that is beyond the scope of this arti-
cle) in a logbook. Often I wanted to
record more specific information.
That’s when the idea of designing a
diving data logger, which I dubbed the
DiveMate (see Photos 1, 2, and 3),
began to take form.
I planned to create a logger that
records depth and temperature meas-
urements every few seconds and
allows the data to be uploaded to a
PC following the dive. The data then
may be plotted versus time, resulting
in a concise, easily interpreted chart.
Then, this chart can be printed and
placed in the logbook along with the
rest of the information, providing a
detailed record of the dive.
SPECIFICATIONS
Like many projects, the specifica-
tions for the DiveMate evolved during
development. Originally, the main
requirements were to be able to meas-
ure and display the current depth and
temperature and store periodic meas-
urements of these quantities for
retrieval following the dive(s). These
broad requirements were subsequent-
ly refined into mode specifications.
The DiveMate has four main
modes: Surface Interval, Dive,
Communication, and Shutdown.
During Surface Interval mode, the
DiveMate counts and displays the
amount of time elapsed since it was
powered up or since the last dive,
whichever is more recent. From this
state, the DiveMate transitions to
Communication mode if it receives a
communication request via the serial
port. Transition to Communication
mode must occur within less than 1 s
of receipt of the request.
Surface Interval mode transitions to
Dive mode if the DiveMate measures
a depth of greater than 5
′
. The test for
this transition must be made no less
frequently than every 10 s to avoid
missing more than a few seconds of
data at the beginning of the dive. This
trade-off allows the DiveMate to oper-
ate at reduced power during Surface
Interval mode by requiring only that
the pressure sensor (depth measure-
ment device) be powered for a short
instant during the 10-s interval. The
device enters Shutdown mode if a
given period of time elapses without
entering Dive mode.
During Communication mode, the
DiveMate operates as a slave device
to a master RS-232 serial host (i.e.,
desktop computer), which initiates all
communication. The host performs
configuration of the device and
queries it for information. Shutdown
mode is initiated if no communica-
tion occurs for 5 min. or if the imme-
diate shutdown command is issued
via the serial port.
FEATURE
ARTICLE
It’s June, and David is
heading to the beach.
SCUBA divers typical-
ly chart their dive data
the old-fashioned
way, with pencil and
paper. But, engineers
always look for a
challenge, right?
Combining his talents,
David devised a sub-
mersible data logger
that uploads to a PC.
David Smith
A SCUBA Dive Monitor
h
Under the Sea
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
31
In Dive mode, the DiveMate meas-
ures, stores, and displays depth and
temperature every 2 and 10 s, respec-
tively. In order to time stamp this
data as it’s stored, a means for keep-
ing time, even during shutdown, is
required. Because divers may go on
extended trips, the DiveMate must be
able to store up to five days worth of
data at approximately 3 h of diving
per day. The transition to Surface
Interval mode occurs when the device
reaches a depth of 5
′
or shallower.
Shutdown mode may not be excit-
ing, but it’s essential. When entering
Shutdown mode, the DiveMate pow-
ers down its hardware to save battery
life. From Shutdown mode, the device
transitions to Surface Interval mode
during powerup.
The electronics must be housed in a
waterproof enclosure capable of with-
standing more than five atmospheres,
or 74 psi, of pressure. This is the
approximate pressure experienced at
the maximum recreational dive limit
of 130
′
. Furthermore, the pressure
sensor must be exposed to external
water pressure without allowing the
enclosure to flood. Similarly, the tem-
perature sensor must be exposed to
the external water temperature via an
interface with a low thermal time
constant in order to prevent a delay in
the accurate measurement of the
water temperature. Finally, the enclo-
sure must allow a contained display
to be visible.
DETAILS
The heart of the DiveMate is the
extremely versatile, 8-bit Atmel AVR
microcontroller. The AVR AT90S4433
is a 28-pin RISC device with 4 Kb of
flash memory for code
storage, 128 bytes of
SRAM for user data, and
256 bytes of EEPROM also
for user data. One impor-
tant detail to note is that
the AVR’s instruction
word size is 16 bits, mean-
ing that it can hold at
most 2000 assembled
instructions.
A nice feature of this
micro’s flash memory-
based program is that it is
(off-line) in-system programmable.
This means no more tedious burn-
and-turn gymnastics with the
EPROM programmer and UV light
source. The ’4433 has 32 general-pur-
pose registers, a UART, SPI port, 10-
bit ADC, 8-bit counter, 16-bit count-
er, watchdog timer, and on-chip ana-
log comparator.
The microcontroller uses a Harvard
bus architecture (separate instruction
and data buses), and executes the
majority of its instructions in a single
clock cycle. This provides up to
8 MIPS at a maximum 8-MHz clock
frequency. The ’4433 also features a
linear address space with no address
paging required. Additionally, it has a
full-featured, vectored interrupt con-
troller like the ones typically seen on
higher-end microcontrollers. [1] For a
solid introduction to the Atmel AVR
microcontroller, read “Working with
AVR Microcontrollers,” by Stuart Ball
(Circuit Cellar 127).
For the DiveMate to function as
specified, it must be capable of accu-
rately measuring
depth. Because the
pressure of the sur-
rounding water is
proportional to depth,
a submersible pres-
sure sensor with a
maximum pressure
rating of at least
74 psi is required for
operation to 130
′
.
An investigation of
the available sensor
options led to the
conclusion that there
are two main alterna-
tives. The first class
of sensors includes signal condition-
ing on-chip and produces a calibrated,
temperature-compensated output pro-
portional to the detected pressure.
The second alternative is a class of
uncompensated sensors that typically
requires biasing via a constant current
source as well as external temperature
compensation. As is usually the case,
the compensated sensor is simpler to
use, but more expensive than an
uncompensated sensor.
Within the two larger classifica-
tions, there are three subclassifica-
tions—differential, gauge, and
absolute. A differential sensor is typi-
cally a two-port device that allows
separate pressures to be applied to
each port, resulting in an output that
is proportional to the difference
between the input pressures. A gauge
sensor appears to be a one-port device,
however, it is little more than a dif-
ferential sensor in which the missing
port is replaced by an opening
exposed to ambient pressure. An
absolute sensor is a true one-port
device. It produces an output that is
proportional to the difference between
the input pressure and an on-chip vac-
uum cavity, which provides an
absolute reference.
After examining the silicon pres-
sure sensors available, I chose the
MPX5700GP. This compensated sen-
sor has a maximum operating pres-
sure of 101.5 psi, sensitivity of 44.14
mV/psi, accuracy of 2.5% of full scale
output, and a full scale output span of
4.5 V. The sensor requires a 5-V power
supply. Additionally, it contains a flu-
Photo 2—
With the cover open, the prototype’s layout and components are
easily observed.
Photo 1—
The initial DiveMate prototype is ready for action. This is a
top view with the cover closed.
32
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
orosilicone gel that provides
protection for the sensor die
from the environment. [2] The
gauge configuration was chosen
mostly because of availability
and smaller package size.
As with pressure, a dedicated
sensor is required for tempera-
ture measurements. Some tem-
perature sensing alternatives
include thermistor circuits,
semiconductor analog sensors,
and digital temperature sensors.
The first two options require
calibration and analog-to-digital
conversion via the microcon-
troller’s onboard ADC. Although this
is feasible, the third option offers a
simpler alternative that is less suscep-
tible to noise and requires virtually
no calibration.
The DiveMate employs the Dallas
Semiconductor DS1621 direct-to-digi-
tal temperature sensor for three rea-
sons. The DS1621’s very low 1-µA
standby current is a boon for battery-
powered applications. The 8-pin
device communicates with the AVR
via a two-wire bus interface (equiva-
lent to the I
2
C protocol) which it
shares with two yet-to-be-discussed
components. The DS1621’s accuracy
is 0.5°C over a –20° to 105° range,
which is more than adequate for this
application. [3] But, if you want more
accuracy, the aforementioned analog
sensor option is the best choice.
In order to provide time and date
stamps for the data, the DiveMate
includes a Dallas DS1307 real-time
clock. This 8-pin chip uses an exter-
nal 32.768-kHz crystal and maintains
accurate time and date information
even when turned off. It interfaces
with the AVR via the same
two-wire bus as the tem-
perature sensor. The chip
features 56 bytes of non-
volatile RAM, although the
DiveMate doesn’t use it. [4]
An Atmel AT24C256
serial EEPROM is included
to provide 32 Kb of non-
volatile data storage. This
IC is rated at one million
write cycles with a 100-
year data retention rating.
Similarly to the tempera-
ture sensor and real-time
clock, this EEPROM inter-
faces with the AVR via the two-wire
bus. Judicious choice of data struc-
tures allows a single EEPROM chip to
store the specified number of dives
(five days, 3 h per day) at the desired
measurement intervals (2-s depth, 10-
s temperature). If you need greater
storage, up to four Atmel AT24C256
chips could be located on the two-
wire bus to provide up to 128 Kb of
data storage. [5]
An 8 × 2 LCD provides immediate
feedback of depth, temperature, sur-
face interval time, and communica-
Photo 3—
The view of the bottom shows the pressure sensor and its interface
to the outside world.
Figure 1—
The DiveMate’s
schematic illustrates the sim-
plicity of the hardware design.
34
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
tion link status, depending on the
operation mode. The display’s 4-Bit
Bus mode makes it a feasible option
even on microcontrollers with low
pin counts. Likewise, its small size
makes it suitable for use in space-con-
strained devices.
Transistors Q1 and Q3 along with
switch S1 comprise a power control
circuit (see Figure 1). You can activate
the DiveMate, but the AVR powers
down the device. To activate, you
press the switch, which powers the
LDO regulator, which in turn powers
the rest of the DiveMate circuitry.
Immediately after powerup, the AVR
sets the output connected to the gate
of Q3, an N-channel FET, high. This
pulls down the gate of Q1, a P-chan-
nel FET, activating it and bypassing
S1 so that the circuit remains pow-
ered even when the switch is released.
At this point, the AVR can power
down the circuit at any time by
pulling the gate of Q3 low.
Although not electrical in nature,
one of the most challenging aspects of
this project was finding a method to
enclose the electronics that would
keep them dry and intact at high pres-
sures and allow the pressure sensor
access to ambient water pressure. An
early idea that held promise involved
potting the entire electronics assem-
bly in an epoxy resin, rendering the
electronics waterproof and highly
pressure-resistant. The drawback is
that there would be no access after
the electronics were potted; some-
thing as simple as a battery change
would be nearly impossible.
The solution to this challenge came
in two parts. I’d like to thank my wife
Christine for finding the perfect
enclosure while flipping through a
diving supply catalog. The Otter Box
is a small (approximately 4.5
″
× 3
″
×
1.5
″
), clear plastic enclosure with an
O-ring seal that’s rated watertight up
to 100
′
. Although short of the 130
′
recreational dive limit, the box is
ideal in all other respects.
The second part of the enclosure
problem was how to provide the pres-
sure sensor access to external water
pressure without causing the box to
leak. Dan Andrews, a mechanical
engineer whom I work with, provided
the solution. He created a small,
threaded metal orifice that screws
into a threaded hole drilled through
the plastic case. One end of a piece of
surgical tubing is placed on a fitting
inside the orifice, and the other end is
placed on a fitting on the pressure
sensor. This way, the sensor has
access to the surrounding water while
the electronics stay safe and dry.
The DiveMate’s UART and ISP pins
are multiplexed onto a common 6-pin
header, J1 (see Figure 1). An external
circuit, illustrated in Figure 2, allows
the DiveMate to connect to a PC’s
serial port via J1 to perform configura-
tion or data transfer. The primary
component of this circuit is the
Dallas DS275, a line-powered RS-232
transceiver chip. This 8-pin chip per-
forms the voltage level shifting
required to interface to a PC’s serial
port. Although not shown, header J1
also allows in-system programming of
the AVR via an external cable con-
nected to a device programmer.
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 131 June 2001
35
FIRMWARE NOTE
Although there isn’t enough space
for a detailed discussion about the
firmware, there are a few points
worth mentioning. As with the major-
ity of embedded projects, the
firmware development took far longer
than the hardware development. The
DiveMate’s firmware was written
100% in assembly. Although ideal for
interfacing to devices and writing
small, tight code, assembly isn’t well
suited for manipulating complex data
structures like higher-level languages,
such as C.
Accordingly, the most difficult rou-
tines to implement and debug were
those that deal with storing dive
record data structures. Although I
wouldn’t have had enough code space
to implement all of the features that I
included had I developed the firmware
solely in C, a C and assembly mixture
may have been feasible.
LET’S GET WET
By last September, the DiveMate
was ready for in-water trials. On
September 10, my dive buddies and I
headed off to our favorite local dive
spot, New River near Blacksburg, VA.
As we descended, I was pleased to see
the DiveMate switch into Dive mode
and begin displaying depth and tem-
perature. I was even more pleased
when the DiveMate’s depth measure-
ment matched that of the other two
depth gauges I had with me. Likewise,
the measured temperature was close
to what the redundant gauge reported.
All was well…until we hit 20
′
. I felt
and heard a sudden pop. Imagine my
horror as I observed the enclosure fill-
ing with water. A postmortem
revealed that the fitting on the pres-
sure sensor had snapped off because of
lateral force. The sensor had been
firmly lodged against the inside wall
Figure 2—
Because the RS-232 driver is required only when the DiveMate is connected to a PC, it was placed on
its own board. This frees space on the DiveMate board and reduces its operational power requirements.
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.
36
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
RESOURCES
PADI (Professional Association of
Diving Instructors)
(949) 858-7234
Fax: (949) 858-7264
www.padi.com
NAUI (National Association of
Underwater Instructors)
(813) 628-6284
Fax: (813) 626-8253
www.naui.org
of the case, which bowed slightly
under the 23 psi experienced, snap-
ping off the fitting.
After some minor modifications
that left more space between the pres-
sure sensor and case wall, it was time
for attempt number two. On
September 23, we headed back to the
river. This time we hit 40
′
and the
DiveMate was working perfectly…
until about 20 min. into the dive
when the display went out. Back on
dry land, a bit of prodding revealed
that the modified display connector
wasn’t making good contact. I fixed
this problem by hardwiring the dis-
play in place.
October 7 was the next chance to
hit the water. This time, the
DiveMate performed flawlessly
throughout the 40-min. dive. The plot
of the data downloaded following the
dive is shown in Figure 3. I gradually
reached a depth just short of 40
′
as I
followed the bottom to the center of
the river. I then ascended to a depth
of 30
′
to cruise alongside some sub-
merged trees. At the 20-min. mark, I
ascended along a rock wall to 25
′
, spy-
ing a huge catfish in a crevice. I head-
ed back down to the bottom and then
followed it to the other side of the
river. At the 33-min. mark, I surfaced
on the far side.
During the 6 min. I spent on the
surface, I swam back across to the
exit point. Then, I submerged for a
few minutes to verify that the
DiveMate would once again enter
Dive mode. I repeated the exercise
before exiting the water at about the
40-min. mark. As is evident from the
plot, the water was about 64° F.
I was able to squeeze in two more
test dives later in October before the
water got too cold to enter in a wet
suit. Each time the DiveMate per-
formed flawlessly.
FINAL COMMENTS
After my experiences developing
this project, I highly recommend the
AVR microcontroller. Its powerful,
consistent architecture makes it a
pleasure to use. Additionally, a devel-
opment system can be put together
inexpensively. The assembler and
simulator are free from Atmel’s web
site. Free plans and software for
device programmers also are readily
available on the Internet. Before
choosing a microcontroller for your
next project, be sure to take a good
look at the AVR.
Developing the DiveMate has been
a frustrating, challenging, yet reward-
ing experience. The project required a
great deal of perseverance and
patience in addition to many late
nights. Now, it’s gratifying to see it
functioning as desired under 40
′
of
water at the bottom of a dark, cold
river. The DiveMate is just one more
example that 8-bit micros can thrive
nearly anywhere.
I
David Smith is an electrical design
engineer at National Optronics. He
has been designing, developing, curs-
ing, and debugging 8-, 16-, and 32-bit
embedded systems for the past five
years. David is a licensed
Professional Engineer, and holds a BS
and MS in Electrical Engineering
from Virginia Tech. You may reach
him at dmsmith@cfw.com.
REFERENCES
[1] Atmel Corp., “8-bit AVR
Microcontroller with 2K/4K
bytes In-System Programmable
Flash.”
[2] Motorola SPS, “MPX5700
Integrated Pressure Sensor On-
Chip Signal Conditioned,
Temperature Compensated and
Calibrated,” rev. 4, MPX5700.
[3] Dallas Semiconductor, Inc.,
“DS1621 Digital Thermometer
and Thermostat,” rev. October
22, 1999.
[4] Dallas Semiconductor, Inc.,
“DS1307 64 × 8 Serial Real Time
Clock,” rev. August 18, 2000.
[5] Atmel Corp., “2-wire Serial
EEPROMs,” rev. 0670D, October
1999.
Figure 3—
The first successful in-water DiveMate trial was held in October 2000. The depth and temperature ver-
sus time plot represents the acquired data.
SOURCES
AVR AT90S4433
Atmel Corp.
(408) 436-4270
Fax: (408) 436-4314
www.atmel.com
DS1621
Dallas Semiconductor, Inc.
(972) 371-4000
Fax: (972) 371-3715
www.dalsemi.com
MPX5700GP
Motorola, Inc.
(847) 576-5000
Fax: (847) 576-5372
www.motorola.com
Otter Box
Otter Products, LLC
(888) 695-8820
(970) 493-8466
Fax: (970) 493-1755
www.otterbox.com
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,
38
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
ersonal comput-
ers are endowed
with a high visualiza-
tion and computation
capacity, but they have scarce
resources to interface with the physi-
cal world. On the other hand, many
microcontrollers have analog and digi-
tal inputs and outputs that facilitate
the relationship with the physical
world, but their visualization and cal-
culation capacity is limited.
Is it possible to take advantage of
the best microcontroller attributes
and the best PC attributes and design
a low-cost system dedicated to teach-
ing electronics? Because we were con-
vinced that the answer is yes, we pre-
pared to demonstrate it by creating
the Electronics Lab.
HARDWARE
The first step was selecting the
microcontroller and designing the
hardware. We opted for the Philips
80C552. The 80C552 is derived from
the 8051 family, meaning it has all of
the 8051 peripherals (CPU, two stan-
dard 16-bit timer/counters, full-
duplex UART, four 8-bits I/O ports,
and five interrupt vectors). And, it
adds an additional 16-bit timer/count-
er coupled to four capture registers
and three compare registers, a 10-bit
ADC with eight multiplexed analog
inputs, and two 8-bit resolution PWM
outputs. An additional 8-bit I/O port
plus one 8-bit input port shared with
the analog inputs, I
2
C bus serial I/O
port, on-chip watchdog timer, and 10
new interrupt vectors are included.
The 80C552 provides enough
resources to interface with analog and
digital real-time devices. Its analog
inputs allow you to build an analog
oscilloscope with eight probe signals.
Each PWM output supported by a
low-pass filter can become a signal
generator. The I/O ports complete the
16 outputs of the word generator and
16 inputs of the digital logic analyzer.
Also, the digital inputs can be used
by a 16-bit pattern detector that acti-
vates the COMP output when the 16
digital inputs match the combination
selected by you. The serial I
2
C port
can become an I
2
C bus controller. The
timer/counter allows you to make a
clock generator and a frequency
meter. The UART working at 57,600
bps receives commands from the PC
and periodically sends the Electronics
Lab input values so that they are visu-
alized on the monitor.
The hardware is similar to any gen-
eral-purpose microcontroller card (see
Figure 1). It uses the 80C552 with 32
KB of external RAM and 32 KB of
external program EPROM. It also con-
tains 512 bytes of EEPROM serial I
2
C
memory. The Electronics Lab can use
an 83C552 with embedded EPROM
and eliminate all of the external
memories. The presence of these
memories is justified because we plan
to reuse this card for other purposes
(e.g., microcontroller training card).
The PAL16V8 generates the *RD
and *PSEN signal, *CS signals for the
EPROM and RAM, *CE1/2 signals for
the I/O ports and the pattern detector
COMP output. A MAX232 transforms
the logic levels from TTL to RS-232
and vice versa.
The Electronics Lab has two 8-bit
output ports, S[15…8] and S[7…0],
(see Figure 2), made with two octal D-
type flip-flops (74HC377), adding 16
LEDs to monitor the outputs. These
output ports are memory-mapped at
addresses 0xD000 and 0xE000.
FEATURE
ARTICLE
When Mariano Barron
and Javier Martinez
teamed for the
Design2K Contest,
they used the oppor-
tunity to improve elec-
tronics education.
Here they explain
how they created a
teaching tool that
uses the best features
of both microcon-
trollers and PCs.
Electronics Lab
p
Mariano Barron & Javier Martinez
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
39
Two 8-bit input ports, E[15…8] and
E[7…0], are also available. They are
memory-mapped at the same loca-
tions as the output ports. Every input
port has been made with two octal
buffer driver 74HC541s; one monitors
the state of the input pins through
LEDs and the other reads the state of
the input pins through the data bus
AD[7…0] when the microcontroller
demands it. The 10-k
Ω
pull-down
resistors connected to the inputs of
the first 74HC514 ensure a low input
level when there is no signal input.
The RC filters connected to the
microcontroller’s two PWM outputs
work as low-pass filters and provide
the two analog outputs of the
Electronics Lab (see Figure 3). The RC
filters connected to the eight analog
inputs are used to limit the slew rate
during the sample interval and avoid
crosstalk from neighboring signals.
80C552 SOFTWARE
After establishing the hardware, we
had to write the programs for the PC
and 80C552 to allow simultaneous
function of the electronic instru-
ments. And, we needed programs that
enabled obtaining the maximum ben-
efit from the microcontroller and PC.
The microcontroller program was
written in C using the Keil 8051
Developer’s Kit. The program con-
tains a header, four interrupt func-
tions, an initialization function, the
main function, and six other auxiliary
functions. It fills 1600 bytes of code
memory and needs about 100 bytes of
internal RAM to store the variables.
The program does many tasks. It
polls and executes the orders sent by
the PC through the serial port and
captures the values of the Electronics
Lab’s inputs and periodically sends
them to the PC. The program also
makes the analog output signals of
signal generators A and B, makes the
clock generator’s square signal, and
refreshes the word generator’s 16 digi-
tal outputs. Communicating with the
I
2
C devices and counting the received
pulses in the frequency meter input
are the last two tasks performed by
the microcontroller program.
TEMPORIZATION
Several of the tasks executed by the
Electronics Lab require accurate tim-
ing. It’s necessary to take advantage of
the timers, which are driven by pulses
generated by the microcontroller
oscillator with the crystal (11.0592
MHz). In this way, Timer1 is used to
fix the data rate of the UART at
57,600 bps.
The Electronics Lab periodically
sends through the serial port 12-byte
packets with input information in
them. These 12 bytes contain two
bytes shared by the frequency meter,
the I
2
C bus controller and synchro-
nization information; 8 bytes with the
eight analog input values; and 2 bytes
with the state of the 16 digital inputs.
A UART high-priority interrupt is
generated every time a byte is
received or sent (see Table 1).
Signal generators A and B use the
80C552’s two PWM outputs to make
the two analog signal outputs. Every
PWM output is connected to a low-
pass filter formed by a simple RC net,
as shown in Figure 3. Direct Digital
Synthesis (DDS) generates signals.
DDS uses the timer T2 (T2H) low-
byte overflow interrupt, which is pro-
duced 900 times per second using a
T2 prescaler of 4.
This interrupt also is used by the
clock generator, frequency meter, and
80C552 to determine the moment
when a packet of 12 bytes must be
sent to the PC, as explained earlier.
The clock generator generates a
square wave of programmable period
and duty cycle. Timer T2 generates
the period supported by one internal
RAM byte (T2HH), which is increased
when the 16 bits of the T2 register
overflow. So, with T2H and T2HH
you can generate periods of up to
65,536/900, or 72.8 s. Without this
internal RAM byte, the maximum
value of the period would be as low as
256/900, or 284 ms.
Compare register CM0’s interrupt
verifies that the clock generator time
period has expired. If the duration has
finished, bytes T2HH, T2H, and T2L
are cleared to begin measuring a new
period and the clock generator output
(P4.0) is set. To clear T2HH, T2H and
T2L, the CM0 interrupt function
writes 0 in T2HH and generates a ris-
ing edge on pin P4.0, which is con-
nected to pin P1.5 (T2 reset) through
switch SW4 (see Figure 1).
Similarly, compare register CM1’s
interrupt verifies that the T
on
, dura-
tion of the clock generator period, has
expired. If the T
on
has finished, the
clock generator output (P4.0) is reset.
The frequency meter uses counter
T0 to count the falling edges applied
in P3.4 for 0.166 s (150 T2L overflow
interrupts). Every 0.166 s, the counted
pulses in TH0 and TL0 are sent to the
PC, so the result of the last six data
inputs are the pulses counted in 1 s
(frequency). For this reason, the maxi-
mum frequency that can be measured
is 6 × (2
16
– 1), or 393 kHz. This is
enough for the Electronics Lab.
Finally, the T2 low byte overflow
interrupt, produced 900 times per sec-
ond, determines if the necessary time
has passed to send the next 12-byte
packet to the PC. You determine this
time to view the signals in different
frequencies, with as much detail as
possible, on the PC monitor.
DIRECT DIGITAL SYNTHESIS
The DDS method needs a look-up
table to generate every wave and a
fixed timing reference, such as a peri-
Photo 1—
The minimum value for sine and triangle
waves is 1, not 0.
Photo 2—
The performance analyzer displays the
execution time recorded for each function as bar
graphs.
40
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
odic interrupt (T2L overflow
interrupt). The look-up table in
a DDS generator usually con-
tains data for a complete single
cycle of the waveform. Of the
five waveforms, only a table for
sine is necessary, because the
others can be calculated easily
on the fly. The DDS method
uses a phase accumulator that’s
increased by the phase incre-
ment on each incoming T2L
overflow interrupt, generating a
ramp from zero to full scale
and then wrapping back to
zero. The larger the phase
increment, the higher the out-
put frequency.
The phase accumulator
addresses the look-up table. You can
use the phase accumulator directly to
generate a sawtooth wave. To gener-
ate a square wave, compare the phase
accumulator value with half of its
maximum value so that the output is
low when the phase accumulator
value is less than the reference level
and high when it’s higher.
In Tom Napier’s two-part series,
“Applying Direct Digital Synthesis”
[1, 2], he states the output frequency
of a DDS is:
where N is the phase accumulator
length in bits. The smallest fre-
quency change you can make
is:
If f
clock
is 900 Hz and N is 16
bits, you have a resolution of
0.0137 Hz, which also is the
minimum frequency you can
generate. If you substitute N =
24, you obtain a better resolu-
tion of 53.6 µHz, but the soft-
ware becomes more complex.
Because the C compiler sup-
ports the char (8 bits), int (16
bits), and long (32 bits) but
doesn’t support 24-bit types,
you have to use a trick to make this.
To address the look-up table, you
use only the eight high-order bits of
the phase accumulator. For this rea-
son every look-up table fills only 256
bytes of code memory.
If you use the sine and triangle
waves shown in Photo 1, you can take
advantage of the symmetry in both
waves and reduce the table size to 128
bytes because
function(x) = function(256 – x) for
128
≤
x
≤
256
You can even divide the look-up table
by two, if you take into account that:
function(x) = 256 – function(128 – x)
for 64
≤
x
≤
128
Nevertheless, the triangle wave can
be calculated easily without using any
table, because
Which is the same as:
This last expression is easy to calcu-
late because division by 256 is equiva-
lent to staying with the high byte of
the result. And, the 80C552 includes
the MUL AB instruction, which
for 0 x
≥
≥
128
Photo 3—
The controls of the Electronics Lab are on the left side of the
screen. The analog and digital oscilloscopes are on the right. The I
2
C con-
trol panel appears and disappears by selecting the I
2
C button in the lower
left side of the screen.
Robert X. Cringely
And the Embedded Shall Inherit the Earth
bert X. Cringely, Silicon Valley gossip columnist
and author of the best selling book, Accidental
Empires: How the Boys of Silicon Valley Make their
To register for FREE admission to the Product Exhibits:
or bring this ad to Navy Pier Festival Hall B.
42
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
enables 254 × 2x in only four machine
cycles. The
fvalue function (see
Listing 1) allows you to generate the
sine, triangle, sawtooth, and square
waves using only one table of
65 bytes for the sine function.
How long does the 80C552 take in
all of the functions listed in the previ-
ous sections? The answer isn’t easy,
because the times depend on several
parameters, such as the number of
commands received from the PC,
kinds of generated analog signals, and
period of the clock generator.
Although we could attempt a theoret-
ical study of the time taken by the
functions, it’s easier to use the debug-
ger performance analyzer to modify
the influencing parameters
and write down the results
(see Photo 2).
When you subject the
80C552 to the maximum
working load, you obtain the
following results: The two
analog signals and clock sig-
nal use 15% of the CPU
time (
cm0_interrupt(),
cm1_interrupt(), t2_interrupt(), and
fvalue()), and the UART interrupt
uses up to 10%. The analog and digi-
tal input data readings use up to
17.5%. The auxiliary functions don’t
reach even 1% of the CPU time, and
the main function uses at least 56.5%
of the CPU time to do nothing.
PC SOFTWARE
A PC controls the Electronics Lab
and monitors its input. We use a
Windows95/98 software program cre-
ated using LabVIEW.
The main program structure is a
while loop that executes until you
press the Abort button. Every 50 ms,
the while loop examines if you have
modified any control using the mouse
or keyboard. If any control has been
modified, the action that corresponds
to that change is ordered. Usually,
this involves sending a command to
the Electronics Lab via the PC serial
port. Sometimes, for example, when
you need to save or retrieve data from
the hard disk, it isn’t necessary to
send data to the Electronics Lab.
If the word generator is running in
either Burst or Cycling mode and the
time interval between data has
Photo 5—
The lab provides the mounting surface for
practice, power source for the circuits, outputs of ana-
log and digital signal generators, and inputs for the fre-
quency meter and analog and digital oscilloscopes.
Photo 4—
The analog oscilloscope has an X-Y mode. For each
axis, you can select the difference between any two analog input
signals divided by a constant (attenuation if the constant is greater
than one, amplification if the constant is less than one).
success of embedded
designs—and configurability
is key to the right BIOS.
detailed information and a
free sample BIOS binary for
your standard
reference
design.
What do the leading silicon
vendors know about BIOS
© 2000 General Software, Inc. All rights reserved.
Full source code automatically
configured with over 400 para-
meters using BIOStart
Windows 95/98/CE/NT
Embedded, Linux, DOS, and all
x86-based operating systems
www.gensw.com •sales@gensw.com • 800-850-5755 • 425-454-5755
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
43
visualized; the y-axis represents
amplitude and the x-axis represents
time. In X-Y mode, time doesn’t inter-
vene and a signal (the difference
between any two signals selected by
you) is represented in both axes. The
X-Y mode is useful to obtain the char-
acteristic traces of diodes, transistors,
Schmitt trigger circuits, and so on, or
to draw Lissajous figures.
Signal generators A and B produce
two suitable signals for stimulating
the electronic circuit. They are easily
controlled by a mouse or keyboard,
selecting for every generator the
required signal, frequency (0.001– 100
Hz), amplitude (0– 5 V), and minimal
value (0– 5 V). You can define the
phase shift between two signal gener-
ators if they have the same frequency.
The clock generator provides a vari-
able period (20… 9999 ms) and T
ON
rectangular signal. You can synchro-
nize the clock and word generators.
The word generator is formed by a
memory of 256 words (16 bits each).
The words can be sent to 16 digital
elapsed, the while loop automatically
sends the following data to the
Electronics Lab.
If the program receives a packet of
12 bytes from the Electronics Lab, it
extracts the information correspon-
ding to the frequency meter or I
2
C
bus, the eight analog inputs, and 16
digital inputs. The information is
shown in the corresponding indica-
tors, keeping the 80C552 and comput-
er synchronized.
The program presents a screen with
the equipment controls on the left
side and the analog and digital dis-
plays on the right (see Photo 3). This
allows you to observe the low-fre-
quency signals in real time. The
graphics are drawn as the PC receives
data sent by the Electronics Lab; the
PC and lab act like an oscilloscope.
As each new value is received, it is
plotted to the right of the last value.
When the plot reaches the right bor-
der of the plotting area, it’s erased,
and plotting begins again from the left
border. At any moment, you can stop
an acquisition to examine the
received data. The horizontal axis of
the display is graduated in minutes
and seconds (MM:SS). To make the
interpretation of the input signals eas-
ier, they are shown in different colors.
You can name the 16 digital inputs
and 16 digital outputs. And, you can
hide the analog or digital signals that
aren’t necessary.
The control window in the lower
left-hand side of the screen allows you
to select the time interval (5 s in this
case). The range of values varies from
1.5 to 30 s. This control determines
the analog and digital input sampling
rate, whose value in samples per sec-
ond is 450 per control window value.
So, if the window value is 5 s, 90
samples per second are taken.
When you select the X-Y button in
the upper left side of the analog dis-
play (see Photo 3), the graphic shown
in Photo 4 appears. This button
allows you to switch between the X-Y
and Oscilloscope modes. In the latter
mode, the eight analog signals are
Figure 1—
The Electronics Lab microcontroller card is similar to any general-purpose microcontroller card. It has 32 KB of EPROM, 32 KB of RAM, 512 bytes of EEPROM, a
PAL16V8 for glue logic, and a serial RS-232 port.
Next to the I
2
C button you see the
COMP button; two columns of LEDs
appear when you select this button.
The columns enable selection of the
16 digital inputs’ logic state, which
will activate the pattern detector
COMP output.
DATA SYNCHRONIZATION
The Electronics Lab sends between
15 and 300 12-byte packets/s to the
44
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
outputs in three different ways— one
data, burst, or cycling. With the latter
two options, you can set the time
interval (20… 9999 ms) between data.
When the word generator is stopped,
you can toggle the state of each out-
put by clicking on one of the 16 verti-
cal virtual LEDs.
The Clear button clears all of the
256 memory positions and current
address control of the word generator.
Also, the eight analog
signals and 16 digital
signals of the graphic
displays are made visi-
ble. The Load and Save
buttons let you get or
keep the following in a
file: word generator
data, values of all con-
trols, names of the 16
output and 16 input
digital signals, visibili-
ty conditions of every
analog signal, and the
16 digital signals of
both displays. This
makes things like
preparing lessons that
can be reused during
class easier.
The frequency meter indicates the
frequency of a TTL or HCT-MOS sig-
nal applied to the Electronics Lab’s
frequency input. It admits signals up
to 385 kHz.
The I
2
C bus controller panel
appears over the digital display when
you select the I
2
C button (see Photo
3). This panel enables reading or writ-
ing the I
2
C chips contained in the tar-
get circuit.
Figure 2—
The output port S[0…7] and the input port E[0…7] are memory-mapped at address range 0xD000…0xD7FF. Ports S[8…15] and E[8…15] are memory-mapped at
address range 0xE000…0xE7FF
Figure 3—
Two RC filters connected to the two PWM outputs provide the two analog outputs. The eight analog inputs are connected to
RC filters to limit the slew rate during the sample interval.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
45
PC. The number of sent packets
depends on the time window you
select. The frequency meter sends a
new amount (2 bytes) every 0.166 s,
which means that every second only
six packets carry information from
the frequency meter. For this reason,
every second there are nine to 294
packets with two free bytes for other
types of information. If the frequency
meter has nothing to send but the I
2
C
bus does have information to send,
that information is sent. If neither the
frequency meter nor I
2
C bus have any-
thing to send, the 0xff value is sent in
the first byte.
The I
2
C bus information that trav-
els to the PC is coded in two bytes,
and the first byte always is a value
between 0xfb and 0xff. Therefore, to
maintain synchronization, the PC
constantly checks what is supposed to
#define UCHAR unsigned char
UCHAR code SIN_TABLE[] = {
0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03,
0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x0A,
0x0B, 0x0C, 0x0D, 0x0F, 0x10, 0x11, 0x13, 0x15,
0x16, 0x18, 0x1A, 0x1C, 0x1E, 0x20, 0x22, 0x24,
0x26, 0x28, 0x2B, 0x2D, 0x2F, 0x32, 0x34, 0x37,
0x39, 0x3C, 0x3F, 0x41, 0x44, 0x47, 0x4A, 0x4D,
0x4F, 0x52, 0x55, 0x58, 0x5B, 0x5E, 0x61, 0x64,
0x67, 0x6A, 0x6D, 0x70, 0x74, 0x77, 0x7A, 0x7D,
0x80};
UCHAR fvalue(UCHAR angle, UCHAR wave)
{
/* wave: 0=SINE, 1=TRIANGLE, 2=SAWTOOTH, 3=SQUARE */
bit bf;
if(wave == 0) /* SINE */
{
if((angle & 0x40) != 0)
angle = - angle;
bf = angle & 0x80;
angle = SIN_TABLE[angle & 0x7f];
if(bf != 0)
angle = -angle;
}
else if(wave == 1) /* TRIANGLE */
{
if(angle == 0x80)
angle = 0xff;
else
{
unsigned ui;
if((angle & 0x80) != 0)
angle = - angle;
ui = (angle + angle) * 254;
angle = ui / 256;
angle ++;
}
}
else if(wave == 3) /* SQUARE */
{
if((angle &= 0x80) != 0)
angle = 0xff;
}
// else if(wave == 2) /* SAWTOOTH */
// ;
return (angle);
}/* FIN DE fvalue */
Listing 1—
The
fvalue
function (77 bytes of code) and a table (65 bytes of code) replace the tables of four
waveforms (1024 bytes of code).
CHARGE ORDERS to Visa, Mastercard,
. Shipping and handling for the
Limited. NO COD. Prices subject
Panasonic DVM60. Miniature
digital video cassette.60 Minutes.
46
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
include the ICs and extra devices
because the Electronics Lab contains
a large number of inputs and outputs
and can hide the unnecessary signals.
In addition, every practical exercise
includes a configuration file that
establishes the stimuli signals of the
circuit and the visibility conditions of
the input signals.
IN THE CLASSROOM
The Electronics Lab is an extremely
useful piece of equipment for practic-
ing electronics. It allows you to exper-
iment with real electronic circuits,
reducing the mounting time and elim-
inating the following tasks: initial
grouping of the necessary electronic
instruments, connection of the target
circuit, and putting the instruments
back on the shelves after class is over.
You can make the best of your PC
with the practice handbooks in elec-
tronic format, because its resources
can be used to teach students and
generate, monitor, and register the
signals. The Electronics Lab is also
useful to verify fixed-function
SSI/MSI integrated circuits and pro-
grammable logic devices.
Depending on the complexity of the
circuits to study, the teacher may ask
students to make the entire circuit
mounting or present the circuit
already mounted. Another option is to
ask the students to complete a circuit
partially mounted on a normalized
card. In addition, the work carried out
every school year as well as the new
developed practices can be reused in
later years.
The reduced weight and size of the
Electronics Lab allow its use outside
of the laboratory. You can use it at
home or in the classroom for live
demonstrations. Also, because it’s
controlled by a computer, you may
expand the Electronics Lab for remote
experimentation, paving the way for
laboratory experiments via an
Intranet or Internet.
I
Mariano Barron is a professor of con-
trol engineering at University of the
Basque Country in Spain. He may be
reached at ispbarum@sb.ehu.es.
Javier Martinez teaches electronic
systems at a secondary school in La
Rioja, Spain. You may reach him at
jdisen@openbank.es.
be the first byte of every packet of 12
bytes, which must be greater or the
same as 0xfb. This byte will be less
than 0xfb only when the Electronics
Lab sends the pulses counted by the
frequency meter in 0.166 s and when-
ever this frequency is less than 6 ×
0xfaff (385 kHz).
If the program determines that the
first value is less than 0xfb in two
consecutive packets or if this first
value is greater than 0xfb during a
time superior of 0.166 s, it deduces
that it has lost synchronization.
Then, the program eliminates the
reception buffer characters. This trick
is efficient and can be checked easily
by plugging and unplugging the serial
cable several times.
ELECTRONICS LAB
As you see in Photo 5, the
Electronics Lab has an 80 × 60 mm
surface for practice mounting on the
left side. Notice that there are more
than 470 connection points where
electronic parts and interconnecting
wires can be inserted.
On the right side, there are two
contact rows; all of the input signals
to be watched are in the upper row
and the output signals to stimulate
the test circuits and its power con-
tacts are in the lower row. These two
rows allow fast insertion of complete
circuits previously mounted on stan-
dardized 80 × 60 mm cards.
The left side of the Electronics Lab
also has two similar rows with 32
LED diodes to indicate the state of
the 16 digital inputs and 16 digital
outputs at all times. For this to work,
the Electronics Lab has to be connect-
ed to the computer’s main power and
serial port.
A set of circuits mounted on nor-
malized cards for fast connection
comes with the Electronics Lab. Also
included is a practice handbook to
create analog and digital electronics
courses. Every normalized card can
Byte 0
Byte 1
Byte 2
Byte 3
Byte 4
Byte 5
Byte 6
Byte 7
Byte 8
Byte 9
Byte 10
Byte 11
Frequency/I
2
C/
Frequency/I
2
C/
Analog 0
Analog 1
Analog 2
Analog 3
Analog 4
Analog 5
Analog 6
Analog 7
Digital
Digital
Synchronization
Synchronization
inputs inputs
E (0…7)
E (8…F)
Table 1—
The information packet is periodically sent from the Electronics Lab to the serial port.
SOFTWARE
The code is available on Circuit
Cellar
’s web site.
REFERENCES
[1] T. Napier, “ Applying Direct
Digital Synthesis— Part 1:
Generating Waves with an
NCO,” Circuit Cellar 95,
December 1997.
[2] ———
, “ Applying Direct
Digital Synthesis— Part 2:
Building a Numerically
Controlled Oscillator,” Circuit
Cellar
96, January 1998.
SOURCES
8051 Developer Kit
Keil Software, Inc.
(800) 348-8051
(972) 312-1107
Fax: (972) 312-1159
www.keil.com
MAX232
Maxim Integrated Products, Inc.
(408) 737-7600
(800) 998-8800
Fax: (408) 737-7194
www.maxim-ic.com
LabVIEW
National Instruments Corp.
(512) 794-0100
Fax: (512) 794-8411
www.natinst.com
Atmel's programmable FPSLIC SOC technology
speeds time-to-market while lowering risk
for a true out-of-body experience.
Set yourself free on your next design
project. Let Atmel's FPSLIC devices
give you inner peace with FPGA,
bytes of SRAM on a single chip.
Need to get to market fast? No problem.
System Designer™, our co-verification
based design tool, will take months off your
development schedule. And with stand-by current
under 100 µA, you won’t need divine intervention
to meet the power goals of your portable products.
market. For more information and to order your
starter kit, go to www.atmel.com/ad/fpslic02.html.
Fax-On-Demand:
(800) 292-8635 (North America)
(408) 441-0732 (International)
48
Issue 131 June 2001
CIRCUIT CELLAR
®
orking with
embedded devices is
always an exciting
proposition. Every day
brings new products, new challenges,
new problems, and hopefully new
answers. As a regular reader of both
Circuit Cellar
’s print and online ver-
sions, I came across an advertisement
touting Internet connectivity for any-
thing that remotely looks like a serial
port. The ad boasted little to no cod-
ing at a cost of $49 for the module
and $99 for the SDK. Well, you
already know the rest. The acronym
SDK and “connect to anything” was
all I needed to take a closer look at
this supposed “miracle module” that
appeared to be a TCP/IP stack,
Ethernet interface, and serial engine
all on a single IC. Could this be
embedded nirvana?
TWO UPS DAYS LATER
Upon receiving the box of goodies, I
immediately thought I had been
deceived. Surely this tiny blob of elec-
tronics couldn’t do much, and if it
could, I’d have to beat it out of it.
There just wasn’t enough equipment
for anything serious to happen. The
problem was that I was going by the
pictures in the ad and on the web site.
www.circuitcellar.com
APPLIED
PCs
All they showed was a crystal and an
IC of unknown origin decorated with
a fancy color logo surrounded by a
couple of 0.100 center female headers.
NetMedia calls this embedded wonder
SitePlayer SP1.
Buyer’s remorse became even worse
when I glanced at the SDK. Not much
there beyond the standard stuff of but-
tons and LEDs. I kept wondering what
the female headers are for, so I peeked
under the module on the SDK and
whoa! There’s another IC under there!
Those sneaky little devils. It was time
to take a closer look at what is writ-
ten on all the ICs and see what this
little hummer can do.
SITEPLAYER PHYSICS
After careful investigation, I found
that the mystery IC depicted in the
ads is a Philips 89C51RD2 8-bit flash
memory microcontroller (see Photo
1). Its companion on this side of the
tiny circuit board is a 20-MHz crystal.
A closer look at the whole part num-
ber put things in perspective. The
89C51RD2HBBD is the heftiest in its
class, weighing in at 64 KB of flash
memory and 1 KB of RAM. It’s also
the tiniest, packaged in LQFP (quad
flat pack) plastic. The 89C51RD2 is
milligram for milligram compatible
with the trusty old 8051, and can run
at 20 MHz in 6 Clock mode and 33
MHz in 12 Clock mode.
For 8051 types, this bit of informa-
tion says a lot. First, there is the pos-
sibility of the SitePlayer using the on-
IC UART of the 89C51RD2 for its
serial interface feature. Then there’s
the ISP (in-system programming) and
IAP (in-application programming) fea-
Fred Eady
Working with a Player
w
Do miracles happen?
When a company
advertises a low-cost
device that enables
Internet connectivity
for practically anything,
Fred takes notice.
When that product
also promises not to
require much code, he
gets to work testing.
And, yes, Virginia,
there is a Santa Claus.
Photo 1—
My first thought was that NetMedia had real-
ly designed the IC around the amount of labeling it had
to put on the plastic case. That’s a lot of scribbling for
an 8051 look-alike.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
49
tures that could give the SitePlayer its
ability to absorb and apply firmware
downloads on the fly. The difference
between ISP and IAP is that IAP
allows user code running on the
89C51RD2 to alter program memory
on the same 89C51RD2 it is running
on. For the Microchip-inclined, this is
akin to the same feature in the
16F877. IAP ability allows the use of
boot loader configurations; ISP is the
means by which the microcontroller
is programmed natively while on a
circuit board instead of in a program-
mer socket. Unlike the PIC16F877,
the 89C51RD2 has ROM boot loader
code which makes the ISP and IAP
processes easier to implement.
Photo 2 is a belly shot of the
SitePlayer SP1 coprocessor module.
This part has been popping up on all
sorts of embedded single-board com-
puters, and is widely used on some
inexpensive PC slot Ethernet boards.
The RTL8019AS is an NE2000-com-
patible Ethernet engine that is well-
suited for interfacing small 8-bit
microcontrollers like the 89C51RD2
to larger Ethernet networks.
This is all starting to come together
now. By merely observing what com-
ponents are contained on the SP1, you
can make accurate assumptions. The
89C51RD2 could contain enough
firmware to implement a minimal set
of Internet protocols. Also, the
firmware includes drivers for the
RTL8019AS Ethernet engine and the
onboard UART. The SitePlayer
coprocessor serial interface is likely
supplied by the 89C51RD2, and judg-
ing by its amount of RAM, there’s
probably some area set aside for user
data and HTML pages. The 20-MHz
crystal, if used for the processor
clock, tells you that the 89C51RD2 is
likely running in 6 Clock mode, at six
clocks per machine cycle instead of in
12 Clock mode. The maximum clock
frequency for 12 Clock mode is 33
MHz. In 6 Clock mode, 20 MHz looks
like 40 MHz, so I’ll bet 6 Clock mode
is in use.
The SitePlayer development station
is shown in Photo 3. There are still a
couple of key components that seem
to be missing—an RS-232 converter
IC and the Ethernet magnetics. The
lone 74HC86 performs RS-232 con-
version and inversion duty, provides a
simple pulse width modulated DAC,
and conditions the processor reset
pulse. Jumper selected RS-232 inver-
sion allows the SitePlayer to connect
directly to another microprocessor’s
UART or hook up to a COMM port
on a personal or embedded computer.
As for the Ethernet magnetics, they’re
incorporated inside the 8-pin female
RJ-45 Ethernet connector.
Collectively, the Ethernet RJ-45/
magnetics module is called the LAN-
Mate and is designated as LF1S022.
The LF1S022 is electrically equivalent
to the jack-less pulse FL1012. Both
the LF1S022 and FL1012 have a built-
in filter network in addition to the
standard isolation transformers. The
rest of the glue on the SitePlayer SDK
handles switches, LEDs, power, and
the interface to the piggyback
SitePlayer SP1 coprocessor module.
WHY ARE WE HERE?
I’m sure that’s what you’re asking
yourself right now. Well, there’s a
method to my madness. My usual
goal is to describe the latest and great-
est in embedded SBCs. The thought
occurred to me that many embedded
applications are not running on 2001
Ethernet- or Internet-enabled hard-
ware. With companies looking to cut
costs, adding Internet functionality to
existing embedded solutions must be
inexpensive on both the hardware and
manpower sides of the equation.
For instance, I have a Midwest
MicroTek MMT-188EB SBC, rev. D
(see Photo 4) that does not contain
native Ethernet support, but it’s
heavy with I/O and serial port sup-
port. There could be hundreds of
these in the field humming along just
fine. So, why spend a ton of money to
replace them with late-model SBCs
just to get them on the Internet?
I don’t have software or hardware
support natively on the MMT-188EB
to call on. Using the SitePlayer, the
worst case is to test one system that I
can upgrade with SitePlayer at a mini-
mum of $50 (plus whatever my time
is worth). Is it worth the effort? Can
it be done at all? Will the final solu-
tion perform satisfactorily? Let’s put
SitePlayer on the line and find out.
INTEGRATING THE SP1 AND
MMT-188EB
Note the coprocessor inference in
SP1’s official name. SitePlayer’s
onboard processor allows it to run
independently, but the term coproces-
sor implies that another computing
device (MMT-188EB) can also access
the SitePlayer hardware resources.
SitePlayer handles the web traffic and
Ethernet packets without help from
the MMT-188EB. In Mainframe Land,
the SitePlayer would be called a front-
end processor. Mainframe front-ends
Photo 2—
Now this all makes sense. There’s a full-
blown NE2000-compatible Ethernet engine hidden
under the processor. The RTL8019 underneath was a
real surprise.
Photo 3—
Lots of the usual buttons, shell connectors,
and LEDs, but where are the magnetics for the
Ethernet interface?
Photo 4—
This board has been around for a while but
there’s still plenty of application left in it. It’s about to
pay a visit to Internet Land.
50
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
typically handle all of the com-
munications traffic, thus reduc-
ing the time the main CPU
complex has to devote to that
task. SitePlayer works on the
same concept with smaller
CPUs and SBCs.
Communications with the
device, your MMT-188EB, is
accomplished with objects
flowing across the two-wire
serial connection between the
SitePlayer and MMT-188EB.
This is accomplished using an
object system called
SiteObjects. SiteObjects is simi-
lar to the emWare concept in
that HTML-based graphical
images change their behavior
according to data received from
the enabled device, which is the
MMT-188EB. NetMedia claims that
this all can be accomplished without
CGI (common gateway interface)
scripts or Java programming.
SitePlayer can be broken down into
eight hardware and firmware mod-
ules. Directly behind the SitePlayer’s
physical serial port are three
firmware-based processes—Ethernet
Protocol Processor, SiteObjects
Processor, and SitePlayer Web Server.
The SiteObjects Processor is the
direct object interface to the
SitePlayer’s UART. The SitePlayer
Web Server module hosts web pages
and their objects. The Ethernet engine
drivers and all of the protocols that
SitePlayer supports are provided by
the Ethernet protocol processor
firmware. Protocols supported by the
SitePlayer include ARP, ICMP, IP,
UDP, TCP, and DHCP, which are all
available via the SitePlayer’s 10BaseT
Ethernet interface.
RAM flash memory that is not used
for standard processing activities is
divided into two sections, SiteObjects
RAM and flash memory web pages.
Web pages and data input are
processed through the 768 byes of
SiteObjects RAM. By now you’ve
probably come to the conclusion that
I’m attempting to sleuth the inner
workings of the SitePlayer, and I’m
not going to dismantle or reverse-
engineer the SitePlayer electronics.
So, peeking at the 89C512RD2
datasheet, it sure is a coincidence that
there are exactly 768 bytes of ERAM
(expanded RAM) on the 89C51RD2.
SiteObjects RAM area theory could
be confirmed if you knew that the
ERAM was being accessed using
MOVX instructions with the
EXTRAM bit cleared. I’d bet on my
initial assumption here. Web pages
and configuration information is held
in 48 KB of flash memory, which
implies that the SitePlayer operating
code occupies no more than 16 KB of
the available 64 KB of flash memory
within the 89C51RD2.
These microcontroller firmware
modules and hardware interfaces fil-
ter down to the outside world through
a couple of 9-pin female headers. The
bulk of the 18 pins are given to the
SitePlayer’s stand-alone I/O. The idea
is to allow the SitePlayer to drive
relays and sense inputs on its own if
the application requires it.
Your plan is to make data from the
MMT-188EB available over the
Internet using the SitePlayer and its
facilities. So, let’s put together code
and push some bits along the wire.
ASSEMBLING THE APPLICATION
Information is gathered by the
MMT-188EB’s parallel and/or serial
I/O subsystems, which could include
an onboard ADC. This bit-oriented
data is transferred via two-wire (TX
and RX only) RS-232 from the MMT-
188EB to the SPI’s serial interface.
Photo 5—
I found this tool helpful in figuring out what the
SitePlayer was doing to memory locations and bits. And it helps
to determine which IP address the SitePlayer is actually using.
www.circuitcellar.com
Issue 131 June 2001
51
CIRCUIT CELLAR
®
The data is stored in memory loca-
tions defined by the objects contained
in the SitePlayer definition file. When
pages are served, each stored object
value is substituted for a related
SiteObject tag in the HTML text. This
process also works from the HTML
page backwards to the MMT-188EB.
Using the HMTL GET method, values
from the HTML text are written to
objects defined in the definition file.
The MMT-188EB retrieves the object
values from SitePlayer memory via
commands issued over the serial con-
nection to the SitePlayer. Retrieval of
data from the SitePlayer is up to the
MMT-188EB; data can be requested by
polling the SitePlayer’s serial status or
by a hardware interrupt triggered by
the SitePlayer’s IRQ output pin.
The first order of business is to cre-
ate an
.SPD file (SitePlayer definition
file), which consists of the instruc-
tions that the SiteLinker program will
use. The SiteLinker program makes
.SPB files (SitePlayer binary files), and
these binary image files are down-
loaded to the SitePlayer module
through the Ethernet connection. As
you would imagine, the
.SPB file con-
tains all the code, startup parameters,
web pages, and SiteObjects.
The SitePlayer definition file can be
cut into three sections, definition,
object, and export. The definition sec-
tion provides the initial setup parame-
ters for the SitePlayer. This is where
the SitePlayer name and IP address
are defined, including a switch to
enable or disable DHCP. Download
passwords are defined in this section
as well as
.SPB file names, include
files, root folders, and a switch for
polling or interrupting incoming
SitePlayer data. Let’s go ahead and
create the
CCINK.SPD file starting with
the definition section. You can follow
my logic in the example available on
the Circuit Cellar web site.
This SitePlayer test “site” will
never be relocated, so I disabled
DHCP. Because this is a test and I
won’t put sensitive data on the ’Net, I
also forewent security by not specify-
ing passwords. DHCP is disabled and
if I want this to work, I’ll have to sup-
ply a valid IP address. 192.168.1.254
works well. There will be no real-
time forms processing in this test, so I
can turn off $PostIRQ and poll the
SitePlayer status register for my data.
I created a root directory for your
test site at C:\SitePlayer\CCINK_Site\
root. Everything you need is con-
tained within this directory structure.
The
pcadef.inc file defines the
SitePlayer special functions memory
map. If you check Table 1 against the
89C51RD2 datasheet, you’ll find that
the items under the Name heading
relate to real hardware on the
89C51RD2. The “real” hardware is
mapped to a SitePlayer function
address. For example, if you want to
turn on the green LED attached to
IO4 on the SDK board, write a 0 to
address 0xFF15.
The pca in
pcadef.inc goes along
with the 89C51RD2 datasheet and
coincides with its programmable
counter array (PCA) hardware. That
datasheet states that the PCA is actu-
ally a 16-bit timer that has five 16-bit
capture/compare modules under its
52
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
wing. Remember I talked about PWM
capability on the SitePlayer SDK
board? Well, Table 1 tells you how
the PCA modules can be accessed the
SitePlayer way, and
pcadef.inc makes
sure the object definitions are there
to allow it to happen. Each module
can be programmed to operate in
Rising or Falling Edge Capture mode,
as a software timer, high-speed out-
put and, of course, a pulse width
modulator (PWM).
Objects are simple variables that
have a name, type, size, and initial
value. Ultimately, the objects you
define in the object section will
become SiteObjects. Basically, a
SiteObject is a reserved byte or array
of bytes in SitePlayer memory with
an associated name. SiteObjects are
used to communicate
between the MMT-
188EB device processor
and SitePlayer processor.
To lessen confusion and
make it all work, the
object names defined in
the object section must
match the SiteObject
names in the HTML
pages. These variable
names must also match
your variable definitions
for the MMT-188EB.
The only thing you need
to watch out for is to
avoid conflict with the
reserved symbols. These
reserved symbols are
similar to their C coun-
terparts and are what
you’ll use to make your
object definitions (i.e.,
you can’t use DB or DW
as an object name).
Defining object loca-
tions is dependent on
what type of object you
want to define. Take
another look at the top
portion of Table 1. Just
about any object can be
defined between
addresses 0x0000 and
0x02FF. If you want to
define bit objects, the
SitePlayer system has a
special area for them at
address 0x02E0. There are 256 bits
between 0x02E0 and 0x02FF. In
SitePlayer lingo, bits 0–7 reside at
0x02E0, bits 8–15 are located at
0x0x02E1, and bits 248–255 can be
found at 0x02FF.
As
CCINK.SPD shows, the bits must
be defined using dbit and must reside
between addresses 0 and 255 decimal.
This means that you can’t mix bits
and bytes in this address range. The
0x02E0–0x02FF bit addresses are con-
verted from their respective byte
addresses in the SitePlayer firmware.
This eliminates contention in HTML
form applications.
This is a good place to show you a
helpful tool that comes with the soft-
ware package, Serial Port Tester. I
defined eight bits, 0xA5, at location
SitePlayer object memory map
Address
Description
0000h
Regular objects addressable with 1- or 2-byte addresses
02DFh
02E0h
Bit objects addressed with 1-byte bit addresses,
or regular objects with 2-byte addresses
02FFh
0FF00h
Special SitePlayer functions
0FFFFh
SitePlayer special functions memory map
Address
Name
Description
0FF00h
P1
Port 1—complete 8-bit port
0FF01h
CMOD
PCA Counter mode
0FF02h
CCON
PCA Counter control
0FF03h
CH
PCA Counter high
0FF04h
CL
PCA Counter low
0FF05h
CCAPM0
Module 0 mode
0FF06h
CCAPM1
Module 1 mode
0FF07h
CCAPM2
Module 2 mode
0FF08h
CCAPM3
Module 3 mode
0FF09h
CCAP0H
Module 0 capture high
0FF0Ah
CCAP1H
Module 1 capture high
0FF0Bh
CCAP2H
Module 2 capture high
0FF0Ch
CCAP3H
Module 3 capture high
0FF0Dh
CCAP0L
Module 0 capture low
0FF0Eh
CCAP1L
Module 1 capture low
0FF0Fh
CCAP2L
Module 2 capture low
0FF10h
CCAP3L
Module 3 capture low
0FF11h
IO0
Port 1 bit number 0
0FF12h
IO1
Port 1 bit number 1
0FF13h
IO2
Port 1 bit number 2
0FF14h
IO3
Port 1 bit number 3
0FF15h
IO4
Port 1 bit number 4
0FF16h
IO5
Port 1 bit number 5
0FF17h
IO6
Port 1 bit number 6
0FF18h
IO7
Port 1 bit number 7
0FFE0h–
MAC
6-byte Ethernet MAC address
0FFE5h
0FFE6h–
Current IP
Current IP address
0FFE9h
Table 1—
The majority of the 89C51RD2's features are available through
the SitePlayer interface. You can also get to these features using
SitePlayer commands transmitted via a simple serial port.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
53
0x02E0. Using SiteLinker, I made the
CCINK.SPB file using definitions and
objects from
CCINK.SPD in Listing 1.
Photo 5 shows the SitePlayer Serial
Port Tester screen that got the object
value from the byte at 0x02E0. 165
decimal just happens to be 0xA5,
which is the initial state of the first
group of bits I defined at 0x02E0. In
Photo 5, you can also see the addi-
tional functionality the Serial Port
Tester contains. I’ll point out what
the other values are as I go further.
Now I’ll introduce another impor-
tant part of SitePlayer, the command
set. SitePlayer commands are made
up of two sections. There are 16 com-
mand functions and the upper four
bits of the command byte call these
out. The lower four bits of the com-
mand byte hold the number of bytes
that will be sent or received by the
command. Using the SitePlayer com-
mand set in Table 2 and the Xmit line
at the bottom of Photo 5, you can see
how this system works.
The byte at 0x02E0, 0xA5, is
returned on the Rcvd line. The Xmit
line in Photo 5 is called an object
packet. An object packet consists of
the command byte followed by a one-
or two-byte address, least significant
;****************************************************
;THE FRIST LINE BELOW IS FROM THE MAKEASM.DEF FILE
;THE SECOND LINE IS PART OF THIS FILE MMT188DEFS.ASM
;****************************************************
;^name equ ^address^h ; ^type ^direction ^default
p1 equ 0FF00 h ; Byte bidirectional 0
;****************************************************
;THE REST OF MMT188DEFS.ASM IS BELOW
cmod equ 0FF01h ; Byte bidirectional 0
ccon equ 0FF02h ; Byte bidirectional 0
ch equ 0FF03h ; Byte bidirectional 0
cl equ 0FF04h ; Byte bidirectional 0
ccapm0 equ 0FF05h ; Byte bidirectional 0
ccapm1 equ 0FF06h ; Byte bidirectional 0
ccapm2 equ 0FF07h ; Byte bidirectional 0
ccapm3 equ 0FF08h ; Byte bidirectional 0
ccap0h equ 0FF09h ; Byte bidirectional 0
ccap1h equ 0FF0Ah ; Byte bidirectional 0
ccap2h equ 0FF0Bh ; Byte bidirectional 0
ccap3h equ 0FF0Ch ; Byte bidirectional 0
ccap0l equ 0FF0Dh ; Byte bidirectional 0
ccap1l equ 0FF0Eh ; Byte bidirectional 0
ccap2l equ 0FF0Fh ; Byte bidirectional 0
ccap3l equ 0FF10h ; Byte bidirectional 0
io0 equ 0FF11h ; Byte bidirectional 0
io1 equ 0FF12h ; Byte bidirectional 0
io2 equ 0FF13h ; Byte bidirectional 0
io3 equ 0FF14h ; Byte bidirectional 0
io4 equ 0FF15h ; Byte bidirectional 0
io5 equ 0FF16h ; Byte bidirectional 0
io6 equ 0FF17h ; Byte bidirectional 0
io7 equ 0FF18h ; Byte bidirectional 0
bit_0 equ 0000h ; Bit bidirectional 1
bit_1 equ 0001h ; Bit bidirectional 0
bit_2 equ 0002h ; Bit bidirectional 1
bit_3 equ 0003h ; Bit bidirectional 0
bit_4 equ 0004h ; Bit bidirectional 0
bit_5 equ 0005h ; Bit bidirectional 1
bit_6 equ 0006h ; Bit bidirectional 0
bit_7 equ 0007h ; Bit bidirectional 1
byte_0 equ 0100h ; Byte bidirectional 204
sbit_0 equ 00F8h ; Bit bidirectional 0
sbit_1 equ 00F9h ; Bit bidirectional 1
sbit_2 equ 00FAh ; Bit bidirectional 0
sbit_3 equ 00FBh ; Bit bidirectional 1
sbit_4 equ 00FCh ; Bit bidirectional 0
sbit_5 equ 00FDh ; Bit bidirectional 1
sbit_6 equ 00FEh ; Bit bidirectional 0
Listing 1—
Using the export command set, you can generate all kinds of files like this one. You can even
build a
.def
file that generates HTML using the object values as dynamic tags. I’ve associated the first
line of the output file with the contents of the
.def
file it is fashioned after.
Get your IP network remote control
8 Relays, 8 Inputs. Control & Feedback
8 Inputs, 8 Relays. Alarm Monitor
Web, Ping Controlled A/C Reboot Switch
1 Input / 1 Output OEM Control Board.
30+ years satisfying End Users, VARs, and OEMs.
100s of products plus custom modifications & design.
54
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
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
MMT-188EB
Midwest Micro-Tek
(605) 697-8521
Fax: (605) 692-5112
www.midwestmicro-tek.com
SynEdit
MKI Design
www.mkidesign.com
SitePlayer
NetMedia, Inc.
(520) 544-4567
Fax: (520) 544-0800
www.siteplayer.com
89C51RD2
Philips Semiconductors
(408) 991-5207
Fax: (408) 991-3773
www.semiconductors.philips.com
Tera Term Pro
T. Teranishi
http://hp.vector.co.jp/authors/VA00
2416/teraterm.html
SOFTWARE
The source code is available on the
Circuit Cellar
web site.
byte first and 0 to 16 bytes of data.
You can send multiple objects with a
single command as long as the num-
ber of bytes is equal to or less than
16. The object packet at the bottom of
Photo 5 uses the command 0xD0
(ReadX) to get the byte value at
address 0x02E0.
In the
CCINK.SPD file I go on to
define a byte object at 0x0100 with an
initial value of 0xCC. The next set of
bit definitions is not related to the
first set of byte-related bit definitions.
The sbit_X definitions are status bits.
Table 3 shows the status bits that
MMT-188EB uses to determine if any-
thing needs to be sent to or received
from the SitePlayer. The most signifi-
cant status bit is dedicated and is set
when form data has been submitted
to the SitePlayer. As you can see in
the bottom right corner of Photo 5
and in the status bit area of the
CCINK.SPD file, the remaining status
bits are user-controlled.
The final section of the
CCINK.SPD
file contains the export definitions,
which allow the object definitions to
be exported to files suitable for use by
the external device and supporting
development programs. Export files
can be used for input into compilers
for C, assemblers, Visual Basic forms,
modules, and even HTML generators
like Microsoft’s Front Page. Listing 1
is output from definitions in a file
called
makeasm.def.
ALL THAT’S LEFT…
At this point you have a pretty
good working knowledge of the major
components that make up SitePlayer.
To create the SitePlayer side of the
application, you must define the
SitePlayer definitions, objects, export
file requirements, and build your
HTML pages.
As far as the MMT-188EB is con-
cerned, you now know that it must
be able to converse with the
SitePlayer using commands over its
serial port. That’s a simple matter of
coding serial routines that encapsu-
late SitePlayer commands and data
that is taken from the 8255 I/O sub-
system. Bytes from the MMT-188EB
ports are directly associated with
objects (bytes) on the SitePlayer.
Using the output of the export com-
mand set, an MMT-188EB C or
assembler program can be assembled
to allow the MMT-188EB to read and
write to the SitePlayer object memory
areas by issuing commands from its
serial port.
You know from experience that the
MMT-188EB can be coded to perform
the serial transfers I’ve described here.
Using a binary
editor like
SynEdit and a
terminal emula-
tor, binary files
in the form of
SitePlayer
object packets can be assembled and
sent to the SitePlayer. Results of the
commands can be viewed using the
SitePlayer Serial Port Tester. When
the bits and bytes are acting the way
you want them to, then you can mix
them into your custom HTML
imagery. Now the MMT-188EB cod-
ing will be a quick process because
you’ve already debugged the com-
mand sequences that the MMT-188EB
will be responsible for.
The SitePlayer system is now
geared for web pages and protocols.
There’s no easy way to connect to the
SitePlayer from the network side
directly with other methods…yet.
However, all in all, SitePlayer stood
up to the test to put the MMT-188EB
on the Internet with minimal hassle
(minimal code), proving once again
that is doesn’t have to be complicated
to be embedded.
I
Table 2—
The
SitePlayer imple-
ments a UART delay
automatically to
allow time for the
external device to
transition from
receive to transmit
mode. A simple ter-
minal program like
Tera Term Pro can
be used to control
the SitePlayer using
these commands.
Command byte
Command value
Number of bytes sent/requested
Up to 16 different commands
1–16 bytes (0 = 1, 1 = 2, 15 = 16)
D7 D6 D5 D4
D3 D2 D1 D0
SitePlayer serial commands
Command
Command byte
Description
NOP
00h
Do nothing, recommended initializing command
Status
10h
Return status of SitePlayer
Reset
20h
Perform a watchdog reset
ComParams
33h
Sets transfer rate and UART delay
Read
0C0h
Read object from SitePlayer
Write
80h
Write object to SitePlayer
ReadX
0D0h
Read using extended 2-byte addressing
WriteX
90h
Write using extended 2-byte addressing
ReadBit
0E0h
Read a bit variable, 1-byte address
WriteBit
0A0h
Write a bit variable, 1-byte address
ToggleBit
0B0h
Toggles a bit variable, 1-byte address
Submit
Bit 254
Bit 253
Bit 252 Bit 251 Bit 250 Bit 249
Bit 248
D7
D6
D5
D4
D3
D2
D1
D0
Table 3—
The MMT-188EB issues a SitePlayer command to read this SitePlayer sta-
tus byte. The bits are then parsed to determine what to do next or what event has
occurred. Seven of the eight bits are user defined in the
CCINK.SPD
file.
When it comes to troubleshooting a circuit, the process of lug-
ging a logic analyzer or oscilloscope around and then getting every-
thing set up can be time-consuming and inconvenient. With only
three buttons, the MultiProtocol Logic Probe provides multiple ana-
lyzer functions in a compact instrument that can be held like a
large pen. At roughly 1.5² wide and 6² long, it can quickly probe
and save hundreds of waveforms in its 512-KB memory.
Using an FPGA in conjunction with the Z80S183 serial ports
and analog inputs, the Probe can save digital or analog data and
display it in logic analyzer form, serial protocol analyzer form (e.g.,
for RS-232), digital voltmeter, digital counter, or oscilloscope form
(up to the 500-kHz sampling rate of the Z80S183). A unique FPGA
digital sampling circuit permits 200-MHz logic level data
acquisition from the probe tip. Additional connector
pins allow an external clock, trigger, and 16 bits of
sample probes to be attached to the MultiProtocol
Logic Probe as needed. An optional serial computer
www.circuitcellar.com/zilogdtd2000
Circuit Cellar design contests always bring out the best
engineers, and when we teamed up with ZiLOG to pres-
ent the Driven to Design contest, there was no doubt we
were in for an exciting ride. There were some great
entries from designers around the world, but after the
Practical experiments are critical when teaching system-
control theory, closed loops, pole-placement methods, and
real-time regulation. Most experiments are based on trivial
systems or are only simulation based. In both cases, the
The eZ-Stunt platform is a $15 toy RC car. The onboard
radio receiver and power drivers were kept in tact, but
tracks were cut on the PCB between the receiver chip and
the transistor-based power amplifiers. The main modification
to the car (except the addition of the processor board) is an
articulated vertical 40-cm aluminum bar, fixed on the axle of
a high-precision potentiometer. The game (i.e., required con-
trol loop) is to automatically move the car back and forth to
keep the bar as vertical as possible, even if someone gently
The eZ-Stunts miniature controller board is built around
a Z80S183 mixed-signal microcontroller. The processor
gets the current angle of the vertical bar with a poten-
tiometer and the integrated 10-bit ADC of the Z80S183. It
then drives the motor of the car backward and forward
Even well-tested equipment can experience new conditions in the
field that result in failure. However, the remote data-monitoring capa-
bilities of the Data by Z-mail system can give designers more accurate
results from field tests and help prevent costly field retrofits.
The Data by Z-mail system is a bench-top device that reads ana-
log and digital data from a UUT (unit under test) every hour and sends
that data out via e-mail and local RS-232. The Z-mail system is con-
nected to desired test points of a UUT (e.g., machine, circuit board, or
test platform). This allows the engineer to monitor UUT
data from any place in the world via e-mail.
Test points can be either analog
from any device that outputs 0 to
5 VDC. The digital inputs can be
from digital output type circuits.
Example input devices that output
analog voltages are pressure trans-
ducers, temperature sensors, photo
sensors, power supplies, and various
outputs from analog circuitry. Example
input devices that output digital signal
levels are microprocessor outputs,
intelligent sensors, PLC outputs, and
various outputs from digital circuitry.
A simple dimmer switch may be fine for
controlling a single light, but when it comes to
dimming multiple lights or interfacing to an
existing control system, the DMX512 Dimmer
The dimmer can be controlled through its
serial port or networked to other dimmers using
the industry-standard DMX512 protocol. The eight
analog inputs allow interfacing to standard 0 to 10-
V control signals or can be used as an alternative
Using IGBT drivers allows the dimmer to handle
up to 500 W. By using IGBTs to control the lights,
the dimming can start on the leading edge of the
power cycle. This allows for a smooth turn on/off,
thereby eliminating the rapid rise times that produce
noise. This design eliminates costly noise filtering
and extends the life of the lights by reducing ther-
Prize: Portable DVD Player & $500
www.circuitcellar.com/zilogdtd2000
judges results were calculated, Robert Morrison wound up in vic-
tory lane as the engineer who turned a Z183 into a Z3!
Circuit Cellar and ZiLOG would like to congratulate all of the
winners and thank everyone who participated in the Driven to
Design contest. For complete abstracts from this contest and
other Circuit Cellar design contests, go to
The Vehicle Trip Recorder keeps track of and dis-
plays basic information such as elapsed time, cost/quanti-
ty of fuel, distance traveled, average speed, and other
trip information. Information is gathered from the vehicle,
processed, and displayed on an LCD panel. Keypad com-
mands tell the system when to start and stop recording
and allow data entry. Information is stored on a plug-in
Compact Flash (CF) memory card to allow easy transfer
of the travel information to a PC for record keeping. A
low-cost CF reader connected to a home PC allows trans-
Web surfing and computer usage usually involve little
physical motion or exertion. The Mega-Keyboard offers
an alternate keyboard, on which the user walks (or
jumps, or dances.) The keyboard surface itself is entirely
passive. Detection of the keystroke is done optically,
by scanning a matrix of infrared beams and determining
which have been broken. The control, decoding, and
communications functionality is all handled by a
The design supports several packaging variations. It
can be used to build large-scale soft keyboards with
the texture of a flat punching-bag, for use by people with
limited neuro-muscular control. Because the detection is
entirely optical, it could also be
This RF-to-X10 Converter application provides wire-
less control for up to 256 devices. The sensors are wire-
less and transmit to the controller when a change in the
environment is detected. The controller operates the
devices by using pre-existing power lines via X10, elimi-
nating the cost of installing wires for communication.
One proven application would be to control the lights
in a museum. The idea would be to intensify a light
when a patron moves in front of a display, and dim the
light after the patron moves away from the display.
Another application would be to control the environment
and turning fans or heaters on
or off to get the desired tem-
One of the major setbacks when building a steam-
powered radio-control model airplane is the ability to
quickly and easily vary the rpm of a steam engine.
Similar to fuel injection in a gasoline engine, steam has
to be injected into the appropriate cylinder of a steam
engine at the appropriate time. Signals, which are calcu-
lated and produced by the Z183, turn on and off steam
valves that are actuated by solenoids. The speed of the
steam engine is selected using a variable resistor. The
Z183s A/D converter reads the
voltage across the resistor and
this information is then used to
calculate the appropriate time
RadioCommunications Controller
vals greater than 1 s and send them via radio.
for this project. Channel ESCC-B of the RadioCommunications Controller
(DCE) can be connected to a computer (DTE) via RS-232 in asynchronous
mode or to synchronous equipment via a V.24 interface. Channel ESCC-A
of the controller can be wired to radio via radio-modem chips MX (FX)469
or MX(FX)589 to provide radio communication with 1200/2400 or
Gvozdev Alexandrovich, Aldashkina Ivanovna,
Each received a personal GPS unit and an eZ80 evaluation board.
Two runners-up will receive a Handspring Visor
Two runners-up will receive a Handspring Visor
Two runners-up will receive a Handspring Visor
Pick a category and
submit your project by
60
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
Photo 1—
Litz wire coiled on a
ferrite rod collects the RF. The
capacitors form a resonant circuit
with the larger winding at 60 kHz.
A cap on the circuit board res-
onates with the secondary wind-
ing in the center of the rod. In
use, you must mount the antenna
in a C- or U-shaped electrostatic
shield.
very spring and
fall brings the
ordeal of adjusting our
clocks into and out of
daylight saving time. At last count,
we had 31 timekeepers scattered
around the house in the form of
clocks, watches, cars, a microwave,
range, thermostat, water softener, and
even a UPS, all clamoring for atten-
tion. Fortunately, the personal com-
puters take care of themselves.
I began the task by setting my
wristwatch from WWV’s radio station,
the National Institute of Science and
Technology (NIST) standard time sig-
nal voice that broadcasts on 5, 10, 15,
and 20 MHz from Fort Collins, CO.
Half an hour later, all our clocks were
correct, or close enough.
NIST also transmits digital time
data on WWVB at 60 kHz, with recep-
tion throughout the continental U.S.,
Mexico, and Canada. A binary signal
amplitude modulates a 50-kW carrier
with BCD numeric time information.
I wondered what that signal looked
like here in the Hudson Valley and
decided to build the simplest RF
amplifier possible to find out. If it
looked good, I could easily add a
detector and decoder to retrieve the
data. What I discovered was rather
interesting, even if it wasn’t at all
what I expected!
PUMP UP THE VOLUME
An AM radio receiver has two key
parts: an antenna that converts RF
energy into electrical current and a
detector that recovers the signal mod-
ulated onto the carrier. Everything
else, notably amplification and fre-
quency selection, falls in the category
of fine tuning (so to speak).
If you live near a powerful radio
transmitter, nearly anything can serve
as a receiver. Crystal radio sets derive
enough power for an earphone direct-
ly from the incoming RF and, if
you’re really close, bedsprings and
dental fillings work fine, too.
As you move further from the
transmitter, the RF signal amplitude
decreases, although not by any simple
factor or exponential relation. The
WWVB transmitter produces a field
strength of about 100 µV/m half a
continent away, at the fringe of its
useful range.
An AM detector can be as simple as
a diode, however, you need about 1 V
for useful results. If you could collect
the signal potential difference across 1
m, you’d need a voltage gain of
10,000, or 80 dB, between the antenna
and detector.
It occurred to me that newer op-
amps can provide plenty of gain at
60 kHz. Could a few op-amps substi-
tute for the usual RF circuitry?
Does bad reception
ever interrupt your
favorite songs on the
radio? Would pur-
chasing a bigger
antenna or a few op-
amps solve all of the
problems? Ed’s been
delving into the world
of radio frequency
transmission and has
come to some inter-
esting conclusions.
Ed Nisley
Can’t Set Your Clock
e
ABOVE THE
GROUND
PLANE
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
61
ANTENNA TUNING
Before you can receive a signal, you
must wrestle it from space with an
antenna. The familiar wire antennas
on automobiles, rooftops, and in ham
radio operators’ backyards have
dimensions roughly comparable to the
signal’s wavelength. For example, at
146 MHz, a wavelength is 2 m, which
makes a quarter-wavelength antenna
0.5 m, or about 19
″
long.
This approach doesn’t work well at
60 kHz with a 5-km wavelength. In
that VLF (very low frequency) range, a
more practical antenna couples with
the signal’s magnetic field rather than
its electrical field. A typical VLF
antenna uses several loops of insulat-
ed wire, generally in an electrically
shielded enclosure. The dimensions of
the loop, although much smaller than
the signal wavelength, nevertheless
couple strongly enough to be useful.
The loopstick antenna in Photo 1
represents a variation of the larger
open-loop design. Loopstick antennas,
wound on a ferrite rod that acts as a
concentrator for the magnetic field,
will be familiar if you’ve ever torn
down an AM radio. You must choose
a ferrite suitable for the signal’s fre-
quency; Amidon’s material 33 is spec-
ified for VLF and LF antennas. The
more common material 61 is in the
AM broadcast band near 1 MHz.
As far as I can tell, there are as
many ways to wind a loopstick as
there are references. Maximum sensi-
tivity comes with the largest number
of turns, as you’d expect. Spacing the
turns one wire diameter apart gives
the best quality factor (Q), which is
improved even further if the wire cov-
ers less than the whole rod.
Obviously, there are several trade-offs
here, so I went for maximum gain and
tried to get selectivity a different way.
Although you can connect the large
winding to the receiver, adding a
smaller, secondary winding and res-
onating the primary with a capacitor
attenuates frequencies you’re not
interested in. I used a pair of capaci-
tors that add up to the proper value;
you may also adjust the number of
turns to match your capacitor.
The secondary winding, 10 turns in
the middle of the rod, attaches to the
small cable running off to the left.
The other end appears in the upper-
left section of Photo 2 and supplies
the input on the left of Figure 1, the
main schematic.
I used 8/33 Litz wire for the wind-
ings, although ordinary enameled
wire should work just as well. Litz
wire is made up of many small, insu-
lated strands that maximize the sur-
face area of the conductor to mini-
mize the skin effect, which is a seri-
ous problem at higher frequencies.
Although the antenna couples to
magnetic fields, it is susceptible to
electric fields. I mounted the rod
inside an electrostatic shield made of
a 1
″
copper pipe, slit lengthwise. The
slit is vital because, otherwise, the
copper cylinder neutralizes the mag-
netic field. It isn’t perfect, but it’s
good enough to wipe out the signal
you want to receive.
CHAIN O’ GAIN
The three op-amps in Figure 1 each
have a voltage gain of 100, or 40 dB.
The overall gain is thus 120 dB minus
filter insertion losses.
The MAX4255 op-amps I used have
a 22-MHz GBW (gain bandwidth prod-
uct). The GBW tells you the frequen-
Figure 1—
MAX4255 op-amps can provide a voltage gain of 100 at 60 kHz, where the simple LC filters select the 60-kHz WWVB carrier. Because the MAX4255 op-amps use
a single supply voltage, all signals must be referenced to V
CC
/2 rather than ground. Note the RF filters on the non-inverting inputs to each op-amp.
62
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
cy at which the open-loop gain drops
to 0 dB. Below that frequency, the
open-loop gain is roughly equal to the
GBW divided by the frequency.
You can also work the other way by
dividing the GBW by your desired
gain to find the maximum frequency
the circuit will handle. For the
MAX4255, dividing 22 MHz by 100
gives 220 kHz, comfortably above the
60 kHz you need.
Why not crank the gain to 350 with
a maximum frequency of 63 kHz?
Remember that op-amps trade open-
loop gain for nearly ideal behavior. To
the extent that the open-loop gain
isn’t infinite, the behavior isn’t ideal.
The MAX4255 has a typical open-loop
gain of 112 dB, which drops to about
50 dB at 60 kHz. That leaves 10 dB to
keep the op-amp’s output in line.
Although higher speed op-amps are
available, there’s another trade-off to
accept. The MAX4255 has decent
low-noise performance, which is
important for the first stage of an RF
amplifier. So, amplifier noise wasn’t
the biggest problem I had to face.
The MAX4255, as with most newer
op-amps, uses a single 5-V supply.
That means each gain stage must
have an AC-coupled input and the
non-inverting input must be biased to
V
CC
/2. Omitting that coupling cap is a
common error because it isn’t needed
with op-amps that run from dual sup-
plies centered around ground.
AC coupling may cause another
problem called motorboating. Each
coupling cap shifts the signal’s phase
by 45° at its low-frequency cutoff.
With enough gain around the loop
you can get a low-frequency wow-
wow! You’ll know it when you see it.
FREQUENCY SELECTION
If WWVB were the only transmitter,
a simple antenna and 120 dB of gain
would do the trick. In the real world,
you must select the signal you want
with filters that reject everything else.
Along with simple op-amps, I won-
dered if a few dead-simple LC filters
would do the trick.
In a series LC circuit, the inductive
and capacitive reactances cancel out
each other at the resonant frequency.
In effect, the circuit becomes a wire,
leaving only the parasitic resistance of
the inductor in the circuit, which is
about 10
Ω
for the Toko coils I used.
You can think of the two LC filters
as forming voltage dividers with R17
and R18. At resonance, the voltage
across those resistors will be at a
maximum. Off resonance, the voltage
will drop. The filter’s quality factor,
Q, improves as you make those resis-
tors smaller, at the cost of decreasing
the output at resonance and, thus, the
overall gain.
Numerically, Q equals the center
frequency divided by the half-power
bandwidth. This is determined by sev-
eral factors, including the inductor’s
parasitic resistance and the circuitry
on either side of the filter, and can be
remarkably hard to determine accu-
rately in advance. A few SPICE simu-
lations indicated that the overall
bandwidth would be a few kilohertz,
which may be OK.
Starting from the antenna, you’ll
find four resonant circuits, the pri-
mary and secondary rod windings and
two LC filters. After tweaking each of
those to 60 kHz, I measured an over-
all bandwidth of 4 kHz, roughly what
I expected.
The overall gain, from the input of
IC3 to the output of IC5, was 115,000
(101 dB), so the filter losses were
19 dB. That’s roughly what I expected
from the inductor resistances plus op-
amp output impedances.
Incidentally, it’s a good idea to use
different inductor values in a circuit
with several LC filter sections. The
parasitic capacitance in each inductor
produces a self-resonant response and,
because inductors have an external
magnetic field, two identical induc-
tors can couple to each other. Enough
gain around that loop will support an
oscillation at the inductors’ mutual
resonant frequency.
POWER ON, QUIETLY
MAX4255 op-amps have a power
supply rejection ratio of at least
75 dB, which means if the overall cir-
cuit gain exceeds 75 dB, an output sig-
nal fed back through the power distri-
bution network to the input op-amp
will show positive gain around the
loop. The power supply in Figure 2
must not only produce the proper
voltages, but deliver them quietly.
I used Texas Instruments’ low-
dropout regulator to convert the raw
DC input. The TPS77501’s output
voltage is
although other members of that regu-
lator family come preset to standard
voltages. I picked 4.7 V so I could use
a 5-V NiMH battery pack for com-
plete power line isolation.
A TI TLE2426 rail splitter divides
that supply voltage in half and buffers
it. If you need V
CC
/2 for several op-
amps, a TLE2426 may be easier and
less expensive than building your own
divider and buffer. However, it also
raises the problem of feedback
through the V
CC
/2 line.
I used MAX4255 op-amps in their
inverting configuration, so the non-
inverting inputs connect to V
CC
/2.
Each input has a ferrite bead to
remove RF, plus an RC filter to chop
(
)
Figure 2—
The TPS77501 low-dropout regulator provides 4.8 V from a DC input and indicates when
the output falls out of tolerance. The TLE2426 rail splitter produces exactly half the supply voltage at
its low-impedance output.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
65
out 60-kHz feedback. You can gener-
ate V
CC
/2 at each op-amp if you prefer.
The Amidon FB-75B-101 beads
attenuate most effectively around
5 MHz and cover the MAX4255 gain
range. Beads made from the familiar
material 64 have lower attenuation in
that range and are more suited for
higher frequency RF designs.
tive enclosures. One of those 150-W
soldering guns does the trick.
Remember to be careful because the
tip is the high-current secondary of a
husky transformer that isn’t grounded
and may induce nasty currents in sus-
ceptible circuits.
BRING THE NOISE (AGAIN!)
So I finished the circuit, wired up
the battery, tucked the antenna in its
shield, hitched up my scope, turned
things on, and got a full-scale, rail-to-
rail output. In fact, the signal was so
strong I thought the circuit was oscil-
lating. Rotating the antenna on my
bench reduced the signal to about 1 V.
I then punched the Frequency but-
ton on the scope, which reported
59.1 kHz. Perhaps my instruments
aren’t calibrated quite right? I fiddled
around a bit, moved the antenna
around, and concluded that the circuit
wasn’t oscillating, but it wasn’t pick-
ing up WWVB either.
Eventually, I was standing in a dark,
silent basement with only the RF amp
and digital scope turned on. Could it
The circuit board has
copper on both sur-
faces, with the bottom
layer connected to the
top through the many
short wires under the
solder blobs in Photo 2.
With a production
board, you’d use plated-
through holes, but I
don’t have that luxury.
For frequencies above
VHF, you’d also solder
copper flashing around
the board edges to form
a low inductance bond
between the surfaces.
I laid out the circuit
with room for conduct-
ing barriers to isolate each stage.
Those weren’t necessary, but you
should tuck that technique in the
back of your head for future projects.
In RF work, a little distance and a
conductive barrier keep things stable.
The fancy temperature-controlled
soldering iron I use for SMD parts
lacks sufficient mojo to build conduc-
Photo 2—
With input from an antenna and a highly amplified output, the cir-
cuit requires good shielding. Wires through the board bond the upper and
lower ground planes. A copper lid completes the shield. There was no feed-
back!
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
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
67
(800) 377-3244
(714) 547-4494
Fax: (714) 547-4433
www.amidoncorp.com
Coils, inductors
Toko America, Inc.
(847) 297-0070
Fax: (847) 699-7864
www.toko.com
M321BS digital receiver
Ultralink, Inc.
(775) 782-9758
Fax: (775) 782-2128
www.ulio.com
be? I dug out my trusty old Tek
2215A pure analog scope, switched
the cable, turned off the HP54602B,
and watched the trace settle down to
the baseline.
OK, so I won’t have any scope pho-
tos to go along with this article.
Moving the circuit and scope
upstairs showed a strong 80-kHz sig-
nal. Given the filter attenuation at
that frequency, it must have a very
powerful source (the monitor of my
upstairs PC).
Eventually, I got the house quiet
enough so that the trace hovered at
the baseline, showing nothing but
random noise. Over the course of a
few days, I verified that WWVB didn’t
appear at all, even at times when the
NIST propagation charts showed it
should be clearly present.
CONTACT RELEASE
Eventually, I bought an M321BS
serial output WWVB receiver from
Ultralink and discovered that WWVB
simply does not reach here during the
day. In the wee, still hours of the
night, the M321BS manages to syn-
chronize with WWVB, but still
reports interference. As nearly as I
can tell, I’m simply in a terrible loca-
tion for 60-kHz propagation from
Boulder, CO.
If you’re closer to the transmitter in
Colorado, don’t mind waking up in
the middle of the night, and don’t
have my digital oscilloscope, you’ll
probably have better results. Although
the M321BS reduces the problem to
building a box and an RS-232 level
converter, you don’t get the fun of
making the gizmo work.
Would a bigger loop antenna, some
biquadratic active filters, and a few
tunable notches get the job done?
I
SOURCES
RFI kits, R33-050-750 ferrite rod,
33/64 materials, FB-75B-101 beads
Amidon Associates, Inc.
Ed Nisley is an electrical engineer. In
addition, he is a ham radio hobbyist
(call sign KE4ZNU). You may reach
him at ed.nisley@ieee.org.
RESOURCE
J. Carr, Secrets of RF Circuit
Design
, 2d ed., McGraw-Hill, New
York, NY, October 1996.
68
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
hen I set up a
network at home to
allow multiple com-
puters to access the
Internet through a single Telco con-
nection, I wondered about the best
medium to use. At the office we’ve
been using coaxial connections for a
long time, allowing the MACs and
PCs to coexist on the same network.
Now, we don’t use a single MAC and
have upgraded to Cat5, twisted pair
cabling. Installing twisted pair wiring
has the advantage of using the same
punch-down blocks as used for tele-
phone wiring. So, you can run tele-
phone and Ethernet together and
make all connections in a central
location. Some people wire using only
Cat5. Although it’s more expensive
than four-wire cable, using just Cat5
allows for more options later on.
Digital, Intel, and Xerox developed
Ethernet back in 1980. When the IEEE
standards organization got hold of it,
it was renamed IEEE 802.3. The for-
mat is not restricted to one medium;
copper, fiber optics, and wireless all
can use the Ethernet format.
You may be familiar with terms
such as 10Base5, 10Base2, or 10BaseT.
The first two consist of coaxial con-
nections, a 10-Mbps connection with
maximum lengths of 500 and 200
meters, respectively. The 10BaseT
term indicates twisted pair connec-
tions. This differs from the coaxial. A
single coaxial conductor carries both
transmitted and received data over
the same conductor. Cat5 uses one
pair for data transmissions and one
pair for data receptions. Using sepa-
rate twisted pairs means the data
doesn’t have to share the same cop-
per. In addition, differential transmis-
sions are immune to common mode
noise. This also means that each run
of cable has its own transmitter and
receiver, expanding the maximum
length of the network. Of course
these benefits don’t come without a
bit of confusion. Coaxial just “Ts”
into the network, whereas using
twisted pair wiring requires you to
pay attention to the interconnections.
10BaseT connections are usually
through an RJ-45 jack. Standard jack
wiring designates the orange/white
pair (pins 1, 2) as the transmit pair
and the green/white pair (pins 3, 6) as
the receive pair (see Table 1).
If you think of the 10BaseT connec-
tion as a PC and modem, things get
much simpler. The PC is designated
DTE (data terminal equipment) and
the modem is designated DCE (data
communication equipment). In order
to connect the two, a straight-through
cable (e.g., pin 1 to pin 1) is used. This
is because the PC transmits data on
pin 2 while the modem receives this
data on pin 2, and on pin 3 the data is
flowing in the opposite direction,
transmitted by the modem and
received by the PC. When two PCs (or
two modems) are connected to one
another with the same cable, the
transmitters are connected together
FROM THE
BENCH
Perhaps
you
think
net-
works
are
solely for the office.
Jeff’s here to explain
why he hooked up his
home computers, too.
While he’s at it, he
shares how to rig your
own home network.
Jeff Bachiochi
Intelligible HUBbub
Ethernet Home Networking
w
Pin
Color
Name
1
White/orange
TxData+
2
Orange
TxData-
3
White/green RxData+
4
Blue
5
White/blue
6
Green
RxData-
7
White/brown
8
Brown
Table 1—
TIA/EIA specifications for T568-B wiring of
an RJ-45 are listed here. Purchased at local hardware
stores, these connectors are well labeled.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
69
and the receivers are connected
together. No communication paths
can be established. On one side both
are talking while none are listening,
and on the other side both are listen-
ing but no one speaks. This reminds
me of some conversations I’ve had,
total chaos or total silence.
Think of a hub as a modem. The
PC can talk to a hub using a straight-
through cable. For hubs to talk with
one another, the transmitter and
receiver connections must be swapped
on one end. This can be done by mak-
ing a special (null modem) cable or, in
some instances, one of the hub’s RJ-
45s can be configured to swap these
signals internally. Where the coaxial
connections are considered daisy-
chained (a one-to-many connection),
the twisted pair network is star-wired
(a one-to-one connection).
THINK REPEATER
When you think hub, think
repeater. Because each hub repeats
any transmission it receives at all of
its transmitters, it has the ability to
massage the data as well. It has con-
trol of a domain, consisting of every
connection from itself to the device
connected at the other end of wire.
This device may be a PC or another
hub. Because the domain of this hub
shares its domain with that of the
next hub, a virtual interrelationship
exists creating total collision detec-
tion for the network.
It makes sense to listen to the net-
work before transmitting data, cor-
rect? However, there is the possibility
that those two transmissions might
occur at the same time. It might be
that the two just happened to be syn-
chronous in their “presence check” or
delays through the network hubs gave
an artificial idle response. If idle is
not detected, the transmitter can
delay its transmission until the traffic
has cleared.
If a hub detects data on more than
one receiver, a collision has occurred.
The hub will then broadcast a JAM
bitstream, which notifies all nodes on
the network that a collision has
occurred (or is occurring) and all
transmissions should cease and try
again. So, that’s all there is to the vir-
tual collision detection.
Although the frame formats for data
are complex and beyond the scope of
this project, an 802.3 packet size can
vary from 64 to 1518 bytes. It is the
hub’s responsibility to receive and
retransmit this data packet accurately,
even if it doesn’t actually know what
the data means.
Figure 1
—Intel’s (formerly Level One) LXT914
quad Ethernet Repeater is the heart of this
month's project. A four-line interface bus lets
multiple ’914s work together eliminating the
need to tie up ports to expand hub-to-hub.
70
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
ISOLATION AND PHYSICAL
CONNECTIONS
To achieve total isolation between
PCs and/or hubs, each port is isolated
with a small signal transformer. TX
and RX transformers are available in
various packages. I chose to use a DIP
package with a TX and RX trans-
former in the same package. This
allows you to populate each port on
an individual basis without leftover
and unused devices in the package.
The transmitter ratio is 1:1.414 (for a
little gain), and the receiver ratio is
1:1. RJ-45s provide easy connections
to Cat5 cable with runs up to 100 m.
STATUS INDICATION
Single-pin outputs create multi-con-
dition indications using multiple
LEDs. Because an output can drive
high, low, or become tri-stated (not
driven), two opposing LEDs referenced
to one half V
CC
can be alternately
driven by an alternating high and low
output. When the output is tri-stated,
neither LED has a potential across it.
Five ON states can be indicated using
this method. These are the resulting
conditions indicated separately for
each of the four ports, as shown in
Table 2.
In addition to the indicators just
discussed, there are two overall indi-
cators that show general hub data for-
mat violations.
QUAD EXPANDABLE HUB
This month’s project, the
HomeHUB (see Photo 1) assembles
the pieces necessary to build a net-
work for your PCs. The project is
based on Intel’s LXT914 Ethernet
Repeater. Multiple HomeHUBs can be
connected together, thus eliminating
wasted inter-hub connections. There
are other features on this device,
which may make for interesting
future projects.
Now take a look at Figures 1 and 2.
The main sections of this project
include LXT914 repeater, isolation
and network physical connection, sta-
tus indication, expansion bus, and
external management. Let’s start with
the repeater.
The LXT914 was chosen for numer-
ous reasons. This was available in a
non-SMT package (important to many
experimenters). In fact, none of the
parts for this project are SMT. I found
this part available in small quantities
from an online distributor. It costs
less than $10.
The main functions of the repeater
are data recovery, retransmission, and
collision propagation. Upon receipt of
a valid data packet, the repeater
broadcasts the packet to all enabled
transmitters (except the originator).
The LXT914 contains four 10BaseT
transceiver ports and an attachment
unit interface (AUI), which could be
used as a fifth port
with additional cir-
cuitry. Additional
components are
required to access
the AUI; an addi-
tional 10BaseT con-
nection was consid-
ered too costly for
this project when
compared to the
per port cost of
expansion through
its expansion bus.
The LXT914
includes special
network manage-
ment configura-
tions, which allow
you to have some
control over the
twisted-pair ports.
Port LEDs
Condition
Red LED
Green LED
Meaning
1
Off
Steady
RX link pulse
2
Off
Blinking
TX packet
3
Steady
Off
Reversed polarity
4
Blinking
Off
RX packet
5
Alternating
Alternating
Partitioned out
Collision LED
Condition
Red LED
Green LED
Meaning
1
Off
Steady
FIFO error
3
Steady
Off
Collision
Violation LED
Condition
Red LED
Green LED
Meaning
1
Off
Steady
Manchester code
3
Steady
Off
Jabber
Table 2—
System and port LEDs display status information, which helps deter-
mine network health.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
71
In addition to showing these condi-
tions visually, the LXT914 has the
ability to report these through its syn-
chronous serial interface. This is part
of the network management interface
built into the LXT914.
EXPANSION BUS
Multiple HomeHUBs can be bused
together (see Photo 2), eliminating the
need to tie up ports with patch cables.
More than 32 HomeHUBs can be tied
together, but most homes won’t need
more than two or three for all of the
connections. The bus to accomplish
this contains five control lines and a
BCLK. The *IRENA pin allows an
LXT914 to request control of the bus.
The IRDAT pin outputs the data syn-
chronous to the BCLK. Two addition-
al control signals, *IRCFS and
*IRCOL, pass collision status among
the bused LXT914s. The BUSCLK
supplied by a single LXT914 can syn-
chronize everyone on the bus, or each
LXT914 can asynchronously output a
clock when it has control of the bus
through *IRENA.
NETWORK MANAGEMENT
INTERFACE
There are 48 bits of setup registers
within the LXT914. These register
bits enable and disable control func-
tions of this repeater (i.e., automati-
cally disabling ports (connections)
that are causing problems on the net-
work). The default condition for these
functions is off if the SDI input is tied
low. The LXT914 has the ability to
read 48 bits from an external serial
EEPROM if one is attached. If SDI is
not tied low, the LXT914 clocks in
stored data. In fact, when multiple
HomeHUBs are used, 48 bits will be
clocked out for each unit attached.
When the first HomeHUB finishes its
read, it signals the next board with
the *SENO output. The next
HomeHUB takes over clocking its 48
bits, and so on.
In larger systems, an external man-
agement device (EMD) can be used to
initialize all HomeHUBs. This is
accomplished via the same clock and
data I/O line as used by the serial
EEPROM. To enable the network
management interface, the EEPROM
is not installed and EXT input is
pulled low. The HomeHUB will now
know that it should not attempt to
clock in initialization data, but the
clock will be applied from the EMD.
When initialized via the EMD, the
LXT914 will output 48 bits of status
information every packet transmis-
sion or interrupt event. The EMD can
keep tabs on HomeHUB. Status
includes packet received on Portx,
collision on Portx, links lost on Portx,
polarity reversed on Portx, Portx iso-
lated, short packet on Portx, and long
packet on Portx.
The standard hub does not have
these features so they will not be
explored this month. (If there is any
interest from readers, I may revisit
this in the future.)
ETHERNET TRANSMISSIONS
Although I’m not discussing the
data format, the signaling method for
transmitting that data does go hand-
in-hand with the circuitry presented
here. Referring to Photo 3, you can
see that the carrier wave picked off at
Port 4’s receiver is, in fact, 10 MHz
(remember the 10 in 10BaseT). If you
Photo 1—
Tying four PCs
together is easy with the
Ethernet HomeHUB. LED
indicators show traffic
through the connections as
well as individual port status.
72
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
look closely at the scope photo you
can see that the multiple scans show
a reversal in phase of the carrier. This
is key to how the data is represented.
The signaling method used for
Ethernet is Manchester phase encod-
ing and decoding.
Using the Manchester scheme, one
data bit is transmitted for each cycle
of the carrier. At the transmitter, a
10-MHz clock is used as a reference.
On each falling edge of this clock the
data bit to send is sampled. The carri-
er’s phase must be in sync with the
clock for a data 0 and 180° out of
phase with the clock for a data 1. On
the rising edge of the clock, the phase
of the carrier is changed only if data
has changed from the last bit. If the
data is all 1s, the carrier will remain
out of sync with the clock, and there
will always be a point where the car-
rier crosses through zero (out of phase
with the original clock). If the data is
all 0s, the carrier will remain in sync
with the clock, and there will always
be a point where the carrier crosses
through zero (in phase with the origi-
nal clock). A phase reversal must take
place when the data changes state.
At this point the carrier will look
like it has been reduced to half of the
clock frequency, because for this
reversal to take place the carrier
reverses direction and doesn’t cross
through zero.
For the receiver to translate data
correctly, it must get in-phase with
the transmitter’s clock. Take a look
at Figure 3. Because repeating 1s or
0s looks like the same thing (you
can’t tell what’s in-phase or out-of-
phase yet), an alternating pattern of
1s and 0s is used. This looks like a
5-MHz carrier because the phase is
Photo 2—
Ribbon cable expansion
brings ’914 control signals as well as
power to up to 32 additional PCBs
(although not many homes will need
128 access points).
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
73
Figure 2—
Physical connections shown here use shielded
RJ-45s to reduce interference. SV1 and SV2 jumpers pro-
vide inter-board communications. This makes the HomeHUB
expandable without tying up RJ-45s.
480-837-5200 / fax: 480-837-5300 / info@embeddedx86.com
74
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
CAT5
Cat5 cable is rated to 100 MHz.
You’ll want to string plenty of this
prior to putting up Sheetrock for any
new construction. It’s a bear to do
wiring in a preexisting home. Your
home improvement center has plenty
of products to help make this job easi-
er. By far, the easiest installation is
placing outlet boxes on the surface of
existing walls. The wire runs on the
outside of the wall as well, and if you
can be discreet, it isn’t too ugly. Most
people prefer mounting the outlets
inside, but flush with the wall’s sur-
face (like your power outlets). This
requires some fairly messy holes but
the finished product can be almost
invisible. Wall plates are available
also changing. The receiver’s phase-
lock loop will synchronize with this
carrier if the alternating pattern is a
sufficient length.
A doubling of this derived clock
will now be in sync with the trans-
mitter’s clock. Once synchronized,
the receiver’s phase-lock loop must
be able to hold sync while receiving
either phase of the 10-MHz carrier.
Thus, this clock can be used as a ref-
erence to determine the data
received. Because it’s now in sync
with the 10MHz data.
From this discussion you can proba-
bly understand why it is important to
get the differential wiring correct.
Reversing the differential connections
means inverting the data!
Photo 3—
This scope shot clearly shows the phase reversal of the 10-MHz Ethernet carrier.
Figure 3—
Trace
a
and
b
represent the two
phases of the 5-MHz
Ethernet carrier (alter-
nating data, 1s and 0s,
are phase reversals of
the 10-MHz carrier
which then look like 5
MHz). Trace
c
is a
phase-locked loop
adjusting to either phase
of the 5-MHz signal. A
frequency doubler, trace
d
, then creates a 10-
MHz signal in sync with
the original transmitter’s
carrier.
PRE-SYNC
IN-SYNC
a)
b)
c)
d)
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
75
WHY NETWORK?
If you haven’t already convinced
yourself that you need a network in
your home, here are a few reasons you
may not have thought of. The most
obvious incentive is to file-share
without having to make diskettes and
physically bring them around to
another machine. Program sharing, or
at least locating program data on one
central machine, allows everyone
connected to have access to the same
data without redundant copies, which
never quite seem to get updated cor-
rectly. Instant messaging between
computers is great for announcing
phone calls or that supper is ready (no
more yelling). For me the biggest
advantage in having a home network
is still allowing everyone to share a
single Internet connection through
the network via a single
modem/phone line. For my kids, it’s
being able to battle one another in a
Doom maze (their video game of
choice). My oldest two sons now
bring their laptops whenever they
come to visit. They don’t want to be
left out of the battle. It seems no one
gets tired from hide-and-seek, espe-
cially when you can run around with-
out running around.
I
with one, two, three, four, or more
modular ports that can be populated
with a variety of connectors. My
favorite combination is RJ-45 (net-
work), RJ-11 (Telco), and two F-con-
nector coaxials (TV/VCR/SAT/
ANT). Don’t spend to much time
trying to determin the best place-
ment for these outlets because
you’ll eventually want them some-
where else. You’ll need to use the
same color-coded wiring standard
on every outlet to make sure every-
thing stays compatible. Refer back
to Figure 1 for standard T568-B,
which is what I use.
Most Ethernet adapters come with
a patch cable. This cable goes from
your computer to the hub (or in most
cases, to an RJ-45 mounted in a wall
outlet, which is an extension cable
going from the wall outlet to the hub
in the basement). Although the RJ-45
sockets have punch-down connectors,
more than likely you’ll need to buy a
crimping tool to be able to correctly
apply an RJ-45 plug onto the Cat5
cable.
Jeff Bachiochi (pronounced BAH-key-
AH-key) is an electrical engineer on
Circuit Cellar’s engineering staff. His
background includes product design
and manufacturing. He may be
reached at jeff.bachiochi@circuitcel-
lar.com.
SOURCES
LXT914 Quad Ethernet Repeater
Intel Corp.
(602) 554-8080
Fax: (602) 554-7436
www.intel.com
JAM bitstream
JAM Technologies LLC
(617) 526-8666
www.jam-tech.com
76
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
ea, verily as I
write this column
by candlelight….
Despite what you may
have heard about California’s energy
crisis, it’s not so bad (not for me any-
way). I happen to be on a circuit that’s
immune from the rolling blackouts.
Furthermore, with a family’s worth of
expenses for taxes, insurance, car pay-
ments, and mortgage, the price I per-
sonally pay for energy seems like an
incredible bargain.
Of course, it’s just that presumption
that it’s free juice coming out of the
wall that makes it hurt so much
when it disappears.
My heart really goes out to busi-
nesses big and small for whom energy
problems, both price and reliability,
are a showstopper. It’s one thing to
miss that Laverne and Shirley rerun,
quite another to have your production
line come to a screeching halt as you
weep over an energy bill that has
tripled before your very eyes.
Perhaps there is a bright lining. The
crisis is inspiring folks to look at
some of the Econ 101 fundamentals
like supply, demand, and price. The
upshot is a growing awareness that
we shouldn’t waste energy as though
it’s free, because it isn’t.
It’s solving that awareness problem,
according to a recent article, “Davis
Weighs Meter Retrofit” ( SJ Mercury
News
, February 25, 2001), that’s caus-
ing some experts to advocate “real-
time pricing” schemes. UC Berkeley
economist Severin Bernstein said,
“We really need to have these very
strong price signals because the alter-
native is rolling blackouts.”
SILICON
UPDATE
Tom Cantrell
Power Tripped
y
PGA
x10,50
X10
4
th
-order
∆Σ
modulator
2
nd
-order
∆Σ
modulator
X1
Voltage
reference
I
IN
+
I
IN
–
V
IN+
V
IN–
V
REFIN
V
REFOUT
Power
monitor
VA–
PFMON
Digital
filter
Digital
filter
System
clock
/K
Clock
generator
High-pass
filter
Power
calculation
engine
(energy
*IV
I
RMS
'
V
RMS
)
High-pass
filter
Serial
interface
E-to-F
Calibration
SRAM
X
IN
X
OUT
CPU
CLK
D
GND
Watchdog
timer
VD
+
*RESET
VA
+
MODE
*CS
SDI
SDO
SCLK
*INT
*EDIR
*EOUT
Figure 1—
The overriding requirement for a silicon power meter like the CS5460A is dual ADCs to sample voltage
and current at exactly the same time. After that, it’s a matter of crunching the numbers to compute rms voltage, cur-
rent, and energy.
California’s
recent
power cri-
sis has
shined the
spotlight on energy
conservation. Often
taken for granted,
power isn’t free nor
unlimited. From the
West Coast, Tom
talks about the prob-
lem and fixes.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
77
CLOSING THE LOOP
The economists will tell you that
what consumers need is accurate and
timely information, namely how
much energy costs right now and how
much we are using. Enabled with that
knowledge, it’s not hard to imagine
energy management systems becom-
ing a lot more sophisticated, even on
a residential scale.
For example, major appliances such
as refrigerators, washing machines,
dryers, and water heaters could all be
programmed to be smart energy shop-
pers, meeting the demands of a partic-
ular homeowner at the lowest price.
I’ve got a circulation pump on my
hot water line to speed the delivery to
remote faucets, which is not only
convenient but saves water. Sure,
water is another one of those things
that you take for granted because you
consider it to be almost free. It’s no
surprise that every now and then
there’s a shortage.
Anyway, that circulation pump
runs all the time, even though
demand is cyclical (i.e., it really could
be shut off overnight). Along the same
lines, that refrigerator in the garage
doesn’t need to maintain a particular-
ly tight temperature range and could
chill when it’s cheap. When you
punch the button on the dishwasher,
does it really need to happen right
now, or just finish the job before your
next meal? You get the idea.
Nobody worried about this kind of
stuff at a few cents per kilowatt-hour.
But the spot prices associated with
peak demand have recently gone as
high as $0.30 to $0.40 per 1 kWh.
SPINNING WHEEL
Unfortunately, keeping track of
energy use isn’t easy. Besides waiting
for the after-the-fact surprise in the
mailbox, the only alternative is to run
outside and check the meters, whim-
sically low-tech mechanical gadgets
that seem little changed from the
days of yore. Considering the
increased need for real-time monitor-
ing and the march of technolology, it’s
clearly time for an upgrade.
Where there’s a will, there’s a way,
and usually a chip. This time it’s the
CS5460A single-phase, bidirectional
power/energy IC from the Crystal
division of Cirrus Logic (see Figure 1).
It’s designed to accurately (i.e., 24-bit
resolution) measure instantaneous
voltage, current, and power (i.e., volt-
age × current) and also calculate rms
voltage, rms current, and the bottom
line, energy (i.e., power over time).
Resolution of 24 bits may seem like
overkill, but it’s necessary to main-
tain accuracy for the calculated (ener-
gy, V
RMS
, I
RMS
) values. In the default
configuration, thousands of instanta-
neous readings (4-kHz conversion
rate) go into each calculated result (1
Hz), so it wouldn’t take much conver-
sion error to mess up the calculations.
Delta-sigma converters are the call
for moderate-speed, high-resolution
applications, and the CS5460A
includes a pair of them, one for volt-
age and one for current.
Why not just share a converter
between both channels, the typical
approach for multi-channel muxed
ADCs? The answer is simply a matter
of time (i.e., both current and voltage
have to be captured at exactly the
same instant in time to accurately
determine instantaneous power).
WATTS UP, DOC?
Let’s follow the electrons from
input to output across the CS5460A
to see how a modern replacement for
wheel-and-dial power meters works.
N L
Voltage
transformer
M:1 RP
V
*
N L
Current
transformer
N:1
R
B
Alternate sensor
options
R
2
R
1
N
L
V
IN+
V
A+
V
IN–
I
IN–
I
IN+
V
REFIN
V
REFOUT
V
A–
CS5460A
V
D+
PFMON
CPUCLK
X
IN
*RESET
*CS
SDI
SDO
SCLK
*INT
*EDIR
*EOUT
DGND
RP
V
*
RP
I
◊
R
S
CP
I
◊
0.1µF
11
12
CP
V
◊
14
Optional
clock
source
Serial
data
interface
24
19
7
23
6
5
20
22
21
1
2
17
0.1µF
470nF
500
Ω
500
Ω
100µF
0.1µF
10
Ω
3
10k
Ω
5k
Ω
2.5MHz
20MHz
X
OUT
13
4
To
service
◊
Refers to input
protection
– Section 4.13
RP
I
◊
16
15
10
9
Figure 2—
The CS5460A requires scaling the AC voltage and current differential inputs to 150 mV using sense
resistors or transformers.
Voltage
∆∑
Delay
regulator SINC
2
Delay
regulator
FIR
HPF
APF
SINC
2
N
√
+
x
x
Configuration register
PC[6:0] bits
Current
∆∑
SINC
2
FIR
HPF
APF
SINC
2
N
√
+
x
x
–
N
∑
x
x
x
P
OFF
◊
TBC
◊
V
◊
V
ACoff
◊
P
◊
I
◊
I
ACoff
◊
I
DCoff
◊
I
gn
◊
÷
4096
V
RMS
◊
E
◊
I
RMS
◊
◊
Denotes register name
–
V
DCoff
◊
V
gn
◊
E to F
Pulse-rate
◊
*E
OUT
*E
DIR
Figure 3—
Dual ADCs sample voltage and current at the same time. After the raw conversions are filtered, phase
compensated, and scaled, the rms and energy calculations are performed.
78
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
The chip can operate from one 5-V
or a dual ±2.5-V supply. In either case,
it can be configured for single-ended
(i.e., I
IN
- and V
IN
-connected to ground)
or differential inputs. The allowed
input range for the current channel is
30 or 150 mV (selectable 10 or 50×
gain) and 150 mV (10× gain only) for
the voltage channel. Note that differ-
ential operation is allowed in the sin-
gle supply configuration because the
chip can tolerate – 0.25 V on the input
(e.g., – 75 to 75 mV).
The CS5460A is suitable for two- or
three-wire single-phase hookup.
Multiple chips can be ganged together
running off a single clock to handle
multi-phase supplies.
As shown in Figure 2, the AC con-
nection can be accomplished via resis-
tors (divider for voltage, in-line for
current) or transformers. Typically,
the power metering subsystem will
need to be isolated from whatever it’s
connected to, either with the trans-
former option or alternatively isolat-
ing the digital output. Standard prac-
tice also calls for a measure of input
protection with current limiting resis-
tors, which along with some capaci-
tors also serve as a front-end filter for
any stray high-frequency noise.
With correctly scaled and nicely
tamed inputs, it’s time to head on-
chip (see Figure 3). The voltage and
current inputs are converted at a high
rate (e.g., 4 kHz) determined by the
chip’s clock (4.096 MHz typically) to
determine instantaneous voltage, cur-
rent, and power. Completion of each
conversion is indicated by a CRDY
status bit and, if enabled, assertion of
the INT output.
A programmed num-
ber of conversion cycles
comprise a computation
cycle that updates the
V
RMS
, I
RMS
, and energy
outputs. For valid calcu-
lated results, a computa-
tion cycle must encom-
pass at least 10 conver-
sion cycles. Completion
of each computation
cycle is indicated by a
DRDY status bit and, if
enabled, assertion of the
INT output.
PURPLE PHASE
As mentioned earlier, the voltage
and current measurements have to
take place at the same time to yield
meaningful results. Having dual
ADCs is necessary, but not sufficient,
to completely address the issue of
phase compensation.
The output of each delta-sigma
modulator passes through a sinc low-
pass filter, second order and fourth
order for voltage and current, respec-
tively. The output then optionally
passes through a high-pass filter (HPF)
to help remove DC offset as an alter-
native to the subsequent user-pro-
grammed hardware offset adjustment.
If you want to utilize the HPF on only
one channel, the other should be pro-
grammed to utilize the dummy all-
pass filter (APF) to equalize the delay.
Backing up a bit on the voltage
channel, you notice a couple of other
progammable delay elements. These
other delay elements are designed to
compensate for any phase delay intro-
duced by the external voltage- or cur-
rent-sense circuits. The proper delay
value is determined by testing with a
purely resistive load on the AC line;
inductive and capacitive loads intro-
duce their own phase shifts. The
seven bits of programmable delay
allow fine-tuning the voltage and cur-
rent phase relationship in 0.0215°
increments over a ±2.8° range.
BITS AT LAST
The instantaneous voltage and cur-
rent are written to their result regis-
ters and then handed over to the com-
putation block, which performs the
long-term rms and energy calcula-
tions. Finally, ones and zeros!
What gets done with them depends
on whether or not the overall design
includes a micro. If so, the host issues
8-bit commands and accesses 24-bit
registers through a 4-pin (*CS SDI,
SDO, and SCLK) SPI clocked serial
port. The port isn’t really a bottleneck
because it runs at up to 2 MHz. SCLK
has a special rise/fall time spec (up to
100 µs versus 1 µs for other digital
inputs) to accommodate slow switch-
ing isolators, a nice touch. Similarly,
SDO is specified at 5 mA to drive an
optoisolator LED.
*E
OUT
*E
DIR
*E
OUT
*E
DIR
Positive energy
Negative energy
Negative energy
Positive energy
128 ms
128 ms
Figure 4—
The CS5460A doesn’t need a micro to do something useful. In
Standalone mode, the E
DIR
and E
OUT
pins offer frequency, mechanical
counter (
a
), or stepper motor outputs (
b
).
Voltage
reference
Crystal
4.096 MHz
CS5460
*CS
SDI
SDO
SCLK
*INT
E
DIR
E
OUT
V
REF
IN OUT
Serial
EEPROM
V
IN+
V
IN–
I
IN+
I
IN–
REF
AGND
Test
switches
80C51
Microcontroller
32K x 8
SRAM
LEDs
RS-232
Trans-
ceiver
Reset
circuitry
Crystal
20.0 MHz
RS-232
Connector
VA+
VA–
AGND
VD+
V
U+
Figure 5—
The CDB5460A board, which connects to a PC via the COM port, provides a low-cost, easy-to-use plat-
form for evaluating the CS5460A chip.
a)
b)
80
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
Other CS5460A features that come
in handy if you’re using a micro
include a power monitor that can gen-
erate interrupts and a watchdog timer
that can generate an interrupt if
power is failing or the chip hasn’t
been accessed in a few seconds. For
compatibility with any micro, the
INT output driver (totem pole or open
collector), polarity, and edge or level
assertion is programmable.
The CPUCLK output pin provides a
buffered version of the clock (2.5– 20
MHz, 4.096 MHz typically) that can
supply a clock for an attached con-
troller. To minimize noise, a control
bit allows the phase of CPUCLK to be
inverted so external logic switching
occurs on the opposite edge relative to
the CS5460A. If the CPUCLK isn’t
needed as such, another control bit
allows it to be used as a general-pur-
pose output.
If the micro has an ADC, it also can
take advantage of the CS5460A’s own
reasonably stable (60-ppm/° C) on-chip
2.5-V reference, made available on the
VREFOUT pin. Alternatively, a VRE-
FIN input allows the CS5460A to use
a more precise external reference.
If you’re not using a micro, jumper
the CS5460A MODE pin high and the
chip uses the SPI port to “ autoboot”
itself (initialize registers and receive
commands) from an external serial
EEPROM. In Standalone mode, two
outputs, E
OUT
and E
DIR
, can be config-
ured to deliver various digital repre-
sentations of energy consumption. Or,
either or both lines can be used as
general-purpose digital outputs.
As their pin names imply, in
Normal mode, E
OUT
outputs pulses at
a frequency corresponding to the ener-
gy level and E
DIR
the direction (posi-
tive or negative energy). The frequen-
cy range is programmable to allow
calibration. However, the chip will
work without calibration, which may
be acceptable if you’re more con-
cerned with relative, rather than
absolute (or especially accurate),
measurements.
In addition, the CS5460A offers two
slower (e.g., 10 Hz) mechanical output
modes, Totalizer and Stepping Motor
(see Figure 4). Reattaching the wheels
and dials seems to defeat the purpose,
but I suppose some metering apps
may prefer a hybrid solution rather
than going completely electronic in
one fell swoop.
AC/DC UNPLUGGED
To get started with the CS5460A,
check out the CDB5460A evaluation
board (see Photo 1).
As shown in Figure 5, the board
includes a ’51 MCU, serial EEPROM,
SRAM, and RS-232 connection to a
host PC. There’s also a precision low-
drift (5-ppm/° C) voltage reference
(Linear Technology’s LT1019) that
serves as an optional (jumpers)
replacement for the on-chip reference.
Four BNC connectors accept the
low-voltage (150 mV)
differential voltage
and current sense
inputs required by
the chip. This allows
evaluation and test-
ing with a bench-top
function (sine wave)
generator without
having to fool around
with high voltages,
something the com-
pany’s lawyers no
doubt frown upon.
A DIP switch
selects Host (i.e., the
PC) or Autoboot
mode. Using the PC
mode, the chip can be configured and
calibrated and the proper values writ-
ten into the serial EEPROM. Then,
flipping the switch to Autoboot mode
will allow stand-alone operation (i.e.,
the ’51 is no longer involved) with the
new parameters.
Two LEDs monitor the E
OUT
and
E
DIR
lines, most useful in the mechan-
ical output modes, which are slow
enough for you to see the activity. In
the center of the board is another
bank of four LEDs. According to the
schematic, one of them signals that
power is applied and the other three
are available for your own use.
The RS-232 port runs at the usual
plain vanilla 9600 8-N-1. There are
special DIP switch and headers for
testing your COM port connection,
helpful for getting past the seemingly
inevitable head scratching. There are
also plenty of test points, headers, and
spare breadboard areas.
As an aside, it was interesting to
see that the board has a USB section.
Although it wasn’t populated, the fact
that they were thinking about it does
reinforce my opinion that USB and
Ethernet aren’t just for desktops, they
are the wave of the future for EV
boards as well.
POWER ME SOFTLY
The Windows-based software that
comes with the board helps you get
up to speed with the chip quickly. It
isn’t super-fancy, but does handle the
basics with finesse and performs
some sophisticated data analysis.
Photo 2—
So many bits, so little time. The software that comes with the EV
board makes it easy to tweak and twiddle to your heart’s content.
Photo 1—
The question is how fast is the meter run-
ning? The CS5460A is the silicon-age answer.
82
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
conversion to voltage and current
depends on the specifics (calibrated
gain and offset) of the external sense
circuits. It would be nice if they could
add a feature to the software that
would allow you to enter your own
conversion factors and then scale the
displays to use volts, amps, and watts.
And the truth shall set you free.
I
We all have better things to do with
our time (and brain cells) than twiddle
bits, right? Especially true considering
that all the registers are 24-bits long.
“ Hmm, I want to set the nineteenth,
twelfth, and sixth bit, so in hex
that’s…”
Instead, the software pro-
vides a helpful register access window
(see Photo 2), breaks out all the bits,
and provides convenient decoded
access. Additional
screens are provid-
ed for offset and
gain adjustment
and calibration.
When everything
is set up, start by
issuing commands
to perform single
or continuous con-
versions. You can
monitor the result
registers directly
or, for stand-alone
apps, capture the
pulse count and
frequency on the
E
OUT
and E
DIR
pins.
Going a step beyond the ordinary,
the software also includes sophisticat-
ed analysis and display routines
including time domain, histogram,
and FFT (see Photo 3), including tid-
bits such as signal-to-noise ratio.
My only complaint is that the data
collection functions display their
results using raw register values.
That’s understandable because the
Photo 3—
Assuming you’re not experiencing a rolling blackout, the CS5460A can
keep a close eye on your power consumption.
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.
SOURCES
CS5460A, CDB5460A
Cirrus Logic
(800) 888-5016
(512) 445-7222
Fax: (512) 445-7581
www.cirrus.com
LT1019
Linear Technology Corporation
(408) 432-1900
Fax: (408) 434-6441
www.linear-tech.com
Problem 1
—There are three ants at the three corners of a
triangle. Each starts moving towards another randomly-
chosen corner. What is the probability that no ants col-
lide?
Contributed by Wael Badaway
Problem 2
—What makes PNP transistors slower than
NPN transistors?
Contributed by Naveen PN
Problem 3
—You can use either stack or registers when
passing parameters between C and assembly code. It
seems very logical to have a 68000 "C" convention to
pass data parameters in registers D0 and D1 and
address parameters in registers A0 and A1. However,
what is logical about using the Analog Devices ADSP
SHARC convention with registers R0, R4, R8 and
R12 to pass parameters? Why not R0 through R3?
Contributor: Michael Smith
Problem 4
—The following circuit is designed to
demonstrate the working of a NAND gate. The LED
indicates the output; and the switches S1 and S2
form the inputs. There is a mistake in the circuit.
Can you spot it?
Contributed by Naveen PN
1K
1K
1
14
3
LED
IC74LS00
5V
330 ohm
7
2
S2
S1
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
CIRCUIT CELLAR
Test Y
Your E
EQ
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
83
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 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
85
Scottsdale, Arizona
Ph: 480.998.3503
Fx: 480.998.3504
Resistance Substitution Device
Order
on-line for
FREE shipping!
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)
86
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
For acquisition and control of digital and 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
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 , external driver capabilities.
Internal FIFO for linear, cubic or spline Interpolation.
24 digital I/O,2 SPI, 11 analog channels on-board.
32 bit DLL with examples in VC++,VBasic and Delphi.
9 Channel Data
Loggers from
US$400. Ask us, or
visit our web site.
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
87
Give Your Product Ethernet & TCP/IP
See our new site at www.jkmicro.com
88
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
© 2001 Sealevel Systems Incorporated
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
89
• 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
Easy to use converter adapts any
....by using real-time emulators.
HC12, HC11
8051
C166
C500
ST10
Super10
Philips XA
68300 family
Ubicom
90
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
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
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
91
Email: sales@picofab.net
92
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
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…
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
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
93
94
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
56&RQWUROOHGRU&DQQHG&\FOHG&RQWUROOHG
6KRUW&LUFXLWDQG2YHU7HPS3URWHFWLRQ
3URJUDPPDEOHELWRSWLFDOO\LVRODWHGLQSXWV
%XLOWLQ$FFHOHUDWLRQ'HFHOHUDWLRQUDPSLQJ
6RIWZDUH&XUUHQW$GMXVWPHQWYLD56
• Design, PCB Fabrication & Assembly
• DS, Multi-Layer, SMT & RF PCBs
• In-house CAM & Photo Plotting and
Superior Quality at Competitive Prices
"...your product was delivered on
schedule and was of the highest quality."
R.R. Bell Atlantic Test Systems
7845-M Airpark Rd., Gaithersburg, MD 20879
Fax: (301) 990-6715 BBS: (301) 990-9628
ADVERTISER’S
www.circuitcellar.com
CIRCUIT CELLAR
®
Issue 131 June 2001
95
INDEX
24
ADAC
93
Abacom Technologies
92
Abia Technology
85
Ability Systems Corp.
86
ActiveWire, Inc.
84
Advanced Embedded Systems
14
Advanced Embedded Technologies
52,70
Advanced Transdata Corp.
45
All Electronics Corp.
94
Amazon Electronics
9
Amulet Technologies
84
Andromeda Research
86
AP Circuits
65
ATOP Technologies
7
Arcom Control Systems
47
Atmel Corporation
92
Bagotronix, Inc.
84
Basic Micro
85
Bay Area Circuits
91
Beige Bag Software
85
CCS-Custom Computer Services
94
CSMicro Systems
94
Capital Electro-Circuits, Inc
93
Cermetek Microelectronics, Inc.
90
Circuit Specialists, Inc.
86
Conitec Data Systems
35,89
Connecticut mircoComputer Inc.
85
Copeland Electronics Inc.
86
Cyberpak Co.
66
Cygnal Integrated Products
92
Data Design Corp.
The Advertiser’s Index with links to their web sites is located at www.circuitceller.com under the current issue.
Page
53
Dataprobe Inc.
C4
Dataman Programmers, Inc.
91
Decade Engineering
59
Design Logic 2001 Contest
87 Designtech Engineering
90
Digital Products Company
18
Dreamtech Computers
75
Earth Computer Technologies
71
ECD (Electronic Controls Design)
84
EE Tools
(Electronic Engineering Tools)
23
EE GLOBE Inc.
79,88
EMAC, Inc.
71
Engineering Express
84
FDI-Future Designs, Inc.
42
General Software
85
HVW Technologies Inc.
84
Hagstrom Electronics
89
IMAGEcraft
73
ICE Technology
53
IndustroLogic,Inc.
91,93
Intec Automation, Inc.
55
Interactive Image Technologies Ltd.
91
Intronics, Inc.
65,87
JK microsystems
53
JR Kerr Automation & Engineering
85
LabMetric, Inc.
89,90
Laipac Technology, Inc.
94
Lemos International
2
Link Instruments
85
Lynxmotion, Inc.
90
MaxStream
91
MCC (Micro Computer Control)
83
MetaLink Corporation
88
MJS Consulting
87,88
Micro Digital Inc
93
microEngineering Labs, Inc.
63,72
Microchip
50,81
Micromint Inc.
74
Midwest Micro-Tek
41
Miller Freeman-ESC
35,64
MVS
91
Mylydia Inc.
17
NetBurner
88,94
Netmedia, Inc.
89
Nohau Corp.
87,88
OKW
51
On Time
94
Ontrak Control Systems
92
PCB Express, Inc.
C2
Parallax, Inc.
83
Phytec America LLC
92
Phyton, Inc.
91
Picofab Inc.
91
Prairie Digital Inc.
88
Pulsar Inc.
33
R4 Systems Inc.
84
R.E.Smith
89
RLC Enterprises, Inc.
86
RMV Electronics Inc.
15
Rabbit Semiconductor
72
Radiotronix, Inc.
42
Remote Processing
85
SMTH Circuits
37
Saelig Company
5
Scott Edwards Electronics Inc.
88
Sealevel Systems Inc.
14,91
Senix Corp.
94
Sigg Industries
83
Signum Systems
85
Sirius MicroSystems
87
SmartHome.com
14
Softools
34
Solutions Cubed
83
Square 1 Electronics
90
Street Rod Digital
90
Tech Systems
40,73
Technologic Systems
86
Technological Arts
90
techBITES INTERactive
C3
Tech Tools
89
Tern Inc.
25
Texas Instruments
67
Trilogy Design
92
Vantec
92
Vetra Systems Corp.
86
Weeder Technologies
1
Wilke Technology GmbH
67
Xelos
93
Xilor Inc.
87
Z-World
83
Zanthic Technologies Inc.
Keyless Security Entry Control System
Scan 3-D Project
Steplocked Magic Sine Waves
USB, FTDI Style
The Lighter Side of Programming: How to Improve a Singing Fish
I From the Bench
: The Missing (Wireless) Link
I Silicon Update
: Liquid Crystal Delight
I Applied PCs:
Tuning the Data Radio: Wireless Data Communication
Page
Page
Page
Embedded Programming
PREVIEW
132
he worst part about technological revolutions is that wherever you are along the timeline, the outcome
and long-term consequences are just as difficult to predict. For some people, this is an invitation to head
for cover. For NASDAQ watchers, it is an equal invitation to gamble or duck.
In spite of all the dot bombs, there has been a lot of speculation on how computers and the Internet will affect
our lives and whether it will be good or bad. Despite predictions that we’d all have Internet-connected inventory-managed kitchens
by now, it is still only speculation and most order-online grocery houses have failed. Will your refrigerator ever take inventory, cre-
ate a shopping list, and order the groceries itself? I don’t know and I’m still not sure I ever want it to.
Because I don’t have a crystal ball, I can only look at history to see how technology becomes integrated. Obviously, revolutionary
change is not instantaneous. No matter how quickly engineers have adapted to computers, history suggests it takes a good 30-35
years before society truly reorients itself around any revolutionary “new” technology. Prior to that, any changes generally involve
just doing the old stuff better.
A specific example of this was the transition from steam-powered manufacturing to electric motors. Steam-powered factories
were designed as single long buildings with a powered drive shaft. Machines derived power through a pulley-and-belt system con-
nected to the drive shaft. Adding a new machine was easy as long as there was room along the drive shaft.
The advent of the electric motor extinguished the noisy, smelly steam system almost overnight. Initially, however, the electric
motor merely replaced the steam engine by turning the long central drive shaft. It took a number of years before people built indi-
vidual electric-motor-powered machines to replace the single line. As a result, the long open manufacturing building made way for
compartmentalized manufacturing and physically separate production departments. Of course, the real benefit of electric motors
came as they were eventually applied to entirely new disciplines.
I’ve said this before but, in my opinion, the real computer/Internet revolution hasn’t occurred yet. Yes, our cars run better
because 50 microprocessors provide coordinated monitoring, we can put a city library in a suitcase and we can teleconference
anywhere on the planet. We have succeeded in enhancing the speed and reliability of virtually all our traditional processes and pro-
cedures.
The early days of this computer revolution were driven by breathtaking hardware enhancements. The second half is all about
applications and connectivity. Tech stocks might be in the pits now but they will rebound with a vengeance. As the classic rules
about supply and demand dictate, companies can gear up all they want making the Internet lightning fast and efficient, but a giant
pipe is useless until there are enough broadband-connected end users demanding applications through it. Dot bombs and tech
companies weren’t necessarily failed missions. For many it was simply a case of supply leading demand.
The real developments will come when all this technology is applied to things we never thought possible. When you have a
friendly machine that exactly tailors your personal environment, tracks your habits, and presents you with your favorite electronic
information, foods, and products, will you prefer its holographic assistance to a real person? When children are immersed in a 24/7
Internet world where they matter-of-factly incinerate every fictional adversary, do they miss the personal interaction that helps them
adapt to the real world? The real change may be social.
As a publisher, I look forward to describing and presenting all the“toys” and “techniques” that move us along this revolutionary
path. But, as an everyday guy experiencing the benefits and consequences of all the jogs and dips along the way, I want us to be
mindful that invention shouldn’t be a mindless quest either.
Still Doing the Old Stuff Better
INTERRUPT
t
steve.ciarcia@circuitcellar.com
PRIORITY
96
Issue 131 June 2001
CIRCUIT CELLAR
®
www.circuitcellar.com
In-Circuit Firmware Development with
evelopment tools from TechTools
ER3 will speed up your firmware
development by eliminating the need
to remove-erase-program and re-
devices plug into the EPROM
socket on your target board
We provide software that loads your
firmware code into the emulator in a matter of
seconds! No more waiting for the eraser or
EPROM programmer. No more “debugging” bent
FlexROM emulators provide engineers with a flexible
development tool for any Embedded project that uses an
external FLASH, EPROM or SRAM device.
see the Target’s address fetches with FR3’s Hardware
FR3 is a Flexible, in-circuit memory Emulator with instrumentation.
ER3 is designed for quick, in-circuit firmware test cycles.
TechTools Complete Development System with integrated
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