© PROJECTS m THEORY @ APPLICATIONS = CIRCUITS m TECHNOLOGY
WOE, VOR
ay |
stn ea | Svea ay TRONIcs
Build Bhs Own | + Me
gills A
¢ ats ‘old crutches into a dipole? Antenna artist shows you how.
Keep an eye on the weather with a PIC-based Barometer.
= Parking Sentinel project protects your bumper and your garage.SN
HIS
Capture your world in high definition Una ee)
OPE ea Ru ees rus
teeta een kere cue hoe
eI as eee ke cur Iess
Teese Meee
ee eur ern in)
i | le
Pa
Bercy
Bt eZ Me WEL}
See ees)
+ Intelligent Voice Control
Be) en ey
Protec
aN
Soa rea)
Cee a aes
Saeed
+ IP-68 Housing, Waterproof to 10 Meters
MD10
S60
Bo OMe ator UC} Bison or masa) UC}
* Recording Time (Max.) * Recording Time (Max.)
Ne ene cy Re ad
Een ty Lane iri}
See PSR + Dimensions: 2.32 x 1,69 x 1.38 in.
Biko SC econ
Crea | | Ate hel
a A CeTur your BeagleBone Black into anything you want with the
mikroBUS™ Cape. With four sockets, you can pick and mix from over
130 click” boards to add all sorts of sensors, transceivers, encoders,
connectors and many other modules to your projects. New clicks are
coming out weekly, so keep returning for more!22 Motion Triggered Plane Aisle
Night Lighting Internet Radio Player
Build this nightlight on steroids to keep twilight Never be at a lack for music with this incredibly
walkers safe and your electric bill down. flexible system that features the Pi MusicBox
By Goof Clark software.
ee eee By Craig A. Lindley
uild a iz Dipole Out of Crutches
Here's a fun way to “break” into ham radio! 48 How to Craft a PIC Barometer
Use this unique antenna design to find signals — Of al the ingredionts that make up a weather
weak or strong, forecast, knowing what the current atmospheric
By Bob Fischer pressure is doing is the mast important.
1h aueusiiel By Thomas Henry
licroprocessors and Model Trains
Meet Head On! 53 7 DIY Indoor Air Quality
Let your Arduino ride the rails to make realistic Monitoring System
crossing flashers for your model train setup. The air that we breathe indoors ~ whether at home
1 By Bob Fink ‘oF at work — can put us at risk for health problems
if there are common pollutants in i Be sure of what
34 The Garage Sentinel You're broathing with this prototype systom that
‘Yep. We've got yet another parking assistant project features many types of sensors.
thet will save you from the ol hanging tennis bel 3 By Tom Kibalo
By Larry Coyle mn
08 TechKnowledgey 2014 The Design Cycle
Events, Advances, and News Advanced Techniques for
Road about a method for cancelling shockwaves, Design Engineers
Shea et Gevice te inser, SD. Etna cote Giving Our “Board” Wings to Fly Over
LANs or the Internet.
12 Os The A-10 Thunderbot I (also known as the Warthog)
a fs built around its 30 mm cannon. This month's
: ‘ait offering is built around its own 10 MB Ethernet port
Answers to questions about furnace data acquisition a , eee
Sa eletecolca aroUnd Voilcls fil anil I've got the itch, so let's scratch-build the “board”
which is based on the Microchip PIC32MX795F512L.
% te Spin Tone 70 Near Space
Propeller Programming Approaching the Final Frontier
Fun with Charlieplexing. CubeSats — Part 5: Designing a
Learn about this method of LED control that takes Model CubeSat for School Use.
advantage of a processor's ability to manipulate As CubeSats continue to play a pivotal role in space
ihe pin sate. exploration, i's important te introduce more
Schools to this taohnology. Hore’ kt tht can
Go jst that
Departments 76 Practical 3D Printing
DEVELOPING = ELECTHO.NET Real World Uses for the
O° BERSPECTIES 66 NVWEBSTORE Electronics Experimenter
07 READER FEEDBACK °° CLASSIFIEDS Pegboard Solder Holder.
20 NEW PRODUCTS ee Never lose your roll of solder again with this handy
Seema 80 AD INDEX Boneh organizational too
TBs RN |S NSCOR Age MOTTO a pid ay GODS pa by TA ers he D Ntcind Can Cama CA HRD PERODCALS
Bal Cohen de axa AnonBal natn dics ROSALES oe dels o Ms 8s BO Box HRY, North ayrod CA M113 Son 00
4 MTSEVONS. August 2015TSC AULT 2 De
4 gape Ns rs,
TIT geeVintage Repair
[in ite of overhauling vintage Singer 2012
[sewing machine, manufactured in the US in 1940. As |
expected, the motor brushes need replacing, the ole:
fashioned leaf switch controlling the light is — at best —
intermittent and needs a good cleaning, and the cotton-
insulated wire is begging to be updated to fireproof silicon,
insulated wire. Old appliances — void of microcontrollers
or even simple semiconductors — are a pleasure to tear
down and rebuild. They're fun as a solo weekend project,
or, if you have someone you want to teach basic
mechanics and electricity to, they make a good two or
three weekend project. Even bringing an old toaster back
to life can provide a sense of satisfaction.
Back to the Singer, there's always more involved in a
Vintage repair than meets the eye. These old sewing
WORLD'S MOST VERSATILE
Eat
Se nore]
Seer
Pheer is
MONTHLY CONTEST
Visit us on Facebook® to post a
photo of your creative Panavise
Panavise prize package.
PANAVISE
Innovative Holding Solutions
7540 Calbre ve Reno + Nevada B75 (8007597535 wwFaavie com
© WUTSIVOTS Auoust 2015
machines require regular lubricating and cleaning like any
other fine metal equipment. 've tried just about every
grease on the market, and have come to rely on Triflo
clear grease. I's a synthetic grease that’s fairly odorless,
relatively inexpensive, and easy to come by. lust make
certain you remove all of the old organic grease before
you apply the TriFlo. The combination of old and new
grease doesn't perform well
‘One of the unfortunate characteristics of lighted
appliances from the middle of the last century is that they
relied on inefficient 110V incandescent bulbs. The Singer
uses a miniature 15W bulb that gets extremely hot — hot
enough to blister the paint on the bulb holder. I've solved
that problem by replacing the incandescent with a more
efficient, much cooler LED version. An unanticipated
The Easiest Way to Design Custom
Front Panels & Enclosures
You design it We machine it
SOETRES CAD satus,” plolarsonaly ines product
Front ParelDeegner” ro miimum cuantiy requed
* Cost effective prototypes and production
runs with ne setup charges.
‘* Powser-coated and anadized finishes in
various colors.
* Select from aluminum, acrylic or p
your own material
‘© Standard lead
iA
I(T SE9
FrontPanelExpress.comNUTS: VOLTS
Published Monthly By
T&L Publications, Inc.
1430 Princeland Ct
Corona, CA 92879-1800
(951) 371-8497
Fax (951) 371-2052
Webstore orders only 1-800-788-4624
‘wanw.nutsvolts.com
Subscription Orders
Tol Free 1-877-525-2538
Outside US 1-818-487-4545
PO, Box 15277
North Hollywood, CA 91615
FOUNDER
Jack Lemieux
PUBLISHER.
Lamy Lamioux
[email protected]
ASSOCIATE PUBLISHER/
‘ADVERTISING SALES
Robin Lemieux
[email protected],
EDITOR
Bryan Bergeron
[email protected]
VP OF OPERATIONS
‘Yorn Granor
‘
[email protected]
CONTRIBUTING EDITORS
Fred Eady Tim Brown,
Jon NicPhalen Jet! Eckert
Paul Verhage ‘Chuck Helebuyck
Thomas Henry Tom Kibalo
Bob Fischor| Bb Fink
Geoff Crk Lary Coyle
Craig Lindley
CIRCULATION DEPARTMENT
[email protected]
‘SHOW COORDINATOR:
Audrey Lemieux
WEB CONTENT
Michael Kaudze
[email protected]
WEBSTORE MARKETING
Brian Kirkpatrick
[email protected]
WEBSTORE MANAGER
‘Sean Lemieux
ADMINISTRATIVE STAFF
Debbie Stauffer
Fle Gandara
Copyright © 2015 by T & L Put
‘All Rights Reserved
I adersing issue wo planers eprora. We
“rpowapica ors. this 8 vats hogan assures
Rp resporsby forthe ealaoky 01 coraiion of
Sverige ter of ft the Ponty of the averse
‘he pubisner maces ro. dame fr she eaeky
thy tom avers in huis Vols. Tus be 2
Tomorsbliy of the adverse: Rovrisos ara far
gens eats ondary and ote: te pels
im aa a dee, cian or parse ang Tor
bavesang paced in Nuts & vats Peso send
tora Garecsondonce UPS. ovrnaht al, ord
‘en to 40 Bnet Cour, Carng, CA 2578,
Ponta nth USA on SI & FSC soc
advantage of moving to LED lighting is that the light is nearly pure white as
opposed to yellow. You can find LED bulbs at Amazon, 100bulbs.com, and, of
course, homedepot.com.
Replacing frayed power cords can be a challenge — especially when the
appliance is designed for a non-polarized two-pronged connection to the
mains. Arbitrarily connecting a three-pronged plug can be a hazard — especially
on an appliance with a metal chassis. Unless you're familiar with electrical code
—as well as how your house is wired — I'd stick with the original wiring
diagram. Do replace the brittle plastic cord with modern flexible cord. I've had
good luck with non-polarized cords from both Amazon and Walmart
Switches — especially power switches — are the most problematic
‘components in a vintage repair. IV's usually easy enough to replace a toggle
switch with a garden variety version, but i’s at the cost of destroying the
“vintage” feel of the appliance. Take the Singer sewing machine switch. The
toggle is a distinctive white Bakelite, and the mechanical aspect of the switch is
almost two inches long. | was lucky enough to find a new old stock (NOS)
replacement on eBay. Otherwise, | would have been forced to substitute a
miniature toggle switch for the classic Bakelite toggle. I've found a great source
of old fashioned switches is guitar supply houses and local music stores —
‘especially stores that cater to the tube amp crowd.
So, next time you walk past a yard sale, check out the vintage electrical
items, There’s always something to learn from a teardown, even if you have no
need for the actual item, NW
READER FEEDBACK
Weather Website
In one of Bryan Bergeron’s past
editorials, he mentioned purchasing a
\weather station, Ive often thought of
building oF buying my own weather
station, but | never seem to find the
time to do it.
Living in southern CA, | wanted
to add seismic sensors, in addition to
the standard array of sensors (wind
speed, direction, temp, humidity,
barometric pressure, rainfall, etc.). ltd
be cool to be able to set up a
weather website, so my neighbors
could see the conditions. ! wonder
what make/model system Bergeron
finally settled on.
emailed both Davis and
‘AcuRiite, and they have told me — in
no uncertain terms — that neither of
their systems can be made to work
\with *homebrew* sensors. So, maybe
the easiest way to go would be to
start with a standard model weather
station — from either Davis or
Acute — and have it upload the
weather data to a website
Then, | could design my seismic
sensors and upload the data to that
website as a separate process, using
a microcontroller (sort of in parallel
to the weather station)
Any thoughts on this would
certainly be appreciated. It might be
doable, but I'm no expert on this.
Jeff Kerner
J ended up modifying an ancient
but workable Heathkit weather
station that a friend was about to toss
out. It was a fun project. going from
analog to digital. You have an
ambitious project: really data fusion.
‘ike the idea of parallel
treatment of data. You get more than
the simple sum of the parts.
You could write a simple cata
feed from an Arduino to process on
your Mac/PC and do some nifty
‘graphics/analyss in real time.
Bryan Bergeron
School of Hard Shocks
When | received my May 2015
Nuts & Volts, | read it cover to cover.
Continued on page 23
August 2015 WITSIVONS 7TECHKNOWLEDGEY 2015
BY JEFF ECKERT
ADVANCED TECHNOLOGY
Micrometer
resolution of a penny
taken from 1.8 R away.
From Smartphone to 3D Printe:
{ present, if you want to create something using a
3D printer, you first generate a digital model using a
software package like Blender, OpenSCAD, or even
AutoCAD. However, the process eventually may be as
simple as taking a photo of something using your
smartphone and sending the data to the printer, thanks
to a camera chip developed at the California Institute of
Technology (www.caltech.edu)
ting camera basically just catches pixels of
it without reference to how far away an
object is. The CalTech chip — called a nanophotonic
coherent imager (NCI) — uses LIDAR, which illuminates
the target with a laser and analyzes the reflected light to
provide both distance and intensity data
"By having an array of tiny LIDARs on our coherent
imager, we can simultaneously image different parts of
an object or a scene without the need for any
mechanical movements within the imager,’ noted
developer Prof. Ali Hajimir
Using coherent light, it is possible to detect the
pphase, frequency, and intensity of the reflected light
from different points on the object, which is sufficient
information to create a highly accurate 3D image. In the
illustration, micrometer-scale resolution was obtained on
a penny from a distance of about 1.5 ft (0.5 m)
The prototype NCI consists of an array of only 16
coherent pixels, which isnt all that useful. In fact, the
image of the penny was created from a seties of 4 x 4
pixel sections. Hajimiri says the current array of 16 pixels
could be easily scaled up to hundreds of thousands.
With these larger arrays, the imager "could be
applied to a broad range of applications from very
precise 3D scanning and printing, to helping driverloss
ars avoid collisions, to improving motion sensitivity in
superfine human machine interfaces."
8 WUTSIONS August 2015
Method for Cancelling Shockwaves
Jn today's conditions of asymmetric warfare, explosive
devices pose a major hazard to soldiers and equipment.
Most of the damage is created by two threats: flying shrapnel
and shockwaves. Shrapnel often can be handled using armor
and other physical bares, but shockwaves are more dificult,
to deal with. By definition, shockwaves are "traveling,
discontinuities in pressure, temperature, density, and other
physical qualities through a medium, and they can pass
through intermediate media.
However, it was recently reported that Boeing Co.
(wwnw.boeing.com) has been working on a method of
creating a shock-attenuating force field and, in fact, recently
\was issued a patent on its "Method and system for
shockwave attenuation via electromagnetic arc”
(One is tempted to think in terms of a force field such as
popularized in science fiction, but in reality it is more
analogous to the operating principles of a noise-canceling
microphone. in the Boeing concept, the system — perhaps
mounted on a Humvee ~ visually detects and analyzes an
explosion, then before the resulting shockwave can reach the.
vehicle, creates an opposing protective shockwave.
It does so by sending out laser pulses that ionize the
intervening air and forms a plasma channel, The channel —
Via deflection, absorption, reflection, and refraction —
minimizes damage to the vehicle.
There is no indication of when or if such a system will
be ready for deployment, but there is no reason why it cantt
ako be applied to aircraft, naval ships, and even buildings,
IM llustration of shockwave attenuation system from
‘patent application.EVENTS, ADVANCES, AND NEWS
COMPUTERS and NETWORKING
Chromebooks Down to $149
Ithough initially scoffed at by market analysts,
\Chromebook sales were up by 85 percent in 2014
and, in fact, accounted for 14 percent of the laptop
market. Contributing factors include widespread adoption
in K-12 schools and continuously plunging prices, The
expanding market is attracting new players, one of which
is Hisense USA (www.hisense-usa.com) — a more
traditional vendor of televisions, refrigerators, air
conditioners, dehumidifiers, etc.
Hisense recently introduced a $149 unit that,
according to one prominent reviewer, ‘actually isn't
awiul" Low-end machines don't have many features to
divell on, but it's worth mentioning that it runs on a 1.8
GHz quadcore Rockchip processor (Cortex A17),
incorporates a 16 GB SSD, and features duatband
802.1 ac and Bluetooth networking. As with most et
cheapo devices, the display is nothing to write home
Give Your Device the Finger
je'e all more or less accustomed (or at least
resigned) to the standard userid/password security,
procedure, Its a very bad idea to use the same login for
all of your devices and websites that need to be secure,
so you now have dozens of IDs and passwords — all
scrawled in a notebook or on the back of an envelope
somewhere because there's no way you can remember
them all. An obvious solution is biometric authentication,
which can be based on recognition of things like irises,
ear shapes, olfactory sensing, and (most popularly)
fingerprint recognition.
Fingerprint scanning can be done using several
technologies, with the most common being optical and
capacitive (e.8., Apple's Touch ID). Unfortunately, both
are subject to
alitches. Issues such
as temperature and
humidity (which
both affect the
capacitance of your
skin), dirt, scan
WThe first venture
into the
Chromebook
market by
Hisense USA.
about, but it does boot up in less than 10 seconds, and it
offers two USB 2.0 ports, HDMI, and a headphone jack.
Battery life is said to be "up to 8.5 h.' It’s available at a
Walmart near you.
angle, cuts and scrapes, and other factors can negatively,
affect recognition accuracy, and if your fingers get
shriveled up in the shower or ocean, they may be
temporarily unrecognizable. However, Qualcomm
Technologies (www.qualcomm.com) is now offering,
manufacturers the 'mobile industry's first comprehensive
3D fingerprint authentication solution based on ultrasonic
technology.”
The Sapdragon Sense™ID 3D Fingerprint
Technology is said to have some advantages over other
approaches, including the ability to scan through a
smartphone cover made of glass, aluminum, stainless
sieel, sapphire, or plastics, and it can scan through such
contaminants as sweat and hand lotion to provide more
accurate identification. Additionally, the sound waves:
directly penetrate the outer layers of skin to detect 3D
dletails and unique fingerprint characteristics, including,
ridges and sweat pores that capacitive sensors can't pick
up. The result is "a highly detailed surface map of the
fingerprint which is difficult to imitate or spoot” The
Qualcomm system should be appearing in commercial
devices later this year.
wear ones]
oy
Qualcomm's new Snapdragon
Sense technology picks up 3D
details using ultrasonics.
‘August 2015 MTSIVONS 9Post comments on this article at www.nutevolts.com/index.php?/magazine
Jarticle/august2015_TechKnow16.
CIRCUITS and DEVICES
Low(er) Priced Network
Audio Player
ince the 1970s, the Marantz name has
been attached to high quality,
equipment prized by audiophiles, and
although Saul Marantz shut down the
Kew Gardens, NY production facility long,
ago, the brand still produces some top-
Pe shana ee ie oe The Marantz NAGOO5 network audio player.
‘media are being replaced by networked
audio files, one would correctly expect the company to offer some high-end network players such as
the NA11S1, which is priced at a hefty $3,499 and is beyond most budgets. However, the good
news is the new NA6005, will run you “only” $649. It features both WiFi and Bluetooth technology,
as well as proprietary Marantz audio technologies to offer advanced connectivity and sound.
performance.
Through builtin Wifi or an Ethernet port, the NA6O05 connects to a home network to access
Internet radio stations and streaming services like Spotify Connect®. It's also equipped with Apple's
Airplay® so users can stream their iTunes® music (from a Mac or PC), as well as directly from an
iPhone®, iPad®, or iPod Touch®.
Users can also access local file libraries on a network attached storage (NAS) device or a
computer media server, and play audio file types including WAV, WMA, MP3, and AAC. Moreover,
the NA6005 can play back high resolution audio files including DSD 2.8 MH1z/5.6 MHz, FLAC
192/24, WAV 192/24, AIFF, and ALAC. Of course, youll also need to pick up a PM6005 integrated
amplifier ($699) and a CD6005 CD player ($499) to complete the system.
Let There Be Light
Se ere ere
including the widely despised CFLs, various arrangements of LEDs, and
{pethaps soon) graphene bulbs. One of the latest introductions is the Hue Go
lamp from Royal Philips (www.usa.philips.com). At frst glance, a portable
lamp seems pretty mundane, but it won an iF International Forum Design
award and features five new patented light effects that ‘enrich special
moments." It also offers interaction with more than 200 third-party apps.
According to Philips’ Sridhar Kumaraswamy, "We envisage all lights to be
connected. Put simply, lighting is now central to the Internet of Things, and
‘we see Philips Hue as the go-to lighting brand for the home."
Among its attributes is portability, and the Hue Go can be used
throughout the home; when unplugged from the power supply it becomes a
portable centerpiece that operates for up to three hours in battery mode. The
bowshaped device can be positioned in different ways, so you can use it for
an intimate dinner, to light up a wall, or whatever.
More interesting is that you can choose from seven different lighting
effects ranging from warm white to bright daylight, or one of the five effects
Hue Go: Lifestyle enhancement called cozy candle, Sunday coffee, meditation, enchanted forest, and night
‘or justa glowing bowl? adventure. With the Hue app, you can choose from more than 16 million
colors. Finally, the Hue Go can provide “light notifications’ if you receive a
new email or a weather alert, oF something else of interest occurs,
‘One might wonder: Is this glowing bowl a bona fide contribution to the modern lifestyle or just an overhyped
reincarnation of the lava lamp? For $99.95 (US pricing yet to be announced), you can judge for yourself,
10 NUTSHOKS August 2018CIRCUITS and DEVICES continues
Useless Serial Bus
(Catia patent det eels
created dozens of (arguably) clever
Flash drives that look like something else,
including sushi, guitars, cheeseburgers, and
human thumbs. Most of the gadgets run
the gamut from 256 MB to 16 GB, so they
are functional as well as weird. Now, you
can plug up an unused USB port with the
USB Squirming Tentacle, which has the
distinction of offering no storage at all t
basically just sucks power from the port
and wiggles, although the folks at Think
Geek (www.thinkgeek.com) caution that ~ IH Your choice: Wiggly
having been inspired by H. P. Lovecraft's Cthulhu deity — it ‘may summon the Elder Gods or humpy?
from the depths." Maybe it offers $14.99 worth of amusement — especially at work, in
airports, or in other public places. On the other hand, you may get more laughs from the
USB humping dog, available from Oddity Mall (odditymall.com) for only $10.50. &
INDUSTRY and the PROFESSION
3D Printed Cars? For Real?
pee ene eee a Eee ee Lee
envisioned by the folks at Local Motors (localmotors.com). According to the company, "Gone are the days of mega
or even gigafactories that consume tremendous amounts of time and energy to fabricate products. A more sustainable,
nimble, and flexible factory is on the horizon. Called microfactories, these diminutive factories drastically change how
we produce large consumer goods for unique local needs." The most interesting part of it is that these microfactories
are intended to produce cars. Yes, humanssize cars (and motorcycles, tricycles, and other vehicles) that actually can be
driven, and are predominantly manufactured using 3D printers
Impossible? Apparentiy not. They have already built one called the Strat, and every part that can be integrated into
a singlematerial piece has been printed including the chassis/frame, exterior body, and many interior features.
Everything else (battery, motors, wiring, etc.) has been lifted from Renault’ electric city car, the Twizy.
The Strati takes 44 hours to print, but Local Motors intends to reduce that to 24 hours eventually. The process is
referred to as big area additive manufacturing (BAM),
which is really just 3D printing on a larger scale. The
Siratiis pretty simple, sporting your choice of a 5 or 17
HP motor and an automatic single-speed transmission.
‘Top speed is about 50 mph (80 kph), with a 62 mile
(100 km) range from a 3.5 hour charge.
Key to the microfactory concept is that Local Motors!
cars will not be produced in a large factory in Detroit or
Tennessee, but in many small factories scattered across
the world (hence, the ‘local part). The company intends
to open 100 such facilities over the next 10 years.
IF you have a desire to become an automotive
tycoon in your own area, give them a call. In the
meantime, feel free to interact with the website which is
designed to be a "free online and physical workspace
where creativity, collaboration, and design drive vehicle
innovations.” Local Motors has a simple request: "Help us
bring badass vehicles to life.” NW
Local Motors! Strati, @ drivable 3D printed car.
August 2015 MUTSIVOUS. 11WITHTIM BROWN
Furnace Data Acquisition
| am looking for a “dongle” that I can hook up
to my furnace to collect data about running
time. I have a simple running time meter
{across the burner motor. This tells me the total
time but not how long itis running or what time of day
itran. Is there a simple low cost dataacq device with a
builtin internal clock and battery? I can put a relay with
contacts or a TTL level on the furnace, no problem. What
| am thinking of is something that can be installed on the
fumace for a month to collect data, then unplug it and
insert it in a USB port, download my data from it, then use
a spreadsheet to analyze any ideas.
— Edward Ganshirt
via email
You have a great idea, Monitoring gas and oil
fired furnaces is a good way to check the health
of our vital heating systems and a good way
save money while helping to cut pollution
and energy usage. | was able to find a couple of websites
that may provide the furnace runtime data logger you are
looking for, and I am sure there are many more systems.
See www.energytools.com/DataWatcher.him (Energy
Tools runtime data watcher) or www.onsetcomp.com/
products/data-loggers/ux90-004 (HOBO on/off motor
logger) for more information,
FIGURE 1
Microcontroller Furnace On Time Monitor
ek Diagram
12 MTSWOUS Avoust 2015
Furnace Data Acquisition
¢ Electronics Around Vehicle Fuel Tanks
Mailbag
Both devices have external current sensors, so you.
cdo not have to break a motor wire which could cause
problems when you remove the data logger. Both units are
battery powered and should be able to track your furnace’
‘operation for a heating season, and have software which
can display the data graphically to make interpretation
‘easier. The down side is the unit with software will cost a
couple of hundred dollars
If you are into programming, you could rig up a
microcontroller (e.g, Arduino, BASIC Stamp, Microchip
PIC) and program it to log the on/off times, time of day,
etc,, but this would involve program development —
especially if you wanted graphics capability.
Figure 1 is a block diagram of a microcontroller-
based furnace monitor. Being able to monitor furnace
runtimes could help determine the effectiveness of energy
improvement projects and detect furnace problems before
you are left without any heat. There are other systems
which monitor temperatures, fuel flow rates, etc, but they
are more expensive and require sensors to be inserted into,
the furnace.
Hopefully, some of our readers have experiences they
‘can share with us on their successes and failures with
furnace monitoring.
lectronics Around Vehicle Fuel Tanks
Please explain the safety concept
applied to the electrical circuits
in vehicle fuel tanks. Normally,
when designing electrical circuits
{or application in potentially explosive
environments, one of the following two
approaches are employed: 1. The circuit is
designed to be intrinsically safe, .e., under a
‘worst case fault condition, there can never
be enough joules available to cause an
explosion; or 2. The potentially hazardous
electrical circuit is contained in a UL listed
explosion proof box located within the
potentially explosive environment.
The box is designed in a manner that if
potentially explosive material leaked into the
box and there was an explosion, it would beQUESTIONS and ANSWERS:
Post comments on this article at
‘www.nutsvolts.com/index php?/magazine/article/august2015 OA.
MAILBAG
Re: Burn Marks on LCD TV Screen
Thanks for answering my question in the March issue
of Nuts & Volts. | tured down the backlight and the
brightness, and that resolved most ofthe problem. | used
a snow pattern and a pixel protector, but neither worked.
Probably because the image is too persistent. Thanks
again.
Mark Erickson, El Paso, TX
‘Mark, 1am glad I could help you. Technology today is
‘moving s0 rapidly its sometimes hard to keep up with. So,
the questions of our readers are helping me to stay on top
of the rapidly changing field of electronics.
Re: Op-Amp Accuracy Question
Thank you for the answer to my question on op-
amp accuracy in the May 2015 issue. It was exactly the
answer | was looking for. | will order the Analog Devices
paart and test it for future use. In the past, | have found
that any trimpots in the circuit are subject to temperature
variations that add to the inaccuracy.
‘Also, [need to look for an app that gives me lunar
planetary alignment. Thanks.
Milton
Milton, that is what | love about doing the Q&A —
helping readers solve their electronic problems. A couple
of websites for astronomy apps for the iPhone are: www.
businessinsider.com/1 1-best-astronomy-apps-for-
amateurs:2013-10 and www.iphoneness.com/iphone-
apps/top-astronomy-applications-for-iphone/.
contained and not propagate beyond the box. Obviously,
with the joules potentially available in a vehicle fuel tank,
the design is not intrinsically safe; nor are the electrical
Circuits in the fuel tank housed in an explosion proof box.
Please explain the concept employed to prevent
explosions in vehicle fuel tanks.
= Dennis Quinn
via email
If you are not a licensed
electrician, you are mighty
insightful into a deep, dark
secret of the electrical
trade. The National Fire Protection
Association's National Electric Code
(NEC) Article 500 classifies areas
where gasoline vapors are (Division
1) o may be present (Division 2) as
a Class {/Group D hazard location
(there are also temperature and zone
expensive and exacting: A general-purpose enclosure was
made af stamped sheet metal with a simple latch, whereas,
an “explosion proof” enclosure was cast aluminum with 20
or 30 bolts to close the gasketed cover, and the threaded
hubs were designed for a tight seal to prevent infiltration
Make up to $100 an Hour or More!
Be an FCC
iy LICENSED
ELECTRONIC TECHNICIAN!
Get your “FCC Commercial License” with our
proven Home-Study Course!
classifications, but | am trying to
keep it simple}. So, fuel tanks would
be classified as Class /Group D/
Division 1 locations when specifying
the necessary safety precautions
for electrical/electronic equipment.
[The NEC is written to cover every
conceivable situation, and is thus a
very complicated volume which is
for those who realy like to read and
follow various circuitous paths to find
a simple answer.
Tota in Class Group D/
Division 1 chemical plant and our
electrical installations were both
+ No costly school. No classes to attend.
+Learn at home. Low cost!
+ No previous experience needed!
+ GUARANTEED PASS! You get
your FCC License or money refunded!
Your “ticket” to thousands of high paying jobs in Radio-TV,
Communications, Avionics, Radar, Maritime and more.
Call for FREE info kit: 800-877-8433 %
: www.LicenseTraining.com
COMMAND PRODUCTIONS « FCC License Training
Industrial Center, 480 Gate Five Rd, PO Box 3000, Sausalito, CA 94966-3000
‘August 2015 MTSIVOUS 13at Cy Gente
een sh
T corsa ote
~~ mFIGURE2
Fuel Gauge Bagram
of flammable vapors which would make the panel a tiny
bomb,
The conduit had to be the rigid type (not EMT)
and had a large number of threads to be engaged. Plus,
conduit from boxes and going between walled areas had
to be sealed with a material which is like a cross between
concrete and grout (pity the electrician that had to pull
‘out the wiring once the sealing compound had set). You
are right on target with the methods approved for ensuring,
the electrical installation is explosion proof: enclosing the
electrical circuits (the enclosure | just described); or be
intrinsically safe, meaning the circuit does not produce
enough energy during normal operation to ignite a
flammable vaporair mixture.
NEC Article 504.2 defines intrinsically safe devices
as “Simple Apparatus: An electrical component or
combination of components of simple construction with
welldlefined electrical parameters that does not generate
more than 1.5 volts, 100 milliamps, and 25 miliwatts, or a
passive component that does not dissipate more than 1.3
Feedback Motion Control
The Old Way Kangaroo
1) Bul robet The
2) Guess PID coefficients 1) Build robot
2) Press Autotune
3) Get a snack
by Search internet,
5c) Read book, moi PIDcoeficent gaia
5) Decide performance’ good enough
30) Reale Rist
Sig pre dapointment
wh igrnccaee Kangaroo x2
Mowcets Steen Cquaimmtee _ adds self-tuning
ncicaseren tity ameenrocoaniem — f€etdback to SyRen
Since uk encrnca"" and Sabertooth motor
DITNLTemmniowm drivers.
14 WTSIVOUS August 2005
$24. 99 —.
snsionengineering.com/kangaroo
watts and is compatible
with the intrinsic safety
of the circuit in which itis
used.”
For example, our
plant used thermocouples
on to measure temperature
which produced only up
to 100 millivolts. So, these
Circuits were “intrinsically
safe” (we still enclosed
the wiring in rigid conduit for protection). We also used
bubble level meters that bubbled nitrogen into storage
tanks, but later switched to explosion proof capacitive
meters (airliners use them) which were compatible with
‘our computer control system.
‘With me (and OSHA et al), human safety is
paramount so I don’t cut corners where life and limb is
concerned. | purchase commercial devices that have been
repeatedly tested and approved. | know that is not what
our DIY readers want to hear, but I stand firm on this issue.
You have only one life, so take as many precautions as you
‘A good example of electronic devices in fuel systems
are those in modern automobiles: the fuel pump and level
sender. The pump is mounted in the tank with an external
explosion proof motor and an impeller made of spark
proof material (in case you run out of gas andi air is present,
with the impeller accidentally contacting the metal in the
fuel tank). The sender is mounted inside the fuel neck
and uses a float activated potentiometer (variable resistor)
‘which is sealed from the fuel vapors
since it operates at 12 volts (ie, not
intrinsically safe). Refer to Figure 2
{for a diagram of the automotive fuel
sauge system.
WARNING: Our readers should
NEVER develop a circuit or device
for use in fuel tanks because of the
inherent dangers to yourself and
others (seeing the results of fuel tank
fires on TV and the Internet I think of
the gasoline tank as a small nuclear
‘weapon). am a licensed engineer
(Chemical, Mechanical, and Electrical)
with over 40 years of experience and
| would not attempt to construct such
a device. So, don’t any of you either. 1
don’t want to see you on the evening
news as the latest catastrophe.
| hope this answers your question
and gives you a humongous fear of
fuel system explosions. NVTHE SPIN ZONE
ADVENTURES IN PROPELLER PROGRAMMING
BY JON MCPHALEN
Fun with Charlieplexing
design and write code for. There are lots of
tech conventions around the world, yet not
everyone has the budget to design custom
hardware. This
help out. They'll build the badge — you
write cool custom code for your venue.
where Parallax intends to
-ompletely finalized, though there are a couple LED
circuits that won't change. Figure 1 is a 3D model
of the preliminary design. In one section, there are six
blue LEDs connected to three resistors and three 1/O pit
in another section, the six LEDs of two RGB modules are
similarly wired, Wait .. how do we control six LEDs with
only three I/O pins?
Chatlieplexing!
Charlieplexing —
named after its
inventor, Charlie Allen
is a method of LED
control that takes
advantage of the
processor's ability to
manipulate the pin
sate: a pin can float
(input mode); be an
‘output and low; or be
‘an output and high
(the term tistate refers
to the pin's ability to
be in one of three
states). We don't often
think of the input state
A: the time of this writing, the badge design is not
]
FIGURE 1. Hackable badge.
MLFIGURE 2.
“Two LEDS.
FIGURE 3. Six LEDs.
8 an output control mechanism, but its critical to the
operation of Charlieplexing, Okay, then, lets start dirt easy
with two LEDs (see Figure 2).
Ifwe make PO high and P1 low, current will flow
through D1 and light; D2 is reverse biased and will not
light. I we reverse the outputs and make PO low and P1
high, D2 will light and D1 will be extinguished.
Now, what if we make PO or P1 an input (ie.,
floating)? When this happens, the pin is disconnected from
the output driver whi ‘opening a switch. Both
LEDs will be extinguished, regardless of the state of the
other pin, Ths is key to Charlieplexing,
With this understanding, have a look at Figure 3 and
the corresponding logic table in Figure 4. The circuit
shows the beauty of the
Charlieplex arrangement: With
just three 1/O pins, we can
control up to six LEDs. Getting
down to the nitty-grity, using
Charlieplexed connections
allows us to control up tom *
(n- 1) LEDs with m 1/0 pins
This means four pins could
control 12 LEDS, five pins
could control 20, and so forth.
AAs you study the table in
Figure 4, youl see that one
pair of outputs which is
‘connected across the target
LED is set to high (H) and low
(U, while the third output is set
to the input/floating state (X);
‘August 2015 MISEVOUS. 15,Post comments on this article and find any associated files and/or downloads at
wwrw.nutsvolts.com/index.php?/magazine/article/august2016_SpinZone.
ITEM DESCRIPTION SOURCE/PART# BOM.
Propeller Activity Board Parallax #32910
Circuit Overlay Board Parallax #32999
RIR3 47 Ohm Mouser #299-47-RC
D1..06 Green, 5mm Mouser #604-WP7113GD
this allows us to control the designated LED. Yes, this
means that we can only activate one at atime, and for
many applications this is fine. For a 1-ofN project, we
dont need any special code, just a method to handle
which LED is active:
pub sot_cp_ledin}
aira[cr2..ceo) := 4000
a
outa[CP2..cP0) := $002
dira(cez..cpo) := 8012
1
outa(cr2..ceo) := $010
dira[ce2..cpo) := £012
A
outa[ce2..ceo} := $002
dira[cp2..cP0) := $101
a
outa[ce2..cpo} := 8100
dira[cp2..cPo) := 8101
outa(Cr2..ce0) := $010
dira[cp2..cpo) := $110
5
outa(ce2..ce0] := $100
@ira(ce2..cP0] := #110
‘The method counts on having pin constants CPO and,
CP2 defined; these are the LSB (Least Significant Bit) and
MSB (Most Significant Bit) control pins of the three-pin
group. At the start of the method, we set the direction bits
for the group to %000 which disables all outputs. This
serves two purposes: 1) It clears the LEDS in the event we
ppass an invalid LED number; and 2) It prevents ghosting of
LEDs when making changes from one to another.
Vf you look carefully, youll see that the code in the
‘case structure directly corresponds with the control table.
I's a good idea to create such a table when using
Charlieplex wiring, and structure the code to follow your
table.
16 NUTSHOLTS Avoust 2015
This is pretty cool, right? It is, and yet |
know you're thinking, "Okay, Jon, that's
great, but what happens when I want to
have two LEDs on at the same time?" As my
friend John B. frequently quips .. no
problem, it's just a small matier of
programming (SMOP).
So far, we've only used Charlieplex wiring, but the
software process of Charlieplexing — like its cousin,
multiplexing — is more involved. What we're going to do is
loop through a control value that tells us which LEDs are
‘on. For those that are on, we will light them briefly, then
move to the next LED.
If'we do this fast enough (greater than 50 Hz), the
persistence of vision in our retinas will cause the LEDs to
appear to be on at the same time.
In most processors, this happens in an interrupt, and
for very simple Propeller programs we might even be able
to use the timer object to refresh the LEDs on a
reasonably fixed schedule. To be on the sate side,
however, and keep things generalpurpose, | decided to
create a stand-alone object.
For the object to work, the LEDs must be wired as in
Figure 3 and the pin passed to the start() method is the
LSB pin of the three-pin group. After that, everything else
takes care of itself. Here are the start() and stop()
methods for the six LED Charlieplex object:
pub start (cp)
stop
cycleticks := (elkfreq / 300) / 6
cog i= cognew (charlie 6(cp0), @stack) + 1
return cog
pub stop
if (cog)
cogstopicog - 1)
cog i= falae
ledbits = 4000000
Itis convention for the start() method to call the
stop() method to ensure everything is clean before
launching a cog (as we do here). The stop() method will
kill the presently running cog, mark it as stopped, and
clear the control value (ledbits)
The start() method sets the timing for LED updates in
the global (to the object) variable cycleticks. Remember
that al timing in the Propeller is done in system ticks. By
dividing elkfreq (system ticks in one second) by 300, we
set the update rate to 300 Hz. Why? In a word filed withJon "JonnyMac* McPhalen
[email protected]
Parallax, Ine.
Propeller boards, chips, and programming tools.
‘www.parallax.com
video cameras, this minimizes odd visual artifacts when
things are moving. Note that we further divide the timing
by six (the number of LEDs we're controlling) to ensure
that all LEDs are updated at 300 Hz.
The cognew call for a Spin cog requires two
parameters: 1) the method that will run itn its own cog;
and the hub address of an array used for the cog's stack
space. As with launching PASM cogs, cognew will return -
1 (cog did not launch) to 7, which gets promoted to 0
(false, did not launch) or 1 to 8 when everything launched
normally
The Charlieplex process is simple enough that we can
run it in a Spin cog without resorting to assembly, so long.
as we keep the application clock frequency at 20 MHz or
higher (more on this later). Here's the method that runs in
its own cog:
pri charlie 6(cp0) | cp2, t, cycle
cp2 i= cp + 2
re ent
repeat
jpeat cycle from 0 to 5
dira[cp2..cp0] := 8000
if (edbite ¢ (1 << cycie))
case cycle
0:
outalep2..cpo] := 8002
diralcp2..cpo] := 3011
a
outalep2..cp0] = $020
diralep2. soit
$001
101
outa [ep2. .cp0]
dia ep2. .cp0)
outalcp2..cp0) := 3100
diralcp2..cp0) := 3102
2010
e110
outa lep2. -cp0]
diralcp2..cp0]
outa(ep2..cp0] := 2100
diralep2..cpo] := 8110
eee eee
This method — as the start() method did earlier —
‘expects to receive the base pin of the three-pin group as a
parameter, A local variable ¢p2 is calculated for the MSB
pin of the control group. Variable Cis used for timing the
synchronized inner loop; this will run at the rate set by
ccycleticks that was set up in the start() method.
Inside the primary repeat loop, a variable called cycle
iterates from 0 to 5; this is used to designate which LED.
we're working with at the moment. As we did before, the
control pins are defaulted to inputs to disable everything,
‘The next step is to test our control value based on cycle
using a temporary mask. If the corresponding bit in fedbits,
is 1, we will activate the LED. This goes on while the cog
is running at a rate that fools our eyes into thinking
multiple LEDs are on at the same time.
To control the LEDs, we need to manipulate ledbits.
Here are two methods to do that:
Pub set_ledin, state)
32 (Un => 0) and (n =< 5))
if (state)
ledbits |= 1 << n
ledbits s= 1(2 << n)
pub set_ali (bits)
ledbits
bits ¢ $111111
The first method allows control of a single LED. We
pass the LED number (0 to 5) and a state value, where any
non-zero state value is accepted as on. I the state is not 0,
the corresponding bit is set to 1 (on); ifthe state is 0, the
corresponding bit is set to 0 (off).
For cases where we want to treat all LEDs as a single
value, the set_feds() method takes care of that.
Inside the demo program, there are two methods that
demonstrate single- and multi-LED access. The first is —
‘you guessed it — a six output Larson scanner. It would be
heresy to have a strip of LEDs and not program them to
do a Larson scan, right? This one can even be configured:
pub run_larson(cycles, ms) | n
repeat cycles
repeat n from 0 to 4
leds.set_led(n, true)
‘time pause (ms)
‘August 2015 MISEVOUS. 17FIGURE 5, Bad path,
leds-set_ledin, false)
repeat n from 5 to 1
lede.set_led(n, true)
‘time.pause (ms)
lede-set_led(n, false)
The first parameter of run_Jarson() is the number of
back and forth cycles to run; the second is the delay time
for each LED. For a one second cycle, the delay timing is
set to 100 ms by the caller.
‘The second method is a simple counter that uses all
six LEDs:
pub run_counter(ms) | a
repeat n from $11
all (n)
ase (ns)
1 to s000000
Lede. set
No, it's not terribly exciting, but it does, in fact, verify
that we can have up to six LEDs [appear to] be on at the
same time,
There you have it: six LEDs for the cost of three pins
and three resistors. There are a couple things to note
FIGURE 6. Overlay PCB.
18 NUTSHOLTS August 2015
when using Charlieplexed LEDs. When using the simple
circuit shown in Figure 3, the LEDs should be of the same
type and forward voltage. If you're going to mix LEDs,
remove the resistors shown and replace each LED with an
appropriate LED/resistor combination
Another thing that one must watch for is the resistor
values. Have a look at Figure 5; what this lustrates is the
possibility of lighting multiple LEDs under the right
conditions. When we light D1 (PO high, P1 low, P2
floating), there can be a secondary path through D3 and
D6 as shown,
This can happen if the combined forward voltage of
the LEDS is lower than the output voltage of the
controller, and the resistors are so small that enough
current can flow to light both LEDs — though they won't
be as bright as the target LED.
For my circuit, this isnt a problem because the
forward voltage of each LED is about two volts; there is
no way 10 light two of these LEDs in series with a 3.3V
micro. That said, if 1 moved this circuit to a 5V micto, |
would have to check the resistor values.
Finally, | mentioned earlier that the Spin driver will
run down to a clock speed of 20 MHz (PLL = 4x). We
‘can speed things up by converting the Charlieplex
‘operations to PASM; this will allow us to run all the way
down to 5 MHz (PLL = 1x). This might be helpful when
using the Charlieplex circuit in a battery powered
application,
Ie included a duplicate of the demo code which
uses the PASM version at the article link. Those of you
that are starting to make the move from Spin to PASM.
wil find the code interesting. The PASM is very simple,
and a near direct match of the Spin code.
Lock It Down!
If you're like me, you have solderless breadboards
INFIGURE 7. Overlay on PAB.with parts in them that never come out. In my case, many
of these are in the form of Propeller Activity boards
(PABs). My friends at Parallax have introduced a new
product that lets me keep my circuit and free up my
Activity boards. It's called the Circuit Overlay Board
(Figure 6}, and it’s compatible with the Activity board and
the various "Boards of Education’ from Parallax. Plus, its
less than six dollars!
You can see the overlay board in action in Figure 7.
On the left is an Activity board with the Charliplexing
Circuit installed. On the right is another with the same
Circuit soldered into an overlay PCB (printed circuit board).
Like any shield, I can pop this in and out at my leisure —
the PAB breadboard is no longer locked up with a favorite
circuit.
To make matters even better, Parallax has released the
DipTrace design files for the overlay PCB. The release of
these files will facilitate — and | hope encourage — the
creation of shields for the Propeller Activity board. Ive
certainly got plans. Will you join me?
Timer Update
Every day, | seem to find another use for my timer
“object (covered in the June 2015 issue) and find reasons
to add features. A note from a Nuts & Volts subscriber
reminded me: Let others review your code — especially the
code you're really in love with. And, no, tm not ashamed
to say that I'm in love with some of my code. Real men
admit such things.
A gentleman named Dennis Page kindly pointed out
that the mark() method was unnecessarily recalculating
values; these calculations take time, hence affect the
speed of the method, He was absolutely right. | had been
so close to the code that | looked right past this
inefficiency. Thank you, Dennis, for pointing this out. The
Updated object is used by the Charlieplexing demos, so
do save it to your Library folder.
Until next time, keep spinning and winning with the
Propeller! MW
a
aa i
2a Technologic
wu
TS-7970
Single Board Computer
Industrial High Performance
i.MX6 Computer with Wireless
Connectivity and Dual GbEth
311 Giz Solo or Quad Core Freescale iMX6 ARM CPU.
82GB RAM, 4 GB eMMC Flash
Starting at
8 WiFi and Bluetooth Module $169
2x Gigabit Ethernet, 4 USB ‘1y 10
HDMI, LVDS, & Audio In/Out "Noguesearingae = S214
Linux, Android, QNX, Windows $89 caty100)
ae)
Peers
DESIGN YOUR SOLUTION TODAY
CALL (480) 837-5200
TS-TPC-7990
Touch Panel PC
i.MX6 Mountable
Panel PC with Dev Tools Such
as Debian GNU and QTCreator
17 Inch Touch Panel PC Powered by 1 GHz .MX6 ARM CPU.
a Resistive and Capacitive Screens "Starting at
10 Inch Screen Available
Linux, Android, QNX, & Windows fee
4 OI Creator, GTK, DirectFB, and More $342
Yocto, Debian, Ubuntu Distro Support ut
ee)
solutions add value
ens
August 2015 MUSEYDUS 19ll HARDWARE
™ SOFTWARE
NEW l™ GADGETS
™ TOOLS
ACTOBOTICS ACTOBOTICS GEARMOTOR
GOOSENECK ROBOT KIT POWER INPUT BOARDS
the Gooseneck™ now available from ServoCity is a Teme
tle traikwheel robot kit that glides effortlessly across power connector
the floor. The 2.975” orange skate wheels are each driven boards also now
by a 195 RPM 3V-12V precision planetary gearmotor. The available from
“truck-bed!” style chassis is ideal for battery storage, ServoCity add
electronics, or for hauling things around, The chassis is versatility to any
almost entirely snap-together, requiring only a 7/64” hex gearmotor. These
key for assembly. The chassis plates incorporate the boards simply slide
0.770" Actobotics hub pattern, allowing for easy over the motor
attachment and customization using other Actobotics terminals and solder
components. The protruding “Gooseneck” piece provides in place. The pre:
a base for a robotic arm, gripper kit, scoop, or other installed .100"
sai acct ORD
ms different plug styles
UST, Rx battery connector, male servo connector). The
be utilized to run additional wires to the motor or to daisy-
chain multiple motors. It is sold with 90 degree header
pins pre-soldered to the board. Prices start at $0.69/each.
For more information, contact:
www.servocity.com
HIGH SPEED CONDITIONED
MEASUREMENTS WITH
CHANNEL-to-CHANNEL
ISOLATION
Dn isteren coming Corporation announces the
release of the SC-1608 series of USB and Ethernet data
acquisition devices. The SC-1608 series features analog signal
conditioning, allowing customers to easily measure voltage,
thermocouple, RTD, strain, frequency, and current. Isolated
analog output and solidstate relays make it an ideal platform for
systems needing flexible conditioning and low cost per channel
‘The SC-1608 series is priced starting from $999.
‘There are four devices in the SC-1608 series with sample
rates up t0 500 kS/s. Fach device accommodates up to eight 8B
isolated analog signal conditioning modules and eight solid-state
20 WISEVOUS August 2015relay modules. Up to two isolated
analog outputs are available on some
models. Signal conditioning modules
are sold separately
Microsoft Windows software
options for the SC-1608 include
DAQami and TracerDAQ to display
and log data, along with
comprehensive support for C, C+,
#, Visual Basic, and Visual Basic
NET. Support is also included for
DASYLab and NI LabVIEW. UL for
Android provides programming
support for Android devices. Open
source Linux drivers are also
available
For more information, contact:
Measurement
Computing
www.meedag.com
HIGH SENSITIVITY
CURRENT
PROBES
G vis Company Inc, announces
the availability of the CPO30A
(50 MHz) and CPO31A (100 MHz)
high sensitivity current probes from
Teledyne LeCroy. Providing
sensitivity down to 1 mA/diy, users
can now measure currents from
milliamps right up to a peak current
of 50 amps, all with the same
probe. This represents ten times the
sensitivity of previous models, and
allows for more precise low current
measurements on most Teledyne
LeCroy oscilloscopes. When used
with Teledyne LeCroy’s 12-bit
resolution HOO high definition
oscilloscopes, users can obtain highly
accurate, low current waveforms for
improved debug and analysis
capabilities.
The CPO30A and CPO31A
probes expand the capabilities of
Teledyne LeCroy current
measurement products to additional
applications by providing the ability
to measure and analyze very low
current waveforms, The probe's small
jaws are designed to measure
Continued on page 69
NATIONAL. RF, IN
TYPE HFDF
NOISE LOCATION SYSTEM
"XO
LOCATE NOISE IN THE HF SPECTRUM
Visit www-NationaiRF.com for this
‘and other Radio Products!
‘Office: 858-565-1319,
Te ae
NV BOOK SPECIALS
he aspen P
cr
re
www.boxedkitamps.com
Build something
you'll enjoy every day.
DIY HiFi Audio kits.
Crore
MDE8051 Trainer
by Digilent
Dienst A 10H
Sr es
SDP 8.22 rte
One-Stop Shop for
Mechatronic Components
EXPLORE €
DESIGN
BUY ONLINE @
www.sdp-si.com) @ =
‘no minimum requirement
De
August 2015 MUMSEVOUS. 21BUILD IT YOURSELF
Motion Triggered Plane Aisle
MUG
[ U
|
=
By Geoff Clark
rv@beamicom
Post comments on this article and
find any associated files and/or
downloads at www.nutsvolts.com
Jindex.php2imagazine/article/
‘august2015 clark.
Reading through parts catalogs is a pleasure which being a subscriber to Nuts &
Volts, you can probably relate to. As | leafed through the M. P. Jones & Associates
(MPJA) offerings recently, a motion sensor caught my eye because it was only $3.95.
The cheapest at a major distributor is many times that. It made me think of how to
automate some of my home lighting, because | am the stereotypical dad that walks
the house at night snapping off lights left on by the non-electric-bill-paying residents
and muttering under my breath. A few pages later was a five meter roll of blue LEDs
that | noted was down to just over a dollar a foot. LEDs for illumination were
unknown a few years ago, and now look. They are affordable, and you just peel off
the backing and stick them anywhere. Yes! | could have cool blue strip lighting along
the hallways of my home — just like the fancy ones that light up an airplane aisle in
case of emergency. Plus, there’s no extra wiring for a wall switch (which everyone
but myself would ignore anyway) because just walking by turns it on!
22 NUTBWVOUS. August 2015hat else would 1 MOSFET N-ohon enh
Wess:
sensor so it didn’t
turn on during the day? No,
it's built in and adjustable! A
microprocessor to add a delay
before turning off? No, the
delay is built in and adjustable! re
Sensitivity? Adjustable. five ee
OMNSI5L is SOvDS, 14¥G, 3.0.
254 ROS On max x 15a x 150 = .12W
Iat S0degc/W = NI degC rise
Power jock depends on power supply.
Commen types ore 5.5x2.imm ond §.5x2.5mm.
FIGURE |.
12V LED strond
Length determines amperage.
5m of thie LEDs 150
volt regulator? No, this $3.95,
bargain can run off the same
12 volt supply that powers the
LED strip. Speaking of which, a
12 volt, 2.5 amp supply is just
$5.95 in the same catalog!
Assembly
Figure 1 shows how to
hook everything up. The only component not available at,
mpja.com is the MOSFET that drives the LED string
controlled by the 3.3V “test” output of the motion sensor,
Go to the supplier of your choice and use these
parameters: MOSFET (obvioush), N-channel enhanced,
single, through-hole (avoids soldering), continuous drain
current at least 2.5A (the capacity of the power supply),
drain-source breakdown voltage over 12V (select over 20V
for safety), gate threshold voltage under 3V, and resistance
(RDS on) less than 0.16 ohms (because we want less than
‘one watt of heating). | found 516 in stock, many under a
dollar. Sort by price and start double-checking the
datasheets. | used an MTPION1OEL which | don’t
recommend because itis obsolete, but I had it on hand.
Its RDS on is typically 0.17 ohms, so at 1.5 amps (full blue
LED string), | expect 0.38 watts (W = FR)
Ut rated 4-24VDC,
>>
Speslomeir ccc Ent
IF you have ever sat at a railroad 7 7 nmaiiieitiawe
crossing, you may have noticed that the }}}]] @ 133 @ PH ONIN ONIN
flashers go off instantly when the last car F2| |W2 El
of the train leaves the crossing. They wi
come on when the train is a good. Sensor Grae Sensor placement to give realistic
distance away (prescribed by state and Crossing action ofthe flashers going off as
federal aw), and work from either
direction. With an extra pair of sensors,
‘we can have that realistic action. With
four sensors, we have enough tools to
do a timing job to calculate the scale
speed of the train’s passage from either
direction.
‘Most of the jobs on a model railroad
involve sensing the presence of atrain.
Traditionally, it has been done by sensing
‘current flow through the track, or by the
‘older method of optical or mechanical
sensors. The advent of microcontrollers
has revived a simple use of alight L
dependent resistor (LDR), or 7
:
1
photosensor. I have also used
phototransistors (they are presented here
as an alternative).
In either case, we place the sensor
MLFIGURE 1. Placement of the four
photocell track sensors. The
speedometer distance should be
exactly the same on either side
of the crossing and accurately measured for
inclusion in the software.
Resistance.
train clears the erossing,
Speedometer distance is accurately
set up to give SCALE speed .
Analog
‘val Vala a pin
Digital Va 1027
ina drilled hole in the center of the fester mre
track, connect it through a simple “resto digital mamber FIGURE 2.The relationship between
voltage divider to an analog input pin,
and rely on the Arduino’s builtin analog
to-igital converter (ADC) to yield a
digital light level number.
Figure 1 shows the placement of
the four sensors at the crossing, The “Speedometer
Distance” shown needs to be the same between the two
sensors on either side of the crossing, and must be
accurately measured for inclusion in the software sketch.
Calibration is the
First Step
With any optical sensor, we need to find that value of
digital data the processor produces when it has gone from
‘the light level and resistance of a
photosensor. By using them in a simple voltage divider
and measuring their output levels, a “threshold”
number is established for the software.
normal light to fully Covered in the layout room
environment. I call it the “threshold” number. It will
depend on the ambient room light at the final installation,
but we can simulate layout lighting conditions and do a
calibration job to determine the number we need
Figure 2 shows the concept and simple hardware to
move from light levels and the resistance of the LDR to a
sensor threshold number. Of all the LDRs | have used over
the years, | don’t think I have ever found two batches with
the same bright to dark resistances. A simple voltage
divider will provide the final
ITEM SOURCE
Crossing flashers and a speedometer
Photoresistors (Catalog #PRE-24)
Phototransistors (Catalog #PTR-2)
LCD displays,
Arduino boards (many sources)
20x4 LCD display
Scale Factors: G gauge 26 (varies); O scale 48; S
scale 64; HO 87; N 148; Z 220.
wwwallelectronics.com
wwwaallelectronics.com
www.sparkfun.com
www.sparkfun.com,
interface for each of the sensors to
the processor.
Photo 1 shows the mock-up
on the bench for the four sensors |
used. You can build a much
simpler single LDR setup for the
batch you are using to do your
calibration.
Use the overall hookup guide
(Figure 3) shown in the main
PARTS LIST
August 2015 WSHOUS 29=
Son
schematic, then run Sketch 1 (available at the article link).
It will work for one or all four sensors in the final
arrangement. It wil allow you to vary and simulate the
ambient light level of your layout room. Then, you can
‘observe — on the serial monitor — the change in digital
values as you shade the sensors fully. Armed with these
values, you can set the threshold number about halfway in
between. If your sensors “clear” from partial light between
the cars, move your threshold number lower.
an asin
pr bww—f
a0 pen
PHOTO |. The development mockup used to calibrate sensors and the
LCD screen display. The screen display shows the Block Clear status.
An Akos store the
What We
Need from
the Arduino
| used an Arduino Uno, It has
six ADC pins, and we will use
four of them, We need to
alternate — on and off — two
flasher LEDs at a rate of about 1
Hz. So, we need two digital pins
for that job. The LCD display uses
six output pins unless you use
‘one with an °C backpack. Then,
you're down to using only the SCL
and SDA pins plus five volts and
GND.
The current demand for the
whole job is under the limit, and
we could probably even tie in
another job. You could use a
hardware interrupt to sense the
change in light levels, but the
Millis timer won't function during
an interrupt service routine, so
let’s keep it simple. You could also do the flasher
alterations with a hardware setup such as an LM555 chip
but — there again — software is sure a lot simpler.
Two Applications in One
eoe How It Works
Take a look at Figure 4. Here's the sequence the
processor will go through as it executes its continuous
“loop.” It monitors the westbound
sensor and if it changes. a train has
entered the area. If not, it checks the
eastbound sensor and then returns to
the start of the “polling” loop if
nothing is found. If sensor WI has
been covered, a train is detected, so it
tums on the two LED flashers with a
subroutine to time them to alternate at
about one cycle per second. It waits
for the sensor across the crossing
(wa) to be covered, and does nothing
Until the train has completely come
LoD
sina
80 NITSIVONS, August 2015
FIGURE 3.
‘Schematic for the
Arduino hookup.
actoss it. The while do loop is great
for such stalling,
When the back of the train clears
the sensor (W2), it turns off the
flashers and starts timing for the
speedometer run, The intrinsic Mills
function gives us the number of
milliseconds as a number since the lastLogical Flow for the Crossing Flasher
‘Speedometer Sketch
FIGURE 4. Overall program logic for the flasher!
speedometer.
reset, so we Can use a start and finish value later to get
very accurate real time, When the back of the train finally
clears the outer most sensor (E1), it records a “finish” time
and computes the speed.
Speed is dependent on your scale, and by changing
the scale factor (87 for HO scale, 48 for O, etc), this
scheme will work for any model railroad big or small, The
computation of scale speed takes the milseconds of
elapsed time, the distance traveled in inches, and the scale
‘of the model, and turns it into a scale MPH. The same
sequence occurs for a train going eastbound with only a
difference in the displayed train direction
The LCD uses the builtin library of the Arduino to
produce the display shown for a westbound train, After a
delay, the display goes back to a clear block.
Making All Model
Railroad Animation
More Realistic
If you enjoy realistic animation as one more facet of
Microprocessors and Model Trains
Meet Head On!
In order to bring the hardware and software together, @
‘mockup was needed an the bench. Track sensors (LDRs) were
‘mounted in a strip of plywood. A piace of propainted track
roadbed from another project was on hand and worked out ust
fine, The LCD — which would eventually be mounted in the track
framework fascia nezr the flashers — was also tied to the
Arduino Uno with plug ended jumpers.
‘After software debugging and speedometer time checks, the
entire units ready for mounting and permanent wiring. It works
for any scale model ralirad and fits in a very small amount of
space.
PHOTO A. Screen display after a train has passed.
The LCD screen fits into the fascia nearby.
model trains, you can give ita big lift by using a
microprocessor and servos. In the larger scales, the
‘commercial crossing gates and moving accessories are
usually driven by a solenoid. I's way too “jerky” to be
realistic, and begs for the installation of a servo to slow it
down. It would be fairly simple to rebuild the device with
a servo attached, then slow down the motion and change
the timing to come on and off like we did with the
flashers in this project. Look around your layout. There are
August 2015 WISNOUS 31Imagine
tpi
numerous microprocessor projects waiting to be explored!
= DOWNLOAD our free CAD software
DESIGN your two or four layer PC board
. : a SEND us your design with just a click
F waineed lop
RECEIVE top quality boards in just days
expresspcb.com
32 NUSIVOUTSREADER FEEDBACK emmarsnmer
| am thiilled to see that there were
four very informative and very well
written articles on radio.
For JW. Koebel's article, "Fix Up
That Old Radio," I saw the mention
‘of the fact that preWW II radios had
DC power provided by the radio to
the speaker to energize the
electromagnet in the speaker.
A bit of a warning here. About
20 years ago from the "School of
Hard Shocks," I learned these radios
have a lot of dangerous voltage on
the speaker field wire (90 to 250
volts).
found out the hard way while
checking out the innards (alot larger
and more componentiaden than the
DeWald 618) of a cabinet radio for a
coworker who was finishing the
cabinet.
I didn't measure the voltage with
a regular meter, but my *skin meter’
said REALLY HIGH and biting.
Tim Brown N&V Q&A
Good point, Tim. 1 had one of
these old speakers and know exactly
what you mean. Also, a good way to
learn XL = 2pift. is if you disconnect
the speaker while energized (my skin
meter registered that, as well)
Bryan Bergeron
Radio and Rockets
| found Bryan Bergeron’s editorial
‘on amateur radio interesting. | agree
with him on the points he made.
| would like to take the time to
call attention to an increasing use of
amateur radio: model rocketry.
It has been done in the past, but
I'd like to call specific attention to the
efforts of Bdale Garbee and Keith
Packard in producing Arduino-based
‘open source flight computers for
model rockets. | have no financial
connection to the Altus Metrum
‘company but have had the privilege
of attending launches where Altus
Metrum products were in use, and
sometimes Bdale and Keith were
there developing stuff.
GPS coordinates of the rocket’s
location and throughout the flight are
relayed to ground via telemetry using
‘one of the ham bands. This link —
altusmetrum.org —should take you to
more information that could/should
be part of a future application/article
of amateur radio,
The fight computer is powerful
‘enough to have a role in balloon-sats
and cubesais.
hope to see a future article on
amateur radio applications in
rocketry.
George Shaifier
Electronics Courses
Cleveland Institute of Electronics
‘An open source Raspberry Pi Based 1U Rack Mount
Internet Appliance With the World's Only 10"x 1"
id mowntccupman. susan power coney, sehen srs,
‘ivr he le can ow aes ua rope ok
‘Train at home to be a professional dectonics or computer
technelan! Learn with hands-on labs, instructor support online
‘exanis, videos and instructor le chatrooms.
FREE course catalog ewwcie-we.edu or (800) 243-6146
«NEW Rabo Auomation Lab + NEWS Comper Scant Spcast
+ Industrial etn wih PLC + Broadet Engineering
+ Becton with ECC + PCTrosblshootng
+ lectonksTouleshootng + Networking
Visit wwwcie-weedy and start today!
Features at a glance:
August 2015 WISNOUS 33By Larry Coyle
Post comments on this article and
find any associated files and/or
A Car Parking Assistant er
It's great to replace your old beat-up car with a brand new one, but when you first
bring it home and find that it’s a tighter fit in your garage than the old one, you may
have a problem. In my case, the new car was a bit longer, and it was a challenge to
get it into that sweet spot where it was in far enough to close the garage door, but
not so far that | bumped into the storage shelves on the back wall.
34 NUTSIVOLTS August 2018Ceiling at just the right spot is the classic solution, but
with more than one person using the garage —
possibly driving different cars or just backing in — that just
‘wouldn't cut it. Also, it would be in the way for somebody
walking through the empty garage.
Some of the commercial garage parking aids that |
reviewed also had their drawbacks: One system used a
laser beam shining down onto the dashboard of the car;
‘thers had only a limited range of adjustment or warming
lights that were too dim, The situation seemed ripe for a
‘custom electronic solution.
The System’s Approach
Fim always attracted to projects that involve firmware
as well as hardware development, and it seemed that a
microcontroller — plus some way to sense the location of,
a car — would be a good start. As feedback to the driver,
‘of the car, l envisioned a series of bright lamps mounted,
‘on the rear garage wall which would come on as the car
passed through three “zones:” 1) when the car was nearly
inside the garage; 2) when it was in the prime parking
area — which | think of as the “comfort zone;” and 3)
‘when it had gone too far and was close to hitting the wal
This job is simple enough that almost any
microcontroller would do. I have used the Propeller multi-
cote processor by Parallax (www,parallax.com) for a few
projects, and a survey of my supply cabinets tumed up an
Unused Propeller USB project board. This board features —
in addition to the Propeller microcontroller unit (MCU) —
voltage regulators, clock crystal, USB interface, and a
good sized area for additional components. It would be
ideal for this application.
| began to kick around ideas to sense the distance to
a car. I considered a motion detector or a diode laser
beam reflected off the front of the oncoming vehicle.
Neither approach seemed accurate enough, and the laser
spot idea wouldn't work if you backed the car in. | could
also anticipate setup problems with these schemes.
Eventually, | settled on a non-contact approach using,
an ultrasonic range finder to measure distance. Parallax
sells these devices, good for distances up to three meters
(about 10 feet), so I sent for one,
Next, my thoughts turned to the signal lamps. These
had to be bright enough to be easily seen in broad
daylight. | stewed about this for a time, considering and
rejecting several ideas; for instance, using relays to control
incandescent bulbs. | found my answer in a local
automobile paris store. For just a few dollars each, | was
able to pick up some running lights — also knows as
clearance lights — of the type used on big truck trailers.
These lamps contain several high-intensity LEDs; are very
ce I know ... a tennis ball suspended from the
visible — even in bright sunshine; and run nicely on 9-16
volts DC. The lamps come in two colors (red and amber),
so | bought one of each and decided I would use
firmware to show when the driver had strayed into the
third zone (mentioned above) and needed to back up.
Refining the Idea
I didn’t want the system to run 24 hours a day —
mainly as a power conservation measure — but also to,
turn off the ultrasonic pinger when it wasn't needed, since
bats, moths, and (I suppose) other creatures are sensitive
to these frequencies. So, | looked for some way to apply
power to the system when the garage door opened, leave
it on for a few minutes while the car was being parked,
and then automatically shut down.
‘A micro switch activated by the garage door opener
‘was the most direct approach, However, there were some
mechanical difficulties involved in my case, so | began
looking for another plan. Like most overhead garage door
systems, mine features an overhead lamp which turns on
when the door opens and remains on for about five
minutes. Just what | wanted!
To avoid any modification or direct connection to the
‘existing door opener (and possible grounding and safety
problems}, | decided to go with an inexpensive cadmium
sulphide (Ca) light-sensitive resistor which I would locate
inside the overhead light fixture, close to the bulb. The
change in resistance when the overhead light came on.
would tum on a MOSFET which would apply power to the
MCU board and the signal lights.
Novy, | felt | had the basic system design pinned
own, With the huge capability inherent in the Propeller
and the ease of programming it, any reasonable
refinements could come later.
A Few Preliminary Tests
My first priority was to see if the components | had in
mind were adequate for the job.
First, [checked the current requirements for the LED
lamps and found them to be fairly modest — only about,
40 millaps at 12 VDC for each lamp. Adding in 30
milliamps for the ultrasonic range sensor and 20 mA for
the Propeller microcontroller board meant that the whole
thing could easily be powered from a small wall wart
power supply.
Next, | soldered about 30 feet of twisted pair to the
terminals of the CaS photoresistor and mounted it inside a
clear plastic boitle. Refer to Figure 1. | fastened it with
tape inside the garage door opener overhead lamp close
to the bulb, and hooked up my digital multimeter to
measure the resistance. | was pleased to see that with the
August 2015 WISNOUS 35FIGURE |. Cadmium sulfide photoresistor and plastic
bottle ready to receive it.
overhead light off, the meter read over one megohm;
‘when the light was lit the resistance dropped to less than
20K ohms. Plenty of range for switching a MOSFET!
Thad no qualms about the Propeller MCU chip. From
‘other projects, | knew it had more than enough capability
{or this job, since only four /O pins are needed: two for
the LEDs; one for the ultrasonic sensor; and one for a
pushbutton switch used for calibrating distance (more on
that later), Processor speed is not an issue either for this
task.
The Circuit Design
At this point, | felt | had enough of a handle on things
to go ahead with the actual circuit design, The system
block diagram in Figure 2 shows how the major
‘components work together. The system block labeled
“Power Control” contains a P-channel MOSFET whose
function is to switch power to the rest of the circuit under
[Ppvea Seneay
(cas)
INFIGURE 2, System block diagram.
control of the optical sensor. In other words, it acts as a
solid-state relay.
Circuit details are shown in the schematic in Figure 3.
The NPN transistor, Q1, is driven to cut off when the
sensor is dark; Le,, when its resistance is high. This allows
the gate of the MOSFET, Q2, to be pulled high, turning off
Q2 and thus cutting off power to the rest of the circuit,
The only current drain now is a few microamps due to
leakage through the MOSFET and the photoresistor.
Diode, D2, in the emitter of Q1 is there just to ensure that
QI cuts off completely — even if there may be a slight
leakage of light onto the sensor — as on a bright sunny
day with light streaming through the garage window.
Note that an NPN Darlington transistor — a BC517,
for example — could be used in place of the Q1/D2
‘combination since the Darlington inherently has a higher
base-toremitter forward voltage drop (Vbe) than the
2N4401. 1 just used what I had available.
‘The LEDs get their power directly from the raw DC
input. As mentioned previously, each LED lamp uses
about 40 mA when it’s on and is controlled by a 2N4401
‘switching transistor. There is nothing critical about these
transistors, and almost any NPN capable of handling a
collector-to-emitier voltage (Vce} greater than the input
supply voltage will do.
Momentary normally open (NO) pushbutton switch,
1, simply provides a user input signal for use during the
calibration procedure. This is explained in the Calibration
section of this article. Schottky diode, D1, is in the circuit
to prevent any disastrous consequences if the power
source is accidentally reversed.
‘The ultrasonic pinger is an easy-to-use non-contacting
distance sensor which operates on the same principle as,
range‘inding radar. Besides power and ground, it uses just
a single control pin driven by the microcontroller.
‘When the control pin receives a pulse from the MCU,
the pinger emits a burst
of highfrequency (40
kHz) sound. The control
pin then outputs a high
level until an echo return
De Powerin
716 Vde
(
prey
MCU - Parallax Propeller
Project Board - USB.
is received,
The width of the
signal from the control
pin is the same as the
echo time delay, and is
therefore a measure of
the distance to the
reflecting object. Parallax
teD
190
specifies a supply voltage
Pe
of five volts for the pinger,
36 NITSIVONS August 2015
but I found that theSchottky Diode
1N5B18
IRF9520
P-chan MOSFET
if Vin to.
e cu
7-16 Vide in oe
”
ev conrol
from MCU (PO)
optical
Sensor Pa ©] amber
ea-F e go avwor_[9| “U5
e Pa
AMBER onto, 2330
fromMcu(et) se
D2 Re
ou Naga San
Pinger Caltration Towcu
te “et (0)
s
O e ‘Control Signal from MCU (P7) ate
° +33.Ve0
O e t
FIGURE 3. Electri
| schematic. All components shown here (except for the pinger and optical sensor) are
through-hole devices and are mounted in the prototyping area of the Propeller USB project board.
device works with no problems at 3.3 volts. | was prepared
to installa levelshifting circuit between the pinger control
pin and the MCU using a single-transistor circuit (which
has appeared several times in the pages of Nuts & Volts)
but it seemed to be unnecessary in this case.
I have included a description of a suitable level shifter
‘with the information package at the article tink if you
should choose to go that way.
The firmware for the garage sentinel project was
written entirely in the Propeller Spin language, and is very
basic and easy to understand. The program begins by
initializing the 1/O pins and retrieving the near and far
limits of the comfort zone (program variables nearmark
and farmark), which have been stored in EEPROM during
the calibration process.
Next, it enters an endless loop which repeats every
250 milliseconds, where the first order of business is to
check the state of the calibration pushbutton,
If the button is depressed logic low), a calibration
routine (called “method” in the Spin language) is entered
IF not, the program sets the MCU pinger control pin as an
‘output and pulses it high for 50 microseconds.
Next, it sets the pin as an input and monitors the
duration of the return signal. The duration is converted
from system clock counts to distance in centimeters and is
stored in the program variable distance.
A series of comparisons follow:
+ If distance is greater than 260 cm, both LEDs are
tured off
+ lf distance is less than 260 cm, the caris
approaching the comfort zone and the amber LED
is turned on,
+ If distance is less than the maximum zone boundary
{farmark), the car is within the comfort zone and the
red LED only is turned on.
+ If distance is less than the minimum zone boundary
(nearmark), i's beyond the comfort zone and the
red LED flashes at a rate of twice per second,
The loop then repeats from the beginning
Calibration
In this mode, the user gets to set the distances
marking the near and far limits of the comiort zone for
parking the vehicle. These distances are stored in program
variables nearmark and farmark, respectively, and also in
EEPROM so they can be retrieved every time power is
applied to the system. As mentioned in the firmware
description, the firmware periodically checks the state of
‘August 2015 WISNOUS 37the calibration pushbutton. If the button is pressed, the
calibration method is entered. Here, the duration of the
button press is captured, and again a series of
comparisons is carried out:
+ If the button press is less than one second or more
than 20 seconds, the calibration method is exited
and control returns to the main program.
+ If the button press is between one and five seconds,
the distance reading is stored in nearmark and in
EEPROM, and the calibration routine is exited
+ lf the button press is between five and 20 seconds,
the distance is stored in farmark and in EEPROM,
and the routine is exited,
In practice, the actual calibration procedure is pretty
straightforward
First step: Drive your car slowly into the garage and
stop where you consider the beginning of the comfort
zone to be. Then, press the calibration pushbutton for
more than five but less than 20 seconds. This saves the
location in EEPROM and in the farmark program variable,
Second step: Pull the car forward to where you want
the end of the comfort zone to be. Now, press the
calibration pushbutton for at least one second, but not
more than five seconds. This records the nearmark
location
‘That's all there is to it!
Hardware
For an enclosure, | went with the neat clear plastic
multiboard project box offered by Parallax that is designed
to fit the Propeller USB project board. There is plenty of
room on the board to accommodate the small number of
components required. Figure 4 is a picture of the board
populated with all components
needed to bring two external cables into the box
from the remotely-located optical sensor and the three
wire cable to the pinger. There are several knockout
sections of various sizes convenient for feeding cables into
the box. | had to cut a hole in a side panel to mount a DC.
power coax jack, and another hole to give me access to
the USB port on the project board (in case | wanted to
modify the firmware after assembling everything).
T mounted the two LED lamps on the front panel of
the enclosure where they fit very nicely, as shown in
Figure 5. The final configuration of the complete garage
sentinel system as set up in my garage is shown on the
first page of the article
In that photo, you can also see that | put the pinger in
4 small separate box at the end of a short cable since |
had to put it low enough to “see” the front of the car. Of
course, the box with the LED lamps had to be high
enough for the driver to see it.
To power this project, | used a wall wart type of
external power supply, capable of supplying about 200
mA at nine volts DC. One word of caution which applies
to any home-built project using this type of power supply
Be sure to check the open voltage (ie., the
unloaded output voltage) at least once before
connecting your wall wart to the device you are
building.
Some of these supplies can put out nearly twice their
rated voltage without a load, and if you turn on the supply
before connecting it to your project, the brief overvoltage
before it settles down could be extremely bad news to
your system.
{TEM
Ri 1/4 watt resistor
Re 1/4 watt resistor
Ro V4 watt resistor
Ra 1/4 watt resistor
RS, RE 1/4 watt resistor
Ry 1/4 watt resistor
Re {V4 watt resistor
DI Schottky diode
2 Silicon diode
Q1,03,04 NPN transistor
P-channel MOSFET
SI NO pushbutton switch
Pi, P2,P3,P4 Male pin header
PS.
‘Male pin heads
Rad high-intensity LED.
Amber high-intensity LED
Propeller USB project board
Ultrasonic range sensor
Cadmium sulfide photoresistive optical sensor
‘Multiboard enclosure, clear plastic
Power supply (wall wart)
pa
eae PARTS
ha
pages) LIST
ee
sat
Parallax PIN 32810
Parallax PIN 28015
Parallax PIN 350-0008
Parallax PIN 721-3212
9-16 VDC 100 mA
or greater
38 NITSIVONS August 2015The ultrasonic pinger used in
this project can be utilized to
measure distance to neatly any
surface — solid or liquid. If
pethaps you are thinking of other
applications, | should mention
here that the performance of the
sensor isa bit dependent on air
temperature. This doesn’t imply a
defect in the pinger’s design; i's
just a property of sound in ai
Sound travels faster in warm
air than in cold, and since we're
using the time delay of the return
echo to determine the range,
temperature can affect the
distance reading, The folks at
Parallax provide a handy formula
on the pinger datasheet for
correcting the range
measurements, If you are after the
ultimate accuracy, you will need
to do this compensation.
This means adding a
temperature sensor to the system
and a bit of firmware to do the arithmetic. Not difficult to
do, if you need the accuracy; | chose to ignore this
problem for the garage sentinel since my garage stays
pretty much between 3 and 50 degrees C, resulting
in a possible error of about plus or minus four
percent. This amounts to just a few centimeters at
the closest approach. Not enough to worry about for
parking the car.
‘As mentioned, there is plenty of untapped
capability in the Propeller MCU on this project. | can
imagine adding a beeper or other auidible alarm
when the car gets too close to the garage wall as an
additional warning besides the flashing LED. Or,
another cool feature might be to continuously
increase the LED flash rate as the car gets farther
past the comfort zone
Also, it shouldn't take much to add a second
pinger, arranged to give a wicler coverage angle. This
‘would be useful if you have a wide garage, or more
than one car,
I may build up a future version of this device
using some of these upgrade ideas, but for the
present it suits my needs asis. Now, | can always
IGURE 4.The Pro
The calibration pushbutton is the red
of the board. Th
oer ard
eller USB project board with all components mounted,
uutton in the left center
o the
Sw."
from the optic
wo-pin header
label
anything, and with enough room to walk around the car in
ease the car into the parking comfort zone without hitting
front and back after the garage door is closed.
MFIGURE 5.The
LED
imps mounted on the front panel of
the enclosure
August 2015 MTSEVOUS. 39BUILD IT YOURSELF
A WEB CONTROLLED MUSIC
AND INTERNET
INDIO
LAY
Post comments on this article and
find any associated files and/or
downloads at www.nutsvolts.com
index.php 2imagazine/articlel
augusi2016 Lindley.
>
Long-time readers of Nuts & Volts may recall that | have covered Internet radio topics
a couple of times in the past. My first build was based on a repurposed Wi-Fi router
and was described in the article, "Build Your Own Wi-Fi Internet Radio" in the March
2012 issue. With the arrival of the Raspberry Pi (RPi), | updated (and simplified) my
approach and documented that in the article, "More Raspberry Pi Anyone?" in the
August 2013 issue. These systems have served me well over the past few years, but
when I stumbled across the Pi MusicBox software for the Raspberry Pi, | knew | had
to revisit this again. The Pi MusicBox software combined with a RPi (B+ or Pi 2 B)
makes for an incredibly flexible music system. | truly cannot envision a system much
more flexible than this.
40 NITSIVONS. August 2015fhe Pi MusicBox software running on the RPi provides
the following features:
Remote control using a web interface from any browser
‘on any device or by using an MPD client app like
MPDroid for Android.
+ A headless auclo player for streaming music from
Spotity, SoundCloud, Google Music, and Podcasts (with
iTunes, gPodder directories), local and networked music
files (§MP3/OGG/FLAC/AAC), and Web/Internet radio
(ovith Tuneln, Ditble, AudioAddict, Soma FM, and
Subsonic).
+ Includes AirTunes/AirPlay and DLNA/OpenHome for
streaming from a phone, tablet (iOS and Android), or
PC using software like BubbleUPnP.
Flexible USB audio support for all kinds of USB sound
modules including generic (like | used here), HifiBerry
(DAC/Digi/AMP/#), IQ Audio, etc, for higher end
audiophile applications.
Can play music files from the RPi's SD card, from an
attached USB Flash or USB hard drive, and over a local
area network (LAN).
+ WiFi support for Raspbian (the officially eecommended
RPI operating system software} supported WiFi
adapters.
The music player system I'll describe in this article
{refer to lead photo) is lke having a WiFi remote
Controllable iPod that also plays 100s of Intemet radio
stations, and can play music from many streaming
services. | have over 500 digitized CDs online, and this
system plays them flawlessly. In fact, L copied my entire
iTunes music library onto a 64 GB USB Flash drive that |
included in my new MusicBox player system and away |
went.
The project itself is relatively simple to build with the
packaging being the hardest part. I you look around for
deals, you can build this music player system for around
$80. You will need a stereo system to plug into, however,
as the build I describe here does not include amplifiers or
speakers.
Finally, even though Pi MusicBox software is hosted
‘on the Raspbian version of Linux used on the RPi, there is
no requirement for using the Linux command line during
installation or normal operation. A Parts List for the music
player for the configuration | built is shown in Figure 1
‘The schematic is shown in Figure 2.
Part Description Part Number ‘Source
Raspberry Pi Model B+ or Raspberry Pi2 Model 8 83-16317 or 83-16530 memelectronics.com
MicroSD Card 2 GB or larger 83-11235, memelectronics.com
USB Audio Adapter ‘Syba SD-CM-UAUD USB
Stereo Audio Adapter ‘amazon.com
USB Wii Adapter Miniature Wi-Fi (802.11b/g/n)
Module ID: 814 ‘adafruit.com
USB 64 GB Flash Drive PNY Attaché 64 GB USB 2.0
Flash Drive - PFDB4GATTO3-GE ‘amazon.com
Male Micro USB Connector Micro USB Type A
Male five-pin Connector ‘amazon.com
Power Switch Any swit
Power Indicator LED Any color
(used a
1K ohm 1/4 watt Resistor
USB Cable (minimum three foot length) 93-14274
USB Power Adapter 2 amps @ 5 volts 28-19300
Audio Cable
ich you would like to use
F andlor size
color changing RGB LED.)
memelectronics.com.
memelectronics.com
Stereo cable for connecting USB
audio module to your stereo system
250 uF @ 25 volts or greater Filter Capacitor
1 jlF Capacitor
Wire, solder, baltic birch plywood,
‘smoked plastic sheeting,
wood screws, and other misc. hardware
FIGURE 1.
PARTS
LIST
‘August 2015 WUSNOUS 41USB micto intial values, but some must be tailored to
connector OUT specific environment. At a minimum,
pin 1 the following two items must be set:
pin wifi_network = your witi_
0 networke_sS1D
aspberry —wifi_password = your_vifi_
Pi
seworks_password
red wire Powe 1K ohm
sy SWISh v4 watt
UsBeable [4 [
> withend cuto ) 2500-4 E
tend eof é
IP andwires — -25V ]-1F]
USB Power stripped
Module black wire
5V@ 1.5.Aor Gnd Pe ee
better
Figure 2. Music player schematic.
Software Preparation
and Configuration
For this part of the process, you will need a computer
system that is capable of writing to a microSD card (2 GB
minimum size), and that is connected to the Internet and
able to download files.
The first item of business is to download the Pi
MusicBox software from wwww.woutervanwijk.nl/
pimusicbox/musicbox0.6.zip. This is a rather large file, so
it will ake some time to download. Once downloaded,
unzip the file to get the file “musicbox0.6.img” contained
within, This is the operating system's image file that must
be transferred to the microSD card. How this is done
depends on the computer system you are using, For
instructions on how to do this on your computer, go to
http://elinux.org/RPi_Easy_SD_Card_setup.
‘The Pi MusicBox software Uses a file named
settings.ini forall of its configuration settings. The file is
structured as a Windows ini file where all lines starting
with a # are comments. Comments within the
configuration file describe each configurable item, so read
the comments carefully. Some configuration lines are
commented out by default, so if you want to use them,
remove the # at the beginning of the line.
‘Once the Pi MusicBox software is operational, you
can manipulate the configuration settings online through
the web interface. It is also possible to enable SSH in the
Pi MusicBox software so the configuration file can be
accessed and manipulated remotely by logging into the
RP (default username: root; password: musicbox) and
Using an editor like Nano of Vi to edit the configuration
file. At runtime, the configuration file can be found at
/boot/contig/settings ii.
You can also edit the Pi MusicBox settings file directly
‘on the SD memory card before the card is inserted into
the RPi. To do this, put the SD card into your computer
and open the contents of the file /config/settings.ini with
‘your favorite text editor.
Most of the configuration items are set to reasonable
42 NITSIVONS August 2015
Set the wifi_network value to the
SSID of your Wii network and set the
witi_password entry to the password of
your Wifi network,
Since I ike to be able to remotely log
in to the RPi in the music player, | always
enable SSH (Secure Shell) as follows:
enable_se!
= eve
Pi MusicBox must scan local and networked music
files before they will be selectable in the web user
interface. Scanning can take a long time if there are a lot
‘of music files to process. If your music library is very
‘dynamic, uncomment the scan_always entry which will
‘cause a rescan every time your music device is powered
up. If your music library is relatively static, set scan_once
to true:
scan_once = false
true
tecan_alvaye
Then, when the Pi MusicBox software runs, it will scan
your music library once and then reset scan_once to false
automatically. If you add new music to your library, set
scan_once to true again and reboot,
Hardware Configuration
In my music player, | used a 64 GB USB Flash drive
for holding my complete music library. As mentioned, |
copied my entire iTunes music directory to this device so |
would have local access to all of my digitized music.
Before doing this, however, | had to reformat the Flash
drive into plain FAT32 format. This was necessary because
the Flash drive | used came formatted as exFAT which the
Pi MusicBox software does not support natively
Once | had formatted the Flash drive, it was an easy —
but long — process to copy the music files (33 GB total)
Once you are finished with copying, make sure to
properly eject the USB Flash drive so as not to corrupt it
accidentally when you unplug it from your computer.
Music Player Packaging
How one packages a device such as this music playeris a matter of personal
choice, taste, and budget.
‘When I started thinking
about how | would do it,
looked around my shop and
found some leftover baltic
birch (BB) plywood and
some 1/8” black translucent
sheet plastic/acrylic that |
had from past projects.
So, that is what |
decided to use. | will
describe what I did in the
hope it will be helpful at
least for a starting point in
whatever you do it you
decide to build a music
player for yourself. Note if
you use a different USB
sound module than | did
‘you may have to alter the
dimensions given in the
discussion that follows,
First thing I did was to
figure out the size of the
enclosure | needed to build
to house all of the
components: RPi, Flash
drive, USB sound module,
etc. So, | plugged all of the
components together and
with a ruler determined the
minimum volume necessary.
I decided the intemal
dimensions had to be at
least 2-1/2” deep by 6”
wide and 1-1/8" tall. Past
experience told me it was
not a good idea to try and
minimize the enclosure size,
so I decided on slightly larger internal dimensions of 3”
deep by 7” wide and 1-1/4” tall. This size would allow
me to easily fit all of the required components.
Next, I decided that the enclosure I was to make
from BB would need to have at least a 1/2” thick border
to make it structurally rigid, So, the outside dimension of
the enclosure would be 8” by 4”. To achieve the desired
height, | would need to glue 3/4” and 1/2” pieces of the
BB plywood together. With that decided, I made a
template out of 1/4” MDF that was 8” by 4”. | rounded,
the comers of the template for a more sleek look
(IMHO). | marked the template with an arrow to indicate
the top front side.
On my router table, I set up a flush cutting bit with a
bearing on the bottom that would ride on the template
re
Drive
Peer ees
oe
Photo |. Case/enclosure during construction.
et
2. Internal view of the music player.
The following websites have information pertinent to this
discussion
+ The website of the developer of the Pi MusicBox
software is www.woutervanwijk.nl/pimusichox/.
+ A forum for users of the Pi MusicBox software is
available at https://discuss.mopidy.com/c/pimusicbox.
+ A list of FAQs about the Pi MusicBox is available at
www.woutervanwijk.nl/pimusicbox/faq.htenl.
+ The Pi MusicBox manual is available at
www.woutervanwijk.nl/pimusicbox/MusicBox_
Manual.pdf.
August 2015 WTSEYOUS. 43Music player wiring closeuy
and supports all of the wiring,
Rear view.
Seng
Audio Cable
Rete
Peer nes)
Carey
re)
Pees
o
Components labeled,
44 NITSIVOES August 2015
50 uF capacitor is glued to the plastic bottom
and allow me to cut the BB
and the plastic sheeting to
the exact dimensions |
needed. Using the template
guaranteed each piece
would be exactly the same.
Trough-cut the two BB
pieces and the two black
plastic sheets into rectangles
that were 1/8" larger in
each dimension than the
template. | marked each
piece with an arrow which
would indicate the front of
the piece, and I made sure
the arrows on the template
and the arrows on each
piece were aligned before
machining.
Lused double-sided
template tape to secure
each piece to be routed to
the template. With this
done, routing each piece
took only a couple of
minutes
I set aside the plastic
pieces and glued the two BB
pieces together, making sure the
arrows were pointing in the same
direction, After gluing, | measured
in 1/2” from each side of the piece
to delineate where the internal
cavity would be. | then used a 3/4”
spade dril bit to drill out each
corner. Finally, used a jig saw to
cut along the lines to hollow out
the intemal cavity.
Next, | drilled holes for the
power switch and the LED power
indicator, and milled slots in the back for
the audio cable and the USB power cable.
Additional milling was also required for
mounting the power switch (as can be
seen in the photos). After a bunch of
sanding, the result is shown in Photo 1.1
finished up by staining the BB with a dark
walnut stain
I then turned my attention to the top
and bottom smoked plastic pieces. Fist, |
used some 120 grit sandpaper to soften
the edges of the plastic because they
were very sharp as a result of the milln
Machining the top was easy as | only
needed to locate holes for the six flathead brass wood screws which would hold it
on. | countersunk the screws so the heads
‘would be flush with the surface of the plastic.
The bottom is just a little more complex.
because in addition to the mounting screws
(which were done identically to the top), | had
to drill holes to mount the RPi. Four 4-40 by 1”
machine screws, 1/8” spacers, and nuts were
used to mount the RPi.
With all of the machining and staining
completed, | mounted the RPi onto the bottom
plastic piece, glued a color changing RGB LED
Power indicator into place, mounted the power
switch, inserted the 2 GB microSD card | had
prepared previously, and then screwed the
bottom assembly onto the enclosure. | attached
four cork adhesive pads to the bottom as feet
to protect whatever surface the music player
was set upon.
Wiring was performed according to the
simple schematic shown in Figure 2. | super
slued the electrolytic capacitor to the bottom
plastic (noting polarity) and wired up the power
connections, including the modified USB cable
used for power.
With the wiring completed, | plugged an
audio cable into the USB sound module,
connected up my USB power module, and then
put the top into place and screwed it down,
Assembly was now complete and the player
‘was looking good.
Flipping on the power switch caused the
rainbow power indicator to light, and I could
see the RPis power and activity indicators
flashing through the translucent plastic,
indicating the RPi was booting.
Using the
Music Player
Booting the music player takes a couple of minutes.
During that time, there will be numerous clicks and pops
sent out the audio connection, so itis best to allow the
player to boot completely before turning on or turning up
‘your connected stereo system. | always wait until | can
access the player with a web browser before turning on
my stereo,
‘Once the player is up, you can access it by typing
“musicbox.local” or by typing the IP address your home
router assigned into your browser's address bar. Once
connected, you should see a screen like Figure 3. By
licking the Browse tab (Figure 4), you can navigate to
either your local music collection, your networked music,
collection, select one of the many streaming sources, or
select from a vast array of Internet radio stations via
igure 3. Pi MusicBox Main Screen.
Figure 4. Pi MusicBox Browse Screen.
Tuneln, for example.
From the web user interface, you can control volume
and selection of what music you want to hear. You can
also control if the music should be played in a loop, and
whether songs should be played sequentially or in random
order,
Music in the
Back Country
My wife and I have a little retreat we often visit that
has no cell phone service or Internet. It does, however,
have electricity. We have a small stereo system that we
hook an iPod to that provides music for us while we are
visiting
‘This has worked fine, but it is somewhat inconvenient
in that we cannot control the music selection or volume
from a different room. We have since replaced the iPod.
with this music player and it works great.
August 2015 WISNOUS 45Sale Price
Set
aan
Get 20% off these three books &=_ Shi
ral oc eee
Visit for these and other great deals!
To do this, however, | had to modify th
running on the RPi to support an Ad-Hoc netw
assly. Configuring an Ad-Hoc network is
the scope of this discussion, but for those
[cdev.dk/2012/11/18/raspberry-pitutorial-connect-
to-wifi-or-create-an-encrypted-dhcp-enabled-ad-hoc-
network-as-allback/,
With an Ad-Hoc network set up, | can use my iPod
Touch's browser to control the musi¢ p re: Since
there is no Internet available, | cannot listen to Internet
radio stations, However, with over 500 CDs available on
the 64 GB Flash drive built into the device, | never lack for
music. Why not build one of these music players for
yourself?
JOIN TEAM SYNERGY MOON!
Synergy Space Explorers are
Pen he a cee td
Reactors td
Pe CER ra)
SA COE UCL
PSC ey
rane atta)
Ror ComTCn Cd
PER Ur a eCard
going into space this year,
BRE ence Co
co
Pete?
NERGY
MOON
7S Sy
kale iim
Smeets ants
SRO Sona
%, Participate in space research,
SOS UO EEG au
PICS Cmca}
Crane
Creat
Perches tay
Pent
Peer
Renters eco
PO eC Rcd
Coe ma ETE tcc ts
Re G eam are ee
DIY SATELLITES AND SPACECRAFT SYSTEMS
POR ara sul ay
46 NITSIVOES Aucust 2015eed f/ ORiDiUM
OR) . .
Preset Floating polneene for
eT controllers from $5.00
Cle www.coridium.us
‘Add USB to your nex projec
USB feceiunachn CLP
USB-IFO + USB-UART » USBiMicrocontoler Boorse
RFID Readors » Design Manutactunng Services Avalale
Absolutly NO diver softdare davabonbont aula!
‘www.dipdesign.com
Assay ENGINEERING
Kits, Parts and Supplies
www.HobbyEngineering.com
ohaey\ |
EV i eet ARO IY
ge “3 Qronwood , GigarsnaP BGA
Favorite Mobile Device! Ly ‘rcrronics Sockets & Adapters
f 5 s
3 OR Pai Sanne
arena Py
oP DD Tesi
Wwww.servomagazine.com
Did You Know Preferred
Subscribers get access to all the
digital back issues of
Nuts & Volts for free?
Call for details ima. ad near
1-877-525-2539 | ie rm?
August 2015 MUSEYDUS 47
nec a naaHow to
Craft a PIC
Barometer
By Thomas Henry
Post comments on this article and find any
associated files andior downloads at
www.nutsvol i em ic!
‘august2015 Henry,
48 NITSIVONS August 2015
Of all the ingredients making up a
local weather forecast, perhaps the
most important is knowing what the
current atmospheric pressure is
doing. "Highs" and "lows" and
especially rapid changes between
those extremes typically give a very
good indication of what's in store.
The barometer — a device dati!
back to the time of Galileo — is used
to measure atmospheric pressure.
Until quite recently, barometers were
mechanical in nature, built of
siphons, glass cylinders or rubber
bulbs filled with water, mercury, or
air. Nowadays, we have electronic
equivalents which are not only easier
‘to use and more accurate, but also
less expensive. Best of all, a solid-
state barometric pressure sensor can
be interfaced to a microcontroller for
automated data logging and analysis.
of trends.he BMPO85 — produced by Bosch
[Sensortec — is just such a device. This eight
pin marvel is exceedingly accurate, yet
priced to be within easy reach of the most
frugal DIYer. Communication with the chip
is by way of the popular PC bus, meaning
that we can concentrate almost exclusively on
manipulating the data it sends, rather than fussing over
how to receive the data in the first place. As icing on the
cake, the BMPOBS also contains an integral thermometer.
Not only is knowing the temperature useful to us humans,
but the value detected also automatically figures into the
barometric pressure measurement
If you're a weather junkie like me who’s aways
wanted a decent barometer which doesn’t break the bank,
then read on! In this article, you'll learn how to interface
the BMPO85 to most any PIC microcontroller. After
covering the electrical requirements, we'll unravel the
somewhat nasty software aspects (don't worry — all of the
ugly mathematics and tricky data type manipulations have
been taken care of for you). With what you learn here,
you'll be all set to design a customized barometer and
start making your own weather forecasts.
‘One final thing before we tuck into the details. Using
the BMPO85 with an Arduino is a breeze since software
libraries already exist for it, but going with a
microcontroller chip instead has a number of advantages.
The PICI6F1825 that | used costs about one-tenth of an
Arduino. Moreover, the required program code runs half
as long.
Finally, with a PIC you get total
control of the design at a much lower
level. When you throw in the fact that
welll be using a free compiler to create
the firmware, we're talking a complete
high performance barometer for about
ten smackers!
Hooking It Up
The BMPO85 is a tiny device (about
a quarter inch square) intended for
surfacemount construction. | don't know
about you, but my eyes and hands are
‘way too old to deal with such things.
Fortunately, the component is readily
available already soldered to a breakout
board from a number of suppliers. See
Figures 1 and 2 which show the front
and back.
This nifty affair features standard
0.1" pin spacing, meaning that it’s easy
to socket on a circuit board or try out on
a solderless breadboard. | got mine for
some six bucks from Amazon, but if you
shop around you'll find it for even less
on eBay. Just so you know, you might also bump into the
BMP180 (and breakout board) which is a newer version of
the thing, The hardware and software described in this
article are compatible with either.
Apart from making the chip more conducive to hand
construction, the breakout board sports two other features,
to really help things along, First, you need to know that
the BMPO85 is a 3.3V device, but frequently (as with the
circuit described herein) you'll want to use it with a 5V
microcontroller. Conveniently, the breakout board comes
loaded with a regulator and appropriate decoupling
capacitors to derive the required lower voltage.
It was mentioned above that communication with the
chip proper is by means of the relatively straightforward
FC bus, which is a two-wire affair. If you've played with
this protocol at all, then you'll already know that the two,
lines comprising it ~ called SCL and SDA — each require a
pulkup resistor. These, too, are provided on the breakout,
board.
Nowy, one thing might worry you at this point. Ifthe
microcontroller is powered by 5V and the BMPO8S by
3.3V, are we cruising for a bruising on the FC bus with
incompatible clock and data voltages? Not at all. One of,
the excellent features of this protocol is that the bus lines
are configured around opensdlrain FETS. Instead of forcing
pins high (to a possibly hazardous voltage for the
BMPO85), instead we're only safely bringing them low
through those pullup resistors just pointed out
We've come this far, so let's go ahead and see the
August 2015 MUSEYDUS 49“Ti SP 085 mposut contine pu
Brocton SDA ana Sou on
vita 3 poe .
{+
of
FIGURE 3.
L ne Picts iaes
bw:
contrast
{ok
sell
complete circuit for a test rig. Refer to Figure 3. An LCD
has been tacked on and that’s about it so, realy, no parts,
list is needed. Keep in mind that there are stll four port
lines free for additional features you might dream up.
For example, one could add on a real time clock,
humidity sensor, waming beeper for rapid pressure
changes, maybe even a stepper motor with indicator
needle to imitate how an analog barometer might appear.
In the words of the old Steve Allen song, “this could be
the start of something big!”
When we get to the firmware in just a moment, you'll
find that only half of the program space has been
consumed, with a plentiful 4,000 words left over for new
features.
‘Oh, and software FC routines ("bitbanging”) have
been exploited throughout, meaning that you can connect
the sensor to most any port lines of any PIC you want, as
long as they support both input and output modes.
Bits, Bytes, Words, Integers,
and Longs
‘The time has come to consider the program which
orchestrates the show. The code has been written in Great
50 NUTSHVOLTS Avoust 2015
‘80, you've got your PIC barometer up and running:
‘now what? Here are a few guidelines to get you started
(on your weather journey.
First off, as a rule its the change in values that
matters most, not the absolute reading at any given.
‘moment. Keep in mind that atmospheric pressure varies
naturally somewhat during the day due to assorted
vironmental ar geographic factors, So, dan't hover
‘around the barometer taking constant readings. A more
‘meaningful approach is to sense the atmospheric
prassura once avery 24 hours, say at 800 in the morning
‘F 800 at night when the effects of the day's heating are
under wraps. In this way, youl see the big picture
sie by ine peeks and valve witch ey meen
nothing.
The following interpretations are widely quoted and
reproduced on the Web, and are a good place to begin.
‘The predictions are for the weather to expect in the next
24 hours. The numbers shown represent the mean
level pressure measured in inches of mercury.
‘Over 30.20"
Rising or stoady
Slowing falling
Rapidly falling
Continued Fatr
Fair
~ Cloudy, Warmer
23.8 to 30.20"
Fising or steady
‘Slowing falling
Rapidly fang
- Same as Present
= Litle Change
Precipitation Likely
Under 2280"
Rising or steady
‘Slowing felling
Rapid faling
= Clearing, Cooler
= Precipitation
+ Storm
Cow Basic — my tool of choice when working with PIC
and AVR microcontrollers. This excellent compiler is open
source and free of charge, yet is a genuine powerhouse. It
features many, many valuable commands and data types,
and is exceedingly easy to use. If you don't already have
it, you can download a copy from
‘gcbasicsourceforge.net. As long as you've got the
computer warmed up, go ahead and fetch the software
for this article from the article link, too.
First off, let’s get a feel for how the BMPO8S pulls off
its magic. When the circuit of Figure 3 is first powered up,
the PIC queries the barometer for some calibration data.
These are 11. 16bit factory-set constants, personalized to
‘each and every unit manufactured. The calibration
constants need only be fetched once at power-up. They'll
be used in some later computations to fine-tune the
reading. We'll wind up with temperature accurate to one
decimal place and the atmospheric pressure to two
decimal places.
Aiter that, the BMPO8S is polled once every second
or so for the Current readings. We'll receive both the
uncompensated temperature and atmospheric pressure
along the FC bus.
Next, some basic arithmetic is wielded to convertthose numbers into accurate compensated values, then
‘welll conclude by printing the results to the LCD.
The datasheet for the BMPO85 is a good one and
details the computations necessary. They're very easy to
handle if you're just going to carry them out with pencil
and paper. | won't lie to you, though. Creating the PIC
code to perform those calculations consumed over 100
hours of my life and was one of the most difficult
programming challenges I've ever faced. Here's why.
Of the 11 calibration constants mentioned a
moment ago, some of them represent signed 16-bit
integers, while others are unsigned integers — also 16
bits. (The signed version is called an integer in Great
Cow Basic, while an unsigned one is a word.) What's
more, in the actual computations, some of the
intermediate subtotals are also mixed up like that. Then,
toss in the fact that when divisions occur, sometimes the
uotient should be rounded and at other times simply
truncated. It was an incredibly frustrating two weeks of
very full days sorting this all out, It pleases me to no end.
that I can spare you that! With the software library
included with this article, you can start using the
BMPO85 within minutes
Here's how | handled the mixed data types. All of
the 16-bit numbers (constants and variables alike) —
whether signed or unsigned — are promoted to 32-bit
numbers, which Great Cow Basic calls longs. No need to
worry about overflows now! Furthermore, with one
consistent data type throughout, keeping things straight is
much simpler, Figure 4 explains what's going on behind
the curtain, should you be curious.
However, a new problem arises. In the Great Cow
compiler, 32-bit arithmetic is
always assumed to be
performed on unsigned
longs. So, had to forge
ahead and write new
multiplication and division
routines to accommodate
signed long integers.
(Addition and subtraction
take care of themselves).
For ultimate accuracy, | also
created a division routine
which rounds things
properly when needed.
Incidentally, all of the
computations are easily
handled without recourse to
floating point arithmetic,
Why open a can of beans
with a stick of dynamite?
To see how it all shakes
out, be sure to look over
the "BMP085.H" include
URE 4.
Example:
To represent -1234 in two's-complement form:
Start with the positive
number 1234.
0000 0100 1101 0010
1111 1011 0010 1101 Then complement it.
+1 Finally, add 1
1111 1011 0010 1110 equals -1234
t_ sign bitis set, meaning negative
The integer type as shown here is 16-bits long.
To cast it to a 32-bit, long integer, prefix the
number with sixteen additional 1’s, since it's
negative. Were it non-negative, it would be
prefixed with sixteen additional 0's,
file which contains the library routines and is heavily
commented throughout.
And Finally, the Firmware
By including the file “BMPO85.H1" in your own
programs, you naw have access to three commands — no
muss, no fuss:
August 2015 WUSNOUS 51+ getConstants()
+ getTemp(Colsius, Fahrenheit)
+ getPressure(Pascals, Station, MSLP)
Now's the time to mention that the BMPO8S spits out
the atmospheric pressure in Pascals — a member of the so
called Iniermational System of Units. If you live in the
United States, you'll probably find the traditional inches-of
mercury (inHg) scheme more familiar. The firmware takes
UL
‘heavy-duty low-speed goar box. 1Omm
‘square shafts tapped with 5116-18 UNC 28
thread, sivated at a 65° angle. Overall
length of motor and gearbox, 142mm.
cate oeM473 $3.0)00
24VDC 2.8A ae
POWER SUPPLY
6 output cord with 2.5mm
‘coax power plug, center
positive. Detachable
2.conductor power cord
‘eULus, TUV. CE
CATE PS-2428
$1025 Goartaea)
4MM BLUE OVAL LED
Cree # CASK. BLE.
High-bighiness. Rate: 3.2, 20m.
Wavelength: 47onm, 300-1520 mod
Large quantity avalabe.
catsleDZr $100
2-CONDUCTOR WATER-
PROOF CONNECTOR
Interlocking 2-conductor bullet connector.
12" ed and black leads, AWG 10 stranded
or eat ct
a
52 MITSIVONS August 2015
ELECTRONICS
care of making this conversion. But there’s more!
‘The sensor reads the actual or absolute atmospheric
pressure of wherever itis sitting — whether you live in a
‘cave far below the surface of the earth or on top of a
benef ofan ISP header and FTO ntertace.
Power via USB or through the barrel ack
‘On-board power regulator, 7 to 15.Vce.
careanoz2 "$1995.
DUAL BANANA,
ee hd
ates
mea
Soi $15,
re, Sees GEES)
m, See Gens
WIRE MANAGEMENT KIT
ae
eae
Geersi0.00each) $1500
DE-SOLDERING WICK
oat headin
ee
SN,
Suet ape
Rar eee ase,
Tap 125 Gwen $3.50
es
0.075" (1.9mm) wide
(Zor $3.00 each.)
CAT# SWK-3
‘each
‘mountain, This is referred to as station pressure.
(On the other hand, newspapers and television
broadcasts report readings in what's called mean sea level
pressure, abbreviated MSLP. The station pressure is
converted and standardized to what it would be if you,
lived at sea level. This makes it
easier to compare values and trends
over vast regions of the earth
Clearly, MSLP depends upon
the elevation of where you're living
I visited City Hall and found the
value for my very block from one of
the kindly civil engineers there.
In the source code, you'll note
the constant BMP_PRESS_FACTOR
and how to set it based on your
elevation. If it isn’t clear, the
getPressure command in the library
file returns values for all three
systems: Pascals, station pressure,
and MSLP (the latter two in inti).
Solid-state barometers tend to
bounce around a little compared to
mechanical types which, in effect,
exploit inertial averaging, To mitigate
this, the BMPO8S has four different
levels of operation governed by
what the manufacturer calls the
“oversampling setting,” It’s really
nothing more exotic than finding the
‘mean of several consecutive
readings,
Provision is made for taking
averages of one, two, four, and eight
samples, and this is set by the
constant BMP_OSS (with a value of
0, 1, 2 oF 3, respectively). If you
look into the code, you'll find other
niceties, along with various hints,
tips, and explanations.
Figure 4 shows my test rig
cranking along, In the top row of
the display, the temperature is given
both in Celsius and Fahrenheit. The
bottom row shows the station
pressure and the MSLP.
With that, you should be all set
to begin crafting your own
barometer with the BMPO85. May
your forecasts ever come true! NWBy Tom Kibalo
A DIY
Indoor
Air Quality
Monitoring
System
Most of us spend much of our time indoors. The air that we
breathe in our homes and work areas can put us at risk for
health problems. Understanding and controlling some of the
common pollutants can help improve your indoor air quality,
and reduce yours and your family's risk of health concerns
related to air quality.
here are some excellent guides on this
available from the US Environmental
Protection Agency, but an important
step in this process is to begin to
monitor your indoor air environment.
Given the availability of inexpensive gas
sensors, gas monitoring for the DIY enthusiast is
readily attainable, As a result, we decided to
build our own gas monitoring prototype system
using ISaAC (a Raspberry Pi adapter board
introduced back in the Nuts & Volts August
2014 issue) and a Raspberry Pi, ISaAC seemed
like a natural fit based upon its ease of use with
the Raspberry Pi — especially in this type of
measurement and control application. We finally
ended up with a monitoring air quality
measurement system capable of collecting,
measuring, and recording selected indoor air gas
pollutant concentrations and the ability to report
pollutant levels in real time, while allowing long
term logging of concentrations to understand
both trends and to facilitate rework/validation
for any notional remedies. The resulting
prototype system is portable enough for easy
deployment to isolated areas of a house
including the basement, garage, bedroom, attic,
etc.
In this article, we will discuss the prototype
system design, our sensor selections, and the
approach we used on how to apply specific
manufacturer's specifications to derive gas
concentration levels, Let’s get started!
Avgust 2015. NUBRONS 63The Indoor Air Pollutant
Environment and Our
Sensor Choices
+ Carbon monoxide (CO) is a colorless, odorless
gas that interferes with the delivery of oxygen
throughout the body. CO causes headaches,
dizziness, weakness, nausea, and even death.
(Ivan Blumenthal, www.nchisnlm.nih.gov/pme/
articles/PMC1281520.)
» Sensor Chosen: MQ-7 CO 503,000 PPM
Parallax gas sensor board (see Figure 1),
+ Volatile organic compounds (VOCs) are chemicals
found in paints and lacquers, paint strippers,
cleaning supplies, varnishes and waxes, pesticides,
building materials and furnishings, office
equipment, moth repellents, air fresheners, and
dry-cleaned clothing. VOCs evaporate into the air
when these products are used, or sometimes even
when they are stored. (P. Wolkoff, et.al.
htip://onlinelibrary.wiley.com/doi/
10.1111.1600-0668.1997.101-2-
00003.x/abstract,)
» Sensor Chosen: GROVE HCHO 1-50 PPM
Grove gas sensor board (see Figure 2).
+ Combustion pollutants are gasses that come from
fuelburning appliances. The amount depends on
the appliance, and how well itis installed,
maintained, and vented. Fuel types also varys
typically, propane and methane. In my case, we
Use propane for our kitchen stove and gas
fireplace. (A. Kazragis, A. Gailius,
‘www-tandfonline.com/doi/
abs/10.1080/16486897.2006.96368934.
VHGAIDHF9qs,)
» Sensor Chosen: MQ-2 combustible gas and
smoke 300-10,000 PPM Grove gas sensor
board (see Figure 3)
Background and Theory
in Applying a Gas Sensor
Gas sensors are widely available for various gas
types, sensitivity levels, and different cost factors. All of
the MQ sensor series are inexpensive (MQ-7 CO,
HOCHO, and MQ22 LPG) with reasonable PPM (PPM
stands for one part per milion) resolution, This sensor
series uses a small inside heater in conjunction with an
electro-chemical sensor. The heater allows for good
sensitivity against a range of gasses that occur indoors
at room temperature,
‘The preferred sensor wiring is to connect both
sensor ‘A’ pins together and both sensor ‘8’ pins
54 NUTSHOLTS August 2015
FIGURE 1.
Parallax MQ-7
CO sensor and
breakout board.
FIGURE 2.
Grove HCHO
‘sensor and
breakout board.
WN:
FIGURE 3.
GROVE MQ-2
LPG sensor and
breakout board.together (sce Figure 4). The A
and B pins are driven by a
‘common voltage (VEC). A
picture of this sensor and a
general circuit of the MQ
sensor is shown in Figure 5.
‘The schematic shows a
resistor network for the
sensor (RS) in series with the
load (RL) to ground. The gas
sensor output voltage is VRL
~ the voltage across RL. From
the schematic (using the
Kirchhoff voltage law), it can
be shown that:
Vee 1) x
St) x AL
RS.
All of our MQ sensor breakout boards incorporate RL
{as a settable potentiometer and +5V as VCC. It should be
no surprise with a lower RL there is a lower VRL value,
resulting in less resolution in measurement. Likewise, the
higher the VRL value, the greater resolution we have for
similar concentrations of gas.
There is a notable exception to the heating scheme
with the MQ7 CO. It requires a twocycle VCC heater
voltage: first, applying +5V to purge the sensor for 60
seconds; and then +1.4V for 90 seconds to perform
before measurement. Fortunately, the Parallax breakout
board has an on/off transistor that allows for the heater
voltage to be changed using Pulse Width Modulation
(PWM). More on this later.
Let’s examine a typical MQ spec. The manutfacturer’s
spec sheet for all MQ sensors uses a graph indicating gas,
sensitivity of a sensor as a ratio of RS (sensor resistance)
to RO versus PPM (refer again to Figure 5).
This RS/RO ratio is a
linear relationship across
different gas concentrations
when using a log scale for
RS/RO versus gas PPM.
Generally, PPM is the lowest
Unit of measurement, where
10,000 PPM = 1% by
volume.
Note that within the
graph there is a pure air
FIGURE 4. Generic gas sensor.
Fix the VCC (+5V).
2. Fix and measure your RL (in pure air) for necessary
sensitivity (use manufacturer recommendations).
3. Measure corresponding VRL for pure air conditions.
4. Derive RS (pure air) using the equation shown
previously.
5. Look up the RS/RO ratio for pure air conditions
Using the MQ graph.
6. Calculate RO using the ratio. We now have a fixed!
RO to use for PPM determination.
7. Once we've completed steps 1 to 5, we are ina
position to calculate PPM from VRL samples.
a. Measure VRL with our computer system
b, Use VRL to derive RS (step 4).
¢ Look up the RS/RO ratio (step 5).
d. Calculate RO (step 6).
€. Look up gas PPM using RS/R0.
Although steps 6 and 7 seem straightforward, they
can be cumbersome. There are a number of discrete
‘equations to solve, and the manufacturer's graph can be
RS/RO ratio is 1in air
without any gas
concentration
RS/RO ratio is linear
(log scale) across
condition where RS/RO = different gas
This is an important
relationship in our PPM concentrations!
determinations. Let’s review Gas
the following steps to PPM
understand the process of
determining PPM from VRL: FIGURE 5. Manufacturer's spec: RS/RO versus PPM for MQ-2.
‘August 2015 MISEVOUS. 55large and unwieldy for lookup within a software
application. We can automate the process by using a
spreadsheet to plot and thus capture the curve fit for the
RS/RO relationship to VRL and then to PPM. A simple
regression can be used to derive a formula. The formula
‘can then be applied for code use within Python. As an
‘example, with MQ2, the equation is v= 0.1575e724
where LPG gas PPM is y and the MQ-2 VRL is x. The
spreadsheet example is shown in Figure 6.
‘Most of this spreadsheet “leg work’ has been cone for
‘you on the selected gas sensors, and the necessary
‘equations are derived. A copy of this spreadsheet with the
a5 equations is available for download at the article link,
As you build your own air quality prototype using the
‘equations (Figure 6), keep in mind several fixed required
conditions before starting:
est pte bo
FIGURE 6. Excel MQ-2 derived PPM to VRL equation.
Cee cree
are
pe) cor}
Sensor Adapter Board
DC power
uUsB+5V
Display/Keyboard/mouse
{56 NUTBLVOTS. Aust 2015
+5V Supply/level conversion/ LEDs
1. Configure RL on breakout boards; these can be set
using a multimeter when VCC power is not applied
to the boards. In our case, we followed
manufacturer's specitications and configured both
MQ-2 and MQ? for an RL of 10K, and HCHO for
an RL of 20k.
2. Keep the supply voltage (VCC) to +5V DC.
Prototype Overview
Lot's start with a good old fashioned block diagram
(sce Figure 7). The computer hardware, as mentioned
earlier, is based on an ISaAC adapter/Raspberry Pi board.
‘The application is written in Python which executes on the
Raspberry Pi. To this, we added a gas sensor interface
board. This is where the MQ:7, MQ.2, and HCHO sensor
breakout boards interface
directly to computer
hardware. The sensor
board also provides an
LED feedback.
The various gas sensor
breakout boards are
supplied with +5V DC
power and ground from
ur sensor interface. Also,
it is here where the sensor
voltage outputs are
buffered and levels are
converted for ingestion
into the computer
harchware,
AAs noted earlier, each sensor
contains individual heating
‘elements that at +5V require
‘current, These typically run hot,
land can consume about 160 mA
‘each. Itis not practical to use
power from the ISaAC and Pi; +5
volts is needed to supply heater
Power, so a separate +5V DC
supply is integrated in the sensor
interface to handle all gas sensor
power.
Finally, for email connectively,
the system uses a WiFi dongle or
direct Ethemet connection.
HOCO on
rae
Sensor Board
Particulars
The MQ-2 and VOC sensor
use a fixed +5V. The MQ-7 CO
sensor is unique from the other
sensors in that it requires the use2m canrat of 0 Santor voltae ue
z £5 Sonor Voltage wmf oo a
eat > 2}
0-7 €0 Gas Sensor # clas
g vine | TPES ee Tea, * eet Purge cycle
ee piel eee |
i : S
ta-@ LPC Gas Sensor § GER | PT ae
; Game ik is
* Gomme we = 3.36
E poe
3 a0
od rey ig €
veco cas sensor F germ — ALT fem cs
& thes *
=== aad
g
[ FIGURE 8. Gas sensor board
i i Secaantaaas
‘of PWM to switch from +5V (sensor purge 90 second (A2) for MQ-7, MQ-2, and HCHO.
cycle) to +1.4V (sensor measurement 60 second cycle). + API_com (command string)
The Parallax sensor breakout board provides an HSW. + For digital /O where various command strings
input to switch the MQ VCC on/off. We use the HSW_ are OXX (set out digital), HXX (set digital high),
with PWM control to achieve the +1.4V and +5V VCC and LXX (set digital low) for XX = 01, 02 for D1,
needed for this sensor. and D2, respectively.
The sensor board also uses three Microchip MCP608 + For precision PWM using command string ‘2’ +
railto-rail op-amps to do a voltage level conversion from 09" (pin D9) + 5 digit PWM frequency (HZ) + 6
ec eal a he nee soe Pl ky te tes
peak requirements
‘The op-amps connect directly to the VRL sources from
the breakout boards, and then each outputs to a resistor = Resources
network of a 10K pot in series with a 3.3K resistor to Various:
ground. The pot settings are about 1.7K to achieve a full Sa en
scale conversion of +5V to +3.3V at the tap point of each ‘www.parallax.com ik Ree
resistor network. These networks prevent overdriving of Gas Sensor Board (#27983) (1) Red LED
the input 33V analog pins of ISAAC, thereby protecting 0 {Cagvon Monexttel M7 (1) Green LED
them (see the sensor interface schematic in Figure 8). aeeect (1) Raspberry Pi with Display,
ISaAC does the “heavy lifting” of interfacing to the gas won.sesedstudia.com Keyboard, Mouse
sensor boards, as well as driving the LEDs ~ all under Grove Gas Sensor MQ-2 LPG
Python control by the Raspberry Pi, The !SaAC Python Grove HCHO Sensor Si TeUat EST
library is used fr this control in commanding the hardware:
¥ ‘i ikibacorp.com
. i . vod Microchip Direct (3) MCP-608 Ree
ee asa g aeAmoenMONEP™™ ste Sinton
‘August 2015 MISEVOUS. 57FIGURE 9. Kir quality monitoring GUI.
Gas sensor collection and measurement occurs once
every 150 seconds for the duration of the collection
session. This is dedicated by the number of total samples
requested. Each 150 second collection cycle is marked by
red LED active for the purge cycle, followed by a green
LED for the measurement cycle.
Prototype Operation
The air quality system application is implemented
using Raspberry Pi Python 2.7 code with ISAAC, Tinker,
and SMTP, MYSQL, and file I/O Python libraries. Once
the application is launched under IDLE, a Monitoring and
Control GUI appears similar to what is shown in Figure 9.
The application was kept simple and built to help DIYers,
Understand and evaluate these new gas sensors for indoor
‘environments.
Measurements made during the application process
are automatically time tagged, converted to voltage, and if
‘optionally logged, PPM. The data can be maintained using
‘an MYSQL database to support analysis and trending.
Let's clarify what is meant by a sample in our system.
A sample isa collection of al selected gas measurements,
(both voltage and calculated PPM). It is comma delimited
and terminated with a carriage return and line feed. Each
sample starts with a full date/time string tag that captures
the start time of the first gas value in the sample.
The sample is ASCII formatted as follows (voltage and
PPM are in decimal): YYYY:MM:0D:MMSS, CO voltage,
CO PPM, LPG voltage, LPG PPM, VOC voltage, VOC
PPM, CR, LF. If a gas is not selected, then a blank will exist
between the appropriate commas.
A good way to understand the application's
functionality is to walk through the application’s applied
Use of the Python Tinker GUI widget set and its associated
features. Notice, first ofall, that the GUI display is broken.
into four main sections: Gas Selection, Log Control,
Acquisition Control, and Advanced Control.
88 NITSIVONS August 2015
Lot's start with Gas
Selection. Here, check
boxes help you select
which of the three sensors
are candidates for
measurement
The next section (Log
Control) provides a file
name where the session
measurements will be
stored {if the Enable Lo;
checkbox is selected). If it is
not selected, the session
will simply dump all the
measurements into the
Python shell for direct
viewing.
Acquisition Control sets the number of samples for
the collection session. The user sets this by typing a
sample number in the Entry box. Upon hitting the “Run”
button, an estimated completion time is automatically
displayed and logging commences if enabled. The
application will automatically set a file log name in the File
Name eniry box. The file name uses the measurement start
time as an example: Gas_Log_YYYY_MM_DD_MM_SS.txt
With each sample collected by the system, the
sample's number box will decrement, and the collection
session will end at the zero sample.
Once the session ends, a user can view the file log by
hitting the “View Log” button. The file log content appears
asa scrollable text box widget. Under Advanced Control,
the log results can be stored in an MYSQL database
(gas_database.db) for long term archival by hitting the
“Update DB” button.
The user can also elect to send a copy of the log file
using the “Send Email” button to the recipient’s email
address listed in the email entry box address. The “from
address” in this email will be fixed to your DIY air monitor
system.
When in doubt about what is going on, examine the
‘outputs that are printed to the Python Shell; it captures all
the action going on “under the hood.” That is about it for
operation — simple enought
Software Installation
‘A Python bundle for the entire system is available for
download at the article link. Just unzip within your main
Python folder and you should see:
+ ISSACCOMVER2,PY (ISaAC Library)”
+ GASGUIVERT.PY (main application operation and.
Gul)
+ SYSMAILPY (email funetion)**
+ SQUTE_CREATE_DB.PY (SQLITE database install)Just run this once. It will create a relational database
for log entries. The database table is named “GAS.”
In GAS, the entries are sampletime, COVOLTS,
COPPM, LPGVOLTS, LEGPPM, VOCVOLTS, and
vOCPPM
SQLITE_LOG_INSERTPY. This code takes the
Current fog file and loads its contents into the
database.
SQLITE_EXAMPLE_QUERY.PY. This is a query
example to be run against the database once you
have updated it with some log file data. It queries all
COVOLTS>O. This is run independent of all other
files, and serves as an example of what the
database query can do for you (but does not
represent the complete functionality). Please refer
to Python SQUITE for a more complete set
The entire application launches under IDLE as the
Python module GASGUIVERI1.PY..
“The ISaAC board needs to be integrated with the
Raspberry PI GPIO serial port. The process is
straightforward and appears in the August 2014 article
mentioned earlier. I's detailed in the freely downloadable
ISaAC Tech Manual.
** SYSMAILPY needs to be updated with your
personal email address and password, Placement variable
definitions are provided in code.
Current Prototype
Figure 10 shows our current bench implementation.
‘As you can see, our version
of the sensor board and its
connections to ISaAC
(siting on top of the
Raspberry Pi) uses a
solderless breadboard.
Again, simple enough. Since
ISAC implements an
‘Arduino compatible form
factor, one may choose a
more compact
implementation that could
be realized by integrating all
the sensor board electronics Leeaay
‘onto an Arduino shield. :
The present
configuration has been
successively moved around
my house and gas
measurements have been
collected, A substantial
database of these
recordings is now in place.
‘One area remaining to
be addressed is calibration. That will be an additional
project. The literature indicates a number of ways in which
this can be accomplished, so given that the entire design
is open and readily modified, Il leave that up to you. For
my purposes, this current configuration captures what |
need for now in terms of gas indications.
What's Next?
In this article, we introduced you to tools and
techniques to understand and apply gas sensors within an
indoor environment. The hardware and software for this
‘open implementation can serve as a model for your own
DIY system. It is expandable, so you can first start with a
single sensor and then add on the others. Our discussion
‘on gas sensors should also help you apply other sensor
types in your design.
Until next time, happy air monitoring! MW
FIGURE 10. Prototype air quality system.
August 2015 MUSHYDUS 58THE DESIGN CYCLE
BY FRED EADY
Giving Our “Board” Wings to
Fly Over LANs or the Internet
Soldering is a perishable skill. So, every time | get a chance, I pick up a soldering iron and
make some solder joints. I also love to lay out printed circuit boards (PCBs). That's because
after | lay one out, | have to solder stuff to it. More times than not, there's a microcontroller
on that PCB. That leads to having to hone my programming skills. So, | guess that means
that | really love to design and build electronic gadgets. I'm especially fond of Ethernet-
equipped gadgets because that most always forces a connection to another Ethernet-laden
gadget over an LAN or the Internet. So, guess what we're about to do ..
q " for generalpurpose use. The fourth UART will act asa
The "Board pipeline to a microSD card under the control of an Atmel
We will implement a flexible design for a mult ATMega328P.
purpose 32-bit microcontroller-based platform, This model In a previous Design Cycle (June 2015), we designed
will be based on a six UART-equipped a microSD implementation that was capable of being
PIC32MX795F512L. One of the sextet of UARTS shall driven by a PIC32MX795F512L. We'll “reuse” and include
drive an FTDI FT232RL USB-to-serial IC. Another one of the details of that design in this month’s project. The
the PIC32MX795F512U's UARTS will be used to service a | inclusion of the PIC32MX795F512L-driven mictoSD card
“true” RS-232 port, which will be overseen by an allows us to utilize the microSD card portal for
STMicroelectronics $T3232C RS-232 interface IC. bootloading, web serving, and general:purpose data
A third PIC32MX795F512L UART will be pinned out | handling. The native microSD card interface will be
supplemented by a 1 Mbit
25LC1024 EEPROM.
In that other
Microchip SPI Flash
memory ICs are pin-
compatible, the FEPROM
space can be occupied by
a denser Flash memory
device if necessary. Justin
case we need to interface
an SPhbased IC or
peripheral to our
PIC32MX7956512L, we'll
also pinout a standard SPI
portal
‘What would any
microconiroller-based
design worth its salt be
worth without LEDs? To
= offload our
Photo 1. This little board allows you to send it, receive it, process it, and store it. You can ieee
do this via wired Ethernet or external wireless modules. What you don't see in the shot is PIC32MX795F512’s I/O
the Ethernet magnoties package which Is mounted on the opposite side of the PCB. subsystem, we'll drive all
60 NITSIVONS August 2015
ete arsADVANCED TECHNIQUES FOR DESIGN ENGINEERS
Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/
index.php?/magazine/article/august2015_DesignCycle.
mSchematic 1.
There are 100
pins on the
PIC32MX795F512L
package, and we
can access almost
every one of them
Tn one way or
‘another.
of our user-controllable LEDs through a NUD3105,
MOSFET relay driver. The NUD3105 includes all of the
necessary bias resistors and steering diodes on the chip.
So, we don’t have to mount the gate and drain resistors
normally associated with standard MOSFET switch circuits.
The power supply design will be simple and rugged. A
Micrel MIC29150 will provide a regulated +3.3 VDC
power supply rail. The MIC29150 is capable of supplying
Up to 1.3A of current from input voltages as high as 26
VDC. This will allow us to power the circuitry from
‘common wall wart power bricks
‘The PIC32 was not only chosen for its large number
‘of UARTS. This particular microcontroller also contains an,
‘onchip Ethernet MAC and is capable of driving an
external PHY device. In this case, our choice of external
PHY devices is provided by Microchip in the form of the
SMC LAN8720A. The addition of the LANB720A gives
our device the capability of web serving, acting as.a
TCP/IP client or server, and providing email (SMTP), time
(SNTP), UDP, and FIP services.
Timing is always important when it comes to
microcontroller circuitry. Time is also important to
humans. To appease both human and silicon, the
PIC32MX795F512U's intemal RTCC (Real Time Clock and,
Calendar) will be attached to an external 32.768 kHz
‘crystal. This will provide a real time clock that can be used
for various timing requirements. For instance, the one
second tick from the RTC can be used to blink an “I'm
alive” LED. The finished product is shown in Photo 1. To
make the assembly you see in Photo 1 possible, we had
to combine and interconnect a number of electronic
subsystems.
The Heart of the System
Schematic 1 is a graphical depiction of the
PIC32MX79565 12L and its supporting resistors,
capacitors, crystals, switches, LEDs, and LED drivers. The 8
MHz CPU clock crystal is the seed for the PIC32's PLL,
\which ramps up the CPU clock frequency to 80 MHz. The
PIC32MX795F512L's internal peripherals are also clocked
at 80 MHz, Coupled with the PIC32's immediate YO
‘commands (LATXSET, LATXCLR, LATXINV), the 80 MHz
clock makes for some very fast /O switching.
You can also see how clean the LED NUD3105
MOSFET driver circuits are. All we have to do is connect
an NUD3105 to its respective PIC32MX795F512L YO line
and write the code to drive it.
‘The NUD3105 also allows us to directly drive small
relays in the same way we are driving the LEDs.
August 2015 MUSOU 61Microchij
Microchip TCP/IP Stack HERS oaet
Sah ere ‘www.microchip.com
“4 via its transmit and receive lines.
This module will most likely be
we used to communicate with a host
ue = 3 USB device such as a laptop PC.
use " The only physical
ee eke eos housekeeping we have to do here
a oo JK vweoy ‘is make sure we don't overcurrent
user Ne Ha iS the indicator LEDs. The real work
Sus is in the firmware driver. You can
us, 4 see view the FT232RL hardware
as! ret Egg gx, detals in Schematic 2
cass en :
q Exmemed RS-232 is Not Dead
The news of the death of RS-
Schematic 2. There's not much to do here as far as the
‘Tasks include filtering the supply voltage and taking care
In my opinion, many boards like our board have too
many pushbuttons. The sole intent of designing in the
single pushbutton switch was bootloading control. My fir
Use of the pushbutton switch during development of the
code for this column was in a debugging sequence. So,
it’s there if we need it for whatever we may need it for
‘The PIC32MX795F512L is programmed and
debugged using a PICkit 3, which is attached to our
board's male fiveppin ICSP connector using a six inch
cable assembly terminated by a five-pin DF13 1.25 mm
female header.
USB in a Cl
The FT232RL is attached to the PIC32MX795F512U,
232 has been greally exaggerated.
RS-232 interface ICs are not hard
to find, and many modern devices
are equipped with a legacy RS
232 portal. So, why not include a true RS-232 portal on
our board?
Like the USB subsystem, the RS-232 subsystem is not
a burden on the harchware side of the fence. According to
Schematic 3, we only need to add five 100 nF capacitors
to the mix,
microSD on a String
A slightly modified version of SparkFun’s Opentog is
drawn up in Schematic 4. The original intent of the
Openog was to simply store the incoming stream of RS-
232 data on the microSD card. However, there are
‘commands associated with the OpenLog that allow us to
control the microSD card file system.
So, we can choose to use this
hardware is concerned.
of the indicator LEDs.
“ microSD card to log data or store data
a tm on bt under program control. The really neat
TN Hour thing about it all is that the control and
gee 2] coon pi 2 BR data transfers are done via one of the
Ron RIN PIC32MX795512U's UARTS
om mae 0 . 7 .
microSD the Microchip Way
tom Ta], pon
ca [4 Res The “other” microSD card is being fed
‘tne : —4 from one of the PIC32MX795F512l's SPI
% 7 portals. Like the OpenLog microSD card,
= CS" T the “other” microSD card can be used to
MOF Be Yon veo PE log data or store data under program
LT control using Microchip's microSD card
sre Be file system.
Schematic 3. Setting up an RS-232 hardware port used
remember back in the day having to lash up separate receiver and
‘transmitter ICs that required negative supply voltages. Today's RS-232
interface ICs are a breeze to use.
62 NITSIVONS August 2015
However, the microSD card under the
control of the PIC32 also has the ability to
hold firmware images that can be
bootloaded into the PIC32MX795F512L
Jumper blocks are used to set the card
to be a real pain,ExpressPCB
The "board printed circuit board
www.expresspob.com
level. n that
the PIC32MX795F5 121-
controlled microSD card is
seen as an SPI portal to
the PIC32, there isn’t
much hardware work to
be done in this area. The
minimal “other” microSD
card hardware setup can
be seen in the contents of
Schematic 5.
What you don't see in
the schematic is the SPST
switch between pins 9 and
10 of MSD95. The switch
is an integral part of the
microSD socket. When a
card is present, the switch
is closed. mM Schematic 4. This is an implementation of the OpenLog, which can be purchased os a
The switch feeds the module from SparkFun. Any serial input is directed to the microSD card by the firmware
gate of the MOSFET. ‘contained within the ATmega328P microcontroller.
Depending on the
Jumperx settings, the MOSFET is either turned ON or
wg
OFF by the state of the card detect switch. Normally, Pe
the gate of the MOSFET is tied high and the SPST oe
switch within the microSD card socket is jumpered to wsorss
0 logically low when closed. 4
The 25LC1024 EEPROM signals are shared with the ee
PIC32MX795F512U's microSD card, The EEPROM is Sa Z
selected using the PIC32's EE-CS W/O pin. voweero | fae SSE
somo]
1 eo
All Powerful Ethernet ed
tr
Despite all of the SPI portals, UARTS, clocks, and
timers that the PIC32MX795F512L possesses, its most
powerful asset is its Ethernet interface. As you can see
in Schematic 6, the Ethernet circuitry isn't particularly Ml Schematic 5. + ws
complex. However, by including this circuitry, we Phd 7 -
instantly have the abilty to contact other network aarthn carl aa
capable nodes on an LAN or over the Intemet. Our detect logic level 10K
board can suddenly become a TCP/IP server or client. Norell tied JUMPERI som.co
We can use the Ethernet portal to serve web pages. jtur2ti wad | ree toe x
Fonaaean
‘We can send email messages. We can synchronize with Jumper! is tied
Intemet time servers. f necessary, we can even igaically high
7 results in an
bootload the PIC32MX795F512L over an Ethernet is ening
connection. The inclusion of the LANB720A interface is Getect signal
well worth the loss of a few of the PIC32’s YO pins.
its currentimiting resistor, the parts count rises to five
Clean Power ‘components.
Wired Ethernet portals are typically power hungry.
No data will low and no LEDs will blink if the power | ‘This design will draw around 250 mA while running the
supply fs inadequate, So, we must design in a robust and | Microchip TCP/IP stack with all LEDs illuminated, The
noise free power supply circuit. Fortunately, that spectrally Micrel MIC29150 won't even break a sweat with that
clean power system consists of only three components. load. All five components plus the power jack make up
If you include the optional power indicator LED and Schematic 7.
August 2015 WSNOUS 63m Schematic 6.Thi
a classic implementation of the SMC
LAN8720A. All of the signals needed to drive the external
PHY are provided by the PIC32MX795F512L.
leet eae = =
pie[ ete fe ep
ts
anything right now either.
Since we will be running the TCP/IP
stack against the Ethernet interface, we
‘want to make sure the
PIC32MX795F512U's Ethernet signals are
rrr, | | routed to the LANB720A PHY correctly
Te : That is done by making sure the FMIEN
a <=) use is sot to OFF and the FETHIO fuse is
Sle 7 f SHESAIS 4 set to ON. This activates the normal set of
we ES ames woul ei the PIC32MX795F512U’s Ethernet
ES te | i interface pins instead of its alternate set of
som al aes eo [1 | | Ethernet pins. IF you examine Schematics
vet micz01s0-2.30u
lM Schematic 7. As Leonardo da Vinci would sa
. aug mask
4 1" our
@e 8 e
& &
“Simplicity is the
ultimate sophistication’ This is one simple rock-solid power
regulator circuit
Shake Down
Let’s power up and see if this thing works. We will test,
‘our new creation by loading and running the free
Microchip TCP/IP stack. The first thing we need to do is
make sure the PIC32MX795F512U's configuration fuses
are set correctly:
FPLLMUL = MUL. 20
FPLLEDIV = DIV.2
FWDIEN = OFF
FPBDIV = DIV
poscuop = xt
gpragma
dpragna
#bragna
dpragna
#pragna
Spragra
#pragna
#bragna
#pragra
#pragna
contig
Sontig
config
Sontag
Sonfig
Sontag
y
config
As far as the fuses are concerned, we want to make
sure we are running at 80 MHz. With an input frequency
‘of 8 MHz, multiplied by 20 and divided by 2, we end up,
with 80 MHz
We don’t want the watchdog nipping at our heels,
and the PIC32MX795F512U's configuration fuses reflect
that the watchclog timer is indeed disabled. Along with the
disabled watchdog timer, we don’t want to code protect
64 NITSIVONS August 2015
1 and 6, you will see that the alternate
Ethernet signals are not tied to the
LANB720A.
The TCP/IP stack code we will run
will have the web server (HTTP) module
enabled, The TCP/IP stack HTTP server
‘module includes provisions to control LEDs on the
server hardware. We just happen to have a few
LEDs on our board that we can put into service
‘The TCP/IP stack code calls out eight LEDs. We can
map to five of them:
Haetine
fdefine
Hdet ine
LEDO_TRIS (TRISEDits .TRISF3) //aCT2
LEDOLIO. (LATFbits .ZATF3)
TRIS (TRISADits.TRISA3) //ACTI
fdefine LEDI“10 (LATAbits.2ATA3)
Hdefine LEDQTAIS (TRISRbits.TRISAA)
T/oserh
fdefine LED2-10 (LATADita. LATA)
Hdefine LEDS_TRIS (TRISBbits.TRISB15)
‘T10mer2
#define LED3'TO (LATBbits.LATB1S)
fdefine LEDI_TRIS (TRISBbits.7RISB14)
{/0ser3
fdefine Lep4 10” (LATBbics.LATSI4)
Hdefine LEDS_TRIS _ (TRISDItS.7RISD13)
7/No such LED
fdefine Leps_10. ” (LATDDits.tATD13)
Hdefine LEDS_TRIS — (TRISDDItS.7RISD13)
11No such LED
fdefine Leps 10 (LATObics.LaTD13)
Hdefine LEDTITRIS — (TRISDDitS.7RISD13)
7/No such LED
fdefine LEp7_10 ” (LATOpits.LATD13)
LEDs 5, 6, and 7 are mapped to the PIC32's D13 /O
pin, which is not used by our hardware, LEDO does
double duty as the “I'm alive” blinker:
// Blink LEDO every second.
Gbqtickget() - t >= TICK_SECOND/2u1)
The TICK_SECOND interval is determined by our
peripheral clock speed, which we define via the
configuration fuses. The TCP/IP stack gets at the speed
values this way:
#dofine Gotsystenciock()
(8000000002)fdefine GetInstructioncieck()
(Getsystenclock() /1)
#dofine GetPeripheraiciock()
(Getsystenclock 0/1)
In addition to the TCP/IP stack’s TICK_SECOND
interval, the PIC32MX795F512U's UARTs and SPI portals
derive their baud rates from these speed values.
While we're at it, let's map in that single pushbutton
switch:
#define BUTTONO_TRIS (TRISGbits.7RISG32)
7/882
fdefine BUTTON 10 _ (PORTGbits.RG2)
#define BUTTONI_TRIS (TRISDbits.TRISD13)
Vie Button
fdafine BUTTON ro _ (PORTDbits.RD?)
#define BUTTONZTRIS (TRISDbite.TRISDL3)
Tite Button
fdefine BUTTON2 10 (PORTDbits.RD13)
#define BUTTONSTRIS (TRISDbits.TRISDL3)
Vie Button
#dafine BUTTON3_10 (PORTDbits.RD13)
In addition to controling our board's LEDs, the
TCP/IP stack also contains code that senses the
pushbutton status.
We can test our Ethemet portal, the LEDs, and the
pushbutton switch by simply running the HTTP server
module of the TCP/IP stack. The default Microchip web
page that is served contains visual LED and pushbutton
switch indicators. The LEDs can be illuminated and
extinguished via a click of the mouse. The pushbutton
status reflects the state of the pushbutton on our board.
In that we are depending on a served web page to
confirm our hardware, it would be nice to define the
251C1024 hookup. The 25LC1024 is responsible for
housing the web page binary image. Here's what the
TCPAP stack wants to see:
fdetine EEPROM cS_TRIS
Vdefine EEPROMCS—10
Vdofine EEPROMISCR TRIS
faefine EEPROUSDI“TRIS
Sdefine EEPROM_SDOWTRIS
(rRISabite,7RISA1S)
(GATAbits.LATAI5)
(RISDDL ts. 7RISD1O)
(IRISCDAts “TRISCA)
-RISDDits ,7RISDO)
Vdetine SPI P50bits.SPI1IF)
Adefine EEPROM S32BE (SPTLBUF)
Vdefine EEPROMCSPTCONL {SPTACON}
fdefine EEPROM SPICONIDits (SPIICONbits)
fdefine EEPROM_SPICON2 (SPTLCON2)
fdetine EEPROM_SPISTAT {seIistaT)
Hdefine EEPROM SPISTATDits
Adefine EEPROM_SPIBRG
(SPLISTATbIts)
(SPTIBRG)
‘That should be enough to get us started. So, le’s feed
the MIC29150 +5 VDC and see what happens.
nemo.dyndns-server.com
That happens to be the URL that calls up the web
page from our PIC32MX795F512L that is currently
running the TCP/IP stack. | placed nemo.dyndas-
server.com in the host lst of my DYN account. My DYN
Welcome! —————
1 rlUplats pase sr cogent ano
mM Screenshot 1, | went around the horn to get to our board's
Ethernet interface. The URL nemo.dyndns-server.com maps
back to the Cisco router on my bench. Our board is
programmed to sit at 192.168.0:99 on the EDTP LAN.
account tracks the IP address of the Cisco router that is
running on my bench, so I can access my router from the
Internet by simply using nemo.dyndnsserver.com as the
target URL. Since our board is physically attached to the
shop’s LAN, | could have also entered 192.168.0.99. Here.
is the TCP/IP stack information that makes that possible:
fdefine my DEFAULT MAC BYTEL (0x00)
Hdefine MY_DEFAULT-MAC BYTE? (0x08)
Hderine HACLBYTES (0x03)
Haerine HAC_BYTES (0x00)
Hderine BYTES (0x00)
Hdefine MY_DEFAULT_MAC BYTES (0x00)
faetine cagzun)
Hdefine Gesu)
Hderine (oul)
Hderine (8801)
Either way, we get our web page which is captured in
Screenshot 1
It Works!
However, we still have more firmware work to do. We
stil need to verity the pair of microSD subsystems and the
remaining UART interfaces.
For now, the LEDs on our PIC32MX795F512L board
follow the clicks of the mouse on the web page LED
indicators, and the pushbutton switch togeles the web
page's buttons indicator. The “I'm alive” LED is also,
working as designed.
In the next installment of Design Cycle, we will focus
‘on completing the firmware that brings our
PIC32MX7956512L board's silicon to life. NW
August 2015 WISNOUS 65Electronics from the Ground Up:
Learn by Hacking, Designing,
and Inventing
by
Ronald Quen ELECTRONICS
Sreucemerst’ | GROUND
ena alten UP
electronic device?
Electronics from the
Ground Up guides
you through
Step-by-step experi
ments that reves!
hhow electronie circuits function s0 you
advance your sis and design custom
circuits, Youll work with a range of circuits
and signals related to optical emitters and
receivers, audio, oscilaors, and video.
Paper back 544 pages
$30.00
GREAT FOR DiYers!
Electronics Workshop
Companion for Hobbyists
by Stan Gibilisco
In this practical ro
ge pea
Bie
"elecroncs||
) Workshop
Seer ern
Sopyamptowe
Companion
setup a home
‘workshop £0 you
can invent, design,
build, eest,and
repair electronic
cireuits and gadgets.
lectronics Workshop
Companion for Hobbyists
provides tps for constructing your
‘workbench and stocking ft with the tools
Components, and test equipment you'll
need. Clear ilustrations and inveresting
‘do-it-yourself experiments are included
throughout this hands-on resource.
$25.00
be aia
Arduino Projects for
Amateur Radio
by Jack Purdum, Dennis Kidder
Boost Your
Ham Radio's
Capabilities Using |
Gescanie
z=" ((48))
Do you wane to
increase the
functionally and
value of your ham
radio withoue
pending alot of
money! ths book wil show you how!
‘Arduino Project for Amateur Rado sled
‘with step-by-step mlerocontrller projects
You can aecomplsh on your own" no
Programming experience necessary.
Reg Price $30.00 Sale Price $24.00
Make Your Own.
PCBs with EAGLE
by Eric Kleinert
Featuring detailed pms
illustrations and
step-by-step.
instructions, Make
Your Own PCBs with
EAGLE lends you
through the process
of designing 8
Schematic and
transforming into
PCB layout. You'l
then move on to
fabrication via the generation of standard
Gerber files for submission to 2 PCB man-
facturing service, This practical guide
offers an accessible, logteal way to learn
EAGLE and start producing PCBs as
quickly as possible,
Build Your Own
Transistor Radios
by Ronald Quan
A Hobbyist's Guide to High
and Low-Powered
Ganson radios
thar are inexpensive
ye hihly efi
Mride'ous book
fers compete
projects wth
Beatied schematics
Sd nights on how
Sra redea were
‘Rsgned: Lean .
howto choose
Components,
onserct the diferen types of radios, and
{roubleshoot your werle
TRANSISTOR
RADIOS
Beginner's Guide to Reading
Schematics, 3E
by Stan Gibilisco
Navi the roadmaps
Sramplecearone EM
Sireate and complex
Syptems wth heb rom
ahexpertenced
tngneer With alonew
trturd domo orcas
you ean bul, this
Xandson trated
Zeige expan how 2
{derstand and create
hgepreceon
seen dgrm
Find ve how to
‘deny pres and connections, decipher
Slement ratings and appy agram-onsed
information in your own projects.
Tod
Guide to
“Poperbocl 496 poger
$30.00 Ror Price $4998 Se Price $39.95 $25.00
How to Diagnose and Fix Programming PICs in Basie Programming Arduino
Everything Electronic Ny Chuck Hellebuyck Next Steps: Going Further
by Michael Jay Geler you wanted 20 learn with Sketches
Master the Art of,
Electronics Repair
ae ai ity
In is hands-on
aude Welong
Scenics ror
pr shares tested
fecniqueand
inalble ge
Howto Diggs ond
fe trenne
Elec shows you how to repair and
extend te fe oa nds of sob ace
dhs trom rien dig gdgury 63
charaitd wndog produc of yoneryonn
$24.95
Pai
o
66 NITSIVONS Avoust 2015
haw to program
mirocartalir. then
roulve found the’ right
boil Microchip Pe
microcontrollers are
Being designed into.
lectonies throughout
the world and none
more popular than the
epi version: Now
the home hobbyist ean
ree projec wih hase de
‘evelopment tool called the CHIPAXE
System and the Basic software
Itnguage Chuck Hellebayek introduces
how t9 use this development setup to
build useful projets with an eightpin
PICI2F683 microcontroler $14.05
by Simon Monk
In this practi! guide,
electrons guru Simon
Monk takes you under
the hood of Arduino
and reveals professional
programming secrets
[Also shows you how
o-use interrupts,
‘manage memory,
program for the
Ineernet, maximize seri-
al communications,
perform cigtal signal
Drocessing and much more.All of the 75+
example sketches featured in the book are
swallble for download, $20.00
pore!
act ary KC ‘www,store.nutsvolts.com
Or CALL 1-800-783-4624 today!
EDUCATIONAL CD-ROM SPECIAL
Bookicombor ¢
Ea 132 Tr
Complete with supporting
MN HEV CM ele WCC)
a v
TRARSISTO
RADIOS
ae. ,
i Pd
ie eee
al Ea eeu bara = 5!
1st
Arduino Classroom - learn computing and eletroies
eH
‘The free Internet virtual textbook: Arduine 101
at www.arduinoclassroom,com provides a sensible
learning sequence that Introduces computing and
electronics with clear text and detailed hands-on labs
with tested examples using the Arduino Projects Kit.
Available from Nuts&Volts for only $44.99
August 2015 NUTSTVOUS 674-800-783-4624
www.nutsvolts.com
I si
Looking for a way to protect all your
frozen yummies?? ln the June 2015 issue
‘we have an article that wil help
you do just that.
The kit includes:
| Transmicter PCB, | Recelver PCB
I Transmitter Programmed Chip
| Receiver Programmed Chip
(ther components can be found at your
favorite parts house.
$39.95
Solar Charge Controller Kit 2.0
W you charge batteries using solar
panels, then you can't afford not to have
them protected from over-charging. This
12 vol/12 amp charge controller
is great protection for the money. Its
simple to build, ideal for the novice, and
PROJECTS,
Seismograph Kit
Now you ean record your own
shaking, rating, nd rolling
‘The Poor Man's Seismograph isa great
projectidevice to record any movement in
‘an area where you normally shoulda’ have
‘any The kit includes everything needed to
build the seismograph.All you need is your
PC, SD card, and co download the free
software to view the seismic event graph,
$79.95
Geiger Counter Kit
This kt isa great project for high
‘school and universicy students The unit
devects and displays levels of radiation,
and can detect and cisplay dosage levels,
25 low as one micro-roentgen/hr.
‘The LND 712 tube in our kit is capable
fof measuring alpha, beta, ana
3D LED Cube Kit
‘This kit shows you how to build a
realy cool 3D cube with a4x 4x4
monochromatic LED matric which has a
total of 64 LEDs. The preprogrammed
microcontroller that includes 29 patterns
‘that will automatically play with a runtime
of approximately 6-1/2 minutes.
Colors available: Green, Red Yellow & Blue
$97.95
Super Detector Circuit Set
Pick a circuit!
With one PCB you have the option
(of detecting wirelessly:
temperature, vibration, light, sound,
motion, normally open switch, normally
closed switch, any varying resistor
‘no special tools are needed other than amma particles input. voltage input, mA Input, and tl
2 foldering iron and a 9164" dri Partial kts azo avalable Just co name a few.
$27.95 $159.95 $32.95
FOR BEGINNER GEEKS!
The Learning Lab 1 The Leaming Lab 2 The Learning Lab 3
Funders Cons Basic Digtal Concepts Basic Electronics scl ators
and Op-Ampe and Amplifiers
$59.95
NE
$49.95
Au
at
$39.95
These labs from LF Components shaw simple and interesting experiments and lessons all done on a solderless circuit board
‘As you do each experiment, you learn how basic components werk in a crcuit,and continue to build your arsenal
of knowledge with each successive experiment.
For more info and lab details, please visit our webstore.
68 NITSIVONS Avoust 2018mE |
mNEW
PRODUCTS
Continued trom page 27
currents even in tight
spaces, clamping onto
conductors up to 5 mm in
diameter.
Many current probes
require external power
supplies or amplifiers to
display a waveform on an
oscilloscope screen, but
the CPO30A and CPO31A
probes connect directly to
Teledyne LeCroy’s
oscilloscopes through a
builtin front panel ProBus
interface, thus requiring no
additional external
hardware. This connection
allows communication
between the current probe
and the scope, resulting in
current waveforms that are
automatically displayed on
screen in amps and
calculated power traces
scaled correctly in watts
This full integration also
allows for degauss and
autozero functions to be
accomplished directly from
the oscilloscope’s user interfac
probes are available in a variety of models for a wide
range of applications; prices start at $3,790. The full range
of current probes includes models with bandwidths up to
100 MHz, peak currents up to
‘SURPLUS ELECTRONIC PARTS & ACCESSORIES
oo Fane Posmtomeon Spaatere YOR Pars
‘Surplus Material Components No Minimum Order
‘SMCELECTRONICS Credit Cards ang PAYPAL Accopted,
www smesiectronics.com Flat $4 65 per oder USA Shipping
Wire and cable since
[email protected]
1973. Items avaiable. from
1888 GO 4 KITS
stock: Hook up wire, Shrink
tubing Cable tes, Connectors,
Arduino + Raspberry Pi
Power Supr
tte Wire cut & strip to specs,
‘wisn, striping If inereste,
plese call 1-800-626-
7540, FAX: 714-563-8209.
VisiMCiAmex. See us on
the Internet: worwanaheim
wirecom or email info@
2naheimuirecom,
Visit us at:
www.gkits.com
PT Ig
aL
-e. Teledyne LeCroy current Pricer
Til
700A, and sensitivities to 1 x
mA/div. Teledyne LeCroy current probes are often used in eon
applications such as the design and testing of switching,
power supplies, motor drives, electric vehicles, and
uninterruptible power supplies.
BGA SOCKET FOR TESTING
DEVICES WITH SMART
FEATURES
[rence Becronics recentyinvoduced anew BGA
socket that addresses high performance requirements
for testing BGA devices with smart features. The contactor
is a stamped spring pin with 17 gram actuation force per
DEC EQUIPMENT ae
WANTE!
Digtal Equipment Corp.
For more information, contact nd compa.
Saelig Company, By Sell Tac
www.saelig.com (caus Kerwavs 937-047-2300
or emall uyer@keywayscom ;parts-express.com/nuts,
Continued on page 7 August 2015 MUTSEYOUS 69NEAR SPACE @ BY L. PAUL VERHAGE
CubeSats — Part 5: Designing a
Model CubeSat for High School Use
As CubeSats continue to play a pivotal role in space exploration, it's
important to introduce more schools to their technology. There are CubeSat
teaching kits on the market to meet this need; however, | want to see one
that primary and secondary schools can afford. Besides, | strongly believe
that space and near space make excellent STEM platforms, and a model
CubeSat could tap into middle and high school student's interests.
Therefore, this month I'll describe a CubeSat kit I'm designing with the
intent of using it in my high school.
The Affordable CubeSat Airframe
First things first, this is not a real CubeSat kit; that is,
you can’t launch the finished product into space, For
one thing, the body is plastie and outgases in the
vacuum of space. Second, the bus does not meet the
PC104 standard, Aside from these issues, however, it’s a
pretty decent model that | believe will become an
70 NITSIVONS. August 2015APPROACHING THE FINAL FRONTIER
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/index.php?/magazine/article/august2015_NearSpace.
exciting satellite kit that will help
motivate America’s next generation
of aerospace engineers
The concept of stacking PCBs
(printed circuit boards) to form the
layers of a CubeSat was pretty simple
rasp. Therefore, the issue |
actually struggled with the most was
the airframe of the CubeSat. | was
flummoxed to come up with a sin
and inexpensive solution, and was at
the point of asking a friend to laser-
cut sheets of acrylic plastic. Using,
laser-cut panels would raise the cost
of the Model CubeSat kit, so I was
hesitant to go this route. Then, one
afternoon the solution found me
J occasionally visit the Interstate
Plastic store in Boise, ID to look over
their scraps for ideas. One day while
rummaging through their scrap pile, |
found a discounted item: a plastic
display cube for baseballs
The cube slides open into two
pieces, with each piece being a "C
shaped sheet of plastic. The sturdy
walls of the baseball display are 1/8'
thick, and it’s a perfectly square cube
that measured 4-3/32" across, That's
close enough for a CubeSat mode,
and I'd be able to stack my fake
PC104 cards inside of it
Now that | had a cube, it was
time to make printed circuit boards
for the electronics. Before I could
design PCBs for the CubeSat, |
needed to select a microcontroller
and design its bus. A real PC104 card
supports pretty sophisticated
microcontrollers and single-board
computers (SBCs), and uses a 104
pin bus. | had no intention of doing
the same because | was creating a
CubeSat kit for a PICAXE
microcontroller
A PICAXE-14M2 or 18M2 would
suit the purposes of the kit since they | curve than would using something pin SIP (two rows of the same pins)
was programmed in BASIC. Using, like C#, Since the microcontroller for stability and strength,
BASIC meant the Model CubeSat would be a PICAXE, | decided to use Below are the pin functions o'
would have a shallower learning an 18>pin bus contained ona 2x18 | the bus. If he PICAXE-14M2 is used,
August 2015 MUSEYOUS. 71[email protected]
‘The Model CubeSat kit contains a
series of PCBs like this one.
Instructions included in the kit —
along with the top silk on each
PCB — will explain the proper
placement of the electroni
components.
then not all of the pins in the bus are
available,
GND (Ground)
2 (vo)
Commit (Input oniy)
Commit (Input oniy)
8.2 (YO)
83 (VO)
SDA (HC)
SCL (PC)
B5 (YO)
8.6 (VO)
87 (YO)
+5V (Regulated five volts)
Vin (Input voltage)
C6 (vo)
C7 yO)
0/0)
1 (yo)
GND (Ground)
Each plane was created on
FreePCB, and based on a generic
plane | initially created. Opening the
generic plane and then modifying it
for a new one ensures that the new
plane fits the other existing planes.
Each plane has the dimensions of
a PC104 card, and has a minimum of
the 2x 18 pin SIP and four 1/4”
diameter holes in the corners. When
stacked together with the SIP and
spacers, each plane is 5/8” apart
72 NITSVOES, August 2018
The current radio used in the Model CubeSat doesn't need an
antenna. So, the “antenna” is just bolted to the top of the CubeSat's
plastic frame. In the future, | plan to connect the antenna to the radio.
‘That way, an amateur rocket can launch the Model CubeSat severai
thousand feet into the air where a ground station can communicate
with it during its descent.
The Planes (So Far)
To date, | am happy with four
planes that "ve created. There is
more work to do with regard to
tweaking older planes and building
new versions. For one, I found the
Model CubeSat could use all the YO
‘on the bus, so | will need to focus
more attention on the PICAXE-18M2
version of the control plane,
Currently, I'm experimenting with
the following planes as I write this
article: power; microconteoller;
photometer; and radio
Power Plane
The initial version of the power
plane uses four “AAA” cells, but will
eventually contain a rechargeable
lithium polymer battery. That’s
because I find it’s too much trouble
to destack the CubeSat when the
batteries are dead,
Real CubeSats use hot wire
cutters to release deployables like
antenna elements and solar panels.
That's too hazardous for students, so
instead, the power plane (which is
always located at the bottom of the
stack) contains a micro-servo that lifts
a pin to release CubeSat deployables.
For now, I've bolted a length of
metal tape measure to the top of the
Cubesat’s airframe to act as its
deployable antenna, Attached to the
ends of the metal tape are loops of
Dacron string that reach the metal
pin attached to the micro-servo's
horn. When the servo rotates up, it
lifts the pin and releases the antenna
‘elements. The antenna then snaps
out with a pop that will startle you if
you aren't prepared,
Soldered to the underside of the
power plane is a momentary tactile
switch,
This replicates the switch
CubeSats use to detect that they've
The power plane with its
battery holders, switch, and
antenna-release servo,been released from their P-POD
dispenser.
The current program in the
Model CubeSat waits in a loop for a
button to be pressed before
beginning its mission and releasing
the antenna, Eventually I'l find a
tactile switch with a longer
pushbutton that actually protrudes
from the bottom of the airframe. The
Model CubeSat will wait until i's
lifted off the table to signal it’s been
dispensed from its P-POD. One other
thing | discovered about the power
plane is that the main power switch
must be replaced; it’s too difficult to
reach inside the airframe and flip on
the swith its currently using, I'll
replace it with a pushbutton switch
with a plunger long enough to reach
the surface of the airframe.
Microcontroller Plane
The microcontroller plane
supports the PICAXE and I'C
memory chip. The memory allows
the Model CubeSat to store
science data until its next radio
contact with the ground station,
There are two changes I want to
make, however.
First is to shift the DB-9
programming header outward just
a bit more. Right nowy, it’s just
beyond reach of the PC's
programming cable. Then, on the
underside of the PCB, is a right
angle header for the deployables’
micro-servo. | want t move that
servo header to the power plane
in the next version.
Photometer Plane
Currently, the only science-
related plane for the Model CubeSat
is a two-channel LED photometer.
This measures light intensity in the
blue and infrared portions of the
spectrum. A future upgrade will let
students select which two colors of
the spectrum to measure.
There are LED detectors at each
comer of the PCB in the hopes that
This microcontroller plane
contains a PICAXE-14M2.
Eventually, I'll switch to a
PICAXE-18M2 for access to
more VO.
The first science-focused plane is the
photometer plane.
using many LEDs will make the
CubeSat less sensitive to pointing
direction. The plane also contains an
LM335 temperature sensor to
calibrate the LED's output (LEDs are
sensitive to their temperature). The
photometer’s intensity readings
appear on a bus VO as a variable
voltage where they are then digitized
by the microcontroller.
The XBee radio provides two-way
communication between the Model
CubeSat and the ground station.
Something borrowed,
something blue. This XBes
radio is from @ moon rover
project | made using
CheapBots.
Plane
The last plane is the radio
plane. It provides twoway
communication with a simulated
ground station. The radio is an
Bee radio and the plane converts
the main +5V power supply to #3.3V
for the radio (the +3.3 volts is limited
to just the plane and not available
cover the bus). Communication is
serial and uses the TX and RX pins in
the Model CubeSat’s bus.
So, what about the ground
station? The ground station 'm using
‘was originally designed for a moon
August 2015 MTSEVOUS. 73,rover robot project | built five years ago. It uses a PICAXE-
(08M2 to interface a PC to its XBee radio.
‘Communication with the PC is through the Terminal
program included in the PICAXE Program Editor. This
means the ground station’s PICAXE coordinates and.
formats communicate between the radio and PC so that,
an operator can easily understand what information the
Model CubeSat is telemetering,
What's Next?
The Model CubeSat is still a work in progress. In the
near term, however, | want to develop the following
additions.
First, the Model CubeSat needs more Y/O in order to
take advantage of its volume. I've already designed the
PCB for a PICAXE18M2 microcontroller plane; | just need
to design additional PCBs before | can send it out for
manufacture (I prefer to combine several different PCBS
and then panelize them in order to save money)
Second, the Model CubeSat needs a communications
protocol. | designed one for my moon rover and plan to
Use a variation of it for the Model CubeSat. That would
allow the CubeSat to store and download data like real
A AP CIRCUITS
As low as. Two Boards
Two Layers
. Two Masks
eae’ One Legend
Unmasked boards ship next day!
www.apcircuits.com
74 NITION. August 2015
CubeSats do when they're out of range of a ground
station.
| want additional science and engineering planes. That
way, the Model CubeSat can be restacked and
reconfigured for new missions. The latest plane I've
designed is a sun sensor and magnetometer plane. It
detects which surface of the CubeSat faces the Sun and
the orientation of Earth’s magnetic field relative to the
CubeSat. This will permit the Model CubeSat to determine
its attitude in space.
Another plane I'd like to create is a Geiger counter
plane to allow the CubeSat to determine the amount of
radiation around it.
What does a CubeSat do with attitude information?
Aside from transmitting that information to the ground
station, it can be used to help hold the attitude of the
CubeSat with magnetorquers. That's not really practical
with this model, but | will create a plane to simulate
magnetorquers.
In place of magnetorquers will be b-colored LEDs that
illuminate when the magnetorquers are energized. So,
when the Mode! CubeSat is out of its desired orientation,
the LEDs turn on indicating the magnetorquers are active.
‘The color of the LEDs will indicate the polarity of the
magnetorquers. Then, when the Model CubeSat is turned
back to its desired attitude, the LEDs are turned off.
A more difficult addition, | think, is using real solar
panels to recharge the CubeSat’s battery. The solar
panels would measure 4” square and would need to be
encapsulated for durability. The panels would
mechanically attach to the Model CubeSat airframe and
electrically connect to their own plane. The solar panel’s
current would then feed into the Vin pin of the Model
CubeSat bus. The recharging circuit would need to be an
upgraded power plane.
Finally, | want to add a camera. A slow scan camera
‘would be ideal, but even a baby monitoring camera
‘would be fine. The Model CubeSat would activate the
camera when commanded to do so by the ground
station. I’m assuming Il se different transmitters and
frequencies for the camera and XBee. Therefore, while
the camera is transmitting an image, there would be no
further communication aver the XBee in order to
simulate the CubeSat using the same radio for both
functions,
When | think about it, I guess I'm only half way done
with just the design of the Model CubeSat. There's still a
lot of work developing new planes, writing code, and
‘writing directions for students. However, it’s my hope to
make this kit available to schools as a complete
curriculum that teaches electronics, programming, and
engineering. With space as its focus, | think many
students will find it a motivating project to work on.
‘Onwards and Upwards,
Your near space guide NWll NEW PRODUCTS
Continua from page 69
ball, and a cycle life of 500,000 insertions. The self
inductance of the contactor is 0.98 nH, insertion loss < 1
GB at 21.9 GHz, The current capacity of each contactor is
four amps at 30°C temperature rise. Socket temperature
range is 35°C 10 +180°C.
‘The socket also features a floating guide for precise
ball to pin alignment and a Bluetooth electronic module
integrated into the top portion of the socket (compression
plate}. 4 thermo couple sensor is brought down from the
electronic circuitry to the internal socket cavity where the
BGA is placed. When the BGA is placed and compressed
against a printed circuit board (PCB) via the contact
element, the thermo couple touches the top BGA surface.
Power is applied to the BGA to start its function. As
the BGA starts functioning, heat is generated. This heat is
sensed by the thermocouple and fed to the electronic
Circuitry where its processed, then the temperature is
displayed via a Bluetooth mobile app. The app monitors
temperature continuously and provides result in graphical
format, This feature is very useful for testing during BGA
characterization. All BGA sockets can be integrated with
this smart feature depending on space availabilty. Custom
features can be added to any of the company’s standard
BGA sockets, as well, Contact Ironwood Electronics for a
price quote,
For more information, contact:
Ironwood Electronics
www.ironwoodelectronics.com
PIC32 HARMONY SOFTWARE
DECODER FRAMEWORK
crochip Technology, Inc., now has available the
PIC32 Harmony Software Decoder Framework and
Microsoft Windows Media Audio (WMA) Decoder Library
for 32-bit PIC32 microcontroller (MCU}based consumer
audio application development within the MPLAB@
Harmony Integrated Software Framework. The WMA
Decoder Library includes a new modular framework for
audio decoders including support for MP3 and AAC,
allowing for easier audio application development.
Microchip's Audio Decoder Framework allows for
audio software codecs to be easily addled to a PIC32
design project. Rather than having to rewrite large sections
‘of application code, the framework allows for easier
integration into an existing customer application after the
corresponding decoder library has been purchased. The
WMA Decoder increases the depth of the library for
PIC32 MCUsupported audio decoders, in addition to
MP3 and AAC. This increases the range of audio formats
that designers can choose to support.
The audio decoder framework within the Harmony
environment allows designers to easily add, subtract, and
switch among various software-based audio decoders.
Additionally, including a WMA decoder gives developers
an even wider set of options and support for audio
playback
The WMA Decoder Library is targeted for low cost
applications in consumer markets such as audio docks,
home audio receivers, and automotive head units. It gives
developers added flexibility in decoder options that play
back from internal or removable media. The addition of a
WMA Decoder Library further expands the audio
application flexibility of PIC32-based designs, building
upon existing USB and Bluetooth streaming audio
solutions
The Microsoft WMA Decoder Library (part #5
3320015 and SW320025-1HPM, $199.97 and $199.00),
is supported by Microchip's free MPLAB Harmony
Integrated Software Framework and PIC32 Bluetooth
Audio Development Kit (part # V320032, $199.99), all of
which are available now:
For more information, contact:
Microchip
www.microchip.com
August 2015 WSNVOUS. 75PRACTICAL 3D PRINTING
im BY CHUCK HELLEBUYCK
Pegboard
Solder Hold
1am constantly looking for my roll of solder. I like to use a water
soluble flux version so | can wash off the solder flux with water
launched the free-to-use Tinkercad software from my
Chrome browser (which is recommended) and began
the design. It realy didn’t take a lot of time to create
the actual piece, but getting the spacing right was.
the toughest part. | decided to just use a screw and nut to
secure the holder to the pegboard. | didn’t trust a plastic
hook to hold up. | also wanted a couple of guide pins to
locate the bracket and eliminate the need for two screws.
wanted some strength, so I used a triangle support
bracket from the base up to the post that will hold the
solder roll. Figure 1 shows the completed design.
The design consisted of multiple objects essentially
slued together to make the final piece. | ike Tinkercad
because it makes 3D design as easy as building with blocks
like I did as a kid. In places where I need to take material
away, | just create an object that is a “hole” and that
removes anything it touches rather than add to it.
Figure 2 shows the blocks that create the final design.
The light gray blocks are the holes where material is
removed. | squared off the edges of two parts because |
76 WATSHOKTS Auoust 2015
FIGURE 2. Tinkercad blocks
Using 3D printers for
practical projects on
your workbench.
er
thought it looked better.
In Tinkercad, | just select all the objects and then gr
them together to make the final piece. When the design
complete, it can be exported as an .STL format file so it can
be imported into the XYZware software | use for sling the
file and sending it to my da Vinci 1.0 printer 3D printer.
I made the design public, so anybody can copy it and
modify the source file in Tinkercad to fit their requirements,
| also uploaded the .STL fle to my Thingiverse.com
account, o anyone can print the same design | created.
I printed the holder with the post sticking straight up.
‘This eliminated the need for support material. This is not
the best way to print it for strength, however, as the layers
can potentially sag if the solder roll is too heavy. Printing
it lengthwise would be stronger but some support would
bee required, and that means extra plastic to use and extra
work to remove it. | also thought at some point | could
redo the design with a hollow shaft and then insert a metal,
rod inside for strength. That is actually a popular 3D print,
technique: Pause the print near the top of the post; insertREAL WORLD USES FOR THE ELECTRONICS EXPERIMENTER
Post comments on this article and find any associated files and/or downloads at
‘www-nutsvolts.com/index. php?/magazine/artic
FIGURE 3. Print Position
the metal rod; and then let the print finish
= that covers up and traps the metal rod
inside. | found | didn’t need this though, as
it was strong enough for me.
The final design in Figure 3 shows the Thingiverse 3D
presentation of the object based on the file, and Figures,
4 and 5 show the finished print. You can see they look
very similar | used a 0.2 layer height and a 50% fil to give
it strength. It took 3-1/2 hours to print and 8-1/2 meters
of filament. At the current price of $28 for a cartridge of
XYZprinting filament, the bracket cost about $1 in plastic.
Figure 6 shows the solder holder mounted to my
bench. It works great! My son liked it so much he had me
print several for his job where they build up electronic
boards. He also used the same design to hold wire spools
(Figure 7), then added a tube above the reel with a small
slot so he could guide the wire and solder down to the
user’s hands. | probably could have 3D printed that guide
tube as well, but sometimes just a standard off-the-shelf
plastic tube will work fine.
They've been in use for many months now with very
litte issue. A new roll of solder will cause the bar to sag a
little, but it springs back as the weight reduces.
The ideas for what else could be mounted to the
pegboard with a custom bracket are endless, ve seen
Resources
Check out my website and blog:
www.elproducts.com
YouTube Channel:
www.youtube.com/user/beginnerelectronics
My 3D designs:
worwsthingiverse.com/elproducts/designs
Tinkercad:
www.tinkercad.com
Da Vinci 30:
us.xyzPrinting.com:
SolderHolder Design:
https://tinkercad.com/things/9WatVIISTH
INFIGURE 4, Mounted Position
/august2015 Practi
13DPrinting.
FIGURE 5. Back View
screwdriver racks, digital caliper mounts,
jumper wire racks, and many more useful
mounting ideas. The fact that you can
customize it to fit your specific tool is
what makes 3D printing your own tool holders so great.
You can create the design any way you want instead of
trying to find something that might work.
You could just design something out of wood, but that
requires you to make all the cuts, put it together, and then
if you want another, repeat the whole process. The 3D
printer does all the work once the design is set, and that is
a total time saver. I set up many prints before | go to bed,
50 in the moming, the design is ready to use.
Making my lab more organized is always a challenge,
as tend to let stuff pile up on top of my bench. So, making
a custommounting bracket like this is not only easy and
cheap, but extremely useful
There are many more 3D printed pegboard designs at
Thingiverse.com that can be modified as necessary since
you can import an STL file into Tinkercad and then add or
remove material to make it look how you want — even if
you don’t have the original design.
Let me know what you've printed or seen printed for
an electronic hobbyist’s workbench. Sharing ideas is what
makes 3D printing so popular, NW
Pst eavy
and solder mounts.
‘August 2015 MTSWVOUS 77READER
>>> QUESTIONS
Headphone Hookup
My flat panel TV doesn’t have
headphone jack. It has dual RCA
jacks labeled “R/L line out” and a
“TOSLINK’ connector. What would
be the simplest way to get my
headphones hooked up to this TV?
#8151 Chad Kessler
Marion, IN
Dim Bulb
What's the difference circuit wise
between a “dimmable” and a “non
dimmable” 110V home LED light
bulb?
Jeremy Tores
#8152 Garden City, NY
Servo Cycler
I would like to make a servo
tester that would continuously run
a servo from 0 to 180 degrees and
back. I have found a number of 555
servo tester designs, but none that
actually cycle the servo, Does anyone
have a schematic for such a thing?
#8153 ‘Owen Corlis
Plymouth, MI
Voltage Mod
| am trying to build a small micro
ampere meter project I found on the
Internet (Figure 1). The design calls
for a +9V and -9V supply. Is it possible
to modify this circuit to use a single
9V battery instead of two?
#8154 Stephan Barth
Grand Bay, AL
All questions AND answers are
submitted by Nuis & Volts readers and
are intended to promote the exchange
of ideas and provide assistance
for solving technical problems. All
submissions are subject to editing
and will be published on a space
available basis if deemed suitable by
the publisher. Answers are submitted
7 WISHOUS August 2015,
TO
READER
‘icro ampere mete
>>> ANSWERS
[#6153 - June 2015]
Bipolar vs. MOSFET
{ve read that bipolar transistors
are current devices and MOSFET
transistors — lke ole-fashioned vacuum
tubes — are voltage-operated devices.
What does that mean from a
practical perspective? For example,
does this mean that bipolar are best
for high power applications and
MOSFETs are best for low voltage
applications?
MOSFETS come in many flavors:
there are Naype and P-type of
course, but there is enhancement
mode and depletion mode.
Enhancement mode is off at zero gate
voltage; you have to apply a positive
gate voltage for N-type or a negative
gate voltage for Pype to turn it on.
Netype MOSFETs are available with
by readers and NO GUARANTEES
WHATSOEVER are made by the
publisher. The implementation of any
answer printed in this column may
require varying degrees of technical
experience and should only be
attempted by qualified individuals.
Always use common sense and
good judgment!
Wan eireuiteteday com
drain voltage ratings from 30V to
800V or more. Most MOSFETs are
designed for switching; an 800V, 10
‘amp device would quickly burn up
Unless it could turn on and saturate
‘even quicker.
MOSFETs are characterized by
their saturation resistance which can
be very low (like .01 ohms). Bipolar
transistors on the other hand, are
‘characterized by their saturation
voltage which can’t get as low power
as MOSFETs. The threshold voltage
(the point where the transistor just
{ums on) is not well controlled,
0 you can't really know what the
drain current will be at a particular
voltage. That makes it cfficult to
design a linear circuit, | avoid that
problem by using bipolar transistors
in linear circuits, or using pulse width
modulation in a switching circuit
which can be filtered to produce an
analog signal.
Depletion mode MOSFETs are on
at zero gate voltage and you have to
apply a negative gate voltage to an
Nitype to turn it off. Junction FETS are
also depletion mode devices and the
zero gate voltage drain current is not
well controlled, so they are usually
binned and labeled so you have some
idea of what you are designing with,
Russell Kincaid
ford, NH>>>YOUR ELECTRONICS QUESTIONS ANSWERED HERE BY N&V READERS
Send all questions and answers by email to [email protected]
or via the online form at www.nutsvolts.com/tech-forum
[#7151 - July 2015]
PIR Hookup
My home alarm system has a
motion sensor that has failed and the
alarm company wants $89 for a new
one! | removed the bad one and it has
screw terminals labeled:
*OND
hw
* ALARM COM
* ALARM NC
*TAMPI
*TAMP2
The simple PIRs Hind for use
with the Arduino are SV and they
don’t have “tamp” pins. Can someone
provide a schematic on how to
hhook up one of these low cost
replacements?
#1 You only need to connect four
wires for a burglar alarm motion
detector to work properly. “GND”
and “12V" are voltage for the motion
detector — 12V is the positive, GND
is the negative. “ALARM COM” and
“ALARM NC" connect to the zone
input on your burglar alarm panel.
‘Typically, there is no need for polarity
because this is a simple switch — with
no motion in the area, the switch
is closed; if motion is detected, the
switch opens.
“TAMP1” and “TAMP2" are
connected to a microswitch within
the motion detector housing that
activates your alarm if someone
were to remove the cover — called
a “tamper.” If anything is connected
to these terminals, you can simply
‘wvist the wires together, complete
the circuit, and cap them off. I is not
necessary to utilize the tamper feature
and is often not recommended.
But, | would avoid any type of
“inexpensive” replacements for your
alarm system motion detector. One
Of the major sources of false alarms in
burglar alarm systems tends to be the
motion detector. Installing a motion
detector not specifically designed for
burglar alarm use may end up causing
false alarms with your system and
depending on your jurisdiction, fines
from the local police department from
the dispatching of those false alarms.
Most burglar alarm motion detectors
are designed to limit false triggers, so |
‘would suggest going that route.
I did a quick search and could
find a reliable motion detector listed
for burglar alarm use for $25. Easy
‘enough to replace yourself; just make
sure you seal up any penetrations
in the housing where the wire and
screws go through. Spiders love to
make homes in these and that will
also cause false alarms.
Alternately, $89 may not be a
bad price for your alarm company to
replace the detector if that includes
the labor. Nobody wants to work for
free, afterall! Plus, you can get them
to quickly check your system to make
sure it is communicating properly
to your monitoring company and
everything is working correctly
Eric D. Bailey
Cecilton, MD
#2 There are several reasons an
Arduino hobby type PIR is not a
good substitute for a commercial PIR
motion sensor.
1) You will need to step down the
12V to 5V with a voltage regulator.
Coincidentally, page 78 of the July
2015 N&V Tech Forum has answers
fora 5V regulator question.
2) You will need to add a SV relay
from the TTL output of your Arduino
PIR so that you can provide floating
form C (COM and NC} contacts
for Alam COM and ALARM NC.
Normally, the ALARM contacts are
closed unless an alarm condition is,
sensed. ll sensors and switches in
the ALARM loop are wired in series
ina burglar alarm. Color code may
vary, but in my experience a red and
a black wire were used. You should
pay attention to the colors used in
your system,
3) Unlike a commercial PIR, the
Arduino PIR does not have an optical
shield and/or shutiers to adjust the
beam width. As such, it will have a
broader sensitivity and be susceptible
to false alarms from moving persons
or objects outside windows or pets
inside, Additionally, it may be blinded
from ambient light sources.
4) The terminals marked TAMP1
and TAMP2 are tamper switch
connections. Normally, the tamper
Circuit is closed unless the sensor
case is opened. In my experience,
‘a white and green wire were used
for tamper circuits. Yours may differ.
Ifthe tamper switch is opened
in a commercial alarm system, a
supervisory signal is sent to the alarm
office and a technician is sent to
inspect the system. This is to prevent
a woulthbe burglar from opening the
sensor and tampering with wires or
placing tape over the PIR sensor. In
a residential alarm system, a trouble
light will appear locally at the control
panel. With the above information,
you can make the Arduino PIR
function, however, the possibility
{or false alarms will be much greater
unless you are willing to spend the
time constructing a proper light
shield.
The $89 quoted by your alarm
company sounds fait, and is an even
better deal if they install it for that
price. you are under contract for
alarm reporting to the central office,
modification of the system may create
problems with the agreement. You
may be able to find an equivalent
commercial sensor on e-Bay for a
800d price if you insist on replacing
it, Personally, I would stick with a
commercial PIR for this application.
Joe Leikhim
Oviedo, FL
August 2015. MUSIVOUS. 79imurivewweeres ADvertiser INDEX
AMATEUR RADIO
ANDTV
National RF 21
Ramsey Electronics e283
BATTERIES/CHARGERS
Hitee. 2
BUYING ELECTRONIC
SURPLUS
Earth Computer Technologies «33
CCD CAMERAS/VIDEO
Ramsey Electronice e283
CIRCUIT BOARDS
AP Circuits ™
Dimension Engineering 14
ExpressPOB . 32
Front Panel Expre88 LLC sono 8
Saslig Co. Ine Back Cover
COMPONENTS
soPisi at
COMPUTER
Hardware
Earth Computer Technologies 38
Microcontrollers /
VO Boards
MikroEtektronika 3
Technologie Systems. 19
80 WASIVOLS Avoust 2015
DESIGN/ENGINEERING/
REPAIR SERVICES
Cleveland insttute of Electronics. 33
ExpressPCB 2
Front Panel Express LLC... 8
National RF 21
DRIVE COMPONENT
CATALOGS
SDPIS! 2
EDUCATION
Boxed kit Amps 21
Cleveland insttute of Electronics. 2
Command Produations 13
INK El0Ct N18 sonnet
Poscope. i
ENCLOSURES
Front Panel Expre88 LLC onion
HI-FI AUDIO
Boxed Kit Amps 21
KITS & PLANS
Boxed Kt Amps a
Earth Computer Teco 98
KC Elect0N8 vn
Pamrsoy Blecvorics 22-89
MISC,/SURPLUS
Al Electonics Cop 2
Front Panel Express LLG ....6
MOTORS
‘Servo CityRobot Zone 5
PROGRAMMERS
MikroBlektronika
RETRANSMITTERS/
REC!
ERS
National RF 21
ROBOTICS
Cleveland instute of Electrons. 33
Hitec 2
‘SOPISI 21
‘Servo Gityobot Zone 5
‘SATELLITE
‘Servo City Robot Zone 5
Team Synergy Moon,
TEST EQUIPMENT
Dimension Engineering nnn 44
NKC Electronies 21
Poscope 2
Saelig Co. Ine Back Cover
TOOLS
MikroBlektronika 3
PARAVISE 5
Poscope
WIRE, CABLE AND.
CONNECTORS
‘Serve Gity Robot Zone 5
AM Electonics C01P. nu-52
AP Cireulte m4
Boxed Kit AMPS ren
Cleveland inst of
Electronics
Command Productions ...13
Dimension Engineering....14
Ean Computer Technologies 83,
ExpreSSPCB eens 2
Front Panel Express LLC
Hite e
IMieoElektronika 3
National AF a
NKC Electronics 2
Panavise 6
Poscope, 22
Ramsey Electonics 8288
SasligCo. Inc. ..Back Cover
SDPISI one 21
Servo City Robot Zone
Team Synergy MOON AB
Technologie Systems satSERVO macazine...
Paving the way for the next generation
of Robotics Experimenters!
SUBSCRIBE TODAY!
Call us at 877-525-2539 or visit our website at
www.servomagazine.com
OW ele EAA
compete
Pred: eaiakcs al ert)
rar end rin
ah term
ro
VAN ae
ERVO
ROVE
Co
ny tne Tia)PETS ae Ue i
Donets
Soren Nee
CORO aaa
Peroni
fereetac perro emeeaee
Cra ree aoe
Poet etree ES
Pec eed
RUN Me eect a
Derren rd eer ech
pat eee ent cae
Pechenegs
eee ea eae reer acs CoM aT Naa
Pa AMT resign oh A a calcio an
ee ree ter na eee mee
Pa nace ey co re en a Peace ee ee ee
Bene cee
CRU a ace te eee ad
Hotere nee ee ea beeen cae at
ea eae Pee ee ee
Eee Se to ee
te
ied
We then jumped the technological timeline ofthe 60's Nixie cplays by adding the latest mul-colored LEDs to
Pe Ea ere cee rene eta re
Be ee ee
Then we leaped over the technological melng by iterating an optional GS time base reference fr the u
Pere eae eke ee eee ee
HO EN Uh ta Een ea As
Pes ee A ne rat eek ne ee cote ane a
FL ice CR a eS
See eee es ar
Pan cn tan eta
Pad eee ee
ore al ar’ Pe ekenkey eee ne arn
States ae en Oat ht ta
Sait Pat anee ea
ec ee eee eae ’
Bee eee ao =
ae ec
eee acd
Ser rene ies
aa)
aye
Pt ray Rawal Mee eal
inte Paid sas Winewe? | gg | fips ne rose err,
Pott eer Petter)
Pecan pe erected
Pe mer ce en ee eee
eee el f Veena rod
seer ae reer
Sas ieee
Ses eer acl
Peed rier
os
pee ete a eal
ERIE Gre
Bo ees
Rene ee ee eae
ree
ee
at Poe
crea
Se ERE mee
Premier
eee ee nate
Macro en ee ied
ated
Ep erst ora
Papcoypieniacetoaent ante
Ee etree
soles eae
peepee
FREE eee
Pinon eerie)
ERR ee aL
cre
Eoaareene teen
err
Pla earee een
eee ee
Spice at
pe heiietanl arene
Draenei eats
(eae ates eh
pennalergeneerirer een
aspen oreo
Dee ae bal
Poiaracsoenerenp nen
eno
ea sree eer
alate
Phare re
eer pe
nena ene
Piomenne pecd
mM bert
i neeute ty cr
er Mme SUES bred
Eee Aires
Cees ESE
ET amd ca
ame aot Prats
PURI Re Ue Rem ae
Tne CE a pk
eT aye ee
te Teed
meee eet) buy
[There's only so, much room on these two
eorer en ete aera
Ronee mar
pages and search with ease! Visit
rete teal
Follow Us and SAVE $$
(ee ee
CareerSU ee ae a as
erent terns i
Beach eh ele
eee en ee narra eatery
Bae rece pee ay
ee eee
Fee ean Cp eee Oe
eee ne en eee are
Sc in eee ee
Bee eta nce
ee tae
ae
earn Sear treet toad
Pa Acer Metco Reese ena
pr eine cre ee ne eee ee
Sere Seine Lea tar en ene eet aI
Pra en Te ae Ce
Peete ee ee ete ere
Breed berate errant rout hae
el Riel Dea eer a adie
Petia wih aaNet pale Red sUlenibe ar tehieerad
Heater tl tec ats snk eed ens tty a
pe pe ty
M308 Digital EM stereo Transmitter Kt 0-25mW, Black
age eee eee)
eee
oer
Rien a
eee a
Pacer acne eee
Prey
Bry
boro
Touch a, tach of, ar momenta
Ere nan
eet er ee js
PRUE ee ree
a opp a ee ox
Mad Blaster Warble Alarm feel Bose B lone d
eee epee
me poate a as cme to
Bee ese Erector tee
eee eae
eo ors ER eee nies
ea Perera
ey poe trea”
eerie a Panter gern ter m
feelers PRE St tested bed
Pee alles ie fetal Bote ea iit ane)
Se ee ae Es
Geen on Sa ee an
ere Tee Stok snooker ;
aS rcp ers
Sree hereon Bere real
ee an ones bs
er eres
oy
eter emer tt
Recetas
Ra nae
ea ae
SEA
Sead
re a.
Perea -
pi
ae Ss
Stn > ;
See am erg eat a
(eee os Mere ETE,
eee ron ney
Betis
ee eT)
Prt ee
CSU Un ae aCe
Ree ane etn eM Earn
ERO Skee pny
‘hooks standard Supt 10D with ronge up
ee a a ae
eaten
ecto eae cae
CM atece rel et Rae
PC eee eo are
Pee ate ey
Dae ee eee)
Preterm oe ney
ai cee ee ee aya
See era a ee
acer
Pesach aeeie err ee
ae are er aac
Eee
Ce ee ee ed
eed x.
eres
ee rer
eerie
pees
epee
aes
SMS Electronic Site Kit
Bo
Deru
eee er]
beer a ert
Peet
Sear een ee ay
Escenas
ee Teens
Fee
Se
pepe
Coan ees
Ee eRe
Pare
Po ed
Brey
Ce
To ae
SD RET
td oe
ape Ca abe ee EU a any
peeve cece ney = en cae cnet eee Ragan een Ta ey
Chee Pee ee eee ean ree ar ent hio aa te
Sono riaey oem see et eee ee eo eS
Cen eye ae
oe aR rpseepaeeges tec ea
oe eane cs ele Oe Pere SN
eas ab rare ie | cece ts ae ee
Bran ap [eet pmb
Sac Pola ors Oe
Lee ee yt FS rey
ea hee mT meet me eran eer mT
amici neat un 800-446-2295 RAMSEY ELECTRONICS®
Nong carer td ld
oa a a bedrbadacies ued Dred
10% off your order! peepee sie str EeOscilloscopes
RIGOL’s test &measurementinstruments
compete with industry leaders but more
affordably; Analog & Mixed-signal Scopes
fo 1GHz with AWG, Function/AWGs from
20MHz-350MHz RF Signal Gens to
6GHz, Pwr Supplies, DMM, & Spectrum
OWONS affordable, reliable, easy-to-use
precision benchtop & handheld scopes
ate unbeatable in ther price range. Battery
powered and portable options for field
Use. Qwon’s Triple Output Power Supplies
offertemote control & preset configurations,
Pico
PICO TECHNOLOGY - the world’s best
PC-based oscilloscopes & data acquisition
{equipment with the performance of good
bench scopes; compact &lightweight-ideal
forfield work. Award-winning automotive
Scopes find engine & electricfaults quickly.
in Test & Measurement
Circuit/PCB Test
ABI Electronics
RF Test
Aim-TTI, Aaronia, Rigol
Fy
ny sy ;
a ee
Affordable benchtop and handheld RF test
tools measure free audio channels, find
Interference, emissions, noise, distortion,
demodulate AM/FM signals etc Some
inchide tracking generators to measure
Gireut frequency response automaticaly
Telemakus
‘TELEMAKUS's - USB
controlled, memory
sticksized RF devices
build reconfigurable,
‘complex, economical
and portable RF test
system with features
‘of expensive benchtop systems, RMS
detectors, Switches, Digital Attenuators,
Vector Modulators Synthesized Sources
SWORD
SWORD Inc custom,
portable, quick-erect
RF shielded enclosures
provide supetior RF
shielding in_ fabri.
based structures which
attenuate RF signals
from electronic equipment by up to
10048, excellent for testing or eliminating,
electronic eavesdropping possibilities.
‘ABI ELECTRONICS - PCB testitepaln
BoardMaster 8000: easy-use PCB test
system; JTAGMaster: programs/tests via
{TAG port; RevEng Schematic Learning,
‘System: generates schematics rom PCBS;
SENTRY: detects counterfeit components.
map
MAP ELECTRONICS - USB20 Analyzers
1Gens, Protocol/Electrical Test equipment,
offering unbeatable value/performance
ratio and Vbus monitoring. GraphicUSB
software offers full analysis of std USB20
protocol with Class Analysis options
Cosview
COSVIEW - range of
‘extremely affordable USB-
connected inspection
microscopes & stands,
very useful for examining
printed circuit boards
‘and small integrated
cdrcults for production faults or part
number markings. Polarizing fiter option
which excludes surface glare is available,
i Saeli + Incredible Low Prices « Excellent Customer Service « Free Technical Support +
/ g 585-385-1750 www.saelig.com [email protected]
unique elec