You are on page 1of 67



$3.95 U.S.
$4.95 Canada
#9 8 S E P T E M B E R 1 9 9 8
|HB|00|0 PP||B|0N8
Data Acquisition Goes Ballistic
Recording Rocket Acceleration
Audio Spectrum Analyzer
MicroMonitor Your
Cars Performance
Fundamental FAQs



2 Issue 98 September 1998 Circuit Cellar INK

The Final Rendition

ike any kid, when I studied music, I had my
favorite pieces and those I practiced so many
times that the rest of the family had strains of Happy
Birthday or Three Blind Mice intermingling with
recipe ingredients, calculus assignments, crop-rotation
decisions, and so on. My mother, an accomplished pianist and organist for
one of the larger congregations in the nearby city, however, knew the real
secret to success, Janice, lets hear your scales. She was equally fond of
those inane Hannon exercises, not to mention arpeggios, triads, chords,
harmony, history, etc. She had quite a list.
Surprise, surprise, with time, a little patience, and some good old-
fashioned parental supervision, I actually got to be not too bad at churning
out a little Bach, Chopin, Kabalevsky, and many Hannon exercises. In
preparation for my last music exam, I had pushed my way up to five hours
of practice a day (now theres a new definition of tedium, eh?!).
Probably the most nerve-racking experience was preparing for recitals.
In a sense, exams werent quite so bad. Yeah, you could fail and spend
several more months repreparing. But, a recital happened once a year, in
front of many people, people you knewyou flub up then, thats it!
In the weeks before a recital, I protected my fingersno knives, no door
jams, no volleyball. As a result, I would arrive at my recital with my hands
intact, but really it did no good. At that point, nerves would strike. My hands
would be so cold that I could barely move them and theyd sweat so pro-
fusely that Id lose my grip and slip all over the keys.
I suppose the final product sounded good, but it was always a hair-
raising experience. I finished the concert, people congratulated me, but I was
still in some kind of echo-chamber reality. So worn out from the rigors of
preparation and recital that everything sounded a little hollow and undone.
As I talk to engineers, it seems to me that embedded applications is
just about the same. There are all those years of engineering studies, then
the first few years of getting your feet wet in some lackey first-time job, and
then design, development, debugging, testing, and production. After a
product is on the market and ready to sell, many company owners have
that same exhausted, hollow look that I had following each recital. One part
of them cant believe they actually got it finished, while another is deathly
afraid that someone, somewhere will find that fatal timing error in the sev-
enth measure, or perhaps I should say, module.
And, in many ways, the final productthe concert, the inventionis
the crowning glory. It shows how well you learned all the bits and pieces
that go into the final product. You know, how well you learned your scales.
This months feature articles are real concert winners. Tom Consi and
Jim Bales, researchers at MIT, launch the issue with a look at acquiring
acceleration data from rockets. Robert Lacoste, the first-place winner for
the PIC17XXX family in Design98, then unveils his audio spectrum ana-
lyzer. And, Robert Priestley is back with a car performance monitorjust
what you need for your next high-speed, high-tech car rally.
In EPC, Jim Brady introduces us to DeviceNet, a new automation
network, while Ingo checks out what we need to know about TCP/IP to
design real-time applications, and Fred shows us how to solve RF prob-
lems, even if were not RF experts.
Stuart Ball wraps up his two-part MicroSeries on building a PROM
programmer, Jeff pokes about in the nether-world of phosphorus, while Tom
tells us about his latest and greatest finds at Sensors Expo.
All in all, its a high-quality recital from engineers determined to keep
delivering what theyre the best at. I, on the other hand, having completed my
last piano exam, changed from music to English, moved from that campus
and havent lived with a piano since. Now when I play, my ears know what
to expect, but my fingers can no longer deliver. My many years of training
are now put to work picking out fine compositions and recordings.

Steve Ciarcia
Janice Hughes
Elizabeth Laurenot
Michael Palumbo
Tom Cantrell
Ken Davidson
Fred Eady
Harv Weiner
Sue (Hodge) Skolnick
Rose Mansella
Jeannette Walters
KC Zienka
Jeff Bachiochi
Phil Champagne
John Gorsky
James Soussounis
Cover photograph Ron MeadowsMeadows Marketing
For information on authorized reprints of articles,
contact Jeannette Walters (860) 875-2199.
Circuit Cellar INK

makes no warranties and assumes no responsibility or liability of any kind for errors in these
programs or schematics or for the consequences of any such errors. Furthermore, because of possible variation in
the quality and condition of materials and workmanship of reader-assembled projects, Circuit Cellar INK

any responsiblity for the safe and proper function of reader-assembled projects based upon or from plans, descriptions,
or information published in Circuit Cellar INK

Entire contents copyright 1998 by Circuit Cellar Incorporated. All rights reserved. Circuit Cellar INK is a registered
trademark of Circuit Cellar Inc. Reproduction of this publication in whole or in part without written consent from Circuit
Cellar Inc. is prohibited.
TO SUBSCRIBE: (800) 269-6301 or via our editorial offices: (860) 875-2199
TELEPHONE: (860) 875-2199 FAX: (860) 871-0411
EDITORIAL OFFICES: Editor, Circuit Cellar INK, 4 Park St., Vernon, CT 06066
E-MAIL: Author addresses (when available) included at the end of each article.

, THE COMPUTER APPLICATIONS JOURNAL (ISSN 0896-8985) is 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, 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 INK Subscriptions,
P.O. Box 698, Holmes, PA 19043-9613 or call (800) 269-6301.
Postmaster: Send address changes to Circuit Cellar INK, Circulation Dept., P.O. Box 698, Holmes, PA 19043-9613.
Bobbi Yush Fax: (860) 871-0411
(860) 872-3064 E-mail:
Valerie Luster Fax: (860) 871-0411
(860) 875-2199 E-mail:
Ingo Cyliax Norman Jackson David Prutchi
Circuit Cellar INK

Issue 98 September 1998 3

34 Nouveau PC
edited by Harv Weiner
38 Networking with DeviceNet
Part 1: How Devi ceNet Stacks Up
Jim Brady
46 RPC Real-Time PC
TCP/IP Networki ng
I ngo Cyliax
55 APC Applied PCs
Radi o Frequency and Mi cros
Part 1: Transmi tter and Recei ver Modul es
Fred Eady
Smart Rockets
Data Acqui si ti on i n Model Rocketry
Tom Consi & Jim Bales
Audi o Spectrum Anal yzer
Robert Lacoste
Automotive Travel Computer
Addi ng a Performance/Tri p Moni tor to Your Car
Robert Priestley
I MicroSeries
Bui l d a Seri al Port PROM Programmer
Part 2: Two Adapter Modul es
Stuart Ball
I From the Bench
The Next Step i n EL Dri ver Technol ogy
Jeff Bachiochi
I Silicon Update
Sensory Overl oad
Tom Cantrell
www. ci rcui t cel l ar. com
# # # # # September Password: Arthur # ## ##
Task Manager
Janice Hughes
The Final Rendition
Reader I/O
New Product News
edited by Harv Weiner
Advertisers Index/
October Preview
Priority Interrupt
Steve Ciarcia
Which Numbers Count
6 Issue 98 September 1998 Circuit Cellar INK

I enjoy the arti cl es on RTOSs, but Im surpri sed that
Ingo hasnt menti oned Real Ti me Li nux. RT-Li nux
offers sub-100-ms real -ti me response, Posi x soft-real -
ti me tasks, a tremendous devel opment envi ronment
wi th free compi l ers, RTOS, and debuggers, and remote
l oggi ng, moni tori ng, and debuggi ng vi a a PPP l i nk.
James Linder
Keep an eye out for upcoming articles on Linux in
Embedded PC, especially in Real-Time PC, where I ngo
will be presenting a series of applications using RT-Linux.
Thanks for Dan Cross-Col es arti cl e about turni ng
your PC i nto a mul ti channel anal yzer ( Usi ng a PC for
Radi ati on Detecti on, I NK 96). The cal cul ati ons to
determi ne the percentage of radon i n a poured concrete
basement were enl i ghteni ng. Worki ng from counts to
U-235 to U-238 to radon to concentrati ons to fl ow
rates to a muffi n fan i s a l ot more i nteresti ng than
sendi ng a cani ster off to be measured by a l ab.
However, a coupl e of si gni fi cant cal i brati on i ssues
werent addressed because there wasnt enough hard-
ware appl i ed to the project.
Fi rst, any pul se ampl i tude spectra measured by the
anal yzer wi l l be bi ased toward hi gher energy pul ses. The
sampl e-and-hol d ci rcui t i s real l y a peak-hol d ci rcui t, so
whats measured i s the l argest pul se that has occurred
si nce the ci rcui t was reset. Thi s woul dnt be a probl em
i f al l the pul ses were from the 185-keV gamma emi ssi on
of U-235, but as Dan notes, hi gher energy pul ses come
from the decay chai n of U-238. For exampl e, Bi smuth 214
emi ts 609 keV, 1120 keV, and 1764 keV gammas. These
pul ses mask many of the gammas produced by U-235.
The second i ssuedead ti merel ates to the amount
of ti me the anal yzer i s unabl e to detect a pul se and the
average number of pul ses per second. For exampl e, i f
the C++ program FHJ@=J= takes 10 s to acqui re and
store a pul se i n i ts array and the radi oacti ve source i s
produci ng 6000 pul ses per second, the anal yzer i s dead
for 6000 0.0000010 = 0.06 s per second, so 6% of the
pul ses are l ost. As Dan demonstrates, thi s dead ti me
can be compensated for by cal i brati ng the anal yzer
wi th a radi oacti ve source of a known acti vi ty.
Thi s onl y works i f the mul ti channel anal yzer PC
does nothi ng el se. Anythi ng that i ncreases the amount
of ti me FHJ@=J= takes to handl e the data (e.g., i nter-
rupts) substanti al l y changes the dead-ti me and, conse-
quentl y, the measured pul se rate. In other words, dont
expect good resul ts i f you run thi s task on Wi ndows NT.
Mi ni mi ze the fi rst i ssue by usi ng a gated peak-hol d
where the gate i s turned off shortl y after a pul se i s de-
tected. The second i ssue can be handl ed by usi ng the
pul se detector to generate an i nterrupt and a ti mer to
track the amount of ti me between pul se detecti on and
ISR data col l ecti on.
Stephen Lloyd
Tom Cantrel l s hi nt of a l oomi ng 8-bi t OTP MCU war
i n The Mi cro Pri ce i s Ri ght (I NK 96) was on target.
Three weeks after Motorol a i ntroduced the 49 8-bi t MCU,
Mi crochi p Technol ogy fi red back wi th an 8-bi t MCU pri ced
at 40 for a ROM and 49 for an OTP i n l arge quanti ti es.
The PIC16C505 OTP mi crocontrol l er provi des desi gn
engi neers wi th a hi gher val ue sol uti on by offeri ng 1024
12 words of program memory, 2:1 code compacti on over
competi ti ve sol uti ons, 72 8 bytes of user RAM, 12 I/O
pi ns wi th 25-mA si nk and source capabi l i ty, wakeup on
I/O change, and 4-MHz i nternal cl ock osci l l ator.
Accordi ng to Dataquest, Mi crochi p now ranks num-
ber two i n worl dwi de 8-bi t MCU shi pmentsthanks
l argel y to I NK readers. In turn, these l eadi ng desi gners
can rest assured that Mi crochi p wi l l respond to future
i ndustry battl e cri es and del i ver the most appropri ate
8-bi t MCUs for thei r desi gn needs.
Eric Sells
I was struck at how wel l thought out Kens recent
edi tori al was ( A Mi nd i s a Terri bl e Thi ng..., I NK 95). It
gi ves good ti ps and di recti ons for hel pi ng students.
Thi s past year, I was very pl eased to have di rected my
focus on one agent useful towards l ymphoma. Thi s smal l
success remi nded me to set my goal s careful l y, and I am
happy to i ncorporate your method for reachi ng students.
Marc McGary
8 Issue 98 September 1998 Circuit Cellar INK


Edited by Harv Weiner
The FT8U24AM USB Game-Port Joystick Controller
IC i ncorporates a four-channel rati ometri c measuri ng
ci rcui t for determi ni ng the posi ti on of the anal og control s.
Tradi ti onal l ow-cost anal og joysti cks track posi ti on
wi th an RC ti me constant, usi ng l ow-tol erance compo-
nents (i .e., a potenti ometer and a capaci tor). Resul ti ng
threshol d val ues vary wi th temperature and vol tage,
produci ng i naccurate joysti cks that need frequent recal i -
brati on. Di gi tal joysti cks use opti cal sensors and el ec-
troni cs to el i mi nate these i naccuraci es, but they can be
more expensi ve.
The FT8U24AM measures the angl e of the potenti -
ometer rather than i ts resi stance to el i mi nate the tol er-
ance effect and provi de a typi cal accuracy of 1%. It
features an i ntegral EMCU mi crocontrol l er wi th pre-
programmed mask ROM, 128-byte data memory and 12
I/O pi ns. The four rati ometri c anal og channel s measure
x and y movements as wel l as throttl e and rudder func-
ti ons. The IC supports a wi de range of confi gurati ons
wi th up to four anal og control s, four sti ck and four base
buttons, as wel l as support for a POV hat swi tch. The
IC i s packaged i n a 24-pi n PDIP.
The FT8U24AM sel l s for l ess than $2 i n quanti ty.
Saelig Co.
(716) 425-3753
Fax: (716) 425-3835
Circuit Cellar INK

Issue 98 September 1998 9

The MicroGripper Oscilloscope Kits from Emul ati on
Technol ogy provi de easy probi ng of fi ne-pi tched devi ces.
They are uni quel y desi gned to provi de testi ng of PQFP
and SOIC packages from 0.8- to 0.3-mm l ead pi tch.
Combi ned wi th a dual -l ead adapter, the Mi croGri pper
enabl es hands-free testi ng. The devi ces work wi th al l
popul ar osci l l oscope probes.
The Mi croGri pper ti p i s i nsul ated to prevent shorti ng
out when attached si de-by-si de and features a wi re-ti p
di ameter of 0.08 mm. It i s constructed of steel or stai n-
l ess steel wi re, ni ckel pl ated wi th an ABS pl asti c fi ni sh.
It i s rated at 500 WVDC. The ki t i s i ntended for use wi th
vol tages up to 40 V. The probe capaci tance i s l ess than
2 pF between adjacent gri ppers and i ts i nductance i s
l ess than 1 mH (both measured at 1 kHz).
The 3-dB bandwi dth i s greater than 100 MHz.
Three separate ki ts are avai l abl e, depend-
i ng on the l ead pi tch. Each ki t contai ns
parts for use wi th two probes, i ncl udi ng
four Mi croGri ppers and two dual -l ead
Pri ci ng ranges from $145 to $199.
Emulation Technology, Inc.
(408) 982-0660
Fax: (408) 982-0664
10 Issue 98 September 1998 Circuit Cellar INK


The PC Caller ID pl ug decodes cal l er-ID data sent
over a tel ephone l i ne and del i vers the name, number,
date, and ti me to a computer. Enhanced servi ces, l i ke
voi ce-mai l noti fi cati on and cal l er ID wi th cal l wai ti ng,
are al so supported. The PC Cal l er ID Pl ug, whi ch mea-
sures onl y 2.25 3, pl ugs di rectl y i nto any spare PC
seri al port and requi res no external power.
Incl uded software (wi th source code) enabl es the user
to transform a PC i nto an advanced cal l er-ID box and to
i ntegrate cal l er ID i nto other appl i cati ons. The software
has DOS- and Wi ndows-based programs. Wi ndows soft-
ware source code i s suppl i ed i n Vi sual Basi c, and DOS
software source code i s suppl i ed i n C. The Wi ndows
software supports Wi ndows 3.11, 95, 98, and NT.
The uni t i s FCC Part 68 certi fi ed and can suppl y
cal l er-ID i nformati on to mi crocontrol l ers, SBCs, and
other embedded systems. Ful l documentati on, i ncl ud-
i ng the data format and a schemati c di agram for i nter-
faci ng to other hardware, i s i ncl uded.
The ITU PC Cal l er ID Pl ug i s avai l abl e for $34.95. A
30-day money-back guarantee and a 90-day warranty are
suppl i ed wi th each uni t.
ITU Technologies
(888) 448-8832 (513) 661-7523
Fax: (513) 661-7534
Circuit Cellar INK

Issue 98 September 1998 11

The QED Analog Conditioning Board enabl es
di rect moni tori ng and control of 16 anal og
i nputs and 8 anal og outputs from thermocoupl es,
RTDs, strai n gauges, pressure sensors, photo-
di odes, bri dge sensors, anal og actuators, and 4
20-mA transmi tters. Onboard ampl i fi cati on,
attenuati on, and fi l teri ng can be easi l y custom-
i zed wi th pl ug-i n components to provi de fl ex-
i bl e si gnal condi ti oni ng. Anal og outputs range
from 0 to 10 V.
Typi cal l y control l ed vi a a di rect cabl e i nter-
face to the C-programmabl e QED board con-
trol l er, the QED Anal og Condi ti oni ng Board
al so features bui l t-i n thermocoupl e col d-junc-
ti on compensati on to si mpl i fy temperature
measurement and control .
The QED Anal og Condi ti oni ng Board sel l s
for $249.
Mosaic Industries, Inc.
(510) 790-1255 Fax: (510) 790-0925
12 Issue 98 September 1998 Circuit Cellar INK

Tom Consi & Jim Bales
Model rockets have
always served as
ideal vehicles for
teaching physics and
engineering basics.
With this new data-
acquisition device,
Tom and Jim show
how to trace the
rockets acceleration
and store the entire
flight and its data.
odel rockets
have i nspi red gen-
erati ons of students
to pursue careers i n
engi neeri ng and sci ence. Indeed, many
of you probabl y went through a rocket
phase i n your formati ve years.
Model rockets are popul ar wi th
aspi ri ng engi neers for good reason.
Theyre exci ti ng, theyre fun to bui l d
and l aunch, and they offer a number of
si gni fi cant engi neeri ng chal l enges that
can be tackl ed wi th si mpl e tool s and
smal l budgets.
From an educati onal perspecti ve,
model rockets i ntroduce a number of
fundamental concepts i n physi cs such
as Newtons l aws, l i ft, and drag. Inex-
pensi ve mi crocontrol l ers and sol i d-state
sensors add an exci ti ng new di mensi on
to model rocketry.
Its now possi bl e to bui l d ti ny devi ces
that can measure and record the perfor-
mance of a model rocket i n fl i ght. Thi s
arti cl e descri bes just such a devi ce that
we desi gned, bui l t, and fl ew as part of
our Smart Rockets semi nar at MIT.
Our system measures just one fl i ght
characteri sti caccel erati onal though
i t coul d be easi l y modi fi ed to measure
other aspects of a rockets fl i ght. We
desi gned the system to fl y i n a smal l ,
si ngl e-staged, model rocket that coul d
be l aunched i n a rel ati vel y smal l area.
Data Acqui si ti on i n
Model Rocketry
Smart Rockets
Automotive Travel
Circuit Cellar INK

Issue 98 September 1998 13

cord, whi ch attaches to the 12 di ameter
Pri or to l aunch, an engi ne i s i nserted
i nto the rear of the rocket and hel d i n
pl ace wi th a spri ng cl i p. A pi ece of
recovery waddi ng (fi reproof ti ssue) i s
pl aced i n the rocket body just forward
of the engi ne to protect the pl asti c
parachute and shock cord from hot
gasses duri ng ejecti on.
Next, the parachute and shock cord
are coi l ed up and i nserted i nto the
rocket. The nose cone/payl oad secti on
i s i nserted i nto the forward end of the
body, and the model i s pl aced on the
l aunch pad, ready for fl i ght.
Our l aunch pl atforman Estes
Porta-Pad IIconsi sts of a pl asti c
tri pod, a steel bl ast defl ector, and a
meter-l ong l aunch rod. The rocket has
a smal l tube attached to i ts si de, the
l aunchi ng l ug, that hol ds the model to
the l aunch rod duri ng the i ni ti al phase
of powered fl i ght.
Model -rocket engi nes are fi red
el ectri cal l y usi ng an i gni ter that typi -
cal l y consi sts of a pi ece of ni chrome
wi re coated wi th a fl ammabl e materi al .
A current passed through the wi re
i gni tes thi s materi al , whi ch then i gni tes
the propel l ant.
The i gni ter connects to a l ong pai r
of wi res that l ead to the l aunch control
box at a safe di stance (~20) from the
rocket on the pad. The l aunch control
earth vi a a parachute. Duri ng thi s
recovery phase, the rocket i s at the
mercy of the wi nd whi ch can bl ow i t
onto rooftops, i nto trees or power
l i nes, or, i n our case, dump the model
i n the mi ddl e of the Charl es Ri ver! If
al l goes wel l , however, the rocket i s
recovered, the engi ne i s repl aced, and
the model can be fl own agai n.
Model -rocket engi nes are desi gnated
by a l etter and two numbers. The
l etter i ndi cates the total i mpul se of
the engi ne, whi ch i s just the i ntegral
of the thrust versus ti me curve of the
engi ne (the dashed l i ne i n Fi gure 1).
We used A-, B-, and C-si zed engi nes
wi th total i mpul ses of 2.5, 5, and 10 N,
respecti vel y. The fi rst number of the
engi ne desi gnati on i s the average
thrust i n newtons, and the second
number i s the peri od of the tracki ng
phase i n seconds.
Our rocketthe Estes Nova Pay-
l oaderi s a typi cal si ngl e-stage model
rocket. Its about 21 l ong, 1 i n di am-
eter, and wei ghs 1.8 oz. (50 g) wi thout
a payl oad or engi ne.
The rocket consi sts of a paper tube,
bal sa wood fi ns, and a 4 -l ong pl asti c
payl oad secti on topped by a nose cone.
The wood and paper parts are assembl ed
wi th wood gl ue, and the pl asti c parts
wi th model cement. The rocket body
and the nose cone/payl oad secti on are
connected by an el asti c rubber shock
The enti re system, i ncl udi ng bat-
tery, i s 4 l ong, sl i ghtl y under an
i nch wi de, and wei ghs about 1 oz.
(32 g). Photo 1 shows a pi cture of the
system mounted i n the rocket.
Insi de the payl oad compartment i s
a smal l ci rcui t board that contai ns an
accel erati on sensor, power suppl y,
mi crocontrol l er, and nonvol ati l e mem-
ory chi p. A pai r of l eads brought out
of the payl oad run down to the ti ps of
two fi ns and touch correspondi ng con-
tacts on the l aunch pad. The l aunch-
pad contacts attach to a cabl e that
l eads to the l aunch control box.
When the l aunch button on the
control box i s pressed, two thi ngs
happen. Fi rst, the l eads brought out to
the fi ns are shorted together, tri ggeri ng
the data-acqui si ti on system. Second
(and el ectri cal l y i sol ated from the
fi rst), a current passes through the
i gni ter, starti ng the rockets engi ne
and setti ng the vehi cl e i nto fl i ght.
Model rockets are l i ghtwei ght, l ow-
cost, sol i d-fuel rockets desi gned to
permi t safe experi mentati on wi th the
pri nci pl es of rocketry. Factory-made,
si ngl e-use, sol i d-fuel engi nes are a key
feature i n model -rocket safety.
A model -rocket engi ne consi sts of,
from bottom to top, a nozzl e, propel l ant,
del ay charge, ejecti on charge, and an
end cap. Thi s desi gn governs the over-
al l fl i ght characteri sti cs of the model .
The accel erati on phase (i .e., when
the propel l ant burns) l asts from a frac-
ti on of a second to up to 2 s for typi cal
rocket engi nes (see Fi gure 1). It i s
fol l owed by a l onger (several seconds)
tracki ng phase when the rocket coasts
up to maxi mum al ti tude. The model
i s not powered duri ng thi s phase, as
the del ay charge that generates smoke
for vi si bi l i ty has negl i gi bl e thrust.
At the end of the tracki ng phase,
the ejecti on charge i gni tes at the peak
al ti tude, when the vel oci ty of the rocket
i s near zero. The ejecti on charge bl ows
forward, bursti ng the end cap, and
pressuri zi ng the i nteri or of the model ,
whi ch pushes the nose cone/payl oad
secti on out of the rocket body.
Both pi eces, connected by an el asti c
shock cord, then dri ft safel y back to
1 0
1 5

1 0
1 5

0 0 . 5 1 1 . 5 2
Ti me (s)
Acceleration (g)
Thrust (N)
Figure 1This graph shows the predicted performance of the rocket. The thrust data was extracted from a perfor-
mance curve of the Estes C6-5 engine provided by the National Association of Rocketry. The acceleration curve for
the rocket is calculated. Note that at t = 0, the system experiences Earths gravity, which is equivalent to a rocket
accelerating upward at 1 g in free space.
14 Issue 98 September 1998 Circuit Cellar INK

box has a swi tch (the l aunch button)

