Nuts & Volts September 2007
Nuts & Volts September 2007
9 NUTS & VOLTS KEEP COMPONENTS COOL • VOLTAGE REFERENCE • INCHWORM ROBOT September 2007
Page 108
8:22 PM
8/8/2007
Cover.qxd
CoverInside.qxd 8/8/2007 3:22 PM Page 2
Stepper Motors
2 & 4 Channel GDS-2000 Series Digital Part #: Motor Frame
Size:
Holding Torque: Price:
Pa n e l M e t e r s
Jumbo LCD 9V Independent 3-1/2 Digit LED Panel Meter
Ground Panel Meter o n We b S i t e ! w/5V Common Ground
The PM-1028A is designed to run off of a The CX-102 series of digital panel meters
9V (7-11V) independent power source. have high reliability, good quality and fine
The figure height is 21mm. High quality workmanship. They can be used for a
SMT construction provides high reliability variety of applications and are competi-
and the decimal point selection is conve- tively priced. Their unmatched perform-
niently done by wire jumpers. The panel ance make these 3-1/2 digit LED panel
meter implements dual slope integration meters the first choice for applications that require
A-D conversion measuring methods. Item# $12.95 instrumentation. $14.95
Quantity Item# Quantity
Details
Details at Web
Web Site
Site PM-1028A Price Breaks Details
Details at Web
Web Site
Site CX102B Price Breaks
> Panel Meters > Digital Panel Meters at website! at website!
> Panel Meters > Digital Panel Meters
C i r c u i t S p e c i a l i s t s , I n c . 2 2 0 S . C o u n t r y C l u b D r. , M e s a , A Z 8 5 2 1 0
8 0 0 - 5 2 8 - 1 4 1 7 / 4 8 0 - 4 6 4 - 2 4 8 5 / FA X : 4 8 0 - 4 6 4 - 5 8 2 4
Full Page.qxd 5/10/2007 2:18 PM Page 3
RCM4510W
ZigBee RabbitCore®
$
72 (qty. 100)
RCM4400W
Wi-Fi RabbitCore
$
99 (qty. 100)
SEPTEMBER 2007
08 READER FEEDBACK
30 SHOWCASE
32 NEW PRODUCTS
66 ELECTRO-NET
96 CLASSIFIEDS
75
98 NV HOBBYIST STORE
Nuts & Volts (ISSN 1528-9885/CDN Pub Agree#40702530) is published monthly for $24.95 per year
by T & L Publications, Inc., 430 Princeland Court, Corona, CA 92879. PERIODICALS POSTAGE PAID 101 TECH FORUM
AT CORONA, CA AND AT ADDITIONAL MAILING OFFICES. POSTMASTER: Send address changes
to Nuts & Volts, P.O. Box 15277, North Hollywood, CA 91615 or Station A, P.O. Box 54,
Windsor ON N9A 6J5; [email protected] 105 ADVERTISERS INDEX
4 September 2007
Full Page.qxd 8/8/2007 3:30 PM Page 5
Link Instruments
PC-Based Test Equipment
S a/s
500M 1Mp
ts
www.Link-instruments.com
(973) 808-8990
September 2007 5
DevPerspective.qxd 8/8/2007 7:45 PM Page 6
Only
$99 Qty. 100
Published Monthly By
July ‘07 issue of Nuts & Volts. T & L Publications, Inc.
Your readers should try the 430 Princeland Ct.
MAGIC BOX KIT American Radio Relay League’s online
Corona, CA 92879-1300
DOES THE TRICK course on digital electronics (www.
(951) 371-8497
FAX (951) 371-3052
I recently completed the Magic Box arrl.org). This is an excellent hands-on Product Order Line 1-800-783-4624
featured in your April/May editions and course on using CMOS ICs. www.nutsvolts.com
must say it was without a doubt one of the Also, an additional way to develop Subscriptions
best projects I have seen in your magazine. perspective is to try to invent a new way Inside US 1-877-525-2539
Since I don’t usually have all the spare parts, of doing a function, such as sending Outside US 1-818-487-4545
nor the time to gather them up, I usually radio waves, adding numbers, steering P.O. Box 15277
opt out for the kit version and go from a robot, storing electrical energy, etc. North Hollywood, CA 91615
there. When it arrived, I was pleasantly This inventive process will encourage FOUNDER/ASSOCIATE PUBLISHER
surprised to find all the parts, very well one to really examine what is going on Jack Lemieux
packaged in groups and labeled, rather than in existing electronics circuits and to PUBLISHER
all thrown into one large bag like many oth- consider what alternatives may be Larry Lemieux
[email protected]
er kits. The building instructions and doc- possible. You can use a morphological
umentation were expertly explained and table to further stir up new ideas. ASSOCIATE PUBLISHER/
diagramed. It was a real pleasure building Nickolaus E. Leggett VP OF SALES/MARKETING
Robin Lemieux
the Magic Box, and it’s a blast watching Reston, VA [email protected]
people try to figure it out. I contacted Zone-
masterskits.com to request a set of extra OP-AMP OPTIONS EDITOR
Bryan Bergeron
Coke™ bottle pawns, and their response I have some questions for Gerard [email protected]
was immediate and informative. I look Fonte concerning his article in the August
forward to Nuts & Volts for just this type N&V on the ARB. The op-amp he speci- CONTRIBUTING EDITORS
Chuck Hellebuyck Marvin Mallon
of project. I only wish all the projects were fied is an LMC6082 CMOS device. That Jeff Eckert David Geer
of this magnitude. Keep them coming. particular op-amp seems to be difficult to Peter Best Michael Simpson
Russ Kincaid Mike Bessant
Kimberly Hamel find in a PDIP package in small quantities. Jon Williams Paul Verhage
Do you know where I can buy just a Craig Lindley Vaughn Martin
EXPERIMENTING WITH couple of them? Alternatively, what oth-
Stuart Ball Doug Malone
PERSPECTIVE er op-amp would you recommend? How CIRCULATION DIRECTOR
Tracy Kerley
Thank you for Bryan Bergeron’s about the LMC6442 or the LMC6042? [email protected]
Continued on page 97
SHOW COORDINATOR
Audrey Lemieux
MARKETING COORDINATOR
Brian Kirkpatrick
PRODUCTION/GRAPHICS
Shannon Lemieux
Michele Durant
ADMINISTRATIVE ASSISTANT
Debbie Stauffacher
TECH
2007
KNOWLEDGEY
EVENTS, ADVANCES, AND NEWS
■ BY JEFF ECKERT
ADVANCED TECHNOLOGY
MAGNET CONTROLS ANOTHER SOLAR CELL as the 40.7 percent achieved last year
LIQUID COLOR ADVANCEMENT by a Boeing Spectrolab (www.spectro
lab.com) device. However, “This is the
TECHKNOWLEDGEY 20 07
mind problems such as data back-up, PowerPC Macs in native mode. sland.com). Not only is it a digital
PC performance and health, and (Version 1.2.0 is available for Windows wristwatch, it also plays MP4 videos on
specialized networking support for 98 through Vista.) The program sells a built-in color screen and MP3 music
customers without dedicated IT staff.” for $129 on the website, but you can through an included set of earphones.
The notebooks start at $449, and download a free 15-day trial. The device comes with up to 2
you can get the Vostro 200 shown for GB of Flash memory, a 1.5-in color
about $319. The notebooks use either FREE EMAIL FOR screen (128 x 128 pixels), and digital
dual-core AMD or Intel Core™ 2 Duo iPHONES recording capability. It has five equal-
processors and have displays ranging izer modes plus a “super bass 3-D”
PHOTO COURTESY OF THINPRINT, INC.
from 14.1 to 17 inches. The 200 uses playback mode. Viewing options
the Intel chip. The company also include thumbnail, slide show, and
introduced a new 19-inch widescreen manual, and it even comes with a USB
display that lists for $229. cable for file transfer and recharging.
(You get eight hours of continuous
AN MD IN YOUR PC music playback on a charge.)
Originally priced at $199.99, it is
now offered at $159.99, so get your
Christmas shopping over early and look
forward to watching your friends and
family walk into walls and drive off cliffs.
NEW MEMORY
SUBSYSTEM FOR
EMBEDDED
■ The Cortado Free program offers
APPLICATIONS
iPhone users free email services.
LEON H. SIBUL,
INDUSTRY AND 1932-2007
THE PROFESSION
UNIVERSITY OF TECHNOLOGY.
PHOTO COURTESY OF TALLINN
SPAMMERS/SCAMMERS
ARRESTED
E arlier this year,
the electron-
ics industry lost
CCaattaalloogg!
quently sold the stocks at a profit. in the era of satellite communications.
Unfortunately for the Useltons, this Finally, in 1964, he joined the
call toll free is a violation of Section 10(b) of the Applied Research Lab at Penn State,
1-800-543-4330 Securities Exchange Act of 1934 and conducting signal-processing R&D
refer to or visit
Rule 10b-5, and the SEC was not for undersea weapons guidance and
www.mcmelectronics.com/magazine amused. In related enforcement actions, control, sonar systems, and other
Texas authorities indicted the Useltons naval applications, and also taught
for engaging in organized crime and acoustics. Sibul retired in 2002.
money laundering and seized more He held electrical engineering
than $4.2 million from their bank degrees from George Washington
accounts. The best part is that you can University (bachelor’s), New York
see a video of Darrel’s arrest at www. University (master’s), and Penn
oag.state.tx.us/media/videos/play.php State (Ph.D.) and was a life member
Source Code: NVM53 ?image=070907uselton_arrest&id=235. in the IEEE.
12 September 2007
Full Page.qxd 8/8/2007 3:39 PM Page 13
www.microchip.com/Easy
■ BY CHUCK HELLEBUYCK
GETTING STARTED WITH
THE LATEST IN PROGRAMMING MICROCONTROLLERS
PICs
LARGE DIGITS ON A 4x20 LCD
DRIVING A LIQUID CRYSTAL DISPLAY (LCD) module has become very easy to
do with the various PIC® microcontroller (MCU) options that are available.
microEngineering Labs’ PICBASIC PRO compiler, Basic Micro’s BasicATOM
chips, and many other PIC MCU-based chips, modules, and compilers offer a
command dedicated to driving these types of displays.
G E T T I N G S TA R T E D W I T H P I C s
SOFTWARE
This software listing is kind of long, but most of the
code deals with setting up the LCD to display the large
custom characters. (The complete software listing is
available on the Nuts & Volts website at www.
nutsvolts.com.) In the code, you will notice the “|” pipe
character at the end of several lines. This is for line
continuation. This is a special character that the BasicATOM
compiler recognizes as a continuation message. When the
compiler sees that character, it knows the command line
was too long for the editor window and continues on the
next line. Setting up the characters takes a lot of space, so
the line-continuation function is used often.
HOW IT WORKS
First, we establish a few variables and constants. The
variables are just temporary storage locations labeled X and
Char. The constants define the LCD “E” pin and “RS” pin.
■ FIGURE 4. Connections to the Ultimate
OEM BasicATOM module.
September 2007 15
GetStartedWithPICs.qxd 8/7/2007 11:33 AM Page 16
After the code above executes, the custom characters ‘ *** Final message from program before looping back to
are now in the LCD character-generator memory. The the top ***
program can now call them to create the large characters lcdwrite rspin\epin,outc,[clear,home,scrram,|
on the LCD. The “main” label starts the central program ”Just imagine what”,scrram+$40,”you can do!”]
loop. In the section below main, we use the LCDWRITE pause 3000
command to display a description of what this program will goto main
do, as shown in Figure 2. We display “Large Digits Using”
by using the LCDWRITE command. With this custom character method, you can create just
about anything on an LCD screen.
‘ *** Initial screen with program description ***
main
lcdwrite rspin\epin,outc,[clear,home,scrram,”Large Digits NEXT STEPS
Using”]
lcdwrite rspin\epin,outc,[scrram + $40] The projects that can result from this are endless. Just
remember that nothing stops you from redefining the
This next section will call up the custom characters just custom characters in the middle of the program. Let’s say
created, one at a time, using a FOR-NEXT loop, and will you want to display large characters, initially, and then later
display them using the LCDWRITE command. The variable in the program want to create an animation using different
x holds a value from 0 to 7. LCDWRITE directs the LCD to custom characters.
display characters 0 through 7. See how easy it is to display After completing the large custom number characters,
custom characters, once they are created? clear the LCD screen and then load new custom characters
16 September 2007
GetStartedWithPICs.qxd 8/7/2007 11:42 AM Page 17
G E T T I N G S TA R T E D W I T H P I C s
in CGRAM locations 0–7. From these new characters, you of detailing how to use the PIC16F877A MCU with MBasic
can create the animation. Since the custom characters load Pro. Best of all, his book’s CD includes a free version of the
in CGRAM quikly, the person watching the display just MBasic Pro compiler, which is limited to working with the
notices a frame change from words to large digits to PIC16F876(A). This offers you the option to take a 28-pin
animation. I’ve seen custom characters that had the old BasicATOM chip design and move it pretty easily to a
Pacman character eating dots across the screen. PIC16F876A — all for the cost of a book and a programmer
(to load the .hex file into the PIC16F876A). Check it out.
Feel free to email me with your comments at
CONCLUSION [email protected], and thanks for all of the feedback I
By no means am I declaring that I invented this custom- continue to get. I do like reading the feedback and try to
character method. In fact, there are numerous sites on the respond to all of the emails as quickly as possible. See you
Internet that refer to creating custom characters on an LCD. next month. NV
Scott Edwards (www.seetron.com)
even incorporates this type of
large-character generation into his
PIC MCU-driven serial LCD modules.
If you are really creative, you can
probably create a whole animated
cartoon on the LCD by constantly Easy Ordering In Nanoseconds
changing the custom characters. It will
potentially take a lot of memory, but
most graphic programs do.
I once again used the BasicATOM
chip, because of the simplicity of the
software and the low cost for any
reader that wants to follow along by
doing the projects. I have received
many emails from readers asking me
to pick a platform and stick with it.
Because Basic Micro (creator of the
BasicATOM) also has a Basic compiler
— which is called the MBasic
Professional compiler — this platform
offers the reader the option to start
cheap with the BasicATOM software
via a free download and a $20
BasicATOM chip (which should be
cheaper by the time you read this).
Eventually, most people will move to
programming blank PIC MCUs, to
save money on larger-volume projects.
Here’s a tip for readers: There
is a book available in the Nuts & Volts
Hobbyist Store (www.nutsvolts.com)
• The ONLY New Catalog Every 90 Days
called Programming the PIC
Microcontroller in MBasic by Jack • NEWEST Products & Technologies
Smith (this has a similar title and exact- • Over 850,000 Products Online
ly the same publisher as my PICBASIC
• More Than 330 Manufacturers
compiler book). Jack does a great job
• No Minimum Order
This book is • Fast Delivery, Same-day Shipping The Newest Products
available in our For Your Newest Designs
store on page 100.
Visit mouser.com (800) 346-6873
www.nutsvolts.com
or call 800-783-4624. The NEWEST Semiconductors | Passives | Interconnects | Power | Electromechanical | Test, Tools & Supplies
$59.95 Mouser and Mouser Electronics are registered trademarks of Mouser Electronics, Inc. Other products, logos, and
company names mentioned herein, may be trademarks of their respective owners.
September 2007 17
NutNVolt200709.qxd 8/8/2007 3:45 PM Page 18
Mad Blaster Warble Alarm DTMF Encoder Decoder Cable Polarity Checker
If you need to simply get atten- Decodes standard Touch Tones from Checks continuity AND polarity of
tion, the “Mad Blaster” is the telephones, radio, or any audio a pair of wires! Simply connect
answer, producing a LOUD ear shat- source. Detects and decodes any the remote board to one end, and the tester
tering raucous racket! Super for car single digit and provides a closure to the other end and LED’s show opens,
and home alarms as well. Drives any to ground up to 20mA. Great for shots, and polarity! Even includes auto power
speaker. Runs on 9-12VDC. remote tone control Runs on 5VDC. off! Runs on a standard 9V battery.
MB1 Mad Blaster Warble Alarm Kit $9.95 TT7 DTMF Encode/Decode Kit $24.95 MK132 Cable Polarity Checker $7.95
Power Saver Timer IR Remote Control Checker Stereo Ear Super Amplifier
Add time delay power-off to any Is your IR remote control working? Just point Ultra high gain amp boosts audio 50
of your projects or circuits! and shoot, and this kit will let you know! times and it does it in stereo with its
Momentary push button selects Confirms IR signal generation from any IR dual directional stereo microphones!
desired time delay (1H, 2H, 4H, remote and displays proper receipt on the four Just plug in your standard earphone or
8H, 24H) and LED flashes faster as time approaches. LED display. Don’t change the batteries, check headset and point towards the source. Great
On-board 10A relay. Runs on 120/240VAC. the remote first! Runs on a standard 9V battery. stereo separation besides! Runs on 3 AAA batteries.
K8075 Power Saver Timer Kit $24.95 MK137 IR Remote Checker Kit $6.95 MK136 Stereo Ear Amplifier Kit $9.95
Steam Engine & Whistle SMT Multi-Color Blinky SMT High Intensity Blinky
Simulates the sound of a vintage The ultimate blinky kit! The 8-pin micro- The SMT revival of our classic BL1!
steam engine locomotive and controller drives a very special RGB LED in Super bright SMT LED’s alternately flash
whistle! Features variable engine 16 million color combinations! Uses PWM in a brilliant display. Subminiature con-
speed and volume. Whistle blows at methods to generate any color with the micro, struction makes it perfect for badges and
a touch of a button! Great for model train setups. with switchable speed selection. SMT construction with displays. SMT construction with extra parts when you
Includes the speaker. Runs on a standard 9V battery. extra parts when you lose them! Runs on 9V battery. drop them! Includes two LR55 button cells.
MK134 Steam Engine & Whistle Kit $10.95 SBRGB1 SMT Multi-Color Blinky Kit $29.95 BL2 SMT High Intensity Blinky Kit $17.95
Did You Know... ✔ It’s impossible to give you full specs on these products in a 1” space!
✔ A lot of our kits are also available “factory assembled and tested”, if you don’t want to build it!
✔ We have over 350 products currently available, and all those don’t fit here!
Surface Mount Technology (SMT) has This is a beginner’s Not only will you learn
become a way of life for electronics. Virtually project specifically soldering and desol-
all new high tech products utilize SMT design designed to teach you the fundamen- dering but you will also learn compo-
and components. Even our latest Ramsey kits include various SMT components. tals of soldering and working with nent identification and color codes.
There are two problems with SMT: First, the parts are extremely small, at times printed circuit boards.
the size of a pin head! Therefore, you need to have the proper tools, not only to With 163 solder points, you will learn
hold them and solder them, but to see them! (Check out the tools section at Like any skill, good soldering requires and practice standard soldering, close
ramseykits.com for help!) Secondly, unlike “through hole” parts, SMT components practice as well as an understanding of tolerance soldering, tack soldering and
are soldered directly on the surface of the PC board (hence the name SMT!) This the principles involved. You will desoldering. Plus you will learn com-
is an entirely new method of soldering, and it takes practice to get it right. Trust become familiar with PC boards, the ponent identification and complete
me, I’ve created a number of solder bridges myself when I first started soldering how’s and why’s of soldering, compo- color codes. Even includes a color
SMT components! nents, component installation, and code calculator! Also learn voltage and
troubleshooting soldering problems resistance analysis in circuits. Com-
Taking this course and practicing on the neat little kit will prepare you for the (including solder bridges!) Project prehensive manual includes written
future in electronics. Includes the PC board, all the SMT and other components runs on a standard 9VDC battery, not and visual exams. Project runs on a
required, and a comprehensive training course covering all aspects of SMT solder- included. standard 9VDC battery, not included.
ing, desoldering, removing, and component placement. The finished project is a SP1A Soldering Lab $9.95 SP3B Soldering-Parts Lab $9.95
neat little “Decision Maker” that includes 6 flashing SMT LEDs, complete with a
professional overlay panel. The finished Decision Maker runs on a standard 9VDC
battery, not included. Non-Conductive Tweezers
SM200K Practical SMT Soldering Course & Lab $20.95 ✔ Great for SMT and small parts
✔ ESD safe!
AM/FM IC Radio & Training Course We’ve discussed tweezers and magnifiers while working
✔ Learn all about AM/FM radio with SMT components. Working with some highly sensitive
design and theory! components our engineers asked for some ESD safe tweezers. We looked, we
✔ Build a high performance found, and they are a life saver! This set of 4 non-conductive tweezers are perfect
radio with an IC! for any static sensitive devices you may be working on. And...they are priced right!
✔ Step by step assembly and VTTWSET2 Non-Conductive Tweezers Set $3.95
test procedures
✔ Great for student projects!
This Superhet 108 AM/FM Radio Electronic Learning Labs
Kit is a “superheterodyne” receiv-
er of the standard AM (amplitude PL200
modulation) and FM (frequency modulation)
broadcast frequencies. The unique design of the Superhet 108 includes an inte-
grated circuit (IC), 9 transistors, 4 diodes, and other related resistors, capacitors,
coils, and misc. parts. Because good soldering practices are important, a soldering PL130
guide is also provided as well as a component color code and pictorial identifica- PL300
tion chart. ✔ Learn and build!
✔ 130, 200, 300, & 500 In One! PL500
The actual assembly is broken down into 9 sections. The theory of operation for ✔ Super comprehensive training manuals!
each section, or stage, should be read before the assembly is started. This will Whether you want to learn the basics of electricity, the theory of electronics, or
provide the student with an understanding of what that stage has been designed advanced digital technology, our lab kits are for you! Starting with our PL130, we
to accomplish, and how it actually works. After each assembly you will be give you 130 different electronic projects, together with a comprehensive 162
instructed to make certain tests and measurements to prove that each section is page learning manual. A great start for the kids...young and old! Next, check out
functioning properly. If a test fails to produce the proper results a troubleshooting the PL200, that gives you 200 very creative and fun projects, and includes a neat
guide is provided to help you correct the problem. interactive front panel with 2 controls, speaker, LED display and a meter.
After all of the stages have been built and tested a final alignment procedure is From there, step up to our PL300, which gives you 300 separate electronic proj-
provided to peak the performance of the receiver and maximize the Superhet ects along with 165 page learning and theory manual. The PL300 walks you
108’s reception capabilities. Runs on a standard 9VDC battery, not included. through the learning phase of digital electronics.
(This is today’s version of the “5 tube superhet radio I built in Mr. Baehre’s 9th
grade electronics shop class!) If you’re looking for the ultimate lab kit, check out our PL500. Includes a whop-
AMFM108K AM/FM Integrated Circuit Radio & Training Course $34.95 ping 500 separate projects, a 152 page starter course manual, a 78 page
advanced course manual, and a 140 page programming course manual! The
PL500 covers everything from the basics to digital programming!
3-in-1 Multifunction Lab Learn all about electronics theory, and digital technology the fun way and build
✔ Digital multimeter! some neat projects!
✔ Regulated power supply!
✔ Temp controlled soldering station! PL130 130 In One Learning Lab Kit $42.95
✔ RoHS lead-free compatible! PL200 200 In One Super Fun Learning Lab $54.95
PL300 300 In One Advanced Learning Lab Kit $69.95
Take a close look! On your left is a multi- PL500 500 In One Super Learning Lab Kit $169.95
function 3½ digit digital multimeter. Its large backlit LCD display can be seen
from anywhere on your bench while you’re working. The DMM also features
built-in transistor, diode, and continuity testing, data hold, and audible alarm.
Next up, the regulated lab DC power supply. Switch selectable ranges of 3V, 4.5V,
6V, 7.5V, 9V, and 12V provide a continuous duty current of 1.5 amps with a 2 amp MORE than just friendly on-line ordering!
peak! Features both overload protection and overload indication. Clearance Specials, Ramsey Museum, User Forums, Dealer Information, FAQ’s, FCC
To the right we have a high quality temperature regulated soldering station. The
Info, Kit Building Guides, Downloads, Live Weather, Live Webcams, and much more!
24V low voltage iron features an isolated ceramic 48 watt temperature controlled
element. Front panel control gives you variable tip temperature control from
150°C to 450°C and LED indication of power-on and heating-on. Runs on 120VAC.
LAB1U 3-in-1 Multifunction Lab $119.95
www.ramseykits.com
800-446-2295
Get The Catalog! Where ✦ Build It!
Get the latest 2007 Ramsey Hobby Catalog! 590 Fishers Station Drive Electronics ✦ Learn It!
96 value packed pages of the neatest Victor, NY 14564 Is Always ✦ Achieve It!
(800) 446-2295
goodies around! Order yours on-line today (585) 924-4560 FUN! ✦ Enjoy It!
or give us a call! Or download the PDF at
Prices, availability, and specifications are subject to change. Not responsible for typos, stupids,
www.ramseykits.com. printer’s bleed, or dorm room parties. Robin wanted the ad copy early again, so this month’s
typo’s are on her! Visit www.ramseykits.com for the latest pricing, specials, terms and conditions.
Copyright 2007 Ramsey Electronics, LLC...so there!
NearSpace.qxd 8/6/2007 12:47 PM Page 20
SPACE
NEAR
N E A R S PA C E
0.0306 volts per percent of relative perature sensor (for the interior of the ■ FIGURE 2. The
humidity. Exercise caution when using BalloonSat) is mounted on a separate placement of parts
this sensor and do not touch its face; printed circuit board (PCB). Since the for the near space
moisture and skin oil can damage the rest of the weather station is mounted weather station.
sensor. You can find the datasheet for outside of the BalloonSat, the
this sensor at Phil Anderson’s website BalloonSat airframe needs an opening
(www.phanderson.com/hih4000.pdf). to pass the cable between the two
I found a distributor for this sensor at PCBs. To keep this opening in the
Newark (www.newark.com). BalloonSat airframe small, I designed
The SM5812 is a silicon micro- the external portion of the weather
electric mechanical system (MEMS) station to be connected to the internal
based pressure sensor. Inside the portion with a header and receptacle.
sensor is a vacuum sealed “cup” with There’s nothing difficult about
a thin silicon lid. As the air pressure on assembling the miniature near space
the sealed cup changes, the stress of weather station. However, I would still
the silicon lid also changes. Stress in recommend placing lowest lying
the silicon lid changes its resistance components first, but there are no
and therefore, the voltage dropped tight fitting components that require
across it. The circuitry in the SM5812 you do it this way. The additional
calibrates and amplifies the output holes in the PCB’s ground plane are
voltage of the sensor. The sensor pro- strain relief for the wires in the
duces 0.5 volts at zero PSI of pressure weather station cables. So, pass wires
and 4.5 volts at 15 PSI. through those holes before you solder
Between the two extremes, the them to the PCB. I would recommend
output voltage is linear with respect to making the power wire red and the
pressure. You can find more information ground wire either green or black.
on this sensor at the Silicon Cut the five wires that you soldered
Microstructures website (www.si- to the external PCB to a length of six
micro.com) under the SM58 product inches. The five wires terminate with a
series. The SM5812 is available from 1x5 header to form a unified cable that
Servoflo Corporation (www.servoflo. connects the external weather station to
com). Since Servoflo is not ready to the internal temperature sensor through
take online orders, call them at (866) its receptacle. I prefer to make my cable
830-9572 to order a SM5812. by tinning the short pins of the 1x5 male the soldered wire and header. Now you
header and the 1/4 inch long bare ends only have to repeat this four more times.
of the wires. Then slide thin heat shrink The internal temperature sensor
ASSEMBLING THE over the ends of the wires and press a board has its own cable that plugs the
MINIATURE NEAR SPACE tinned wire to a tinned header pin. weather station into the BalloonSat’s
WEATHER STATION When the pin and wire are heated, the ADC channels. I make this cable the
solder in each fuses together. Remove same way as the last one (except
You’ll notice that the second tem- the heat and slide the heat shrink over there are six wires in this cable). If you
■ FIGURE 3. This is the external portion of the weather station ■ FIGURE 4. The internal portion of the weather station.
(PCB and five components). The newer version described in The PCB has a LM335 temperature sensor and a receptacle.
this month’s column includes a filtering capacitor that was The header soldered to the end of the external portion of the
left out in the original design. weather station terminates in a 1x5 header pin. Since I didn’t
have a three row header, I’m using two 2x3 headers (on the
left) to connect the weather station to the BalloonSat Flight
Computer’s ADC channels.
September 2007 21
NearSpace.qxd 8/6/2007 12:47 PM Page 22
■ FIGURE 6 ■ FIGURE 7
22 September 2007
NearSpace.qxd 8/6/2007 12:47 PM Page 23
N E A R S PAC E
■ FIGURE 8 ■ FIGURE 9
value of 41) and then multiplied by temperature of -60 degrees Fahrenheit. ors (black, white, silver, and light blue).
100% to calculate the relative humidity. In the winter, I typically see it lower to To reduce variations in the experiment, I
Once you’ve finished editing your 40,000 feet and drop down to -90°. flew all four cubes on the same mission.
data in Excel or other spreadsheet, The latitude does affect the altitude That meant I needed four temperature
you need to include a column for and temperature of the tropopause. sensors for the mission. Instead of build-
altitude. You can look at the TNC log The relative humidity chart in ing a temperature sensor for each cube,
from the mission to get this informa- Figure 7 shows us that the air gets drier I designed the following circuit board.
tion or calculate it by determining the with increasing altitude. But notice
climb rate of the near spacecraft and that the relative humidity spiked three
multiplying by mission elapsed time. times at 8,000, 12,000, and around
ASSEMBLING THE
When you’ve added the altitude to 35,000 feet. I don’t recall the weather TEMPERATURE
the spreadsheet, you can generate conditions on this flight, but I suspect SENSOR ARRAY
charts like the ones in Figures 6 there were clouds at these altitudes.
through 9 (these charts come from a The temperature chart in Figure 9 There’s no preferred order when
mission launched in late 2006). shows that the interior of the soldering the array together. Do note
The three I like best are Figures 7, BalloonSat stays significantly warmer
8, and 9 (the pressure seems boring to than the outside air. The airframe of
me). So let’s take a closer look at each this particular BalloonSat was 1/2 inch TEMPERATURE SENSOR
of them. Notice that the air tempera- thick Styrofoam. At 80 minutes ARRAY PARTS LIST
ture decreased with increasing altitude mission elapsed time, the balloon
• Four 1K resistors
until the BalloonSat reached an altitude burst. The movement of air over the • Four LM335 precision temperature
of 50,000 feet. From there, the air tem- BalloonSat as it fell chilled the external sensors
perature rises with increasing altitude. temperature sensor and cooled the • Thin gauge wire
The air temperature cools in interior of the BalloonSat. • A 3 x 4 male header (or equivalent)
the troposphere and rises in the • Thin heat shrink
stratosphere. The transition between • Printed circuit board (see the copper
the two is called the tropopause. The
TEMPERATURE SENSOR pattern on the Nuts & Volts website
troposphere cools with increasing ARRAY at www.nutsvolts.com)
altitude primarily because the balloon
is moving away from its major source The last sensor I want to dis-
of heat — the earth’s surface. The strat- cuss this month is an array of tem-
osphere, on the other hand, warms perature sensors (Figure 10). Many
with increasing altitude because the years ago, I became curious about
balloon is moving closer to its primary how the color of my near space-
source of heat — the sun. craft would affect its internal tem-
Ozone in the stratosphere blocks perature. To find out, I created four
some ultraviolet radiation and identical foam blocks and covered
converts it into thermal energy. So it is them in materials with different col-
the presence of ozone that we’re
detecting above 50,000 feet when we ■ FIGURE 10. This is an older version
measure an increasing temperature. of the temperature sensor array
than I’m describing in this column.
In summer time, I typically see the The new design incorporates strain
tropopause at 50,000 feet and with a relief into the PCB.
September 2007 23
NearSpace.qxd 8/6/2007 12:48 PM Page 24
N E A R S PAC E
26 September 2007
Full Page.qxd 8/8/2007 3:52 PM Page 27
www.Jameco.com
Or call 800-831-4242 anytime
©Jameco Electronics. *According to their web sites on July 23, 2007. Trademarks are the property of their respective owners.
Q&A.qxd 8/6/2007 2:37 PM Page 28
✓ Fly Zapper.
In this column, I answer questions about all
aspects of electronics, including computer ●
hardware, software, circuits, electronic theory,
troubleshooting, and anything else of interest
to the hobbyist. Feel free to participate with
✓ Sam’s Photofact.
●
your questions, comments, or suggestions.
Send all questions and comments to:
✓ Linear Ramp.
●
Q&[email protected]
— Anonymous
1) Why is the signal input between circuit by assuming a constant 0.6 volt This site will give you many
the diodes?
QU E ST I O N S & A N S W E R S
■ FIGURE 2
nal will be down in the noise of light- linear acceleration/deceleration ramp reversed. You could use a five volt pow-
ning and automotive ignition. A better where an instant voltage change at the er supply instead. A five volt change in
solution is to generate an accurate 60 input to the circuit (from say five volts the output of the A op-amp, caused by
Hz from a crystal as shown in Figure 2. to eight volts) would produce that a three volt input, takes 5.5 seconds.
The crystal can be pulled a little so same change at the output of the cir- You can increase the time by increas-
if the frequency is off, you can increase cuit, in the range of five to 10 seconds. ing R4 or using a larger capacitor (C1).
C1 and C2 to lower the frequency or It is important to me that this This circuit cannot maintain zero
decrease them to increase the fre- ramping up (or down) be linear. speed for very long because it is not
quency. The crystal tolerance is typically Simply charging a capacitor through a possible to match the reference
50 ppm. I divided the crystal frequency resistor won’t do. I would prefer to voltage perfectly. The speed will drift
down to 120 Hz then divided by two use simple gates or op-amps and/or higher over time in one direction or
because the 4060 does not have a Q11 discrete components, as I don’t get the other. Some kind of tachometer
output. The added advantage is that the along well with microprocessors or feedback would be needed to main-
output is a symmetrical square wave. any of their relatives. tain zero speed.
The procedure for finding the Any help or suggestions would be
divider outputs to decode the frequen- most appreciated.
cy is this: Divide the input frequency — Clark W. Kuhl
FLY ZAPPER
by the output frequency to find the I am looking for a small size
division factor (N). This must be a
whole number. Find the highest power
of 2 that can be subtracted from N. Do
the subtraction; the result being a new
value for N. Repeat until the result is
A
The circuit in Figure 3
provides the linear ramp that
you want. The B section of
the op-amp provides a five
volt reference so the motor can be
Q fly zapper, but I can’t find
one. It is either a big
commercial unit, or it uses
some scented refills.
How hard would it be to make
zero. The powers of 2 that you use are
the Q outputs needed to decode.
LINEAR RAMP
I enjoyed T.J. Byers’ column
RECTANGULAR HOLES
I have a very simple question. I
build a lot of simple nifty electronic
gadgets, many from Nuts & Volts and
usually put them in plastic project
boxes. I have never figured out how to
30 September 2007
Q&A.qxd 8/6/2007 2:40 PM Page 31
SHOWCASE
PP:KLWH
ZDWHUFOHDU
/('9
PFG
$%
VHFRQGYRLFHUHFRUGHUSOD\EDFNPRGXOH
SUHDVVHPEOHG$
7KH9HOOHPDQ3HUVRQDO6FRSH
LVDFRPSOHWH06VSRUWDEOH
QGV
7KRXVD
L WH P VRQ
PRUH
E V LWH
RXUZH
$15
Very Schmart!
www.schmartboard.com
NewProductsSep07.qxd 8/7/2007 2:27 PM Page 32
NEW
■ HARDWARE
■ SOFTWARE
■ GADGETS
■ TOOLS
P R O D U C T S
LOW COST DDS American Beauty Soldering Tools.
American Beauty Soldering Iron
FUNCTION Maintenance Kits include everything
GENERATOR necessary to remove flux residue,
contamination, and oxidation that
32 September 2007
NewProductsSep07.qxd 8/7/2007 2:28 PM Page 33
■ H A R D W A R E ■ S O F T W A R E ■ G A D G E T S ■ T O O L S
Called the Model 8063, this new several ways: the model 8063’s VXI-11 Standard includes the
interface box provides 48 digital I/O VXI-11 Service can be accessed by necessary RPCGen header files for
lines that the user can control from LabVIEW, VEE, Visual Basic, and C adding RPC calls to any program. ICS
any computer with an NIC interface language application programs that provides a VXI-11 keyboard program
or from a TCP/IP network. Typical ap- make VISA calls by selecting the which lets users with a WIN32
plications for the 8063 are interfacing 8063 as the TCP/IP resource. Both computer interactively control the
digital devices, controlling relay Agilent and National Instruments 8063 and other VXI-11 compatible
matrices, or acting as an Ethernet provide VXI-11.3 compliant VISA instruments without having to write
interface for devices or instruments libraries. Linux, Unix, and other a program.
with digital interfaces. programmers who do not want to ICS’s 8063 Ethernet-to-parallel
The Model 8063 is an Ethernet-to- use a VISA library can access the interface has several unique features
parallel interface that provides 48 8063’s VXI-11 Service by RPC calls which include: the 8063 is 100%
parallel I/O lines that can be from the application program. The VXI-11.3 compliant (which is an open
configured as inputs or outputs in
eight-bit bytes. Data transfer can be
done by a combination of three
methods, depending upon the needs
of the devices connected to the 8063.
First is by transferring data directly to
or from a specific byte, second by
strings of data characters to or from
multiple bytes, or third, by setting or
reading individual bits in a byte.
Handshake lines are provided for
synchronizing the data transfers or for
latching data into external devices.
The 8063 can also monitor 15 input
lines and generate VXI-11 Service
Request messages when an enabled
line changes state. The 8063 is an
IEEE-488.2 compatible interface that
responds to the 488.2 common
commands and uses SCPI commands
to configure its digital interface. The
user can customize the 8063’s IDN
message to integrate the 8063 into
a system. All settings are saved in
Flash memory.
The Model 8063 is a VXI-11.3
compliant interface. VXI-11 is a
communication standard developed
by the VISA consortium in 1995
in conjunction with the VISA
Specification. The VXI-11.3 sub-
standard covers TCP/IP-to-Instrument
servers like the 8063 and is used for
LXI devices. Communication with the
8063 is via VXI-11 RPC protocol over
a TCP/IP network.
The 8063 can be controlled
September 2007 33
NewProductsSep07.qxd 8/7/2007 2:26 PM Page 34
34 September 2007
Full Page.qxd 8/8/2007 3:57 PM Page 35
Ball.qxd 8/6/2007 2:45 PM Page 36
PROJECTS ●●●●
■ THIS MONTH’S PROJECTS
Keep Those Components Cool . .36 KEEP THOSE
Flight Recorder — Part 2 . . . . .41
36 September 2007
Ball.qxd 8/6/2007 2:45 PM Page 37
BY STUART BALL
■ FIGURE 1. Schematic of
the fan controller circuit.
T1 is a thermistor mounted
to the component needing
to be cooled.
September 2007 37
Ball.qxd 8/6/2007 2:45 PM Page 38
38 September 2007
Ball.qxd 8/6/2007 2:46 PM Page 39
September 2007 39
Ball.qxd 8/6/2007 2:46 PM Page 40
40 September 2007
Bessant2.qxd 8/7/2007 2:38 PM Page 41
FRECORDER
LIGHFORT Last month, we
introduced you to the
basics of model rocketry
and outlined the
hardware design of a
MODEL ROCKETRY
PART 2
compatible flight
recorder.
September 2007 41
Bessant2.qxd 8/7/2007 2:39 PM Page 42
■ FIGURE 2. Three-axis
angle below the chute, and then
accelerometer connections began a relatively sedate descent.
to sensor port. Touchdown at 18 seconds appears to
have been surprisingly gentle. The
0.1 inch pads. Silicone nose cone eventually came to rest on
glue was used to mount its side, with the vertical accelerome-
the breakout board ter measuring near zero g.
onto the flight recorder If we now turn our attention to
that seemed to provide the Y and Z traces, we see that they
reasonable rigidity understandably show lower levels of
while offering the acceleration. They do, however,
accelerometer some indicate that the rocket performed a
Signal conditioning circuitry is there- protection against excessive g-forces. definite ‘wiggle’ after leaving the
fore limited to the simple RC low-pass Figure 3 is an example plot of launch rail that decayed in amplitude
filters that are included as standard on three acceleration channels measured over the next three seconds.
the ADC inputs of the sensor port. during a model rocket flight. The verti- Following touchdown, the horizontal
Figure 2 shows the connections cal acceleration trace is labelled ‘X’ and traces seemed to show the nose cone
required between the breakout board the two horizontal traces are labelled rolling after touchdown. It is possible
and the sensor port. Although it is pos- ‘Y’ and ‘Z.’ All three accelerometer that the initial wiggle and ground roll
sible to operate with different sensitiv- channels were sampled at 100 Hz for were both caused by the effects (upon
ity on each axis, by changing the state 27 seconds, which only used 25% of the fins and chute) of a moderate
of the control pin ranges between suc- the available storage capacity. side-wind at the launch site.
cessive ADC readings, the associated If we start by looking at the verti-
settling time would adversely affect cal channel, the plot shows that it was PICAXE Firmware
the sampling rate. The range of all briefly overloaded at engine ignition
three channels was therefore fixed at but could easily accommodate the Figure 4 lists the PICAXE firmware
the maximum specified range of ±6g. following level of sustained thrust. At that was used to record three channels
(However, the ADC accepts signal approximately 1.5 seconds into the of acceleration during flight and export
levels that exceed this range.) flight, acceleration dropped abruptly the data to Microsoft Excel. The func-
The accelerometer is only avail- with propellant burnout. The rocket tion of the trigger, record, and playback
able in a difficult-to-hand-solder surface then coasted upwards for about 3.5 routines were explained in last month’s
mount package, but this limitation was seconds before the vertical channel article. Note that the setfreq m8 com-
overcome by using a small breakout was overloaded by the nose cone mand doubles the default PICAXE
board from Spark Fun Electronics ejection and chute deployment. clock rate to 8 MHz, which means that
(www.sparkfun.com) that has the Things then became a little wild until data is sent at 9.6 kbaud (not 4.8 kbaud
MMA7260 connections brought out to the nose-cone dangled, inverted at an as listed). The SelmaDAQ macro is
used in Excel to accept data and place
it in the spreadsheet for subsequent
processing and display.
Martin Hebel, of SelmaWare
Solutions and a professor in the
Electronic Systems Technologies pro-
gram at Southern Illinois University
Carbondale, wrote SelmaDAQ. This
application only uses a fraction of the
capabilities of this extremely flexible
software tool, which may be down-
loaded from www.selmaware.com
Additional Sensors
As horizontal accelerometer
channels normally provide less
42 September 2007
Bessant2.qxd 8/7/2007 2:39 PM Page 43
September 2007 43
Bessant2.qxd 8/7/2007 2:39 PM Page 44
sampling the amplified output from a pressure IC from VTI Technologies. Conclusions
magnetoresistive sensor that is used to Pressure and temperature output data
measure the vertical component of are calibrated and compensated With the exception of the sun and
the Earth’s magnetic field in order to internally. This device operates from a magnetoresistive sensors, all the
detect when the rocket tips over at 2.4V-3.3V supply and has the poten- above examples could be connected
apogee. Honeywell and Phillips pro- tial to provide a more accurate alti- directly to the sensor port without
duce devices that have the required tude profile than could be derived by additional signal conditioning or
0.5 gauss sensitivity for this task (but integrating vertical acceleration data. power supply circuitry.
the output signal would have to be The SHT11 humidity and temper- The flight recorder is a compact
amplified before feeding the ADC). ature IC from Sensirion AG is another and low power instrumentation tool
By comparing the recorded smart sensor that has a two-wire serial that can be rapidly configured to
magnetic field strength and vertical bus. However, it is not I2C compatible accommodate a range of applications.
acceleration data, it should be possible and would have to be interfaced by In addition, the use of SelmaDAQ
to measure any delay between apogee ‘bit banging’ sensor port I/O lines. makes spreadsheet data import,
and nose cone ejection. This informa- This device operates from a 2.4V-5.5V processing, and display an almost
tion will help determine the engine supply and the output data is calibrat- seamless task. NV
delay charge required to deploy near ed and compensated internally. It
the rocket’s minimum speed, in order to could be used to study microclimates
reduce the risk of damaging the chute. by measuring the relative humidity This book is
Having employed all three of the and temperature of a column of air available in our
store on page 99.
flight recorder’s ADC channels in the (e.g., to obtain a profile through a
Visit
above examples, we still have the layer of mist). However, because the
www.nutsvolts.com
option of interfacing sensors via the sensor’s update rate is in the order of
or call 800-783-4624.
sensor port’s serial I2C bus. A good seconds, measurements are best
example of an I2C compatible smart taken during a slow descent under a $24.95
sensor is the SCP1000 barometric generously-sized parachute.
44 September 2007
Full Page.qxd 8/8/2007 4:01 PM Page 45
ew
675+ N s
t
Produc
ages
430+ P r
lo
Full Co
Visit us at
www.jaycar.com/catalog and
obtain your free copy of our 430+ page, full
Universal Speaker color catalog. We have an extensive range of
electronics kits and the best in
Protection and Muting innovative gadgets.
Module Kit
KC-5450 $17.50 + post & packing
Protects your expensive speakers Water Level Indicator Kit POST AND PACKING CHARGES:
against damage in the event of catastrophic KC-5449 $20.50 + post & packing Order Value Cost Order Value Cost
amplifier failure such as a shorted output This simple circuit illuminates a $25 - $49.99 $7.50 $200 - $499.99 $60
transistor. In addition, the circuit also banishes string of LEDs to quickly indicate $50 - $99.99 $20 $500+ $75
those annoying thumps that occur when many the water level in a rainwater tank. $100 - $199.99 $40
amplifiers are switched on or off, especially when The more LEDs that illuminate, the Max weight 12lb (5kg). Heavier
the volume is set to a high level. The design also higher the water level is inside the tank. parcels POA. Minimum order $25.
incorporates an optional over temperature The input signal is provided by ten Note: Products are dispatched from Australia,
heat-sensor that will disconnect the sensors located in the water tank and local customs duty and taxes may apply.
speakers if the output stage connected to the indicator unit Beat w How to order:
gets too hot. Configurable restricti ater Phone: Call Australian Eastern Standard Time
via-light duty figure-8 cable. Kit water ons with a
for supply voltages between supplied with PCB with overlay, tank Mon-Fri on 1800 784 0263
22VDC-70VDC. Supplied with great kand this Email: [email protected]
machined case with screenprinted lid it!
a silk screened PCB, relay and Post: PO BOX 6424, Silverwater NSW 1811. Australia
and all electronic components. Expect 10-14 Days For Air parcel delivery
all electronic components. • Requires: 8mm (OD) PVC hose/pipe (length
required depending on depth of tank)
4 Channel Guitar Amplifier Kit Requires 9-12VDC or AC wall Fuel Cut Defeat Kit
KC-5448 $57.50 + post & packing
adaptor (Jameco #252751 $12.05) KC-5439 $11.75 + post & packing
The input sensitivity of each of the four channels
This simple kit enables you to defeat the factory
is adjustable from a few millivolts to over 1 volt,
so you can plug in a range of input signals from a IR Remote Control Extender MKII fuel cut-out signal from your car's ECU and
KC-5432 $14.50 + post & packing allows your turbo charger to go beyond the
microphone to a line level signal from a CD
Operate your DVD player or digital decoder using typical 15-17psi factory boost limit.
player etc. A headphone amplifier circuit
its remote control from another room. It picks up Note: Care should be taken to ensure that the
is also included for monitoring purposes.
the signal from the remote control and sends it boost level and fuel mixture don’t reach unsafe
A three stage EQ is also integrated,
via a 2-wire cable to an infrared LED located close levels. Kit supplied with PCB, and all electronic
making this a very versatile mixer
to the device. This improved model features fast components.
that will operate from
12VDC. Kit data transfer, capable of
includes PCB with transmitting Foxtel digital Improv
remote control signals model ed
overlay and all fo
electronic using the Pace 400 2007 r
components. series decoder. Kit
supplied with case,
screen printed front
Stereo VU and Peak Meter Kit Com
panel, PCB with two kitbine these
KC-5447 $40.75 + post & packing overlay and all most s to get th
Accurately monitor audio signals to prevent signal electronic components. Variable Boost perfo cost effecti e
rma ve
clipping and ensure optimum recording levels.
Requires 9VDC wall adaptor on thence increase
This unit is very responsive and uses two 16- Kit for marke
t!
(Jameco #252751 $12.05)
segment bargraphs to display signal levels and Turbochargers
transient peaks in real time. There are a number 2 Channel USB Oscilloscope KC-5438 $11.75 + post & packing
of display options to select, and both the signal QC-1930 $149.50 + post & packing It's a very simple circuit with only a few
threshold and signal level calibration for each Using Plug 'n Play USB technology and providing components to modify the factory boost levels.
segment are adjustable. Kit supplied with PCBs, full optical isolation from the computer, this It works by intercepting the boost signal from
LCD and all electronic components. Accuracy oscilloscope is easy to setup and use, as well as the car's engine management computer and
within 1dB for signals above -40dB. providing protection for the computer. modifying the duty cycle of the solenoid signal.
• Case not included use HB-6082 $5.50 The software is a fully featured chart Kit supplied in short
recorder, function form with PCB and
generator, logic overlay, and all
generator, logic specified
analyser, and electronic
spectrum analyser components.
all in one easy to
use package. See
Requires 9-12VDC wall adaptor website for
(Jameco #252751 $12.05) specifications.
Log on to
www.jaycar.com/catalog 430+
page
for your FREE catalog! Catalog
1-800-784-0263
(Monday - Friday 09.00 to 17.30 GMT + 10 hours only). All
For those who want to write: 100 Silverwater Rd
Silverwater NSW 2128 Sydney AUSTRALIA
prices in
USD
w w w. j a y c a r. c o m
Simpson.qxd 8/6/2007 10:43 AM Page 46
●●●●
When I first started this
series, I knew I wanted
to build a wireless
weather station. In no
way could I have
imagined how well
the overall system would
C O N T R
YOUR WORLD
O L
function, nor could I have
envisioned its versatility. Build a Wireless Weather System: Part 1
have to run a cable to the location With a wireless system, all these
If you have already built where you want to place the problems will be solved. The only
display. This can be problematic and cable that needs to be run is for a
a PC or microcontroller- time consuming. power source. This is simply two
based weather station wires and in many cases can be a
connected to a 1Wire 2) You are limited to the length very short run. You can even power
of the cable and the number of your weather pole with a set of solar
network, you may be items you can reliably place on cells and a rechargeable battery.
asking yourself why you the cable. The heart of our wireless system
is a Zigbee mesh network. You have
should go to all the effort 3) If you want to add additional probably read about mesh
and expense of converting sensors to various locations, this can networks, but this is your chance to
it to wireless. prove almost impossible if you don’t actually build one and put it to
have access to attic or basement work. Once the network is built, you
areas. will be able to add sensors or dis-
plays to any location in your home.
4) With a wired system, In addition, we are going to add
you generally only have extra features like the ability to
a single display system. create as many display systems as
we like without
having to change
NOTE: the network in any
The parts list for this project will be way. For instance,
included in Part 2 next month. I can add a PC
interface to the
system by simply
■ FIGURE 2
adding a Zigbee
unit to an RS-232
card and I can start
collecting data. At
the same time, I can
build a small LCD
display for my
desktop. I can add
a large LED sign
display to the front
■ FIGURE 1
entrance of my lab
46 September 2007
Simpson.qxd 8/6/2007 10:44 AM Page 47
BY MICHAEL SIMPSON
September 2007 47
Simpson.qxd 8/6/2007 10:45 AM Page 48
48 September 2007
Simpson.qxd 8/6/2007 10:46 AM Page 49
• PC Interface Satellite
• Indoor Weather Satellite
• Outdoor Weather Satellite
PC Interface Satellite
Since the PC interface satellite is
nothing more than a USB or RS-232
development board connected to the
PC, we already have one of our ■ FIGURE 9b
satellites. The USB development
board shown in Figure 9a is a great
board for the PC interface satellite. was featured in the July issue of
Since it’s powered directly by the USB this series. ■ FIGURE 10
port, it’s simple to connect. The only The components needed for this
problem with using this board is that satellite are:
when the PC is powered down, we
lose the ability for this satellite to act • DiosPro 28 chip
as a router. If this is a problem, you • Dios Carrier 1 kit (Note: This is built
can always plug it into a powered USB with the headers facing up.)
hub. If you decide to use the RS-232 • One amp regulator kit
development board shown in Figure • XBee module
9b, you will need to connect the • XBee interface board
included AC adapter. • Hobby Boards or SparkFun pressure
I recommend that you mount the sensor
development boards between two • Humidity gauge (optional)
pieces of plastic as shown in Figures • AC adapter
9a and 9b. This will protect your • PlexiGlass and standoffs
board from shorts and will allow you • Double sided foam tape
to stand the board on end. Figure 10 • SchmartBoard jumpers
shows my PC interface satellite sitting
on one of my shelves. Notice that I listed an XBee
interface board. This is a board that
Indoor Weather Satellite you will need to build. It will provide
You will need a couple of sensors the 5 to 3.3 volt converter needed
indoors as part of your weather to connect the microcontroller. On
station. As a minimum, I recommend the Kronos Robotics website, there
a barometric pressure gauge and a are four application notes showing
temperature sensor. I also added a how to build various interface boards: use, but types 2 and 3 will work just as
humidity gauge to mine. Since we well. Next month in Part 2, we will go
need a coordinator module on our www.kronosrobotics.com/Projects/ step-by-step in the overall assembly
network, the indoor satellite is the MaxStreamInterface1.shtml
perfect candidate. Its job is to set up
the network routing for all the other www.kronosrobotics.com/Projects/
modules (routers) on the network. MaxStreamInterface2.shtml
The whole unit shown in Figure
11 is controlled by a DiosPro 28. The www.kronosrobotics.com/Projects/
DiosPro can talk directly to one or MaxStreamInterface3.shtml
more 1Wire networks, as well as to
various other sensors. Since I am using www.kronosrobotics.com/Projects/
a Hobby Boards pressure gauge, a 14 MaxStreamInterface4.shtml
VAC adapter is needed to power this
satellite. As an option, you may also In my opinion, the type 4 ■ FIGURE 11
use the SparkFun pressure sensor that interface is the smallest and easiest to
September 2007 49
Simpson.qxd 8/6/2007 10:46 AM Page 50
Satellite
Display Units
One of the advan-
tages of building a
wireless weather station is
• DiosPro 28 chip that you can tap into any of the data
■ FIGURE 12
• Dios Carrier 1 kit (Note: This is built being transmitted. I have created a very
with the headers facing up.) simple protocol and various DiosPro
and testing process of this satellite. • Xbee module and PC routines to parse the network
• XBee interface board data for just about any display system
Outdoor Weather Satellite • SchmartBoard jumpers you might want to include.
The outdoor weather satellite • SchmartBoard .1” prototype board The LED display shown in Figures
collects all of the data from the instru- • 5V regulator chip 13 and 14 is a Dios LCD board with
ments on our weather pole and trans- • Two 100 µF capacitors a XBee module mounted on the
mits the data to our mesh network. All • .1 µF capacitor bottom, using one of the various
the components that make up this • 1K resistor interfaces. This particular display uses
satellite must fit in a weather-tight box a single button to toggle through the
like the one shown in Figure 12. If you Since space is at a premium with many different display items. It even
followed along with this series, you the outdoor satellite, you need to counts lightning strikes collected by
saw how I built a weather station build the Type 4 XBee interface board. the outdoor satellite and keeps track
using various 1-Wire components. We You can find a complete application of rain fall totals.
will utilize this interface as well with note explaining the process at www. The display in Figure 15 is the
our outdoor weather satellite. The kronosrobotics.com/Projects/Max same LCD carrier board, but it has
main advantage that we gain is that StreamInterface4.shtml. a graphic LCD attached. In this
once the DiosPro is programmed, you I also used a SmartBoard proto- particular display, I collect the data
need only supply 7-12V to the pole type board to build a one amp regula- given by the indoor satellite and
and the rest is done for you. You may tor, as well as the 1-Wire bus interface. display a 12 hour forecast.
also use a battery and a solar cell to There is plenty of room on this board Figure 16 shows a BetaBrite LED
remove even these requirements. for any other circuitry you might want sign connected to a Dios Carrier
You will need the following to add to this satellite. For instance, board that scrolls real-time weather
components for the outdoor weather you may want to use the built-in 10-bit data across the screen.
satellite: A-to-D (analog-to-digital) ports on the The beauty of these displays is
■ FIGURE 14
■ FIGURE 15
■ FIGURE 16
■ FIGURE 17
50 September 2007
Simpson.qxd 8/6/2007 10:47 AM Page 51
What’s Next
Next month, we will build the
indoor weather satellite. Using one of
the Maxstream development boards,
we will test and display the results
from this system. I will also
break down the protocol that I use for
transmitting data over the network.
By understanding this protocol, you
should be able to build your own
display systems using any language
or controller.
Be sure to check for updates at
www.kronosrobotics.com/Projects/
wirelessweather.shtml. NV
September 2007 51
Malone.qxd 8/6/2007 12:40 PM Page 52
●●●●
Okay, you’ve wired up
the latest whiz-bang
sensor to your BUILD A .01%
processor-controlled
project. The sensor has ACCURATE VOLTAGE
REFERENCE
been connected to the
12-bit A/D and now the
moment of truth. You
apply power and look at
the data ... Hmmmm,
the numbers don’t look I f you had a separate accurate volt-
age reference available, you could
devices and progress up to a preci-
sion lab-quality circuit.
quite right. After much determine if your DMM is “telling
the truth.” This is but one example Zener Diodes
head scratching, you of why you might want an accurate
measure the A/D voltage reference. Other possible On the low end of the
reasons include using one to reference accuracy continuum, we
voltage reference with calibrate your DMM, or to construct have the lowly zener diode. It is
your trusty DMM and a precision voltage-to-frequency readily available and 5% accurate
converter or current source. devices are inexpensive. A 5.1V,
get to thinking. A 12-bit The applications for a precision 1N751A zener can be purchased
A/D means the input reference fall into two general cate- for about a dime and is a good
gories: instrument (DMM, DVM) starting point for our discussion.
signal is going to be calibration/accuracy verification, or Zeners provide their stated
represented by one of as a circuit component, such as the breakdown voltage only with a
reference for an A/D converter. particular test current, Iz, flowing
4,096 possible codes; The construction part of this arti- through them. This means that the
one part in 4,096 is cle is geared towards voltmeter cali- series-limiting resistor shown in
bration and/or accuracy verification. Figure 1 must be sized to guarantee
approximately .024%. However, the following discussion of that this current will, indeed, flow.
In other words, if you various reference voltage parameters For instance, with a 9V supply
applies equally well to using a volt- and a 1N751A which has a Iz of 20
want to get 12 bits of age reference as a circuit element. mA, the resistor value is (9-5.1)/20
absolute accuracy, the I’ll quickly go through several mA = 195 ohms. Note that the value
voltage reference options, starting of R1 will be different if anything
reference voltage must with inexpensive and fairly crude other than a high impedance is
be within .024% of the placed across the zener.
I don’t want to dwell too much
desired value. This puts on the lowly zener but there is one
a heavy burden on the point worth emphasizing. You may
be asking, what is the advantage of
test equipment used to using a zener if an accurate supply
measure the reference voltage and a precision resistor are
needed to get the precise desired
voltage.
■ FIGURE 1. NOTE:
So, just how accurate Inexpensive, PCB patterns and artwork are
is your DMM? 5% accurate,
5.1V reference.
available on the Nuts & Volts
website at www.nutsvolts.com.
52 September 2007
Malone.qxd 8/6/2007 12:41 PM Page 53
BY DOUG MALONE
■ FIGURE 3.
1% accurate,
5V reference.
■ FIGURE 2. 4%
accurate, short-
circuit proof, 5V
reference.
current flowing through the device? If the current through the device
Well, fortunately, things are not as varies from 1 mA to 15 mA, the
critical as they might first appear. The voltage drop is guaranteed to change
reverse impedance of the zener is quite a maximum of an additional 10 mV. usual, you get what you pay for. This
low, which means that the current can Figure 3 shows a typical circuit. increased performance will approximate-
vary quite a bit and the voltage will still So far, accuracy has been stated as ly double the cost to a little over $2.
remain relatively constant. As part of a percentage of the nominal voltage Next, we can consider the Analog
the research for this article, I tested with no additional qualifying conditions. Devices AD586L shown in Figure 4.
five 1N751A zeners from Fairchild One such condition is temperature. This device provides 5.000V within
Semiconductor. I used a 200 ohm, 5% Unfortunately, changes in ambient tem- 2.5 mV (.05% accuracy) and has a low
series resistor whose measured value perature will cause a change in the ref- temperature coefficient of 5 ppm/°C,
was 197 ohms. When I varied the sup- erence voltage, regardless if the device an aging rate of 15 ppm/1,000 hours,
ply from 8V to 10V, the current through is a zener or a precision reference. and a supply current of 3 mA. It will
the least accurate zener of the group For instance, the LM4040 DIZ-5.0 cost you a little over $9, however.
varied from approximately 14.3 mA to has a worst-case temperature coeffi- At this point, I need to explain a
24.3 mA, but the zener voltage stayed cient of 150 ppm/°C. This means that little about aging rate — also known as
within 2.3% of 5.1V. The best of the five for every degree up (or down) from long-term stability — specifies how the
devices was within 0.2% of 5.1V! Not 25°C, the breakdown voltage of the reference voltage will change over an
bad for such a simple and inexpensive device will change by 150/1,000,000 extended period of time. In other words,
component. Your mileage may vary. or .015%. Obviously the smaller the even though the temperature, applied
temperature coefficient, the better. voltage, and load current may be con-
Three-terminal For general indoors lab work, the stant, all voltage references will slowly
Regulators temperature coefficient will probably drift over time. A 15 ppm/1,000/hour
not be as important as it would be if aging rate means that after 1,000 hours
Next up, we have the common the voltage reference were exposed to (about 42 days), the voltage can be
7805 three-terminal regulator. The more extreme temperatures. Your expected to be 15/1,000,000 or .0015%
MC7805 from Fairchild (and others) specific application will determine if higher or lower than its original value.
costs about $.50, gives 4% accuracy you need to use a device with a low Now for the pièce de résistance!
under light load, is short-circuit proof, temperature coefficient. As you Intersil has recently come out with a
and can more easily accommodate might suspect, devices with a low series of voltage references that signif-
wide swings in load current than temperature coefficient tend to cost icantly improve upon the historical
the simple zener regulator. Higher more than those with a higher
accuracy devices are available such as temperature coefficient.
the 2% KA7805AE for $.80. Figure 2 ■ FIGURE 4. .05%
accurate, 5 ppm,
shows a typical application circuit. Going Up the 5V reference.
For 1% accuracy, you might want Accuracy Food
to consider the LM4040DIZ-5.0 from Chain
National Semiconductor. This device
costs about a dollar and is a “shunt” Next up on the accuracy
reference similar in general concept to scale, you could try a
a zener except that it isn’t nearly as LM4040AIZ-5.0; this device is
picky as to the current flowing accurate to 0.1% and has
through it. With a 1% accurate device a moderate temperature coeffi-
at room temperature, the output cient of 100 ppm/°C. Now we
voltage is 5.00V plus or minus 50 mV. are getting somewhere! But, as
September 2007 53
Malone.qxd 8/6/2007 12:41 PM Page 54
■ FIGURE 5. Schematic of
the battery-powered, .01%
accurate, 5.000V reference.
price/performance ratio. The series Circuit Description as 8.0V. However, I was pleasantly
includes devices with 1.024V to surprised when I measured the first
5V reference voltages with high The 5V precision reference is couple of prototypes and found that
accuracy, low temperature coefficient, powered by a 9V battery. The circuit the 5V reference voltage was within
low aging, and very low current draws about 4 mA with a fresh .01% with a battery voltage all the
consumption. The X60008C is used in battery, which results in a battery life way down to 6.7V! Hopefully, you will
the construction part of this article in excess of 48 hours of continuous get equally good results.
and costs about $7.50, provides operation. Increased battery run-time Besides supply voltage and com-
5.000V accurate to within 500 µV can be achieved by applying power, ponent tolerances, there are two more
(.01%) , has a low temperature letting the unit stabilize, making your potential error sources that need to be
coefficient of 5 ppm/°C, low aging measurement, and then turning the mentioned. Mechanical stress on the
rate of 10 ppm/1,000 hours, power off. D4, a TL431 “variable die inside the X60008 package can
and incredibly low supply current zener” whose breakdown voltage is cause a voltage shift in the reference
requirement of 800 nA. Figure 5 set by R2 and R4, produces 6.5V to voltage. For instance, pressing down
shows a schematic using this device. supply power to the X60008. on the board and causing it to flex can
The .01% accuracy of the X60008 cause stress. Looking at the photo in
■ FIGURE 6. Photo of the completed is specified with a supply voltage of Figure 7, you will see two slits in the
reference. Note PCB slits adjacent exactly 6.5V; the 5.000V reference printed circuit board (PCB) on either
to X60008. output can deviate as much as side of the X60008. The purpose of
100 µV per volt away from these slits is to de-couple the X60008
6.5V. For example, if the sup- from the rest of the board and make it
ply is 7.5V, the 5.000V refer- more difficult for mechanical stresses
ence could be off as much as to be transmitted to the reference.
600 µV(500 µV from the initial Another potential error source is
.01% tolerance plus another temperature stress. When soldering
100 µV from the supply being the leads of the X60008 to the circuit
1V from the ideal 6.5V); 1% board, work quickly! It is stressful to
resistors and a 0.5% TL431 are the IC die to have one lead at an ele-
used to keep the 6.5V supply vated temperature and other leads at a
between 6.3V and 6.7V. lower temperature. Leaving the solder-
Diodes D1 and D2 pre- ing iron on a pad too long can result in
vent damage to the circuitry the reference voltage permanently
if the battery is installed back- shifting to an out-of-spec value. If you
wards. A low current LED, have an adjustable temperature solder-
D3, is used as a visual power- ing iron, don’t turn it up beyond 600°F.
on reminder. I designed the Use of a flux pen can be very helpful.
circuit to function correctly The X60008 package has eight
with a battery voltage as low leads, but only four are used. I purpose-
ly left off the four PCB pads associated
■ FIGURE 7. This photo shows with the unused IC leads; this minimizes
the 9V battery and holder the number of leads that need to be
supporting the PCB. soldered, which lowers the amount of
54 September 2007
Malone.qxd 8/6/2007 12:42 PM Page 55
September 2007 55
Page56.qxd 8/7/2007 11:04 AM Page 56
SpectraPLUS 5.0
FFT Spectral Analysis System
56 September 2007
Full Page.qxd 8/8/2007 4:03 PM Page 57
Call 1-888-7SAELIG
Devasys - Provides a simple I2C/RS232-driven easy-to-use Fiveco - TCP/IP server with I2C, PCI93LV: industry-standard I2C card NM7010A-LF REV 2 - Complete, Mention Offer# SBW
“drop-in” solution for connecting graphics/text 4.8” x 3.6” LCD - 19 x digital I/O, 5 x 10-bit A/D for PCs. WINI2C/PCI software hardwired TCP/IP-I2C module. Offloads
gives windows-interface to develop to get a free
your PC to 90kHz I2C + 20 I/O white backlight. Program in inputs, and UART serial interface. stack for hi-speed Internet-enabling Starbucks Card
and debug I2C bus systems.
lines. Free software. Use multiple Basic. Display bmp, text, Connect I2C devices/sensors UCA93LV is USB version.
microprocessor systems. Drop-in with your order!
boards for more I2C/IO. graphics, etc. to an Ethernet network! Transparently monitor at W3100A-based board for instant While supplies last -
USB I2C/IO $79 GHB-3224C $199 FMod-TCP from $250 400kHz! $499 network speeds to 8Mbps. $22 not available with any other offers
Stepper Motor Touchpanel Controller USB to 24 x I/O FATfile Storage Easy LCD Touch-Sensing ICs
I/O
Easy-Step 3000 - Advanced stepper CUTOUCH - 320 x 240 Blue Elexol - 24 latched I/O lines self- Micro ALFAT-SD - Easily add Micro LCD - Easy way to add 2” sq Quantum ICs - World’s best capacitive
motor drive and control system for Graphic LCD Touchpanel/controller. powered from USB port. Ubicom SD storage to your product. 128 x 128 color LCD or bright OLED. sensor ICs for switching & control.
unipolar stepper motors up to CUBLOC Program in Basic SX52 allows individual pin I/O Serial data in - FATfile data Add text/graphics/animations Patented Adj. Key Suppression,
35V/3A- ideal for robots/industrial and/or LadderLogic. 82 I/Os and programming. I/O control via PCs out. for any micro with serial/USB. Spread-spectrum. In use worldwide
control - turns you into an instant 2 RS232 MODBUS support. USB port. uALFAT-SD $40 Micro LCD MK II $82 by the world’s largest consumer/
motor control expert! from $84 CT1720 $359 USBI/O24R $69 uALFAT IC $14 Micro LCD-OLED $99 appliance mfrs from $1
Serial-Ethernet Cable Ethernet to Serial Ether-IO Mini Web Server WIZnet TCP/IP IC Serial Server
Ethernet
Network your serial product easily WIZnet - Ready-to-go serial-to- Ether-IO - UDP/IP-controlled 24 PicoServTM Miniature Web Server 10/100 Ethernet controller on a
RS232/422/485 device server for
without a PC using this 28” cable. Ethernet Gateway. Simple set-up digital I/O board 3 x 8-bit TTL allows remote I/O and servicing. chip! Fully hardwired TCP/IP core.
network-enabling legacy serial
Provides an instant IP address. for 10/100Mbps Ethernet - ports each independently Collect analog & digital data over No OS required. TCP offload devices. 1/2/4/8/16/32 ports
RS-232 port compatible with most 230kbps serial. Ethernet/ programmable. Connects to any a web connection. Remote sensing/ improves system performance. 10/100Mbps-230kbps. Static
10/100mpbs Ethernet hubs. Internet-enable any serial part. TCP/IP Ethernet network. control, SCADA, building control. W5100 (integrated PHY) $6.95 IP/DHCP/PPPoE.
eCOV-110-P $99 EG-SR-7150MJ $34 Ether-IO 24 $109 PP1001-V00 $205 NM7010B+ Eval $22 Portbase-3010/RS232 from $171
Bluetooth 3ALogics Transceiver Modules Wireless Controllers TinyOne Zigbee TM Data Modem
RF
Emxys PearlBlue - 100m-Bluetooth RFID Reader Chip - Reads FIVE LPRS easyRADIO TM makes GSM/GPRS/GPS/Bluetooth/ Complete RF solution for fast & reliable USB-powered radio transceiver
module (UART master/slave bridge). International Standards ISO14443 wireless data transmission Ethernet wireless controllers data transmission. Miniaturized OEM boards add wireless RS232 to
Easyconnectionformicro'stoPCs,PDAs, A/B, Tag-IT, Felica and ISO15693. simple for US and Europe! Add for M2M - for autos, machines, RF module ensures fast and easy your device! Get remote control
phones, etc. microIceBlue - PIC16F877 Single-chip solution. wireless capability to your project etc. RS232/485/CAN/ A/D-I/O. integration into wireless applications. for your product from PC USB
based emb. dev. system for shortest TRH031M $6.95 today! TinyOne Zigbee $55 port!
Bluetooth development. $99 RSK-100 Eval Kit $350 ER900TRS from $38 (100) Owasys from $441 B915FH-tiny/40-SMD-WA $61 RTM-USA $89
USB in one IC FT232R Module USBwiz Easy USB GPS Logger USB-Serial Adapter
EW
N
USB
FT232RL - FTDI USB1.1-serial IC with UM232R - FT232RL 24-pin DIP USBwiz - Easily add USB microUSB - Tiny ready-made USB TrackStick II - Pocket-sized logger FTDI - based serial port laptops.
new "security-dongle" feature. Each module - USB-TTL serial convert- peripherals to your system. Includes Interface to 1 Mbps 0.7” x 0.5” tracks position data for vehicles, Instantly adapts older RS232
unique ID and Internal EEPROM, er for your project. Reference cir- FATfile system for USB thumb & based on SiLabs CP2101. personnel, etc. Records date, time, products to USB! Included drivers
FT232RL $2.50 (1K) cuit for FT232R. Plug-in module external USB hard drives. No Gnd/RX/TX Suspend, Reset, & location, route and speed. Shows provide virtual COM port.
FT232BL $2.93 (1K) adds USB1.1 instantly! USB knowledge needed. Plug-n-play! 3.3V 100mA source. data on Google maps! $175 USB-COM-S (45”) $19
Check out the whole FTDI line! UM232R $19.99 IC $29 Demoboard $59 microUSB $25 Super TrackStick II $209 USB-COM (13”) $25
www.saelig.com [email protected]
check for special offers! new products every day!
Floating Point
MULTIPLICATION
and
DIVISION
Without Hardware Support
by Craig A. Lindley
microcontroller development kit Clock speed Up to 16 MHz with many instructions executing in one clock cycle.
from Texas Instruments (TI) called Flash memory 2K bytes
the eZ430-F2013 that could be
had for $20 plus shipping. At first I RAM 128 bytes
didn’t believe it was possible. I ADC A 10 bit ADC is onboard with built-in voltage references.
thought the ad was a misprint but it
wasn’t. That did it. I had to have TimerA can be configured for pulse width modulation that can
PWM be routed to selected pins of the device.
one. It turns out this development
kit is an incredible deal, perfect for TimerA and a watchdog timer are onboard. The watchdog
experimentation with what turns Timers timer can be used as an interval timer if the watchdog function
isn’t required by the application.
out to be the “world’s lowest
power” microcontroller family. A Power Claimed to be the world’s lowest power device.
$20 development kit does truly
I/O capabilities A single eight bit port is available with individual control over
bring microcontroller programming direction and function of each pin in the port.
and experimentation to the Hardware
masses. See the sidebar for more No
Multiplication
information about the eZ430-
F2013 development kit. TABLE 2. APPLICATION REQUIREMENTS
Then the only question was,
“What will I do with it?” It turns out Attribute Description
the answer to this question came At least four This would require at least four digital filters to achieve. The
about as fast as the development channels of filters would need to be at least third order for adequate
frequency selective separation between channels. Digital filters require floating
kit came in the mail. For years, I lighting control point arithmetic for their implementation.
have wanted to design a state-of-
A noise gate will be required to eliminate room and/or
the-art color organ similar to the Noise gate circuit noise in the absence of musical material.
ones I built in my younger days, but
An automatic gain control (AGC) is needed to allow the color
this time do it to the extent AGC organ to adjust itself to changes in musical content. I didn’t
possible in the digital domain want any user controls being necessary.
(instead of the analog). I wanted a built-in microphone with preamp in addition to
For those not familiar with a stereo line input for direct connection of the color organ
what a color organ is, it is a device to any sound source. An analog-to-digital (ADC) converter is
Audio inputs a requirement of the microcontroller used. The ADC converts
that splits music up into numerous the mic or line analog signals into digital samples for
frequency bands and modulates processing by the microcontroller.
colored lights according to the I wanted to drive at least 10 super bright LEDs per channel
musical content. Typical color for the size display box I had in mind. This equates to about
organs are three or four channels Output lighting 200 mA output drive capability per channel. The application
required PWM capabilities so the brightness of the LEDs in
with one color of light associated each channel could be controlled independently.
with each frequency band. With a
Multiple hardware timers would be required for control of
color organ, you can see the music, Internal timing functions internal to the color organ. This includes display
as well as hear it. control sequencing and PWM generation.
Further fueling the desire for a
state-of-the-art color organ was the availability my grandiose idea be implemented on such a
of inexpensive super bright LEDs. The color small microcontroller? My initial answer to
organs I built in the past used incandescent this question was a definite maybe. Take a
lights which introduced a time lag into the look at Tables 1 and 2 and let’s compare
musical response as the light’s filaments had to the capabilities of the MSP430-F2012
heat up and cool down. If LEDs were used microcontroller to the requirements of my
instead, not only would this time lag be application and see.
eliminated, but due to the life expectancy of After contrasting the controller’s capabili-
today’s LEDs, you would probably never have ties with my application’s requirements, it
to replace one. was immediately apparent that if all of the
So, I had my development kit in hand required functionality were going to fit in
which included a bunch of documentation, a the Flash memory, the overhead imposed by
single target board, an emulator, C compiler, use of a high level language (HLL) could not
assembler, linker, and debugger and I had my be tolerated. This was true both in terms
idea of building a digital color organ. Could of the space required by a runtime library
September 2007 59
Lindley.qxd 8/8/2007 11:09 AM Page 60
and/or for the performance hit of an the theory is applied. (The Resources sidebar
interpreted language like some Basics. If this has some pointers to arithmetic theory for those
color organ was going to work, I would need interested in reading further.) Suffice it to say,
to code in assembly language and do so as Horner’s method allows multiplication and
efficiently as possible. division of signed and/or unsigned floating
The first hurdle I had to face was that point numbers using a rather elegant approach
digital filters of the IIR (infinite impulse which I will illustrate. Horner’s method is not
response) variety are typically implemented without its drawbacks, however, which include:
using difference equations of the form:
• When multiplying and dividing, the multiplier
y[n] = A * y[n-1] + B * y[n-2] or divisor must be known in advance and
cannot be changed dynamically. This is not an
where y is a three element array of output issue with most DSP applications because most
history and A and B are floating point filter coefficients are known at design time and don’t
coefficients that are determined from the type change at runtime. (This is true in general, but
and response of the filter being implemented. probably not true of everyone’s applications.)
To use such filters, I needed to be able to
multiply floating point numbers on a • A division remainder is not available using
microcontroller that doesn’t even know how Horner’s method like it is in most other division
to multiply integers. Floating point arithmetic techniques. (Why this is so will be shown later.)
is something one takes for granted when
using a HLL, but as I mentioned this was not • The results of multiplication and division are
an option here. rarely 100% accurate and the errors vary
depending upon the types of numbers being
Horner’s Method to the Rescue processed. (I will illustrate this with examples
shortly.)
In my investigation of how floating point
arithmetic might be done, I stumbled across a TI For my color organ application, none of
application note (see Resources) that described these drawbacks turned out to be significant.
Horner’s method for floating point multiplica- The process of using Horner’s method can
tion and division. Horner’s method provides be broken down into the following series of
reasonably accurate results while only requiring steps. Given a known multiplier or divisor:
shift/rotate and add instructions; something the
MSP430 controller family has and does very 1) If dividing, invert the divisor so that it
well in a single clock cycle. becomes a multiplier.
The remainder of this article describes this
method along with a technique called 2) Convert the multiplier to its binary represen-
Canonical Sign Digit or CSD that can be used to tation of the required bit length; usually 10, 12,
optimize the Horner results. Finally, I will pres- or 16 bits.
ent a program I wrote called Horner.java, that
generates Horner equations and can even gen- 3) Optionally apply CSD to the binary
erate the MSP430 code for performing floating representation to optimize it. (CSD will be
point multiplications and divisions. Note: Even described later.)
though the focus here is on the MSP430 family
of microcontrollers, the techniques presented 4) Generate the Horner equations for the
are applicable to any processor. multiplication from the binary representation.
I won’t delve into the theory behind
Horner’s method; instead, I will show you how 5) Generate the computer code which
implements the Horner equations.
“... a color organ is a device that splits The example that follows will show how
music up into numerous frequency bands this is done. It is actually kind of fun to generate
the equations and the code by hand the first
and modulates colored lights according to couple of times to aid in really understanding
the process. Horner.java came about because I
the musical content ... With a color organ, had to generate a lot of multipliers and the fun
quickly turned to tedium.
you can see the music, as well as hear it.” Let’s generate the equations for the multi-
60 September 2007
Lindley.qxd 8/8/2007 11:09 AM Page 61
plier 0.123456. We will do this using 12 bits in positive powers of two in the Horner
and no CSD. The 12 bit binary representation of equations. Consider a multiplier of 654.321.
0.123456 is 0.000111111001. Starting from the
rightmost bit which is the Least Significant Bit Decimal representation:
(LSB) and moving towards the MSB (Most 001010001110
Significant Bit), find the first one bit in the Fractional representation: 010100100010
binary representation. This occurs at the 2-12 bit
LSB position. From there, count the number of The equations for the decimal portion of
places to the next one bit which, in this case, is the multiplier are:
three. The number of places between the one
bits is called the distance and a distance of T1 = X * 22 + X
T2 = T1 * 24 + X
three results in the first Horner equation:
T3 = T2 * 21 + X
T4 = T3 * 21 + X
T1 = X * 2-3 + X Decimal result = T4 * 21
Here, X represents the number the multipli- Notice the positive powers of two in the
er will be multiplied by. T1 is just a temporary above equations.
accumulator for the calculation. The final X is The equations for the fractional portion of
added in because there are more one bits the multiplier are:
remaining in the representation. This process
is repeated until all one bits in the multiplier’s T1 = X * 2-4 + X
representation have been traversed. The T2 = T1 * 2-3 + X
complete set of Horner equations for our T3 = T2 * 2-2 + X
multiplier is then: Fraction result = T3 * 2-2
September 2007 61
Lindley.qxd 8/8/2007 11:10 AM Page 62
Using a calculator to again check our (“rra” for the MSP430 family) is used for
results when X is equal to 29, the product every negative power of two and a rotate left
should be 18975.309. Running 29 through the instruction (“rla”) is used for each positive
Horner equations yields 18966 for the decimal power of two. For every + X operation, an “add”
result and 9 for the fractional result; their sum instruction is used. For every – X operation
being 18975. Here, the error is again less than (discussed in the context of CSD), a “sub”
the least significant bit. instruction is used. Assuming the symbols “x,”
Generating code to implement these “out,” and “acc” are register aliases, the code is
equations is easy. A rotate right instruction as shown in Listing 1.
This may seem like a lot of instructions, but
remember, each register operation executes in
The TI eZ430-F2013 Development Kit one clock cycle on the MSP430 family of
controllers. The above multiplication executes
Yes it’s true. You can get a complete TI MSP430 microcontroller
in about 32 clock cycles. If the processor is
development kit for $20 plus shipping. It’s called the eZ430-F2013
and is in the form of a USB stick (envision a jump drive). Amazingly, running at 16 MHz, the total execution time is
both the debugger interface and a target board fit inside the a respectable two microseconds.
stick. This development system works with all MSP430F20xx Of course, a C programmer would be able
devices. Even someone as frugal as myself could not pass up a to perform the multiplication in a single line of
deal like this. This offer puts microcontroller development within code such as:
everyone’s reach.
The following information was extracted from the TI website. double result = 29 * 654.321;
Description
The eZ430-F2013 is a complete MSP430 development tool and get exact results. Such is the plight of the
including all the hardware and software to evaluate the assembly language programmer.
MSP430F2013 and develop a complete project in a convenient USB
stick form factor. The eZ430-F2013 uses the IAR Embedded Canonical Sign Digit
Workbench Integrated Development Environment (IDE) to provide
full emulation with the option of designing with a stand-alone Canonical Sign Digit or CSD can be
system or detaching the removable target board to integrate into used to reduce the number of arithmetic
an existing design. The USB port provides enough power to operations (rotates and adds) required to
operate the ultra low power MSP430 so no external power supply
is required.
implement the Horner equations. CSD is an
optimization resulting in fewer instruction
Features executions required to achieve the same
• eZ430-F2013 development tool including a USB debugging result. CSD is a processing step that is
interface and detachable MSP430F2013 target board inserted in the process flow where previously
• LED indicator described. If a multiplier or divisor consists
• Removable USB stick enclosure of decimal and fractional parts, the CSD
• Debugging interface supports development with all MSP430F20xx process is applied across the complete binary
devices
representation. CSD processing proceeds
• Integrated IAR Kickstart user interface which includes an assembler,
linker, simulator, source-level debugger, and limited C compiler from the LSB bit to the MSB and works
• Full documentation on CD-ROM by grouping adjacent one bits in the binary
representation and replacing them with a
What’s Included simpler term.
• CD-ROM including software and documentation To do this, it is required that our binary
• IAR Embedded Workbench (Kickstart Version) IDE representation consisting of ones and zeros
• eZ430-F2013 Development Tool be replaced with a trinary representation
consisting of three symbols (0, 1, and -1). The
In addition to the development system, a set of three MSP430-
F2012 target boards is available for $10. TI’s part number for these
-1 is a special symbol that indicates some
boards is eZ430-T2012. These boards are about the size of a quarter number of consecutive ones (a run of ones)
cut in half. The F2012 processor itself is about the size of the have been replaced. After the application of
fingernail on your little finger. I used one of these target boards for CSD, there won’t be any consecutive ones
my color organ project. left in the binary representation of a number.
The included C compiler is limited to the production of 4K of It is necessary to restart CSD processing after
code which means it cannot be used on the largest of the each run replacement as a new run of
MSP430F20xx devices. TI makes available a free C compiler on its ones may be created by the insertion of
website that can generate up to 8K of code. Since my first MSP430
the replacement.
project was written entirely in assembly language, I didn’t try out
this alternative C compiler. CSD processing is performed in a loop
as follows:
62 September 2007
Lindley.qxd 8/8/2007 11:10 AM Page 63
Running Horner.java
To run Horner.java, you will need to have a Java equ - generate Horner equations for the multiplication
Development Kit (JDK) installed on your computer. The both - generate the MSP430 code and the equations for
program was written for use with Java 5 which is the multiplication
available for free from Sun Microsystems at help or ? - displays this message
multiplier - the floating point number being multi-
http://java.sun.com/javase/downloads/index_jdk5.jsp. The plied. The multiplier must be the final argument.
newer version 6 of Java should also work. An executable
version of the Horner.java program, as well as the source Program defaults: 16bit csd both
code are available at the Nuts & Volts website Please try again
(www.nutsvolts.com) in this article’s archive file:
Horner.jar. To see the Horner equations and the code generated
The code can be run in a couple of ways. First, the for a multiplier, specify the multiplier as the final
source file Horner.java can be extracted from the jar file, command line arguments as in the following:
compiled, and then run using a command shell (cmd.exe)
java -jar Horner.jar 0.12345
with the following procedure.
jar xf Horner.jar This command extracts the source file which will produce the following results:
from the jar
javac Horner.java This command compiles the source file Multiplier: 0.12345 Bits of precision: 16
java Horner <command line arguments> This is how you run
the program Horner equations:
T1 = X * 2^-2 - X
T2 = T1 * 2^-2 + X
Alternately, the code can be run directly from the T3 = T2 * 2^-2 - X
jar file without having to extract anything. This is done T4 = T3 * 2^-6 + X
as follows: Fraction result = T4 * 2^-3
September 2007 63
Lindley.qxd 8/8/2007 11:11 AM Page 64
Binary representation:
Resources 001010001110.010100100010
CSD representation:
■ Java version 5 is available at http://java.sun.com/javase/down 0010100100-10.010100100010
loads/index_jdk5.jsp.
Horner equations:
T1 = X * 22 + X
■ Information on the Texas Instruments MSP430 development T2 = T1 * 23 + X
kit is available at http://focus.ti.com/docs/toolsw/folders/print/ T3 = T2 * 23 - X
ez430-f2013.html. Decimal result = T3 * 21
■ For information on computer arithmetic and algorithms see Total Result = Decimal result + Fraction
the book Computer Organization by Carl Hamacher, Zvonko result
Vranesic and Safawat Zaky, 3rd edition, McGraw-Hill
Publications, 1990. You can see there is one less equation as a
result of the CSD optimization.
Conclusions
Horner’s method can be used to
provide floating point support on
microprocessors or microcontrollers
that don’t have support built in. It is
ideal for applications like mine, that
aren’t written using a high level
language. Horner’s method was just
what I needed for my color organ
application. After developing the
digital filters using Horner’s method, I
can say that the code for the color
organ project can fit in the 2K bytes of
Flash memory provided by the F2012
microcontroller (though just barely).
It may seem like a lot of work to
use the techniques presented here,
but often optimizing performance
and/or memory usage of an applica-
tion usually is work. NV
Metal Fabrication
1-2 Day Lead Times Available
* Quick
* Affordable Complete Fabrication Center
Integrated Ideas & Technologies, Inc.
* Precise Precision Laser, Waterjet, Plasma, Machining,
Forming, and Welding Capabilities
* No Minimums 3896 N. Schreiber Way • Coeur d’Alene, ID • 83815-8362 • USA
Ph (208) 665-2166 • Fax (208) 665-5906 • www.iitmetalfab.com
September 2007 65
ElectronetSep07.qxd 8/8/2007 7:32 PM Page 66
t • 10-bit A-to-D
of
nolo • PWM
12
• Output Compares
www.technologicalarts.com • 3V/5V Operation
jjzêjêêwpjékzjêêwpj¢¤êtj|ê
ê
·
3&','(
wjkêh¾ìwjkêj¾ìwj~okêêê
wêpê½êêzꢦ¢¥¢¢¦¥ªªê꣥
3,&0&8DQGGV3,&'6&DUHDUHJLVWHUHGWUDGHPDUNVRI0LFURFKLS7HFKQRORJ\,QFLQWKH86DQGRWKHUFRXQWULHV
g o t o w w w. n u t s vo l t s . c o m c l i ck E l e c t ro - N e t
Full Page.qxd 8/8/2007 4:06 PM Page 67
ALL
QUALITY Parts
FAST Shipping
ELECTRONICS
DISCOUNT Pricing
CALL, WRITE, FAX or E-MAIL
for a FREE 96 page catalog.
C O R P O R A T I O N Outside the U.S.A. send $3.00 postage.
2
$ 00
male header, 0.1" centers. plug on one end, Output: approximately
38 Degree, wide angle. three RCA jacks 3 Volts @ 40 mA.
each
CAT# HLP-206 (red, white, yellow) on the 60mm square x 2.5mm
20 for $1.50 each other end. 3 ft cable. Allows thick epoxy-encapsulated
iPods and many cam- silicon photovoltaic cell.
FLAT-SCREEN TV STEREO corders to connect directly Solid, almost-unbreakable
SPEAKERS to television or video monitor module with solderable foil strips on backside.
Full-range 15W, 4 ohm
stereo speakers for Philips
flat-screen television. Very
via standard A/V stereo cable.
CAT# CB-218 3
$ 00
each
Ideal for solar-powered battery chargers and
other projects. CAT#SPL-61
100 for $3.25 each 3
$ 75
each
good sound reproduction
EL BACKLIGHT, 3” X 5”
produced by two 2" 8W Salmon color in
off-state. Glows
12VDC 300MA
woofers and one 1" 15W
tweeter.An oval 4.7" x light-green when SWITCHING POWER SUPPLY
1.9" resonant diaphragm energized by Friwo # SPA4UL.
helps accentuate the 120 Vac or inverter. Input: 100-240V
bass response. For backlighting 50-60Hz.
Unbreakable plastic control panels, LCDs, special-effects light- Output:
enclosures are 15" x 3" x 2.55" deep. ing, models etc. Solderable pins extend 12Vdc 300mA.
Set of two speakers, 0.16" beyond plastic laminate exterior. 6' cord with 2.1mm coax
left and right.
CAT# SK-314 8
$ 00
per pair
CAT# EL-13
10 for $9.25 each 9
$ 75
each
power plug, center +.
CAT# PS-1236 $ 50 5
each
MANUFACTURERS - We Purchase EXCESS INVENTORIES... Call, Write, E-MAIL or Fax YOUR LIST.
September 2007 67
Geer.qxd 8/8/2007 4:14 PM Page 68
The Cell Broadband Engine or Cell/BE processor consists of a “Power Processor Element” (PPE),
which is the primary core that generally dictates the work of other cores on the chip. In a typical
configuration, eight “Synergistic Processing Elements” (SPEs) or secondary cores surround the PPE.
A Logic
Analyzer Tutorial
PA RT 1
A logic analyzer — like so many electronic test and measurement tools — provides
a solution to a particular class of problems. These include digital hardware
debugging, design verification, and embedded software debugging. A logic
analyzer is an indispensable tool if you design and troubleshoot digital circuits.
b y Va u g h n D. M a r t i n
L
ogic analyzers simultaneously and other analog characteristics, such ers debug elusive, intermittent signals,
measure numerous digital signals as phase relationships, peaks, time with some advanced ones even
with challenging trigger require- between adjacent edges, etc. correlating source code with specific
ments. If you are using new devices, (see Figure 1). A scope’s vertical axis hardware problems.
you’ll soon discover that debugging represents voltage and its horizontal
microprocessor-based designs requires axis represents time.
more inputs than oscilloscopes can HISTORY OF
offer. Logic analyzers — with their What a Logic Analyzer Does LOGIC ANALYZERS
multiple inputs — solve these problems.
The first logic analyzer appeared
These instruments have steadily A logic analyzer solely measures in 1967 as HP engineer Gary Gordon’s
increased, both in their acquisition digital, not analog signals! It can personal “bench project.” Just six
rates and channel counts, keeping pace capture many digital signals years earlier, Gary became a company
with advancing digital technology. simultaneously and display their hero as an intern in the oscilloscope
There are similarities and differ- often complex timing relationship to lab by solving their digital sampling
ences between oscilloscopes and one another. However, some logic scopes drifting problem when the
logic analyzers. To better understand analyzers slightly transgress into the time base changed.
Gordon’s involvement with digital
how the two instruments address scope’s domain by detecting glitches oscilloscopes before inventing the
their respective applications, let’s and setup and hold logic analyzer is not surprising
compare their individual capabilities. timing violations. But since logical analyzers evolved from
After triggering on a complicated mainly, logic analyz- DSOs. Logic analyzers evolved
sequence of digital events, a logic almost simultaneously with the first
analyzer can copy large amounts of commercially available
microprocessors. The
digital data from the SUT (system
first logic analyzers
under test.) Advanced logic analyzers emphasized operations
behave like software debuggers that closely akin to oscillo-
a trace computer program’s flow. scopes for hardware
A DSO (digital storage debugging and test,
oscilloscope) or any later becoming more
oscilloscope is an concerned with moni-
toring microprocessor
instrument that prima-
signal activity and soft-
rily reveals the signal’s ware debugging.
amplitude, rise time,
September 2007 71
Martin.qxd 8/6/2007 10:08 AM Page 72
PERSONAL ROBOTICS
UNDERSTANDING, DESIGNING & CONSTRUCTING ROBOTS & ROBOTIC SYSTEMS
■ GUEST HOSTED BY BRYAN BERGERON
September 2007 75
PersonalRobotics.qxd 8/6/2007 12:31 PM Page 76
PERSONAL ROBOTICS
REFERENCES
■ [1] HeartLander photo courtesy of Nicholas Patronik and Marco
Zenati, MD, Carnegie Mellon University. HeartLander is funded by
NIH and NASA, with past funding from NSF and The Pittsburgh
Foundation.n [5] X. Gao and L. Jiang, Biophysics: Water-repellent
legs of water striders. Nature, 2004. 432(7013): p. 36.
RESOURCES
■ Tower Hobbies (www2.tower
hobbies.com) — Servos, pushrods
with clevis.
September 2007 77
Full Page.qxd 8/8/2007 4:08 PM Page 78
Gold Sponsors
This unique and unprecedented event will draw over 1,000 robotics industry Media Co-Sponsors
personnel from across the globe and will feature:
■ Comprehensive Conference Program covering the most critical industry topics
including Design, Development and Standards, Tools and Platforms, and
Enabling Technology
■ Over 40 leading industry speakers
■ Keynote presentations by Tandy Trower, General Manager, Microsoft Robotics
Group; Paolo Pirjanian, President and CEO, Evolution Robotics;
Lloyd Spencer, CEO, Coroware; and Dan Kara, President, Robotics Trends
■ A packed Expo Floor offering hands on access to the latest design and
development solutions for producing robots and robotic technology
■ Great networking opportunities, special events and much more
Analysts, Association
& Academic Co-Sponsors
REGISTER TODAY AT
www.robodevelopment.com
or call 800-305-0634
Produced by:
Page79.qxd 8/7/2007 11:06 AM Page 79
$79.99 $119.99
$29.99 Scorpion XL
Scorpion HX
Scorpion Mini 6 Dual 2.5A (6A pk) H-bridges 6 Dual 13A H-bridge 45A Peak!
6 2.5A (6A pk) H-bridge 6 Plus 12A fwd-only channel 6 5V - 24V
6 5V - 18V 6 5V - 18V 6 2.7“ x 1.6” x 0.5”
6 1.25“ x 0.5” x 0.25” 6 1.6“ x 1.6” x 0.5”
Introducing Dalf
6 Closed-loop control of two motors
6 Full PID position/velocity loop
6 Trapezoidal path generator
6 Giant Servo Mode!
6 PIC18F6722 CPU $250
6 C source for routines provided
6 See www.embeddedelectronics.net
H-bridges: Use with Dalf or with your Micro/Stamp
OSMC Simple-H
6 Monster power! 6 6-28V 25A!
6 14-50V 160A! 6 2.25”x2.5 ”x0.5”
6 3.15”x4.5”x1.5” 6 3 wire interface
6 3 wire interface 6 current & temp
$79 protection
MADE IN
THE USA
www.robotpower.com
Phone: 253-843-2504 [email protected]
■ BY JON WILLIAMS
STAMP APPLICATIONS
PUTTING THE SPOTLIGHT ON BASIC STAMP PROJECTS, HINTS & TIPS
WHERE’S WALDO?
It seems like the animation controller from May was a hit. I got a lot of very
positive email and many readers have been creating derivative applications for
controlling servos. A few weeks ago, I got a call from one reader — my friend
Dan — who works in one of Hollywood’s leading prop shops (if you saw the
movie 300, then you’ve seen some of their amazing creature work). Dan
suggested that I build a recording servo controller because — in Hollywood
prop shops, anyway — the live performance is what really counts and the
ability to play back a great performance is a convenience. This kind of device
would also be cool for an animated Halloween or Christmas prop, something
I have a lot of interest in.
S TA M P A P P L I C AT I O N S
■ FIGURE 2.
Joystick Interface.
Vin from the power connector (be careful with using Vin; singled-ended or differential output. Configuration of the
anything above 7.2 volts will probably destroy your servos). ADC is accomplished by clocking four (mux) bits into the
The center pin of the voltage select header is routed device. As you can see in the function code, \4 is used to
through the power switch to the servo headers so that we limit the number of bits sent to the ADC. For convenience,
can power up the SX without applying power to the servos. the waldo program has constants defined for single-ended
When we want the servos to run, we move the power channels 0 and 1 that include the ADC start bit. After
switch to the far-right position. These features shouldn’t be shifting the mux bits out to the ADC, an eight-bit value can
too surprising as they make using the SX28 proto board on be shifted in.
the Parallax Boe-Bot chassis very easy.
FUNC ADC0832
WALDO SUBSYSTEMS tmpB1 = __PARAM1
Clk = 0
CS = 0
The first major subsystem is the analog-to-digital SHIFTOUT Dio, Clk, MSBFIRST, tmpB1\4, 4
conversion of the joystick input. Part of the parameters for SHIFTIN Dio, Clk, MSBPOST, tmpB1, 4
this project was to use an off-the-shelf, PC-compatible CS = 1
analog joystick. The trouble with analog PC joysticks is that RETURN tmpB1
ENDFUNC
we only get two connections per pot; we don’t get the ends
plus the wiper — we get one end (common, on pin 1) and
the wipers from each axis. What we’re forced to do, then, Let me point out a couple things having to do with
is add a second resistor to create a divider. We’ll tap off that the use of SHIFTOUT and SHIFTIN. First, both of these
divider and run it into an input channel of the ADC0832. instructions simply invert the clock pin (twice) for each bit.
Figure 2 shows the joystick interface for the circuit. As What this means is that we need to preset the clock level
you can see, the pot outputs from the joystick (pins 3 and before using SHIFTOUT or SHIFTIN; neglecting to do
6) are connected to 10K pull-downs and then on to the this is a common mistake for those porting BASIC Stamp
ADC0832. The application of 5V to pin 1 of the joystick programs to SX/B. Later versions of SX/B include an
connector routes this voltage to the pots. While this optional clock speed multiplier.
arrangement works, we don’t get a centered output value Without the multiplier, the data rate is about 83K bits
when the pot is in its center position; I don’t like per second, but many devices will operate significantly
“fixing” circuits in code, but this is a case where there is faster than that so we can take advantage by using the
just no choice. multiplier. Another point of consideration for this particular
Let’s have a look at the ADC code. The ADC0832 has project is that a “virtual” servo controller is running in the
two inputs and it can be configured on-the-fly to provide Interrupt Service Routine so all foreground operations are
September 2007 81
Stamp.qxd 8/6/2007 10:24 AM Page 82
slowed — the multiplier restores the access speed to the This subroutine expects a word address and then one
ADC. The other major subsystem is the I2C memory. I or two bytes after that. Since we want to use the same
selected the 24LC512 because it holds 64K bytes of data subroutine to write bytes and words, we’re forced into
and is really simple to use. Figure 3 shows the connections accepting the address as two bytes. If we’re using a word
to the 24LC512. variable for the EE address, the compiler will sort that out
When you look through the complete listing, you’ll see for us. When using a constant value, however, we have to
a lot of code having to do with the EEPROM. The reason is be careful. Let’s say, for example, that we want to write a
that there are four instructions in SX/B (I2CSTART, value to EEPROM address $000F. Here’s how we have to
I2CSTOP, I2CSEND, and I2CRECV) that get encapsulated do that when using constants:
in subroutines or functions to save code space.
I’ve also created a subroutine that lets us write a byte PUT_EE $0F, $00, value
or word to the EEPROM, and two functions for reading: one
for bytes, the other for words. All of this code is highly As you can see, we’re using two bytes for the address
portable and you can use it in many applications. The only and the bytes are aligned Little-Endian. If we did this:
critical note is that the SCL pin is aligned with the SDA pin,
i.e., the SCL pin always follows the SDA pin on the same PUT_EE $000F, value
port (RA, RB, RC, RD, or RE). For example, if SDA is RA.2,
then we must connect SCL to RA.3. the compiler wouldn’t understand that the address is a
Since writing to the EEPROM is a critical task for this word since the address value is less than 256 — so a byte is
program, let’s have a look at the PUT_EE function. If you assumed and used. If the value to be written is also a byte,
compare the code to the 24LC512 data sheet, you should the compiler will complain that we don’t have enough
see that it’s an easy match — my point is that once you’ve parameters for the subroutine. By forcing a two-byte
got the I2C routines set up, access to any I2C device is address, the subroutine can determine whether we want
very straightforward. to write a byte (__PARAMCNT is three) or a word
(__PARAMCNT is four). When we are writing two bytes, a
SUB PUT_EE flag is set that gets used later in the routine.
IF __PARAMCNT = 3 THEN
tmpW1 = __WPARAM12
The subroutine might look a little complicated but it is,
tmpB1 = __PARAM3 in fact, very straightforward. We start with the I2C start
i2cMulti = 0 sequence, write the device address (a constant in this
ELSE program, but could be a variable if you want to expand to
tmpW1 = __WPARAM12 multiple EEPROMs), the address to write to, and then the
tmpB1 = __PARAM3
tmpB2 = __PARAM4 byte(s) to write. As you can see, we use the flag to control
i2cMulti = 1 writing the second byte. Finally, the I2C stop sequence is
ENDIF generated to tell the EEPROM to save its buffer contents.
I2C_START EEPROMs are not particularly fast and this device can
I2C_OUT SlaveWr
I2C_OUT tmpW1_MSB take up to five milliseconds to store the values we just sent to
I2C_OUT tmpW1_LSB it. We don’t care about this delay because we’ll only access
I2C_OUT tmpB1 the EEPROM every 20 milliseconds, but in other applications,
IF i2cMulti = 1 THEN we can have the subroutine wait for the write cycle to com-
I2C_OUT tmpB2
ENDIF plete before returning to the caller. We do this by generating
I2C_STOP another start, and then writing the slave address. While the
‘{$IFNOTDEF NOEEWAIT} EEPROM is busy with its write cycle, the acknowledge bit will
DO be set to NAK (1). A conditional-compilation constant allows
I2C_START
I2C_OUT SlaveWr
us to enable or disable the write-wait option.
LOOP UNTIL ackNak = Ack
‘{$ENDIF}
ENDSUB
PUTTING IT TOGETHER
Like the animation controller project in May, this
program uses a virtual servo controller that runs in the ISR;
since we’ve been through that in detail, we won’t hash
through it again. The only thing that’s been added to the
ISR is an LED control option. The reason is that the program
has four modes:
S TA M P A P P L I C AT I O N S
3) Playback (servo positions are played back from get lucky again and the formula works out to:
the EEPROM)
position = position / 4 + 137
4) Paused (servos hold position until pause button is
pressed again) I say that we got lucky because the multiplier and
divider in the formulas above are powers of two; this lets us
I started with a three-leaded, bi-color LED — one use shift operators instead of multiplication and division
of those LEDs that has red and green elements with a operators (both generate a fair bit of code).
common leg. The problem was that the body was clear and Here’s the adjustment section:
when both LEDs were on, it didn’t really look yellow as I
had hoped. Well, in my supplies I found a two-leaded, IF joyX <= 50 THEN
joyX = joyX << 1
bi-color LED that had a milky, translucent body which I joyX = joyX + 50
thought might work better. It did, but it takes a little more ELSE
code to create the yellow effect. joyX = joyX >> 2
This is accomplished by reversing current flow through joyX = joyX + 137
the LED very quickly. Since the interrupt runs 100,000 times ENDIF
joyX = 300 - joyX
per second, we can do it there. Here’s how: IF joyY <= 50 THEN
joyY = joyY << 1
Check_Yellow_LED: joyY = joyY + 50
IF runMode = M_PAUSE THEN ELSE
ledPort = ledPort ^ %1100 joyY = joyY >> 2
ENDIF joyY = joyY + 137
ENDIF
What this does is invert the state of the LEDs each joyY = 300 - joyY
pass through the ISR when the program is paused.
Figure 4 shows how the LED is connected. There is only Once the program was running, I found that the servos
one resistor because current can only flow through one moved opposite to the actual joystick movement so both
LED at a time. axis values had to be inverted (100 becomes 200, and vice
Okay, we can read the joystick and save values, so let’s versa). This is easy math, too — just subtract the axis value
get to the meat of the program. At the top, we’re going to from 300. Note that the compiler will complain about a
wait for a new servo frame (the ISR sets a flag bit that we’ll truncated literal. This happens because we’re using a value
wait on). When we get the new frame, we read the joystick greater than 255 in the equation and the output is a byte;
axis values: it’s okay, the result will still be correct.
The joystick has two buttons; one for each axis. We can
Main: scan and debounce the buttons like this:
WAIT_SYNC
joyX = ADC0832 Ch0
Check_Buttons:
joyY = ADC0832 Ch1
IF BtnX = Pressed THEN
INC btnTmr(0)
Since the output from the ADC doesn’t match what we ELSE
need to drive the servos, we’ll have to apply a little math to btnTmr(0) = 0
adjust things. ENDIF
Let me take a bit of a detour here and encourage you IF BtnY = Pressed THEN
INC btnTmr(1)
to develop your programs in sections and with separate test ELSE
programs. I did this with all of the systems of the waldo btnTmr(1) = 0
program and have included my test programs for you to ENDIF
work with should you choose. (Files are available at
www.nutsvolts.com.) When testing the joystick, I got values Each button
between 25 and 255, and what we need for the servo is has its own
100 to 200. The challenge doesn’t end there, however, as debounce count-
the center value for the joysticks was 50. er. When either
So, we have two sections: one side goes 25 to 50, the counter reaches
other side of the stick goes 50 to 255. To adjust the first five (which
section for servo pulse values, the math is pretty simple: means the but-
position = position * 2 + 50
Stop_Recording:
ton was held down for five consecutive cycles), it is PUT_EE 0, 0, numRecs
considered valid. runMode = M_IDLE
How a button press affects the program is based on the btnTmr(0) = 0
current operational mode. The next step in the program is GOTO Main
to jump to the handler for the current mode:
We start by refreshing the red LED to indicate record
Mode_Handler: mode and then update the background servo controller
IF runMode = M_IDLE THEN Check_Start
IF runMode = M_REC THEN Recording
with the current joystick values. If the start/stop button has
IF runMode = M_PLAY THEN Playing not been pressed, then the axis values are written to the
IF runMode = M_PAUSE THEN Play_Paused memory, the records count is updated, and then we check
to see if there’s any room left in the EEPROM. If the
The first mode, M_IDLE, is where we’ll sit and wait for start/stop button has been pressed or we have run out of
a start button press, all the while the servos will follow any memory, the recording process is stopped. Here we write
motion of the joystick. When the start (x axis) button is the number of records to address $0000 of the EEPROM
pressed, we’ll look at the Play/Record jumper and take and reset the mode to idle.
things from there. Remove the Play/Record jumper and press the
start/stop button again — you should see the moves you just
IF btnTmr(0) = BtnOK THEN recorded played back. I’m easily entertained, but when this
IF PlayRec = RecordNow THEN
worked the first time my face lit up with a very big smile.
numRecs = 0
runMode = M_REC Here’s the playback code:
ELSE
numRecs = GET_EE2 0, 0 Playing:
IF numRecs > REC_LAST THEN ledPort = LED_GRN
GOTO Empty_EE pos0 = GET_EE2 eePntr
ELSE pos1 = __PARAM2
runMode = M_PLAY DEC numRecs
ENDIF IF btnTmr(0) = BtnOK THEN
ENDIF runMode = M_IDLE
eePntr = 2 btnTmr(0) = 0
btnTmr(0) = 0 GOTO Main
ENDIF ENDIF
GOTO Main IF btnTmr(1) = BtnOK THEN
runMode = M_PAUSE
btnTmr(1) = 0
When the Play/Record jumper is out, the number of GOTO Main
records is read from the EEPROM at address $0000. Blank ENDIF
EEPROMs usually have all locations set to $FF, so if we IF numRecs > 0 THEN
see a bad value in the numRecs variable, the program eePntr = eePntr + 2
ELSE
flashes the red LED and then jumps back to the top in idle IF Repeat = Yes THEN
mode — what this means is that we need to record some numRecs = GET_EE2 0, 0
movements first. eePntr = 2
Install the Play/Record jumper and then press the ELSE
runMode = M_IDLE
start/stop button on the joystick — press it quickly, though. ENDIF
The [movement] records count will be cleared and ENDIF
the mode set to M_REC which directs the program to GOTO Main
84 September 2007
Stamp.qxd 8/6/2007 10:26 AM Page 85
S TA M P A P P L I C AT I O N S
JON WILLIAMS
RESOURCES [email protected]
PARALLAX, INC.
www.parallax.com
Play_Paused:
IF btnTmr(1) = BtnOK THEN
runMode = M_PLAY
btnTmr(1) = 0
GOTO Main
ENDIF
IF btnTmr(0) = BtnOK THEN
runMode = M_IDLE
btnTmr(0) = 0
ENDIF
GOTO Main
USB Programmer $119.95 LAB-X Experimenter Boards BASIC Compilers for PICmicro®
(with accessories) Pre-Assembled Board Easy-To-Use BASIC Commands
for PIC® MCUs Available for 8, 14, 18, 28, Windows 9x/Me/2K/XP Interface
and 40-pin PIC® MCUs
RoHS 2-line, 20-char LCD Module PICBASIC™ Compiler $99.95
Compliant 9-pin Serial Port BASIC Stamp 1 Compatible
Sample Programs Supports most 14-bit Core PICs
Programs PIC Built-In Serial Comm Commands
MCUs including Full Schematic Diagram
low-voltage (3.3V) Pricing from $69.95 to $349.95 PICBASIC PRO™ Compiler $249.95
devices Supports All PICmicro® MCU Families
Direct Access to Internal Registers
Includes: PICPROTO™ Prototyping Boards Supports In-Line Assembly Language
Programmer, USB Cable, Interrupts in PICBASIC and Assembly
ZIF Programming Adapter for 8 to 40-pin DIP, Double-Sided with Plate-Thru Holes Built-In USB, I2C, RS-232 and More
Software for Windows 98/Me/NT/2K/XP Circuitry for Power Supply and Clock Source Level Debugging
Large Prototype Area
EPIC™ Parallel Boards Available for Most PIC® MCUs See our full range of products, including
Port Programmer Documentation and Schematic books, accessories, and components at:
starting at $59.95 Pricing from $8.95 to $19.95 www.melabs.com
6ISIT /UR
7
HTTPWW EBSITE !T
WELEXPC
OM
-(: 37%%0 $# 0/7%2 3500,)%3 3/,$%2).'