that connects the i gni ter to the 6-V
battery (four al kal i ne AA cel l s). We
di scuss the detai l s of the l aunch con-
trol box l ater.
Newtons Fi rst Law, F = ma, con-
tai ns al l the physi cs you need to pre-
di ct the accel erati ons that the system
wi l l record. Al l we need i s the mass of
the rocket (m) and the appl i ed force
(F), ri ght?
The force exerted by a rocket engi ne
i s not constant as you see i n the thrust
versus ti me curve for an Estes C6-5
engi ne (the dashed l i ne i n Fi gure 1).
We assume the rocket moves strai ght
up whi l e the thrust i s appl i ed, so the
total force i s the engi ne thrust mi nus
the gravi tati onal force (mg, g = 9.8 m/s
If the mass of the rocket were fi xed,
then the accel erati on i s the dashed
l i ne scal ed by the mass. However, as
the propel l ant burns, the mass of the
rocket decreases.
How i mportant i s thi s effect? For
NASA, i ts cri ti cal 85% of the space
shuttl es take-off wei ght i s fuel !
In our case, onl y 12 g of the 105-g
take-off wei ght i s fuel (11%). So, we
can treat the rocket mass as a constant,
whi ch gi ves us the expected accel era-
ti on curve shown as the sol i d l i ne i n
Fi gure 1.
Our students made thi s cal cul ati on
on the fi rst day of cl ass. Thei r task for
the semester was to determi ne, by
di rect measurement, i f Fi gure 1 i s
We chose the Mi crochi p PIC16C73
mi crocontrol l er as our data-l oggi ng
engi ne (see Fi gure 2). Thi s chi p has al l
the I/O functi ons we need: DIO pi ns,
a fi ve-channel ei ght-bi t ADC, a USART,
and an SPI synchronous seri al port.
I ts 4 K words of data space (we used
the reprogrammabl e wi ndowed EPROM
versi on) and 192 bytes of RAM easi l y
accommodate our appl i cati on code as
wel l as provi de some head-room for
future expansi on.
Si ze was a key factor i n determi ni ng
what mi crocontrol l er to use. The PIC-
16C73 comes i n a 28-pi n ski nny-DIP
package that fi ts our space constrai nts.
The onl y thi ng the 16C73 l acks i s
nonvol ati l e data storage. Thi s i s pro-
vi ded by a Xi cor 25F128 seri al fl ash-
memory chi p that contai ns 16 KB of
memory i n an 8-pi n DIP package.
The Xi cor chi p communi cates wi th
the 16C73 vi a the PICs SPI seri al
i nterface. A 4-MHz crystal (Y1) was
chosen so each of the PIC i nstructi ons
executes i n 1 s, whi ch i s conveni ent
for cal cul ati ng code-executi on ti mes.
The reset button (SW1) i s a ti ny SPST
momentary On push button whi ch
grounds the MCLR pi n of the PIC.
We consi dered two methods of
tri ggeri ng data col l ecti on by the PIC.
One i s to have the PIC conti nual l y
read the ADC and use the fl ash memory
as a ri ng buffer. The PIC wai ts for the
accel erometer output to exceed a
threshol d and stops wri ti ng to the
buffer just before compl eti ng the next
l oop around the ri ng.
The drawbacks are the added soft-
ware compl exi ty (a concern for stu-
dents just l earni ng PIC programmi ng)
and the fi ni te number of wri te cycl es
al l owed by the fl ash chi p. Al so, for
the fi rst l aunch, we woul d have to set
the threshol d based on our predi cted
accel erati on curve, a gol den opportu-
ni ty for Murphy to i ntervene!
Instead, we chose to suppl y an
external el ectri cal si gnal when the
l aunch swi tch i s pressed. Thi s tech-
ni que removes al l the objecti ons l i sted
above and al so provi des us wi th data
on the l ag between pressi ng the l aunch
button and the l i ftoff.
However, i t presents a new chal l enge:
how to make a rel i abl e el ectri cal con-
necti on that can be broken wi th very
l i ttl e force. We need thi s type of con-
necti on i n two pl acesbetween the
l aunch pad and the rocket and between
the rocket body and the nose cone/
payl oad secti on (whi ch must separate
duri ng ejecti on). Our sol uti on i s i n
the System Constructi on secti on.
Two di gi tal i nput pi ns control the
system operati on. When grounded, the
tri gger i nput (RB0) starts the program
runni ng.
On tri ggeri ng, the program enters
one of two modes, determi ned by the
jumper on di gi tal i nput pi n RB1. Mode
A (RB1 l ow) causes the PIC to acqui re
accel erometer data. In mode B (RB1
hi gh), the PIC i mmedi atel y dumps i ts
stored data to a host computer though
i ts USART.
As Photo 1 shows, the tri gger l i nes
(RB0 and ground) are brought out of
Figure 2Heres the schematic
for the model-rocket data-
acquisition system. During the
rockets flight, the PIC16C73
microcontroller reads the
ADXL50 accelerometer and
stores the data in the X25F128
serial flash memory.
16 Issue 98 September 1998 Circuit Cellar INK

the payl oad secti on and down

the rocket body to the fi n ti ps
where they contact two pl ates
on the l aunch pad, whi ch are,
i n turn, connected to the l aunch
control box (see Fi gure 3). The
l aunch button (SW2) shorts
these contacts together, tri gger-
i ng the system to start acqui r-
i ng data (i f i t i s i n mode A).
Green and red status LEDs
connect to di gi tal outputs RB6
and RB7, respecti vel y. The
green LED i ndi cates that the
system i s on and wai ti ng for a
tri gger si gnal . The red LED
means the system i s ei ther
acqui ri ng data (mode A) or
dumpi ng data through i ts
USART (mode B).
Four other di gi tal outputs
(RB25) were used for debug-
gi ng purposes.
To get the data onto a PC,
we bui l t a smal l i nterface box
that has a push button to tri gger
RB0 whi l e i n mode B. Thi s
i nterface box contai ns a MAX-
233 TTL to RS-232 l evel shi ft-
i ng chi p that el i mi nates thi s
chi p from the payl oads ci rcui t
board. The box al so has i ts
own battery so the payl oads
battery i snt drai ned duri ng
retri eval of data (see Fi gure 3).
We chose Anal og Devi ces ADXL50
accel erometer, whi ch requi res a regu-
l ated +5-VDC suppl y and has an on-chi p
ampl i fi er. The gai n of thi s i nverti ng
fi nal stage can be set by external resi s-
tors, whi ch enabl es us to trade off
range for sensi ti vi ty.
We sel ected the ADXL50s external
resi stors to condi ti on the sensor out-
put to have a zero-g bi as l evel of about
2.5 V. Si nce the maxi mum accel era-
ti on i s expected to be 14 g, we sel ected
the gai n resi stors R4R6 to create an
i nverti ng ampl i fi er wi th a range of
20 g.
An i nternal vol tage reference makes
the output i nsensi ti ve to vari ati ons i n
the suppl y vol tage. The output of the
accel erometer connects di rectl y to the
PICs 8-bi t ADC (pi n RA0), gi vi ng a
resol uti on of approxi matel y 0.2 g.
One potenti al source of error i s
fl uctuati ons i n the regul ated power
suppl y, whi ch serves as the reference
vol tage (V
) for the PICs ADC. A
better desi gn woul d be to use a vol tage
reference chi p for V
, al though that
woul d, of course, consume preci ous
ci rcui t board space.
Another potenti al source of error i s
mi sal i gnment of the sensor wi th re-
spect to the rockets thrust axi s. Thi s
error i s smal l : one mi nus the cosi ne of
the mi sal i gnment. So, for a mi sal i gn-
ment of 5, the error i s l ess than 0.5%.
The code was wri tten i n PIC as-
sembl y l anguage. We used Mi crochi ps
MPASM assembl er and PICStart 16C
programmer as devel opment tool s. A
bl ock di agram of the software i s shown
i n Fi gure 4.
On powerup or after com-
i ng out of a reset, the soft-
ware i ni ti al i zes the I/O
faci l i ti es and i nternal re-
sources of the PIC (DIO,
ADC, SPI i nterface, USART,
and Ti mer 0). The USART
operates at 9600 bps, and
the SPI cl ock runs at 1 MHz.
The program then pol l s
RB0, whi ch i s normal l y
hi gh. A tri gger si gnal pul l s
RB0 l ow and causes the
program to check the mode
and execute the appropri ate
code. After the sel ected
mode executes, the program
l oops back to pol l i ng RB0
for another tri gger si gnal
(see Fi gure 4a).
Mode A i s the real -ti me
data-acqui si ti on porti on of
the program. It i s entered i f
pi n RB0 i s jumpered l ow.
The ADC i s read duri ng an
i nterrupt servi ce routi ne
that i s governed by Ti mer 0,
whi ch provi des an i nterrupt
every mi l l i second, thus
setti ng the data-acqui si ti on
rate (see Fi gure 4b).
How data i s acqui red i s
di ctated by the behavi or of
the Xi cor 25F128 seri al fl ash-
memory chi p. It recei ves
data i n 256-bi t packets vi a
i ts SPI i nterface and stores i t i n one
32-byte sector of i ts fl ash memory.
Transferri ng 256 bi ts takes onl y
about a quarter of a mi l l i second at an
SPI cl ock rate of 1 MHz. The program-
mi ng operati on, however, takes 10 ms.
Fortunatel y, thi s occurs automati cal l y
after the bi ts are recei ved and i t requi res
no further i nterventi on of the PIC.
The program i n mode A reads the
ADC 32 ti mes at a 1-kHz rate, stori ng
these val ues i n 32 bytes of buffer RAM
on the PIC chi p. Between the thi rty-
second and thi rty-thi rd A/D conver-
si ons, i t shoots the contents of the
buffer to the Xi cor chi p through the SPI.
It then proceeds to fi l l the buffer
RAM agai n. Duri ng the 32 ms that
the buffer i s bei ng refi l l ed, the Xi cor
chi p has pl enty of ti me to wri te the
data i t just recei ved i nto i ts fl ash
Photo 1aHeres our smart rocket on the launch pad. Note the clear payload
compartment containing the data-acquisition system and the copper contacts
beneath the fins. The brown streak down the right side of the rocket is one of the
two lines of conductive paint that bring the trigger signal to the payload. bIn
this view of the data-acquisition system, you see the modifications made to the
payload compartment. The brown patch on the rear bulkhead connector is
conductive paint that forms a sliding electrical connection with the rocket body.
To the left of the circuit board is a model-rocket engine.
Circuit Cellar INK

Issue 98 September 1998 17

In addi ti on to sendi ng accel erati on
data, the PIC sends the sector address
that i ndi cates where to store the data
i n the Xi cor chi p. The sector address
i s i ncremented after every SPI transfer.
Thi s cycl e repeats i tsel f 256 ti mes
unti l 8 KB of data are stored on the
Xi cor chi p. The program then ends
mode A and goes back to pol l i ng the
tri gger pi n.
The Xi cor chi p hol ds up to 16 KB of
data. But, we found that 8 KB of data,
correspondi ng to 8 s of ti me, was
enough to capture a rocket fl i ght from
l aunch to recovery phase.
Tri ggeri ng the system i n mode B
presumes that a host computer i s
connected to the USART of the PIC
vi a the i nterface box. The PIC reads a
si ngl e byte from the Xi cor chi p, con-
verts i t to a three-byte ASCII deci mal
number, and transmi ts i t to the host
computer (see Fi gure 4a).
Each transmi tted number i s ap-
pended wi th the ASCII codes for car-
ri age return ($0D) and l i ne feed ($0A).
Thi s cycl e repeats i tsel f unti l al l 8 KB
of data are transmi tted to the host.
Figure 3In the ground equipment, the interface box connects the payload to a host computer for data transfer.
Pressing the ignition switch on the launch control box (SW2) simultaneously ignites the rocket engine and triggers
the payload to record data.
18 Issue 98 September 1998 Circuit Cellar INK

Photo 2aThe accelerometer is in the TO-100 can at the forward end of the board. Its axis
of sensitivity is along the diameter of the can that crosses the tab. The connectors are for
the trigger signal (yellow), serial communication (central three-pin connector), and power
(green), which is shown connected to the lithium battery. bThe red and green status
LEDs, the large black inductor, the mode jumper, and the reset button are visible on the wire
side of the board.
The user must set the
host computer to accept
thi s ASCII stream before
the PIC i s tri ggered i nto
mode B. There i s no hand-
shaki ng between the PIC
and the host. As wi th mode
A, on termi nati on of mode
B, the program l oops back
to pol l i ng the tri gger i nput.
In the fi el d, we used a
l aptop, runni ng a termi nal
emul ator set i n screen-
capture mode, as the host
computer. The captured
fi l e i s a 1-col umn 8192-
row matri x of ASCII deci -
mal numbers.
As soon as the rocket was recovered
and the data upl oaded to a l aptop, we
pl otted the data to ensure that the
system worked properl y. Thus, we
coul d correct probl ems on si te, i nstead
of di scoveri ng them back i n the l ab.
Bei ng abl e to read the data i n the fi el d
usi ng a si mpl e edi tor more than offset
the extra ti me needed to transfer ASCII
as opposed to bi nary data.
The power system, consi sti ng of a
battery and a vol tage regul ator, was
one of the more di ffi cul t porti ons of
the desi gn because i t operates under
several constrai nts. Fi rst, the battery
must source 30 mA at 3 V.
Second, the regul ated 5-V rai l i s
cri ti cal because i t i s the reference for
the PICs ADC. Any change i n thi s
vol tage transl ates i nto a
proporti onal error i n the
recorded accel erati on.
Thi rd, the power sys-
tem must be compact
and l i ghtwei ght because
50 g i s the rockets maxi -
mum payl oad. Fi nal l y, i t
must be reasonabl y effi -
ci ent because smal l bat-
teri es have l i mi ted energy.
We started by l ooki ng
at hi gh-energy batteri es.
The two obvi ous choi ces
were al kal i ne cel l s and
l i thi um pri mary cel l s.
Li thi um cel l s have, on
average, three ti mes
more energy per uni t mass than al ka-
l i ne cel l s.
We settl ed on a CR2-styl e l i thi um
battery desi gned for hi gh-current ap-
pl i cati ons. It provi des 750 mAh at 3 V
and wei ghs 11 g.
We sel ected Maxi ms MAX631A
step-up swi tchi ng regul ator because of
i ts l ow part count (one i nductor and
two capaci tors) and smal l qui escent
Circuit Cellar INK

Issue 98 September 1998 19

current. The sel ecti on of the i nductor
i s cri ti cal because i ts resi stance must
be l ow (0.5 or l ess) and i t must not
saturate when the current through i t
peaks. The power suppl y i s shown i n
Fi gure 2.
The data-acqui si ti on system was
poi nt-to-poi nt wi red on a
16 3
pi ece of pad-per-hol e perf board. The
PIC chi p was mounted i n a socket so
i t coul d be removed for reprogrammi ng.
Al l other components were sol dered
di rectl y to the board.
As you see i n Photo 2 and Fi gure 2,
three connectors were mounted on
the boardtwo 2-pi n connectors to
connect to the battery (J3) and to l i nk
the tri gger l i nes to the rocket body
(J1), and one 3-pi n connector
for the USART connecti on (J2).
The bi g chal l enge i n l ayi ng
out thi s board was mi ni mi zi ng
the component hei ghts at the
edges to accommodate the
cyl i ndri cal shape of the pay-
l oad compartment. Thus the
PIC chi p, accel erometer, and
the l arge capaci tor and i nductor
of the power suppl y had to be
mounted central l y on the board.
We mounted components
on both si des of the board,
whi ch had the added bonus of
bal anci ng the wei ght of the
payl oad. Photo 2 shows both
si des of the payl oad ci rcui t
A sl ot was cut i n the rear
end of the pl asti c nose cone
that acts as a gui de to hol d the
ci rcui t board i n the payl oad
secti on (see Photo 1b). Some
materi al was removed from
the pl asti c bul khead that forms
the bottom of the payl oad
compartment to make a crude
battery hol der.
Pi eces of foam wedged
between the battery and the
wal l of the payl oad compart-
ment hel p hol d everythi ng i n
pl ace. The forward nose cone
and rear bul khead connector
are taped to the payl oad tube
to prevent the el ectroni cs from
fal l i ng out duri ng recovery.
We sol dered wi res onto the termi -
nal s of the battery and brought them
out to a connector on the ci rcui t board.
Beware! Thi s i s the most dangerous
part of bui l di ng the system.
There i s a l ot of energy i n the l i thi um
cel l , and excessi ve heat can cause i t to
catch fi re or expl ode! Use a cel l that
has i ntegral sol der tabs, and dont
l i nger on them wi th the sol deri ng i ron.
One of the more di ffi cul t aspects of
the desi gn was bri ngi ng the tri gger
l i nes (RB0 and ground) out of the pay-
l oad compartment, down the rocket
body, and out onto the fi n ti ps. For
thi s we used conducti ve pai nt, the ki nd
used to repai r wi ndshi el d defrosters.
An el ectri cal connecti on was estab-
l i shed between the payl oad compart-
ment and the rocket body by appl yi ng
two patches of pai nt on the outsi de
surface of the payl oad bul khead con-
nector where i t sl i ps i nto the rocket
body, and two correspondi ng patches
of pai nt i nsi de of the forward end of
the body (see Photo 1a).
Conducti ve l i nes were pai nted
from these forward patches around
the edge of the tube and down the
exteri or of the rocket to patches of
pai nt at the ti ps of two of the three fi ns.
These patches contact copper pl ates
on the l aunch pad that connect to the
l aunch control box (see Photo 1).
The pai nt patches on the bul khead
connector and the rocket body provi de
el ectri cal conti nui ty between the
payl oad and the rocket whi l e the model
i s on the l aunch pad. Thi s connecti on
i s easi l y broken by the ejecti on charge.
Yes No
Digital I/O
Timer 0
Poll For
Set-Up Mode B:
Transfer Data to
Host Computer
Get a Byte of Data
From Serial Flash
via SPI
Convert to ASCII
Transmit Converted
Data to Host
Computer via USART
Decrement Data Byte
8 KB of Data
to Host?
Set-Up Mode A:
Acquire Data
Enable Timer 0
Point to Start of
RAM Buffer
Poll End of
RAM Buffer
Send RAM Buffer
(32 Bytes) to
Serial Flash via SPI
Increment Serial Flash
Sector Address
8 KB of Data
Yes No
Timer 0
Buffer Full
Not Full
RB1 = 0
RB0 = 1
RB1 = 1
RB0 = 0
Enter on Timer 0
Reload Timer 0 with
Perform One A/D
Store Data Byte
in RAM Buffer
Increment RAM
Buffer Address
End of RAM
Clear Timer 0
Interrupt Flag
Set End of
Buffer Flag
Figure 4aData is acquired by an interrupt-driven routine that runs during the time indicated by the shaded diamond. Note
that the code between the points labeled A and B must execute in less than 1 ms to maintain the 1-kHz data-acquisition rate.
bIn this flowchart of the interrupt-driven data acquisition routine, timer 0 sets the sampling period. Each time the routine is
called, one A/D conversion is performed and the data byte is stored in the RAM buffer.
20 Issue 98 September 1998 Circuit Cellar INK

Connector J1 bri ngs the tri gger

l i nes to the pai nt patches on the bul k-
head connector. It i snt possi bl e to
sol der wi res to the conducti ve pai nt, so
we essenti al l y pasted the stri pped end
of each wi re to i ts patch wi th a thi ck
coati ng of the conducti ve pai nt.
Cl earl y, conducti ve pai nt i s not
goi ng to hol d the wi re. To provi de
strai n rel i ef, we gl ued the i nsul ated
porti on of the wi res to the bul khead
connector usi ng model cement. Sti l l ,
these connecti ons proved qui te del i -
cate and someti mes broke i n the fi el d.
The l aunch control box shown i n
Fi gure 3 has many of the features of
the standard Estes El ectron Beam
l aunch control l er. Between the batter-
i es and the ni chrome i gni ter are the
safety key and the armed i ndi cator
(LED D1). The l aunch swi tch i s i n
paral l el wi th the LED.
The i gni ter i s connected wi th the
safety key removed, so the cl i ps to the
i gni ter are not hot. Inserti ng the safety
key appl i es the battery vol tage across
the seri es combi nati on of the armed
i ndi cator and the i gni ter, whi ch enabl es
enough current to fl ow to l i ght the
i ndi cator but not enough to i gni te the
i gni ters bl ack powder coati ng. A ni ce
feature of thi s desi gn i s that any break
i n the wi ri ng prevents the armed i ndi -
cator from l i ghti ng.
Our major modi fi cati on to the
Estes desi gn was to repl ace thei r SPST
l aunch swi tch wi th a DPDT momen-
tary push-button swi tch (SW2). The
second channel of thi s swi tch shorts
together the two contacts brought out
to the fi ns of the rocket. A 20 four-
conductor cabl e bri ngs the i gni ter
current and the payl oad-tri gger si gnal
to the l aunch pad.
Three smal l bl ocks of wood epoxi ed
to the bl ast defl ector of the l aunch
pad (see Photo 1a) support the rocket,
whi l e el ectri cal l y i sol ati ng the fi ns
from the steel bl ast defl ector.
Copper pl ates are attached to each
bl ock of wood, and two of the pl ates
are connected by l eads to the tri gger
si gnal l i nes of the l aunch cabl e. The
two rocket fi ns wi th conducti ve-pai nt
contacts are posi ti oned over these
bl ocks, and the thi rd fi n rests on the
unconnected bl ock to bal ance the
model on the pad.
Before l eavi ng the l ab, we went
through every step i n the sequence of
the setup, l aunch (wi th no engi ne),
data recovery, and data vi sual i zati on.
We even shook the rocket up and
down a few ti mes after pressi ng the
l aunch key, just to generate accel era-
ti on data. Once the procedure was
perfected, we moved outsi de.
The raw data from a l aunch wi th
an Estes C6-5 engi ne i s shown i n
Figure 5Heres the raw data from an actual rocket mission using a C6-5 engine. Because this is the output of an
inverting amplifier, upward acceleration causes decreased output voltage. This curve was plotted in the field, and it
shows that the system functioned correctly. The spike around 4500 ms is spurious, while the structure just before
6000 ms indicates the ejection charge firing.
5 0


0 2000 4000 6000 8000
Ti me (ms)
Circuit Cellar INK

Issue 98 September 1998 21

Figure 6Heres the processed acceleration data for the launch shown in Figure 5. The shape compares favorably
to the predicted acceleration curve in Figure 1.
- 5
1 0
1 5
2 0

0 . 0 0 . 5 1 . 0 1 . 5 2 . 0 2 . 5
Ti me (s)
Fi gure5. The accel erati on appears to
be negati ve, but thats because the on-
chi p buffer of the ADXL50 i s an i n-
verti ng ampl i fi er.
The i ni ti al ki ck and the sustai ned
thrust are easi l y seen, as i s the ejecti on
charge (around 6000 ms). There i s al so
a spuri ous data poi nt (around 4500 ms).
Whi l e the accel erometer output has
not been converted i nto accel erati on
yet, thi s pl ot sti l l tel l s us that the
system worked.
Turni ng Fi gure 5 i nto the desi red
accel erati on pl ot requi res a few steps:
removi ng the spuri ous data poi nts
smoothi ng the curve wi th a three-
poi nt sl i di ng-wi ndow average
converti ng the 0255 A/D readi ngs
to 05 V
converti ng the vol tage to accel era-
ti on, expl oi ti ng the fact that the
system saw 1 g just before i gni ti on
The fi rst three steps are strai ghtfor-
ward. For the fi nal step, we used the
publ i shed response curve of the sensor
as wel l as the cal cul ated transfer func-
ti on for the ampl i fi er, gi ven the val ues
of resi stors R4R6.
We know that, just before i gni ti on,
the rocket was experi enci ng the 1-g
gravi tati onal force, so we defi ned the
observed DC offset to be 1 g. Fi gure 6,
shows the fi nal accel erati on curve for
our system.
Compare Fi gure 6 to the sol i d l i ne
i n Fi gure 1. The general shape of the
curves agree, al though the measured
curve i s compressed i n ti me. The
maxi mum measured accel erati on was
17 g, whi l e the maxi mum accel erati on
predi cted from the mass of the rocket
and the characteri sti cs of the C6-5
engi ne was 14 g.
The correspondence between theory
and experi ment i snt bad, and i t shows
our system works as desi gned. There
are several ways to i mprove the qual -
i ty of the data.
Fi rst i s to perform a careful cal i bra-
ti on of the accel erometer. Cal i brati on
procedures for the ADXL50 are di s-
cussed i n the datasheet. We cal cul ated
gai ns usi ng the nomi nal val ues of our
5% resi stors. Usi ng 1% resi stors i n
the accel erometer ci rcui t woul d gi ve
better resul ts.
Al so, a more stabl e vol tage source
can be used as the reference for the
PICs ADC. Other questi ons can be
addressed as wel l : What causes the
spuri ous data? What i s the source of
the ri ppl e seen even when the rocket
i s on the pad?
There are many ways to i mprove
and expand thi s system. It coul d be
mi ni aturi zed further by usi ng a PCB
wi th surface-mount components.
Earl i er, we menti oned our deci si on
to use a wi re l i nk to the rocket to
22 Issue 98 September 1998 Circuit Cellar INK

Tom Consi is a research engineer and

lecturer in the MI T Ocean Engineering
department, where he develops bio-
logically inspired marine robots. He
received his Ph.D. in biology from
Columbia University in 1987. You
may reach him at
Jim Bales is a research engineer with
the MI T Sea Grant College Program.
He received his Ph.D. in solid-state
physics from MI T in 1991. His re-
search interests include sensors for
underwater robotics and power sys-
tems for autonomous platforms. You
may reach him at
This effort was supported by the MI T
Sea Grant College Program and the
MI T Department of Ocean Engineer-
ing. At MI T we were helped by the
Undergraduate Seminar Office, The
Safety Office, the Campus Police, and
the Athletics Department. Analog
Devices, Maxim, Microchip, and
Xicor all donated I Cs for the course.
Microchip (through S-J New England
I nc.) also provided PI C programmers
and databooks. Finally, thanks to our
tri gger the data acqui si ti on as opposed
to usi ng a threshol d accel erati on to
tri gger the system. Two of our students
managed to i mpl ement thi s i dea and
got i t to work qui te ni cel y. Other
tri ggeri ng schemes coul d use opti cal
or radi o si gnal s as wi rel ess tri ggers.
Al so, more sensors coul d be added.
An ol d model -rocket tri ck for measur-
i ng rol l rate i s to i nstal l a photosensor
i n the si de of the model . As l ong as
the model doesnt fl y di rectl y i nto the
sun, there wi l l be asymmetri c i l l umi -
nati on around the vehi cl e, causi ng a
peri odi c si gnal from the photosensor
as the rocket rol l s. The PIC coul d easi l y
measure the frequency of thi s si gnal .
A number of other sensors coul d be
addedthermi stors, pressure sensors,
and even ti ny gyroscopes. Another
cl ass of sensors consi sts of devi ces
that i ndi cate when cri ti cal events
occur duri ng the fl i ght of the model .
For exampl e, a fi ne wi re coul d be
pl aced across the nozzl e of the rocket
engi ne. When the engi ne i gni tes, the
wi re burns through and si gnal s the PIC,
whi ch l ogs the exact ti me of i gni ti on.
You can i magi ne si mi l ar sensors that
i ndi cate when the rocket l eaves the
pad, when i t cl ears the l aunch rod,
and when the ejecti on charge occurs.
Addi ti onal sensor data coul d easi l y
exceed our systems capaci ty. Greater
memory can be obtai ned vi a hi gh-
capaci ty seri al fl ash-memory modul es
(di scussed by Tom Cantrel l i n Seri al
Fl ash Busts Bi t Barri er, I NK 85).
Weve onl y scratched the surface of
the many possi bi l i ti es for smart model
rockets. We hope to expl ore some of
these avenues i n another course. Thi s
ti me we were more than sati sfi ed that
al l of the students got to fl y thei r
rockets and col l ect real data. I
Anal og Devi ces, Inc.
(617) 329-4700
Fax: (617) 326-8703
Model rockets and rocket equipment
Estes Industri es
1295 H St.
Penrose, CO 81240
Maxi m Integrated Products
(408) 737-7600
www.maxi m-i
Mi crochi p Technol ogy, Inc.
(602) 786-7200
Fax: (602) 786-7277
www.mi crochi
Rocket-engine performance curves
Nati onal Assn. of Rocketry
P.O. Box 177
Al toona, WI 54720
Xi cor, Inc.
(408) 432-8888
Fax: (408) 432-0640
students, whose interest and dedica-
tion were inspirational and who were
just a lot of fun to be around!
Compl ete source code for thi s ar-
ti cl e i s avai l abl e vi a the Ci rcui t
Cel l ar Web si te.
24 Issue 98 September 1998 Circuit Cellar INK

Robert Lacoste
Sure, a DSP can
make the calculations
and generate the
pixel bitmap for an
audio spectrum
analyzer, but at what
cost? Robert gets
the same result from
a single PIC processor
with a design so good
he walked away with
a Design98 first prize.
remember bei ng
qui te astoni shed
when one of my pro-
fessors expl ai ned the
basi cs of frequency domai n anal ysi s,
Every peri odi c si gnal i s the sum of
pure si nusoi dal si gnal s, wi th gi ven
frequenci es, ampl i tudes, and phases.
Hmmevery si gnal . That i ncl udes
the l i ght comi ng from the sun, the
vi brati ons of my ol d car, even the tears
of my two-month-ol d baby!
And, I bet that 99% of I NK readers
are l i ke me. You want to understand,
and you understand i t better i f you
make i t yoursel f.
So, years ago, I qui ckl y wi re-wrapped
an anal og acqui si ti on board and wrote
a smal l BASIC program on my ol d
Appl e II to di spl ay the frequency decom-
posi ti on of an i ncomi ng audi o si gnal .
It was my fi rst audi o spectrum anal yzer.
Later, I di d the same on my PCs, and
the x86s were soon powerful enough
to get real -ti me performance.
Usi ng a PC i s OK, but how about
an autonomous devi ce? Somethi ng
smal l enough to bri ng al ong anywhere
but that has a VGA vi deo output wi th
a decent qual i ty i mage and real -ti me
My fi rst i dea was somethi ng l i ke
the bl ock di agram i n Fi gure 1a. An
ampl i fi er and l ow-pass fi l ter suppress
Audi o Spectrum Anal yzer
out-of-the-band si gnal s before the si gnal
goes to an ADC, whi ch transforms i t
i nto numeri cal sampl es.
A DSP can cal cul ate the frequency
decomposi ti on of thi s si gnal wi th the
cl assi c Fast Fouri er Transform (FFT)
al gori thm and generate the pi xel bi t-
map i n vi deo RAM, whi ch i s di spl ayed
by a CRT control l er chi p.
Youd need a fai r amount of com-
puti ng power, but i s i t possi bl e to do
the same wi th a si mpl er desi gn? How
about a hi gh-end mi crocontrol l er?
I NKs Desi gn98 contest presented a
great opportuni ty to try i t wi th one of
the newer Mi crochi p devi cesthe
Thi s chi p has enough horsepower
not onl y to do an FFT i n real ti me but
al so to el i mi nate the CRT control l er.
The vi deo output can be made wi th
some general -purpose paral l el output
l i nes, and the software toggl es the
correspondi ng bi ts to generate the vi deo
synchroni zati on and col or si gnal s i n
real ti me.
Wi th thi s control l er, the bl ock
di agram of my l ogi c anal yzer (shown
i n Fi gure 1b) i s, wel l , as si mpl e as
possi bl e. PICSpectrum i s born!
Before getti ng i nto more detai l s
about PICSpectrum (see Photo 1),
l ets have a l ook at the PIC17C756
and i ts stri pped-down versi on, the
PIC17C752. These new ful l y stati c
CMOS chi ps are an enhancement of
the exi sti ng PIC17C4X fami l y.
The mi crocontrol l er core runs up
to 33 MHz, gi vi ng a 121-ns i nstructi on
cycl e. These chi ps are pure RISC desi gn,
and thanks to the two-stage pi pel i ne,
each i nstructi on executes i n onl y one
cycl e, except program branches and
tabl e reads/wri tes, whi ch are two cycl es
l ong. That makes i t near 8 MIPSnot
bad for a mi crocontrol l er.
The 58 si ngl e-word i nstructi ons
(coded on 16 bi ts) are easy to l earn for
any user of Mi crochi ps smal l er con-
trol l ers. Di rect, i ndi rect, and rel ati ve
addressi ng modes are supported. Ex-
ternal i nterrupts are present, as i s a
16-l evel hardware stack.
One i nteresti ng feature for com-
pute-i ntensi ve appl i cati ons: there i s
an i ntegrated 8 8 bi t hardware mul -
Circuit Cellar INK

Issue 98 September 1998 25

bootstrap code i s l aunched and wai ts
for orders comi ng from a dedi cated
seri al synchronous i nterface (RA1/
RA4/RA5 pi ns).
Wi th a smal l i nterface connected to
the LPT port of your favori te computer,
you can read or wri te the i nternal
EPROM wi thout any speci fi c program-
mer and wi thout havi ng to extract the
chi p from i ts socket.
I devel oped my own PC-based i n-
ci rcui t programmer based on Mi cro-
chi ps programmi ng speci fi cati ons [2].
El ectri cal l y, the standard-grade
PIC17C756 needs a suppl y vol tage
from 4.5 to 6.0 V, whi l e a speci al ex-
tended devi ce (PIC17LC756) accepts
anythi ng from 3.0 to 6.0 V. In both
cases, the mi ni mum RAM retenti on
vol tage i s 1.5 V.
The suppl y current i s 6 mA at 4 MHz
but cl i mbs to 50 mA at 33 MHz. Of
course, sl eep modes reduce consump-
ti on down to 1 A, dependi ng on the
sel ected peri pheral s, but hi gh perfor-
mances and l ow consumpti on are sti l l
di ffi cul t to conci l i ate.
Now that we have a good mi crocon-
trol l er, l ets l ook at the PICSpectrum
hardware shown i n Fi gure 4.
A smal l power suppl y, whi ch i s
bui l t around U1 (78M05), generates a
cl ean 5 V from a standard 9-VDC power
suppl y (the total power consumpti on
i s around 100 mA, whi ch i s mai nl y
50 mA for the PIC and 50 mA for
dri vi ng the three 75- vi deo outputs).
The LED D1 i ndi cates powerup and
generates a pseudoground 1.9-V l evel
used by the anal og secti on.
The anal og i nput si gnal (from an
onboard el ectret measurement mi cro-
phone or a l i ne i nput jack) i s ampl i fi ed
and l ow-pass fi l tered down to 10 kHz
provi des 50 I/O pi ns wi th
i ndi vi dual di recti on con-
trol . As usual , each pi n
may be used for general -
purpose I/O or dedi cated to some on-
chi p peri pheral s.
Have a l ook of the pi nout of the
PLCC versi on i n Fi gure 3 and youl l
understand that thi s chi p i s qui te
fl exi bl e. Both OTP and wi ndowed
versi ons exi st, even i f they arent so
easy to fi nd.
On the peri pheral feature l i st, there
are four ti mers (two 16 bi ts wi de and
two 8 bi ts wi de, TMR0 havi ng an i nter-
nal 8-bi t programmabl e prescal er),
four capture i nput pi ns, and three PWM
outputs wi th a 10-bi t resol uti on.
Need more? Perhaps two asynchro-
nous and one synchronous seri al port,
the l atter confi gurabl e both i n SPI and
C modes, master or sl ave? Or a 12-
channel 10-bi t ADC? Or an RC-cl ocked
watchdog ti mer?
How about an i ntegrated suppl y-
vol tage supervi si on? Or a confi gurabl e
RC/crystal /cerami c cl ock system wi th
an osci l l ator start-up ti mer? Name i t,
and i ts probabl y there.
The PIC17C756X al so has i n-ci r-
cui t programmi ng hardware. By pul l -
i ng the TEST and MCLR/V
pi ns to a
13-V programmi ng vol tage before
poweri ng up the chi p, a speci fi c ROM
ti pl i er, worki ng i n onl y one i nstructi on
cycl e. Thi s mul ti pl i er offers a perfor-
mance boost of more than three ti mes
(compared to a software-onl y versi on)
for a compl ete FFT cal cul ati on.
The i nternal memory i s i mpressi ve
as wel l . The PIC17C756 has 16 K words
of EPROM program memory as wel l
as 902 bytes of general -purpose RAM,
whi ch accommodates qui te l arge
projects wi thout the need of external
memori es, even i f extended modes are
avai l abl e and support up to 64 K words
of program memory.
The smal l er PIC17C752 has onl y
8 K words of EPROM and 454 bytes of
RAM. Mi crochi p has al so announced
fl ash-memory versi ons (PIC17F75X).
The memory map i s shown i n Fi gure 2.
One pi ece of bad news: the RAM
and regi sters are sti l l banked, and the
worki ng page i s sel ected by some bi ts
i n the BSR regi ster. Even i f some spe-
ci fi c assembl er i nstructi ons hel p, thi s
i s a major headache for the programmer
and a major source of bugs. I hope that
Mi crochi p swi tches to a l i near address
mode i n the near future.
Hosted i n 64- (DIP) or 68-pi n pack-
ages (PLCC and TQFP), the PIC17C75X
Figure 1aHeres a classic block diagram for a spectrum analyzer. The signal is amplified and low-pass filtered before going to an ADC. A DSP calculates the FFT and drives
the VGA screen through a video controller. bThe PICSpectrum block diagram is much simpler. The microphone signal is amplified and low-pass filtered and goes directly to
the PIC, which calculates the FFT and directly generates the video. Its all in the software.
Mode control switches Signal level control

Mode control switches
Signal level control
b) a)
Photo 1The PICSpectrum proto-
type is built on a 1 3 PCB. A good
ground plate is mandatory on a mixed
digital/analog design like this one. I
used a transparent box to prove that
there are very few components inside.
26 Issue 98 September 1998 Circuit Cellar INK

chroni zati on si gnal s are TTL compat-

i bl e, so theres no probl em there. For
the R, G, and B l i nes (02 V/75 ), a
150- seri es resi stor does an adequate
5-V to 2-V/75- adaptati on, thanks to
the hi gh power capaci ty of the PIC
outputs (20 mA/l i ne, 100 mA total for
ports A and B).
The 8-pi n header J4 handl es i n-ci rcui t
seri al programmi ng. Four addi ti onal
output pi ns (i ncl udi ng one UART out-
put) are connected to a debug header.
Thi s provi si on i s useful duri ng the
debug phase because i t enabl es you to
send debug i nformati on to a seri al
termi nal to fi nd out whats happeni ng
i nsi de the box when you dont have an
i n-ci rcui t emul ator.
Of course, when you choose the
si mpl est possi bl e hardware, the soft-
ware has more to do. Here, the software
do the acqui si ti on of a burst of the
anal og si gnal (typi cal l y 256 sampl es
at a sampl i ng frequency of 16 kHz)
these frequenci es, thi s crys-
tal i s a 3 overtone model .
I needed a damper ci rcui t
(L1/C8) to sel ect the correct
resonant frequency. Wi thout
i t, the crystal woul d osci l l ate
on i ts fundamental frequency, and Id
end up wi th a 10.66-MHz cl ock!
Two swi tches (K1 and K2) control
the current mode (run or hol d) and the
scal i ng of the di spl ay (l i near or l ogari th-
mi c). They connect di rectl y to RB6
and RB7 because the PIC has sel ect-
abl e i nternal pul l ups.
The VGA-compati bl e vi deo-output
connector i s di rectl y dri ven by the
PIC. The hori zontal and verti cal syn-
by four operati onal ampl i fi ers (U2,
LM324). A potenti ometer l ets you
adapt the ampl i fi er gai n to the ambi ent
sound l evel and serves as an on-off
swi tch. The output si gnal , centered on
the 1.9-V pseudoground l evel , connects
di rectl y to one of the PICs anal og
i nputs.
The PIC processor i s cl ocked by a
32-MHz crystal (I wasnt abl e to fi nd a
33-MHz crystal i n ti me). As usual for
Program Memory Data Memory
Reset Vector
Interrupt Vectors
User Program
(16 KB)
Boot ROM
Unbanked System Registers
Banked System Registers
Unbanked System Registers
Unbanked User RAM
User RAM
Figure 2From this memory map of the
PIC17C756, you see that the program
and data areas are separated, as usual
on a Harvard architecture. The 17C752
has the same memory map, except that
there is only 8 KB of user program
memory and two user RAM banks.
Circuit Cellar INK

Issue 98 September 1998 27

Figure 4Around the PIC, there is only a quad operational amplifier, a regulator, and some discrete components.
28 Issue 98 September 1998 Circuit Cellar INK

Figure 6The top

part shows the timings
of the video and
horizontal synchroniza-
tion signals, while the
bottom part shows the
conversion of these
timings in number of
instructions as well as
what the PIC is doing
during this time.
cal cul ate the FFT of
these 256 sampl es, gi vi ng
an ampl i tude for each of
the 128 frequenci es
cal cul ate the power of
each frequency and scal e
i t (dependi ng on the
posi ti on of the l og/l i n
swi tch)
manage the run/hol d
swi tch
do the generati on of the
VGA vi deo si gnal i n
paral l el
To do al l these tasks
whi l e keepi ng real -ti me
requi rements, PICSpec-
trum software i s di vi ded
i nto two tasks. The mai n
program i s i n charge of
i ni ti al i zati on, devi ce con-
trol , and numeri cal al go-
ri thms. The i nterrupt
routi ne, executed each
31.77 s (correspondi ng to the VGA
hori zontal vi deo synchroni zati on
peri od), i s i n charge of anal og si gnal
acqui si ti on and vi deo generati on.
These two tasks di al og through
three RAM shared structures:
FFT buffer (256 words, 16 bi ts each),
fi l l ed by the i nterrupt routi ne wi th
anal og sampl es and used by the mai n
program for FFT cal cul ati on
di spl ay buffer (128 bytes), fi l l ed by
the mai n program wi th the l ength
(i n pi xel s) of each of the 128 hori zon-
tal frequency bars, and used by the
i nterrupt routi ne for vi deo generati on
synchroni zati on vari abl es
Fi gure 5 i l l ustrates the i nformati on
fl ow. Si nce you can get the compl ete
source code from the Ci rcui t Cel l ar
Web si te, Il l focus here under on the
more speci fi c codes, l i ke FFT cal cul a-
ti on and software vi deo generati on.
A standard FFT al gori thm works
on compl ex numbers (real pl us i magi -
nary parts). It takes as an i nput an
array of n compl ex sampl es and gi ves
an array of n compl ex frequency am-
pl i tudes. Here, the i nput si gnal i s of
course onl y real numbers.
The i mmedi ate sol uti on to get i ts
FFT i s to add a zero i magi nary part to
each sampl e and to use the standard
compl ex numbers al gori thm. If you do
that, onl y hal f of the n frequenci es i n
the resul t are useful (i n fact, each
val ue i s found twi ce).
Thi s i s a consequence of the wel l -
known Nyqui st rul e. If you sampl e
your si gnal at a peri od of 1/n, you can
onl y anal yze frequenci es wi th peri ods
above 2/n. More probl em-
ati c, thi s si mpl e approach
uses twi ce as much memory
as i s useful and we have
onl y 902 bytes of RAM.
Fortunatel y, you can use
a more sophi sti cated al go-
ri thm, known as real -mode
FFT. The i dea i s to pack two
real sampl es i n each compl ex
i nput val ue, do a standard
compl ex FFT, and decrypt
the resul ti ng compl ex val ues
to fi nd back the good real
fi gures. You can get the
detai l s from Numerical
Recipes in C: The Art of
Scientific Computing [3].
To i mpl ement thi s FFT
al gori thm on the PIC, I de-
vel oped a fi xed-poi nt math-
emati cal l i brary (source fi l e
i s BENA@E?). It i mpl ements
a vi rtual fi xed-poi nt machi ne
operati ng on two 16-bi t
fl oati ng-poi nt regi sters (RA and RB).
Routi nes are avai l abl e for addi ti on,
subtracti on, mul ti pl i cati on, di vi si on,
si ne, and l ogari thm, as wel l as access
to the banked RAM. The fi xed-poi nt
format used i s S/2/13 (one si gn bi t, 2
bi ts for the i nteger part, and 13 bi ts
for the fracti onal part). In fact, wri ti ng
si nus and l ogari thm cal cul ati on rou-
ti nes i n assembl er i s qui te an i nterest-
i ng experi ence.
Wri ti ng the i nterrupt routi ne was
another i nteresti ng exerci se. One
i nterrupt i s generated by ti mer 0 each
31.77 s. Thi s peri od equal s the hori -
zontal refresh peri od of a VGA si gnal
i n mode 7 (640 350).
Because 31.77 s transl ates i nto
254 i nstructi ons onl y (even at 32 MHz),
the number of i nstructi ons used to do
the anal og si gnal acqui si ti on and the
vi deo generati on must be careful l y
opti mi zed.
Fi gure 6 shows the VGA hori zontal
ti mi ng speci fi cati ons, the correspond-
i ng number of i nstructi ons that the
PIC17C756 coul d execute at 32 MHz,
and the operati ons done by the i nterrupt
routi ne i n the correspondi ng ti me frame
(more i nformati on on VGA ti mi ngs i s
avai l abl e on the Web [4]).
Shared RAM
FFT buffer
Display buffer
spectrum and
(lin or log)
Wait for end
of acquisition
Calculate FFT
Timer 0
(31.77 s)
Get one
Signal it to
main prog
video line
video line
Interrupt routine Main Program
Video signal
Number of
acqu: 37
Video signal
generations: 5 to 169
Registers restoring: 10
Video line increments & selection: 11
Housekeeping: 15
Interrupt Interrupt

s3.7 s

s25.1 s
Figure 5The main task is in charge of the numerical
algorithms, while a timer-driven interrupt routine
handles analog signal acquisition and video generation.
The tasks communicate through a shared memory.
30 Issue 98 September 1998 Circuit Cellar INK

The i nterrupt routi ne starts wi th

housekeepi ng (regi ster savi ng, ti mer
rel oad, etc.) and swi tches on the hori -
zontal synchroni zati on si gnal . Duri ng
the 3.7 s needed by thi s synchroni za-
ti on, the software manages the acqui -
si ti on of an anal og sampl e (one si gnal
sampl e i s taken every two i nterrupts,
gi vi ng a 15.7-kHz di gi ti zati on rate).
The current vi deo l i ne number i s
then i ncremented and used as an i ndex
i nto a tabl e, gi vi ng the address of the
routi ne to use for di spl ayi ng each scan
l i ne (verti cal synchroni zati on vi rtual
l i nes, bl ank l i nes, frequency di spl ay
l i ne, scal e or ti tl e di spl ay, etc.). Each
routi ne manages the swi tchi ng on and
off of the three RGB vi deo si gnal s wi th
good ti mi ng.
Thi s brute-force programmi ng
method i s needed to achi eve the resul t
i n Photo 2. The l onger the program
takes between the i nterrupt and the
start of the vi deo di spl ay, the more
bl ack areas you have onscreen.
Real -ti me requi rements have to be
managed very careful l y. In parti cul ar,
the executi on ti me from the i nterrupt
to the start of the vi deo di spl ay must
be ri gorousl y constant, whatever the
resul ts of the i f/then tests are.
If i t i snt, the vi deo l i nes do not
al i gn. I was forced to add NOPs every-
wherei n parti cul ar, i n the anal og
acqui si ti on routi nesto ensure that
the same number of i nstructi ons i s
executed whatever the si tuati on i s.
To get the best resul t, I i mpl emented
some strange programmi ng practi ces.
For exampl e, to get a speci fi c del ay
wi th 125-ns resol uti on, I do a cal cu-
l ated jump i n the mi ddl e of a l ong
sequence of NOPs. Its the onl y sol u-
ti on Ive found, because managi ng a
l oop consumes several i nstructi ons.
Debuggi ng a si gnal -processi ng em-
bedded appl i cati on i snt easy. And, I
dont have access to an adequate ICE.
Si nce i t mi ght be useful for si mi l ar
projects, l et me bri efl y expl ai n my
methodol ogy (whi ch must not be too
bad: PICSpectrum actual l y works!).
After some ti mi ng cal cul ati ons to
ensure the feasi bi l i ty of the concept, I
started wi th a prototypi ng phase on a
PC usi ng a PC sound board as i nput. I
used fl oati ng-poi nt cal cul ati ons, wi th
everythi ng i n C (see Li sti ng 1). I then
transl ated the software to use excl u-
si vel y i nteger numbers and debugged i t.
The thi rd step was to devel op a
fi xed-poi nt l i brary (sti l l on the PC)
that prefi gures the future PIC-based
fi xed-poi nt l i brary. I al so modi fi ed the
FFT code to do al l cal cul ati ons excl u-
si vel y through thi s l i brary. It was
qui te easy to wri te thi s fi xed-poi nt
l i brary i n PIC assembl er, debug i t on
Mi crochi ps si mul ator, and transl ate
the FFT routi ne from C to assembl er.
Usi ng the si mul ator i s useful for
numeri cal -cal cul ati on software. In fact,
Sle 1: code or . !oal rumLe:
!oal dala|hNl.r1:
dala|='dala|`r1: ca!cu!al`or le o !!| oul`re
Sle : code or . `rlee rumLe:
wod dala|hNl. r1:
Sle : code or . ue o eudoe`le Laed or `Xedo`rl
wod a. L: eudoe`le l ard h
m_uL ' uLlacl`or urcl`or aL>a
ma`r oam:
m_!da`'`: !oad dala|` `r l e`le
m_!dL'r1: !oad r1 `r h e`le
m_uL': l = lh
m_d`v': l = l
m_la`': loe l `r dala|
Sle 4: al. lar!al`or `r 1 aemL!e
: m_uL : uLlacl h lo l 'l = lh
m_uL maco
mov L1.U! : !ow L,le `l
uLw a1.1
mov L.U! : ard r`r L,le w`lr Loow
uLwL a.1
ma`r oam:
: dala|='dala|`r1
m_!da` ` : m_!da`'`
m_!dL r1 : m_!dL'r1
m_uL : m_uL'
m_d`v : m_d`v'
m_la` : m_la` '
Listing 1Here you see my step-by-step process from traditional float C code on a PC down to integer
assembler code on a PIC.
i t was possi bl e to open two wi ndows
on my PC, the fi rst bei ng a standard
PC debugger wi th my C-code FFT, and
the second the PIC si mul ator wi th the
manual l y transl ated assembl er code.
Si ngl e steppi ng between the two codes
wi th a test si gnal as an i nput hel ped
me qui ckl y fi nd the more tri cky bugs.
When the si gnal -processi ng part
was compl eted and debugged, I wrote
the real -ti me part (si gnal acqui si ti on
and vi deo generati on) and debugged i t
as much as I coul d on the si mul ator.
Thi s phase was hel pful for correct-
i ng ti mi ng i ssues rel ated to vi deo syn-
chroni zati on. For exampl e, wi th a
Circuit Cellar INK

Issue 98 September 1998 31

[1] Mi crochi p Technol ogy, PI C17C-
75X Datasheet, DS30264A, 1997.
[2] Mi crochi p Technol ogy, PI C17C-
XXX EPROM Memory Program-
ming Specification, DS30274A,
[3] S.A. Teukol sky, W.T. Vetterl i ng,
and B.P. Fl annery, Numerical
Recipes in C: The Art of Scientific
Computing, Cambri dge Uni ver-
si ty Press, New York, NY, 1992.
[4] VGA Ti mi ng Informati on, /Mi sc/El ectroni cs/
docs/ol d/vga_ti mi ng.html .
Robert Lacoste lives in France, near
Paris. He works in the telecommuni-
cation industry as senior project man-
ager for GSM wireless base stations
development. Robert has 10 years
experience in real-time software and
embedded-system development. You
may reach him at
Photo 2This video image was generated by
PICSpectrum. Here, we have a quite clean 1.6-kHz
signal. The third and fifth harmonics are visible
under the fundamental frequency.
breakpoi nt set on each access to the
hori zontal synchroni zati on pi n, i ts
easy to veri fy i f the ti mi ngs on thi s
pi n meet the VGA speci fi cati on.
I wai ted unti l thi s phase was
successful before cabl i ng the proto-
type. The fi rst EPROM I burned di dnt
work 100%, but I got a worki ng vi deo
i mage and somethi ng resembl i ng a
spectrum di spl ay.
Thanks to the i n-ci rcui t program-
mi ng and some debug pi ns, the software
was worki ng soon. In fact, 90% of the
bugs found i n thi s l ast step were rel ated
to banki ng regi ster i ssues, whi ch are
tough to si mul ate because hardware
ports are i nvol ved.
I got the di spl ay l ooki ng qui te good,
wi th an i nterrupt routi ne taki ng ~50%
of the avai l abl e CPU ti me for vi deo
generati on. The mai n program has ti me
to do more than 10 FFT cal cul ati ons per
second, gi vi ng a true real -ti me di spl ay.
Wi th my techni que, the ti me spent
i n the vi deo-generati on code depends
greatl y on the i mage bei ng di spl ayed.
If the screen i s ful l of i nformati on, the
ti me l eft for the mai n program i s near
zero. So, you cant use thi s techni que
for al l vi deo-based projects.
To get sati sfactory resul ts wi th the
vi deo-di spl ay code, I sacri fi ced mai n-
tai nabi l i ty. Changes to the di spl ay may
requi re tremendous efforts i n keepi ng
the real -ti me constrai nts unchanged.
However, i t works, and the basi c pri n-
ci pl es may be used to get cheap vi deo
di spl ay devi ces l i ke PICSpectrum.
For your next vi deo-based project,
try to do i t wi th a software vi deo onl y.
If you have stri ct mai ntai nabi l i ty
requi rements, add a CRT control l er
chi p or sel ect a mi crocontrol l er wi th
one bui l t i n. On the other hand, the
FFT i mpl ementati on i s easi l y reused.
A fi nal note: Im sure thi s project
woul dnt be possi bl e wi thout a good
si mul ator or an ICE. Thanks to Mi cro-
chi p for provi di ng a good si mul ator
for free on the Web! I
Mi crochi p Technol ogy, Inc.
(602) 786-7200
Fax: (602) 786-7277
www.mi crochi
Compl ete source code for thi s
arti cl e and freeware for the PIC-
17C756 i n-ci rcui t programmer i s
avai l abl e vi a the Ci rcui t Cel l ar
Web si te.




34 Nouveou PC
ediled by Horv Weiner
38 Nelworking wilh DeviceNel
Porl 1: How DovlcoMol Slocks Up
Jim 8rody
46 keol-Iime PC
ICPJlP Nelworking
lngo Cyliox
55 Applied PCs
kodio Frequency ond Micros
Porl 1: lronsmlllor ond Rocolvor Modulos
Fred Eody
PC Nouveau
edited by Harv Weiner
The FCLite is a small form-factor, add-in, solid-state flash-memorybased disk emulator that uses an IDE interface.
The drives are compatible with any operating system, without requiring special software drivers or onboard BIOS ROM
sockets. The drives arent mapped into any BIOS or extended memory space. They are currently available in capacities
from 2 to 32 MB and have MTBFs exceeding one million operating hours.
The FCLite drives plug into either a PCI or ISA slot from which they derive power. They consume 3 mA in sleep mode
and less than 100 mA when writing or erasing. The data transfer rate is 4.0 MBps reading, 2.5 MBps writing/ burst,
and 50 kbps writing/ cont. Flash-memory write endurance is in excess of 300,000 write/ erase cycles. The FCLite drives
can withstand operating shock of 500 G, temperature range of
0700C and 595% noncondensing humidity environments.
Board dimensions are 4.3 1.7.
List prices for the FCLite drives range from $129 to $599.
Curtis, Inc.
(612) 404-9081
Fax: (612) 404-9175
The lan104 has been designed for a wide
range of embedded control applications with func-
tions specific to the implementation of PC-based, low-
cost, medium-scale man-machine-interfaces (MMIs).
Its Eurocard-format board features the AMD 100-MHz
lan486 microprocessor (full power management) with fully
licensed ROM-DOS running in flash memory, 416 MB of EDO
DRAM, 48 MB of flash memory, and 128 KB of battery-backed
Other features of the board include dual DMA controllers,
interval timers, real-time clock, clock generation circuitry,
DRAM controller, and ROM interface. Also included are a
bidirectional IEPP/ ECP parallel port, 16550-compatible serial
port, ISA-bus interface, speaker interface, and JTAG test access
Interfaces typically suited to MMI design include matrix
keyboard interface, mono LCD graphics (with VGA, 320
200 to 640 480 pixel resolution) interface, and SVGA CRT/
LCD for interfacing to CRT monitors or color flat-panel displays.
Standard peripheral I/ O ports include 16-bit PC/ 104
expansion interface, floppy and hard disk drive interfaces, two
RS-232 serial ports, one RS-485 port for multidrop serial
applications, and a single LPT parallel printer port. Standard
PC-type mouse and keyboard ports are supplied via PS/ 2 mini-
DIN connectors.
Arcom Control Systems, Inc.
(816) 941-7025
Fax: (816) 941-0343
PC 35
PC Nouveau
WinSystems PCM-AUDIO-DLX offers 16-bit stereo
audio functions that can simultaneously record and playback
(full duplex) voice, sound, and music on a PC/ 104-compatible
module. Based on the ESS Technology ES1888 AudioDrive chip, this
module supports PC audio that is AdLib and SoundBlaster Pro compatible.
A four-channel record mixer blends three 16-bit stereo and one micro-
phone input under software control. An independent seven-channel mixer
supports playback. Stereo output from the playback is up to 2 W per
channel. The volume can be adjusted by software, an external 64-step push-
button audio control, or onboard potentiometers. Two joystick inputs
provide more input and control options.
The ES1888 chip operates at sample rates of up to 44.1 kHz to provide
CD-quality sound. It has a 20-voice, 72-operator music synthesizer. The FM
synthesis is backward compatible to the OPL-3 mode. An MPU401 serial
port can be used to interface with external wave table synthesizers and MIDI
Special drivers are not needed for newer OSs like Windows 95 and
Windows NT. Windows 3.x is supported through supplied drivers.
WinSystems offers a utility that allows record and playback of audio or voice
with control of sample speed, volume, and compression for use with DOS
or non-DOS applications. It also supports playback of Windows 9)8 audio
files in a non-Windows
An optional KIT-PCM-
AUDIO-DLX consists of a
microphone, two speakers,
PC Bus Sound Blaster
compatible board, Win-
dows audio-applications
user guide, and DOS/
embedded-systems tools
and drivers. This kit enables
the designer to develop
and debug the applica-
tion code on either a desk-
top PC or the target
embedded CPU running
in a Windows or DOS
sells for $250.
WinSystems, Inc.
(817) 274-7553 Fax: (817) 548-1358
The CMi586DX133 cpuModule is an ultra-
compact, high-speed, fully integrated PC/ 104-
compliant CPU. The cpuModule features a high-
performance 133-MHz Am5x86 processor, inter-
nal math coprocessor and cache, 8 MB of 32-bit
wide surface-mounted DRAM, IDE, and floppy
Also included are two software-configurable RS-
232/ -422/ -485 serial ports, Extended Capabili-
ties Parallel (ECP) port, keyboard and speaker port,
and a watchdog timer. A 32-pin solid-state disk
socket supports 1-MB EPROM or 512-KB flash
memory, SRAM, NVRAM, or MSystems Disk-
The services and functions provided by its Em-
bedded BIOS ensures PC/ AT compatibility. BIOS
enhancements include quick boot, virtual devices,
and solid-state disk support with flash file system. A
virtual device mode allows the operator to use the
keyboard, video, floppy, and/ or hard disk on
another PC-compatible computer through the serial
port. A nonvolatile configuration EEPROM stores
the system setup without needing a battery.
The CMi586DX133 sells for $598.
Real Time Devices USA, Inc.
(814) 234-8087
Fax: (814) 234-5218
PC Nouveau
The MM686 is a PC/ 104 form-factor board
featuring two PCMCIA slots, four A/ D video input
channels, 5-W SoundBlastercompatible stereo sound,
and support for optional PCMCIA-based Zoom Video MPEG
decoding. It also accommodates two joysticks or a MIDI input.
The video inputs support PAL, NTSC, and SECAM decoding
and real-time video capture ability. The YUV video output plugs
into the YUV connector on 686LCD/ S or 686LCD/ MG SBCs,
allowing for extremely high frame rate video display and capture
handled directly by the video controller.
The PCMCIA interface is PCMCIA-2.1 and JEIDA-4.1 compli-
ant and supports all common PCMCIA cards (e.g., modems, ATA
flash cards, MPEG decoders, and hard drives).
The SoundBlastercompatible port has stereo-line and head-
phone output as well as a direct output from the onboard 5-W
amplifier. The MM686 supports a microphone input, analog line
input, and direct input from CD playback devices via the Zoom
Video port. Volume control is supported in software or via the built-
in up-down-mute plug.
This PC/ 104 board is fully scalable for applications that dont
require all of its features. It can be provided as just a SoundBlaster
board, just a dual-slot PCMCIA interface, just a video/ image
processing board, or in any combination.
Inside Technology USA, Inc.
(972) 390-8593
Fax (972) 390-8609
Jim Brady
Networking with DeviceNet
Part 1: How DeviceNet Stacks Up
Reoding orlicles on nelworks roises o
lol ol queslionslike whelher lo coll Device
Mel o nelwork, o bus, o lieldbus, or whol
lhe lerm bus" is used lor induslriol
nelworks lhol conlrol lhings, os opposed lo
generol ollice nelworks lhol move dolo. l
decided lo lorgel oboul impressive lerms
ond slick lo bosics. l wonl lo cover lhe meol
ond pololoes ol whol o developer needs lo
know lo implemenl o Device
Mel nelwork.
Vhy ore lhere so mony
nelwork prolocols Figure 1
shows 15 ol lhem. Vhy nol
|usl use Elhernel
ln lhe beginning, l didnl osk.
l developed DeviceMel inlerloces
becouse cuslomers requesled
lhem. lhen Prolibus, lhen olhers.
However, wilh lime, l won
dered. is lhere on ideol nel
work lor o given opplicolion
lhis monlh, l show how
DeviceMel compores lo olher
device nelworks ond exploin
how il works. ln Porl 2, lll look ol o reol
DeviceMel device, code ond oll.
Beller dusl oll your C++ books becouse
DeviceMel is ob|ecl orienled oll lhe woy.
C works, bul C++ lils like o glove.
Vhere does DeviceMel lil inlo lhe
nelwork menogerie Al lirsl glonce, oll lhe
nelworks look quile similor. However, eoch
one hos o unique sel ol leolures ond is
designed lo move o specilic lype ol dolo
belween cerloin kinds ol equipmenl.
Here, device" relers lo smoll lo midsize
equipmenl wilh mulliple inlegroled sensors
ond,or ocluolors. Device nelworks ore
designed lo inlerconnecl lhese devices.
As devices gel smorler ond processing
power cheoper, even simple
devices moy hove highlevel
nelwork porls, producing o
consolidolion loword lhe high
end ol Figure 1. Bul lhere will
olwoys be o need lor more
lhon one level ol nelwork. Plonl
engineers donl wonl lo shore
lheir Elhernel ollice nelwork
wilh ossembly robols!
DeviceMel represenls o
new breed ol device nelworks
lhol oller nilly leolures, such os
holplug copobilily, nelwork
V/I c Ie ceLcIe on neIvo:: Ie:e ccy:, /I: ec:y Io geI conu:ec cLouI
Ie c/e:ence: LeIveen neIvo::, Lu:e:, cnc /ec Lu:e:, pc:I/cuc:y ven
c nev Iecnoogy coe: cong. /o/n // o: Ie ovcovn on De+/ce/eI.
Fgoro JAoIomoIon noIorRs oI Io o onU movo on/o11 mossogos
BoIoon smpo sonsors onU ocIooIors. AI Io g onU, compo oqopmonI
Irons1ors orgo BocRs o1 UoIo ponI Uo. OovcoAoI onUos Io mUUo
Block I/O
Discrete I/O





Device Networks Control Networks Field

lion lor relioble reollime
communicolion. Al leosl live
lC vendors moke CAM conlrol
lers lhol hondle oll lhe deloils ol
lhe CAM prolocol lor you.
Vhol mokes CAM so good lor reol
lime messoging 5horl messoge lenglh
ond priorilybosed collision resolulion.
lhe loller leolure is o mo|or reoson lor
CAMs populorily. ll o collision occurs, lhe
higher priorily messoge slill gels lhrough
inlocl! ln locl, lhe lower priorily colliding
node ends up receiving lhe higher priorily
colliding nodes messoge.
Vilh mosl olher prolocols, il o collision
occurs, no dolo gels lhrough, ond lhis con
hoppen over ond over. Mol cool lor o
messoge lo on oulomobile broke!
CAM requires nodes lo lislen belore
sending. ll lwo or more nodes decide lo
send ol lhe some lime, ils lhe some lime lo
wilhin o smoll lroclion ol o bil lime. lhol
meons lhe messoges line up billorbil.
Becouse lhe nelwork line is essenliolly
wireCRed [see Figure 3|, o low bil over
rides o high bil. Modes lislen lo whol lhey
send, ond lhe node sending lhe high bil
will reolize lhol ils receiving o low bil.
Al lhol inslonl, il knows lhere is o
collision ond swilches lrom sending lo
receiving. lhe mosl signiliconl bil ol lhe
Conneclion lD is senl lirsl, so lhe messoge
wilh lhe lowernumbered lD wins lhe bil
wise orbilrolion ond gels lhrough inlocl.
For lhis lo work, nodes ol opposile ends
ol lhe coble musl hove lheir bils line up lo
wilhin oboul holl o billime. lhus, lhe
roundlrip deloy ol lhe coble is limiled lo
1.0 s ol lhe moximum DeviceMel speed
ol 500 kbps. lhe corresponding coble
Fgoro 1To no proUocor-consomor moUo
UonI1os Io UoIo roIor Ion Io soorco onU
powered devices, peerlopeer, liber oplics,
ond loull conloinmenl. And il you do il
righl, your device will be inlerchongeoble
wilh your compelilors. lhis moy nol seem
good lo you, bul your users will like il.
Mosl device nelworks, including Device
Mel, ore delerminislic. ln lhis conlexl,
delerminislic" simply meons lhol lhe nel
work con guoronlee o dropdeod moxi
mum delivery lime lor o crilicol messoge.
Mony peerlopeer nelworks conl cloim
lhis becouse ol lhe possibilily ol mulliple,
deslruclive collisions.
Elhernel using slondord hubs, lor ex
omple, is collisionbosed ond lherelore nol
delerminislic. Bul il con be mode so,
lhereby becoming o conlender lor reol
lime conlrol oulomolion.
ll you hove o losl processor, combined
wilh )ovo, ond perhops Vindows CE,
mosl ol lhe nelwork code is done lor you.
lm more ol on 8bil mon mysell, bul wilh
38E/s ol $1, ils worlh considering.
Mosl new nelworks, ogoin including
DeviceMel, use o producerconsumer [olso
colled dolocenlric| model os opposed lo
lhe older sourcedeslinolion model. lhe
dolo is considered cenlrol lo lhe messoge
ond is whol is idenlilied, rolher lhon lhe
source ond deslinolion.
lhis siluolion increoses lhe elleclive
bondwidlh ol lhe nelwork by permilling
onelomony broodcosl messoging ond
lime synchronizolion. Figure 2 illuslroles
lhe dillerence belween lhe lwo messoge
Aulomolionequipmenl designers ore
eliminoling oldslyle poinllopoinl wiring.
lhey wonl devices lrom vorious suppliers lo
coexisl on lhe some nelwork. llimolely,
lhey wonl inlerchongeobilily belween some
lype devices mode by dillerenl suppliers.
lheyre olso osking suppliers lo moke
lheir devices smorler, wilh beller diognos
lics. ldiol lighls ore no longer enough.
Diognoslic sensors should provide bolh
olorm ond worning levels.
lhe hope is lhol lhe device worns ol
obnormol levels belore ils loo lole. ll o
device does loil, il con eosily be swopped
oul lor onolher, possibly one lrom o dillerenl
monuloclurer, wilhoul powering down lhe
nelwork. Vhen lhe new device comes up
on lhe nelwork, il lells you whol il is, whol
il con do, ond lels you know il ils CK.
loble 1 compores leolures ol some
populor device nelworks. Al lhis level ol
comporison, mony dillerences emerge.
CAMbosed nelworks hove limiled ronge
becouse lhey ore sensilive lo lime deloy on
lhe line. Mosl olher nelworks use repeolers
lo exlend lheir ronge.
Vilh o 500m ronge ond o 4node
limil, you wouldnl use DeviceMel lo nelwork
o lorge holel. Bul, il is on excellenl lil in o
wide ronge ol opplicolions. lhe CAM
prolocol lhol DeviceMel wos buill on wos
originolly designed by Bosch lor use in oulos
ond lrucks. lhis horsh environmenl isnl so
dillerenl lrom semiconduclor lob lools ond
olher oulomolion equipmenl.
Vilh o shorl messoge lenglh, DeviceMel
is well suiled lor limesensilive messoging.
Al 500 kbps, o node doesnl hove lo woil
more lhon 0.2 ms lo send.
lhere is much lilerolure on CAM |1],
including orlicles by Brod Hunling [lhe
5olulions in lhe CAM," I/K 58| ond
Villord Dickerson [Vehiculor Conlrol Mul
liplexing wilh CAM ond )1850," I/K P|.
Here, lm only going lo cover lhe mosl
imporlonl poinls.
Melwork prolocols such os DeviceMel,
5D5, ond CAMopenoll buill on lop ol
CAMinheril o wellesloblished loundo
Source-destination model:
Producer-consumer model:
source destination data crc
data crc
ToBo JRopooIors oro roqoroU 1or Pro1Bos onU IonorRs Io ocovo Is rongo onU noUo
coonI. OovcoAoI onU 5O5 oro Io popoor CAA-BosoU noIorRs. OIors osI, Ioo, soc os
CAAopon onU CAA KngUom. Pro1Bos s o mosIor-sovo proIoco IoI s popoor n oropo onU
gonng sopporI n Io O.5. IonorRs, Uoy osoU n BoUng ooIomoIon, s no soong oso
n Io oqopmonI ooIomoIon 1oU.
DeviceNet SDS Profibus DP LonWorks
Max. range 500 m at 500 m at 9600 m at 2700 m at
125 kbps 125 kbps 94 kbps 78 kbps
Max. speed 500 kbps 1 MBps 12 MBps 1.25 MBps
Max. nodes 64 128 126 32,385
Max. message length 8 bytes 8 bytes 244 bytes 228 bytes
Bus access Peer, M/S Peer, M/S M/S Peer, M/S
Error resistance 15-bit CRC 15-bit CRC 16-bit CRC 16-bit CRC
Deterministic yes yes yes in M/S mode
Hot-plug capability yes yes yes yes
Fault confinement yes yes yes yes
Line-powered devices 24 VDC, 8 A yes optional optional
Media twisted pair twisted pair twisted pair, twisted pair, fiber,
fiber, RF RF, power line
lenglh con be deler
mined by.
0.5 [1.0 s 300 m,s 0.Z2| = 108 m
where 300 m,s is velocily ol lighl
ond 0.Z2 is lhe velocily conslonl ol lhe
DeviceMel coble. lhols why you hove lhe
100m limil on coble lenglh ol 500 kbps.
lhe CAM conlroller colculoles o 15bil
CRC volue lor lhe received dolo ond
compores il ogoinsl lhe CRC il received. ll
on error is delecled, lhe node originoling
lhe messoge is nolilied so il con resend lhe
ll lhe originoling node sends loo mony
messoges lor which il gels on error bock,
il goes ollline. lhol woy, o bod device
wonl crosh lhe enlire nelwork.
Your CP delecls lhis evenl by reoding
lhe CAM chips slolus regisler. You hove
lhe oplion ol sloying ollline or inilioling on
errorrecovery sequence.
ll lhe CAM conlroller originoling o
messoge doesnl heor bock lrom ol leosl
one olher device lhol lhe messoge wos
correclly received, il will resend. lhus, o
lonely node will |usl sil lhere ond send over
ond over.
Vhen you do gel o messoge lrom your
CAM conlroller, you know ils correcl.
And when you lell lhe CAM conlroller lo
send o messoge, il keeps lrying unlil lhe
messoge gels lhrough. Prelly good, con
sidering oll lhis is hondled by one $8 chip.
lo moke CAM inlo o usoble nelwork,
you need o woy lo slring messoges lo
gelher, esloblish conneclions, ond hondle
errors. lhols where DeviceMel comes in.
DeviceMel provides o slruclure lor es
loblishing logicol conneclions belween
devices, releosing conneclions il lhey go
unused lor loo long, ond slringing messoges
logelher il you need more lhon 8 byles. ll
olso provides on ob|eclorienled lrome
work lo lell you how lo slruclure your
nelwork code.
ll your devicelype is in lhe DeviceMel
librory, il even lells you how your device
should behove. lhol porl is necessory lo
moke devices complelely inlerchongeoble.
Cenlrol lo DeviceMel is o concepl colled
o conneclion. lhink ol il os o lelephone
conneclion. Vhen you coll someone, you
esloblish o conneclion. lhol conneclion is
yours, ond olher people lolking on lhe
some liber hove dillerenl conneclions. lhe
conneclion breoks when you hong up or in
some coses il you slop lolking lor o while.
ln DeviceMel, eoch conneclion is idenlilied
by on 11bil number colled o messoge idenli
lier or conneclion lD. lhis number includes
your devices Medio Access Conlrol ldenlilier
[MAC lD|, which is o number lrom 0 lo 3,
usuolly sel by o swilch on your device.
DeviceMel provides o sel ol 11 pre
delined conneclions, colled lhe predelined
mosler,slove conneclion sel [see loble 2|.
Voil o minule.mosler,slove
Yes, lhols o leldown oller expecling
peerlopeer, bul mosl DeviceMel producls
on lhe morkel lodoy ore sloveonly de
vices. lhe implemenlolion is much simpler
ond less memory consuming.
A peer device musl include o lol ol
code lo dynomicolly esloblish ond con
ligure conneclions. ll you reolly wonl lo
include peer copobilily, lhe slondord
enobles you lo pul il in o device olong wilh
lhe predelined conneclion sel.
ln locl, lhe DeviceMel slondord dislin
guishes belween o slove device lhol olso
hos peer copobilily, ond o sloveonly
device. ln lhis orlicle, lm slicking lo lhe
simpler sloveonly device, which uses only
predelined conneclions.
DeviceNel ME55AGE5
DeviceMel hos lwo bosic messoge
lypes. explicil ond l,C. lhe predelined
conneclion sel includes one explicil con
neclion os well os lour l,C conneclions ol
dillerenl kinds.
Explicil messoges include lhe polh lo
locole lhe dolo ol inleresl. lhis consisls ol
lhe closs lD, inslonce number, ond ol
lribule lD. lhey olso specily on oclion lo be
loken [e.g., sel or gel|. Finolly, lhey in
clude lhe moslers MAC lD becouse o
slove musl respond only lo ils mosler.
Vilh ol oll lhis boggoge, explicil mes
soges orenl ellicienl. lhey ore used moinly
lor iniliol conligurolion, ollhough in lheory
lhey could be used lor everylhing. Your
device musl supporl lhis conneclion, bul
olhers ore oplionol.
ln on l,C poll conneclion, lhe mosler
periodicolly sends o requesl soying in
ellecl, Hey! 5end me your dolo." ll is on
ellicienl exchonge becouse lhe mosler
doesnl need lo send ony boggoge.
Vhen lhe slove device sees o messoge
wilh lhis conneclion lD, il relurns o preor
ronged sel ol dolo. Cn more complex
devices, lhe mosler con usuolly selecl lrom
vorious dolo sels. ll only one l,C conneclion
is supporled, ils usuolly lhis one becouse
il is generol purpose.
ln on l,C chongeolslole [CC5| con
neclion, lhe device sends ils dolo when il
chonges more lhon o selecled omounl. lhis
choice is good lor slowly chonging dolo.
lhe l,C cyclic conneclion uses lhe
some conneclion lD os lhe CC5 connec
From CAN
twisted pair line 120
From CAN
twisted pair line 120
Fgoro BA OovcoAoI no I o ono-no
Urvor osos o o ooIpoI 1rom Io CAA
conIroor Io Iorn BoI IronssIors on o o
g ooIpoI Iorns BoI o11. II orRs Ro o
ro-OR, oro ony o ooIpoI UomnoIos
o oIor noUos g ooIpoIs.
Connection ID Bits Description
10 9 8 7 6 5 4 3 2 1 0
Slaves MAC ID Group 1 Message
0 1 1 0 1 Slaves I/O Change-of-State/Cyclic Message
0 1 1 1 0 Slaves I/O Bit-Strobe Response
0 1 1 1 1 Slaves I/O Poll Response

Slaves MAC ID
Group 2 Message
1 0 0 0 0 Masters I/O Bit-Strobe Request
1 0 0 0 1 Reserved
1 0 0 1 0 Masters Change-of-State/Cyclic Ack.
1 0 0 1 1 Slaves Explicit Response
1 0 1 0 0 Masters Explicit Request
1 0 1 0 1 Masters I/O Poll Request
1 0 1 1 0 Unconnected Port
1 0 1 1 1 Duplicate MAC ID Check
ToBo 1Toso JJ connocIons
como 1rom Io OovcoAoI mos-
sogo groops, I Io Connoc-
Ion IO moUo op U11oronIy n
ooc coso. Oroop J mossogos
oro gor prorIy, osoU 1or Io
sovos I/O mossogos. A mos-
sogos orgnoIo 1rom Io mos-
Ior, ocopI 1or Io OopcoIo
mAC IO CocR onU Io sovos
CO5/cycc mossogo.
like o regulor messoge, excepl lhe lirsl porl ol
lhe dolo lield conloins lrogmenl inlormolion.
For on explicilmessoge lrogmenl, lhe
lirsl byle conloins o lrogmenl llog, ond lhe
second byle specilies lhe lrogmenl lype
[lirsl, middle, losl| ond lhe lrogmenl counl.
lhe lrogmenl counl is only o sixbil volue
bul con roll over ony number ol limes,
ollowing lor messoges ol unlimiled lenglh.
For on l,Cmessoge lrogmenl, only
one byle is used lor lrogmenl inlormolion
[lhe one specilying lrogmenl lype ond
counl| lo moximize lhe spoce lor ocluol
dolo. ln lhis cose, lhe lrogmenl llog is
implied il lhe produced conneclion size is
greoler lhon 8.
For explicil or l,C lrogmenls, lhe receiver
simply concolenoles lhe dolo obloined
lrom eoch lrogmenl, slopping when il sees
lhe llog indicoling lhe linol lrogmenl.
Vilh lrogmenled messoges lhere is lhe
queslion ol whelher lhe receiving device
needs lo send on ocknowledge lor eoch
lrogmenl received. ll does lor on explicil
messoge bul nol lor on l,C messoge. l,C
messoge lrogmenls ore senl bocklobock
lor moximum speed.
Figure 4 shows some reol DeviceMel
messoges bosed on o lypicol oulollhe
box slove MAC lD ol 3 ond o mosler lD
ol 1. lhis siluolion is lypicol becouse il gives
lhe slove device lhe lowesl priorily ond lhe
mosler lhe highesl.
For clorily, Figure 4 shows only lhe connec
lion lD ond dolo lields ol lhe CAM messoge
lrome. lhere ore lwo oddilionol lields.
Cne is o lenglh lield lhol lells lhe receiver
how mony byles ol dolo lo expecl.
lion. lhe mosler chooses belween lhe lwo
when il ollocoles lhe conneclion. Vilh lhe
cyclic conneclion, lhe device sends ils dolo ol
o selecled role. lhis choice works well lor
ropidly chonging dolo.
ln on l,C bilslrobe conneclion, lhe device
sends only o lew bils ol dolo in response
lo lhe moslers bilslrobe requesl. lhis is o
good choice lor simple on,oll sensors.
Vilh DeviceMel, no conneclions exisl
unlil lhey ore ollocoled. How do you
ollocole o conneclion in lhe lirsl ploce l
lhink lhe designers ol DeviceMel musl
hove slruggled wilh lhis.
ll lurns oul lhol o speciol conneclion
olwoys exislslhe unconnecled porl. lhe
mosler sends on ollocole messoge lo lhe
unconnecled porl lo ollocole conneclions
ond specily which ol lhe predelined connec
lion sel il wonls lo use. Cnce you hove connec
lions, you con send messoges over lhem.
Mony CAM conlrollers hove individuol
moilboxes lor incoming messoges. You
con ossign eoch conneclion lD lo o diller
enl moilbox. lhe lnlel ond 5iemens chips
hove 15 ond 1 moilboxes, respeclively,
enough lor lhe predelined conneclion sel
wilh room lo spore.
lhis mokes your progrom modulor lrom
lhe slorl. Dillerenl messoges come in dil
lerenl boxes.
An explicil messoge lrom lhe mosler uses
live byles ol lhe eighl byles ovoiloble lor
lhe polh, service, ond mosler MAC lD. lhis
leoves only lhree byles lor ocluol dolo.
ll lhe mosler sends o lourbyle long inl,
lwo seporole messoges ore needed. lhese
messoges ore colled lrogmenls ond ore |usl
F g o r o
#T o s o
oro mossogos
yoo soo on o
OovcoAoI ono-
yzor Uorng o Iypco
sIorI-op soqoonco. To
ConnocIon IOs oro BosoU
on o sovo mAC IO o1 OBF.
AoIo Io voroBo-ongI UoIo
1oU. A mossogo vooos oro
n o, onU Io oosI sgn1-
conI BI s ooys sonI 1rsI.
lhe olher lield is used lor ocknowledg
menl. lhe node receiving lhe messoge
sends on ock bil il lhe messoge wos CK.
CAM messoges ore vorioble lenglh.
Depending on lhe number ol dolo byles
senl, o lrome con ronge lrom 44 lo 108 bils.
lhe lirsl messoge your device deols
wilh is o duplicole MAC lD check mes
soge. Belore going online, your device
musl moke sure il hos o unique MAC lD.
lo do lhis, your device broodcosls lwo
duplicole MAC lD check messoges, 1 s
oporl, oddressed lo ils own MAC lD. All
devices receive lhis messoge, bul none
respond unless your device oddresses lhem!
Aller sending lhe duplicole MAC lD
check messoge lwice ond heoring no
response, you con go online.
Bul since you hove no conneclions yel,
you musl ignore oll messoges wilh lwo
exceplionso messoge lo your uncon
necled porl lo ollocole conneclions, or o
duplicole MAC lD check messoge lhol
conloins your MAC lD.
Duplicole MAC lD check messoges
would be lrom onolher device hoping lo
go online bul sel lo lhe some lD os yours.
Your response lo lhis messoge prevenls lhe
ollending device lrom going online.
Vhen you gel o messoge lo your
unconnecled porl il will be lhe mosler
specilying which conneclions oul ol lhe
predelined conneclion sel il wonls lo ollo
cole. lhe ollocolion choice byle conloined
in lhis messoge will hove bils sel which
correspond lo lhe conneclions il wonls.
ll you supporl lhese conneclions, ollo
cole lhem ond relurn o success response.
Clherwise relurn on error ond donl ollo
cole ony conneclions.
Slaves success response to masters allocate request
5FB 01 CB 00
5FB = Connection ID for slaves explicit response
01 = Echo masters MAC ID
CB = Service code ORd with response flag
00 = Wants 8-bit message format
Masters explicit request to set packet rate of
Explicit connection to 500 ms
5FC 01 10 05 01 09 F4 01
5FC = Connection ID for masters explicit request
01 = Masters MAC ID
10 = Service code for Set Attribute
05 = Class ID of connection class
01 = Instance ID (explicit connection)
09 = Attribute ID of packet rate
F4 = Desired packet rate LSB
01 = Desired packet rate MSB
Slaves duplicate MAC ID check message.
Vendor ID is 0851h, Serial No. is 01020304h
5FF 00 51 08 04 03 02 01
5FF = Connection ID for dup. MAC check
00 = Devices physical port number
51 = Vendor ID LSB
08 = Vendor ID MSB
04 = Devices serial number LSB
03 = Devices serial number
02 = Devices serial number
01 = Devices serial number MSB
Masters allocate connections message to
allocate the explicit and poll I/O connections
5FE 01 4B 03 01 03 01
5FE = Connection ID for unconnected port
01 = Masters MAC ID
4B = Service code for Allocate
03 = Class ID of DeviceNet class
01 = Instance ID
03 = Allocation choice (explicit and I/O poll)
01 = Allocators MAC ID
Slaves success response to masters request to
set packet rate. Actual packet rate was set to 512 ms
5FB 01 90 00 02
5FB = Connection ID for slaves explicit response
01 = Masters MAC ID
90 = Service code ORd with response flag
00 = Packet rate actually set LSB
02 = Packet rate actually set MSB
Masters I/O poll request
5FD = Connection ID for masters I/O poll request
The data field is empty!
Slaves I/O poll response
3FF 00 20 0F
3FF = Connection ID for slaves I/O poll response
00 = Slaves error status (OK)
20 = Temperature of 32F
0F = Humidity of 15%
Analog Input Point Class
Assembly Object
Identify Object
DeviceNet Object
I/O Poll
Connection Class
Assembles data from the
sensors to send in the
I/O Poll Response.
These objects model actual sensors in the device.
They are instances of the Analog Input Point Class.
Contains the devices identity
model number, serial number,
manufacturer name, etc.
to the
Allocates and releases
connections, contains
configuration values like
baud rate and MAC ID.
DeviceNet Network
These objects consume
and produce messages, and
handle fragmentation. There is
one object per connection
supported. The Explicit
Connection is always instance
1 of the Connection Class.
The I/O Poll Connection
is instance 2.
Message Router
DeviceNel lnlormolion
Cpen DeviceMel Vendor Assn., lnc.
[P54| 3405412
Fox. [P54| 3405413
DeviceNel Conlormonce Iesling
niversily ol Michigon
[Z34| Z4433
Fox. [Z34| P3034Z,~sbus
DeviceNel lnlerloce Cords
Huron Melworks, lnc.
[313| PP523Z
Fox. [313| PP528Z
Molionol lnslrumenls, lnc.
[512| ZP40100
Fox. [512| ZP48411
5olling GmbH
lCl, lnc.
[PZ8| 55Z5882
Fox. [P8Z| 55Z5884
55l, lnc.
[51P| Z25513
Fox. [51P| Z251515
// :ccy c: ce:/gnec eLeccec :y:-
Ie: o: yec::. You cy :ecc / cI
Keep lrock ol lhe
mosler MAC lD lhol ollo
coled lhese conneclions, be
couse lrom now on lhis is your
mosler. A messoge conloining o
dillerenl mosler MAC lD is ignored.
For eoch conneclion ollocoled, slorl o
limer lhol deleles lhe conneclion il il limes
oul. For lhe explicil conneclion, lhe limer
deloulls lo 10 s. For lhe l,C poll connec
lion, il deloulls lo zero ond musl be sel by
lhe mosler belore lhe conneclion is used.
lhe limeoul volue is conlrolled by on
ollribule colled lhe expecled pockel role
[EPR|, which lhe mosler con sel. Your lime
oul volue, in milliseconds, equols lhe EPR
4. lhus, lhe EPR lor lhe explicil connec
lion deloulls lo 2500.
ln lhe l,C messoge exomple shown in
Figure 4, nole lhol no dolo, polh, or
service code is senl wilh lhe moslers
requesl. lhe dolo sel relurned wilh lhe
sloves response is olreody specilied in lhe
monuloclurers device prolile or eleclronic
More complex devices moy hove mony
sels ol dolo lhe mosler con choose lrom.
lhe Mosler selecls lhe sel il wonls by
chonging lhe sloves produced conneclion
Becouse no boggoge is involved in lhe
l,C messoge, ils on ellicienl process. A
device such os lhe one modeled in Figure
5 con send ils enlire sensor ond slolus dolo
in one l,C messoge. Vilh explicil mes
soging, mony lulllenglh messoges would
be needed.
Vilh DeviceMel, o device is modeled
os o colleclion ol ob|ecls. Eoch ob|ecl hos
ollribules ond behoviors, ond con be
implemenled direclly os o C++ closs.
Figure 5 shows lhe ob|ecl model lor o
DeviceMel device wilh lwo onolog sensors.
Eoch closs hos o closs lD, ob|ecls hove
on inslonce lD, ond ollribules hove on
ollribule lD. By specilying lhese lhree lD
numbers, ony ollribule in lhe device con
be oddressed.
lhe DeviceMel Cb|ecl Librory is con
loined in Volume ll ol lhe slondord. ln
oddilion lo nelworkreloled ob|ecls, il in
cludes oboul 25 ob|ecls lhol model reol
world swilches, sensors, ocluolors, PlD
loops, posilion sensors, ond conlrollers.
lhere ore more on lhe woy, including on
Anolog 5ensor Cb|ecl lhol models od
vonced sensors, wilh copobililies such os
colibrolion, oulozero, ollsel, goin, ond
Vhen you complele your DeviceMel
producl, how do you know il meels lhe
slondord lhe niversily ol Michigon will
lesl your producl lo see il il conlorms lo lhe
rigors ol lhe DeviceMel prolocol.
ll lhis sounds loo inlimidoling, you con
ovoid emborrossmenl by gelling lhe soll
Fgoro Moros Io OBjocI moUo 1or o OovcoAoI Uovco I Io onoog sonsors. Toso oBjocIs
con Bo mpomonIoU os nsIoncos o1 C cossos, BosoU on Io UoIooU moUos provUoU n Io
OovcoAoI OBjocI IBrory.
|1] ). 5chill, An Cverview ol lhe CAM Prolocol,"
LLeccec oy:Ie: I:og:c/ng, p. 4, 5epl 1PPZ.
wore ond o DeviceMel inlerloce cord so
you con lesl il yoursell. Vhen you do go
lo lhe lesl lob, bring your loplop ond
compiler olong. lhe process is designed
lo be o lixilosyougo experience.
DeviceNel 5IANDAkD5
lhe DeviceMel slondord keeper is lhe
Cpen DeviceMel Vendor Associolion
[CDVA|. ll monoges lhe evolving slon
dord ond ossisls vendors in developing
lheir producls ond lhe Device Proliles lor
lhem. Vilhin lhe ossociolion ore 14 oclive
speciolinleresl groups, orgonized olong
producl lines. lhe CDVA Veb sile lisls
lhese groups.
You con gel your leel wel by gelling o
DeviceMel cololog ol no chorge lrom
CDVA. lhe lirsl chopler hos on excellenl
overview ol CAM ond DeviceMel. ll you
decide lo |ump in, you con purchose lhe
lull DeviceMel specilicolion [lhe CD ver
sion includes o good seorch engine| lrom
CDVA. Loler you con become o member,
|oin o 5lG, ond ploy o porl in delining
nelwork slondords lor your induslry.
Mexl monlh, lll lurn some DeviceMel
ob|ecls inlo C++ closses, embed lhem in o
38E/, ond hong o DeviceMel inlerloce
on il. EPC
Fgoro Joc oyor n o TCP/IP sIocR os o
spoc1c 1oncIon onU oUUs o ooUor Io Io
UoIo 1rom Io oppcoIon oyor.
Network interface
TCP packet
TCP Data
IP packet
PPP packet
Ethernet packet
Real-Time PC
Ingo Cyliax
TCP/IP Networking
hen l discussed nelwork communi
colion losl monlh, l menlioned lhol Elhernel
is slorling lo be viewed os o device
inlerloce bus. l olso lold you oboul lhe
increosing ovoilobilily ol Elhernelbosed
doloocquisilion devices. lhis monlh, lels
see whol il lokes lo build o prololype ol on
Elhernelbosed device.
Firsl queslion. whol do l deline os on
Elhernelbosed device Bosicolly, o device
lhol hos on Elhernel porl os ils primory
inlerloce. A lemperolure sensor wilh on
Elhernel porl is one exomple, bul lm nol
sure oboul lhe economics ol such o pro|ecl.
lo moke developing such o device
more inleresling lo me, il needs lo solve
one ol my problems. 5o, here goes.
l lrequenlly use o prololyping syslem
colled o logic engine, which is essenliolly
o syslem lesler. ll hos 128 l,C porls ond is
conlrolled vio o PCcompolible porollel porl.
lhe prolocol used over lhe porollel porl
needs nonslondord sollwore lo drive il.
lhis siluolion wosnl o problem when o
DC5bosed mochine conlrolled lhis boord.
l simply wrole o progrom lo moke lhe
porollel porl perlorm lhe lunclion l wonled.
Vilh lhe odvenl ol Vindows P5 ond
Vindows Mlbosed syslems, conlrolling
lhe porollel porl becomes on issue. l now
need lo wrile o device driver |usl so my
progrom, which wonls lo conlrol lhe logic
engine, con lolk lo il. Vhols worse, lhis
device driver will probobly breok when l
lry il wilh VinP8 or when Ml5 comes oul.
lhe device l wonl lo discuss is o Elhernel
loporollel porl device lhol conlrols lhe
logic engine. ln o sense, lhe porollel porl
bosed logic engine becomes on Elhernel
bosed logic engine.
lhis lechnique hos severol odvonloges.
Firsl ol oll, l donl need lo wrile ond insloll
o device driver on lhe syslem conlrolling lhe
logic engine. 5econdly, l con shore lhe logic
engine belween workslolions or over lhe
Finolly, l con use o voriely ol progromming
longuoges on mony plollorms lo lolk lo lhis
device. All my longuoge on lhe workslo
lion needs now is o nelwork librory. l donl
V/I LIe:neI c/p: Leco/ng c c/e c cozen, /I: c oI ec:/e: Io [u:I/y c+/ng
you: neIvo: LIe:neI c:/+en. Ingo vc: you I:oug c Ie n/IIy-g:/IIy :Iep: o
ov Io geI you: LIe:neI-Lc:ec ce+/ce vo:/ng v/I :ec-I/e ccpcL//I/e:.
hove lo wrile vorious librories like l did lor
lhe old porollelbosed inlerloce.
Bul belore gelling slorled on lhis pro|ecl,
l wonl lo loke o look ol one ol ils mo|or
lhol lhe dolo, once received, is nol cor
rupled by noise, orrives in order, ond
nolhing is missing or duplicoled.
A virluol circuil is kind ol like o phone
conneclion. Cnce lhe conneclion is mode,
il is moinloined unlil disconnecled.
lCP implemenls lhis relioble virluol
circuil by moinloining o slole on eoch end
ol lhe conneclion. lhere is slole inlormolion
lor eoch oclive [or connecled| porl. lhe
slolus inlormolion moinloins lhe conneclion
slole [i.e., whelher lhe circuil is being sel up or
lorn down ond whelher il is connecled|.
5equence poinlers ore kepl lo indicole
which byle ol lhe slreom hos been received,
ocknowledged, ond delivered lo lhe receiver.
lhe lronsmiller olso lrocks which byle il
senl, how much dolo is lell lo send, ond lhe
losl byle ocknowledged by lhe receiver.
Eoch lime one side ol lhe conneclion
hos dolo lo send [lCP is lullduplex, by lhe
woy|, il bundles up lhe dolo inlo o pockel
ond odds o lCP heoder lo lhe pockel.
lhe pockel heoder includes on endlo
end checksum lo moke sure lhol lhe lCP
pockel is received inlocl, o copy ol lhe
sequence poinler ol lhe senl dolo, ond o
copy ol lhe sequence number lor lhe dolo
il losl received, which serves os lhe ocknowl
edgmenl. lncluding lhe ocknowledgemenl
lor lhe dolo received, while lronsmilling
dolo in lhe olher direclion, is relerred lo os
piggybocking lhe ocknowledgmenl.
lhe heoder olso conloins lhe deslino
lion porl number lhis lCP pockel goes lo
ond lhe source porl number lrom which il
wos senl. Figure 2 shows how lhe vorious
sequence poinlers ore reloled.
Cnce lhe lCP heoder hos been odded,
lhe lCP pockel is possed lo lhe lnlernelwork
loyer. lhis loyer gels pockels lo ond lrom
olher hosls using lhe nelwork inlerloce.
lhis loyer odds on lP heoder lo lhe lCP
pockel. lhis heoder conloins lhe deslinolion
hosl oddress ond lhe source hosl oddress.
lhese oddresses olong wilh lhe porl numbers
lrom lhe lCP heoder lel us uniquely idenlily
which lCP conneclion lhis pockel belongs
lo os well os lhe direclion il needs lo go.
lhe lnlernel loyer needs lo send lhe
pockel oul over o nelwork using one ol lhe
one or more nelwork inlerloces. lnlernel
pockels con be up lo 8 KB long, bul mosl
nelwork inlerloces conl hondle pockels ol
lhol size. For exomple, on Elhernel inlerloce
con only hondle pockels 150 byles long.
lherelore, lhe lnlernel loyer ollen needs
lo lrogmenl lhe lP pockel inlo smoller
pockels. ll splils lhe pockel inlo smoller chunks
ond copies lhe lP heoder inlo eoch one.
A lield in lhe lP heoder lells ol whol
ollsel in lhe originol pockel lhe lrogmenl
pockel belongs. lhe receiving hosls lnlernel
loyer reossembles lhe lrogmenls inlo lhe
originol pockel belore possing il on lo lhe
receiving lronsporl loyer.
For lhe lnlernel lo work, we need lo be
oble lo connecl vorious nelworks logelher
vio speciol hosls lhol hove more lhon one
nelwork inlerloce. lhese hosls ore colled
roulers or lnlernel golewoys.
Cn o rouler, lhe lnlernelloyer imple
menlolion olso needs lo decide which
nelwork inlerloce o pockel needs lo be
senl on. A rouling loble does lhis |ob.
Fgoro 1
TCP osos o vor-
oIy o1 soqoonco
ponIors Io IrocR o
moc UoIo s sonI onU
ocRnooUgoU ooI o1 Io
B1-KB nUo. TCP osos o
sUng-nUo proIoco,
oro ooc soqoonco nomBor
UonI1os o sngo ByIo.
Recoll lhol lCP,lP implemen
lolions use lhe sockel APl lor
opplicolion progroms lo inler
loce lo lhe slock [see Melwork
Communicolion," I/K P|. ln o
nulshell, when lwo progroms
wonl lo esloblish o lCP,lP con
neclion, lhey sel up o sockel
which is idenlilied wilh on
lnlernel oddress ond o porl.
Cnce lhe conneclion is sel
up, lhe progroms wrile dolo lo lhe sockel
os il il were o lile, ond lhe dolo comes oul
lhe olher end ol lhe sockel, where lhe olher
progrom reods il like o lile. lhe prolocol slock
lreols lhe lCP,lP os on unslruclured byle
slreom, so ils eosy lo progrom lor lCP,lP.
Bul os you probobly know, lhe ocluol
nelwork inlerloce belween compulers usuolly
consisls ol o LAM or seriol inlerloce, wilh
dolo being lronslerred in pockels. Lels
look ol whol goes on in lhe lCP,lP slock lo
give us lhis illusion ol o conneclion.
lhe prolocol slock lor lCP,lP is illuslroled
in Figure 1. Al lhe lop, we hove lhe opplicolion
loyer, which is lollowed by lhe lronsporl ond
lnlernelwork loyers. lhe nelwork inlerloce
ond lhe nelwork ore ol lhe bollom.
lhe opplicolion progrom, in lhe opplico
lion loyer, is considered porl ol lhe prolocol
slock. lhe opplicolion usuolly implemenls
some kind ol prolocol on lop ol lhe unslruc
lured byleslreom provided by lCP,lP.
For exomple, lnlernel moil uses lhe
5imple Moil lronsporl Prolocol [5MlP| lo
exchonge Emoil messoges belween dil
lerenl hosls on lhe lnlernel. You moy olso
be lomilior wilh lhe Hyperlexl lronsporl
Prolocol [HllP| lhol Veb browsers ond
servers use lo communicole.
Mole lhol opplicolionloyer prolocols
ore implemenled in lhe opplicolion ond
lhol lhe inlerloce belween lhe opplicolion
loyer ond lhe lronsporl loyer is lhe sockel
APl. lhe resl ol lhe prolocol slocklhe
lronsporl loyer lhrough lhe nelwork inler
loceis usuolly implemenled in lhe C5
becouse ils implemenlolion is lhe some lor
ony opplicolion.
lhe lronsporl loyer implemenls lhe
byleslreom obslroclion ol lhe lronsmission
conlrol prolocol [lCP| over lhe pockel
swilched lnlernelwork prolocol [lP|.
lCP implemenls whol nelworking lolks
coll o relioble virluol circuil. ll is relioble
becouse lhe implemenlolion mokes sure
Write data Read data
ack last seq last ack read by app
TCP header
seq len
TCP packet
TCP header
System memory
Buffer chain
Bus mastering
Ethernet registers
Fgoro BBos-mosIorng IornoI conIroors
con OmA Io pocRoIs UrocIy 1rom sysIom
momory. To Uovco Urvor smpy soIs op o
OmA con Io Io Io conIroor oro Io 1nU
Io pocRoIs.
Mow were ol lhe business end ol lhe
prolocol slock, lhe nelwork inlerloce loyer,
which hos lhe device drivers lor lhe nelwork
devices. A nelwork device moy be on Elhernel
cord, o seriol porl, or wireless Elhernel inler
loce lhol connecls lhe hosl lo lhe nelwork.
Probobly lhe mosl common nelwork
device is lhe Elhernel inlerloce. lls versolile
LAM orchileclure con be connecled lo
lwisled poir, coox, or liberbosed medio.
An Elhernel cord usuolly hos some memory
in which lhe oulgoing Elhernel pockel is
conslrucled ond received. lhe ocluol lrons
milling ond receiving is done wilh hord
wore on lhe cord.
lhe nelwork inlerloce driver copies lhe
pockel il received lrom lhe lnlernel loyer
inlo lhe Elhernel cords memory, odds on
Elhernel heoder lo il, ond lells lhe cord lo
send lhe pockel. Vhen lhe cord lronsmils
lhe Elhernel pockel, il inlerrupls lhe nel
work inlerloce driver. Cl course, lhe cord
olso inlerrupls il o pockel wos received
lrom lhe Elhernel.
lhe nelwork inlerloce usuolly communi
coles wilh lhe nelwork driver queues. lhe
lronsmil ond receive queues decouple lhe
upper level nelwork code lrom lhe inlerrupl
service code lor lhe driver. ln o reollime
opplicolion, lhis losk is especiolly impor
lonl becouse we donl wonl lo spend o lol
ol lime in lhe inlerrupl service rouline.
lhe receive inlerrupl rouline simply
pulls lhe pockel lrom lhe Elhernel cords
memory, puls il in lhe receive queue, ond
signols lhe upper level code. lhe lronsmil
inlerrupl rouline checks lhe lronsmil queue.
ll il hos somelhing lo send, il pulls oll lhe
pockel lrom lhe queue, copies il lo lhe
cords memory, ond slorls lhe lronsmission.
Mewer cordsespeciolly PClbosed
cords lhol con do bus moslering ond occess
syslem memoryuse DMA lo send lhe
pockels direclly lrom syslem memory. For
lhese cords, lhe nelwork driver simply
moinloins o lisl ol buller poinlers lhol poinl
lo receive ond lronsmil buller memory.
lhese cords donl require lhe CP lo copy
lhe dolo oround during inlerrupl lime.
Figure 3 shows lhe bosic ideo.
Ve olso need lo discuss lronslerring
dolo vio lCP,lP. lhere ore lwo Elhernel
speeds, 10 ond 100 Mbps.
Mosl100Mbps cords oulomolicolly delecl
il lhe nelwork lheyre plugged inlo is 100
or 10 Mbps. Al 10 Mbps, Elhernel con lrons
ler olmosl 1 MBps ol dolo in one direclion.
However, you mosl likely wonl see lhol
high ol o lhroughpul. ln mony coses, il
lheres more lhon one hosl on lhe Elhernel,
lhere will be some overheod in lrying lo
occess lhe medio ond deol wilh conlenlion.
For Elhernel, lhis siluolion con be reolly
bod. lhe ulilizolion moy be os low os 30%
when Elhernel is soluroled wilh lens ol hosls.
lhol meons oll hosls logelher ore only
oble lo lronsler oboul 300 kbps on o
highly congesled 10MBps Elhernel. Cl
course, il only lwo hosls ore involved, we
should be oble lo ochieve olmosl lull
ulilizolion ol lhe Elhernel.
Anolher problem is lolency. lo send
dolo lo onolher hosl, lhe dolo hos lo
lroverse lhe prolocol slock, possibly gel
copied inlo lhe Elhernel cords memory,
be lronsmilled over lhe Elhernel, be re
ceived ond copied lorm lhe receiving
cord, ond possed bock up lhe prolocol
slock on lhe receiver ond lhen reverse lhis
lo gel on ocknowledgmenl bock.
Cn o lighlly looded 10MBps nelwork
wilh highperlormonce Elhernel cords, you
PoIo JTs s Io ogc ongno. IIs o
orgo ro-rop oroo I o Bonc
J1B BIs] o1 I/O rogsIors IoI con
Bo conIrooU vo o PC poroo
porI. IIs ossonIoy o
cp onU sysIom
mighl see lolencies down
lo 1.0 ms. However, il lhe
nelwork gels looded, lhe lolency
con eosily reoch 1020 ms or more.
Bosicolly, moke sure lhe Elhernel is
nol very looded il you expecl high ulilizo
lion or lhroughpul. Also, lhis meons lhere
ore upper bounds lo whol con be done
wilh Elhernel os o device bus.
Lels look ol lhe nuls ond bolls ol imple
menling o nelworkbosed logicengine de
vice. As l menlioned, l need lo build on
Elhernel device. ln lhis cose, il is on
inlerloce lo lhe logic engine, o prololype
developed by lhe Compuler 5cience De
porlmenl ol lndiono niversily.
lhe logic engine [see Pholo 1| is used
in on undergroduole digilol design lob
ond lor reseorch pro|ecls. ln bolh coses, il
serves os o sorl ol chip,syslem lesler.
Figure 4 gives on overview ol lhe syslem
we plon lo build.
lhe logic engine is on orroy ol 8bil l,C
regislers which ore reod ond wrillen by o
hosl vio o porollel porl inlerloce. Figure 5
illuslroles lhe logic engines bosic design.
lhe prolocol conlrolling lhe logic engine
is simple. An 8bil oddress is lolched by
lirsl wriling il lo lhe dolo porl ol lhe PC
porollel porl inlerloce ond lhen slrobing
lhe oddress slrobe, which is one ol lhe
conlrol signols on lhe porollel inlerloce.
Cnce lhe oddress hos been lolched, lhe
hosl reods ond wriles lhe regisler.
Vriling il is simplelhe hosl sels lhe
dolo in lhe dolo porl ol lhe porollel inler
loce ond slrobes lhe wrile slrobe. Reoding
is o lillle horder. lhe conlenl is reod by
selecling lhe nibble [upper,lower| ol lhe
l,C regisler ond reoding lhe slolus porl ol
lhe porollel porl. ll lokes lwo lronsoclions
lo reod lhe porl in lhe inlerloce.
Mow you hove on ideo ol how lhe logic
engine inlerloce works, so lels go lo work.
As o minimum, you need o CP boord
wilh o PC porollel porl inlerloce. You olso
need on Elhernel inlerloce ond enough
memory lo hold lhe syslem sollwore.
For lhe prololype, l chose Versologics
V5BC1 molherboord ond lheir PCM30
ME2000compolible Elhernel module.
Vhile ils overkill lor lhis opplicolion, l hod
one on hond. sing o PCcompolible single
boord syslem wilh inlegroled Elhernel,
such os Versologics PCM48P0, would
be more economicol.
Mexl, l selecled on RlC5. My biggesl
concern wos lhol il hos o lCP,lP prolocol
slock ond supporls lhe Elhernel cord.
l chose on ME2000compolible Elhernel
cord, which is lhe mosl common. Meorly oll
lCP,lP implemenlolions hove o driver lor
il. Evenluolly l wonl lo RCM lhis opplico
lion, so o RCMoble RlC5 would be good.
For lhe prololype, l chose CM/, moslly
becouse l con develop lhe code on lhe
syslem while prololyping by booling lhe
C5 lrom lhe nelwork or hord disk. Cnce
ils done ond l donl need lhe developmenl
syslem componenls, l con |usl RCM lhe
essenliol modules needed lrom lhe C5.
Anolher C5 lo consider is RlLinux,
which is o lreely ovoiloble nixlike Linux
C5 wilh o reollime exlension. lhis olso lels me
develop sollwore online ond lhen embed il.
Allhough RlLinux is nol os eosy lo RCM
os CM/, il is possible. l con olso bool Rl
Linux over lhe nelwork.
l olso need lo lolk
oboul lhe opplicolion
loyer prolocol l imple
menled lor lhis pro|ecl.
Recoll lhol lhe opplico
lionloyer prolocol uses
lhe sockel APl lo communicole wilh lhe remole
syslemhere, lhe logic engine inlerloce.
lhe prolocol lor lhe logic engine is simple.
lhe commond is ol lhe lorm.
where <cmc> con be lor reod, w lor
wrile, or q lor quil. <ol> ond <wcala>
ore lwodigil hex numbers. Even lhough
only lhe w commond needs dolo, olwoys
send o dolo byle olong. For lhe ond q
commonds, lhe dolo hos no meoning. ll
|usl mokes eoch commond lhe some lenglh,
which mokes buller monogemenl eosier.
For every commond received, lhe logic
engine inlerloce sends bock o byle ogoin
in o lwodigil hexodecimol encoding. ll lhe
commond is o reod, ils lhe volue ol lhe
regisler oddressed. 5o, lhe response is.
Lisling 1 shows oll ol lhe opplicolion
specilic code lor lhis pro|ecl. lhe progrom
slorls oll by selling up o server porl. Vhen
o conneclion lrom o clienl comes in, you
spown o process lo hondle lhe conneclion
ond il sils in o loop woiling lor commonds.
For eoch ond w commond, you perlorm
lhe lronsoclion on lhe porollel porl ond
relurn o byle. ll lhe conneclion is broken or
q is received, lhe process lerminoles.
Vhol oboul lhe clienl side Here, l use
o losk conlrol longuoge [lCL| progrom lo
lesl lhe inlerloce. You con lind lree lCL
Fgoro #Ts s Io sysIom Uogrom o1 my
IornoI Uovco. By poIIng Uovcos on Io
IornoI, I moRo Uovcos moro porIoBo onU
System under test
Parallel I/F
Parallel I/F
TCL script
Windows or Linux Workstation
Parallel port
Nibble select
Address register
Data strobe
Write Data bus
Read Data bus
under test
(big wire-
wrap area)
Fgoro Yoo con InR
o1 Io ogc ongno os o
Bg orroy o1 B-BI rogs-
Iors IoI con Bo rIIon
onU rooU vo o PC poro-
o porI. II sorvos os o IosI
BoU 1or UgIo crcoIs oI
InUono OnvorsIy.
=`rc!uc- <,wa`l.r>
=`rc!uc- <r-l`r-l`r.r>
=`rc!uc- <lc`o.r>
=`rc!uc- <am`o.r>
=c-1`r- |Ll| X/8
=c-1`r- |S|l| X/
=c-1`r- || X/a
=c-1`r- N,ol 431
`rl ,r:
lucl ocacc_`r `r:
`rl !-r:
-laL!`r commarc ol u`r |1
= oc-l'l!_1h!|, Sl_S|!lN, :
`r.`r_acc._acc = rlor!':
`r.`r_ol = rlor'N,ol:
L`rc','lucl ocacc `r,`z-o1'`r:
!-r = `z-o1'`r: wa`l 1o corr-cl`or
r = acc-l','lucl ocacc `r,!-r:
`1'r <
`1'!1o'| awr o11 oc- lo c-a! w`lr corr-cl`or
c!o-'r: c!o- o11 oc-l `r a-rl
=c-1`r- NL!h o
`rl 1c:|
cra Lu1|18:
`rl r,!:
cra -q:
`rl ol, cala:
wr`!- ' 1 |
! = :
wr`!- ' ! < NL!h |
r = -ac'1c,Lu1|!,'NL!h!:
`1'r < olo cor-_-:
! = r:
Lu1|NL!h = ```:
ca- `q`:
olo cor-_roma!:
ca- `w`:
ca- ``:
cala = !-_-ac'ol:
olo cor-_-:
IsIng JMoro s o Io oppcoIon-spoc1c coUo I nooU 1or Io IornoI Uovco. To rosI
o1 Io sysIom mpomonIs Io TCP/IP sIocR.
`rl :|
`rl X:
oulL',|Ll|: acc-
oulL'X1,||: acc- loL-
oulL'X,||: --l acc- loL-
oulL'X,||: -ac r`r r`LL!-
X = `rL'|S|l|>>4:
oulL'Xa,||: -ac loL- !ow- r`LL!-
X |= '`rL'|S|l| X1:
oulL'X,||: --l -ac loL-
`rl ,X:|
oulL',|Ll|: acc-
oulL'X1,||: acc- loL-
oulL'X,||: --l acc- loL-
oulL'X,|Ll|: cala
oulL'X4,||: w`l- loL-
oulL'X,||: --l w`l- loL-
IsIng JconInooU
IsIng 15nco Io Uovco s no occossBo vo TCP/IP, I con oso scrpIng ongoogos Ro
TCI Io conIro Io Uovco 1rom sovoro poI1orms. Ts progrom oso rons onUor nUos
or Ino IooI congos Io IosI Io ogc ongno nIor1oco.
= lal oc-l lo !o`c -r`r-
-l 1c |oc-l "lm" 431
= lur or l`lal- Lu11-
ul ror-w!`r- |1c "w11w111" : 1!ur |1c
ul |-ac |1c 4
= row !oo lrour a Lurcr o1 rumL-
1o |-l c | ||c < o0| |`rc c||
= w`l- lr- -qu-rc-
-l 4
wr`!- | | < 10 | |
ul ror-w!`r- |1c |1omal "wXX" | |c :
1!ur |1c: -ac |1c :
`rc :
= -ac arc coma-
-l 4
wr`!- || < 10||
ul ror-w!`r- |1c |1omal "X" | :
1!ur |1c
-l , |-ac |1c
-l X |1omal "X" |c
`1 ||, != |X||
ul "cala al | -ac |, co-r`l malcr w`ll-r |X ."
`rc :
ul ror-w!`r- "." : 1!ur lcoul
ul ""
= l, a!! cor-.
ul ror-w!`r- |1c "q" : 1!ur |1c
ul |-ac |1c
Ingo Cy/c c: Leen v:/I/ng o: lMK o:
Ivo yec:: on Iop/c: :uc c: eLeccec
:y:Ie:, IICA ce:/gn, cnc :oLoI/c:. Ie /:
c :e:ec:c eng/nee: cI De:/+cI/on oy:Ie:
Inc., c ocn D/egoLc:ec o:c :ynIe:/:
copcny, ve:e e vo:: on o:c-
eIoc ce:/gn Ioo: o: /g-c::u:cnce :y:-
Ie: cnc ce+eop: eLeccec-:y:Ie p:ocucI:.
eo:e [o/n/ng DoI, Ingo vo:ec o: o+e: 2
yec:: c: c :y:Ie cnc :e:ec:c eng/nee:
o: :e+e:c un/+e::/I/e: cnc c: cn /ncepen-
cenI con:uIcnI. You cy :ecc / cI
CPU module wilh inlegroled Elhernel, Elhernel
Versologic Corp.
[800| 824313
[541| 48585Z5
Fox. [541| 4855Z12
implemenlolions lor Vindows, nix, ond
Lisling 2 ollers o simple lesl progrom. ll
connecls lo lhe server ond lesls some ol lhe
logic engine porls. lhols oll lhere is lo il.
Vell, olmosl. lls CK lor o prololype,
bul lhere ore some lhings lhol need lo be
oddressed. As l hove menlioned, lhe pro
lolype is overkill lor lhis opplicolion.
You only need o lowend 38bosed
CP. Also, l hovenl RCMed lhe opplicolion.
5ome ol lhol depends on lhe RlC5 we use
os well os lhe porliculor CP module.
l olso hovenl oddressed how on Elher
nelbosed device linds oul ils lnlernel od
dress. My developmenl syslem bools lrom
disk, so ils eosy lo conligure lhe lnlernel
hosl oddress in one ol lhe slorlup scripls
vio lhe console l use lor developmenl. ln on
embedded Elhernel device, however, lhere
probobly isnl o console.
Bul donl despoir. lhere ore solulions.
Cne oplion. include o seriol porl on lhe
Elhernel device, which would run o smoll
commondlinebosed inlerloce lhol lels you
conligure lhings like lhe lnlernel hosl od
dress ond slore dolo in o llosh lile syslem.
Bul, lhis solulion mors lhe beouly ol hoving
on Elhernel deviceil would hove o con
sole ond seem more like o compuler.
A beller solulion is lo use one ol lhe
prolocols ovoiloble lor lhis purpose. lheres
lhe dynomic hosl conligurolion prolocol
[DHCP| ond lhe bool prolocol [BCClP|.
lhe ideo. you con use o Vindows or nix
mochine os on lnlernel hosl oddress cleor
Vhen lurned on, lhe Elhernel device
sends o DHCP or BCClP broodcosl over
lhe Elhernel. A workslolion conligured lo
be o DHCP or BCClP server lhen ossigns
on lnlernel oddress lo lhe Elhernel device
ond sends o response. lhe Elhernel device
uses lhis oddress unlil ils lurned oll.
PoIo 1To PCm-BBB s o compoIo BB
compoIor moUoo IoI ncoUos common PC/
AT Uovcos soc os 1oppy onU IO conIroors
onU soro onU poroo porIs. AUU on A1OOO
PC/JO# IornoI moUoo, soc os Io PCm-
BO, onU yooro n Bosnoss.
Allhough lhe logic engine inler
loce isnl o very generol exomple, il
shows you lhe essenliols lor building
on lnlernel device.
ll would be eosy lo reploce lhe logic
engine inlerloce wilh o PC,104 A,D
boord lhol plugs inlo lo lhe Elhernel de
vice, lhen chonge lhe code lo reod oul lhe
dolo lrom lhe A,D boord ond send il lo lhe
workslolion using o lCP,lP slreom. Voil,
on Elhernelbosed doloocquisilion device.
lm sure you con lhink ol olher opplicolions
os well.
Cne lhing lhol bolhers me is lhol ils slill
kind ol expensive lo implemenl lhis sorl ol
lhing. Al one end ol lhe speclrum, you con
lind reosonobly priced 38bosed PC,
104 cords lhol require on Elhernel module
lo be odded. Pholo 2 shows o PCM3335
module like lhis lrom Versologic. lhere
ore olso highend 48 ond Penliumbosed
super cords wilh inlegroled Elhernel ond
5VGA ond so lorlh, bul lhols overkill.
ll seems like lhere should be o nolrills
i38bosed PC,104 module wilh inle
groled ME2000compolible Elhernel con
lroller. Vell, lll keep looking. RPC.EPC
Applied PCs
Fred Eady
L+e: Ice on c conI:ccI, Ien :ec/ze /I: c :pec o+e: you: ecc+ I:ec, Ioo.
Iove+e:, DVI: KI ce+/ce: c:e ouI-o-Ie-Lo :ouI/on:. 7ey eI you ope:cIe cny
I:cn:/IIe:/:ece/+e: pc/:: [u:I /e cn LIe:neI neIvo:. /o neec Io Le cn KI gu:u.
Bock in lhe eorly 1PZ0s [belore some
ol you youngling engineers were born|, l hove
lond memories ol lroveling by cor lo lhe
FCC lield ollice in Allonlo, Georgio. Be
lieve il or nol, l used lo be on RF heod.
All lhose rood lrips werenl |usl lor lun.
l wos loking FCC licensing exoms. l cul my
leelh in prolessionol eleclronics by work
ing in rodio.
Yep, os you con lell lrom my wriling, l
did o lol ol lolking in my eorly yeors ol
broodcosling. l slorled oul by doing lhe
nighlly rock show ond lhe weekend grove
yord shills on lhe locol AM slolion.
l lried lelevision os o comeromon ond
even oudilioned ol V5MlV in Moshville,
lennessee. Good lhing l wos young, dumb,
ond ugly. Couldnl see mysell now doing
weekend weolher! However, l did monoge
lo lond o |ob ol lhe bigcily FM slolion
working lor Molionol Public Rodio.
By lhen l wos o newsmon, bul monoge
menl sow loo much ol me in lhe innords ol
lhe consoles. ll you couldnl lind me, |usl
coll lhe chiel engineer. l wos usuolly hong
ing oul wilh him ol lhe onlenno sile woy up
on lhe mounloin.
Vell, one lhing led lo onolher, ond l
linolly mode o lrip lo Allonlo lo lesl lor
whol wos lhen colled Firsl Closs Phone.
Cver lhe yeors, lhe Firsl Closs wos re
ploced wilh Generol. l slill hove lhol rog
honging in lhe Circuil Cellor Florido room.
Vilh oll lhol, youre probobly scrolch
ing your heod wondering why oll ol o
sudden you need lo know my lile slory.
Vell, my poinl. lheres o lol ol myslery in
RF producl design ond implemenlolion.
Cdds ore, il you donl do RF every doy,
you mosl likely conl do RF ol oll.
ll you lhink like l do, you see RF os o
bunch ol plumbing lied logelher wilh co
pocilors ond coils. Yel RF is very much in
our everydoy lives.
loke your goroge door opener, lor
inslonce. lls probobly nol inlrored con
lrolled. l bel ils RF. You conl use your lV
remole conlrol lo disoble your cor olorm.
lhols RF, loo.
l could go on ond on oboul whol is ond
whol isnl RF. lhe locl is lhol in lhe enduser
communily, RF lechnology is used os much
os microprocessor lechnology.
lo slir in o lillle mud, RF ond micros
moke o cule couple. 5o, il youre o micro
heod ond need lo develop on opplicolion
lhol ossumes you know RF, should you gel
in lhe cor ond heod lor Allonlo Mope.
)usl pick up lhe phone or gel on lhe Mel
ond conlocl DVP.
PoIo Jvon I cooU mpomonI Ioso IrcRy
IIo RF moUoos.
Radio Frequency and Micros
Part 1: Transmitter and Receiver Modules
NO-8kAlNEk kF
RF slull olwoys loscinoled me. Vhen
l wos o kid, l souped up my wolkie
lolkies by odding power sloges ond home
mode onlennoe. ll slill omozes me lhol elec
lronic componenls pumping eleclrons lhrough
lislless wire become somelhing uselul.
ln locl, l wos so enlhrolled wilh RF, every
yeor l purchosed o copy ol lhe Kcc/o
AcIeu:: IcncLoo. l even lried lo build
some ol lhe RF circuils shown in ils poges.
l hod lols ol lun wilh my lwowoy loys,
bul l wos unknowingly breoking every
FCC rule lhol opplied lo lhose lypes ol
devices. Mow lhol lm sorlo o responsible
odull ond o prolessionol, l conl ollord lo
breok lhe rules lo moke on RF opplicolion
lo odd poin lo my RF misery, l wrile
code. l donl design RF. Aboul lhe closesl
RF energy lhing l come inlo conlocl wilh is
microprocessor clock speeds.
lhere musl be o lol ol people like me oul
lhere becouse DVP developed o line ol
whol l coll nobroiner RF modules lhol lel
me opply my micro knowledge in lhe RF
goloxy. DVP ollers olllheshell, oulollhe
box, workrighlowoy RF solulions.
l hoppen lo hove o lew ol lheir lricky RF
modules in lhe I/K Florido room. 5o, lels
lolk oboul lhem belore we opply lhem.
lhese lronsmiller modules ore low
power ond ore designed lor unlicensed
wireless operolion conlorming lo FCC Porl
15 regulolions. lheyre commonly used in
cor olorms ond keyless enlry syslems.
Micro heods like us ore mosl likely lo use
lhese modules lor lelemelry ond dolo
colleclion opplicolions.
DVPs lronsmiller modules operole ol
live dillerenl lrequencies303, 315, 418,
433, ond P1 MHz. lronsmiller modules
ore designoled os l/yyyAl or l/yyyA5.
lhe yyy is lhe lrequency ond Al" denoles
lhroughhole. A5" represenls lhe surloce
mounl version.
lhe smoller module in Pholo 1 is o
l/418Al. As you con see, lhe lronsmiller
module is conloined wilhin o rugged RFl,
EMl shield. lhis puppy con go onywhere
our embedded engines con.
lhe nobroiner design eliminoles ony
luning ond requires no exlernol compo
nenls lo ellecl lhe RF lield. lhe only com
ponion componenls needed ore on on
Fgoro JIm proIIy
soro Ioros moro
Ion Iroo porIs n IoI
IIo Bo.
Fgoro 1To UocomonIoIon sIoIos IoI Io
BB-R rossIor oro s rooy o 1O R .. Any-
oy, noIo Io 5A oscoIor onU soporoI-
oroUyno 1ronI-onU.
SAW Osollator
For o culoll lrequency ol
1 kHz, o 0.001F copoci
lor is connecled ocross pin
lo ground. lhis olso es
loblishes o moximum dolo
role ol 5 kbps.
A second exlernol co
pocilor [C3| uses on inlernol
20k resislor ond 0.1F
cop lo lorm o lowposs liller lhol linds lhe
overoge volue ol lhe doloslreom. lhis sels
lhe signol slicing level ol lhe comporolor.
lhe ideo here is lo ovoid lenglhy pre
ombles. However, o preomble ol some
sorl is necessory lo ossure lhol lhe com
porolor lhreshold is sel obove lhe noise
level when lhe dolo is received.
lhis copocilor musl be sullicienlly lorge
lo prevenl lhe comporolor lhreshold lrom
lolling inlo lhe noise during deod periods
lenno, power, ond some sorl ol dolo
All ol lhe lronsmiller modules employ
100% onoll keyed [CCK| omplilude modulo
lion. Also, eoch lronsmiller module is 5AV
slobilized ond uses on inlernol hormonic
liller lo ensure complionce wilh spurious
emissions limils. Figure 1 shows you lhol
simple is os simple does.
lhe lronsmiller modules operole wilh
power sources os low os 2 VDC ond os high
os 12 VDC. Power consumplion ol 3 VDC
is oround 5 mA. Vhen used wilh o quor
lerwove onlenno ond lhe molching DVP
receiver module, lhis device con ochieve
lronsmission dislonces ol up lo 1000 wilh
o lronsmiller oulpul power ol 1 mV.
Molching receiver modules, like lhe lorger
module in Pholo 1, ore ovoiloble lor oll DVP
lronsmiller modules. Like lhe lronsmiller mod
ules, lhe receivers ore nobroiner componenls,
loo. lheyre designoled by on R/ prelix.
lhese lillle pockoges ore exlremely
sensilive [112 dbm| wilh good superhel
erodyne lronlend circuilry lhol provides
high seleclivily. lhis leolure is on obsolule
requiremenl il you plon lo use lhese mod
ules in heovy RFlrollic oreos.
nlike lhe lronsmiller modules, lhese
moy require o couple exlernol copocilors
in oddilion lo lhe power source ond on
lenno lo ellecl RF receplion. lhese odded
exlernol copocilors lel you lweok lhe sen
silivily ond lower lhe bil error role. You
selecl lhe volues ol lhese cops depending
on lhe dolo role, lronsmission lenglh, ond
deod period belween lronsmissions.
lhe dolorecovery circuilry converls o
voriobleomplilude onolog inpul signol lo
o lixedomplilude onolog signol. lhe om
plilude ol lhe incoming onolog signol
depends on lhe signol slrenglh.
Becouse lhe dolo received is digilol
ond lhus lime reloled, pulse widlh dislor
lion ond noise musl be minimized during
conversion. lhe copocilor connecling lo pin
[C| ol lhe receiver module sels lhe lowposs
liller culoll lrequency. Keeping lhe culoll
lrequency os low os possible wilhoul dis
lorling lhe dolo gives lhe besl sensilivily.
lhe receiver modules hove on inlernol
RC liller consisling ol o 10k resislor ond
100pF cop. lhe culoll lrequency is de
rived lrom.
Fgoro Bmy onIonno BoorUs UUnI como
I Io pono jocR. IooRs Ro Is nIonUoU
porposo os Io occopI gor voIogos.
PoIo 1
To cons o1
RF p-BoII.
wilhin lronsmission
pockels. ll lhe lronsmission
duly cycle is exoclly 50%,
lhen no cop is necessory ocross
pin 3.
lnlereslingly enough, no cop is
needed il lhe selecled culoll lrequency is
1 kHz. Al 1 kHz, lhe moximum dolo
role is 10 kbps. Clherwise, some experi
menlolion is necessory lo choose lhe cor
recl volue lor lhe slice cop depending on
lhe lormol ol lhe dolo youre receiving.
lhe dolobook menlions o volue ol 2.2 F
lor C3 ond 0.001 F lor C. A block
diogrom ol lhe receiver module is shown
in Figure 2.
For us embedded lypes, lhe reol work
is done by lhe progrom. ln RF, lhe reol work
is done by lhe onlenno. 5imply sloled, RF
perlormonce is direclly lied lo lhe proper
design ol lhe onlenno syslem.
lhings l used lo know oboul like goin,
polorizolion, impedonce molching, ond cov
eroge pollerns oll ploy o unique bul imporlonl
porl in onlenno design. Forlunolely lor you, l
wonl go inlo on onlennocrozed monologue.
Fgoro #AoIo Io crcoIry Io BoosI o coopo o1 BoIIoros Io 1OC. Aso noIco Io IronssIor
ovo s1Ior/Bo11or.
Bul, l do wonl lo poinl oul some onlenno
lidbils os lhey relole lo lhese DVP modules.
Firsl ol oll, lhe FCC ond Europeon
regulolions ploce no reslriclions on lhe
receiving onlenno in lowpower unlicensed
devices. However, lhe bod news is lhol lhe
lronsmilling onlenno musl be inlegrol or
inlernol, or il musl use o unique conneclor.
ln olher words, no BMC or RCA connec
lors lrom Rodio 5hock.
Rodioled power is lhe key here, so you
could pump o kilowoll inlo lhe onlenno os
long os lhe rodioled power is wilhin regu
lolory limils. lhis meons lhol you os lhe
designer connol use on onlenno lhol con
be ollered or reploced by lhe end user.
lhe dillering onlennoe moy [ond prob
obly will| exhibil dillerenl choroclerislics
lhol would oller hormonic ond spurious
emission levels.
lo help lhe inexperienced RF designer,
DVP supplies whol lhey coll Anlenno Boords
lo eose lhe poin. l hoppen lo hove o poir
ol 315MHz onlenno boords, ond lhey
oppeor in Pholo 2.
Anlenno boords ore reodyloroll,
molchedpoir lronsmiller ond receiver
modules wilh inlegrol loop onlennoe. All
lhols needed lo pul lhese lillle bobies inlo
operolion is o +5VDC power source ond
o dolo encoder or dolo inpul source.
lhese devices ore perlecl lor lhe em
bedded RF designer becouse llLcompol
ible dolo con be enlered inlo ond re
lrieved lrom lhe onlenno boords direclly.
lhere is no onboord encoder or decoder,
so lhe embedded designer musl code his
or her own dololronsmission scheme.
Figure 3 shows lhe innords ol lhe lrons
miller boord. Figure 4 blows up lhe sur
locemounl componenls lor lhe receiver
lhus lor, lve discussed lhe bosic build
ing blocks necessory lo gel lhe RFim
poired embedded design engineer inlo
lhe bounds ol RFville. For lhose ol you
needing lo lrovel inlo inlerslellor RFspoce,
DVP hos lhe vehicle lor you.
Pholo 3 shows you o molched sel ol
receiver ond lronsmiller evoluolion boords.
lhese boords diller lrom lhe onlenno
boords in lhol lhey ore complele oulollhe
box unils lhol include onboord hordwore
encoders ond decoders lrom Hollek.
As on occomplished embedded coder
or engineer, youre probobly giggling ol
lhe lhoughl ol using o hord
wore encoder or decoder.
As we oll know, you con
code lhol kind ol slull. l
ogree. Bul in lhis cose, ils
prelly neol whol lhese guys ond gols ol
Hollek ond DVP hove done.
lo eliminole reinvenlion ol lhe rolling
device, lhe Hollek encoder,decoder per
lorms neol lillle hordwore lricks. lnsleod ol
lhe rushedlorlime embedded engineer
wriling dolo lormol code ond preombles
ond worrying oboul liming, Hollek provides
|umperselecloble oddress logic coupled
wilh dolo enlry logic on one lC.
PoIo B
To BoIIoros
oro ncoUoU,
onU Ioro oro
ovon BnRng gIs
1or mo1 OonI ovorooR
Io oop onIonno oIcoU
onIo Io BoorU.
IX4J8AI, Anlenno 8oords
DVP, lnc.
[818| 541P020
Fox. [818| 541P423
I:ec Lccy c: o+e: 2U yec:: epe:/ence
c: c :y:Ie: eng/nee:. Ie c: vo:ec
v/I copuIe:: cnc coun/ccI/on :y:-
Ie: c:ge cnc :c, :/pe cnc co-
pe. I/: o:Ie /: eLeccec-:y:Ie: ce-
:/gn cnc coun/ccI/on:. I:ec cy Le
:eccec cI
Fgoro 5oro, yoo cooU rIo Io coUo, BoI n Is coso y? JosI pog n oI Io sIc ponIs.
swilches in Figure 5 wilh logic levels lrom
your embedded moslerpiece.
lhis lype ol oddressing ond dolo ossuronce
scheme mokes il possible lo operole mony
lronsmiller,receiver poirs like you do on
Elhernel nelwork. Ch yeoh, liming is o
simple moller ol plocing o resislor ocross
lhe encoder,decoder C5C pins.
Floobydusl wos o lerm coined by Molionol
5emiconduclor in ils Auc/o IcncLoo. ll
lhe lronsmiller evol
boord uses lhe Hollek
Hl014. lhe 014 encodes
12 bils ol inlo orgonized os 8 bils
ol oddress lollowed by 4 bils ol dolo.
For lhe blinkinglighls lypes, o lrons
mission in progress LED pin is olso pro
vided. lhe lour 014 dolo inpuls ore
oclive low, ond when ony inpul goes low,
dolo lronsmission slorls. ll gels beller.
lhe 8bil oddress ond 4bil dolo pockel
ore ossembled oulomolicolly ond senl lo
lhe inpul ol lhe l/ module on lhe evol
boord. lhis pollern is senl unlil lhere ore
no oclivelow signols on lhe dolo pins.
Mo preomble is needed. You donl hove lo
wrile one ond you donl hove lo send one.
lhe 014 sorlo lokes o preomble by hoving
lhe receiving decoder reod lhe dolo lwice
lor occurocy. Yep, you send double dolo,
bul ils dependoble ond, even beller, lhe
hordwore soves developmenl lime.
lhe receiving decoder reods lhe eighlbil
oddress lwice lo ensure ils picking up lhe
correcl dolo. ll lhe oddresses molch, lhen
lhe lour bils ol dolo ore decoded ond o
doloovoiloble pin is enobled. All you, lhe
embedded genius, musl do is reploce lhe
hos no reol meoning. ll merely colegorizes
elemenls lhol hove no colegory or lhol lil
mosl everywhere you wouldnl expecl lhem.
5o, wilh lhol, heres some RF lloobydusl.
Firsl, even lhough lhe DVP modules ore
unlicensed, you slill need FCC opprovol
lor your producl. lhe onlenno boords ore
designed lo be implonled inlo your pro|ecl,
ond DVP con ossisl you wilh gelling your
producl opproved.
5econd, l wosnl oble lo gel my pows
on o P1MHz rodio sel. lhe signiliconce
ol lhis is lhol, ol P00 MHz, lols ol lhings
con be done wilh lhe moduloled inlormo
lion lhol conl be done below P00 MHz.
For inslonce, conlinuous lronsmission is
okoy ol P1 MHz in lhe .5., bul 433.P2 MHz
isnl. However, Europeon embedded lypes
con lronsmil lill lhe cows come home on
433 MHz. Hopelully, lll be oble lo show
you lhe P1MHz rodio sel nexl lime.
ll would be on in|uslice lo squeeze on
RF opp inlo lhe spoce lell, so nexl lime lll
hove some RF opps using lhe DVP producls
ond some wild embedded goodies.
ln lhe meonlime, gel yoursell o copy ol
lhe DVP dolobook ond lhe Hollek remole
conlrol dolobook. Mexl monlh, lune in os
l prove lhol il doesnl hove lo be compli
coled lo be embedded. APC.EPC
62 Issue 98 September 1998 Circuit Cellar INK

Robert Priestley
Start your engines!
Its time for a high-
tech car rally. This
computer figures out
your gas usage,
distance, speed,
RPMs, fuel, and
more. It even has an
alarm that lets you
know when your heavy
foot is tempting local
ori gi nal l y got
i nvol ved wi th thi s
project when some
fri ends asked me to bui l d
a devi ce for thei r ral l y car to hel p them
navi gate duri ng ral l y events.
They needed an accurate and rel i abl e
tri p meter because, amazi ngl y enough,
thei r 1966 Ford Fal con XP Ral l y car
di dnt have an accurate odometer or
speedo! They al so menti oned that
thei r fuel -tank gauge wasnt worki ng,
so I combi ned both of these requests
and ended up wi th a tri p computer
thats sui tabl e for al l ki nds of vehi cl es.
Sure, i t woul d have been si mpl er to
i nstal l an anal og tri p meter and fuel
gauge, but they fi gured that i nstal l i ng
somethi ng hi gh-tech i n thei r car was a
surefi re way to grab everyones atten-
ti on. I was certai nl y up to the task at
the ti me, and now that the project has
grown over the years, I want to gi ve
you a l ook at what I created.
The mai n features of the tri p com-
puter i ncl ude a custom-desi gned four-
col or membrane keypad (see Photo 1)
wi th acousti c feedback of each key
press and a speci al l y desi gned bl ack
anodi zed case, whi ch gi ves a ri gi d
constructi on that i s shock, dust, and
spl ash proof. The tri p-computer di -
mensi ons are 145 70 55 mm.
The computer i s programmed to
make vari ous cal cul ati ons:
di stancedi stance travel ed journey,
di stance remai ni ng journey, tri p meter,
and di stance to empty based on aver-
age fuel consumpti on
speedcurrent speed, average speed,
and peak speed
tachometerRPM and peak RPM
fuel fuel used journey, fuel remai ni ng
i n tank, l i ters per 100 km, ki l ometers
per l i ter, average l i ters per 100 km,
average ki l ometers per l i ter, l i ters
per hour (fl ow rate), total fuel cost,
and journey fuel cost
ti merjourney ti mer, ti me remai ni ng
to compl ete journey, ti me remai ni ng
at average speed to compl ete journey,
and tri p ti mer
Al l val ues can be di spl ayed i n metri c,
U.S., or Imperi al formats on the 24 2
backl i t LCD uni t.
The computer al so has a standi ng
di stance ti mer accurate to hundredths
of a second typi cal l y used for quarter-
mi l e spri nt ti mi ng, and an over-speed
al arm, whi ch hel ps you avoi d those
speedi ng fi nes.
The computer performs i ts cal cul a-
ti ons by measuri ng the fuel fl ow and
di stance travel ed and by counti ng the
engi ne revs.
Engi ne revs are sensed by ei ther
maki ng a connecti on to the engi ne
di stri butor (for carburetor engi nes) or
fuel i njector (for el ectroni cal l y fuel
i njected [EFI] engi nes).
Regardl ess of the functi on bei ng
di spl ayed, the computer conti nual l y
updates al l of these cal cul ati ons. To
show these functi ons, the computer i s
i ni ti al i zed at the start of each journey.
Pressi ng the Cl ear key zeros the di stance
counters, the amount of fuel used, the
i nternal ti mers, and the peak speed/
tachometer di spl ay.
Al l di stances are di spl ayed wi th a
resol uti on of 0.1 km (or mi l es), and
ti me cal cul ati ons are di spl ayed wi th a
resol uti on down to seconds. Fuel
cal cul ati ons are di spl ayed wi th a reso-
l uti on of 0.1 l (or gal l on).
The over-speed al arm i s an especi al l y
useful feature of the tri p computer.
Addi ng a Performance/Tri p
Moni tor to Your Car
Circuit Cellar INK

Issue 98 September 1998 63

When youre dri vi ng, the Speed Al arm
key can be pressed, whi ch causes the
current speed to be stored i n memory.
If you exceed thi s speed by 5 km/h
(mi l es), an al arm sounds and the com-
puter automati cal l y di spl ays your
current speed unti l you sl ow down.
Fuel fl ow can be measured wi th a
fl ow sensor for carburetor engi nes or
by measuri ng the i njector pul se of an
EFI engi ne.
EFI engi nes work on the pri nci pl e
that a pressuri zed fuel l i ne feeds the
fuel i njectors that are control l ed by a
computer. The fuel i njectors are el ectro-
mechani cal devi ces that del i ver preci se
amounts of fuel to the engi ne. By vary-
i ng the i njector-open ti me, the engi ne-
management computer can preci sel y
control the engi nes performance.
Wi th EFI engi nes and di esel s, a fl ow
sensor i s typi cal l y unsui tabl e. The
pressure of these fuel l i nes can exceed
the speci fi cati ons of the fl ow sensor,
and fuel i njector l i nes usual l y have a
return feed back to the tank.
Therefore, measuri ng the actual
fuel used by the engi ne requi res two
fl ow sensors (di fferenti al measurement)
to measure the fuel bei ng used. That
i s, you need one sensor to measure
fuel fl ow i nto the engi ne and other
sensors to measure the fuel returned
to the tank.
The pri nci pl e behi nd the fl ow sensors
used i s a coi l that gi ves out si ne-wave
si gnal s whi ch are i nduced by permanent
magnets. The sensor i s an i nducti ve
type wi th a range of 1.5200 l /h. The
frequency of the output si gnal i s pro-
porti onal to the measured vol ume.
The fl ow sensor produces 780 pul ses
per 0.1 l of gasol i ne or 1100 pul ses per
0.1 l of water. The sensor has a conti nu-
ous pressure of 10 bar
at 22C and a bursti ng
pressure of over 30 bar.
It has a measurement
accuracy of 3%. The
sensor i s made out of
Hostaform C, has a hi gh
resi stance to chemi cal s,
and wei ghs 25 g.
The V.1.1 fi rmware
i s used wi th one or two
fl ow sensors, whereas
the V.2.0 fi rmware i s
used for EFI engi nes
onl y. However, the
hardware i s the same.
Here, I want to focus
on the V.2.0 computer.
Many types of sen-
sors can measure the
speed of the vehi cl e by
detecti ng the rotati on of
a wheel . A proxi mi ty sensor or a Hal l -
effect devi ce are two exampl es.
Most modern vehi cl es al ready have
a sui tabl e pul se whi ch i s generated by
the speedo sensor. For opti mum per-
formance, the computer requi res 24
pul ses per wheel rotati on.
Before you can use i t, the tri p com-
puter needs to be cal i brated. To cal i -
brate the di stance, a known di stance
i s dri ven (usual l y 15 km [or mi l es])
and the computer counts the number
of pul ses that are produced by the
di stance (speedo) sensor. The com-
puter then cal cul ates how far the car
travel s for one pul se of the sensor.
The V1.1 fi rmware requi res a cal i -
brati on factor to be entered i nto the
computer for the fl ow sensor (suppl i ed
wi th the sensor). Thi s number repre-
sents the number of pul ses produced
per 0.1 l of fuel used.
The V2 fi rmware i s cal i brated by
measuri ng the total open i njector ti me
of a known quanti ty of fuel , such as a
ful l fuel tank. The computer then cal i -
brates i tsel f over the ti me i t takes to
use up a ful l tank.
The mi crocontrol l er has a speci al
ti mer i nput pi n that i s i deal for mea-
suri ng pul ses because i t can capture
the exact ti me at whi ch a transi ti on
occurred on i ts ti mer i nput pi n. Once
the open ti me of the i njector i s cal cu-
l ated, i t i s added to a total .
Every second, the amount of fuel
used i s cal cul ated based on the mea-
sured open-i njector ti me. Li sti ng 1
shows you a sampl e of the code requi red
to measure a pul se for the 68HC705C8.
A 5-ms i nternal ti mer i nterrupt
keeps track of the vari ous ti mers and
the keypad scanni ng routi ne. The
sampl e program i n Li sti ng 2 generates
200 ti mer i nterrupts a second and
i ncrements a ti mer counter i n 5-ms
i ncrements and a seconds counter.
The speed sensor generates a pul se
that tri ggers the external i nterrupt pi n
(EXT) on the control l er. When a nega-
ti ve edge i s detected, an i nterrupt i s
generated whi ch servi ces the di stance
subrouti ne. In addi ti on to the ti mer
routi ne, Li sti ng 2 demonstrates i ncre-
menti ng a si mpl e counter (at RAM
l ocati on $70) when the IRQ pi n i s
tri ggered.
These routi nes are avai l abl e for
downl oadi ng from the Oztechni cs
Web si te al ong wi th a si mpl e PC pro-
gram that si mul ates an i njector pul se
usi ng the paral l el port of a PC. You
can use thi s program to check the
tri p-computer operati on on the bench
before i nstal l ati on.
Oztechni cs 68HC05
devel opment system
provi des many features
essenti al for devel opi ng
appl i cati ons for the HC05
seri es of control l ers. The
devel opment system
software, user manual ,
and tri p-computer 68HC05
routi nes are avai l abl e vi a
Oztechni cs Web si te.
Photo 1A specially manufactured color membrane keypad gives the car
computer a professional look and feel.
Photo 2The two compact boards solder together with the LCD mounted on the back of the
processor board.
64 Issue 98 September 1998 Circuit Cellar INK

headl i ghts are on. A jumper on the

PCB sel ects the requi red opti on.
The matri x keypad al so connects
di rectl y to the control l er. The three
i nput si gnal s to the computer are
buffered by the emi tter-fol l ower stages
(TR1, TR2, TR3) and are then shaped
and i nverted by the Schmi tt tri gger
i nverters of IC3d, IC3e, and IC3f.
The di stance and fuel pul ses are
i nterfaced to the control l er vi a JK fl i p-
fl ops (IC2) to gi ve, i n effect, an extra
i nterrupt l i ne. Seri al data i s avai l abl e
at pi n 30 of the control l er for i nterfaci ng
to a PC vi a a l evel shi fter (the MAX232
i s i deal ).
The si mul ator, whi ch forms part of
the HC05 software package, can run
Li sti ngs 1 and 2 on a PC.
The heart of the ci rcui t shown i n
Photo 2 i s a Motorol a 68HC705C8.
Fi gure 1 shows you a schemati c.
The di spl ay i s operated di rectl y by
the control l er. You can connect the
di spl ay backl i ghti ng to ei ther the
i ncomi ng 12 V from the i gni ti on swi tch
(backl i ghti ng i s therefore on when the
i gni ti on i s on) or to the vehi cl es head-
l i ght swi tch. The l atter opti on means
that the backl i ghti ng i s on when the
Listing 1Two 8-bit registers make up the 16-bit input capture register, which latches the value of the free-
running counter after the corresponding input-capture edge detector senses a defined transition. The level
transition that triggers the counter transfer is defined by the corresponding input edge bit (IEDG) in the TCR.
Use the E key to toggle the timer input pin in the simulator.
| !U |1 |`me corlo! e`le
|S !U |1 |`me Slalu e`le
1lF !U |14 1rul calue e`le r`r
1l !U |1' 1rul calue e`le !ow
!L!1 !U |'1 lN: Sh 10L`l real`ve ede
!L! !U |' lN: NSh 10L`l real`ve ede
US!1 !U |01 lN: Sh 10L`l meaued u!e
US! !U |0 lN: NSh 10L`l meaued u!e
|10 Slal oam om |10 `r !N
S|l| Ll =1
S|l | !raL!e `rul calue `rleul
1 !raL!e `rleul
hl oo reeLo rolr`r
|1N!_1h| hS!| 1.|.S_!L! Lelem`re wr`cr ede caued 1rl
h!_!L! Ll |S |S mul Le acceed lo c!ea !a
Ll 1lF el NSh o l`me courle
S|l !L! Sloe NSh o l`me courle
Ll 1l el Sh o l`me
S|l !L!1 Sloe Sh o l`me
hS!| 1.| Sel `rul edeo`l`ve calue
|1 !rd l`me `rleul
S_!L! Ll |S |S mul Le acceed lo c!ea !a
L 1lF |em loe 1lF!eeze l`me
Ll 1l oad `rul calue e`le Sh
SUh !L!1 '|`me Sh u!e_U`dlr Sh
S|l US!1 Sloe Sh u!e
|l Nove 1lF `rlo accumu!alo
Sh !L! '|`me NSh u!e_U`dlr NSh
S|l US! Sloe NSh u!e
h 1.| Sel `rul edeheal`ve calue
|1 !rdo`rleul u!e meaue
!|_1h| h Lo rolr`r
|1 !rd eXlera! `rleul
!N veclo
|1!!8 |`me `rleul veclo
!Lh |1N!_1h|
|1!!l !Xlera! `rleul veclo
!Lh !|_1h|
|1!!! eel `rleul veclo
!Lh S|l|
Circuit Cellar INK

Issue 98 September 1998 65

Listing 2Two 8-bit registers make up the 16-bit output compare register (OCR), which indicates when a
period of time has elapsed. The OCR contents are compared with the contents of the free-running counter
continually, and if a match is found, the corresponding output compare flag bit is set in the timer status
register. The corresponding output level bit (OLVL) is also clocked to an output level register (TCMP pin).
The I key in the simulator toggles the External IRQ pin.
| !U |1 |`me corlo! e`le
|S !U |1 |`me lalu e`le
NF1 !U |10 ulul comae e`le r`r
N !U |1/ ulul comae e`le !ow
N !U |1!L! Na ol`or e`le
S!hLS !U |' humLe o e!aed ecord
N11_S! !U |'1 humLe o m`!!`ecord
!| !U |/ ourle o eXlera! 1
|10 Slal oam om |10 `r !N
S|l| Ll =1
S|l | !raL!e oulul comae e`le 1
Ll =|
S|l N !raL!e re lar or 1 `r
S!hLS eel ecord courle
N11_S! eel 1m courle
1 !raL!e `rleul
hl oo reeLo rolr`r
l 4NFz c,la! oduce `rlera! l`c. ' l`c = ' m
X ' m = 1 ecord courl. ' = |c4
|1N!_1 Ll |S !ea N !a L, acce`r |S
Ll N ard N e
lLL =|c4 owe ra! reX equ`va!erl o '
|l |em loe !owe ra! o rew N
Ll =| Ue ra! reX equ`va!erl o '
lL NF1
S|l NF1 Udale ue ra! o N e
S| N Udale !owe ra! o N e
1h N11_S! ldd 1 lo m`!!`ecord courle
Ll = ' m = 1
N N11_S! |el ` eacred ,el.
hh! |1N!1 harcr ` rol equa! lo 1
N11_S! !ea 'm courle
1h S!hLS 1rcemerl ecord courle
|1N!1 hS!| .|.|! |o!e N `r
hS!| .| Sel |N `r lo 1 or reXl comae
|1 !rdol`me `rleul
|! h .| Sel |N `r lo or reXl comae
|1 !rdol`me `rleul
!|_1 1h !| 1rcemerl lN
|1 !rdol`me `rleul
Le`re !N veclo
!Lh |1N!_1 Le`re l`me 1 veclo
!Lh !|_1 Le`re eXlera! 1 veclo
!Lh S|l| Le`re eel veclo
The Reset si gnal i s appl i ed to the
control l er vi a the +12-V suppl y from
the i gni ti on swi tch.
The pi ezo buzzer i s operated by the
osci l l ator around IC3a, whi ch i s pul sed
on by the Beep si gnal from the control -
l er. A regul ated 5-V suppl y i s provi ded
by IC4 and fi l tered by C3, C7, and C8.
Constructi ng the tri p computer i s
qui te si mpl e. The ci rcui try i s contai ned
on two smal l doubl e-si ded, pl ated-
through, component masked PCBs,
whi ch sol der together at ri ght angl es.
The LCD mounts on the back of the
processor PCB and i s hel d i n pl ace wi th
Circuit Cellar INK

Issue 98 September 1998 67

Figure 1The schematic for V.1.1 of the car computer is almost identical to V.2.0. The same PCB was used for both versions of firmware.
V1.1 Trip Computer (requires flow
sensor).................................. $110
V2.0 Trip Computer (EFI)....... $110
Flow Sensor................................ $75
Speed Sensor .............................. $25
Oztechni cs Pty. Ltd.
P.O. Box 38
Il l awong NSW 2234
Austral i a
+61-2-9541 0310
Fax: +61-2-9541 0734
Robert Priestley is an electronics
engineer specializing in embedded
systems for Oztechnics, a producer of
embedded system products and devel-
Compl ete source code for thi s ar-
ti cl e i s avai l abl e vi a the Ci rcui t
Cel l ar Web si te.
opment tools for Motorola 68HC05
and 68HC11 microcontrollers. You
may reach him at robert@oztechnics.
four metal thread screws and nuts. The
di spl ay i s about 3 mm from the PCB.
The membrane keypad fi xes to the
cl ear Perspex front panel of the case
usi ng i ts sel f-adhesi ve back, and i t
connects to the PCB vi a a speci al mem-
brane ZIF connector. The PCB assembl y
sl i des i nto the al umi num case, and
the front and rear panel s snap i nto pl ace.
Use PCB pi ns to connect the wi ri ng
harness to the computer. Heat-shri nk
sl eevi ng over each sol dered connecti on
i ncreases rel i abi l i ty.
Instal l ati on i s al so strai ghtforward.
You need to l ocate permanent 12 V,
i gni ti on 12 V, Ground, and an opti onal
headl i ght connecti on (for the backl i t
LCD). The back of the di gi tal cl ock i s
a good source for these si gnal s.
Once power i s establ i shed, run a
wi re to an i njector and connect the
computer to the swi tched (grounded)
si de of the i njector or i nstal l the fuel
fl ow sensor i n the fuel l i ne. Make a
connecti on to the el ectroni c speedo.
Youl l need 24 pul ses per wheel
revol uti on. If more are produced, ei ther
i nstal l a separate speedo sensor or di vi de
the pul ses down usi ng a di vi der chi p
You need a di gi tal pul se (05 V) to
run the computer i nputs. Inducti ve
pi ckups wont work because they need
to be ampl i fi ed and si gnal condi ti oned.
Of course, thi s system doesnt have
to be used as a tri p computer. Any
appl i cati on requi ri ng a counter or quan-
ti ty of l i qui d to be measured can be
accommodated by thi s ki nd of devi ce. I
68 Issue 98 September 1998 Circuit Cellar INK

Stuart Ball
Build a Serial
After Stuart
checks out
the hardware
setup for the low-cost
serial port programmer
he put together last
month, he gives us an
up-close look at how
the software and pro-
gramming algorithms
make everything tick.
From the Bench
Silicon Update
ast month, I
gave you a l ook at
the programmer hard-
ware, constructi on, and
operati on for bui l di ng a seri al port
PROM programmer. Now, l ets check
out the hardware and see how the
programmer works, how i t i nterfaces
to the programmi ng modul es, and how
the software handl es the tasks requi red.
My fi rst task i s to veri fy that al l
the programmer functi ons are work-
i ng. I start by appl yi ng power to the
programmer and checki ng the +24 and
+5 V to be sure theyre correct.
Pi n 2 of U10 (MAX232) shoul d be
8 to 10 V, and pi n 6 of U10 (MAX232)
shoul d be 8 to 10 V. I then veri fy that
the bi col or LED i s green.
Next, I connect the programmer to
the PC and start the communi cati on
program on the PC. (For a descri pti on
of setti ng up the communi cati on pro-
gram, see the secti on on Usi ng the
Programmer i n Part 1.) I then i nstal l
the 27xx EPROM programmi ng modul e.
When I cycl e power on the program-
mer, the command menu shoul d come
up on the PC screen. I sel ect a 2764
by enteri ng =| 1 and turn on the V
and V
vol tages by enteri ng =\.
The LEDs on the programmi ng mod-
ul e shoul d be on. The vol tage at pi n 1
of the ZIF socket shoul d be ~12.5 V,
and the vol tage at pi n 28 of the ZIF
socket shoul d be about 6 V.
Two Adapter Modul es
Circuit Cellar INK

Issue 98 September 1998 69

I turn off the programmi ng vol tages
by enteri ng =. My next task i s to
program an EPROM to make sure the
programmer works correctl y.
The 80C188 i s somewhat pi cky
about crystal s. Wi th some crystal s,
Ive found that the osci l l ator doesnt
al ways start. If you turn on the program-
mer and someti mes the LED stays off
and the startup menu i snt sent, the
osci l l ator may not be starti ng.
To fi x thi s probl em, l ower the val ues
of capaci tors C3 and C4. Some crystal s
start best wi th C3 and C4 removed.
Or, try i nstal l i ng a 1-M resi stor i n
paral l el wi th the crystal . As a l ast
resort, try a di fferent brand of crystal .
The programmer supports i ntel l i gent
programmi ng al gori thms. In the earl y
days, when a 2K 8 2716 was a l arge
EPROM, programmi ng took a constant
50 ms per l ocati on.
When there are 2048 l ocati ons,
programmi ng thi s way takes onl y
100 s. But when there are 32,768 l oca-
ti ons, programmi ng by thi s method
takes 30 mi n.
To reduce thi s programmi ng ti me,
the PROM manufacturers devel oped
adapti ve al gori thms. Fi rst, appl y pro-
grammi ng si gnal s to the devi ce for a
speci fi ed ti me (1 ms, 0.1 ms, etc.) and
read the devi ce to see i f data i s correct.
Repeat these two steps unti l the data
i s correct. Once the data veri fi es, appl y
an overprogram pul se (typi cal l y 2).
Consi der an exampl e where an
EPROM uses a pul se wi dth of 1 ms and
a 2 overprogram pul se. In a typi cal
programmi ng sequence, you mi ght
fi rst attempt to program four ti mes,
and the devi ce programs on the fourth
attempt. Then, you appl y an over-
program pul se of 8 ms (2 4 1 ms).
The total program-
mi ng ti me for thi s l oca-
ti on i n the devi ce i s the
ori gi nal 4-ms pl us the
8-ms overprogram pul se ti me, for a
total of 12 ms.
These al gori thms al so provi de for a
maxi mum number of retri es before
the l ocati on i s consi dered bad. If thi s
hypotheti cal EPROM al l ows up to 20
retri es, then programmi ng one l ocati on
can take anywhere from 3 to 60 ms.
Of course, most l ocati ons i n most
EPROMs take l ess than the maxi mum.
Di fferent manufacturers use di fferent
vol tages and program pul se wi dths.
The 27xx devi ces can be broken down
i nto broad categori es12-V program-
mi ng vol tage versus 21-V, and 1-ms
program pul se wi dth versus 0.1-ms.
The programmer si mpl i fi es thi ngs
by usi ng essenti al l y the same al gori thm
for al l devi ces. So, there are just a few
generi c devi ces to sel ect:
2764, 12 V, 1 ms
2764, 12 V, 0.1 ms
2764, 21 V, 1 ms
There are si mi l ar generi c sel ecti ons for
the 27128 and 27256. A commerci al
programmer may have a dozen di fferent
(but very si mi l ar) al gori thms for
programmi ng PROMs from di fferent
As I menti oned i n Part 1, the
programmer saves cost by usi ng
adapter modul es for di fferent de-
vi ces. There i s one modul e for 27xx
EPROMs and one for PIC devi ces.
Each modul e connects the program-
mi ng si gnal s from the 50-pi n connector
to the ZIF socket hol di ng the devi ce to
be programmed. Tabl e 1 defi nes the
si gnal s for the two modul es.
To program a l ocati on i n an EPROM,
the V
and V
pi ns are rai sed to the
val ues needed for programmi ng
typi cal l y around 6 V and 12.75 V,
respecti vel y. The V
vol tage for pro-
grammi ng i s usual l y hi gher than for
normal operati on.
Fi gure 1 shows the ti mi ng to program
and veri fy a l ocati on i n a 2764/27128
and a 27256. For the 2764/27128, after
the vol tages are stabl e, the address i s
pl aced on the address pi ns, and the
data i s pl aced on the data pi ns. In the
programmer, thi s amounts to wri ti ng
the address and data val ues to the
appropri ate 82C55 ports.
The *CE and *PGM si gnal s are then
dri ven l ow. Thi s condi ti on i s mai ntai ned
for 1 ms, or 100 s, dependi ng on the
al gori thm youre usi ng. Then, the *PGM
and *CE pi ns are dri ven hi gh.
To veri fy the l ocati on just pro-
grammed, the data port of the 82C55
(port C) i s swi tched to i nput mode.
The *CE and *OE pi ns are dri ven l ow,
whi l e the *PGM pi n i s l eft hi gh.
The EPROM reads the sel ected
l ocati on and pl aces the data on the
data l i nes, where the programmer
reads i t by readi ng the 82C55 port. If
the data does not veri fy, the programmer
must program and veri fy the l ocati on
agai n.
The ti mi ng for the 27256 EPROM
i s i denti cal to the 2764/27128, except
Table 1This table maps out the
8255 and control register bits on
the two programming modules. The
PIC module only needs two bits
from the 8255 and does not use
the control register at all.
Signal Usage
EPROM module
A0A14 (82C55 ports A and B) A0A14 (A14 is *PGM
on 2764 and 27218)
D0D7 (82C55 port C) D0D14
*OE (control register bit 2) *OE
*CE (control register bit 3) *CE
Control register bits 4-7 Unused
PIC module
A0 (82C55 port A, bit 0) Clock (RB6)
D0 (82C55 Port C, bit 0) Bidirectional Data (RB7)
2764-27128 Program Timing
Write Read
27256 Program Timing
Write Read
Figure 1In programming the 2764/27128 and
27256 EPROMs, the timing is identical, except for
the *PGM signal, which is address input A14 on the
70 Issue 98 September 1998 Circuit Cellar INK

3. Send h-`r oamm`r

4. Wai t 100 s
5. Send !rc oamm`r
6. Send -ac Lala
7. Check the returned data agai nst the
ori gi nal programmi ng data
Repeat steps 27 unti l the data veri fi es.
Li ke the 27xx EPROM devi ces, the
PIC EPROM devi ces need an over-
program pul se after the data veri fi es.
After the overprogram pul se, the address
i s i ncremented usi ng 1rc-m-rl
lcc- and the next l ocati on i s
The PIC devi ces dont have a way
to randoml y sel ect a speci fi c address,
other than to reset the i nternal address
poi nter to zero. So, these devi ces must
be programmed sequenti al l y from l oca-
ti on 0 to the top of program memory.
Because each PIC l ocati on i s 14 bi ts
wi de, two bytes i n the buffer are re-
qui red to hol d each l ocati on. A PIC
program that i s 1 K words l ong takes
2-KB l ocati ons i n the buffer. The pro-
grammer expects data to be l oaded
l east si gni fi cant bi t fi rst, whi ch i s the
sequence generated by the Mi crochi p
assembl er.
The PIC devi ces have an addi ti onal
feature that the EPROMs do not have
confi gurati on memory. The confi gura-
ti on memory programs the type of
osci l l ator that the PIC expects to use,
the power-up reset characteri sti cs, and
other features. The programmer wi l l
program the confi gurati on l ocati ons.
After the enti re PIC
program memory i s veri -
fi ed, the programmer
programs the val ue i n
buffer l ocati ons 400E and
400F to the confi gurati on
l ocati on (2007) i n the PIC
devi ce.
Agai n, the address i n
the buffer i s 2 the devi ce
address because the devi ce counts
words and the programmer buffer
counts bytes. Li ke normal program
data, the programmer expects the
l east si gni fi cant bi t of the confi gura-
ti on word to be fi rst (i n 400E).
To get the confi gurati on memory
programmed, you must i ncl ude the
confi gurati on i nformati on i n the hex
fi l e. The Mi crochi p assembl er provi des
for thi s wi th the .h!1 di recti ve.
If youre usi ng an assembl er that
doesnt support the confi gurati on
memory, you can manual l y bui l d a
hex fi l e that contai ns your confi gura-
ti on data and send i t to the program-
mer pri or to programmi ng the devi ce.
The PIC devi ces al so provi de l oca-
ti ons that can be defi ned by the user
for tasks l i ke addi ng a seri al number to
each devi ce. The programmer doesnt
support thi s (al though the necessary
code changes woul d be fai rl y mi ni mal ).
The PIC16C84 i s an EEPROM
devi ce that i s si mi l ar to other 18-pi n
PIC devi ces and that uses a si mi l ar
command set. The pri mary di fference
i n how the 16C84 i s handl ed by the
programmer i s that the 16C84 per-
forms an i nternal erase of the EEPROM
l ocati on pri or to programmi ng, so no
bl ank check i s needed.
The 16C84 i nternal l y ti mes the
program cycl e, so onl y one programmi ng
pul se i s requi red, and no overprogram
pul se i s needed. Each l ocati on i n the
16C84 takes a l i ttl e over 10 ms to
that there i s no *PGM
si gnal . On the 27256,
the pi n that had the
*PGM si gnal on i t car-
ri es address bi t A14.
The EPROM pro-
grams when *CE i s l ow
and reads when *CE and
*OE are both l ow. To
read a l ocati on, *OE
must be dri ven l ow fi rst so the EPROM
doesnt see the *CE-onl y condi ti on
and try to program the l ocati on wi th
the data l i nes fl oati ng.
The PIC devi ces use a di fferent
method of programmi ng, whi ch uses
onl y fi ve pi nsPower, Ground, MCLR
(whi ch recei ves the V
vol tage), RB6,
and RB7. The PIC devi ces use a seri al
scheme where a si x-bi t command i s
cl ocked i nto the devi ce. Some com-
mands are fol l owed by 14 bi ts of data.
Fi gure 2 shows the scheme for
sendi ng data to a PIC devi ce. Pi n RB6
functi ons as a cl ock, and pi n RB7
serves as a bi di recti onal data pi n.
The EPROM devi ces support si x
commands (l i sted i n Tabl e 2). The
16C84, an EEPROM devi ce, has addi -
ti onal commands for bul k erasure and
programmi ng the user memory, but
these are not used by the programmer.
The oac or1`ual`or and
oac Lala commands are fol l owed
by data, and -ac Lala i s fol l owed
by data read from the devi ce. The data
i s 14 bi ts, but 16 bi ts are cl ocked i n
and out of the devi ce, si nce the data i s
preceded and fol l owed by a zero bi t.
The programmi ng sequence for the
PIC devi ces goes l i ke thi s:
1. Set V
(MCLR) and V
2. Send oac Lala, fol l owed by the
data to be programmed
Command Code
Load Configuration 000000
Load Data 000010
Read Data 000100
Increment Address 000110
Begin Programming 001000
End Programming 001110
Table 2These PIC programming commands are
loaded serially using two pins on the PIC device.
Figure 2The PIC devices are programmed and verified with commands that are transmitted
serially. Each command is six bits long, and some commands are followed by 14 bits of data.
PIC Command Timing
PIC Data Timing
D0 D1 D2 D3 D4 D5
D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 0 0
Pin Number Pin Number
18-pin devices 28-pin devices Name Function
13 28 RB7 Serial data I/O
12 27 RB6 Serial clock
4 1 MCLR V
(prog. voltage)
5 8, 19 V
14 20 V
+5 V
Table 3With the PIC
programming connector, the
18- and 28-pin devices are
programmed the same way
but use different pins. The
12-pin header on the module
selects the type of device.
72 Issue 98 September 1998 Circuit Cellar INK

Figure 4The 50-pin connector mounts on the

back of the PIC programming module and the
mating connector on the programmer.
As I menti oned l ast month, the
PIC modul e has a 12 2 pi n header
that connects the programmi ng si gnal s
to the proper pi ns for 18- or 28-pi n
devi ces. A socket i s i nstal l ed on the
header, on one si de or the other, to
make the connecti ons. The PCB set
i ncl udes a smal l ci rcui t board for thi s
If you deci de not to use the PCB to
wi re the ci rcui t, you need to wi re a
socket header for thi s purpose. The
header i s wi red as fol l ows:
1 to 6
2 to 8
3 to 9
4 to 10
5 to 11 and 12
Pi n 7 i s a key to prevent reversal of
the socket on the header. To prevent
vol tage from bei ng appl i ed to the wrong
pi ns, the software checks to be sure
the socket i s i nstal l ed i n the correct
posi ti on on the header before program-
mi ng. Tabl e 3 shows whi ch pi ns serve
whi ch functi ons on the PIC devi ces.
Fi gure 3 shows the schemati c of
the EPROM modul e, and Fi gure 4
shows the schemati c of the PIC modul e.
The programmer accepts
two formatsIntel hex and
raw hex. The Intel hex format
consi sts of a l i ne l i ke:
where i s a data byte count
(the number of bytes i n the
l i ne), ==== i s a 16 bi t address
(the l ocati on i n memory where
the fi rst data byte goes), JJ i s a
record type, @@U@@ i s the data
i n hex, and ?? i s a one-byte
The programmer can accept
raw hex fi l es, whi ch consi st of
two ASCII-hex characters for
each byte to be downl oaded.
The programmer al ways pl aces
raw hex data at l ocati on 0000
i n memory, unl ess =N i s used
to force a di fferent offset.
The programmer accepts
raw hex data wi th or wi thout
spaces or commas for del i mi ters. There-
fore, these three l i nes are the same to
the programmer:
ll oo 1 34 o0 /8
The programmer al so i gnores car-
ri age returns and l i nefeeds, so the data
can be formatted for better readabi l -
i ty. In short, al most any combi -
nati on of raw ASCII-hex data i s
accepted i n thi s format.
The one drawback to the raw
hex format i s the l ack of an end-
of-fi l e i ndi cator. The Intel format
has an EOF record type to i ndi -
cate when al l the data has been
transferred, but there i s no such
uni versal i ndi cator for the raw
hex fi l es.
Some conversi on programs gener-
ate an !| at the end of a raw hex fi l e,
and the programmer can recogni ze thi s.
In other cases, you have to termi nate
a raw hex downl oad when the computer
has sent al l the data by enteri ng the
= command.
The programmer software can be
broken down i nto fi ve general compo-
nents. Fi rst, the i ni ti al i zati on code
sets up the peri pheral components,
the 80C188 i nternal chi p sel ects, and
the data transfer rate.
Next, an i nterrupt servi ce routi ne
(ISR) handl es UART I/O. Output data
i s buffered i n a software FIFO and
transmi tted a byte at a ti me as the
UART transmi tter becomes avai l abl e.
Si mi l arl y, i nput data i s read and buff-
ered i n a software FIFO for processi ng
by non-ISR code.
A background l oop performs one
devi ce operati on (e.g., program, veri fy,
bl ank check a byte) per pass. The back-
ground l oop al so checks for and pro-
cesses data recei ved from the PC.
Devi ce support routi nes handl e
devi ce operati ons (e.g., bl ank check,
veri fy, program, setup) as wel l as
generi c operati ons l i ke setti ng and
cl eari ng the control bi ts, wri ti ng a
new address to the devi ce, and so
forth. Fi nal l y, devi ce-speci fi c routi nes
perform the program, bl ank check,
and veri fy operati ons.
Figure 3The 50-pin connector mounts on the back of the
EPROM programming module and plugs into the mating connec-
tor on the programmer.
Circuit Cellar INK

Issue 98 September 1998 73

Each devi ce i s descri bed i n a 16-word
tabl e. The tabl e contai ns i nformati on
l i ke the devi ce si ze and word wi dth, a
bl ank val ue, the devi ce-speci fi c routi nes
to use, the DAC val ues to set correct
vol tages, and whether to perform
bl ank check pri or to programmi ng.
The software can support both 8- and
16-bi t wi de devi ces. The 27xx EPROMs,
for exampl e, are al l 8 bi ts wi de. The
PIC processors are 16 (real l y 14) bi t
devi ces. (The PIC i tsel f i s an 8-bi t
processor, but the programmer i s
concerned wi th i nstructi ons that go
i nto the PROM, whi ch are 14 bi ts wi de).
Fi gure 5 shows the hi erarchy of the
mai n programmer routi nes. When I
deci ded to turn thi s project i nto an
arti cl e, I needed to break the software
up i n such a way that readers coul d
assembl e i t wi th whatever assembl er
they have. Not al l assembl ers support
modul ar assembl y, and I di dnt want to
ti e the source code to just one assembl er.
As a resul t, the software source
code i s broken i nto text fi l es that are
assembl ed i nto one l arge source fi l e by
runni ng a batch fi l e (whi ch i s cal l ed,
appropri atel y, 1|). Wi th mi nor
modi fi cati ons, thi s source fi l e shoul d
be compati bl e wi th just about any
assembl er.
The onl y catch i s that the constants
and vari abl es are defi ned i n separate
fi l es (due to a l i mi tati on i n my assem-
bl er). If you need to have them i ncl uded
i n the source fi l e, youl l have to make
some edi ts so they match your assem-
bl er format.
If your assembl er supports modul ar
assembl y, you can modi fy the text
fi l es wi th the appropri ate header i nfor-
mati on for your assembl er and make
each text fi l e a separate modul e.
The programmer i s desi gned for
expansi on to i ncl ude new devi ce types.
To do thi s, you have to desi gn and
bui l d a new adapter modul e and wri te
devi ce-speci fi c routi nes for the new
devi ce.
You then i ncl ude the new devi ce i n
the devi ce tabl es, i ncl ude i t i n the
vector tabl es for setup, program, bl ank
check, and veri fy, and i ncl ude i t i n
the message thats pri nted wi th the
= command. More detai l ed i nstruc-
ti ons are i ncl uded i n a text fi l e wi th
the source code.
The programmer i ncl udes a few
features to si mpl i fy devel opment of
new modul es. Youl l remember that
l ast month I menti oned the =h and
Support Functions
Device Parameter request
Set LED red/green
SeND MeSsaGe
ASCii to HEX
HEX to ASCii
Set/Clr control register bits
Compl ete source code for thi s
arti cl e i s avai l abl e vi a the Ci rcui t
Cel l ar Web si te.
Stuart Ball works at Organon Teknika,
a manufacturer of medical instruments.
He has been a design engineer for 18
years, working on projects as diverse
as GPS and single-chip microcontroller
designs. He has written two books on
embedded-system design, both avail-
able from Butterworth-Heinemann
( You may reach Stuart
=N commands. =h l ets you l ook at
any 64-byte area of the 64-KB buffer,
and =N l ets you l ook at any 64-byte
area of the program RAM, so you can
l ook at the vari abl es and software FIFOs.
One speci fi c software areaa rotat-
i ng trace bufferdeserves speci al
menti on. Located from 1600 to 16FF,
the buffer can gi ve you a sequenti al
hi story of what the software was doi ng.
You can wri te one-byte val ues to
the buffer by cal l i ng a subrouti ne
named L1lhS|1. Your trace val ue
i s stored i n the next buffer l ocati on,
fol l owed by a byte of FF.
You coul d al so devel op a Wi ndows-
based GUI to control the programmer.
Thi s type of approach coul d probabl y
l et you sel ect devi ces by name, el i mi -
nati ng the = command, as wel l as
doi ng addi ti onal error checki ng (e.g.,
preventi ng you from speci fyi ng an
operati on si ze that i s bi gger than the
devi ce).
The programmer was i ntended to
accommodate such expansi ons, and
the onl y modi fi cati ons youd need to
make to the programmer code woul d
be to repl ace the return messages wi th
numeri c codes.
For thi s project, I needed 27xx
EPROMs and PIC devi ces. You may
have other devi ces you want to program.
Send me E-mai l descri bi ng what
PROMs or mi crocontrol l ers (no PLDs,
pl ease) that you woul d l i ke to see the
programmer support. If there i s a con-
sensus, Il l l ook at adapti ng the pro-
grammer to the most popul ar one or
two choi ces.
Thats i t. Go forth and program. I
Figure 5The programmer
software uses a round-robin
method of scheduling tasks.
The only interrupt is for the
74 Issue 98 September 1998 Circuit Cellar INK

Jeff Bachiochi
The Next
Step in EL
An alien?
No, its
just Jeff
his new
nametag. After
debriefing us on the
fundamentals of EL
panels, he tells us
how we too can get
that strange green
ven though Ive
converted to CDs, I
just cant toss out my
ol d vi nyl LPs. Some have
more than just senti mental val ue. Some
of my favori tes arent even musi c.
Have you ever heard any of Bi l l
Cosbys comedy al bums? Al bums l i ke
To Russell, My Brother Whom I Slept
With keep me smi l i ng even today.
Of course, back then i t was di fferent.
I had to have a ni ghtl i ght because of
Bi l l and hi s storytel l i ng. You see, a
ni ghtl i ght was the one thi ng that pro-
tected you from the snakes that sl i ther
around under your bed at ni ght.
Bi l l tol d how i f you put one foot on
the fl oor after l i ghts out you were done
for. Dari ng the snakes to just take a
l i ttl e l i ck was fool i shness. Thank
heavens for ni ghtl i ghts! They had the
power to keep those snakes under the
bed where they bel ong.
I di dnt thi nk of our
fami l y as hi gh tech at
the ti me, but we di dnt
have a bul b ni ghtl i ght
we had a mysteri ous
panel that gave off the
ki nd of l i ght youd
expect from a ful l green-
cheese moon. And i t
emi tted no heat, unl i ke
any other l i ght source
Id ever seen. For years,
I wondered what i t was.
In my earl y teens, I di d a l ot of
campi ng wi th the Boy Scouts. One ni ght
whi l e campi ng far from ci vi l i zati on, I
had my fi rst encounter wi th an al i en
l i fe form. What el se coul d i t have been?
It was gl owi ng i n the woods. Noth-
i ng I knew of on thi s pl anet coul d
gl ow wi thout batteri es. I touched i t,
expecti ng to be transformed to another
di mensi on. Nothi ng happened. It wasnt
even warm. Fl ashback of snakesyi kes!
Ni ghtl i ghts, hmm. Li ght and no
heat. I needed to know more. But, the
fol l owi ng morni ng, i t was gone.
Wel l , as wi th many other mysteri es
of the worl d, Mother Nature had a
hand i n thi s one. The chemi cal process
of a decayi ng tree stump had produced
a phosphor that gl owed conti nual l y.
Duri ng the day, the gl ow was unde-
tectabl e, but at ni ght, the phosphores-
cent gl ow was si gni fi cant. Today, you
fi nd phosphorescent sti cks and neck-
l aces i n your l ocal store. The magi c has
gone commerci al .
El ectrol umi nescent (EL) l amps are
everywhere. They are used to back-
l i ght devi ces rangi ng from IR remotes
to l ot of the audi o and vi deo equi p-
ment we ownpagers, cel l phones,
GPS recei vers, and, yes, even some
wri stwatches.
Its no surpri se that these l i ght
sources are bei ng used more frequentl y.
Theyre l ow i n power, thi n, fl exi bl e,
and l i ghtwei ght. They produce negl i -
gi bl e heat and can be easi l y manufac-
tured i n custom shapes. Youd thi nk,
wi th al l that goi ng for i t, EL l amps
woul d be used even more than they
are al ready.
There are two major drawbacks to
EL backl i ghts. Fi rst, EL panel s experi -
Figure 1High-voltage AC is needed to drive photons of light from phospho-
rous particles suspended between electrodes.
Rear Electrode
ZnS Phosphor
Front Electrode
AC Drive
Circuit Cellar INK

Issue 98 September 1998 75

ence a typi cal bri ghtness hal f-l i fe due
to agi ng. Thi s hal f-l i fe (i .e., the acti ve
l i fe unti l the bri ghtness di mi ni shes to
hal f i ts i ni ti al output) can be as l i ttl e
as a few thousand hours.
At 24 hours a day, thats roughl y
9000 hours i n a year. So, an EL panel
runni ng day and ni ght at maxi mum
bri ghtness may deteri orate to hal f i ts
bri ghtness i n onl y a few months.
Second, the EL panel often requi res
100200 VAC to operate. For portabl e
battery-powered devi ces, thi s has been
the EL panel s bal l and chai n.
Before we l ook at the support ci r-
cui try, l ets see how EL panel s are made.
Mechani cal l y, the EL panel l ooks
l i ke a l arge capaci tortypi cal l y, a few
nanofarads per square i nch.
As you see i n Fi gure 1, two i nner
l ayersa di el ectri c l ayer and a phosphor
l ayerare sandwi ched between two
conducti ve surfaces. The di el ectri c l ayer
prevents the two conducti ve l ayers
from shorti ng out whi l e bei ng subjected
to hi gh vol tages.
When a hi gh-vol tage potenti al i s
pl aced across the two conducti ve l ayers,
an el ectri c fi el d i s generated. The phos-
phor parti cl es are encouraged to gi ve
off photons (i .e., l umi nesce) as the el ec-
tri c fi el d al ternates.
Duri ng a vol tage ri se, the phosphors
el ectrons are exci ted from the val ence
band i nto the conducti on band. Con-
versel y, when the vol tage decreases,
these el ectrons return from the con-
ducti on band to the val ence band.
El ectrons movi ng to the l ower energy
bands can gi ve off photons. If one con-
ducti ve surface i s transparent, the l i ght
escapes and produces the fami l i ar gl ow.
ZnS phosphor, the most common
compound used i n the di el ectri c l ayer,
i s responsi bl e for the bl ue-green gl ow
of most EL panel s. The spectral emi s-
si ons of the phosphor can be al tered
by dopi ng ZnS, CaS, or SrS wi th transi -
ti on metal s or nonmetal s l i ke magne-
si um or europi um.
Ongoi ng EL devel opment hopes to
ri val col or LCDs someday. But, much
of that i s i n the hands of chemi sts.
The two most si gni fi cant vari abl es
used to generate l i ght output from EL
panel s are vol tage and frequency. Panel
bri ghtness i s di rectl y proporti onal to
vol tage and frequency.
Al though each panel has maxi mum
and mi ni mum val ues for vol tage and
frequency, typi cal ranges are from 100
to 200 VAC and from 60 to 1000 Hz.
An EL panel used as a ni ghtl i ght at
120 VAC at 60 Hz may have a typi cal
l umi nance output of a few candel as.
Unl i ke the coupl e of vol ts DC that
are requi red for LED backl i ghti ng,
thei r hi gh-vol tage requi rements make
EL panel s far more di ffi cul t to use. In
the past, transformer i nverters were
needed to transl ate l ow-vol tage DC
i nto useful hi gh-vol tage AC. Fi gure 2
shows a typi cal DC to unregul ated
hi gh-vol tage AC converter.
In thi s push-pul l confi gurati on, the
transformer i s not onl y a step-up devi ce
but al so an i ntegral part of the pri marys
osci l l ator. Normal l y, these devi ces
were purchased for a parti cul ar-si zed
EL panel because there were no
user-sel ectabl e components for
adjusti ng the output.
Recent i nnovati ons have
reduced the ci rcui try, so that a
si ngl e IC can now act as a vol t-
age step-up converter and a com-
mutati ng bri dge dri ver. Fi gures
3a and 3b show the IMP803 and
SP4428 hi gh-vol tage l amp dri vers,
respecti vel y.
The IMP803 step-up converter
uses an i nternal hi gh-frequency
osci l l ator to gate a MOSFET
swi tch (5090 kHz). An external
coi l , L1, and di ode, D1, combi ne
wi th the MOSFET swi tch to
step up Vi n (as l i ttl e as 3 V) to
as much as 90 V across capaci tor
Cs (Vcs).
The coi l s stored energy i s
rel eased through the di ode i nto
the capaci tor each ti me the
MOSFET swi tch opens. The swi tchi ng
frequency i s control l ed by external
resi stor R
, and the effi ci ency vari es
wi th the sel ecti on of L1 and R
The second secti on of the ci rcui t
appl i es the hi gh-vol tage potenti al to a
ful l H-bri dge. The EL l amp i s pl aced
across the bri dge. A second osci l l ator,
tuned by external resi stor Rel and
runni ng at 300400 Hz, al ternatel y
gates di agonal secti ons of the H-bri dge,
produci ng an al ternati ng potenti al on
the EL panel twi ce that of the hi gh-
vol tage i nput.
IMPs hi gh-vol tage EL l amp-dri ver
IC comes wi th and wi thout a hi gh-
vol tage regul ati on secti on. When Vi n
i s a battery whose output drops wi th
age, Vcs (and the l amps bri ghtness)
can remai n constant i f the devi ce has
regul ati on ci rcui try. When the l amp i s
dri ven from a Vi n that remai ns con-
stant, usi ng the l amp dri ver wi thout
regul ati on has an advantage.
Si nce the EL l amps capaci tance goes
up as the l amp approaches i ts hal f-l i fe,
an unregul ated ci rcui t sel f-compensates
by creati ng a hi gher Vcs. Desi gn con-
si derati ons shoul d be based on the type
of power used and the duty cycl e of
the l amp (how often i t needs to be on).
The Si pex SP4428 uses sl i ghtl y
di fferent ci rcui try. Onl y a si ngl e osci l -
l ator i s used, and i ts frequency i s set
by an external capaci tor.
Figure 2As an integral part of this oscillator, the
primary of T1 also boosts the voltage via its secondary.
Figure 3aThe IMP803 has separate oscillators for more user
control. bThe SP4428 uses a single oscillator to provide both
high voltage DC and switching for the EL panel.
BAT Enable Coil D1

3 4
7 8
BAT Coil
3 4
76 Issue 98 September 1998 Circuit Cellar INK

Energy devel oped

i n an external coi l
by removi ng i t
from ground at the
20-kHz (nomi nal
frequency) rate i s
di rected toward the
second stage by a
di ode si mi l ar to the
IMP devi ce. But, i nstead of chargi ng a
separate external capaci tor as i n the
IMP803, the SP4428 uses the EL l amp
as the capaci tor bei ng charged.
In the second stage, the H-bri dge i s
swi tched by a second cl ock. Si x fl i p-fl ops
generate a second cl ock (~300 Hz) from
the pri mary osci l l ator (frequency/64).
The SP4428 requi res more than 1.1 V
to produce a mi ni mum of 120 VAC
across a 5-nF EL panel (roughl y 1.5 i n.
More and more uses for EL panel s
are arri vi ng on the scene. Im sure
youve seen joggers or other peopl e out
at ni ght weari ng apparel fi tted wi th EL
panel s for hi gh vi si bi l i ty. Portabl e
emergency and hazardous warni ng
si gns are gai ni ng popul ari ty, too, thanks
to some of the new dri ver technol ogi es.
At one poi nt, Id pl anned on maki ng
an LCD nametag. Now, wi th an EL
panel and some ci rcui try, I can do the
job more easi l y and l ess expensi vel y.
I started wi th the basi c ci rcui t (see
Fi gure 4), but I needed to add a coupl e
of capaci tors to get the best output.
Usi ng an IMP803, I found the HV sec-
ti on to work as adverti sed. Sel ecti ng a
coi l wi th l ow Rs gave hi gher Cs vol tage.
The peak current draw from the 3-V
l i thi um coi n cel l was above what the
cel l coul d sustai n. Major vol tage sags
occurred at maxi mum currents, so I
added a capaci tor across Vbat, whi ch
al so i mproved the hi gh vol tage on Cs.
On the H-bri dge si de, I saw spuri ous
output that was i nsuffi ci ent to l i ght
the EL l amp. A note suggests addi ng a
Cbp i f the backl i ght fl i ckers. Fl i cker
wasnt the probl em, but a capaci tor here
cured whatever noi se was preventi ng
the H-bri dge from osci l l ati ng correctl y.
These few parts fi t easi l y on the
back of a 1 3 PCB. I chose the si ze
to fi t across the back of an LCD bezel .
Because the parts were surface
mounted to the PCB, I was abl e to use
Jeff Bachiochi (pronouncedBAH-key-
AH-key) is an electrical engineer on
Ci rcui t Cel l ar INKs engineering staff.
His background includes product design
and manufacturing. He may be reached
IMP, Inc.
(408) 432-9100
Fax: (408) 434-0335
Si pex Corp.
(978) 667-8700
Fax: (978) 667-8310
EL lamps
Durel Corp.
(602) 917-6000
Fax: (602) 917-6049
www.durel .com
Lumi tek Internati onal , Inc.
(800) 992-5149
(301) 831-1001
Fax: (301) 831-8221
MetroMark, Inc.
(800) 680-5556
(612) 935-8844
Fax: (612) 935-5718
Figure 4My EL circuitry needed a bit of capacitance from RSW to Ground. This
situation may be due to the layout currents.
the other si de of the PCB for mounti ng
the EL panel wi th doubl e-si ded tape
wi thout worryi ng about protrudi ng
l eads puncturi ng the EL panel . Extra
hol es i n the PCB enabl e the bezel to
sandwi ch the panel ti ghtl y to the PCB.
For the fi ni shi ng touch, smal l ad-
hesi ve or rub-on l etteri ng l ets me
create any message I deem necessary.
So, i f you happen to see a strange
green gl ow at the next el ectroni cs
show you attend, dont be al armed. It
wont be an al i en. Its just me. I
78 Issue 98 September 1998 Circuit Cellar INK

Tom Cantrell
Sensory Overload
offers the
latest in
sensor technology,
and Toms here to
report. Whether its
position sensing, voice
recognition, or strain
gauge devices, get a
sense of whats best
for your application.
ve al ways en-
joyed the Sensors
Expo. After al l , sensors
are at the heart of most
embedded control apps, whether i ts a
si mpl e thermostat or a hi ghfal uti n
vi si on system.
Ive been there before ( In the Real m
of the Sensors, I NK 49). However,
the show i s on a 10-ci ty cycl e (keep
an eye out si nce i t i ncl udes nontradi -
ti onal venues l i ke Cl evel and, Bal ti more,
and Phi l adel phi a), so i ts been a whi l e.
Anyway, I was a bi t surpri sed at
the sea of booths I encountered. Sure
seems l i ke sensors are getti ng to be a
bi g deal . More power (and ground) to
em, I say.
Even PCs are getti ng i nto the act
wi th temp sensors, fan tachs, and
i ntrusi on and moti on detectors. If
chi ps l i ke the Nati onal LM80, shown
i n Fi gure 1, are any i ndi cati on, anybody
thi nki ng of l i ghtfooti ng a l aptop or
l i fti ng some SIMMs can expect the
MIS pol i ce to come a-knocki n.
The chi p starts wi th an ei ght-channel
ei ght-bi t ADC. Seven channel s are
brought out whi l e one i s devoted to
an on-chi p temp sensor.
Unl i ke a typi cal 05-V ADC, the
LM80 A/D i nput range i s 02.56 V
(i .e., 10 mV/bi t). Thi s happens to be a
perfect match wi th popul ar three-pi n
l i near temp sensors l i ke the LM50.
You can use the LM80 to moni tor
the temp of vari ous components scat-
tered around i nsi de the box. Theres
al so a di gi tal i nput (BTI, whi ch stands
for Board Temperature In) that i s
sui tabl e for connecti ng to thermostat
temp chi ps l i ke the LM56 or LM75.
The ADC i s al so i ntended to moni -
tor the hal f dozen or so system vol t-
ages (e.g., 2.5, 3.3, 5, and 12 V) at
work on the l atest motherboard. Its a
Value RAM
Fan 1
Fan 2
Upper Limit
Lower Limit
Upper Limit
Lower Limit
Upper Limit
Lower Limit
Upper Limit
Lower Limit
Upper Limit
Lower Limit
Upper Limit
Lower Limit
Upper Limit
Lower Limit
Upper Limit
Upper Limit
Interface and Control
8-Bit ADC
and MUX
10-mV LSB
Fan Speed Counter
Fan Speed Counter
Fan Tach
Logic Inputs
2 3 24 23 22
Serial Bus Interface
Serial Bus Interface
Figure 1Whether its the various power supplies, fans, external and internal temp sensors, or even the chassis,
the LM80, like Big Brother, is always watching.
Circuit Cellar INK

Issue 98 September 1998 79

magnetoresi sti ve sensors. The basi c
advantage i s hi gher sensi ti vi ty and
bandwi dth for l ess si ze and power.
The technol ogy i s offered at vari ous
l evel s of i ntegrati on, starti ng wi th the
HMC1001 and 1002 (and l ess-sensi -
ti ve, l ower cost HMC1021 and 1022),
whi ch are just the si ngl e- and dual -
axi s MR bri dge i n 8- and 16-pi n IC
Combi ni ng the 1001 and 1002
wi th ampl i fi ers, the hybri d HMC2003
shown i n Photo 2 i s a three-axi s uni t
wi th hi gh-l evel 0.54.5-V output (2 G,
whi ch i s 1 V/G vs. 15 mV/G for the
bri dge al one). The HMR2300 throws
i n the ADCs and a mi cro to del i ver
di gi tal output vi a RS-232 or RS-485 at
ei ther 9600 or 19,200 bps.
Notabl e for vi rtual -real i ty appl i ca-
ti ons, the uni t can del i ver sampl es at
over 100 Hz, whi ch i s faster than the
CRT refresh rate. Thats good because
i f you update too sl owl y, the vi rtual gets
out of sync wi th the real i ty, whi ch
resul ts i n an al together unpl easant
si tuati on.
Another way of tracki ng movement
i s a gyro. As wi th compasses, the
emergence of el ectroni c equi val ents
to yesteryears mechani cal l ashups
promi ses to prol i ferate appl i cati ons.
Consi der, for i nstance, the Mi cro-
Gyro100 from Gyrati on. Thi s l i ttl e
goodi e uses the el ectromagneti c equi va-
l ent of the Cori ol i s effect, perhaps
best known for causi ng water to drai n
wi th a di fferent spi n north and south
of the equator.
The MG100 outputs a vol tage pro-
porti onal to angul ar vel oci ty (about
The strai n-gauge technol ogy i s
basi c, but Bokams i mpl ementati on i s
cl ever. The strai n gauges are screened
onto the joysti ck mounti ng pl atform,
whi ch acts as a substrate.
Besi des l ow cost, thi s setup enabl es
easy i ntegrati on of condi ti oni ng el ec-
troni cs. For i nstance, versi ons wi th
bui l t-i n ampl i fi ers for hi gh-l evel 05-V
output are avai l abl e, as wel l as ones
wi th bui l t-i n mi cros for di gi tal seri al
output (e.g., RS-232 or PS/2 keyboard).
Another advantage of thi s techni que
i s that the substrate can be al most
anythi ng. For i nstance, theres a total l y
cerami c model thats especi al l y wel l
sui ted for harsh envi ronment and
temperature condi ti ons. Meanwhi l e,
sol i d-steel noncompl i ant uni ts mi ght
be a boon for trul y ham-fi sted hackers
but are more l i kel y found i n i ndustri al
force-measurement and moti on-control
appl i cati ons.
Oh wel l , two booths down
means that Ive got hundreds
mi nus two to go, so Id better
get movi ng.
Di gi tal compasses are al l
the rage. Most notabl y, theyre
fi ndi ng homes i n most new
cars, boats, and presumabl y
any other vehi cl e that can get
l ost. You can check out Do
You Know the Way to San
Jose (I NK 53) for a refresher
on the technol ogy.
Honeywel l has come up
wi th a sol i d-state (i .e., no coi l s
or fl ux gates) upgrade of the
technol ogy i n thei r HM l i ne of
si mpl e matter of usi ng resi stor di vi d-
ers to attenuate and center each vol t-
age i n the A/D range.
Whether i ts the power-suppl y l evel s,
external temperature, or on-chi p tem-
perature, the LM80s rol e i s the same.
It si ts i n a l oop, scanni ng the i nputs
and compari ng them agai nst host-
programmed (vi a I
C) l i mi ts, rai si ng
an i nterrupt on excursi on. The on-
chi p temperature sensor gets a l i ttl e
extra attenti ona 12-bi t conversi on
opti on, programmabl e hysteresi s, and
more versati l e al arm modes.
If thi ngs are heati ng up, fans are a
l i kel y cul pri t, so the LM80 keeps an
eye on them by moni tori ng the fan
tach (note that fans wi th bui l t-i n tach
outputs are avai l abl e from major sup-
pl i ers l i ke NMB, Mechatroni cs, and
Sanyo) and compari ng agai nst a user-
programmed mi ni mum-RPM l i mi t.
Oh yeah, dont forget the omi nous-
soundi ng Chassi s Intrusi on (CI) l i ne.
Even when the LM80 i snt powered, i t
can be safel y dri ven by an external
ci rcui t (Nati onal shows an exampl e
usi ng an optosensor).
On powerup, the LM80 duti ful l y
denounces any poor fool that dei gns to
pop the l i d of thei r PC. Of course, the
fate of such a subversi ve i s l eft to the
system desi gner. It coul d get ugl y.
Another type of PC sensor thats
cl ose at hand, l i teral l y, are force sen-
sors l i ke those desi gned by Bokam
Engi neeri ng for the IBM Trackpoi nt
(see Photos 1a and 1b). Im no expert,
but I fi ddl ed wi th the arrangement,
whi ch pl ants a smal l penci l -eraser
l i ke fi ngerti p joysti ck between the G,
H, and B keys. It seems to work wel l .
Photo 1Force joystick technology finds its way from laptops to the factory floor. The Bockam Engineering con-
cept, screening strain gauges onto a substrate, is the same whether its ceramic (a) or solid steel (b).
Photo 2The Honeywell solid-state magnetoresistive sensor cuts
the size of their electronic compass modules. This unit, the
HMC2003, provides three-axis high-level (0.54.5 V) analog
output in a footprint smaller than 1-in.
a) b)
80 Issue 98 September 1998 Circuit Cellar INK

power consumpti on from a few mi l l i -

amps to onl y a few mi croamps, yet i t
can wake up and get goi ng i n l ess than
a second.
If they arent showstoppers, these
spec foi bl es are a smal l pri ce to pay
because youre onl y payi ng a smal l
pri ce for the MG100 ($15 i n hi gh
vol ume).
Measurand puts another
twi st on the posi ti on-sensi ng
angl e wi th i ts Shape Sensor
(see Photo 3) and Shape Tape.
These sensi ng devi ces rel y
on treated opti c fi ber (l ami -
nated i nto a fl exi bl e tape-l i ke
ri bbon) that modul ates l i ght
i ntensi ty qui te accuratel y,
dependi ng on the curvature.
By mounti ng the tape to a
canti l ever beam of some sort
(versi ons are avai l abl e wi th
i ntegral spri ng steel beam),
the uni t can hel p measure
force, accel erati on, fl ow, and
so forth.
The Shape Sensor comes wi th
modul ar optoel ectroni cs that handl e
the detai l s and provi de a hi gh-l evel
output (14 V for a 5-V suppl y).
Shape Tape goes further, managi ng
up to 64 sensors i n a si ngl e pi ece of
tape by mul ti pl exi ng ei ght LEDs and
ei ght detectors. The sensors are pai red
to extract both twi st and bend i nfo.
1 mV per degree per sec-
ond) i n each of two axes.
The MG100 does ex-
hi bi t some spec l i mi ts
you shoul d be aware of.
Fi rst, the response rate i s
l i mi ted wi th maxi mum
angul ar vel oci ty of 150
per second and a 10-Hz
bandwi dth.
Al so, the uni t i s rather
sensi ti ve to temperature
over i ts 5C to 45C
range, and i t needs com-
pensati on. To hel p your
desi gn achi eve the hi gh-
est possi bl e accuracy, the
MG100, whi ch runs on
anythi ng from 2.2 to 5.5 V,
provi des a 1.225-V reference output
and i ncl udes a temp sensor.
There i s al so a l engthy power-up
del ay (al most 3 mi n., whi ch i s i tsel f
temperature dependent), and duri ng
thi s del ay the output may dri ft a few
Instead of power cycl i ng, consi der
usi ng the sl eep mode. Thi s mode cuts
Photo 3Measurand Shape Sensors put a unique twist on position detection by
translating curvature to force, acceleration, velocity, and flow.
Circuit Cellar INK

Issue 98 September 1998 81

After a cal i brati on exerci se (fl at,
coi l , twi st) and a bi t of number crunch-
i ng (Wi n95 software i s provi ded), i ts
possi bl e to determi ne rel ati ve posi ti on
i n free space between the ends of the
tape. It works because the free-fl oati ng
tape drapes i nto ci rcul ar arcs between
sensors, whi ch al ong wi th known
posi ti on, bend, and twi st, make the
geometry workabl e.
Truth i s, Im not so sure what the
best appl i cati on i s for thi s technol ogy.
The company makes a case for al l
manner of posi ti oni ng apps of the sort
served by el ectromechani cal LVDTs
(Li near Vari abl e Di stance Transducers),
wi th parti cul ar menti on of bi ometri cs,
VR, crash testi ng, and so on.
However, I am pretty sure that, i n
the hands of a cl ever and i magi nati ve
desi gner, thi s stuff has got to be real
good for somethi ng.
Tal ki ng chi ps have been around for
many years, whi ch i s not to say the
technol ogy has al ways been wel l ap-
pl i ed. I can sti l l remember a 70s-era
car that kept i nsi sti ng i ts door was
a jar unti l I taught i t a l esson wi th
some wi re cutters.
Whi l e tal k i s cheap, l i steni ng i s
another story. In fact, practi cal voi ce
recogni ti on remai ns one of the hol i est,
and most el usi ve, grai l s.
On the desktop, I understand the
technol ogy has made great stri des, I
i magi ne l argel y as a resul t of PC-MIPS-
to-burn brute force. Neverthel ess, I
dont foresee tradi ng i n my QWERTY
for a mi crophone anyti me soon.
However, other appl i cati ons have
qui te di fferent functi onal i ty and cost
cri teri a that may l ead to the accep-
tance of l ess grand, but more feasi bl e,
technol ogy.
A sui tabl e app i s one that trul y
demands voi ce i nput (i .e., key entry i s
not an opti on) yet can sacri fi ce one or
more bl ue-sky aspi rati ons such as
speaker i ndependence, conti nuous
speech, or huge vocabul ari es. Li kel y
candi dates i ncl ude voi ce di al ers, toys,
securi ty, appl i ances, and PDAs.
For exampl e, whi l e speaki ng to my
desktop mi ght be ni ce, the downsi de
of QWERTY i snt exactl y l i fe threat-
eni ng. By contrast, hand di al i ng a car
Circuit Cellar INK

Issue 98 September 1998 83

phone i s somethi ng that wi l l probabl y
be i l l egal i n your area soon, i f i t i snt
al ready. Whats next, desi gnated di al ers?
Sensory Inc. (formerl y Sensory
Ci rcui ts) has carved a ni che by sup-
pl yi ng l ow-cost mi ddl ewei ght voi ce-
recogni ti on technol ogy. The RSC-164
i n Fi gure 2 starts wi th an 8051-l i ke
(wi thout the accumul ator and data
poi nter bottl enecks) MCU runni ng at
14.342 MHz (a 32-kHz osci l l ator i s an
opti on for ti mekeepi ng).
It then adds the anal og front and
back ends, whi ch enabl e the chi p to
both l i sten and tal k. Both 10-bi t DAC
and PWM are output opti ons, the l atter
abl e to di rect dri ve a smal l (32 )
The key to l ow-cost recogni ti on i s
the use of neural -network software
techni ques rather than fancy hardware.
The preprocessed patterns are stored
i n on-chi p ROM (speaker i ndependent,
standard vocabul ary) or external fl ash
(speaker dependent, custom vocabul ary).
In addi ti on to recogni ti on, a bi t
more software enabl es the chi p to
handl e other useful audi o tasks, i n-
cl udi ng voi ce and MIDI-l i ke musi c
synthesi s as wel l as DTMF and di gi tal
voi ce record and pl ayback.
Sensory makes the RSC-164 avai l abl e
both for custom programmi ng and
preprogrammed for standard apps. An
exampl e of the l atter i s the Voi ce Di al er
IC, whi ch targets the previ ousl y noted
dri ve-and-di al di l emma.
Figure 3HP answers
the field-bus question
with a Network Capable
Application Processor
(NCAP) that bridges the
gap between IEEE
1451.2 sensors and
standard networks.
Smart Transducer Interface Module
(SMT) Network Capable
Application Processor
Application firmware
1451.2 Interface Driver
Correction Engine
Figure 2The Sensory
RSC-164 is a micro
that talks and, more
importantly, listens.
Purpose I/O
Digital Logic
Preamp and
gain control
The Voi ce Di al er i s desi gned to act
as an autonomous and smart subsystem
connected to a host CPU by a si mpl e
three-wi re seri al i nterface. The host
merel y sends hi gh-l evel commands
(e.g., addi ng a name to a di rectory),
and the chi p takes care of al l the detai l s,
i ncl udi ng voi ce prompti ng the user
al ong the way.
As for handl i ng a 60-name tel ephone
di rectory, Sensory says the recogni ti on
rate exceeds 97% even i n noi sy envi -
ronments. Thats not bad at al l for a
chi p that sel l s for under $5 i n vol ume.
I remember goi ng to Di sneyl and as
a ki d, way back when Wal t was sti l l
i n charge. Maybe you too remember
how Di sneyl and used to sel l ti ckets for
each ri de denomi nated A through E.
The A ti ckets were l osers, ki nd of
l i ke penni es, good for onl y the wi mpi est
ri des. Ahh, but the E ti ckets were
good as gol d, openi ng the door to hi gh-
speed thri l l s.
Much i s bei ng made of the vari ous
fi el d buses that purport to bri ng order
to the di gi tal -control worl d. To tel l the
truth, I have troubl e keepi ng up wi th
them al l . Li ke those Di sneyl and ti ckets,
though, Im sure the market wi l l deci de
that some are an A and others an E.
In a rati onal worl d, nobody woul d
thi nk of speci fyi ng Ethernet as an
i ndustri al control network. But, who says
anythi ng i n thi s busi ness i s rati onal ?
84 Issue 98 September 1998 Circuit Cellar INK

Tom Cantrell has been working on

chip, board, and systems design and
marketing in Silicon Valley for more
than ten years. You may reach him by
E-mail at tom.cantrell@circuitcellar.
com, by telephone at (510) 657-0264,
or by fax at (510) 657-5441.
Force sensors
Bokam Engi neeri ng, Inc.
(714) 513-2200
Fax: (714) 513-2204
Gyrati on, Inc.
(408) 255-3016
Fax: (408) 255-9075
Hewl ett-Packard Co.
(425) 335-2654
Fax: (425) 335-2220
HMC2003, HMR2300
Honeywel l , Inc.
Sol i d State El ectroni cs Ctr.
(612) 954-2888
Fax: (612) 954-2582
www.ssec.honeywel l .com
IR-linked data logger
Lascar El ectroni cs, Inc.
(912) 234-2048
Fax: (912) 234-2049
www.l ascarel ectroni
Maxi m Integrated Products
(408) 737-7600
Fax: (408) 737-7194
Shape Tape, Shape Sensor
Measurand, Inc.
(506) 462-9119
Fax: (506) 462-9095
Nati onal Semi conductor
(800) 737-7018
(408) 721-5000
www.nati onal .com
Sensory, Inc.
(408) 744-9000
Fax: (408) 744-1299
Photo 4In addition to a $995 IEEE 1451.2 developers
kit, HP showed this prototype NCAP connecting 1451.2
(and RS-232) sensors to Ethernet and via built-in
microserver onto the Web.
Fact i s, I thi nk Ethernet i s wel l posi -
ti oned from a pragmati c, i f not theo-
reti cal , poi nt of vi ew. A l ot of PCs are
fi ndi ng thei r way onto the factory fl oor,
and the i ncremental cost of an Ethernet
port i s approachi ng zero. In the real
worl d, peopl e just want to pl ug stuff i n.
I feel l ess squeami sh about goi ng
out on the Ethernet l i mb, thanks to
backi ng from heavywei ght HP. Thei r
vi ew of the worl d (see Fi gure 3), com-
bi nes the recentl y fi nal i zed IEEE 1451.2
sensor i nterface standard wi th Ethernet
as a fi el d network.
For a vi ew of whats to come, check
out the prototype NCAP (Network
Capabl e Appl i cati on Processor) i n
Photo 4. It not onl y makes the IEEE
1451.2 connecti on but i ncl udes a mi cro
Web server (i .e., easy browser access and
control of the sensor subsystem).
Oops, out of pages al ready. Needl ess
to say, theres pl enty of neat stuff that
has to go on the back burner for now.
How about the new l i ne of mi xed-
si gnal ICs just i ntroduced by Maxi m?
Judgi ng by the companys success i n
other endeavors, I expect great thi ngs.
Then theres the cute IR-l i nked
data l ogger from Lascar, not to menti on
a di zzyi ng array of temperature, pres-
sure, opti cal , and ti l t sensors.
Whether or not I hi t on just the
gadget you need, I thi nk theres one
l esson we can al l l earn. Your next
desi gn can, shoul d, and wi l l be more
sensati onal than your l ast. I
96 Issue 98 September 1998 Circuit Cellar INK

Which Numbers Count
hen it gets too deep around here, I start threatening to turn this rag into a controlled-circulation trade journal! Well,
not really. In truth, its not where I want to go, but even I get to rant and rave once in a while.
Being a trade magazine would have some definite advantages. I wouldnt have to worry about editorial direction
PR/marketing-generated vaporware is readily available. I wouldnt have to worry about advertisingPR submissions typically
include an advertising contract and at least one or two power lunches. I wouldnt have to worry about circulationheck, when the magazine is
free, whats the jeopardy in subscribing to a hundred of them? The worst that could happen is getting caught in a magazine avalanche.
All levity aside, the one ingredient that I didnt mention was readers. I think that if you focus a magazine on attracting loyal readers, it
cant use the formula approach represented by traditional trade magazines. In an off-the-record conversation at a recent trade show, the editor-
in-chief of a major trade magazine said that he envied our readership loyalty. He also lamented about the continuous solicitation process
necessary to maintain high circulation numbers in support of advertising revenues. We both laughed about the typical pile of unread trade
magazines on every engineers desk.
When he volunteered that the real readership of a typical issue probably wasnt more than 20% of the distribution, I was floored. Of
course, he didnt have to worry about his stats. He was audited on how many they mailed, not on how many were read. Wow. I guess that
wishing I was in his business meant it was time for a reality check.
When it comes to advertising, big-company PR departments always want solid stats. Certainly, the agencies have to justify their commis-
sions, but I believe that the lack of these stats is frequently an excuse to avoid making decisions. If the editor I talked to is accurate, the value
of circulation audits is not only questionable, its pure advertising extravagance.
I think the only real measure of a magazine is the active readership. Traditional auditing methods monitor potential, not performance.
When we get past the PR department obstacles, INK is always a proven performer. Want solid stats? Go ask your embedded system design-
ers what they read.
Ultimately, the traditional commercial clique is in for a jolt. The Internet has proven to be a valuable resource for extending the reach of
print magazines. But, like all things digital these days, Internet pathways are an accounting expos. Virtually all servers include statistical
packages that register things like user sessions, total hits, page views, and advertiser click-throughs.
Web stats offer a representative demonstration of real performance and perhaps a new undeniable truth. The readership of a small
targeted magazine can easily equal the significant value of a larger controlled-circulation audience (in spite of its overwhelming potential) when
real reader activity is the measure. The bombshell is in the numbers.
One electronic trade magazine recently went public with their Web stats. They claimed an astounding 350,000 hits per month. Ordinarily I
wouldnt care, but I was on our Web stat page at the timeI was looking at 1000 user sessions and 30,000 hits just for the day! Admittedly,
that day was above average, but it offers an interesting comparison. Overall, our documented Web traffic with 30,000 circulation easily equals
and often exceeds that of the large trade magazine with 150,000 circulation. If you factor in the opinion that only 20% of their 150,000 distribu-
tion are active anyway, you coincidentally arrive at 30,000!
Youd think somebody would read the fine print by now. A Web-advertising executive recently told me that big companies think nothing of
spending hundreds of dollars for each click-through. Obviously, that PR department isnt walking down to engineering again.
Truth be told, I wouldnt want to do this magazine any other way. Describe us however you want. My goal is to continue publishing a
magazine that nurtures an active, involved readership. Occasionally, I have to rant and rave about the obvious insanity of the people and
companies in the business. Controlled-circulation offers a wealth of potential, but I believe it comes up short in performance. Of course, when
you get right down to it, theres a bit more incentive to read a magazine youre willing to pay for. We certainly appreciate your support.