You are on page 1of 100

Speed. Torque. Accuracy. Resilience.

Hitec servos have been delivering the STAR power you demand since 1983.

Whether you require the pint-sized proficiency of a micro, the steadfast performance of a standard
sport, the efficiency of a brushless digital or the IP-67-rating of a waterproof giant, our top-level
engineering, design and technology goes into everything we manufacture. For generations,
Hitec’s talented team of R & D professionals have committed to building the
highest quality of servos on the market, giving you the power to be your best.
Be STAR POWERED with Hitec!

Hitec RCD USA, Inc. | 12760 Danielson Court, Unit E | Poway, CA 92064 | (858) 748-6948 | www.hitecrcd.com |
Go portable with LDG!

IN THE
FIELD! ZERO POWER TUNERS
One of the great things about ham radio is that you can take
your hobby with you wherever you go. You’re not limited to These tuners include a AA battery pack
the shack, but can operate mobile from your car, handheld and are zero power once tuned!
just walking around with an HT, and of course portable in the
¿HOG :KHWKHU SLFQLFNLQJ FDPSLQJ SXWWLQJ SDUNV LVODQGV
lighthouses or mountain peaks on the air, or on Field Day,
you can set up a portable station just about anywhere. And
of course, when things go bad like a hurricane, earthquake
or other natural or manmade disaster you can set up an
emergency station near the action to help coordinate rescue
and relief.
Z-100Plus
Low cost and Portable, the Z-100Plus operates from any 7 to
18 volt DC source. AA batteries will run it for a year of normal
A lot of modern ham equipment is ideal for portable
use. Internal ffrequency
re
req
e uen counter
e cy cou
ounte
nteer sstores
ores tuning
tor
ores u ing parameters
tun param
pa ram
amet ete
e te s for
ers fo
operation. You can get a 100 watt radio that’s about the
fast recall. Handles
andl ess 100
ndles 10 watts
wa
attts SSB
tts SSB or or 30
30 watts
ttts digital.
watt
watt dig
igi
g tal
ta
a l.
size of a hardback book, weighs only a few pounds, and
will run off a battery for hours. The hard part about portable
operation is always the antenna. There are generally two
ways to go: you can put up a temporary wire antenna like
a dipole or long wire, or you can use a portable antenna
OLNHDYHUWLFDORUDKDPVWLFNGLSROH,QDQ\FDVHIRUHI¿FLHQW
operation you’ll need a tuner to match the antenna to your
radio. Z-11ProII
Designed for Battery Operation. Operates from 0.1 to 100
LDG makes several tuners that are ideal for portable ZDWWV 66% RU &:  ZDWWV GLJLWDO *UHDW IRU ERWK 453 DQG
operation. They are light weight, compact, and can run on standard 100 watts transceivers. Matches dipoles, verticals,
internal batteries so they require no external power source inverted vees and most coax fed antennas.
at all; they’re literally just plug and play. The Z-100Plus and
Z-11ProII handle up to 125 watts, and the Z-817 up to 20
watts. And, they all include a free internal battery holder.
These tuners use latching relays to hold the tuning settings,
so in standby mode once tuning is complete they use
essentially no power at all. A set of AA batteries will typically
last for months of normal operation.
Z-817
As you plan for the fun and utility of portable operation, 7KHXOWLPDWH453DXWRWXQHU6HDPOHVVLQWHJUDWLRQWRWKH<DHVX
complete your portable kit with an LDG tuner. Visit us on the FT-817 and FT-818 provide one button tuning. 2000 memories
web at www.ldgelectronics.com. covers 160 through 6 meters, 20 watts SSB, 5 watts digital.

LDG ELECTRONICS IS A PROUD


SPONSOR OF
support@ldgelectronics.com
www.ldgelectronics.com
Have you signed up your hamfest or show?
Get your
THEfree LDG/MTC Hamfest
INTERSECTION Swag
OF LIFE ANDBag!
Contact Christine at MTC
Contact your favorite LDG Dealer TODAY!
AMATEUR RADIO
100wattsandawire.com
christine@maintradingcompany.com
LDG/MTC Bringing Back Hamfests!
Your Main Hamfest Prize Center!
I N OU R
NOWTH YEAR!
40 January -
08 Q&A
February 2019
Reader Questions Answered Here
Topics discussed this time:
• Girding for Battle
• Battle Language
• Who Needs Wires?
• Adrift in Time

10 The Ham’s Wireless


Workbench
Practical Technology from the Ham World
Rotators
If the antennas that hams use can focus a signal, then
they need to be able to focus it in the desired direction.
The thing that hams use to point their antennas — large
and small — is called a rotator. There’s a wide range of
rotators, just like with antennas. We’ll cover some of the Page 10
most common types and give you an idea of how they
work. After all, your ham radio success turns on them!
93 Open Communication
88 Near Space
The Latest in Networking and Wireless
Technologies
Approaching the Final Frontier IoT Made Easy
Cosmic Rays Redux The whole Internet of Things (IoT) phenomenon has been
Eight years ago, I wrote an article about detecting cosmic around for a while now, but have you tried to create an IoT
rays on a near space flight. I’d like to revisit this topic, but device on your own? If so, you know it’s not easy. However,
not from the perspective of using the Aware Electronics it is now easier than ever as many of the manufacturers of
RM-60 Geiger counter. My first near space mission this IoT wireless chips and modules are providing the hardware
year carried a new type of detector: one made for detecting and software to make an IoT device happen with minimum
muons. In this article, I’ll tell you about muons and the work. One example is the Wireless Xpress BGX13P module
detector I used to measure their flux. starter kit from Silicon Laboratories.

06 DEVELOPING
Departments 16 NEW PRODUCTS
PERSPECTIVES 31 BENCH & BUILDER
The Ergonomics 86 NV WEBSTORE
of Learning 96 TECH FORUM
07 READER FEEDBACK 97 AD INDEX

Subscription Information
Page 79 Nuts & Volts — PO Box 15277
North Hollywood, CA 91615-9218
Nuts & Volts (ISSN 1528-9885/CDN Pub Agree #40702530) is published bi-monthly for $26.95 per Call 877-525-2539 or go to www.nutsvolts.com
year by T & L Publications, Inc., 2279 Eagle Glen Parkway, #112-481, Corona, CA 92883. PERIODICALS
POSTAGE PAID AT CORONA, CA AND AT ADDITIONAL MAILING OFFICES. POST­MASTER: Send Subscribe • Gift • Renewal • Change of Info
address changes to Nuts & Volts, P.O. Box 15277, North Hollywood, CA 91615 or Station A, P.O. Box 54,
Windsor ON N9A 6J5; cpcreturns@nutsvolts.com. For more details on subscribing, see our ad on Page 51.
4 January/February 2019
52 More Tricks with Old-School
Digital Clocks
Here are a few of the many possible variations on the
Page 32 general theme of discrete-logic digital clocks. If you have a
few LED displays, counters, drivers, and simple logic, you
can probably build a clock. Consult the datasheets of the
ICs you choose to use, breadboard everything first, and

18 Build an Internet Digital Clock


have fun.
■ by Bryant Julstrom
The advent of the ESP32 Wi-Fi development boards allows
for an increase in the sophistication of a digital clock. It
doesn’t take much imagination to envision a digital clock 58 C Preprocessor Reduces
with a large LCD display to not only show the usual time,
date, temperature, and humidity, but to also be able
Debug Headaches
In my experience, few hobbyists or experimenters take
to retrieve things from the Internet like the weather or
advantage of C preprocessor operations. You’ve probably
weather forecast and stock market reports as well. This
seen preprocessor directives such as #include <stdio.h>
seven inch clock also automatically corrects for Daylight
or #include “servo.h” among the first lines in programs.
Savings Time.
However, they are not part of the C language. When you
■ by Theron Wierenga and Daniel Millisor
compile a program, it first goes through a preprocessor
that handles housekeeping tasks such as including files
24 Build the Laser Pencil Engraver that operate a peripheral or that provide a function such as
printf. This tutorial shows how to take advantage of this.
Several months ago, an idea popped into my head for a
fun project. I wondered if I could burn some characters ■ by Jonathan A. Titus
into the yellow paint of a No. 2 pencil with one of those
powerful diode lasers available on eBay. Perhaps it could
be my name or my grandkid’s names, or even a happy
64 DIY Biotech: Open Source PCR
birthday message to my lovely wife. Here’s how I did it.
■ by David Goodsell
Thermocycler
In this DIY Biotech article, we’ll look at an Open Source
Polymerase Chain Reaction (PCR) Thermocycler kit. In
32 Build a Fun Stylophone addition to learning about DNA amplification, we’ll cover
thermal sensing, thermal resistance, the thermoelectric
I decided to make an electronic musical toy as a Christmas
effect, and PID controllers
gift for my young son. I browsed the Web looking for
■ by Bryan Bergeron
inspiration and found the stylophone: a miniature analog
stylus-operated keyboard that was invented in 1967 by
Brian Jarvis. My unique take on it combines music and
writing to make learning fun!
72 Your Amigo Does Bluetooth
If you’re a Mentor’s Friend (a.k.a., Amigo) owner, I
■ by Alexander Krylov hope you and a young protégé have enjoyed hours of
fun together exploring introductory programming and
36 Build an RF Frequency Counter simple computer hardware control. This article offers a
slightly more advanced Mentor’s Friend project for you to
Buffer for HF consider: Exploring Bluetooth using the Amigo breadboard
and Color BASIC serial interface.
Most frequency counters can tolerate only low levels of
RF at their input, but here’s a way to safely measure the ■ by Dane Weston
frequency of an RF signal of up to 200 watts with your
existing frequency counter.
■ by Dwayne Kincaid WD8OYG
79 An ESP8266 Live Wi-Fi Webcam
Having read about the ESP8266 NTP clock in previous
issues of Nuts & Volts, an idea came to mind to construct
42 The Discovery of Radio Waves an interface camera using the ESP8266. In this project,
we used an old Android phone as a camera source and
When the concept of electromagnetic waves was first
proposed around 1864, it was met with great skepticism. linked to an ESP8266 based webserver. The phone acts
As a result, the idea languished for a long time. It took as a camera server and the ESP8266 web server acts as a
several decades for a handful of dedicated persons — client to the camera server. The webserver displays the live
infatuated with the mysteries of electricity and magnetism webcam on its web page.
■ by Kathiresan Muthiah M.Sc. and Benjamin Robson M.Sc.Ph.D
— to finally put the theory on a solid footing.
In this article, we’ll take a look back at this period that
launched the serious study of radio waves. We’ll examine
the contribution of James Clerk Maxwell: the man most
responsible for the concept. Next, we’ll look at the work of
several notable scientists who came after Maxwell, and see
how they confirmed the existence of radio waves. Page 24
■ by Dr. George R. Steber
January/February 2019 5
DEVELOPING
PERSPECTIVES
by
Bryan
Bergeron,
Editor
Published Bi-Monthly By
T & L Publications, Inc.
2279 Eagle Glen Pkwy #112-481
Corona, CA 92883
OFFICE: (951) 371-8497
FAX: (951) 371-3052
WEBSTORE: (800) 783-4624
www.nutsvolts.com

The Ergonomics of Learning


SUBSCRIPTION
Toll Free: (877) 525-2539

I
Outside US: (818) 487-4545
f you have parents or grandparents of five or more. It’s the same idea P.O. Box 15277
North Hollywood, CA 91615
with arthritis, then you’re probably behind the large grips on utensils for the
subscribe@nutsvolts.com
familiar with oversized handles on elderly with arthritis. Oversized grips
everything from eating utensils and allow someone with a compromised
FOUNDER
kitchen knives, to door knobs and or underdeveloped fine motor control Jack Lemieux
toothbrushes. If you’re unable to move system to get the work done.
your joints in certain ways without pain Better yet, if I had the ability to PUBLISHER
or with enough strength, then there choose a larger robot arm with larger, Larry Lemieux
are some things you just can’t do with more robust servo motors with larger publisher@nutsvolts.com
conventional tools. hardware, the boy could have probably
At the other end of the age handled a regular size screwdriver. This ASSOCIATE PUBLISHER/
spectrum — below a certain age or is the thrust of my observations. ADVERTISING SALES
maturation level — you can’t expect When you’re teaching someone Robin Lemieux
a child to handle certain tools. I’m to work with tools in constructing or robin@nutsvolts.com
not talking about whether a nine year repairing electronics, consider the
old can handle a circular saw, but a ergonomics of learning the entire EXECUTIVE DIRECTOR/
screwdriver, needle-nose pliers, or system — the tools as well as what those PRODUCTION
a soldering iron. And the issue isn’t tools will be used on. Sean Lemieux
responsibility or safety, but physical I don’t know the relative sean@nutsvolts.com
ability — a reflection of the maturation contribution of nature or nurture, but
of their fine motor skills. my brother and I grew up building EDITOR
Your 14 year old may be model airplanes. By seven or eight, Bryan Bergeron
techedit-nutsvolts@yahoo.com
responsible enough to work with your we were cutting balsa wood freehand
$200 miniature screwdriver set, but with X-acto™ blades. In my case, I’d
CONTRIBUTING EDITORS
may lack the fine motor skills necessary like to think the practice carried over to Ward Silver Kristen McIntyre
to use the screwdrivers without ruining electronics. Lou Frenzel Paul Verhage
the screwdriver tips. That’s a recipe for Even so, maturation is an individual Kathiresan Muthiah Benjamin Robson
frustration, anxiety, loss of confidence, process. Two people may eventually Jon Titus George Steber
and maybe a turnoff to electronics in get to the same level of mastery, but it Dane Weston Theron Wierenga
general. may take one longer and require more Daniel Millisor Dwayne Kincaid
For example, I was helping intense practice than the other. If you Bryant Julstrom David Goodsell
a friend’s teenager repair a set of take the time to match the project, Alex Krylov
servos from a robot arm using a set of tools, and ability of the learner, then
SHOW COORDINATOR
miniature drivers, soldering iron, and the journey can be fun and educational Audrey Lemieux
pliers. The boy simply couldn’t hold regardless of how long it takes.
the miniature screwdrivers between his I’m not advocating you purchase WEBSTORE MARKETING/
thumb and index finger. Instead, he had special “tools for children.” In my COVER GRAPHICS
to grip the screwdrivers with his fist, experience, these tools are simply Brian Kirkpatrick
using all four fingers and thumb. cheap miniature versions of real tools brian@nutsvolts.com
As a result, the screwdrivers often that break and result in injury or at
slipped off the screw heads and into best frustration. If you’re going to give Copyright © 2019
the servo motor. Luckily, the damage a youngster a set of tools, make them by T & L Publications, Inc.
to the wires was only cosmetic. The adult tools. All Rights Reserved
All advertising is subject to publisher’s approval.
screwdriver tips, however, required a You might consider add-ons such We are not responsible for mistakes, misprints, or
touchup with a blade sharpener. as grip extenders, but that’s about it. typographical errors. Nuts & Volts Magazine asumes
no responsibility for the availability or condition of
It wasn’t the boy’s fault, but rather And make sure the task fits their ability advertised items or for the honesty of the advertiser.
my failure to recognize his maturation level. The youngster that’s all thumbs The publisher makes no claims for the legality
level when it came to handling the with a miniature tool set may want that of any item advertised in Nuts & Volts. This is the
sole responsibility of the advertiser. Advertisers
screwdrivers. I should have considered mosquito-sized drone kit. and their agencies agree to indemnify and protect
purchasing barrel extensions: metal Get them the full-sized versions of the publisher from any and all claims, action, or
expense arising from advertising placed in Nuts &
doughnuts that increase the diameter tools and kits. They’ll have more fun and Volts. Please send all editorial correspondence, UPS,
of the screwdriver handle by a factor learn more in the long run. NV overnight mail, and artwork to: 2279 Eagle Glen Pkwy
#112-481, Corona, CA 92883.

6 January/February 2019
READER FEEDBACK
Analyzing Situation
I finally received my copy of the
November/December 2018 Nuts &
Volts, following the interruption of
mail service from a postal strike in
Canada in December. I really enjoyed
Robert Reed’s article on building a
“Basic Audio Distortion Analyzer” on Please continue writing articles Glad to hear the DIY Biotech
page 32. Had I seen it sooner I might on this subject. articles are making a difference! We
well have built this project. G.D. Gopal have several more planned, so stay
Like Mr. Reed, I have worked tuned!
for different companies in the past
who used professional quality audio

ALLELECTRONICS.com
distortion analyzers, such as those
made in the 1970s by Hewlett
Packard. In fact, at one point, I was
responsible for the regular calibration
of half a dozen of them (not sure of Surplus & New Parts & Supplies since 1967
exact model numbers then, but likely
the 331A or similar). Order Online or Toll Free 1-800-826-5432
So, in December 2018, when
I came across one of these vintage 36" MICRO-USB to USB CABLE SPECIAL, 12 VDC 3 AMP
instruments at a reasonable price on VERY SPECIAL PRICE POWER
eBay, I couldn’t help myself. I had Charge and sync cables for SUPPLY
to have it! (See the photo included smart phones, tablets, 6' output cable
here.) cameras and other with 2.1mm coax
Fortunately, all that was needed portable devices. plug, center+. cULus.
to get it up and running was to CAT# CB-427 CAT# PS-1272 50 for $6.45 each
1
$ 50
6
$ 95
10 for $1.25 each
replace two shorted capacitors in the 100 for $1.00 each 100 for $6.00 each
meter circuit and the neon pilot light each each
with an LED. Fond memories indeed.
I was also pleasantly surprised 6 VDC, 25 RPM GEAR MOTOR 0-100V DC VOLTMETERS
New gear head motor Three 0.28" digits on a
when Mr. Reed described his use of prepped with an arm 0.89" x 0.39" display.
the little known “Bubba” oscillator. that rotates an offset axle Three wire operation.
The “Bubba” and other sine wave in a 1" circle. Motor is

3
oscillators are well described in 1.45"D x 3.00"L. No-load specs: 25RPM @ Red digits CAT# PM-126 $ 95
“Design of Op-Amp Sine Wave 6Vdc, 150mA. Prepped w/ wire leads and Blue digits CAT# PM-126B each
Oscillators” by Ron Mancini of Texas drive arm. Includes a custom mounting
Instruments (www.ti.com/sc/docs/ bracket and slotted metal link rod. AGC (3AG) FUSE POST
apps/msp/journal/aug2000/aug_07. CAT# DCM-470 Screw-style cap. Fits standard
pdf).
4
$ 75 10 for $4.25 each
100 for $3.75 each AGC, 3AG 0.25" x 1.25"

1
each
Don Dorward VA3DDN cartridge fuses. $ 50
300 LEDS, RED, GREEN, CAT# FHPM-31 each
DIY Biotech Inspires
First of all, congratulations on YELLOW, BLUE, WHITE 10 for $1.35 each • 100 for $1.15 each

bringing out a fantastic publication. • 5mm LEDs,


20 pcs each color. BLACK ABS PLASTIC
Bryan Bergeron’s “Developing PROJECT BOX, 5.3" x 3" x 1.9"
• 3mm LEDs,
Perspectives” in the September/ 40 pcs each color. Interlocking lid secured
October issue was extremely • Clear plastic divided with self-tapping
informative. box with locking lid. screws. Interior slots
Our trust is managing four CAT# LED-K1 for pc boards.

8
$ 00
schools and we are seriously thinking CAT# MB-113
about bringing in a subject on DNA
and Biotechnology. This article will
kit
4
$ 50
each 10 for $4.00 each
definitely be an inspiration for our SPDT ON-ON MINI
teachers. TOGGLE SWITCH 12VDC SPDT 40A
We were seriously considering RATED: 6 amp @ 120 Vac. AUTOMOTIVE RELAY
getting equipment from one Solder lug terminals. Plastic enclosed, 1.1" x 1.2" x
company but found it required a huge 1/4-40 threaded bushing. 0.43" long handle. 1" high. Mounts in standard
CAT# MTS-4 automotive relay socket.
investment. The companies Bergeron
CAT# RLY-351
mentioned are comparatively
reasonable and affordable. 1
$ 25
each
10 for $1.10 each
100 for 95¢ each 10 for $2.25 each 2
$ 55
each

January/February 2019 7
Q&A
■ WITH KRISTEN A. McINTYRE

In this column, Kristen answers questions about all aspects of electronics, including
computer hardware, software, circuits, electronic theory, troubleshooting, and anything
else of interest to the hobbyist. Feel free to participate with your questions, comments, or
suggestions. Send all questions and comments to: Q&A@nutsvolts.com.
that titanium alloy is difficult to
• Girding for Battle • Who Needs Wires? machine because of its hardness.
Titanium easily work-hardens, so
• Battle Language • Adrift in Time you need to make sure you are
making constant progress when
Girding for Battle cutting with a drill, for example.

Q
This requires a hardened drill bit and lots of pressure.
I’m building a combat robot from scratch and If you can afford titanium and know how to machine it,
want to design it as bulletproof as possible. it might be a good choice for your combat robot.
Assuming cost isn’t a consideration, what’s the
best metal for the body: titanium or stainless Battle Language

Q
steel? My understanding is that steel will take more of a
beating, but at a significant weight penalty. I’m thinking After watching the movie, Gamer (where
that a titanium chassis would give me the edge to scoot players control other humans), I realized that
out of the way and avoid direct hits from the opponent. the weak link in my battling robot system is my
Thoughts? reaction time and not the robot hardware or
Doug Richardson software. So, I’m thinking of moving basic reflex moves to
Plano, TX autonomous control by the robot, and that I could override

A
those moves if necessary. What language(s) would you
Titanium is a great metal. I love its strength and use to control the local reflexes? I’m thinking low-level
lightness. The frames of my glasses are made assembler to make things as snappy as possible, but then
of titanium alloy and I often forget that I’m I lose the portability of a language such as C. Should I go
wearing them. high- or low-level control language? Any thoughts on the
First, let’s look at the relative densities of steel and overall design?
titanium. For both metals, the particular alloy will change Lyle Mendez
the density, but this will give us some idea. Plain mild Birmingham, AL

A
steel has a density of about 7.85 g/cm3. Stainless steel is
about the same. That means that every cubic centimeter Autonomous reactions could be a very
of steel weighs 7.85 grams. Titanium, by contrast, is 4.5 g/ interesting approach. Whether you can override
cm3. So, an equivalent amount of titanium would be a little them in real time will be a challenge, but if your
more than half the weight. That’s a good thing for a battle reaction time is fast, it might be possible.
robot, perhaps. It depends on whether being lighter would As for languages for real time control, it somewhat
make it easier to be thrown around. You could also use the depends on the CPU’s speed. Programming in assembly
lighter weight armor to put bigger motors or other gadgets language can be simultaneously fun and painful. I’ve
inside for better performance at the same weight. done a lot of assembly programming, and it’s fun to be
Titanium tensile strength is remarkable when right down on the bare metal, squeezing out each extra
compared to steel. Tensile strength is expressed in a instruction. The problem, however, is that this code is often
complicated set of units (106N•m/kg), but the values can fragile and difficult to understand and maintain.
be compared. The best alloy I could find has a tensile My suggestion — based on a lot of experience in this
strength of 282, while steel is 165. Stainless steel is even area — would be to start writing everything in C and see
worse at around 105. Other strength measures are similar. what is too slow. Maybe it will be fast enough, but your
So, I think that titanium would probably take more of a investment in the C code will pay off. Usually, you’ll find
beating than steel, and certainly more than stainless steel. that only a few functions or inner loops are not performing
Of course, TANSTAAFL applies (There Ain’t No Such well enough to achieve your goals. In that case, you’ll
Thing As A Free Lunch). Titanium is quite expensive. I want to speed those up by optimizing them in assembly
found a 12” x 12” x 0.2” sheet of so-called grade 2 titanium language.
for just under $40. I’m sure a comparable steel plate Since you already have a C rendering of what you
can be found for just a few dollars. The other problem is want to achieve, you can start with what the compiler
8 January/February 2019
QUESTIONS and ANSWERS
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2019/01.

generated. Most compilers have a switch to make them


produce assembly language output (on Unix systems, that’s Adrift in Time
usually -S). You can use that assembly code as a starting
point and see how you can optimize it. Be sure to use the
highest optimization level of the compiler to start (on Unix
again, -O followed by some number like 3 or 4). Check the
manual pages for your compiler.
There are at least two ways of getting that assembly
code to be part of your project. You can isolate it to
an assembly language file and make it a function that
can be called from C by following your development
environment’s calling conventions. That is the most
straightforward way, but you have the cost of the function n FIGURE 1.

Q
call. Keep in mind that the more parameters to the function
there are, the more overhead. Usually, these parameters I built a clock using a DS1302 RTC (Real Time
need to be transferred via the stack or registers. In either Clock) chip with a 32.768 kHz crystal per the
case, they must be marshaled into their appropriate datasheet. The clock loses a few minutes per
locations prior to the function call, and that slows things month. I’m looking for a way to fix this. I’ve
down. seen schematics using capacitors to “trim” the crystal, but
Another approach that should be faster depends on I don’t know how to go about it for this application. The
your compiler. Some compilers — like gcc and llvm — allow circuit is in Figure 1. Any help is most appreciated.
in-line assembly language. This has two advantages. You Keith Ujvary
can avoid that function call I mentioned, and you can Oliver, BC

A
reference variables in your function symbolically. This
latter property makes writing the assembly language much The crystals used in RTC applications have a
easier. very low base frequency of ~32 kHz (actually,
You can also keep the C code right next to assembly, 215). These components are not constructed like
using the preprocessor (#if) to select each implementation. typical crystals; they look more like tuning forks.
That can be useful when checking for correctness. The drift in these crystals is large. The frequency varies with
temperature and changes as they age. This makes it hard to
Who Needs Wires? get them to be perfectly accurate. If the frequency is too

Q
high (i.e., the clock is running fast), a trimmer capacitor of
I’m tired of constantly plugging in my wireless just a few pF can be used to pull the frequency in closer to
Bluetooth earbuds for a nightly charge. Do the desired one.
you know of a retrofit that will allow me to use In your case, though, the frequency is too low, so it
inductive charging, like the system used by the can’t be trimmed. A low oscillation frequency can have
Apple Watch? I wouldn’t mind the extra weight or size, several causes. There’s a great article on this topic from
within reason of course. Maxim Integrated at https://www.maximintegrated.com/
John Piche en/app-notes/index.mvp/id/58. They make the DS1302
Chelsea, VT these days after acquiring Dallas Semiconductor.

A
To summarize the possible causes, there are four listed:
I had to look around for this, but it appears that
the market has solved this problem for you. 1. Overshoot on the control signals stopping the
I think it’s best to use a standardized oscillator periodically.
charging protocol, and QI seems to be the 2. A crystal with a lower load capacitance than the
standard for most devices these days. You didn’t mention device expects.
what kind of charging port your earbuds are currently 3. Stray capacitance around the crystal pins.
using, but let’s assume micro USB. 4. Temperature variations.
A quick search on Amazon showed a device from
YTech that looks like it will do the job nicely. It’s a little big Each one of these four points should be investigated
at 4.2 x 1.9 inches, but it’s better than nothing. As of this carefully. Perhaps you’ll find one of them causing the
writing, it’s available for just under $13. I’m sure there are slowdown.
many other solutions out there if this one doesn’t fit the The datasheet for the DS1302 can be found at https://
bill. Just check around on Amazon or eBay. datasheets.maximintegrated.com/en/ds/DS1302.pdf. NV
January/February 2019 9
THE HAM‘S WIRELESS WORKBENCH ■ BY WARD SILVER N0AX
hwardsil@gmail.com

Rotators
How do you turn that thing?
We’ve had a few columns on antennas and propagation,
and there sure is a lot of variation in the types of
antennas! All the different ways signals propagate require different
antenna directions and types. Hams use dinky finger-sized “rubber
ducks” on handheld radios but also some ridiculously big antennas
it seems. Hams can’t use as much power as some of the other
communication services, so they use antennas to get through by
focusing radiated power.
If the antennas can focus a signal, then they need to Yagis or log-periodics for VHF through microwaves. They
be able to focus it in the desired direction, right? A few aren’t sturdy enough to be used with large HF beams
antennas can do that electrically by controlling the signal’s or microwave dishes. They can’t hold antennas with a
phase or switching antenna elements on and off. Most of significant wind load, meaning a large surface area that
the “pointable” ham antennas, though, need to be pointed generates torque on the mast or tower it’s mounted on.
mechanically and held in place during a contact or to keep There are also small portable rotators that work from 12
a communications link working. The thing that hams use VDC.
to point their antennas — large and small — is called a Medium-duty rotators can handle a single mid-sized
rotator. HF Yagi or log-periodic for 14 to 30 MHz. By “mid-sized,”
There are a wide range of rotators, just like antennas. I mean a Yagi with a few elements on a 12 to 18 foot
You may have used a TV antenna rotator with its “chunk- boom weighing 50 pounds or less. A small VHF/UHF Yagi
chunk-chunk” stepping. At the other end of the scale, can be stacked with the HF beam. This is a very common
whole towers turn! We’ll cover some of the most common configuration: a three-element “tribander” (20, 15, and 10
types and give you an idea of how they work. (If you want meters) with a six-meter and two-meter Yagi above it. A
detailed information, including guidelines and illustrations few sections of Rohn 25 tower or an HDBX self-supporting
for how to work with these unsung heroes of the antenna tower (www.rohnnet.com) make for a sturdy antenna
farm, see the sidebar, “Rotator and Tower Know-How.”) system.
These rotators can also handle a set of several VHF/
Rotator Sizes UHF antennas known as a “stack.” If you want them to
point (and hold) a dish antenna up to a meter or so in
TV antenna rotators are just about the smallest version diameter, check the dish wind load to be sure it won’t
used by hams. They are inexpensive and suitable for small overload the rotator. A dish antenna’s main beam is very
narrow — maybe just a few degrees — so a
Rotor or Rotator? rotator has to be both accurate and stable to hold
the dish in place and on target.
Is it "rotator" or "rotor?" Hams are not very precise with slang and The biggest amateur HF Yagis — including
jargon, so both words are used referring to the same thing: A device that stacks of two or three antennas — require a
aims an antenna in a specific direction. Nevertheless, there is a proper much larger rotator. Instead of a solenoid or disc
usage! A "rotator" is a device that causes something to rotate; in this braking system, some of these rotators use a gear
case, a mast with an antenna attached to it. A "rotor" is a part of a device train or worm drive to provide the braking action.
that rotates such as a motor shaft or armature. Be sure the tower and supporting hardware is
If you want to be correct when referring to the gadget that you use
rated to handle the antenna and mast load.
to aim your antenna, call it a rotator. Thank you, I feel better now!
As the rotators increase in capability, they
10 January/February 2019
PRACTICAL TECHNOLOGY FROM THE HAM WORLD
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2019/01.

■ FIGURE 1. The most common methods


of mounting rotators are directly on masts
or inside lattice-style towers. Rotators can
also be mounted directly on the top of
towers (not shown). Mounting the rotator
on the mast (left) exposes the rotator to
bending forces, reducing its maximum
wind load rating. Mount the antenna as
close above the rotator as possible in this
configuration.

What if you have several big antennas that


you want to put on the same tower? If you
need to aim independently, it’s not possible to
use a regular rotator. For the lower antennas,
ring rotators or orbital ring rotators are a
special type of unit installed outside the tower,
attached to its legs. The antenna is carried by
a motorized cradle that moves around the
tower on a circular toothed track that acts
as a drive gear. Some hams simply rotate the
also increase in size. The larger models can be hard or entire tower with the guy wires attached to bearing rings,
impractical to install in lattice type towers like a Rohn 25 or allowing the tower to turn inside them (see Figures 2A and
the smaller self-supporting models (refer to Figure 1). 2B).

■ FIGURE 2B. The tower at Dave NN1N’s station is an example of a rotating


tower. The rings with guy wires attached look like the ring rotators in Figure 2A,
but there are no antennas attached to them. A chain-drive system at the base
turns the whole tower at once.

■ FIGURE 2A. Doug N1LI’s tower has a pair of large single-band Yagis mounted on ring rotators:
one at the very top and one about half-way down the tower. This allows them to be aimed
independently. The top one is aimed to the left and the bottom one to the right. A third two- January/February 2019 11
element Yagi is mounted on a mast turned by a conventional rotator mounted in the tower.
PRACTICAL TECHNOLOGY FROM THE HAM WORLD

There are also rotators that can turn antennas in the brake to impact the sides of the indentations. If your rotator
vertical plane. They are designed for satellite operating doesn’t have a brake delay, practice allowing the antennas
and are called azimuth-elevation or az-el rotators. This to coast to a stop before letting the brake re-engage.
is somewhat complicated mechanically, as you might The largest rotators, including prop-pitch rotators
imagine. Yaesu is the largest commercial vendor of amateur originally used to control the angle of aircraft propeller
az-el rotators, but the SatNOGS group (www.satnogs.com) blades, use the gearing of the motor to hold the mast in
has designed a 3D-printed system for automated telemetry place. Worm gear drives are also designed that don’t allow
reception with lightweight antennas. backward turning under load.

Making Things Turn Rotator Ratings


Small TV antenna rotators have a stepping motor It’s important not to overload a rotator. If you live in
that moves in fixed increments (the chunk-chunk-chunk a location that is prone to high winds, persistent winds, or
noise). For continuous-rotation rotators, the most common large gusts, include a safety factor when selecting a rotator.
motor is a two-phase AC motor with a starting capacitor. Persistent twisting from winds can wear out a rotator’s
The capacitor is switched between phases to control the brake. Rotators are not inexpensive and a failed rotator
direction of rotation. brake can allow an antenna to “freewheel,” damaging the
Because of gear reduction, the motor can be fairly feed line as well.
small and doesn’t draw much current. Large rotators have Table 1 lists manufacturers for rotators and Table 2
bigger motors, but the increase in strength is mostly due to contains the primary specifications for common rotators.
improved gear and brake systems. The power required to
Table 1 - Rotator Manufacturers.
turn even big arrays is not that much.
Rotators are designed to turn a full 360 degrees and Hy-Gain www.hy-gain.com
sometimes a bit more. At the ends of rotation, mechanical Yaesu yaesu.com
limit switches open to remove power from the motor. This AlfaSpid www.alfaradio.ca
prevents feed line damage from being wrapped around the M2 www.m2inc.com
tower.
Channel Master www.channelmaster.com
To accommodate the rotation without stretching
the feed line, leave a rotator loop in your feed line that is TIC www.ticgen.com
equivalent to one full tower circumference or more. Secure
it to the antenna and tower in such a way that it doesn’t Wind Load
get pulled or scuffed when the antenna is repeatedly This is usually specified as a maximum antenna area
turned to either extreme. in square feet. Antenna manufacturers specify the wind
load of their antennas this way, too. For multiple antennas
Making Things Stop Turning on a single mast, add all of their wind load specifications
together. It doesn’t matter if they are all on the same side
Small rotators hold the antenna mast against the wind of the mast or not. A rotator’s wind load rating is often
with a friction disc arrangement. When the rotator turns, given both for the rotator mounted inside a tower and
the discs move apart to let the mast turn freely. When mounted on top of a mast. The rotator can handle a bigger
power is removed, the discs clamp together again. wind load when mounted inside a tower section because
Medium-sized rotator brakes consist of a heavy-duty the tower holds the mast in place straight above the
solenoid and a spring-loaded wedge or bar that fits into rotator. This eliminates any sideways load on the rotating
indentations inside the rotating housing. Braking strength assembly relative to the base.
is determined by how securely the brake is held by the
indentations or — if worm gears are used — by the
resistance to the gears turning backward under load.
Braking Ability and Turning Torque
To turn the rotator, the solenoid is energized, pulling Braking ability is the maximum twisting force the
the brake out of the indentations. Energizing the solenoid is rotator can withstand, primarily caused by the wind.
usually the largest current draw of the rotator. Turning torque is the maximum amount of torque the
When rotation is complete, the solenoid is de- rotator can produce to turn the antennas. Both braking
energized and the brake re-engages the indentations, ability and turning torque are given in inch-pounds.
holding the mast in place. Over time, the indentations or
wedge can wear out, allowing the rotating housing to slip
under heavy loads. Wear is accelerated by de-energizing
Effective Moment and Vertical Load
the solenoid while the mast is still turning, causing the The product of antenna weight and turning radius of
12 January/February 2019
Table 2 – Common Rotator Specifications
Turning Braking Eff
Wind Load Wind Load Torque Ability Moment
Mfr Model (in tower, sq ft) (outside tower, sq ft) (in-lb) (in-lb) (ft-lb) Brake Type Notes
Hy-Gain T2X 20 10 1000 9000 3400 Wedge Heavy-duty
AR-40 3 1.5 350 450 300 Disc Light-duty
CD-45II 8.5 5 600 800 1200 Disc Medium-duty
HAM-IV 15 7.5 800 5000 2800 Wedge Medium-duty
Yaesu G-450A 10.8 5.4 516 2604 Gear reduction Light-duty
G-800DXA 21.5 8 955 3472 Mech and elec Medium-duty
G-2800DXA 32.3 10.8 2170 21700 Mech and elec Heavy-duty
Alfa-Spid RAK1 1400 >14,000 Worm gear Heavy-duty
Channel Master 9521HD 100 Light-duty
(Table courtesy of the American Radio Relay League.)

a maximum antenna system size is used as a spec by the Controlling the Rotator
Hy-Gain company. Heavy and bigger antennas are harder
to turn and to hold in place against the wind, requiring Each rotator family has their own custom control
a higher effective moment rating for the rotator. Many units for energizing the rotator and displaying antenna
rotators also specify a maximum vertical load in pounds or position. There are also after-market control units that
kilograms. operate with any of the common rotators. The most
Wwidely used are the Green Heron controllers (www.
Determining Direction greenheronengineering.com) and the EA4TX interfaces
(ea4tx.com). Both can control most available models of
For local point-to-point connections, a topo
map and compass are usually enough to get your
signals “on target.” For long-distance over-the-
horizon contacts, though, you need to know
about azimuthal-equidistant maps. Such a map
(centered on your location) shows the correct
bearing to any point on the globe (Figure 3).
All the great circle paths from your location
are straight lines heading directly to the edge of
the map. This is the path your signal takes, and it
may be in a direction you’re not expecting. For
example, viewed on a Mercator projection map,
the path from St. Louis to, say, Berlin is almost
straight east. However, the path your signal would
take is about 35 degrees east of north!
Most of the analog meter scales for the
popular Ham-IV and Tailtwister rotators are
north-centered with north at the top and south at
either end of the scale. You can also special-order
south-centered scales or print your own using the
free program, MeterBasic (www.tonnesoftware.
com/meter.html).

n FIGURE 3. An azimuthal-equidistant map


centered on the NØAX station in Missouri. While
my latitude (40 N) is about the same as that of
Spain, the great circle direction to Europe is
between 30 and 60 degrees! Australia and Africa
are almost straight west and east, respectively.
January/February 2019 13
rotators, allowing you to standardize in the shack and on the length of the cable.
customize on the tower. For the popular Ham-IV series, minimum
It’s more common for rotator controllers to have a recommended wire sizes are:
software interface; either RS-232 or USB. The most popular Up to 125 ft: #18 (solenoid), #20 (all others)
protocol is the one used by the Yaesu family of rotators. 125 to 200 ft: #16 (solenoid), #18 (all others)
After-market software control interfaces such as the Easy-
200 to 300 ft: #14 (solenoid), #16 (all others)
Rotor-Control (www.vibroplex.com) or Rotor-EZ (www.
hamsupply.com/rotor-ez-hy-gain-rotor-control) can be Other rotators have similar requirements. I’ve had
installed in the rotator’s controller and connected to your good results from using long runs of 10-conductor
PC. Many of the popular logging software programs will irrigation cable, which is rated for direct burial. The
control a rotator as well. conductors in the cable are #18 AWG (solid), but you can
double-up two pairs of wires to create the heavy wires
Wiring Them Up needed for the brake.

Finally, you have to supply the wiring between the


controller and the rotator. There is also a wireless solution
Wrapping Up the Rotator
provided by Green Heron (see the URL previously Rotators are remarkably reliable, even though they are
mentioned), but you still have to get power to the rotator installed outside and expected to work over a wide range
up on the mast or tower. of conditions with no maintenance. Repair services such
Most rotators require either an unshielded six- or eight- as The Rotor Doctor (rotordoctor.com) or Norm’s Rotator
conductor multi-conductor control cable. Small TV rotators Service (www.rotorservice.com) will rebuild them and may
only need a four-conductor cable similar to a zip cord. have used units available, too.
Solenoid brake circuits need a heavy wire pair, but the rest Often overlooked, the rotator is worth installing
of the circuits are low current. Check the manufacturer’s carefully and being treated with care. After all, your ham
recommendation for minimum wire size, which depends radio success turns on them! NV

PicoScope ®
PC Oscilloscopes

Capture a Wide Range of Signals


and Secure a Better ROI
PicoScope® PC oscilloscopes support a broad selection of test and measurement applications. They not only
offer the ideal mix of speed, resolution, memory depth and software features to help you capture a host of
waveforms, they also deliver outstanding quality and cost-effectiveness. Making it possible to put an entire
high-performance toolbox of instruments in the hands of every engineer for better equipment access, more
functional flexibility and a better ROI than traditionally available. Discover PicoScope today.

THE PICOSCOPE® FAMILY


2000 SERIES - Ultra-compact; 1 GS/s Sample rate; AWG; Available MSOs; Bandwidth to 100 MHz • 3000 SERIES - General-purpose; 1 GS/s Sample rate; + MSOs; AWG; Deep memory: Bandwidth to 200 MHz
4000 SERIES - Resolution to 16-bit; 2, 4 and 8 channels; AWG; Differential-input model • 5000 SERIES - FlexRes® 8- to 16-bit; Sample rates to 1GS/s; Bandwidth to 200 MHz; AWG; MSOs available
6000 SERIES - Bandwidth to 1 GHz; Sample rates to 5 GS/s; AWG; 170,000 Waveforms/s; Memory to 2 GS • 9000 SERIES - Sampling Oscilloscopes to 25 GHz; TDR/TDT available; Optical models

©2019 Pico Technology. All rights reserved. Pico Technology, PicoScope and FlexRes are registered trademarks of Pico Technology. Learn more: www.picotech.com
14 January/February 2019
Pico_PSFam_N&V0119.indd 1 12/10/18 1:40 PM
Jrk G2
Motor Controller
with Feedback

Maestro Servo
Controller

Simple Motor
Controller G2

Tic Stepper
Motor Controller

CO N T R O L I N T E R FAC E S
Analog Rotary
USB TTL serial I2C voltage RC encoder Scripting
Jrk G2 Motor Controllers
with Feedback

Maestro Servo Controllers

Tic Stepper Motor Controllers

Simple Motor Controllers G2

Get your projects moving with motor controllers from Pololu.


Our controllers for RC servos, stepper motors, and brushed DC
motors all include free software, so you can easily configure
your motor's movement based on your selected control input.

Find out more at www.pololu.com


PRODUCTS
■ HARDWARE
■ SOFTWARE

NEW
■ GADGETS
■ TOOLS

RPi VOLTAGE OUTPUT SBC TS-7180 IN


AND DIGITAL ENGINEERING
I/O HAT SAMPLING
M easurement Computing
Corporation announces the
release of the MCC 152 voltage
T echnologic Systems
has announced
that their latest single-
output and digital I/O HAT for board computer — the
Raspberry Pi. Many DAQ users are TS-7180 — is now part
designing systems around the RaspPi of their Engineering
because of its flexibility and low Sampling program which
cost. This growing base of Pi users enables customers to have early For added system integrity, the
is making single-board computers access to Technologic Systems’ TS-7180 comes standard with Cypress
more prevalent in professional DAQ latest innovations, accelerates time 16 kbit FRAM (FM25L16B). FRAM
applications. to market, and provides a channel is a nonvolatile memory employing
for customers to request technical an advanced ferroelectric process
support and design improvements that reads and writes like a RAM and
directly to the engineering team. The retains data like EEPROMs.
program typically lasts for 6 to 12 It provides reliable data retention
months before the product enters into while eliminating the complexities,
production. overhead, and system level reliability
The TS-7180 is developed for problems caused by EEPROM and
any industrial application, but is other nonvolatile memories. Unlike
especially suited for industrial control serial EEPROMs, the FM25L16B
automation and remote monitoring performs write operations at bus
management applications such as speed. No write delays are incurred.
unmanned control room, industrial Data is written to the memory
The MCC 152 features two 0-5V automation, automatic asset array immediately after each byte has
analog outputs with update rates up management, and asset tracking. been transferred to the device. Also,
to 5 kS/s. Eight digital I/O lines are The TS-7180 features the NXP the TS-7180 ships with TS-SILO which
also included and can be configured i.MX 6 UltraLite processor. The i.MX 6 will provide up to 30 seconds of
as input or output on a bit by bit UltraLite is a high performance/ultra reserve power in the event of a power
basis. efficient processor family featuring failure.
Up to eight MCC HATs can Freescale’s advanced implementation The TS-7180 has an impressive
be stacked onto one Raspberry Pi. of the single ARM Cortex®-A7 core. suite of data acquisition and control
With the already available MCC 118 The NXP i.MX 6UL processors offer options allowing users to focus on
eight-channel voltage measurement scalable performance and multimedia analyzing and interpreting data. There
HAT, users can easily configure support, along with low power are 7x digital input/output ports that
multifunction Pi-based solutions with consumption. can sink up to 500 mA or withstand
analog input, output, and digital I/O. The TS-7180 comes standard with up to 30V at the input. The TS-7180
The open source MCC DAQ 512 MB of RAM, with configurations offers 4x channels of ADC (accessible
HAT Library of commands in C/C++ in the family that go up to 1 GB of via Linux kernel) that do not require
and Python allows users to develop RAM. For onboard data storage, any sort of programming to use.
applications on Linux. The library is there is 4 GB eMMC MLC Flash Pulse width modulation (PWM)
available to download from GitHub. that is configurable as 2 GB pSLC has been included for a wide
mode for additional system integrity. variety of applications, ranging from
For more information, contact: A microSD socket is available for measurement and communications
Measurement Computing additional storage, or removable to power control and conversion. The
www.mccdaq.com media requirements. TS-7180 provides three independent
16 January/February 2019
16-bit wide quadrature counters via NEW GENERATION OF
the FPGA, and are accessed through
I2C. The quadrature and edge- VALUE INSTRUMENTS
counter inputs provide access to a
tachometer.
The TS-7180 has a host of
R ohde & Schwarz
now offers a
portfolio of value
standard industrial interfaces to class instruments,
ensure it will fit into any industrial spotlighting five key
application. The TS-7180 has WiFi technologies. The value
(802.11 b/g/n) and Bluetooth instruments portfolio
(4.0BLE) onboard radios standard. features more than
Cellular connectivity is also available 100 products and 300
with either NimbeLink or MultiTech accessories.
modems via the cellular sockets. Rohde &
Digi’s many XBee radios are also Schwarz’s value class
supported. There are two 10/100 oscilloscopes include a logic analyzer, waveforms and more signal details.
Ethernet ports, a RS-485 port, four protocol analyzer, waveform and Designed with class-leading
COM ports (3x RS-232, 1 TTL UART), pattern generator, and voltmeter in signal integrity and responsive ultra-
as well as a SPI, I2C, and CAN bus. the same instrument. Featuring the deep memory, the R&S®RTA4000
USB Host, Device (serial console) power of 10, Rohde & Schwarz’s oscilloscope brings the power of 10
and OTG (via daughter card header) value instrument oscilloscopes to a new level. The R&S®RTA4000
are available. A user programmable include a class exclusive 10-bit is specifically designed to address
button is also standard. analog-to-digital converter (ADC), 10s signal integrity, helping users avoid
Almost all available interfaces of Msamples of memory, and a 10.1 compromising measurement accuracy
are brought out through 40 industrial inch touchscreen offering 1280x800 for an affordable instrument.
grade screw terminals, including four pixel resolution. The technology’s The R&S®RTA4000 also includes
removable terminal blocks for UARTs, 10-bit ADC provides sharp waveforms standard ultra-deep memory, 100
CAN, ADC, and other general- and more signal details, compared to Msamples per channel, or 200
purpose I/O. conventional eight-bit ADCs. Msamples in interleaved mode, and
A quadrature counter, The R&S®RTB2000 oscilloscope’s a fast update rate to overcome any
tachometer, and nine-axis MEMs 10.1 inch capacitive touchscreen challenge. The product’s class-leading
motion tracking device containing allows users to quickly navigate low noise allows users to maximize
a gyroscope, accelerometer, and pop-up menus and adjust scaling by use of the resolution available,
compass, as well as a GPS receiver zooming in or moving a waveform. ultimately revealing signals that may
are optional onboard features. A A memory depth of 10 Msamples be hidden in the noise of other
temperature sensor and real time is available on every channel if all oscilloscopes.
clock (battery backed) are also channels are active, or users can This high-resolution decimation
onboard. benefit from 20 Msamples when allows the R&S®RTA4000 to provide
Power over Ethernet is supported channels are interleaved. up to 16-bit vertical resolution.
via a daughter card and the TS-7180 The R&S®RTB2000 offers 10 Starting at $5,950, this unit also
has an operating voltage supply of times more memory than comparable features a frequency range of
8 VDC to 30 VDC. The TS-7180 oscilloscopes, allowing users to 200 MHz to 1 GHz, outstanding
operates in a broad temperature capture longer signal sequences sensitivity down to 500 µV/div, and
range of -40°C to 85° C. for more analysis results. Starting time-based accuracy of ±0.5 ppm to
For more information, contact: at $1,370, the R&S®RTB2000 ensure accurate measurements over
Technologic Systems oscilloscope features a frequency long time periods.
www.embeddedARM.com range of 70 MHz to 300 MHz. Starting under $3,000, the
Utilizing state-of-the-art ADCs and R&S®FPC1500 spectrum analyzer
low-noise front ends, the oscilloscope has the value and capabilities of a
If you have a new product that is able to precisely measure even the three-in-one instrument: a spectrum
you would like us to run in our smallest vertical resolution. analyzer; vector network analyzer,
New Products section, please The R&S®RTM3000 oscilloscope and a signal generator.
email a short description (300- offers a frequency range of 100 MHz Featuring a frequency range of
500 words) and a photo of your to 1 GHz and is available starting 5 kHz to 1 GHz, the R&S®FPC1500
product to: newproducts@ at $3,560. The oscilloscope’s 10-bit can be upgraded to either a 2 GHz
nutsvolts.com. ADC provides users with sharper Continued on page 50
January/February 2019 17
BUILD IT YOURSELF

BUILD AN INTERNET
DIGITAL CLOCK By Theron Wierenga and Daniel Millisor

It’s time to build this digital clock that connects via Wi-Fi
to the Internet to not only display the usual time, date,
temperature, and humidity, but to also be able to retrieve
things from the Internet like the weather or weather
forecast, and stock market reports as well.
18 January/February 2019
Introduction software would be needed to run them. These have a nice
set of mounting holes in the corners. It also appeared that
I’ve been building digital clocks for longer than I many of them were built to plug into an Arduino Mega
want to admit. My first one was built with over 20 of the 2650 and my thinking was to use an ESP32.
7400 series ICs and the (then) new seven-segment LED I chose instead to use an Adafruit seven inch
displays from Monsanto. My family was really impressed 800x480 display connected to their RA8875 driver board.
— especially when all those zeros rolled around at the Unfortunately, the Adafruit display doesn’t have any
beginning of each hour. Next came a series made with mounting holes, so it will take some extra effort to mount it
dedicated digital clock ICs that scanned the seven-segment in a box. Basically, you have a piece of glass, so you’ll need
displays. This reduced the IC count considerably and to make a frame of some sort to mount it in.
added switching transistors to handle the current. I knew the RA8875 would run off an Arduino and
More recently, I’ve built digital clocks using the Adafruit’s software packages have always worked for me.
Arduino family of microcontrollers and the highly accurate The RA8875 has an SPI interface and the ESP32 has the
(about one minute per year) real time clock ICs like the SPI interface as well, so what could be easier? Famous last
DS3234 and DS3231. These allow for a calendar as well words! I couldn’t get the RA8875 to work with my ESP32.
as the time, and by adding something like the BME280 I purchased my ESP32 from Amazon — their HiLetgo ESP-
you can easily add temperature, humidity, and barometric WROOM-32 ESP32 development board with 2.4 GHz
pressure to an eight-digit seven-segment display. The dual-mode Wi-Fi.
DS3231 is now available on a nice little breakout board I found this ESP32 easy to use. A good ESP32 Arduino
with built-in battery backup and an easy I2C interface. IDE (integrated development environment) installation
Setting the correct time has always been a bit of guide can be found at https://randomnerdtutorials.
an issue. My early approach was the use of switches. com/installing-the-esp32-board-in-arduino-ide-windows-
My latest versions have added an IR receiver, which instructions and there are others that are easy to find
allows you to change the hours or minutes as needed for with Google. After several posts on the Adafruit forum
Daylight Savings Time. A simple pushbutton “clicker” is asking for help using the RA8875 with an ESP32, Adafruit
used with the IR receiver to change the settings. Loss of responded with the message “we’ve never tried the ESP32
power with the backup battery (or a dead one) still means w/RA8875 — ESP32 also has all sorts of weirdness that
reprogramming and uploading the software to the
microcontroller.
When initially programming the starting time
in the DS3231, once the correct time has been
established in the running DS3231, the program is
run again with the set time function commented out.
The battery will now hold the correct time, even if
power is removed.
The advent of the ESP32 Wi-Fi development
boards allows for a further increase in the
sophistication of a digital clock. It doesn’t take much
imagination to envision a digital clock with a large ■ FIGURE 1.
LCD display to not only show the usual time, date, Block diagram of
temperature, and humidity, but to also be able to the digital clock.
retrieve things from the Internet like the weather or
weather forecast and stock market reports as well.
Why the time? With the time retrieved from
the Internet, your clock will always be accurate to
about the second. In addition, you’ll never need to
reset the clock with Daylight Savings Time changes.
Retrieving the time from the Internet will do that for
you.
My design started with looking into the large
seven inch LCD displays with 800x480 pixels.
Between eBay, Amazon, and other dealers, there
are lots of choices. I liked the price of a number on
eBay coming from China but was unsure of just what
January/February 2019 19
■ FIGURE 2. Schematic
of the prototype.

makes it unstable and hard to use.” After digging into the RA8875 software, I found that
Well, I didn’t find the ESP32 hard to use. In an hour or on initialization of the SPI interface, it begins by reading a
two, I had mine installed on the Arduino IDE, and retrieving register and checking the return value. If that value doesn’t
time and weather information over Wi-Fi. match what an Arduino returns, it simply quits. I did open
an issue with the RA8875 library and hopefully Adafruit
■ FIGURE 3.The complete prototype. will address the problem. I also tested a Teensy 3.1 with

20 January/February 2019
the RA8875 and it worked fine.
So, what to do? My display won’t work with
an ESP32. My answer was to put a slave Arduino
Nano between the ESP32 and the RA8875. A bit
of overkill, and a real hassle to form strings on the
ESP32 and then send them to the Arduino Nano
where it needs to parse them and then send the
required commands to the RA8875, but this method
does work.
Figure 1 is a block diagram of the circuit I built.
The Arduino Nano does most of the work. It drives
the LCD display and reads the DS3231 real time
clock as well as the BME280 for temperature and
humidity.

Construction
I used point-to-point wiring on a 3.75 x 2.25
inch prototype board. It fit everything quite nicely. I
used a four-pin header to connect the small BME280
breakout board via an eight inch jumper. This keeps
■ FIGURE 4. Prototype board with components.
the temperature and humidity sensor away from the
heat generated by the prototype board.
A pair of six-pin headers with jumper cables
connects the prototype board to the RA8875. A
nine volt/one amp wall wart type power supply was
used which connects to the board through a mating
jack. The nine volt power supply is delivering about
200 milliamps to the board.
The usual 7805 five volt regulator supplies five
volts to all five small boards: the Arduino Nano;
ESP32; DS3231; BME280; and the RA8875 with its
LCD display. A small 1 x 1.25 inch heatsink on the
7805 works well. It’s warm to the touch, but not so
hot that you can’t keep your fingers on it (which is
my seat-of-the-pants measurement for judging the
size of a heatsink). The complete schematic is shown
in Figure 2.

Software
The heart of this project is the software, given
that the hardware is mostly a set of breakout boards
that are simply connected together. ■ FIGURE 5. RA8875 board.
There are several specific libraries that will need
to be added into your Arduino libraries folder. Check the acting as the slave; and another for the ESP32 which only
various #include statements to identify these libraries in the is used to connect to the Internet and retrieve the time and
programs provided in the download area for this article. outside weather, then pass it on to the Nano. The BME280
These libraries were found online in various locations and board collects the inside temperature and humidity.
Googling the name will lead you to their sources. The The ESP32 software accesses two servers over the
specific locations can change with time. If you need help Internet: pool.ntp.org (Network Time Protocol) to get
with installing libraries, go to https://www.arduino.cc/en/ the current time; and openweathermap.org to obtain
Guide/Libraries. weather information. (See www.ntppool.org/en for more
Two programs were written: one for the Arduino Nano information.)
January/February 2019 21
second whenever polled. The free openweathermap.
org server can be polled once a second, but be advised
the service only updates the weather information
once in less than two hours. It appears this time varies.
My software polled these two servers once every 10
seconds. This was done for testing, and polling once
every 10 minutes is adequate.
The flowchart of the ESP32 software in Figure 7
outlines the basic operations. The program first connects
to the Internet via Wi-Fi. Your local Wi-Fi SSID name and
password must be inserted into the program, so it will
connect to your specific Wi-Fi. If the Wi-Fi signal is lost
■ FIGURE 6.The LCD output.
for any reason, the program will detect this and then
attempt to reconnect.
Using pool.ntp.org is pretty straightforward. You’ll After connecting to Wi-Fi, the program simply reads
need to sign up for access to the openweathermap.org the time and weather data from the servers and then sends
server. Both of these are free services and both sites supply the information in two separate strings out the Serial2 port
information on how to use their service. to the Arduino Nano. The blue LED on pin 2 of the ESP32
The NTP server will give you the current time to the will light when Wi-Fi is connected and go out if Wi-Fi is lost.
The green LED (mounted separately on the board)
will go on for one second when the Serial2 port
sends its strings. After the green LED is turned off,
the program delays for nine seconds and then loops.
When connecting to the pool.ntp.org server,
your offset in seconds from GMT (Greenwich Mean
Time) is specified along with the Daylight Savings
Time offset in seconds. For the weather, there are
different ways to specify what weather location you
wish the openweathermap.org server to report.
I choose using a zip code and specifying
imperial measurement, which then reports the
temperature in Fahrenheit. You can refer to the
software in the download area for more details.
The ESP32 software has been tested on the
ESP-WROOM-32 development board and the
AZDelivery ESP32 Nodemcu CP2102 module
WLAN Wi-Fi development board — both available
on Amazon. It was also tested on the original ESP32
DevKitC board. Only the HiLetgo board has the blue
LED tied to pin 2.
Figure 8 illustrates the flowchart of the Arduino
Nano software. It not only receives the data strings
■ FIGURE 7. from the ESP32, but it also hosts a DS3231 real time
Flowchart of the clock circuit and a BME280 temperature/humidity/
ESP32 software.
pressure circuit along with the RA8875 board to
drive the LCD.
While the DS3231 circuit keeps the time quite
accurately, it is reset once every 10 seconds to
maintain its accuracy and to automatically adjust
to Daylight Savings Time. How often we reset the
time and update the weather is determined by the
program running on the ESP32.
The Nano resets things whenever it receives
a string from the ESP32. The BME280 operates
22 January/February 2019
Post comments on this article and find any associated files and/or
downloads at www.nutsvolts.com/magazine/issue/2019/01.

Parts List
• Adafruit RA8875 and seven inch 800x480
pixel LCD display
• HiLetgo ESP-WROOM-32 ESP32 ESP-32S
development board ■ FIGURE 8. Flowchart of the
• Arduino Nano Arduino Nano software.
• DS3231 breakout board with battery
• BME280 breakout board
• Header pins
• Header jumpers
• 5.5 x 2.1 mm jack
• Nine volt/one amp wall wart type power
supply
• LM7805 five volt regulator
• Heatsink for LM7805
• Green LED
• 100 ohm resistor
• 3.75 x 2.25 inch prototype board
• Wire, solder, screw, nuts

independently and gives the temperature and


humidity at a location close to the circuit board, i.e.,
the inside temperature and humidity. The outside
temperature, humidity, and conditions are obtained
from the Internet when a weather string is received
by the Nano from the ESP32.
I wanted the time to be displayed in large
numbers that could be seen across a room. The
Adafruit software library for the RA8875 is quite
limited when it comes to outputting text, so I wrote
my own function to draw large 80x160 pixel seven-
segment numbers.
One needs to remember that each time a
number is drawn, you need to clear the area
underneath it or else the drawings pile on top of
each other. I felt the text output was difficult to read
at any distance even with the larger fonts on the RA8875. time and date using rtc.adjust(DateTime(year, month, day,
I thickened the font after drawing it once by drawing it hour, minute, second)). Once the DS3231 is running with
again with a location one pixel over and down from the the correct time, I then comment out this line and compile
first location. A filled circle in deep yellow for a.m. and dark and upload the program again. The battery on the DS3231
gray for p.m. separates the hours, minutes, and seconds. board will now keep the clock running when power is
While I like the I2C interface on the DS3231 board, the removed, and when the program restarts, it won’t set the
RTClib (real time clock library) that uses this interface has time but simply continue reading it from the DS3231. Both
a feature I don’t like. It’s set up to only produce a 24 hour programs are available in the download material.
clock. Most digital clocks use the 12 hour mode, so you
need to check for a zero hour and hours larger than 12 I enjoyed putting this digital clock together. Now, all I
and adjust the hour accordingly. need to do is to design a “proper” box to mount it in. Stay
The DS3231 registers do allow for both 12 and 24 tuned for details on that. NV
hour clocks. In addition, the RTClib does not write to the
day of the week register in the DS3231; instead it uses its
own algorithm to calculate the day of the week.
I prep the time in the DS3231 by setting the current
January/February 2019 23
BUILD IT YOURSELF

BUILD THE LASER PENCIL


ENGRAVER By David Goodsell

■ FIGURE 1. Examples of fun messages you can engrave on No.2 pencils and popsicle sticks.

■ FIGURE 2:The complete laser pencil engraver system built on my wife’s old breadboard.

THE FINAL RESULT rest of this article. The only problem right now is that all
the grandkids want their own customized pencils. Not just
An hour later and two clicks of the mouse launched yellow ones, but all kinds of screwy colored pencils. I think
my latest brainstorm. I ordered a 1/2 watt blue engraving I opened Pandora’s box.
laser and two galvanometers from China. (Free shipping! Figure 2 shows the layout of the completed laser
Such a deal!) engraving system with a keyboard to enter the characters.
Figure 1 shows the final result which I’ll describe in the Just for fun, I decided to build the project in breadboard
24 January/February 2019
Several months ago, an idea popped into my head for a
fun project. I wondered if I could burn some characters
into the yellow paint of a No. 2 pencil with one of those
powerful diode lasers available on eBay. Perhaps it could
be my name or my grandkid’s names, or even a happy
birthday message to my lovely wife.

form, instead of
packing it in a
big aluminum
enclosure.
Coincidentally, my
wife had recently
replaced her old
cutting board in
the kitchen with a
new one.
So, I grabbed
the “retired”
one and the
rest is history. A
breadboard on
a breadboard.
(Pretty silly I know,
but I thought it
was clever at the
time.)
Figure 3 is a
more detailed view ■ FIGURE 3:The laser engraver with all its components labeled. Note the exhaust fan on the left.
of the board, with
labels on the major parts. Be sure to check it out, so you’ll desired specs are listed in Downloads 1 as well.
know which components I’ll be referring to. The galvo system came complete with the two
galvanometers, two driver boards, a ±15V power supply,
and all the connecting cables.
THE MAIN COMPONENTS In my opinion, the best way to start this project is to
The two main components are the 1/2 watt blue laser buy the laser and galvos, and fire them up on the bench
and two galvanometers (galvos) that steer the beam, as before doing any permanent mounting.
seen in the close-up shot in Figure 4. Figure 5 graphically For safety, you can substitute a red laser pointer in
illustrates the laser path and Figure 6 shows how a 5x7 place of the more powerful (and not eye-safe) burning laser
character is formed. to test the galvos.
The laser briefly pauses at each dot for about 100 ms Note that all the tapped holes and mounting hardware
and burns a tiny spot. The mirrors then quickly move the of the laser, galvos, and X axis stage are metric. Be sure to
beam to the XY coordinates of the next dot, etc. use the correct metric screws to mount them.
Both the main components were available on eBay
when I wrote this article, so hopefully they’ll still be there
when you read this. HOW I CHECKED OUT THE
The links to them are in the file marked “Downloads LASER
1” with the rest of the article extras. If they aren’t available,
there are numerous other similar units that will work. The The laser finally arrived from China after four weeks.
January/February 2019 25
laser driver board. This would allow you to pulse the
laser on and off. Terminal #1 of the button should be
connected to an external +5V source and terminal
#2 to a 1K resistor to ground. Also hook Terminal #2
to the TTL/PWM wire on the driver board. DO NOT
let the TTL/PWM wire float because the laser may
suddenly turn on. A SPDT button would be suitable
too, with no resistor required.
I used a block of wood at a distance of 8” as
a target. With the button in my hand, I put on the
goggles and pushed it. NOTHING HAPPENED!
What the heck!? On, off, on, off, nothing! What’s
that smell??? Something was definitely burning, but it
wasn’t the wood. I then saw the problem.
I had inadvertently left a small piece of blue
painter’s tape on the front of the laser, which I had
purposely placed there to keep dust off the lens until
I was ready to use it. The tape had a tiny burn spot
right in the center.
Believe it or not, I have built and operated lasers
for over 40 years and thought I knew what I was
doing. After all, it’s not rocket surgery!
Next, I tried some pencils at 8” away, and the
■ FIGURE 4:The 1/2 watt blue laser bounces off the X and Y galvo smoke came forth. A half second burned a nice spot;
steering mirrors and travels six inches to the pencil. two seconds was too much. Success!
The laser had a focusing ring on the front,
so I screwed it in and out until the burnt spot on
the wood was the smallest.
The little focusing ring was hard to grab,
so I added a larger ring that was easier to turn,
as seen in Figure 4. I suggest not using plastic
materials as targets because the smoke may not
be healthy.

HOW TO BE SAFE
WITH LASERS
Notice back in Figures 2 and 3 that the
optical path to the pencil is completely covered,
so there is no chance the beam will “get loose”
and hit someone’s eye.
The laser emits a 1/2 watt of blue light
which will instantly burn a spot on your retina
if you view the direct beam. Reflections from
■ FIGURE 5:You can use a low power red laser pointer to test the galvos shiny surfaces can also be a problem if they are
before mounting them. mirror-like.
I have a pair of goggles that I use, but just
I hooked up +12 volts to the Vcc of the power connector to be safe, I always use a 3x5 card or piece of wood as a
and +5V to the TTL/PWM input of the laser driver board target to indirectly view the beam.
(mounted vertically on the left side of Figure 4) in the One time when I was working on a high-energy
manner described next; +5V = laser on, 0V = off. chemical laser, the beam “got loose” after a mirror
CAUTION: I would suggest connecting an on/off fractured from the intense heat.
button to the TTL/PWM connector wire coming from the The uncontrolled beam almost burned its way through
26 January/February 2019
an exterior wall made of plaster board and corrugated
metal before we hit the red button. Whew!

GALVO CHECKOUT
Figure 5 shows how the galvos are positioned so they
steer the beam in the X and Y axes. The shaft/mirror of
the galvo is designed to rotate mechanically about ±15
degrees, which translates to an optical beam motion of ±30
degrees. A torsion spring inside returns the shaft to center.
There were a gaggle of cables that came with the galvos
but absolutely NO instructions on how to hook them up.
Luckily, the driver board connectors were keyed.
The three-pin signal input connector had a tiny little +
and – marked on the board and the power connector had
±15V. Get out your magnifying glass!
First off, the galvos MUST be powered up to make
the mirrors move to their “center” positions. For initial ■ FIGURE 6:The characters are formed using a 5x7 matrix.
testing, the signal inputs should be shorted or have zero Adding custom characters is a cinch.
volts on them. Refer to Figure 7 for the schematic. The
DACs (digital-to-analog
converters) are not needed ■ FIGURE 7:The schematic includes serial DACs to drive the galvos. An Arduino Mega 2560 is
for these tests. the master controller.
I set up a red laser
pointer so it was 1” from
the lower galvo mirror; a
piece of white cardboard
was 6” away from the
upper galvo mirror. I then
applied a small voltage
(+1.0 VDC) to each of
the galvo inputs and
noted which way the
beam moved. You want
it to go in the +X and +Y
directions.
Simply reverse (rotate)
the three-pin connectors
on the ends of the input
signal cables to reverse the
direction of movement.
In this project, the
serial DACs put out 0 to
+5 volts, so the galvos only
move in one quadrant to
form the letters; to the
right and up.
I measured the motion
of the red laser spot on the
screen and it was about
2° (optical) for a 1.0 volt
input. That equates to only
needing 0.6 volts from the
DACs to write a 0.15” high
January/February 2019 27
drawings of the optical components on the
breadboard because there are just too many ways
to mount them. The only dimensions I suggest you
keep in mind are: 1” between the laser and the
center of the lower galvo mirror; and 6” from the
upper galvo mirror to the pencil.
Try to keep the optical path generally parallel
with the plane of the breadboard by mounting the
components at right angles to each other and their
bases parallel to the breadboard. I chose to put the
laser and mirrors inside an aluminum box for eye
protection/safety reasons.
A piece of thin plastic forms a window to keep
dust off the optics. Any clear plastic will work,
although check that it doesn’t absorb too much
energy and melt.

MOUNTING THE
PENCIL
■ FIGURE 8:The six-sided pencil is held in place on the shelf by a Here’s a place where innovation could be
small piece of double-sided tape. Don’t laugh, it works! applied. The real problem is that most No.2 pencils
have six sides, and when they are in the right
character on a pencil 6” away. Good. rotation for burning, the bottom of the pencil is resting on
BTW, unless you are a servo guru, DO NOT try to a peak, not a flat. I chose the easy way out: double-sided
adjust any of the pots on the galvo driver boards because tape!
you could destabilize the galvo PID loops. Notice that the I made a simple aluminum angle shelf for the pencil
pots are locked with a dab of glue and are only meant to and put a thin strip of double-sided tape on the BACK
be factory adjusted. WALL of the shelf. Refer to Figure 8.
To mount a new pencil, I hold it down against the shelf
while pressing it against the sticky tape in the rear. (Hey, it
DESIGNING THE OPTICAL works!) I can burn at least a couple dozen pencils before
PATH changing the tape.
Of course, there are tons of other ways to mount the
I decided not to present any detailed mechanical pencil, like using a small three-jawed chuck.
My friend, Wayne suggested including an indexed
■ FIGURE 9:The control panel includes four pots to adjust rotation capability, so the pencil could be rotated exactly
the character burn-time, size, spacing, and vertical location.

28 January/February 2019
60 degrees. This way, all six ITEM QTY DESCRIPTION DIGI-KEY (unless noted)
faces could have a different
C1,C3 2 Capacitor, 10 µF, 20V 478-1840
message.
C2,C4 2 Capacitor, 0.1 µF, 50V 478-7340-2-ND

CRITICAL: R2
R13
1
1
Resistor, 1K, 1/4W
Resistor, 2K, 1/4W
1QBK-ND
2KQBK-ND
ALIGNING R1,R3,R5,R7,R20,R21 6 Resistor, 4.7K, 1/4W 4.7KQBK-ND
THE PENCIL R9-R12,R14-R19,R22-R25 14 Resistor, 10K, 1/4W 10KQBK-ND
SHELF R4,R6,R8 3 Resistor, 47K, 1/4W 47KQBK-ND
R26-R29 4 Potentiometer, 10K, 1/8” Shaft 392JB103-ND
This is important! The Q1-Q5 5 Transistor, NPN, 2N3904 2N3904PS
pencil shelf must be absolutely
U1,U2 2 DAC, 10-bit, SPI/VREF, 8-pin DIP MCP4811-E/P
parallel to the movement
of the stage, or the burned KNOB 4 Knob, for 1/8” Shaft 679-3543-ND
characters will “walk off” the MCU1 1 Microcontroller, Arduino Mega 2560 1050-1018-ND
pencil. The way I did this was KB1 1 Keyboard, Mini, PS-2 (see Note below) Amazon Adesso EasyTouch110B
to mount the X axis stage unit
J1 1 Receptacle, PS-2, 6-pin CP-2860-ND
on the breadboard such that
the centerline of the leadscrew J2 1 Receptacle, Power, 3-pin, 115 VAC Jameco 147901
was perfectly parallel with USB CABLE 1 USB Programming Cable, Modified See text and figure
the breadboard base. I then LED1 1 LED, Red 516-1335-ND
clamped a 12” precision ruler
F1 1 Fan, 40x40x20 mm square, 12 VDC Jameco 2233166
to the pencil shelf.
Finally, I carefully adjusted STG1 1 Stage, 4 inch travel, w/Stepper Motor SainSmart 101-80-124
the rotation of the shelf in the BRD4 1 Stepper Motor Driver Board SainSmart 101-60-194
vertical slots of the stage (see PS1 1 Power Supply, 5V@6A, 12V@4A 102-2525-ND
Figure 8 again) until each end LCD1 1 LCD Display, 4x20,Serial In Seetron BPP-420L or 420VY
of the ruler was exactly the
FUSE 1 Fuse, 3/4A, 3AG F2507-ND
same height from the base,
±0.010”. You’re done! FH1 1 Fuse Holder 283-2711-ND
SW1 1 Switch, Toggle, SPST, Power Jameco 76241

OTHER STUFF SW2,SW12,SW13 3 Switch, Micro, Safety and Limit Jameco 188867
SW3-SW8 6 Switch, Mini Button, SPST Jameco 26623
The electronics are pretty
standard; refer back to Figure SW9-SW11 3 Switch, Mini Toggle, SPDT Jameco 2258486
7. SainSmart sells both the X BP1 1 Beeper, 5V Jameco 138713
axis stage and a stepper motor LAS1, BRD3 1 Laser, Blue, 405 nm with Driver Board eBay
driver board to move it. I
GALVO SYS 1 XY Galvo System, includes: eBay
chose a 4” stage because 4” of
characters fit nicely on a pencil. G1,G2 (2) Galvanometer with mirror
Limit switches were added BRD1,BRD2 (2) Driver Board, Galvo
to both ends of the stage PS2 (1) Power Supply, ±15V
because I hate to have it bang
GOGG (1) Goggles, Laser, 405 nm
into the ends and stall.
Initially, after burning BREADBOARD 1 Wooden Breadboard, 22”x15” used My wife’s kitchen
several dozen pencils, I added WINDOW 1 Plastic Sheet, thin, 1” sq Found item
a small fan and ducting to carry PENCIL 100 Pencil, No.2, Yellow or Light Color Staples
away the smoke because it
Note: It appears that some full-size USB keyboards with a USB/PS2 adapter are not compatible. The
always seemed to drift directly mini keyboard from Amazon was $19.50 at the time of publication.
toward me. (Cough.) ■ PARTS LIST.
You could add a piece
of tubing and route it out a window if the smoke really Figure 9 shows that the control panel has four pots in
bothers you or someone else in the area. the lower right which are used to adjust the characteristics
January/February 2019 29
of the characters, like size, spacing, vertical position, and my software is not pretty but it works. I have annotated it
— most importantly — the burn time. Different kinds of in many places and hopefully you can follow the general
pencils require different burn times to get a good image. flow. Refer to “Downloads 3” for a listing of the Operation
Too long a time leaves a black mess. Too short and the Menu on the LCD. The menu starts with:
letters are too light. Be ready to burn up quite a few test
pencils at first. DO KEYBOARD ENTRY:
The Arduino Mega 2560 microcontroller board was 1. NEW MESSAGE
ideal for this application because it had SPI to talk to the 2. REPEAT BURN
DACs, serial for the LCD, a PS2 keyboard header file, and 3. CHARACTER ADJUST
enough interrupts to handle the limit switches and some
button inputs. Arduino Unos never seem to have enough You type in your message; it engraves the pencil; and
pins or interrupts. ends with REMOVE PENCIL.
The Arduino IDE (integrated development Not all the ASCII characters are implemented at
environment) version I used was 1.0.6.1 and it included present, but the usual A-Z, 0-9, and punctuation marks are
a keyboard header file that handled PS2 keyboards. It in the CharacterArray. The lower case letters (a-z) can also
seemed that many full-size USB keyboards — even with be typed in, but that part of the CharacterArray is presently
USB/PS2 adapters — did not work with it. (Yes, I’ve read loaded with the coordinates of the upper case letters.
numerous articles about adapting keyboards but there is Result: The pencil will always get burned with upper case.
only so much time.) If you try to type in a character that is not
After trying a bunch of mini and full size AT, PS2, and implemented, the system will not accept it. See
USB keyboards (plus numerous adapters), I ended up “Downloads 4” for instructions on how to add a custom
with a mini PS2 with its own adapter. It worked fine and is character or fill in the remaining special ASCII characters.
included in the Parts List.
CLOSING COMMENTS
SOFTWARE This has been a fun project for me because of my
Loading, editing, or saving the Arduino sketch for this background in lasers. As you can see, there is ample room
project required a modified USB cable that had no +5 volts for changes and innovations, and many custom characters
going through it. You still need the data, clock, and ground to make.
lines. The problem is that the Arduino Mega is powered by Lasers can be hazardous but please don’t let that
a five volt power supply on the breadboard and a standard dispel you. By the time you burn your first pencil, it’ll just
USB cable would also try to power it with five volts from be another tool. Good luck! I welcome comments and
the host computer. other helpful advice — especially regarding software. NV
This situation causes a conflict which must be
eliminated by snipping the +5V wire in the USB
programming cable. Please see the file “Downloads 2” in Post comments on this article and find any associated
the article downloads for a diagram of how to modify a files and/or downloads at www.nutsvolts.com/magazine/
standard USB cable. issue/2019/01.
For those of you who are just starting with Arduinos,
the ArduinoLaserPencilSketch.ino sketch (file) for this
project (also in the article downloads) should be put into
a newly created folder named ArduinoLaserPencilSketch.
This will enable you to open, edit, and save it back to the
folder.
Later on, you may want to edit the sketch and give it a
new name before saving it. When you select “Save As” and
enter the new name, the Arduino IDE will automatically
create a new folder that has exactly the same name as your
newly-named sketch. The IDE will automatically place the
new sketch inside the new IDE-created folder. Simple!
Bottom line: Every Arduino sketch file (.ino) must be
inside a folder with the same name or the Arduino file
system will give you an error.
As you can see in the ArduinoLaserPencilSketch file,
30 January/February 2019
Bench and Builder
USB Add USB to your next project--

Stuff For The


It's easier than you might think!
USB-FIFO USB-UART USB/Microcontroller Boards
RFID Readers Design/Manufacturing Services Available
Absolutely NO driver software development required!

Electronics
www.dlpdesign.com

DEC and VME Equipment WANTED!


Digital Equipment Corp and
Motorola MVME Systems and Parts
Buy - Sell - Trade
Call Keyways 937-847-2300 or email buyer@keyways.com
Hobbyist

setting your ideas into


MOTION
Use Small Mechanical
Components from SDP/SI

START CREATING!

www.sdp-si.com 516-328-3300

Nuts_Volts_Ad_5_24_18 copy.indd 1 5/24/18 11:59 AM

Check out the


Nuts & Volts
Junkbox
on Pages 86-87!
January/February 2019 31
BUILD IT YOURSELF
By Alexander Krylov

BUILD A FUN
STYLOPHONE
I decided to make an electronic musical toy as a
Christmas gift for my young son. I browsed the Web
looking for inspiration and found the stylophone: a
miniature analog stylus-operated keyboard that was
invented in 1967 by Brian Jarvis. I based my own design
on this; in fact, I replaced short keys with long ones,
thus creating a kind of writing pad. Indeed, you can
write characters and even words on this pad, and every
character has its own ‘sound portrait.’

I think my stylophone can be useful for children


beginning to write. It makes the learning process fun and
helps kids better remember each character thanks to the
unique sounds.

The Circuit
The circuit shown in Figure 1 is basically an astable
oscillator built with an IC 555; you can find a description
of how this circuit works if it seems unfamiliar on www. Therefore, if you want to change the frequency, you
electronics-tutorials.com. should change either R or C. When playing a stylophone,
The frequency of the oscillations depends on the you change R2 to change the frequency of the sound. I
values of R1, R2, and C1, and is calculated as: transformed the formula (1) to separate R2:
32 January/February 2019
connect (R2 + R3 +R4), and so on. Thus, the value of R3 is
calculated as:

The range of my device includes 12 notes: from C6


(chosen at will) to C5#/D5b; refer to Table 1. The reason
for this is purely geometrical. I used an available wooden
box (198 x 98 x
31 mm) as the
enclosure for
the device, and
aluminium strips
7 mm wide that I
had on hand. Only
12 keys fit in the
width of my box.
Let’s take R1
= 10 kΩ and C1
= 100 nF, then R2
for the frequency ■ FIGURE 1.The circuit.
of C6 (1046.50
Hz) calculated
with the formula
(2), which is
1,876 ohms (rounded to the whole
number). The values for other
frequencies can be calculated in the
same way; the lower the frequency,
the bigger the value of R2.
Let’s add a series of resistors
(R3, R4, etc.) to R2; then, as
you touch the point ‘Key1’ with
the stylus, it’s (R2 + R3) that is ■ FIGURE 2. Inside view (A).
connected to the circuit. When
you touch the point ‘Key2,’ you

■ TABLE 1.

C#5/Db5 554.37
D5 587.33
D#5/Eb5 622.25
E5 659.25
F5 698.46
F#5/Gb5 739.99
G5 783.99
G#5/Ab5 830.61
A5 880.00
A#5/Bb5 932.33
B5 987.77
C6 1046.50
■ FIGURE 3. Inside view (B).
A complete table can be found
at http://pages.mtu.edu/~suits/
notefreqs.html.
January/February 2019 33
Parts List
IC1 = NE555
R1 = 10 kΩ
R2 = 1876Ω
R3 = 411Ω
R4 = 438Ω
R5 = 456Ω
R6 = 482Ω
R7 = 520Ω
R8 = 546Ω
R9 = 570Ω
R10 = 626Ω
R11 = 650Ω
R12 = 690Ω
R13 = 730Ω
All resistors have a power rating
of 0.125W.
C1 = 100 nF, ceramic
■ FIGURE 4. Outside view (A). C2 = 10 mF x 10V, electrolytic
LS1 = speaker with impedance
of eight ohms
SW1 = miniature toggle slide
switch
B1 = 4 x 1.5V batteries; type AA

check out the one from www.


ohmslawcalculator.com.
Since the values of the resistors
are not standard, it’s necessary to
combine a required value from
standard ones.
However, you might replace
permanent resistors with trimmers
and establish the required values
using an ohmmeter.
■ FIGURE 5. Outside view (B). The circuit is mounted
on a perforated circuit board;
The other values are calculated in the same way and connections are made with flexible wires. I suggest placing
are indicated in the Parts List. If you need to calculate the components on the plate exactly as they are positioned
new values, you can use an online calculator; for example, in the circuit diagram.

■ FIGURE 6. Keys.

34 January/February 2019
Physical
Arrangement
You can see the inside of the
device in Figures 2 and 3; you’re
free to choose you own way to
position the components in the
box. The outside is shown in
Figures 4 and 5.

Keys
I made the keys from an
aluminium strip from a cross
section sized 7x1 mm. A thin layer
of aluminum oxide that is formed ■ FIGURE 7. Attaching the
on the surface of the keys protects wire to the key.
them from further oxidation but
does not prevent electrical contact
between the keys and the stylus.
A key is shown in Figure 6, whereas Figure 7 explains
how to attach wires to the keys. Figure 8 shows how to
attach the keys to the box. It’s important that the lateral
sides of the keys have no chamfers. Otherwise, the stylus
would not move smoothly on the surface. Attaching aluminum keys on the top surface of the box.
Not to scale
1 — Key.
Stylus 2 — Joint between two keys. A layer of varnish should be put on
the lateral sides of the keys to isolate them electrically.
3 — Layer of glue attaching the keys to the surface.
The stylus shown in Figure 9 is made from a ball point 4 — Top surface of the box.
pen that finished its service. The contact that touches
■ FIGURE 8. Attaching the keys to the box.
the keys is, in fact, a pin of an electrical plug. I soldered
a flexible wire to it, put the pin into the pen, and filled
the space around the pin with a
transparent resin. There is one
specific requirement: The end of
the pin should be half round and
have a smooth surface. This is
■ FIGURE 9. Stylus pen.
necessary to avoid scratching the keys.

Instrument and Tools Post comments on this article and find any associated
You’ll need an ohmmeter if you use trimmers to files and/or downloads at www.nutsvolts.com/magazine/
issue/2019/01.
establish required values of R3, R4, etc.; if you wish to get
exact notes, you could use a camertone (tuning fork) to
tune the device. A soldering iron and wire cutters will be
needed to assemble the circuit; a small hacksaw, a drill,
and a file are used to make the keys. However, your choice
of tools depends mostly on the enclosure that you’ll make
for your device; you could 3D-print it as another option.

I hope your “young ones” enjoy this project, no matter


how old they are. NV

YouTube Video at https://youtu.be/wUcqAbQAk5w.


January/February 2019 35
BUILD IT YOURSELF By Dwayne Kincaid WD8OYG

BUILD AN RF FREQUENCY
COUNTER
BUFFER FOR HF

Most frequency
counters can
tolerate only low
levels of RF at
their input, but
here’s a way to
safely measure
the frequency
of an RF signal
of up to 200
watts with
your existing
frequency
counter.

36 January/February 2019
■ FIGURE 1. Block
diagram of frequency
counter buffer.

■ FIGURE 2. Schematic of frequency


counter buffer.

T
his buffer allows you to connect your transceivers. It performs well, is easy to reproduce,
counter to any RF source from 20 mW is low cost, and has a minimal parts count.
to 200 watts, from 200 kHz to 60 MHz. Most amateur HF transceivers are in the 5 to
The circuit has a protection limiter that 200 watt range. This buffer (Figure 2) will allow
keeps the RF signal strength in a safe range for the you to connect your standard desktop frequency
TTL input of the counter, as well as providing gain counter directly to the RF line, even with higher
for weaker signals (Figure 1). signal levels that most frequency counters can
You can think of the buffer as a dam safely handle. For Citizens Band, most transceivers are in
keeping high water out of Frequency Counter- the 4 to 12 watt range and will work fine with the
ville. If the water/signal is too high upstream, buffer.
you can limit how much of it gets through. Or, The low end of the buffer’s power range
if its strength is too low, you can add some. It covers the smallest of transmitters. For instance,
helps with low signals by using the gain of an the FCC (Federal Communications Commission)
inverter and holds back high signals with voltage allows experimenters to transmit up to 100 mW
protection, all on the same printed circuit board in the AM broadcast band, and the new amateur
(PCB). bands at 135 and 472 kHz. The buffer is also an
excellent front-end for an Arduino, PIC, or your
favorite microcontroller for your next HF project.
Purpose
There are many forms of RF buffer circuits
that do some of the same things. This one isn’t How It Works
the fastest, strongest, widest, or prettiest RF buffer The RF input is shown in Figure 3 as
ever made, but it’s right in the sweet spot for HF measured at Test Point 1. It shows a five watt

January/February 2019 37
signal on 14 MHz into a 50 ohm dummy load.
R1 and C1 comprise the sampling section.
R1 samples some of the RF from the signal as
shown in Figure 4. R1 has to dissipate a little of
the power, so at one watt, it’s somewhat bigger
that you may expect. C1 shapes the frequency
response and provides better sensitivity above
20 MHz as shown in Figure 5.
C2 couples the sampling section to the
protection section, and diode D3 provides
protection by limiting negative-going signals
stronger than about -0.5 volts. Diode D2 and D3
provide protection from signals above five volts.
Once the voltage at D2 goes above about five
volts, zener diode D3 will conduct to ground.
These components limit the signal to
■ FIGURE 3. RF input, five watts on 14 MHz.
between 5.0 volts and -0.5 volts as shown in
Figure 6. C3 couples the protected signal to the
input of the inverter chip U1 and Test Point 2;
R2 and R3 bias U1 for the best gain response.
The output of U1 at TP3 is a TTL compatible
signal (Figure 7) ready to go to your frequency
counter. R11 and C22 reduce harmonics to the
timer pin. The total response of the system is
shown in Figure 8.

For the Engineering


Geeks
Here, we’ll take a little deeper look at each
section. You can skip this part if don’t need the
nitty gritty details, but remember it’s here later if
■ FIGURE 4. Sampled RF waveform. you want more information.
R1 samples enough RF to
drive the inverter. The one watt
rating could be increased here to
build a higher-powered buffer, but
the tradeoff would be decreased
sensitivity in the low power range.
C1 provides a roll-off of
frequencies below 14 MHz and
passes frequencies above 25 MHz.
This helps to make sensitivity across
the frequency range more uniform.
AC coupling capacitor C2
blocks any DC on the RF line. This
is important as many newer radios
use DC power on the coax for
antenna control or remote antenna
switching.
The limiting section D1 and

■ FIGURE 5. Frequency response of


RF sampler.
38 January/February 2019
D2 are fast switching diodes. They can switch
up to about 200 MHz — plenty for the 60 MHz
bandwidth we need.
D3 and C4 provide an RF shunt to ground
when D1 conducts. C4 will shunt any RF to
ground during the few milliseconds it takes
to charge to the zener voltage. Once the
breakdown voltage is reached, the diode
will operate stably. Special thanks to Gregg
Neumann VK3GMN for this part of the circuit.
The key thing to note about the D3/C4
circuit is that it will provide protection without
being connected to the +5 volt DC power
supply bus. This approach has two advantages.
First, this circuit still acts as a protection
device for your counter even if the DC power
■ FIGURE 6. Level protection for input of inverter.
is off. Second, any signal over five volts is sent
to ground and helps keep noise off the +5 volt
bus. This also provides protection to keep larger
voltage spikes from entering the power supply
+5 bus. If you’re monitoring an RF line that
goes to an antenna, it gives your counter some
protection from static.
The bias circuit R2/ R3 centers the AC
signal at around 2.5 volts and creates a sensitive
zero-crossing detector at the input stage of the
inverter. The center voltage is the sweet spot
for low-level RF signals to drive the inverter high
or low and gives the best bandwidth response.
With the input of U1 biased, the bandwidth gain
is usable up to 100 MHz, and provides a good
TTL level output for counting.
The DC supply section is straightforward. ■ FIGURE 7.TTL output of buffer.
Again, we use a zener diode to
provide the +5.0 volt regulation at
TP4 to keep the inverter stable. C4,
C5, and C6 help keep the regulator
stable, and provide additional
filtering.

Ready to Count
We’re done! It’s time to go
hook it up and measure some
frequencies. You’ll need a 5-15 volt
DC power supply and a BNC cable
or adapter for the RF connection.
You can use a BNC Tee
connector to attach to your coax
line, or just clip a wire onto the
post of the RF connector you

■ FIGURE 8.Total bandwidth of


60 MHz.
January/February 2019 39
What is a Frequency Counter?
An RF frequency counter is a test equipment item
that can measure the time interval of a signal and display
the answer in Hz, kHz, MHz, or GHz. The range of an RF
frequency counter is usually measured in MHz but can
also be down to kHz and up to the GHz range. For most
amateur HF transmitters, the output frequency is between
1 MHz and 60 MHz, and RF power levels between 5 and
100 watts.
Many DIY frequency counter kits are available that
have a TTL level input such as the EZM 50 MHz frequency
counter. When measuring RF that uses a 50 ohm system,
just a few watts of RF power can overload the front-end of
a TTL input. This article shows the RF power sample of a
five watt transmitter using a 50 ohm load is about 40 volts
peak-to-peak.
The 40 volts would easily damage the TTL input of a
PIC, Arduino, or other counter with a TTL input with a max
of five volts and a min of zero volts. In this case, an RF
buffer would certainly be needed to protect the counter.

transceiver, or that new 2,200 meter transmitter. Happy


counting! NV
■ FIGURE 9. 3D model of printed circuit board.
Post comments on this article and find any associated
want to measure. Transmit some RF into a dummy load or files and/or downloads at www.nutsvolts.com/magazine/
while making a contact on the air. You’ll be able to read issue/2019/01.
the frequency over a wide range of RF power levels while
safely protecting your frequency counter.

■ PARTS LIST
A Fun Club
NAME QTY VALUE VALUE 2 STYLE BRAND MOUSER PART#
Project
If your radio or U1 1 74LVC1G04 SOT-23 TI 595-LVC1G04QDBVRQ1
electronics club has not
done an assembly project in D1,D2 1 BAT46 DO-35 ST Micro 511-BAT46
a while, talk to them about
doing this one. It takes only D3,D4 1 1N4733 Vishay 78-1N4733A
about 15 minutes to assemble
once the iron is hot, and R1 1 47K 1W Yageo 603-FMP100JR-52-47K
another 15 minutes to test
a bunch of them. Have a R2,R3 2 47K .125W Yageo 603-CFR-12JR-5247K
couple of your local Elmers
bring in a frequency counter R4 1 47 .125W Yageo 603-CFR-12JR-52470R
and a signal generator. There
are no adjustments; just plug C1 1 5 pF 500V TDK 810-CC45SL3JD050DYNA
and play!
C2,C3,C4,C6 4 0.01 µF 50V Kemet 80-C316C103M5U
This RF buffer is a handy
tool you’ll remember every C5 1 47 pF 50V Kemet 80-C315C470K5G
time you use a frequency
counter. You can easily make C7 1 100 µF 50V Nichicon 647-UVR1H101MPD
one for every counter you
enlist to measure RF. L1 1 10 µH 2.2A TDK 871-B78108E1103K009
You know you’ll need it
at the most important time L2 1 100 µH 600 mA TDK 871-B78108E1104J009
while testing your six-meter
40 January/February 2019
TS-4900 4GB MLC eMMC flash storage
Computer on Module WiFi and Bluetooth on-board
High speed industry standard
i.MX6 ARM CPU connections
WiFi & Bluetooth
Rugged, Industrial with Fanless
Solo or Quad Core
-40°C to +85°C Range
www.poscope.com 2 GB DDR3 RAM

Board Support Packages,


Source Code and Toolchains
Available
www.embeddedARM.com

- USB - PWM
- Ethernet - Encoders
- Web server - LCD
- Modbus - Analog inputs
- CNC (Mach3/4) - Compact PLC
- IO

- up to 256 - up to 32
microsteps microsteps
- 50 V / 6 A - 30 V / 2.5 A
- USB configuration
- Isolated

PoScope Mega1+
PoScope Mega50

-up to 50MS/s
-resolution up to 12bit
-Lowest power consumption
-Smallest and lightest
-7 in 1: Oscilloscope, FFT, X/Y, Recorder,
Logic Analyzer, Protocol decoder, Signal
generator

January/February 2019 41
The Discovery of
Radio Waves
By George R. Steber
When the concept of electromagnetic waves was first
proposed around 1864, it was met with great skepticism.
As a result, the idea languished for a long time. This is
understandable since the foundations of the theory were
complex and the conceptual ideas were at odds with
physical thinking. It took several decades for a handful
of dedicated persons — infatuated with the mysteries of
electricity and magnetism — to finally put the theory on a
solid footing.
In this article, we’ll take a look back at this period that launched the
serious study of radio waves. We’ll examine the contribution of James Clerk
Maxwell, the man most responsible for the concept. Next, we’ll look at the
work of several notable scientists who came after Maxwell, and see how
they confirmed the existence of radio waves.

W
e have a seemingly unlimited examine what we mean when we talk about
electromagnetic spectrum consisting such waves.
of radio waves, microwaves, visible
light, ultraviolet, x-rays, and gamma rays.
How we came to discover and comprehend
these astonishing waves is a captivating
story. In what follows, we’ll look back at the
historical underpinnings of electromagnetic
waves — and we’ll do so without invoking
theoretical derivations. But first, let’s

Figure 1. Assume that you have a stick with a


certain amount of charge Q. (a) When you hold
the stick stationary, the charge is surrounded by an electric field E but no magnetic field (b). The same charge in
motion creates a magnetic field B as well. If the stick is shaken up and down at frequency f, a small portion of the
field escapes to propagate away as an electromagnetic wave at the same frequency.
42 January/February 2019
Figure 2. Electromagnetic waves are formed
when an oscillating charged particle creates
ripples in its electric field and thereby also
creates a magnetic field. A typical wave is
shown here: an electric field coupled to a
magnetic field. The fields of the wave are
perpendicular to each other and to the
direction of propagation of the wave.

The Strange Path to Maxwell’s


Conceptually, an electromagnetic wave can be
generated as shown in Figure 1. A more comprehensive
Electromagnetic Theory
picture of how electromagnetic waves are formed and their
analogy to gravitational waves can be found at the URL According to many science books, James Clerk
noted in Reference 1. Maxwell (Figure 3) is the person most responsible for
Electromagnetic waves providing the theoretical
consist of both electric and foundation for electromagnetic
magnetic field waves. These waves. What the books don’t
waves oscillate in perpendicular tell you is that at the time of
planes with respect to each other, Maxwell’s death in 1879, his
and are in phase. A simple picture theory — which bolsters so much
of a transverse electromagnetic of our present technological
wave propagating through space world — was not yet on firm
is shown in Figure 2. footing.
The creation of an Science teachers tell us that
electromagnetic wave begins with the basic rules by which light and
an oscillating charged particle, indeed all electromagnetic waves
which creates oscillating electric behave — such as electric fields
and magnetic fields. When and magnetism interactions —

Figure 3. James Clerk Maxwell time electricity, magnetism, and


was a Scottish mathematical light as manifestations of the
physicist, who formulated same phenomenon. He was one
the classical theory of of the most influential scientists of
electromagnetic radiation, the nineteenth century.
bringing together for the first

accelerating — as part of the can be reduced to four elegant


oscillatory motion — the charged particle radiates energy equations. Today, these equations — known as Maxwell’s
creating ripples (or oscillations) in its electric field, and also equations — are found in just about every introductory
produces a magnetic field. engineering and physics textbook. It is little known
Once in motion, the electric and magnetic fields [Reference 2] that Maxwell did not write these equations;
created by the charged particle are self-perpetuating — although, he was mainly responsible for the theory behind
time-dependent changes in one field (electric or magnetic) them.
produce the other. This means that an electric field that Let’s look back at the early development of
oscillates as a function of time will produce a magnetic electromagnetic theory. In later sections, we’ll look at
field, and a magnetic field that changes as a function of events that occurred after Maxwell’s death.
time will produce an electric field. Consequently, both
electric and magnetic fields in an electromagnetic wave
will fluctuate in time, one causing the other to change. Events Leading Up to Maxwell’s
If the charge’s frequency of oscillation is f, then it
produces an electromagnetic wave with frequency f. The
Electromagnetic Theory
wavelength λ of this wave is given by λ = c/f where c is
the speed of light. Electromagnetic waves transport energy Most historians agree that developments related to
through space. This energy can be delivered to charged electromagnetic theory began in 1800 when physicist
particles a large distance away from the source. Alessandro Volta announced the invention of a battery,
January/February 2019 43
REFERENCES
[1] www.tapir.caltech.edu/~teviet/Waves/emfield.
html
experiments, to claim credit for the views at that date.”
[2] James C. Rautio, “The Long Road To Maxwell’s
However, historians do not attach much importance
Equations,” IEEE Spectrum, Dec. 2014.
to this fascinating document and do not regard Faraday as
[3] T.K. Sarkar, et. al, “History Of Wireless,” Wiley IEEE the prime inventor of wave propagation. It was all well and
Press 2006. good to prophesize about such phenomena, but shaping
[4] Bruce J. Hunt, “The Maxwellians,” Cornell University these ideas into a complete theory was far beyond his
2005. mathematical abilities. Nonetheless, Faraday’s dreams,
once planted, were enough to stir the imagination of those
which allowed experimenters to work with a stable supply who followed him.
of direct current. Some years later, the first physical This was the situation that Maxwell found during
evidence of a link between electricity and magnetism was his formative years in the 1850s at the University of
obtained by Hans Christian Oersted by demonstrating that Cambridge in England. In the next section, we’ll set the
the needle of a compass would shift when it was moved foundation for his work in this field.
close to a wire carrying direct current.
Soon thereafter, Andrè-Marie Ampère showed that
a mutual attraction or repulsion occurred between two Maxwell Begins His Scientific Work
parallel current-carrying wires depending on the relative
direction of the currents. Then, around 1831, Michael Maxwell was already an accomplished mathematician
Faraday showed that a magnet could affect electricity when he left Scotland for the University of Cambridge
when he demonstrated that pulling a magnet through a coil in 1850. He studied in Trinity, a college of Cambridge,
of wire would produce a current. under the tutelage of William Hopkins who was known for
These events were pieces in a puzzle that were not turning out mathematical geniuses.
understood in a systematic or complete way. They were After a brief interlude working on pure mathematics,
indeed very perplexing. How could a current-carrying wire his attention turned to physical problems such as electric
reach out and shift a compass needle? And, how could a and magnetic fields, the kinetic theory of gases, the nature
moving magnet cause a current to flow in a wire? of Saturn’s rings, and color vision. In his first attempt at
Certainly, the natural philosophers and scientists electromagnetic theory, Maxwell wrote a paper in 1855
conjectured on the manner in which electric and magnetic called “On Faraday’s Lines Of Force,” showing how the
influences are transmitted through space. Most favored equations that describe incompressible fluid flow could
direct action-at-a-distance. Exploring a different approach, analogously be used to solve problems with constant
the foremost mathematician Karl Frederick Gauss, around electric or magnetic fields.
1855, considered the idea that electric actions propagate Unfortunately, his work was disrupted by many
between the charges with finite velocity. However, he difficulties. He was forced to leave his first teaching
resolved not to publish his research until he could design position at Marischal College in Scotland because of a
a mechanism to achieve that transmission — which didn’t college merger and nearly died from complications of
happen. smallpox. Finally, he ended up as a professor at King’s
Faraday, a scientist-inventor, had also begun to College, London.
challenge the orthodox view that electromagnetic Maxwell’s time at King’s was — by most accounts —
phenomenon were the result of direct action-at-a-distance the most productive of his career. This period of his life
between electrical particles. Instead, he envisioned a would see him produce the world’s first light-fast color
mysterious invisible “electrotonic” state surrounding photograph, develop his ideas on the viscosity of gases,
the magnet — what we would call a field. Changes and propose a system of defining physical quantities — now
in this electrotonic state, he said, are what caused known as dimensional analysis.
electromagnetic phenomenon. Maxwell would often attend lectures at the Royal
It is now known that in a deposition with the Royal Institution, where he regularly came in contact with
Society of London known as “The Original Views,” Faraday Faraday. The relationship between the two men was not
considered the idea that electric and magnetic effects are close; partly because Faraday was 40 years’ Maxwell’s
“progressive and require finite time for their transmission.” senior and showed signs of age. They nevertheless
Faraday did not find time to provide experimental evidence maintained a strong respect for each other’s work.
to support his views and hence wished the deposition, It was at this period in his life that Maxwell made
submitted in 1832, to remain unopened for 100 years. He significant theoretical advances. He examined the nature
stated that “ by depositing this paper in the care of the of both electric and magnetic fields in his two-part paper
Royal Society, to take possession as it were of a certain “On Physical Lines Of Force,” published in 1861. Therein
date; and so have the right, if they are confirmed by he provided a conceptual model for electromagnetic
44 January/February 2019
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2019/01.

induction consisting of tiny spinning cells of magnetic flux. capacitors and inductors had determined their values
Each cell is surrounded by small particles of some form that very precisely. Using these numbers, Maxwell was able to
helped carry spin away from one cell to another. calculate the speed of an electromagnetic wave in space.
Although he eventually discarded this concept, he Amazingly, when he compared his value to the existing
found that this picture helped him describe a variety of values of the speed of light, he concluded from their
electromagnetic phenomena. Perhaps, most importantly, closeness that light must be an electromagnetic wave.
it helped lay the basis of a radical new physical concept
known as displacement current.
Displacement current is a difficult concept since it is Maxwell Predicts Electromagnetic
not really a current. Normal conduction current found in
wires consists of moving charges. Displacement current is a
Waves
way of describing how the change in electric fields passing
through a given area give rise to a magnetic field, just as a In 1864 when he was 33, Maxwell presented a paper
conduction current would do. “Dynamical Theory Of The Electromagnetic Field,” where
An ordinary capacitor holds within it one of the most he theorized that an electromagnetic disturbance travels in
striking examples of displacement current. Consider a free space with the velocity of light. He also conjectured
parallel plate capacitor in an electric circuit with empty that light is a transverse electromagnetic wave even though
space between the plates as shown in Figure 4. If the this fact was somewhat hidden in the set of equations he
capacitor is charging, that causes charge buildup on the proposed. Most importantly, he described how electricity
plates and an increasing electric field Ε between the plates. and magnetism are inexorably linked in a moving
This changing electric field causes a changing magnetic electromagnetic wave.
field B which is related to the so-called displacement When Maxwell introduced his theory at a presentation
current ID = IC. No conduction current actually flows to the Royal Society, the audience was mystified. Maxwell
between the plates. had shown a fundamental shift in his approach. Instead
However, Maxwell’s displacement current is more of building imaginary physical models, he tried to discern
fundamental than this example shows. It can arise in any scientific truth from well established mathematical relations
medium including regions where electrons are available or known as the laws of dynamics.
not. And, just like a conduction current, it gives rise to a To the audience, a difficult physical model would be
magnetic field. bad enough, but a theory based on no model at all was
Maxwell’s new concept provided the necessary bridge beyond their comprehension! Their perplexed state is
to link measureable circuit properties such as permittivity understandable since Maxwell’s paper was long, hard to
and permeability of free space. He somehow realized that grasp quickly, and the mathematics was difficult to follow.
these constants can be combined to determine how fast an It described how various variables interacted and how
electromagnetic wave travels in space. they moved in space and time. More confusingly, it used
Maxwell relied on others whose experiments on the concepts of vectors to represent electric and magnetic
field intensities and flux densities. Few people of the time
understood vectors. For newcomers, it was especially

Figure 4. This is a parallel plate capacitor with empty


space between the plates assumed to be in a charging
circuit. Because of the charging, there is a changing
electric field Ε between the plates, and consequently
a displacement current ID (not shown) producing a
magnetic field B. The displacement current ID has the
same value as the conduction current IC that flows in
the wires due to charge movement.

difficult since each vector came as triple — one equation


for each of the three dimensions.
Maxwell also employed a counter-intuitive variable he
invented known as electromagnetic momentum — known
today as magnetic vector potential — from which he
calculated the electric and magnetic fields.
All told, Maxwell introduced 20 equations involving 20
January/February 2019 45
Figure 5. Oliver Heaviside
was a reclusive mathematical
variables. For those interested genius who spent most of his
in studying all of them in detail, life on the fringe of the science
see Reference 3. Through establishment. In spite of this,
these equations, Maxwell he did more than anyone else
essentially unified the work to shape Maxwell’s theory and
of Oersted, Gauss, Ampère, put Maxwell’s equations into
Faraday, and others while their present form.
adding his own radical concept
of displacement current. Today, one that would bring much-
this theory is the foundation of needed order to the subject, help
our modern understanding of newcomers, and establish a solid
electromagnetism. base for future work.
All of this work was met with In 1873, Maxwell published
extreme skepticism even from his his book “Treatise On Electricity
closest colleagues. Sir William And Magnetism,” where he
Thompson — later Lord Kelvin — expounded further on many of
was one of the loudest skeptics. his ideas. Still in print, it is one
He simply did not believe a of the most renowned books in
displacement current could exist. physics. However, the “field”
Our intuition would agree with concept in the book was alien to
him. physicists and his mathematics
It was one thing to think of a displacement current in a seemed like a backward step in the art.
material filled with atoms. It was quite another to imagine His fields obeyed partial differential equations which
it forming in the emptiness of space! Without a model were far more difficult to handle than current Newtonian
to describe this displacement current — one that works force laws. Without adequate mathematical interpretation,
without moving charges — it was not clear how such a his theory of electromagnetism hung like a museum
current could arise. This whole concept was very repulsive painting on the wall, admired by some but out of reach.
to the scientists of the time. Maxwell died in 1879 at age 48 with Katherine and a
Today, we readily accept radical theories. We friend at his bedside. He was a lone pioneer as was Faraday
accept black holes, gravitational waves, the Higgs field, before him. Almost nobody understood his “Treatise”
quantum entanglement, and other theories that defy during his lifetime. Not until the following generation — led
everyday intuition. We do so as long as the mathematical by a small band of individuals known as the “Maxwellians”
foundations are sound and can be verified to some extent. (Reference 4) — did anyone truly understand what he was
Because of all the complexity surrounding the debut trying to say. Oliver Heaviside was one of these.
of Maxwell’s work, it was not met with enthusiasm. One
could more accurately say that practically no one was
interested! Heaviside Arrives On the Scene
Oliver Heaviside (Figure 5) was once described by a
Maxwell Publishes the “Treatise” friend as a “first rate oddity.” He was actually the forgotten
genius of the Victorian age. He was the youngest of four
Maxwell had put his new electromagnetic theory on sons, born in 1850 to a poor but respectable family in
full public display, but it was ignored by most. It would London. At the age of eight, scarlet fever left him partially
be some time before it would be appreciated. No one, deaf making it hard to play with other boys. Subsequently,
perhaps not even Maxwell, understood the full significance he relied on his own resources and developed a stubborn
of his work. independence that he held to the day he died.
Maxwell had thrived on a full assortment of work He did well at school but was denied a university
during his five years in London, but he still yearned for education because it was beyond the family’s resources.
country life. So, he decided to resign his chair so that he Heaviside taught himself science and mathematics —
and his wife, Katherine could take up a settled life in his old learning from the journals and books of the day.
Glenlair House in Galloway in 1865. Through the influence of his uncle, Charles
The years Maxwell spent at Glenlair were in no sense Wheatstone (of bridge fame), he got his first and only job
a time of retirement. His work on electromagnetism was at the age of 18 as a telegraph operator on the Anglo-
far from finished. He wanted to write a substantial book; Danish cable running from Newcastle to Denmark. In this
46 January/February 2019
Figure 7. Oliver Joseph Lodge
was a British physicist who
studied electromagnetic He had left his telegraphers job
radiation. He made a and returned to his parent’s
particularly strong mark in the home where he began pushing
field of wireless telegraphy. back the frontiers of electrical
In 1894, he perfected the knowledge.
“coherer:” an electrical It was Heaviside working
device used to detect radio at home alone that developed
waves. Lodge’s version of the Maxwell’s equations in their
coherer greatly improved the present form. Plowing through
detection of radio waves. the complicated vector
calculus, he happened upon a
capacity, he had the opportunity way to reformulate Maxwell’s 20
to learn firsthand about the confusing equations into the four
most advanced and scientifically we use today, shown in Figure 6.
interesting branch of electrical Heaviside said the key was
engineering. removing the strange magnetic
Telegraph equipment of the vector potential. According
time used visual cues, so his mild to Heaviside, “I never made
deafness did not play a role. He any progress until I threw all
loved communicating in Morse the potentials overboard.”
code, but fixing faults in the Heaviside’s formulation placed
cable system was what he really the electric and magnetic fields at
enjoyed. Telegraphers, being the forefront.
the elite of the group, were free to experiment with many While Heaviside’s formulation exposed the beautiful
electrical components like bridges and condensers. To be symmetry of Maxwell’s equations, they also exposed a
sure, they had to know these components well to keep the mystery. Electric charges have lines of electric field around
traffic moving. them emanating from the charge. However, the magnetic
Heaviside eventually became the star troubleshooter, field lines — as we know them — have no source and
enjoying each problem and the puzzling effects of appear only in continuous loops, with no start or end.
electricity that often baffled his colleagues. In his free time, Heaviside was troubled by this and added a term to
he continued his studies into electricity and mathematics, the equations to represent magnet charge assuming it had
and even began writing scientific papers. not been discovered yet. In fact, magnetic monopoles still
One day, he came across a copy of Maxwell’s haven’t been found, although they have been predicted by
“Treatise” and was immediately impressed. Although much some particle theories. Yet, the notion of magnetic current,
of the mathematics was far above his head, he became composed of fictitious moving monopoles, persists and is
determined to master it. By this time, Heaviside had sometimes used as an aid in solving some problems.
already decided to devote all his attention to electricity. Heaviside was often asked why we don’t call these

And Magnetism” into the new D and the magnetic field strength H
and more compact form shown — related to Ε and B by constants
here. They have become the that reflect the nature of the
standard that today defines the medium that the fields pass through.
relationship between electricity and The displacement field D was the
magnetism and the wave nature key contribution of Maxwell. The
of electromagnetic radiation. last equation describes how both
Shown here is the differential form changing electric fields and current
of Maxwell’s equations, but other produce magnetic fields.
forms exist such as the integral form. The symbol ∇ is a vector
Here, Ε and B are the electric differential operator, commonly
Figure 6. Around 1884, Oliver and magnetic fields respectively, ρ called Del or nabla that compactly
Heaviside began writing the is the electric charge density, and J expresses the calculus that involves
20 fundamental equations of is the current density. There are two directionality of the three x, y, and z
Maxwell’s “Treatise On Electricity other fields — the displacement field components.
January/February 2019 47
Figure 8. George Francis
Fitzgerald was an Irish professor
of physics at Trinity College in Lodge’s friend George
Dublin, Ireland. He is known for his Francis Fitzgerald (Figure 8),
work in electromagnetic theory a professor of experimental
and for the Lorentz–Fitzgerald philosophy at Trinity College
contraction, which became an in Dublin.
integral part of Einstein’s special It turned out that
theory of relativity. Lodge and Fitzgerald were
captivated by Maxwell’s
equations Heaviside’s equations. work and were trying — with
He said that he believed that mutual support — to carry it
Maxwell — with good reason forward, largely through the
— “would have admitted to the exchange of letters. Fitzgerald
necessity of the changes when was a brilliant theoretician
pointed out to him.” Hence, he felt but a bit lazy when it came to
they should be called Maxwell’s experimental work. However,
equations. he was one of the very few
Refining a mathematical people who read and learned
theory was one thing, but finding the “Treatise” in detail.
experimental evidence to support Lodge, on the other hand,
it was something else. With the was more comfortable using
help of two other Maxwellians and models rather than equations
a little known German researcher, and enjoyed experimental
Heinrich Hertz, the fog began to work. Heaviside’s bond with
lift. them was immediate, and
they began collaborating in the hope of advancing the
understanding of Maxwell’s theory.
Other Maxwellians Arrive On the Lodge and Fitzgerald were particularly interested
Scene in finding experimental evidence to support the idea
that light is an electromagnetic wave. They didn’t have
much success in this endeavor initially. One day, Lodge
Up to 1888, Heaviside was doing the same things: was experimenting with a lightning protection system in
reading journals, writing papers that were seldom read, preparation for a talk to the Society of Arts.
and rarely travelling from his He endeavored to simulate
home. One day, he happened lightning by discharging Leyden
upon a report by Oliver Joseph jars across the wires. Sparks
Lodge (Figure 7), professor of appeared between the ends of
physics at University College the wires. This was expected,
in Liverpool, wherein he was but soon he found that by
mentioned for his work on varying the wire lengths he
Maxwell’s theory. Overjoyed to could make very large sparks
find a kindred spirit, Heaviside or weaker ones. He realized
promptly wrote to Lodge and immediately that he was seeing
found he had another admirer, an electromagnetic wave in
resonance. With enough
Figure 9. Heinrich Hertz was power, he claimed to actually
a brilliant German physicist see the ionized standing wave
and experimentalist who around the wire.
demonstrated that the Lodge planned on
electromagnetic waves reporting his astonishing results
predicted by James Clerk when he returned back from
Maxwell actually exist. In a vacation in the Alps. For
November 1886, Hertz became the trip, he took along some
the first person to transmit and unread journals. While on the
receive controlled radio waves. train leaving from Liverpool, he
48 January/February 2019
Figure 10. Hertz took this photo of his lab.
It shows the coil that he used (left) and the
antenna — a dipole resonator with spark
gap that he used to detect electromagnetic
radiation.

of no sparking. This was evidence of a standing


wave formed by a travelling wave combined with
its reflection from the screen.
Hertz’s findings attracted little attention
in Germany. However, across the channel, the
Maxwellians showered him with praise, welcomed
him into their ranks, and began promoting his
work. Lodge, for example, made a replica of
Hertz’s apparatus which he demonstrated before
the British Association and other groups. Heaviside
was crestfallen to read about similar work in the July issue was so elated, he wrote Hertz thanking him for providing
of Annalen der Physik und Chemie by Heinrich Hertz, the the experimental proof, saying he had given “the death
German researcher. Hertz (Figure 9) had produced and blow” to the action-at-a-distance theories.
detected waves not only along wires, but in free space. Hertz, Lodge, Fitzgerald, and Heaviside became a
More incredibly, he had measured the speed of the close and mutually supportive group. Through the efforts
waves and showed that they could be refracted, reflected, of these four very different persons — joined in a common
and polarized the same as light. Lodge, of course, was cause — they brought Maxwell’s theory out of the shadows
severely disappointed that he was outdone, but this was and into the light.
more than overshadowed later on by the newfound
admiration of the German’s work.
Epilog
Experimental Evidence for Radio The Maxwellians had built up a solid friendship
Waves through their correspondence, and succeeded in revising
and transforming Maxwell’s theory in many ways. They
gave us the equations we currently use today and they
Hertz’s experimental work began in the 1880s at were the ones who gave us the confirming evidence
the Technische Hochschule in Karlsruhe, Germany. At that light is an electromagnetic wave. Most importantly,
this time, there were various electromagnetic theories, they got Maxwell’s theory accepted by the scientific
including Maxwell’s. Hertz was encouraged by his mentor community.
Hermann von Helmholtz, to differentiate the theories. Unfortunately, their heyday lasted for only a few years,
Hertz tried an experiment to detect displacement currents, from 1888 to 1894. Tragically, Hertz died in 1894 from a
but he found nothing. rare bone disease at the early age of 36. We’ll never know
Several years later, in the course of setting up an what other wonderful things he could have accomplished.
experiment for a classroom demonstration, he noticed Fitzgerald also died at the young age of 49. In addition
while discharging a condenser through a loop, that an to his work on Maxwell’s theory, he is remembered today
identical loop some distance away developed arcs. He as one of the proposers of a theory on the relativity of
instantly recognized a resonance condition and suspected space with speed, now known as the Lorentz–Fitzgerald
electromagnetic waves. Now inspired, Hertz began using contraction. This later became a crucial part of Einstein’s
such loops to detect unseen radio waves, and verified most special theory of relativity.
of the properties of electromagnetic waves. A photo of his Lodge lived until 1940 and continued his work in many
lab is shown in Figure 10. fields including radio. In 1894, he perfected a “coherer:” an
In one interesting test, Hertz transmitted radio electrical device to detect radio waves.
waves toward a grid of parallel wires and verified that Heaviside corresponded with other scientists and
they would pass through or be reflected depending on continued publishing until he died in 1926. His other
the angle of the grid. This showed that electromagnetic achievements include using complex numbers to study
waves were transverse waves and oscillating, as light does, electrical circuits, inventing the step function, and
perpendicular to the direction of propagation. In another developing mathematical techniques for solving differential
experiment using a zinc sheet as a reflector, he moved the equations. He is perhaps best known for his prediction that
detector around and found places of sparking and others earth’s atmosphere had an ionized reflective layer capable
January/February 2019 49
Figure 11. Two IEEE Milestone ceremonies
were held in Glenlair House and at
King’s College in 2009 to commemorate
the publication of Maxwell’s equations.
This is one of the plaques that inform
visitors of his unified theory of electricity,
magnetism, and light, summed up in the
equations that bear his name.

and the most fruitful that physics has


experienced since the time of Newton.”
Maxwell’s achievement was honored
by two IEEE Milestone ceremonies in 2009:
one in Glenlair House; and the other at
King’s College. The plaques inform visitors
that between 1860 and 1871, Maxwell
developed his unified theory of electricity,
of bouncing radio signals back to earth, such that the radio magnetism, and light, summarized in the equations that
signals followed earth’s curvature — now known as the bear his name. One of the plaques (engraved with the
Kennelly-Heaviside layer in his honor. famous equations) is shown in Figure 11.
Maxwell’s theory of the electromagnetic field had a Some prescient words from Heaviside seem
momentous effect on science, but theories seldom spring appropriate at this point. “The great gap between Hertzian
from the minds of their creators fully completed. As so waves and waves of light has not yet been bridged, but I do
often happens, the next generation of scientists has to not doubt that it will be done by the discovery of improved
refine and codify it — a process that can take years. So it methods of generating and observing very short waves.”
was with Maxwell’s theory. Very prophetic words indeed!
Albert Einstein once said: “The special theory of
relativity owes its origins to Maxwell’s equations of the In closing, I would like to dedicate this article to my
electromagnetic field. Since Maxwell’s time, physical reality former student and longtime friend, Dr. Steven E. Reyer,
has been thought of as represented by continuous fields, who recently passed away unexpectedly. His presence will
and not capable of any mechanical interpretation. This be truly missed. NV
change in the conception of reality is the most profound

Continued from page 17 capability. It is compatible with iOS, to prevent damage to the instrument
Android, and PCs, and features a low and the device under test (DUT), such
or 3 GHz frequency. In addition to noise floor and high maximum input as overtemperature, overload, and
being able to measure RF signals, it power. short-circuit protection.
is also an RF signal generator and Featuring four channels, the
features a tracking generator and R&S®HMP4040 power supply offers For more information, contact:
independent continuous wave (CW) a maximum voltage of 128V and Rohde & Schwarz
signal generator. maximum current of 40A, up to 10A www.AskAnEngineer.us
The R&S®FPC1500 spectrum output current per channel; 160W of
analyzer includes a one-port vector channel power is available with the REAL TIME STREAMING
network analyzer with Smith chart
display, a signal generator, internal
R&S®HMP4040. This unit offers the
same voltage range on all channels.
FROM DEVICES
voltage standing wave ratio (VSWR)
bridge, independent signal source,
and resolution bandwidth settings
The R&S®HMP4040 comes
standard with a dual USB/LAN
interface and locates all basic
T ektronix, Inc., has announced
the launch of a new Initial State
data streaming and visualization
down to 1 Hz. functions on the front panel to allow service for individuals. The cloud-
The R&S®FPC1500 includes a for direct access. based data service — which includes
10.1 inch Wide XGA (WXGA) display Offering high efficiency and low unlimited data streaming and dynamic
(1366x768 pixel), is Wi-Fi-enabled, residual ripple, the product includes visualizations — is ideal for students,
and includes a remote control a wide variety of protection features individual engineers, technologists,
50 January/February 2019
and electronics hobbyists. dashboards, GPS trackers,
Following a free 14 day manufacturing line data
trial, the service is priced collection, education, and
at $9.99 per month or $99 energy use tracking to name
per year, and is free for a few. Among the platform’s
students. The Initial State more advanced capabilities
data service is well-suited are real time data
for applications that involve transformations that make
real time streaming data it easy to derive meaning
from IoT devices, creating from both historical and real
dashboards to visualize time data without manual
the data, and sending out calculations.
triggers and alerts. It can Real time triggers allow
also be used to capture users to set alarms with
and collaborate on test and SMS and email notifications.
measurement data, with features like installed software. All visualization Using these tools, engineers can build
an interactive multi-row waveform and analysis applications are available hosted data applications using both
viewer accessible through a web through a web browser. historical and incoming real time data.
browser. Initial State uses AWS To improve collaboration, users
Users can share and annotate infrastructure and enterprise-grade can add notes, comments, and
waveforms, providing a better way to best practices for encryption, data, emojis for specified time ranges and
collaborate as compared to sending and access management, and offers then cycle through annotations for
around screen captures. high uptime and full data redundancy. presentations and review.
The cloud-based Initial State The platform incorporates a robust
For more information, contact:
platform provides a highly secure set of tools for a wide range of
centralized repository for time-series applications such as home/office
Tektronix
www.initialstate.com
data and untethers analysis from monitoring, IoT device performance

January/February 2019 51
More Tricks
with

Old-School
Digital Clocks
By Bryant Julstrom

52 January/February 2019
Figure 1. Typical design
of a discrete logic clock.

The Time Base minute to drive the counters that identify the time’s digits.
Crystal frequencies that include larger prime factors
Any crystal frequency can be used in the time base so should be avoided. It’s inconvenient to try to divide by,
long as it can be divided down to provide the frequencies say, 23. Powers of 2 like 4.194304 MHZ are the easiest to
a clock requires. The tools available here include binary divide down. Just use the requisite number of stages in a
ripple counters (sequences of flip-flops) like the CD4020 binary ripple counter.
and CD4060, and decimal and binary counters like the The necessary signals can also be derived from the
CD4510, 74LS90, 74LS161, and many others. 60 Hz line frequency. Assuming a low-voltage transformer
Suppose, for example, that our junk box yields a crystal powers a clock, the transformer’s output is rectified
whose frequency is 3.072 MHz and we desire a 1 Hz separately from the clock’s power supply — but not filtered
signal. The prime factorization of 3,072,000 is 213 x 3 x 53. — and run through a Schmitt trigger; there will be noise on
Rearranging the factors to match various counters, we get the line, and we don’t want extra pulses.
3,072,000 = 211 x 102 x 15. We can generate a 1 Hz signal The trigger can be an inverter in any of several chips,
from the output of an oscillator based on this crystal with, based on a TLC555 or an op-amp, or built from discrete
say, 11 stages of a CD4020 to divide by 211; a CD4518 components. The resulting signal will be divided by 60 to 1
dual BCD up-counter to divide by 10 twice; and a CD4516 Hz and by 60 again to 1/minute.
binary counter with additional logic so that it resets when it An elegant device that divides by 60 is the 74LS57:
reaches a count of 15 rather than 16. an eight-pin DIP integrated circuit that was designed for
These stages can occur in any order, so we can choose use in clocks. (The 74LS56 divides by 50, for clocks in 50
appropriate higher-frequency signals for setting. Dividing Hz systems). Two of these yield a 1/minute signal from
the 1 Hz signal by 60 = 6 x 10 yields one pulse every the line frequency and take up little space on a board. The
January/February 2019 53
Figure 2. A circuit that divides a 60 Hz input down to
1/minute. It divides the input frequency by 15, by 16, and Hz, 4 Hz, 1 Hz, and 1/minute. The first and third counters
then by 15 again. count down from 15; they are reset to ‘1111.’ The middle
counter counts up to 16. In general, external logic
can be used to reset any counter when it reaches a
specified count less than 10 or 16.

Seconds
A useful extension of the design above accepts
an input signal of 1 Hz and displays seconds as well
as minutes and hours. This requires only duplicating
the minutes circuitry to count seconds. In this case,
the colon need not blink, and it might be useful
to be able to set the seconds directly to zero by
resetting the seconds counters. The seconds can be
presented using smaller displays. Figure 3 shows a
CMOS clock with a seconds display.

Technologies
As our discussion suggests, a clock of this
kind may use any of the familiar integrated circuit
Figure 3. A CMOS 12 hour clock with a seconds display. technologies. TTL and its relatives in general require
more current than CMOS, but both work perfectly
74LS57 is, however, very hard to find and so probably not well. If you want to really go back in time, there are RTL
a viable choice. counters that can be used.
Certainly, one can twice divide by 10 and by 6, using,
say, 74LS90s or other BCD counters and two 74LS92s, or
using BCD or binary counters and some additional logic to
Driving Displays
reset two of them when they reach 6 (and 10 if necessary). Directly
Noting that 3600 = 152 x 16, another solution uses two Usually, in circuits like these, each digit (except
binary counters and additional logic to each divide by 15, perhaps the hours 10s) is identified by a counter whose
and a third binary counter to simply divide by 16. BCD output goes to a driver. The driver — for example, a
Figure 2 shows such a circuit using three 74LS193 up/ 74LS47 or CD4511 — has seven outputs that the driver sets
down binary counters with 60 Hz input and outputs of 60 high or low so the seven segments of a display present the
54 January/February 2019
Figure 4. A circuit using a CD40110
counter/driver that counts from 0 through 5
and, upon detecting segment signals unique
to ‘6’, resets to zero.
digit. The CD40110 is a decimal up/
down counter that includes a driver;
its seven outputs drive the segments
of a common-cathode LED display
directly. We can build a clock using
CD40110s, but counts that stop short
of 10 require additional logic that Figure 5. A diagram of the Hewlett-
responds to the segment outputs. Packard 5082-7000 LED display.
For example, the minutes 10s
counter must reset when its count derives from this observation:
reaches 6; a reset signal must Counting downward in positive
respond to segments that appear BCD yields the same sequence of
together in the digit ‘6,’ but not in representations as does counting
any lower-valued digit including ‘0.’ upward in negative BCD.
Similarly, to identify when to roll The appropriate choice here is a
the hours count over from 13 to 1 presettable binary counter that can
(for a 12 hour clock) or from 24 to count down, such as the CD4516
00 (for a 24 hour clock), logic must and the 74LS193. To count up from
respond to inputs to the two hours zero in negative BCD, set such a
digits that uniquely identify 13 or 24, counter to 1111 — the inverted
respectively.
Figure 4 presents a circuit for the minutes 10s digit
using a CD40110. This counter must reset to 0 when its
Introducing the

1(:39-U
count reaches 6. The digit ‘6’ illuminates, among others,
the e, f, and g segments of its display; these are not all on
in any preceding digit. A three-input AND gate identifies
this pattern and raises the reset line to the CD40110; the

0LQL&LUFXLW%RDUG+ROGHU
counter immediately resets to zero. (Alternately, a NOR
gate could detect a unique pattern of low outputs from a
CD40110.)

Negative BCD Displays '(6,*1('


In 1969, Hewlett-Packard introduced the 5082-7000 )25 29(5
display — the company’s first. It is not a seven-segment
display. Each unit contains 28 red LEDs (dots) with 7+(('*(
which to form digits and circuitry to drive the diodes
corresponding to the value represented by a negative &20321(17
%2$5'6
(inverted) BCD input.
That is, in the four inputs that represent a digit, a high
voltage (+5V) represents a 0 bit and a low voltage (0V) Model
represents a 1 bit — the opposite of modern practice. One 220
more LED is a decimal point.
Figure 5 shows the structure and pinout of the 5082-
7000. These and similar displays can occasionally still be Innovative H
Holding
olldi
o din
ngg SSolutions
olutio
ol utiio
ut ons
n
found.
One way to use displays like these in a counter-based 800-759-7535
digital clock is simply to invert each counter output; BCD
outputs become the negative BCD inputs that the driver/
displays expect. A more elegant and economical solution
January/February 2019 55
Figure 6. Inside and outside views of a clock that uses four
HP 5082-7000 displays, whose inputs are negative BCD.
Figure 7. Counting from 0 through 9 in negative
(inverted) BCD.

Similarly, the hours counters must be reset correctly at


13 or 24. Figure 7 presents a circuit appropriate to these
digits; it sets its counter — a CD4516 — to 1111 when it
detects the inverted representation of 10 (0101) and thus
cycles through the inverted representations of 0 through 9.

Switch Debouncing
Clocks of this kind are generally set in one of two
ways. The first sets the minutes and hours individually using
a signal of, say, 4 Hz or so. The second presents the clock’s
counter chain with 60 Hz for fast setting or, again, 4 Hz or
so for slow setting.
In either case, signals from the time base must be
switched. Often, this is done directly with pushbutton
switches. Unfortunately, many such switches bounce on
both make and break, so setting becomes more random
representation of zero — and count down. The outputs of than predictable. Simple debouncers can use flip-flops or
the counter are then directly acceptable to displays like the R/C circuits.
5082-7000. Figure 6 shows inside and outside views of a Switch debouncers can also use the ubiquitous NE555
24 hour clock that uses four of these displays. or one of its relatives. The circuit in Figure 8, for example,
When counters are used in this way, the minutes appears in Timer, Op-Amp & Optoelectronic Circuits &
10s counter, for example, must be reset when its output Projects, by Forrest M. Mims III. The ‘555’s output is high
reaches the inverted representation of 6. The minutes and until the switch is closed, when the output goes low.
hours 1s counters must be reset to 1111 when they reach Should the switch itself bounce on make or break, the
the inverted representation of 10. ‘555’s output still will not.
56 January/February 2019
There are also integrated circuits designed specifically
as switch debouncers. The best known is probably the
MC14490, which contains six independent debouncing
circuits. This IC is eminently simple to use, requiring just
one external capacitor. Connect a switch to an input and
use the corresponding output.
In all these cases, however, signals from the time base
are not directly switched. A debouncing circuit renders
a switch’s output clean, but that output is a high or low
voltage which must then control the disposition of the
signals. The 74LS125 and 74LS126 are described as “quad
buss buffers,” and the CS4066 as a “quad bilateral switch.”
Chips like these can implement switching at the control of
a debouncer’s output.
These ICs all contain four independent SPST switches,
each with a control line. In the 74LS125, for example,
when the control line for a switch is low, its input is
connected to its output. Otherwise, the output is in a high-
impedance state.
Figure 9 shows a circuit in which two debouncers in
an MC14490 and the four sections of a 74LS125 select
one of three signals from the time base — 60 Hz for fast
Figure 8. A switch debouncer using an NE555.
setting; 4 Hz for slow setting; or 1/minute for running — to
be passed to a clock’s chain of counters.

Conclusion Finally, don’t forget to scatter several .1 µF bypass


capacitors from the positive supply to ground in any clock.
These are a few of the many possible variations on the NV
general theme of discrete logic digital clocks. If you have a
few LED displays, counters, drivers, and simple logic, you
can probably build a timepiece. Consult the datasheets of Post comments on this article and find any associated
the ICs you choose to use, breadboard everything first, and files and/or downloads at www.nutsvolts.com/magazine/
have fun. issue/2019/01.

Figure 9. Selecting one of three


inputs using a MC14490 switch
debouncer.

January/February 2019 57
C Preprocessor
Reduces Debug
58
Headaches
January/February 2019
By Jonathan A. Titus

In my experience, few hobbyists or experimenters take


advantage of C preprocessor operations. You’ve probably
seen preprocessor directives such as #include <stdio.h> or
#include “servo.h” among the first lines in programs. However,
they are not part of the C language. When you compile a
program, it first goes through a preprocessor that handles
housekeeping tasks such as including files that operate a
peripheral or that provide a function such as printf.

T
he preprocessor “dictionary” lists many program and replace it with 3.14159.”
directives that help with test and debug tasks, Then, in a C statement such as:
among others. As an added benefit, you may
include debug operations in your programs circ = ONE_PI * dia;
and enable or disable them as you choose.
You no longer need to find and remove code added solely the preprocessor makes the replacement and gives the C
as debug or test tools. (For more information about the compiler the statement that follows, although we don’t see
preprocessor directives, see Resources.) it this way in a listing:
I often put several LEDs on unused MCU
(microcontroller) outputs to indicate that code execution circ = 3.1416 * dia;
reached — or didn’t reach — certain instructions. When the
program finally worked properly, I went through the code Here’s a code snippet that shows how to use the
and removed — or commented-out — all the LED control ONE_PI substitution in practice:
instructions. That’s a pain! Plus, it’s easy to forget where I
put all the LED statements or how I used them. #define ONE_PI 3.1416 / Just a text substitution
float circ; / Circle circumference
float dia = 11; / Circle diameter
Define Substitution Statements int main ()
{
circ = ONE_PI * dia;
I’ll start this tutorial with a simple example of how the print(“Circumference = %f \n” circ);
#define directive works: /Print answer
}
#define alpha beta Remember, the directive performs only a text
substitution.
When you include the directive above at the start of a
program, it causes the preprocessor to substitute the text Debug with the Preprocessor
“beta” whenever it finds the text “alpha” in the program.
Only the compiler sees the substitution; we don’t. Although you may put preprocessor directives
Suppose you define the text “ONE_PI” and its anywhere in your code, I recommend you place them
replacement, the text 3.14159 as shown here: at the program’s start, prior to the main.c code. That
approach makes them easy to find and ensures you have
#define ONE_PI 3.1416 / Just pi defined a text substitution before you try to use it in a
program.
This #define directive does not create a constant nor For the examples that follow, I used a Parallax Propeller
does it create a variable and assign it a value. It simply tells QuickStart board and the Parallax SimpleIDE software for
the preprocessor, “Find every instance of ONE_PI in the C programming. On a breadboard, I connected I/O pin
January/February 2019 59
P16 to a red LED. A high(16) command turns the red LED RED_LED_ON high(16) directive. If you do, the compiler
on and a low(16) turns it off. (Instead of controlling an LED displays an error message because it will find the RED_
with an output pin, you could use a pin’s signal to trigger LED_ON statement in your main program and tell you it
a logic analyzer or an oscilloscope.) The next code snippet never got defined!
shows how I used a directive to define RED_LED_ON I often use preprocessor directives to enable and
as high(16). You could use any similar descriptive name; disable LEDs or I/O pins used for tests as my programs
perhaps DBUG_LED_RED. The preprocessor substitutes evolve. Two directives in my software simplify LED control.
high(16) for every RED_LED_ON here: The statements in Example 1 substitute high(16) for
RED_LED_ON later in my program. On the other, the
#include “simpletools.h” /Parallax C libraries
#define RED_LED_ON high(16) /Definition statements in Example 2 substitute “nothing” for RED_LED_
ON, so the LED control statements have no effect.
int main() /Main program If I have six or seven debug LEDs and perhaps a logic
{
print(“Hello!”); /Print statement analyzer, I can control them individually as needed for
RED_LED_ON; /Turn on red debug LED tests.
}
This program compiled without errors, printed “Hello!” Example 1.
on the SimpleIDE terminal, and turned on the red LED.
That test worked, but now I no longer need to turn the LED #define RED_LED_ON high(16) /For debug purposes
//#define RED_LED_ON /use the red LED
on after the print statement. I can “disable” the LED in one
of three ways:
Example 2.
1. Delete the RED_LED_ON; statements in the main
program. If I need to use it again, I might forget I put it //#define RED_LED_ON high(16) /For final code
#define RED_LED_ON /do not use the red LED
here, though; or
2. Comment out the RED_LED_ON; statement in the You can take another approach that lets the
main program. That way, I remember where I controlled preprocessor enable or disable groups of I/O pins.
the LED; or
3. Remove only the high(16) command from the
#define directive to leave #define RED_LED_ON. Use Conditional Debugging
In the third case, the preprocessor replaces the RED_ The preprocessor can handle conditional directives
LED_ON; statement in my C code with “nothing.” The that are similar to the if-else statements in C. For the
compiler will never “see” RED_LED_ON; thus, it compiles following example, I put a yellow and a green LED on my
the code as if RED_LED_ON doesn’t exist. In other words, breadboard at MCU pins P17 and P18, respectively. I then
you can leave RED_LED_ON; statements in your C code; added the following lines for the preprocessor at the start
they simply become inactive. of a program:
If you must go back and debug again, the RED_LED_
ON; statements remain in your program. You can re-enable #define DBUG /Define DBUG.
#ifdef DBUG /Debug is defined,
them when you restore the preprocessor directive to: #define RED_LED_ON high(16) /so allow use
#define YELLOW_LED_ON high(17) /of the LED
#define RED_LED_ON high(16) #define GREEN_LED_ON high(18) /statements.
#endif /End of if section.

That’s the beauty of using the preprocessor directives The first line defines DBUG, which simply tells the
for debugging. You can leave debug operations in a preprocessor that DBUG now exists. There’s nothing
program and “enable” or “disable” them as needed via special about the name DBUG, and you may substitute
simple changes to the preprocessor directives. You no another name if you wish.
longer must hunt through your code and remove all the Next, the #ifdef directive determines whether the
LED control or other debug functions before you release a preprocessor has defined DBUG. In this example, it
final version of your software. has. So, the #ifdef statement evaluates as true, and the
Of course, you could use a search-and-replacement preprocessor executes the indented directives that define
operation to remove all RED_LED_ON statements, but if high(16) as the replacement text for RED_LED_ON,
you must debug or test a program again, you might not high(17) as the replacement text for YELLOW_LED_ON,
remember where you had the LED control instructions and and so on.
what they indicated when you ran the last tests. The following snippet of code shows how you might
Important: DO NOT comment-out the entire #define use the red and green LEDs:
60 January/February 2019
PRINT_TEST; in the program. When you run the program,
RED_LED_ON; /Red LED on when execution gets here it prints the text “Test Data” followed by the value assigned
while (alpha > beta)
{ to variable XYZ (you must define a data type earlier; in this
do this..; case, an integer for XYZ):
do other things..;
beta++; total = weight * units;
} /Calculate total weight
GREEN_LED_ON; /Green LED on at end of while loop XYZ = total;
/assign total value to XYZ
The red LED should turn on just before the MCU’s PRINT_TEST;
/print test statement
processor reaches the while command.
The green LED will turn on to show
completion of the while loop. If the
green LED doesn’t light, we likely have a
problem in the while loop. We could put
a YELLOW_LED_ON statement within the
loop to help us find incorrect instructions
or variables.
After we fix any bugs and the
program behaves properly, how can we
disable all three LED-on statements? We
don’t need them in the final code. Again,
do not comment-out the #define DBUG
directive. As explained earlier, you’ll get
an error message.
Instead, we add directives that take
effect only when we don’t define DBUG,
as shown in the next code snippet. In
this case, I may now safely comment-
out the first directive: //#define DBUG.
Then, with DBUG not defined, the #ifdef
DBUG directive evaluates as false, so the
second set of directives after the #else
take effect.
The directives in bold in the
following code define the LED control Figure 1. This multiline macro flashes an LED 20 times in a C program.
words, but they assign “nothing” to
each. Now, the preprocessor ignores the corresponding You can enable or disable the PRINT_TEST directive as
statements in the C code: needed.

//#define DBUG /Commented out, don’t

#ifdef DBUG
/define DBUG
/If DEBUG is defined... Write Multiline Macros
#define RED_LED_ON high(16) / continue.
#define YELLOW_LED_ON high(17) Preprocessor macros (several lines of code in a
#define GREEN_LED_ON high(18)
#else /If DBUG is not defined contiguous block) may include complete C functions;
#define RED_LED_ON /substitute “nothing” perhaps to calculate an answer or to control an external
#define YELLOW_LED_ON /for the LED commands device as you test and debug a program. Again, the
#define GREEN_LED_ON
#endif preprocessor replaces the defined text name with the lines
of C code text.
Because the #define operation substitutes one section Why wouldn’t programmers put such tasks in a normal
of text for another prior to compilation of a program, you C function? They might. There’s no reason to create a
may create detailed substitutions such as: macro if library functions will work. Some library functions
— think of printf, for example — consume large quantities of
#define PRINT_TEST print(“Test Data %d \n”, XYZ) memory. You don’t want to include them in an embedded
MCU’s memory just for debugging. Why use printf for
Then, you assign the variable XYZ a value and insert debugging when an MCU includes a basic UART that
January/February 2019 61
might do the job?
Aim for simplicity in your programs and in your test #define MY_TEST \
print(“This is a test! \n”); \
and debug toolbox. Also, you might create macros for print(“Value at this point %d \n”, my_value)\
specific tasks and reuse them in other software or keep /No semicolon!
them proprietary. (Frankly, to minimize errors, we want to
modify our application code as little as possible.) Note there’s no semicolon at the end of the second
It’s easy to create one macro and then have the print statement. When you use the two-line macro
preprocessor insert it — or not — as required. If you disable immediately above in an if statement such as:
the macro, it’s still available if you need it at another time.
As an example of a macro, I created one to flash an my_value = 10; /Value for a test run
if (counter == 0) /if counter equals zero,
LED on a Propeller QuickStart board 20 times (Figure 1). MY_TEST; /print my_value on terminal.
Note the use of a semicolon at the end of the macro name
in the main program, and the lack of a semicolon at the The preprocessor substitutes the macro’s text for MY_
end of the macro itself. TEST; so, the if statement looks like this to the compiler:
To use the LED_FLASH macro, just put the statement
LED_FLASH; on a line in your software. The C language my_value = 10;
if (counter == 0)
statements in the while-loop macro flash the LED at pin print(“This is a test!” \n);
P16 20 times. print(“Value at this point %d \n”, my_value);
The preprocessor replaces LED_FLASH with the C /...here.
code you created. The last brace } in the macro code When counter equals zero, you’ll see only “This is
doesn’t need a semicolon because one exists at the end of a test!” on a terminal. The second print statement never
the LED_FLASH; statement in the main program. executes. Why?
This loop demonstrates how to create a macro, but The semicolon at the end of the first print statement
keep in mind it causes the MCU processor to spend eight terminates the if section of the C code (the semicolon
seconds flashing an LED before it moves on to the next at the end of the second print statement is the same
instruction! Your application might not tolerate such a semicolon that ended the macro name, MY_TEST;).
delay, even when you test it. Take a look at a typical if statement that involves two
CAUTION: When you create a preprocessor C code operations:
macro, you must end each line with a backslash \ followed
immediately by a “newline,” or a “return.” (Press the Enter my_value = 10;
if (counter == 0)
key immediately after you type the backslash.) Do not {
leave whitespace after the backslash! code here..;
The compiler will produce a warning if spaces occur more code here..;
}
between the backslash and a new line. In the Propeller
SimpleIDE, for example, the warning text reads in part: Braces — { and } — enclose a block of code that will
run when counter equals zero. A multiline macro must do
“warning: backslash and newline separated by something similar so all its lines execute properly no matter
space [enabled by default]”
where you have the macro name in a program. Some
Remove any extra spaces and the warning disappears. programmers define multiline macros with a bottom-driven
Use semicolons to end statements in the macro just as you do-while loop such as this:
would in a C program. You may leave spaces between the
semicolon and the backslash, though. #define MY_TEST \
do{\
printf(“This is a test.” \n); \
Construct Macros with Care printf(“Value at this point %d \n”, my_value); \
} while(0)
When you need a multiline macro, you must construct Now, we have the two lines of macro code enclosed
it carefully and consider what happens during the in braces within a do-while loop. Because the second printf
preprocessor’s substitution of the macro text for the macro statement exists within the loop, now you must end it with
name in a C program. a semicolon.
The format might seem complicated at first, but in The while(0) condition lets the macro’s do loop run
practice, you’ll find it easy to implement. Bruce Blinn, only once. When the preprocessor analyzes the statement:
a software developer, explains some of the traps on his
website (see Resources). I’ll briefly describe several. my_value = 10;
if (counter == 0)
The following two-line macro should print a message MY_TEST;
and then an integer value, my_value:
62 January/February 2019
it substitutes the new macro text and yields this Then, MULT(3 + 2, 4 + 2) becomes ((3 + 2) * (4 + 2))
intermediate result, although we don’t see it: and you get the expected answer: 30. Parentheses are your
friends.
my_value = 10;
if (counter == 0)
{
printf(“This is a test.” \n); Get Detailed Debug Data
printf(“Value at this point %d \n”, my_
value);
} The C preprocessor provides predefined macros such
as __FILE__, __LINE__, __DATE__, and __TIME__. Two
underscore characters precede and follow each macro
According to Blinn, the current gcc [gnu compiler name. The FILE and LINE macros come in handy because
collection] version provides another method you can use the former identifies the file in use, and the latter gives you
in place of the do-loop, as shown in the following example. the line number in that file. These two macros provide a
Simply put a parenthesis before the first brace and after helping hand in test and debug steps.
the last. I find this method easy to remember. Test this As an example, the macro that follows displays the
technique with your C compiler: name of the file in use and the line number in the code
where you put this PRINT_OUT macro:
#define MY_TEST \
({ \ #define PRINT_OUT printf(“File: %s at line %d
printf(“This is a test.” \n); \ \n”, __FILE__, __LINE__)
printf(“Value at this point %d \n”, my_value); \
})
Insert the PRINT_OUT; macro in your code and it will
Make Friends with Parentheses give you information such as:

When you use a math operation in a macro, pay File: Blink_Light_1.c at line 36
careful attention to how the preprocessor handles the
expression or you can get odd results. Remember, the Often, you’ll find this type of debug information more
#define directive performs only a text substitution. Here’s a useful than a flashing LED because it identifies a specific
simple math macro that will multiply two values: file and execution at a particular line in a program. NV

#define MULT(x, y) x * y
Post comments on this article and find any associated
files and/or downloads at www.nutsvolts.com/magazine/
What happens when you use the macro this way in a issue/2019/01.
program:

int z = MULT(3 + 2, 4 + 2); Resources


For information about the preprocessor directives and
You expect that z equals 30, from (3 + 2) * (4 + 2) but macros, visit https://en.wikibooks.org/wiki/C_Programming/
instead you get 13. The #define directive doesn’t take into Preprocessor_directives_and_macros.
account math-operation precedence — the order in which For more information about the C preprocessor, visit https://
math operations get done. As a result, the macro MULT en.wikipedia.org/wiki/C_preprocessor.
substitution will look like this to the compiler: For Bruce Blinn’s descriptions of preprocessor macros, visit
http://bruceblinn.com/linuxinfo/DoWhile.html.
int z = 3 + 2 * 4 + 2
The website www.cprogramming.com/tutorial/cpreprocessor.
Multiplication and division take precedence over
html examines how improper arrangement of math operations
addition and subtraction, so the 2 * 4 gets calculated first can lead to unexpected results. It also shows how to avoid them.
to yield 8, and then 3 and 2 get added to the result to give
us 13. For information about C and C++ predefined macros, visit
Information on a programming website recommends https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-
Macros.html#Common-Predefined-Macros and https://
programmers, “...force the arguments themselves to be
gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.
evaluated before the rest of the macro body” (refer again
html#Standard-Predefined-Macros.
to References). You accomplish this task by surrounding
the arguments with parentheses in the macro definition: I recommend, “An Introduction to GCC for the GNU Compilers
gcc and g++,” by Brian Gough, Network Theory Limited, Bristol,
#define MULT(x, y) ((x)*(y)) UK. 2005. ISBN: 9780954161798.
January/February 2019 63
By Bryan Bergeron

DIY Biotech:
Open Source PCR
Thermocycler
In this DIY Biotech article,
we’ll look at an Open Source
Polymerase Chain Reaction
(PCR) Thermocycler kit. In
addition to learning about
DNA amplification, we’ll
cover thermal sensing,
thermal resistance, the
thermoelectric effect, and PID
controllers.
Photo 1. Completed open source PCR thermocycler.

INTRODUCTION directly and need to be amplified before being sent to a


transmitter antenna, headphones, or speaker. Similarly, if
There are many parallels between the processes used there are only a few strands of DNA on an object — say,
in biotech and those used in everyday electronics. Take a partial fingerprint at a crime scene or a bit of tissue
amplification. Electrical signals are often too minute to use recovered from a frozen woolly mammoth — then it’s often
64 January/February 2019
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2019/01.

impossible to fully analyze the DNA without amplifying the denaturing, annealing, and extending sequence is repeated
few strands into several billion strands. dozens of times.
In biotech, this amplification doesn’t rely on tubes or With each iteration, there are twice as many DNA
transistors, but on the polymerase chain reaction (PCR): a strands as before, or 2N strands, where “N” is the number
relatively recent scientific discovery that involves repeated of cycles. For example, after only 12 cycles, there are 212
cycles of heating and cooling for specific periods. or 4,096 strands of DNA. After 20 cycles, there are 220
or 1,048,600 strands, assuming 100% accuracy, which is
THE SCIENCE never actually the case. Even so, we’re talking millions to
billions of copies per PCR run. That’s quite an amplification
Key STEM Concepts factor.
The rate-limiting step is often the hardware used to
• DNA is a double-stranded molecule that contains an rapidly and precisely heat and cool the soup of ingredients.
organism’s unique genetic code. However, even the very simple OpenPCR kit discussed
• In DNA, the nucleotide base Adenine binds with here can run dozens of cycles within a few hours.
Thymine and Cytosine binds with Guanine.
• The PCR is possible because of the heat tolerant Taq THERMOCYCLER DESIGN
polymerase enzyme discovered in E. coli bacteria growing The thermocycle kit reviewed here is fully open source.
in a hot geyser. You can opt to buy the kit from OpenPCR for $499 or
• Thermal cycling — alternative heating and cooling — build it yourself. If you go to the website, you’ll find a
is the basis for PCR. complete bill of materials (BOM) including sources, the
design of the housing panels in SolidWorks 3D, the PCB
PCR and Thermocycling (printed circuit board) in Eagle, as well as the source for the
In addition to thermocycling, the PCR process requires software, including the Arduino Uno software. A copy of
five “wet” components: the BOM is available with this article’s downloads.
An advantage of a truly open source device such
• The most obvious component is the DNA to be as the OpenPCR is that you can selectively upgrade
copied. At least a strand of an organism’s double-stranded components of the kit. For example, I’m considering
Deoxyribonucleic acid (DNA) must be present. substituting aluminum panels for the wooden panels. It
• A soup of the raw materials used to construct DNA would make for a much sturdier device, but at a cost.
— known as DNA nucleotide bases — must be created. Another advantage is increased longevity of the system.
These four bases are (A)denine, (T)hymine, (C)ytosine, and For example, if the Arduino Uno is discontinued and
(G)uanine. In constructing the double helix of DNA, the replaced with a less expensive/higher performance device,
base pairings are A-T and C-G. you have access to the source code to make any necessary
• Primers that bracket the DNA to be copied. These changes.
short pieces of DNA initiate the PCR reaction. The major design elements of the OpenPCR device
• The heat tolerant Taq polymerase builds the are a PID controller, a Peltier thermoelectric effect device,
complementary strings of DNA. thermal sensors, and an overall low thermal resistance
• A chemical buffer that creates the optimum design.
conditions for the Taq polymerase to operate rapidly
and efficiently. The buffer commonly consists of TRIS PID Controller
hydrochloride (HCl), potassium chloride (KCl), and At the heart of the OpenPCR is an Arduino-based
magnesium chloride (MgCl2). Proportional Integral Derivative (PID) controlled ST

Given these five ingredients or components,


the thermocycling process can proceed as shown
in Figure 1. The double-stranded DNA (A) is heated
to the point that it denatures or separates into two
separate strands (B). The temperature is lowered
rapidly in an annealing process that allows the
primers to bind to the separate strands, bracketing
the segments of DNA to be replicated (C). The Figure 1. DNA
amplification
temperature is then raised moderately, enabling Taq process.
polymerase to extend or build the complementary
strands (D) and release them into the soup. The
January/February 2019 65
double pTerm = error; at https://github.com/jperfetto/OpenPCR. For the pid.
double iTerm = iIntegrator + error; cpp file specifically, go to https://github.com/jperfetto/
double dTerm = error - iPreviousError;
double output = (pPIDTuning->kP * pTerm) +
OpenPCR/blob/master/arduino/openpcr/pid.cpp.)
(pPIDTuning->kI * iTerm) + (pPIDTuning->kD * The main components of the code are shown in
dTerm); Listing 1. As you can see, it’s a real PID controller and
not — as is often the case — a P or PD controller. All three
Listing 1. Basic Proportional Integral Derivative (PID) calculation from
the file pid.cpp. terms are calculated and used.
The proportional component of the PID controller
produces an error term that is proportional to
the difference between a set point or desired
temperature and the actual temperature. Purely
proportional controls can result in temperatures
that oscillate about the set point.
The addition of an integral term addresses
the instability of a purely proportional control
scheme by the addition of a term that represents
the sum of the difference between desired and
actual temperature over time.
Even so, a PI controller can result in
temperature instability. The ultimate controller
then adds a derivative component that limits the
second to variation in temperature.

Peltier Thermoelectric Effect Device


The “fun” component in the kit is a
formidable 84W Peltier device which has a
Photo 2. The kit ships in separate modules. maximum current draw of 7.8A. Depending on
whether it’s forward or backward biased, the
VNH3SP30 H-bridge that drives a 25W resistance heater unit can heat or cool the tubes containing the PCR soup.
and an 84W heater/cooler Peltier device. The H-bridge The thermal capabilities of the Peltier device are largely a
is obviously needed, given the current driving capability function of the large Cooler Master Hyper 101i CPU cooler
of a bare Uno is limited to a few milliamps per port. The which has an integrated fan.
source code for the PID controller is freely available in the
file called pid.cpp. (The full source code can be obtained Thermal Sensors
There are two thermal sensors in this kit: one is an
integrated thermistor in the heater strip in the cover
of the device; and one is a 10K thermistor embedded
in the tube holder. (Refer to the BOM available with
the downloads for details.) In general, however, both
thermistors exhibit a decrease in resistance with
increased temperature.
This decrease is measured by the Uno and used to
adjust the PID controller, as well as the LCD display.

Low Thermal Resistance Design


A characteristic of this and any other efficient
thermocycler is low thermal resistance between
the heating and cooling elements and the outside
environment.
For example, the Peltier device doesn’t connect
directly with the Cooler Master CPU cooler identified
earlier, but uses Laird Technologies flexible graphite pads
as well as thermal grease to decrease thermal resistance.
Photo 3. Laser cutouts with tape removed. A lower resistance translates to a quicker response and
66 January/February 2019
potentially shorter cycle times.

THE BUILD
Thanks to a simple design and excellent
build documentation, the kit is suitable for
anyone who can use a screwdriver and hex
wrench. There is no soldering involved. The kit
and the build are modular. As shown in Photo
2, there are six modules including the power
supply. In all, I spent about four hours on the kit.
After reviewing the manual, my first step
was to remove the paper tape from one side
of the laser cut wooden panels (Photo 3).
The cutouts are sharp, well finished, and the
tolerances are tight. Tackling the lid module
next, I laid out the small wooden cutouts,
aluminum plates, and the electronics (Photo 4).
After removing the tape from the small Photo 4. Lid components.

Photo 6. Lid heater/sensor on thermal plate.


Photo 5. Lid panels assembled.

wooden cutouts, I assembled the lid (Photo 5) using


the supplied nuts and bolts. Although not part of the
kit, I used red Loctite on the nuts and bolts.
Next, I attached the Kapton 25W/11.3V heater/
sensor assembly to the aluminum thermal plate
(Photo 6). This heater is intended to heat the tops
of the microcentrifuge tubes. Because the leads to
the heater and sensor are easily mixed up during the
build process, it’s a good idea to mark one of the
pairs now. I dipped the insulation of the heater leads
into red enamel paint to avoid problems later.
If you mix up the leads, you’ll fry the small
thermistor and will have to start over with new
components. Photo 7 shows the assembled lid from
the bottom. The heater/sensor element is just behind

Photo 7. Assembled lid from bottom.


January/February 2019 67
the aluminum plate in the photo.
Next, I opened the tube heater/cooler box and
noted the 85W Peltier device, the aluminum tube
holder, and mounting hardware (Photo 8). Photo 9
shows the Peltier device which makes contact with
the aluminum tube holder on one side and the large
heatsink on the other through thin graphite sheets.
Photo 10 shows the aluminum tube holder along
with a very delicate wire to the thermistor mounted
in the tube holder.
Photo 11 shows the cooling assembly including
the external fan before I mounted the aluminum

Photo 8. Tube heater/cooler parts.

Photo 9. Peltier device.


Photo 11. Cooling assembly for Peltier device.

Photo 10. Tube holder/temperature sensor. Photo 12. Peltier/tube holder stack.
68 January/February 2019
Photo 13. Control and display electronics.

plate to the underside of the unit. Photo 12


shows the underside of the cooling assembly
with the Peltier/tube holder held together by
four screws.
Be careful not to over-tighten these screws
because the aluminum tabs will bend, shifting
the alignment of the stack. In assembling the
stack, I applied thermal grease directly to the
copper and aluminum parts of the heatsink.
With the main heating/cooling hardware
mounted, the next step was to install the control

Photo 15. Controller board.


Photo 14. Peltier assembly and LCD mounted to front panel.

and display electronics. As you can see in Photo 13, the


electronics consist of an Arduino Uno, a custom controller
board to handle the high current heaters, an LCD, and a
flat cable.
I mounted the Peltier assembly and LCD to the front
panel as in Photo 14. Note the orientation of the flat cable
attached to the LCD, with the blue wire corresponding to
pin 1.
Next, I mounted the controller board (Photo 15) and
12 VDC at 14A Micro ATX power supply to the base of the
unit as shown in Photo 16. The only steps remaining were
to mount the lid (Photo 17) and connect the heaters and
thermistors to the custom controller board. I plugged in the
unit, turned on the power, and the LCD displayed a ready
message.

Photo 16. Controller board and power supply mounted in case.


January/February 2019 69
Photo 17. Lid mounted.

Photo 18. Wired unit.


DRY RUN — using the parameters shown in Figure 2. The denaturing
To test the operation of the thermocycler, I set up a temperature is 95°C, annealing temperature is 55°C and
dry run — that is, without test tubes filled with a DNA soup the extending temperature is 72°C.

www.embeddedARM.com
TS-7180
Single Board Computer

696 MHz i.MX6 UltraLite CPU


4GB eMMc Flash
Up to 1GB RAM
WiFi and Bluetooth Enabled
XBee/NimbeLink sockets
SPI, I2C, CAN, RS-485
Nine-Axis MEMs
Gyroscope, Accelerometer and Compass
Industrial Temp Range (-40 °C to 85 °C)
10+ Year Life Cycle

Board Support Packages,


Source Code and Toolchains
Available

70 January/February 2019
Photo 19. Display from dry run.

Photo 20. Buffer mix.


Figure 2. Mac/PC user interface.
Photo 19 shows step 10 of the thermocycler when
the tube temperature is 55.0°C and the lid is 109°C. The create a chemical environment supportive of the PCR
display is updated in real time with the current temperature process.
and step. According to the LCD display, the thermocycler Companies such as Chaibio.com (the supplier of the
tracked the planned temperature and duration within a OpenSource PCR) offer buffers and other components in
degree or two. the form of mixes (see Photo 20). These mixes typically sell
I have no reason to doubt the accuracy of the LCD for upwards of $100 or more, but support over a hundred
readout. However, a full test of the system would require a experiments.
calibrated thermal probe to verify the temperature shown One of the problems with PCR supplies is that they
on the LCD display. The ultimate test, of course, is using must be kept frozen at -20°C; this means overnight
the thermocycler to amplify DNA. There’s no arguing with shipping of expensive biologicals that could be ruined by a
success. single exposure to high ambient temperatures — such as in
the back of a delivery truck.
DISCUSSION Some mixes (such as the one in Photo 20) are
The OpenPCR is a simple thermocycler. Comparable available in partially dry form, extending their longevity
used thermocyclers are available on eBay for about half without need for expensive overnight delivery.
the price of this kit, but these machines are black boxes. Good luck with your DNA experiments! NV
More advanced PCR systems are available. While they
can handle dozens of tubes and provide rapid changes in
temperature and elaborate timing schemes, they can also
cost upwards of $5K and more.
Of course, the hardware is half of the equation. In
addition to protein sequences to amplify, you’ll need to
January/February 2019 71
Vintage Computing
Your Amigo Does
Bluetooth
By Dane Weston
daneweston15@gmail.com

If you’re a Mentor’s Friend (a.k.a.,


Amigo) owner, I hope you and
a young protégé have enjoyed
hours of fun together exploring
introductory programming and
simple computer hardware control.
This article offers a slightly more
advanced Mentor’s Friend project
for you to consider: exploring
Bluetooth using the Amigo
breadboard and Color BASIC serial Figure 1: Bluetooth control of the Amigo retro computer
at your service! Control your Mentor’s Friend from your
interface (Figure 1). Android or iOS device.

K
ey to this project will be taking advantage hacks, hopefully in enough detail to get you started on
of one of those hardware modules (in this another exciting Amigo adventure. I think the finished
case, Bluetooth) designed for the Arduino project is pretty cool, and hope you enjoy it. However,
and other popular microcontrollers. Arduino another goal of this article is to encourage you to launch
projects — especially those built around self- off on your own Arduino-to-Amigo conversion adventure.
contained functional modules — can often be converted If you have a BT module and your controller device
to the Amigo. The Amigo has almost everything you handy, let’s cut right to the chase and establish a Bluetooth
need to leverage these units already baked in: onboard link, then see what we can do with it. (If you don’t have a
switches and LEDs; a breadboard; and a built-in integrated BT module, pick up an HC-05 for your Android or an HM-
development environment (IDE; Color BASIC) with a serial 10 for your iOS device, but beware of cheap clones. You
interface. The main trick for these Arduino project “hacks” may be able to get a clone to work, but it may be at the
with the Amigo is replacing the Arduino sketches with roll- expense of hours of trial and error.)
your-own Color BASIC programs. I tried several combinations of BT modules and apps
In this article, we’ll examine one of these project for this article with both Android and iOS devices, but we
72 January/February 2019
Vintage Computing

As originally discussed back in the December 2015 sample programs. If you already have a Propeller board
issue of Nuts & Volts, the Mentor’s Friend (nicknamed with connectors for a PS/2 keyboard, VGA monitor, and 2
the Amigo) is a direct descendant of the Pocket Mini GB SD card, however, you can “roll your own” Amigo by
Computer (PMC): a project by Jeff Ledger that combined getting the Color BASIC source available with this article’s
the work of several Propeller gurus to offer a series of downloads, updating the I/O pin assignments to match
retro computers running a version of BASIC. When the your hardware, and then loading the compiled Color
PMC was no longer commercially available, Dane Weston BASIC binary to the EEPROM on your board.
developed a simplified replacement in mid-2015 to provide Or, if you are truly ambitious, download the Amigo
a home-built, BASIC-driven mentoring platform for Nuts & schematic (also available with this article’s downloads)
Volts readers. and build out the circuits using your favorite construction
Perhaps the easiest way to build your own Amigo is techniques, then download the Color BASIC source or
from the kit available through the Nuts & Volts webstore binary and Flash it to your EEPROM.
which provides everything you need, including the Regardless of the method you choose, please use the
circuit board, all components (including an EEPROM N&V forums to share your challenges and triumphs, or to
pre-loaded with Color BASIC), and a 2 GB SD card with ask for advice if needed. Good luck!

only have space to discuss my favorite combination as an 40 CLS


exemplar. This is my Android tablet running the ”Bluetooth 45 LOCATE 15,0: PRINT “Amigo EASY TERM”: PRINT “ “
Electronics” app from keuwlsoft (www.keuwl.com), talking 50 PRINT “BAUD = “;x,”RX Pin = “;r,”TX Pin = “;t
to a DSD TECH HC-05 Bluetooth module on the Amigo 55 PRINT “ “
breadboard. 60 COLOR 12,0
If you want to use an iOS device as your controller, be 65 PRINT “TX = GREEN”
sure to use a Bluetooth Low Energy (BLE 4.0) module like 70 COLOR 11,0
the HC-08 or HM-10; iOS devices won’t speak to Classic 75 PRINT “RX = BLUE”
Bluetooth (BT 2.0 or 2.1) modules like the HC-05 or HC- 80 COLOR 63,0
06. An excellent reference on BT modules (and Arduino 85 PRINT “F1 = CLS”: PRINT “ “
interfacing) is at www.martyncurrey.com/bluetooth- 90 a=INKEY
modules. You should glance at it if you have any questions 95 IF a=208 THEN GOTO 35
or issues with your module. 100 COLOR 12,0
We’ll establish our link in five steps: Loading a terminal 105 IF a>0 THEN TX a
program on the Amigo; installing the BT module on the 110 IF a>12 THEN DISPLAY a
breadboard; downloading and configuring the device 115 b=RX
terminal app; pairing the device and BT module; and 120 COLOR 11,0
validating the link. Here are some details on each step, 125 IF b > 12 THEN DISPLAY b
using my “Bluetooth Electronics”/HC-05 exemplar for 130 GOTO 90
reference:
Two items deserve mention. First, adjust Line 15 for
1. Load the Amigo Terminal Program. I wrote a the baud rate of your module. (Some modules default to
little Color BASIC program (EASYTERM.BAS) to send and 38400 instead of 9600.) Second, ignore Line 20 unless
receive characters using the TX and RX commands. In you have a Parallax Prop Plug USB-to-serial device. If you
addition to being able to clear the screen, this program do, you can use it to connect your desktop right into
displays sent and received characters in different colors J5 on your Amigo. The Parallax “Propeller IDE” desktop
and offers reminders of the current baud rate and TX/ application contains a terminal program that works
RX pin assignments. I found all these features helpful in perfectly for this. I used it several times during my initial
troubleshooting various BT links and configurations. Here’s testing and kept the Prop Plug pin assignments in the code
the code, which you can get from the downloads for this for convenience.
article:
2. Install the BT Module. Connect your Bluetooth
10 REM --- EASYTERM.BAS --- module on the left side of the Amigo breadboard, leaving
15 x = 9600 REM <- Baud Rate room for some later wiring on the right side. Your module
20 REM r = 31: t = 30 REM <- Prop Plug RX/TX Pins may have four or six pins (depending on type and
25 r = 6: t = 7 REM <- Breadboard RX/TX Pins manufacturer), so refer to the datasheet if you have it or
30 SERIAL r,t,0,x Martyn Currey’s website if you don’t. Connect module
35 COLOR 63,0 GND to Amigo Gnd; VCC to Amigo 3.3V; TXD to Amigo
January/February 2019 73
Vintage Computing

RXD to TX. (Don’t ask me how I know this, or how many


times it took me to learn the lesson!)
If your module has a status LED, at this point it may
be flashing, indicating that it’s powered up and available
for pairing and connection. Figure 2 shows my HC-05
module on the Amigo breadboard.

3. Download and Configure the Device


App. On your Android device, go to Google Play and
download “Bluetooth Electronics” from keuwlsoft. (If
you’re using an iOS device, I suggest you try “HM-10
Bluetooth Serial Pro” from the app store, and generally
follow the instructions below.) Once installed, open the
app and you will see the controller framework and a pre-
loaded set of control screens shown in Figure 3.
Ignore these for now; you may want to explore them
later for future projects. You may also want to check
the Info section of the app now (the “i” in the upper
left corner of the screen), or just wait until you have a
question.
Scroll the panels section to the right and select
Panel 9, which we will use as our Amigo controller. Press
Edit, then drag and drop these features to the controller
Figure 2: Wiring up the Bluetooth module on the
breadboard. I used an HC-05 for this project, but verified screen:
functionality for HC-06, HM-8, and HM-10 modules. The • Select “Text” on the right side of the screen, then
important thing is to know the default baud rate and PIN drag and drop a text box for your controller title.
(if any) of the module. REMEMBER: The TXD pin of the BT
module goes to the RX pin of the Amigo serial port, and Edit it with the button at the bottom right of the
vice versa! screen. I used “Hola Amigo!” for mine.
• Select “Terminals” and drag and drop a “Monitor
P6; and RXD to Amigo P7. *DOUBLE CHECK* your wiring! 14x48” window to the top right of the Edit
Pin P6 is the seventh hole from the left on the J8 header, window. This feature will display all sent and
and yes, BT module TXD goes to the Amigo RX pin, and received traffic on the Bluetooth serial link.
• Add a couple of “Send” buttons
with canned message strings below
the Monitor window. Note that the
serial TX and RX buffers in Color
BASIC are limited to 15 characters,
so if you try to send or receive
strings longer than that, you’ll get
some weird truncation in your
messages.
Figure 4 shows the Edit screen
with my control panel set up with
these Terminal features. We’ll add
more features to our controller
once we have validated that we can
send and receive characters over
the link. For now, back arrow to the
app main screen and proceed to
the next step.

Figure 3: The start-up screen of keuwlsoft’s “Bluetooth Electronics” App for


4. Pair the Device and
Android, which comes pre-loaded with eight controller panels. We’ll scroll right Module. Now that our little
to panel 9 and build our own Amigo Bluetooth controller panel. terminal is done, tap the “Connect”
74 January/February 2019
Vintage Computing

button on the main screen, select


“Bluetooth Classic,” and press
“Next.” Confirm your module is
powered up and advertising for
pairing (mine flashes the LED
continuously), then press the
“Discover” button.
With any luck, you should see
the assigned name of your device
under Discovered Devices. (Mine
is actually “HC-05,” but sometimes
the names are a bit obscure.)
Highlight your device name
and press “Pair.” Enter the PIN
for your module (mine was 1234,
but 0000 is also common), then
your device name should appear
on the right side of the screen
under Paired Devices. Highlight it
under Paired Devices, then press Figure 4: Configuring the Terminal portion of the Bluetooth Electronics
controller screen. The Monitor window at the top right will show both Send and
“Connect.” Receive traffic, and the buttons below will send scripted messages.
After a brief pause, you should
see a “Connected to: <Your Device
Name>” at the top of the screen,
and the module LED flashing
pattern should change. Now, press
“Done” to return to the main
screen. We’re getting close! Refer
to Figure 5.

5. Validate the Link. Load


and run EASYTERM.BAS on your
Amigo, then enter a few characters
at the keyboard. With any luck, you
should see those characters sent
magically through the ether to your
“Bluetooth Electronics” controller,
and likewise for traffic in the
opposite direction.
If you don’t, first double-check
your module baud rate; remember,
some default to 38400. If your link Figure 5: The Bluetooth Electronics connection
screen is intuitive and easy to use.
still doesn’t work, go back and
check your wiring one more time, verifying that pin 6 We’ll begin by adding two wires to our breadboard, to
(seventh hole from the left) goes to module TXD, and pin 7 connect one LED and one pushbutton to the Propeller I/O
goes to RXD. If still no luck and you typed in the code for pins. As shown in Figure 6, connect P10 to S1 and P12 to
EASYTERM.BAS, double-check your program. D1. We’ll use each of these for different parts of our initial
controller demo.
Hopefully, your Bluetooth link will come up without Let’s start by controlling an LED on the Amigo with our
too many issues. Bluetooth Electronics controller. With the controller panel
Now that we have it established, what can we do with showing in the app, select “Edit,” highlight “Switches” on
it? Let’s start by hacking the standard “control an LED” the right side of the screen, then drag and drop a switch of
Arduino project, then move on to some more advanced your choice to the panel grid.
control features. Now, with the switch highlighted, select Edit in the
January/February 2019 75
Vintage Computing

control string prefix. If it is, program control jumps


to the subroutine at Line 200, which gets the control
character, displays it, then compares it against a list of
control actions to see if any apply.
You can add more controls and actions after Line
220 if you wish (like more switches for the rest of the
Amigo LEDs), but this one action set is all we need for
our proof of concept.
Now, for the moment of truth. Run EASYBLUE.
BAS on your Amigo, then fire up your Bluetooth
Electronics controller and connect to the HC-05. Now,
holding your mouth just right, flick the switch on your
controller and watch LED D1 light on the Amigo. It’s
a bit underwhelming, but it is a success that can add
some spice to your future Amigo adventures.
If the system doesn’t work the first time for you,
verify the ~A and ~a control signals in both terminals,
then double-check your wiring and pin assignments.
Congratulations on your first Arduino project hack
with the Amigo!
Now, let’s do things in reverse, and control an
indicator on the Android device with one of the Amigo
switches. On the Bluetooth Electronics control panel,
select Edit and then drag and drop one of the round
Figure 6: Add two wires (shown in blue) to connect a white “Indicators” to the Edit field grid. We’ll just
pushbutton and an LED to our Bluetooth setup. accept the default control string for the light indicators
— “*LRxxxGxxxBxxx*” — where the xxx following the
bottom right, set Turn On Text to “~A” (without the R, G, and B are the red, green, and blue color levels (0 to
quotes), and set Turn Off Text to “~a” (again, no quotes). 255).
Click “OK” to finish adding the switch to the controller So, using this definition, “*LR0G0B0*” turns the
panel. (BTW, feel free to use a button instead of a switch if indicator off (black); “*LR255G0B0*” is red; and
you wish. Just configure it as instructed above.) Now, bring “*LR255G255B255*” is white. All we need to do to change
up the BT link and flip the switch as a test. The terminals the indicator color is TX the appropriate control string to
on both ends should display ~A when the switch is closed, the BT module, and on to the app.
and ~a when it’s opened. Oh wait! Color BASIC doesn’t have a string
We’re almost there! Now all we need to do is add manipulation capability. We can certainly PRINT these
some code to our Amigo terminal program to recognize control strings to the screen, but how do we send them out
and respond to these on/off commands. the serial interface to the BT module?
Add the following code to EASYTERM.BAS, then SAVE We could hard-code each string separately as shown
the program as EASYBLUE.BAS: below, but this is cumbersome, and there is a better way.
Do it like this only if you don’t need to send many strings
125 IF b > 12 THEN DISPLAY b and they are fairly simple:
128 IF b = “~” THEN GOSUB 200
130 GOTO 90 28 s=0 REM <- State of Switch S1
200 REM —- Process RX Commands —- …
205 b=RX 112 IF (INA [10]<>s) THEN GOSUB 300
210 DISPLAY b …
215 IF b=“A” THEN OUTA[12]=1 300 REM --- Send Indicator Strings ---
220 IF b=“a” THEN OUTA[12]=0 305 GOTO 310+20*s
295 RETURN 310 REM s=0; Send “Switch On” String
312 TX “*”: TX “L”
Like many Color BASIC routines, this added code is 313 DISPLAY 42,76
pretty intuitive. Line 128 examines each received character 314 TX “R”: TX “2”: TX “5”: TX “5”
to see whether it’s a tilde (~), which we are using as a 315 DISPLAY 82,50,53,53
76 January/February 2019
Vintage Computing

316 TX “G”: TX “2”: TX “5”: TX “5”


317 DISPLAY 71,50,53,53
318 TX “B”: TX “2”: TX “5”: TX “5”
319 DISPLAY 66,50,53,53
320 TX “*”
321 DISPLAY 42
324 s=1
325 RETURN
330 REM s=1; Send “Switch Off” String
332 TX “*”: TX “L”
333 DISPLAY 42,76
334 TX “R”: TX “0”
335 DISPLAY 82,48
336 TX “G”: TX “0”
337 DISPLAY 71,48
338 TX “B”: TX “0”
339 DISPLAY 66,48
340 TX “*”
341 DISPLAY 42
342 s=0
345 RETURN

With this brute force method, we TX hard-coded


strings down the serial channel, then repeat the hard
coding with DISPLAY commands to the screen. Suppose
we could PRINT strings to the screen instead, then read
those character-by-character and TX each one over the
serial interface? This should work, since we can use the
BYTE command to read the contents of any given screen
location. Figure 7: Two-way control of your Amigo via Bluetooth!
So, how do we know the screen coordinates of the
characters in our string? Where does the string start and …
where does it end? 300 REM --- Send Indicator Strings ---
It turns out that Color BASIC needs to keep track of 305 m = 2931 - 50*BYTE[25854] - BYTE[25853]
the screen cursor location for a variety of reasons, and 310 if s=0 THEN PRINT “*LR255G255B255*”;: s=1: GOTO
we can grab that information if we know where to look. 320
This means that we can save the starting cursor location, 315 if s=1 THEN PRINT “*LR0G0B0*”;: s=0
PRINT a string (including variables), save the ending cursor 320 n = 2931 - 50*BYTE[25854] - BYTE[25853]
location, and then use BYTE to read each character for TX 325 FOR i = m TO n+1 STEP -1
to send. 330 TX BYTE[i]
For information, the “secret” locations of the cursor 335 NEXT i
coordinates in Color BASIC 2.2L that ships with the Amigo 340 DISPLAY 13
are: 345 RETURN

Cursor X location = BYTE[25853] While there’s no real magic in this snippet, a quick
Cursor Y location = BYTE[25854] review may be in order. Line 28 initializes variable s, which
we’ll use to track the state of button S1 in the Amigo
Let’s use these to add a simple string TX capability Experimenter’s Section. Line 112 compares the “real” state
to our program. Enter the following code, then SAVE it as of S1 against the value of s and jumps to the Send String
EASYBLUE.BAS: routine when they are different (that is, when the button is
first pressed or released).
28 s=0 REM <- State of Switch S1 Line 305 captures the screen memory address of the
… current cursor location, using the Color BASIC “trick” of
112 IF (INA [10]<>s) THEN GOSUB 300 Screen Memory Address = 2931 - 50 * [Screen Column]
January/February 2019 77
Vintage Computing

- [Screen Row], and substituting the Cursor X and Y to avoid any screen wrap issues, and Line 345 returns
locations for Screen Column and Row. Lines 310 and program execution back to the main loop (Figure 7).
315 print the appropriate “Light On” or “Light Off” string, Now when you run EASYBLUE.BAS, you should see
depending on the value of s, and Line 320 captures the the appropriate control strings on both terminals when
ending cursor location. you press or release button S1, and the indicator on your
Lines 325-335 step through a FOR/NEXT loop that Bluetooth Electronics control panel should turn on or off as
sends each character in the printed string down the the button is pressed or released.
serial channel, stopping at the screen location of the last With a little work, you can extend this simple capability
character (n+1). to drive other indicators (like gauges or thermometers),
Line 340 sends a new line to the Amigo screen send text alerts from Color BASIC to your BT controller, or
even parse received control strings
inside Color BASIC. Congratulations
on this addition to your Amigo toolkit!
THE MOST COMPLETE PROGRAMMING TUTORIAL!
• Everything you need to learn to program PIC® micro- That’s a Wrap
controllers is included in this package That completes this brief
• Learn the fundamental concepts of programming, explanation of installing a Bluetooth
including program flow, loops, coding techniques, binary interface on your Amigo. I hope this
project sends you and a young helper
manipulation, device-to-device communication, user
on another technology adventure,
interface design, in-circuit debugging, and more!
and that you’re inspired to see what
• Includes all the necessary the software, compiler, other Arduino projects you can hack
$99.99 trainer board, cable, tutorial with exercises and sample with your Mentor’s Friend. Be well
Academic and bulk pricing available
code! and have fun! NV
Check out our other popular products
for PIC® developers including: Post comments on this article and

PBP3
U2 Programmer find any associated files and/or
PBP3 Compiler downloads at www.nutsvolts.com/
Prototyping Boards magazine/issue/2019/01.
PICBASIC PRO™ Compiler Experimenter Boards
www.melabs.com
Contact us at info@melabs.com

Your Single Source of Electronic Equipment, Tools, and Components

01DM820B 01DMMY64 01DMM9803R Sweep Function Generator


Digital Multimeter Digital Multimeter Bench DMM 3MHz, 6 Waveform Functions, Int/Ext Counter,
Super Economy 32 Ranges True RMS lin/log sweep
DMM - Volts, current, Including temperature, Auto and manual Model FG-30 $135
Resistance, Transistor capacitance, frequency range, RS232C (no display)
and Diode Test. and diode/transistor standard interface. Model FG-32
$7.50 $139.95 $195
Includes Leads testing
$29.95 Runs on DC or AC (5 digit display)

01DS1102E 01SDS1052DL DC Power Supplies


100MHz Rigol Oscilloscope Siglent 50MHz DSO Model HY3003
Variable Output, 0-30VDC,
Features: 1 million points of
deep memory, FFT, record
500MSa/s Sampling
32K Memory 0-3Amp. $95
and replay, roll mode, alternate trigger mode, and 6 Digit Frequency Counter Model HY3003-3
USB Interface Two 0-30VDC, 0-3Amp Variable
adjustable trigger sensitivity
$399 7” Color TFT-LCD Screen $279 Outputs plus 5V 3A fixed. $195

Parallax Board of Education Full Kit BOE Full Kit $98.90 0603ZD98
48W Soldering Station
USB version with Stamp and USB Cable. Parallax 7.5V Power Supply $8.95 Temp. Controlled
$15.25
310oF~840oF

1 (800) 972-2225 | http://www.elexp.com | contact@elexp.com


78 January/February 2019
AN ESP8266 LIVE WI-FI

By Kathiresan Muthiah M.Sc. and Benjamin Robson M.Sc.Ph.D

Having read about the ESP8266 NTP clock in


previous issues of Nuts & Volts, an idea came
to mind to construct an interface camera using
the ESP8266. We succeeded in building a live
webcam using the ESP8266 Wi-Fi webserver, and
would like to share our experience with you!

B
asically, to construct a Wi-Fi live webcam, phones. We didn’t need any OS and driver for the camera
we needed a Wi-Fi server interfaced with a because they’re built inside. The only thing we had to
camera. This kind of server is nothing more find was a way to interface it with the ESP8266 Wi-Fi
than a Wi-Fi server built around an ESP8266. webserver. The details of our approach are discussed
Constructing an ESP8266 Wi-Fi server is not below.
difficult. Just like in the NTP clock design,
we also used the Arduino IDE (integrated Interfacing with the
development environment) for compiling the Wi-Fi server
code we wrote and fused it into the ESP8266. ESP8266 Wi-Fi Webserver
Sometimes it can be very difficult to interface First, we converted the Android Wi-Fi camera server
commercially-available USB cameras to ESP8266 by writing a suitable mobile app. To do this, we used the
microcontrollers. For this, we needed a suitable driver for Android Studio tool. We’ll explain this in detail shortly.
the camera and had to write OS for the microcontroller Second, we connected the Wi-Fi camera server (built
to use with the driver. It’s a very cumbersome job for the with the Android phone) to the local Wi-Fi network by
average programmer. using the Android Settings icon and entering the SSID and
To overcome this difficulty, we used a different password of the Wi-Fi modem/router that is connected to
approach and focused on using the camera in Android the Internet. Once the phone is connected to the Wi-Fi
January/February 2019 79
3.3V USB-TO-SERIAL ESP8266 BOARD CP2102 (USB-TO-SERIAL) Building the Wi-Fi
CONVERTER USED IN THE PROTOTYPE
1 TX PIN RX PIN TX PIN
Webserver
The ESP8266 module is gaining popularity in the
2 RX PIN TX PIN RX PIN field of electronics because it’s affordable, reliable,
3 +3.3V PINS (SUPPLY PIN) 3.3V SUPPLY +33V PIN (+5V PIN NOT USED) and readily available. The ESP8266 Wi-Fi module
4 GROUND GROUND GND contains a 32-bit low power CPU, ROM, and RAM.
Table 1. Connection details between the USB-to-serial
The ESP8266 is a complete and self-contained Wi-
converter and ESP8266 board. Fi network solution that can run stand-alone or
connected to a microcontroller. Unfortunately, most
camera server, it’s also connected to the Wi-Fi network. of the documentation is in Chinese and the information
Third, the Wi-Fi webserver built with the ESP8266 is provided in the datasheet is lacking in practical details. To
also connected to the same local Wi-Fi network, using the help fill this gap, an ESP8266 community forum has been
same SSID and password. The method on how to enter the established.
SSID and password to the ESP webserver will be explained
momentarily. Schematic
Since the camera and ESP8266 server are connected
to the local Wi-Fi network, interfacing the camera with the The circuit schematic is shown in Figure 1. We used
ESP8266 is very simple; just feed the displayed camera the ESP826612E module as a stand-alone device. The
URL from the Android phone to the Wi-Fi webserver. The supply voltage for the Wi-Fi module is 3.3 volts. A USB-to-
method for how this is done will also be explained later. serial module (CP2102) is used for connecting the TX and
In this situation, the ES8266 webserver will act in a RX pins to a PC for communications and programming.
dual role. It will be a wireless client to the camera server The CP2102 can work with either 5V or 3.3V. For our
as well as a wireless webserver to the outside world. This purposes, we used the 3.3V option. You can use any 3.3V
design comprises three parts: building the ESP8266 Wi-Fi USB-to-serial converter that you prefer.
webserver; building the mobile app (usually called the The driver software associated with the USB-to-serial
camera server app); and testing and interfacing. converter has to be installed in the PC for communications.
Table 1 shows the connection
details between the converter
and the ESP8266 board.
The ESP826612E
module only has 16 output
pins for use. The reset pin
is connected to the supply
through 10K resistance, and
a pushbutton (S2) is provided
for manual reset.
The programming mode
pin GPIO0 is connected to
the supply voltage via the 10K
resistor, and a pushbutton
(S1) brings the module to the
programming mode.The CH_
PD pin is connected to the
supply via the 10K resistor.
The ESP8266EX also
integrates a general-purpose
10-bit resolution ADC (analog-
to-digital converter). The ADC
Figure 1. The range is from 0V to1.0V. It’s
hardware circuit. typically used to measure the
voltage from the sensor or
battery.
The ADC can’t be used
80 January/February 2019
when the chip is transmitting.
All digital I/O pins are protected from
over-voltage with a snapback circuit connected
between the pad and ground. The snapback
voltage is typically about 6V, and the holding
voltage is 5.8V. This provides protection from
over-voltage and ESD (electrostatic discharge).
The output devices are also protected from
reverse voltage with diodes. The setting pin
GPIO12 is connected to the supply voltage via
the 10K resistor, and a pushbutton (S3) is used
to bring the module to set mode to establish the
SSID, password, and camera URL.
An LED is connected to GPIO pin 4.
Suppliers of Wi-Fi modules follow a different
pattern for output pin arrangements. So, we Figure 2. Our prototype.
used the ESP826612E module and
designed a PCB (printed circuit ESP8266 PUSHBUTTON LCD (2x16 ) CD4094 LM358 OP- LM35
(COMMERCIAL SWITCH SERIAL-TO- AMP
board) to suit our requirements. We BOARD ) PARALLEL
chose this module because more SHIFT
GPIO pins are accessible for users. REGISTER
The circuit is simple; you can easily GPIO 12-----------➔ S3
wire it up and do the design.
GPIO 0------------➔ S1
Due to limited output pins, we
implemented a simple application RESET-------------➔ S2
to measure the room temperature GPIO 5---------------- ----------------------- --------------➔ STR(1)
using an LM35 temperature sensor GPIO 14-------------- ----------------------- --------------➔ SI or DATA (2)
and ON/OFF LED control. Output
pin 2 of the LM35 is connected to GPIO 13-------------- ----------------------- --------------➔ CLK (3)
the ADC pin of the ESP8266 through RS(4)--------➔ Q2(5)
the unity gain amplifier LM358 which R/W(5)------➔ Q3(6)
acts as a buffer. The LM358 is a
EN( 6)-------➔ Q4(7)
calibrated temperature sensor; the
sensitivity is 10 millivolts/10C. D4(11)-------➔ Q8(11)
The circuit board is shown in D5(12)------➔ Q7(12)
Figure 2. The LCD is interfaced using D6( 13)------➔ Q6(13)
the eight-bit shift register CD4094 to
display the IP Address. The LCD is D7(14)------➔ Q(14)
operated in four-bit mode. ADC ------------------ ----------------------- ------------------ ------------➔ OUTPUT1(1)
Table 2 shows the complete INPUT+(3) -➔ VOUT(2)
connection details between Note: Some commercial boards have the reset and GPIO0 pin readily available for use. If
the ESP8266 and the external these pins are not available, just follow Table 2.
components: LCD, CD4094, LM35, Table 2. Connection details between the ESP8266 and external components.
LM358, and pushbutton switches
S1, S2, and S3.
The method to use is:
Software Programming 1. First, download the latest version of the IDE from
We use the Arduino IDE for compiling and loading https://www.arduino.cc/en/Main/Software and install it.
programs. The ESP8266 community has developed a There are versions available for Windows, Linux, and Mac
suitable plug-in for the ESP8266 to use with this IDE. Craig platforms. Follow the directions for the installation process.
Lindley (in his October 2015 article, “Meet the ESP8266”) After the installation is over, launch the Arduino IDE.
explained how to set up the Arduino IDE for compiling and 2. Go to the file and bring up the Preference page.
loading the program for the ESP8266. Enter http://arduino.esp8266.com/stable/package_
January/February 2019 81
FILE NAME ROUTINE PURPOSE
ESP-WIFI-LCD4.ino Const char image[] This is the array containing hex code of the Nuts
& Volts logo. This array was created from a jpeg
using “hexy.exe.” This is free software that can be
downloaded.
void setup() This starts the following routines:
initHardWare()
setupWiFi() and server.begin()
void loop() This handles a request from the client, creating a
webpage using the String function and sending
the webpage to the client.
void setupWiFi() This initalizes the LCD and EEPROM
It also handles various LED, EEPROM, and serial
communication functions.
void initHardWare() This initalizes the serial port and configures the
GPIO4 as output, the GPIO12 as input, and keeps
the GPIO4 pin low.
size_t sendProgmem(WiFiClient client, const char progmem[], This routine sends larger array files to the client.
size_t size)
byte ReadStringUART(char *Dest) This routine reads the character from the serial
terminal.
LCD3Wire.cpp LCD3Wire::LCD3Wire (int _lcd_lines, int _dat_pin, int _str_pin, This routine configures GPIO pins for data,
int _clk_pin) strobe, and clock for the CD4094 shift register.
In our design, data=GPIO14, str=GPIO5, and
clock=GPIO13.
void LCD3Wire::init () This routine configures GPIO pins 13, 15, and
5 as output and sets the LCD for four-bit mode
operation.
VoidLCD3Wire::commandWrite(uint8_t value This routine writes the command value in the
command register.
size_t LCD3Wire::write(uint8_t value) This routine prints the character in the current
cursor position in the LCD display.
void LCD3Wire::writeIn(char msg[]) This routine prints the message in the current
cursor position in the LCD display.
void LCD3Wire::_pushByte(uint8_t value, bool command) This routine first sets the strobe pin low, sends
the first four data bits, and sets Hbyte to zero.
void LCD3Wire::_pushNibble(uint8_t nibble, bool command) This sends four bits of data using the routine
_pushOut(nibble)i.
void LCD3Wire::_pushOut(uint8_t value) This pushes the byte to the shift register and then
on to the LCD.
Table 3. Routines and their purposes.

esp8266com_index.json into the Additional Board ESP8266 as an Arduino.


Manager URL field and click OK. Additionally, you have to select the serial port in the
3. Go to the Tools Menu tab and click Board and then IDE for serial communication. In our case, we selected the
Board Manager. This will bring up a list of Install items. COM3 port for the USB-to-serial converter. The Arduino
Scroll down to see “ESP8266 by the ESP8266 Community.” IDE is now updated with ESP8266 support.
Highlight this entry; the Installation button should appear. The Flash size is 4 MB for the ESP826612E module.
Click this button to install the ESP8266 software. This The default Flash size in the IDE is 512 KB. So, we have
may take some time because a lot of software is being to set the Flash size as 4 MB (1 MB SPIFS).This can be
transferred to your PC. done by going to the Tools Menu, clicking Flash Size, and
choosing this setting from the list.
Once the process is completed, click the Tools Menu The ESP8266 Wi-Fi webserver program is available in
and Board Entry. You should be able to select “Generic the ESP-WIFI-LCD4 folder. This folder has the following files
ESP8266 Module,” You are now ready to program the which are explained next:
82 January/February 2019
ESP-WIFI-LCD4.ino: The main sketch file which • JDK is installed in the directory “C:\Program Files\
contains the Wi-Fi webserver code. It contains routines Java\jdk-10.0.{x}” where {x} denotes the upgrade
for initalizing hardware, setting the serial communication, number.
creating web pages, setting the Wi-Fi, initializing the • JRE is installed in “C:\Program Files\Java\jre-
EEPROM, and reading strings from the serial port. 10.0.{x}.”
LCD3Wire.cpp: This file contains all the routines for
the LCD and the serial-to-parallel routine for the CD4094. To edit the PATH environment variable in Windows:
LCD3Wire.h: This is the header file that defines the
variables and functions used in LCD3Wire.cpp. • Launch Control Panel=>(Optional) System and
Security=>System. Then, click “Advanced system
All the software used is written in the C language. settings” on the left pane.
Details of the routines used in the files are explained in • Switch to the Advanced tab=>Push the
Table 3. Now, launch the Arduino IDE, go to File, navigate Environment Variables button.
to the ESP-WIFI-LCD4 folder, and then choose ESP-WIFI-
LCD.ino and click open. This will open all the files in the Under System Variables (the bottom pane), scroll
IDE. Next, we have to bring the ESP8266 webserver board down to select Path. Click Edit and set the path variable as
into programming mode. shown in #1 in the listing that follows. For setting JAVA_
We first connect the USB cable from the ESP board HOME, click New in Variable Name, enter JAVA_HOME.
to the USB slot in the PC. Power-up the unit and bring the In Variable Value, enter your JDK installed directory (“C:\
ESP8266 into programming mode by holding the S1 button Program Files\Java\jdk-10.0.{x}”).
down, pressing the reset button, and then releasing S1. The
ESP board is now in programing mode. NAME VALUE
Click the upload button and the IDE will compile 1 PATH”C:\Program Files\Java\jdk-10.0.{x}\bin”,
and load the progran into the ESP board. After successful 2 JAVA_HOME”C:\Program Files\Java\jdk-10.0.{x}”,
loading, the LCD in the board will start functioning and will
display the message “ESP-WIFI” in the first line. For other platforms, you can refer to http://www.ntu.
Since we haven’t configured the SSID and password, edu.sg/home/ehchua/programming/howto/JDK_HowTo.
the IP address will not be displayed yet. This simply html to install JDK.
confirms the successful functioning of the Wi-Fi webserver After installing JRE and JDK and setting the
board. environment variables as described above, you can
Now that we’ve finished with the ESP Wi-Fi webserver download Android Studio from the website and install it.
board, our next step is to build the Wi-Fi camera server. Again, there are versions available for Windows, Linux, and
Mac platforms.
Building the Wi-Fi Camera Go to https://developer.android.com/index.html and
select Get Android Studio=>Download Android Studio
Server App 3.x.x for Windows, and run the downloaded installer.
We’ll be using Android Studio to build the Wi-Fi Follow the on-screen instructions and accept the defaults
camera server app. You can download the latest version to complete the installation. Launch Android Studio. It will
from https://developer.android.com/index.html. Before run the setup wizard for the first launch; do not import
installing anything, we loaded the Java development kit previous settings.
(JDK) to compile and run the app in Android Studio. In Installation Type, choose Standard. Check the SDK
First, download the latest JDK version from http:// folder by default. This step will download another 1 GB of
www.oracle.com/technetwork/java/javase/overview/ the SDK package and will take some time to complete. The
index.html. On the site, look under Java Platform, Standard camera server app is a ported version of the application
Edition=>Java SE 10.0.{x} where {x} denotes a fast running from https://github.com/foxdog-studios/peepers.
update number. Click the JDK’s Download button under We have now ported it to Android Studio and
Java SE Development Kit 10.0.{x}. Check the Accept modified the source to work with all types of Android
License Agreement. phones. The original software fails for Mi type phones.
Choose the JDK for your operating system, i.e., It doesn’t display the camera URL for them. The original
Windows (for the 64-bit Windows OS), and download function private String tryGetIpV4Address() in the file
the installer (e.g., “jdk-10.0.{x}_windows-x64_bin.exe” - StreamActivityCamera.java was commented and we added
390MB). Run the downloaded installer (e.g., “jdk-10.0.{x}_ the following new function:
windows-x64_bin.exe”), which loads both the JDK and JRE.
By default: private String tryGetIpV4Address()
January/February 2019 83
Post comments on this article and find any associated files and/or
downloads at www.nutsvolts.com/magazine/issue/2019/01.

Again, this will take time to load all


the project files.
Finally, the Android IDE will
load all the project files and start
the Gradle build. After some time,
you’ll see the message “Gradle build
finished” in the bottom right corner
of the IDE. All that’s left to do is run
Figure 4. The “Select the application. However, before
Deployment Target” wizard. running and loading the app in the
Android Ddvice, we have to do
multiple settings in the phone:
Figure 3. “Allow USB debugging?”
message.
1. Go to the Settings in your
{ device and tap it.
WifiManagerwifiMgr = (WifiManager) 2. If Developer Options are not found here, go to
getApplicationContext().getSystemService(WIFI_ “About phone” and tap seven times on the Build number
SERVICE) ;
return Formatter.formatIpAddress(wifiMgr. to create Developer options. After that, Developer options
getConnectionInfo().getIpAddress()); will be created on your device.
} 3. Go to Developer options and enable USB
The camera server app source code is available in the debugging.
camera server folder. The source code files are available 4. Go to Security and enable “Unknown sources.”
under app=>src =>main=>java=>com=>kathi =>kathir.
Seven Java files are available: StreamCameraActivity.java is For Mi type phones:
the main activity file, and the other six are used by this file
to provide suitable class files when needed. 1. Go to Settings and then to About Phone.
PeepersPreferenceActivity.java is another activity file 2. Click on “MIUI version” seven times. It should
used by the main activity file. PeepersApplication.java is display “You have unlocked the Developers option.”
very important for displaying the output of the application. 3. Go back and find the Additional Settings.
Without this file, the application will be running without 4. Go to the Developers options and enable USB
any output in the screen. Debugging and “Install via USB.”
Now, launch Android Studio. A Welcome screen will
appear. Click “Open an existing Android Studio project”Next, go to the menu bar =>Run=>Run app. The Select
and navigate to the CAMERASERVER folder and click OK.
Deployment Target wizard will pop up. In your device, the
“Allow USB debugging?” message
will appear as shown in Figure 3;
now click OK.
The device name should
appear under Connected Devices
in the wizard (see Figure 4).
Highlight the device name and click
OK. The task will be executed, the
APK (Android PacKage) will be
installed on your device, and the
camera server will be launched.
In Mi type phones, you’ll get
an “Install via USB” message on
the screen. Click install. You’ll now
get another message; click Accept
to install the APK in the device.
After successful installation, you’ll
Figure 5. Image on the mobile phone showing the camera server app find the NUTS&VOLTS icon in the
running with the URL displayed at the top left. device display. By tapping the icon,
84 January/February 2019
you can run the camera server.

Testing the Project


After tapping the NUTS&VOLTS icon, the camera
server app will be running, and you’ll see the images on
the screen displayed by the camera; the camera URL will
appear in the top left corner (Figure 5). Except for http://,
the remaining digits are fed as the camera URL to the
ESP8266 webserver.
Open the HyperTerminal on the PC with the baud
rate at 115200. In the HyperTerminal, power on the unit
and bring the ESP8266 into setup mode by holding the S3
button. Do a reset using the Reset button and release the
S3 button. The board will now go into setup mode and
you’ll get a prompt for entering the SSID password and
camera URL. Separate the SSID password and URL using
commas and press the Enter button (Figure 6). The SSID
password and camera URL will be stored in EEPROM.
For subsequent use, the Wi-Fi setting is not required,
and you don’t need to use switch S3. When Wi-Fi is
connected, the IP address will be shown in the LCD
display.
Figure 6. Screenshot of the SSID, password, and
Launch the browser with the IP address. You’ll get camera URL entry from HyperTerminal.
a web page showing the live camera activity (Figure 7).
The buttons marked as LED ON and LED OFF are used Use a stepper motor to rotate the camera in all
for switching the LED which is connected to GPIO pin 4. directions using suitable hardware and software linking to
Appliances like fan motors can be switched on-off with a the ESP module. You could also use a separate pushbutton
suitable relay driver circuit using optocouplers in GPIO pin for entering the camera URL. Due to the limited number of
4. The status of GPIO12 and the temperature reading are GPIO pins, we used the single pushbutton S3 for all.
displayed using AJAX scripts without refreshing the entire Hopefully, these ideas will inspire you to give the
webpage. ESP8266 a try. NV
Sometimes refreshing temperature data using AJAX Figure 7. Web page.
scripts can cause stack overflows in the ESP module. If this
happens, you’ll have to increase the refreshing time by
changing 2000 to 3000 in the following line in the ESP-
WIFI-LCD4.ino file:

s4 += “ setInterval(function() {“;
// Do something every 1 seconds
s4 += “ refreshDiv(‘div2’,’Status.cgi’,’/
home’);”;
s4 += “ }, 2000);”;

Final Thoughts
This was a simple and fun project with lots of flexibility.
For example, the camera could be implemented for remote
visual control utilizing buttons on the web page.
For simplicity, we used LEDs for control. You could
also control industrial equipment with heavy-duty switching
contactors using optocouplers in the GPIO pins. We just
used a single camera here, but multiple cameras can be
used on different Android phones by linking them to the
ESP module through software.
January/February 2019 85
Printed Circuit Boards Build
Arduino Graphics Interface
e t h i n g
TEENSY Graphics Interface
Mass Measurement
Som
Today
!
Wide Range Pulse Generator
Numitron Clock
Continuity Tester
Pi Scrolling Display Search www.nutsvolts.com for these terms and read the articles.
Search store.nutsvolts.com to find the boards.
Analog Style LED Clock Some are available as complete kits too!

Nuts & Volts and SERVO On CD

Getting Started Kits Popular DIY Kits


ARDUINO: A Beginner’s Guide To Wee Little Talker Skull Kit
Programming Combo Amigo Kit
Learning Labs 1-3
Solar Charge Controller Kit 2.0
Geiger Counter Kit
Poor Man’s Seismograph
LED Cube
86 January/February 2019
To Order Visit
store.nutsvolts.com
or call
1-800-783-4624

Surprise Packages
Are Back In Stock! Popular Clock Kits

January/February 2019 87
NEAR SPACE ■ BY L. PAUL VERHAGE

Cosmic Rays Redux


E
ight years ago, I wrote an article about detecting cosmic rays on a near space
flight. I’d like to revisit this topic, but not from the perspective of using the Aware
Electronics RM-60 Geiger counter. My first near space mission this year carried a new
type of detector: one made for detecting muons. In this article, I’ll tell you about muons
and the detector I used to measure their flux.

was the source of this mysterious radiation.


Years later, American physicist Carl
Anderson (1905-1991) discovered that cosmic
rays produced new subatomic particles when
they collided with molecules in the atmosphere.
One of these was the mu-meson, or muon.
Anderson initially thought this particle was
the recently hypothesized subatomic particle
responsible for holding the nucleus of the atom
together. However, later observations indicated
that muons were not the pions that Japanese
physicist Hideki Yukawa hypothesized.
By the way, after the true discovery of
additional types of mesons, the term mu-meson
fell out of favor and we only call them muons
today.

Muons
The discovery of muons initially represented
a problem for subatomic physics. They were
the beginning of a zoo of subatomic particles
Figure 1: A young Victor Hess about to explore the nature of that physicists couldn’t classify in a logical sense.
cosmic rays from a balloon. Image from phys.org. However, over time, they gradually increased their
understanding about subatomic particles and
created today’s hierarchy (of subatomic particles)
Discovering that Cosmic Rays are Truly that helps make sense of these fundamental particles of
Cosmic in Origin nature.
So, what do physicists have to say about muons today?
Physicist Victor Hess (1883-1964) discovered the First, they carry a negative charge just like the electron.
true origin of cosmic rays in 1912. He did this by carrying Second, they have a mass 207 times greater than the
electroscopes in a balloon (that he himself rode) to an electron. Third, muons do not have internal structure, nor
altitude of 17,400 feet. Electroscopes were the tool of do they contain quarks, like the true mesons do.
choice before physicists invented radiation detectors This means muons are fundamental particles in and
like Geiger counters. Hess’ balloon flights showed of themselves just like electrons. In fact, muons decay into
that the amount of radiation increased as the balloon electrons over time. So, muons are most easily understood
climbed higher. This increase meant the radiation was of as heavy electrons.
extraterrestrial origin and not the ground. A muon produces a lightweight electron and two
To ensure this radiation didn’t originate from the neutrinos when it decays. While its very difficult to detect
sun, he performed one balloon flight during a near total neutrinos, the electron is easily detected. We know that
solar eclipse. Again, the amount of radiation increased a muon has a half-life of 2.2 microseconds (2.2 millionths
with altitude, indicating the moon wasn’t blocking a solar of a second), which is a very long time for subatomic
source of radiation. Hess’ work indicated that outer space particles. Since they travel at near the speed of light,
88 January/February 2019
APPROACHING THE FINAL FRONTIER
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2019/01.

muons should cover a distance of 1,500 feet from their for muons. Particle detectors like Geiger counters and
point of origin in the 2.2 microseconds before they decay scintillators are not directionally sensitive by themselves.
(this is the average distance they should cover since half-life This means the detection of a subatomic particle says
is a probability of decaying). Particle detectors, however, nothing about its direction of travel, and therefore, its
show something different. source. To get around this lack of information, detectors
Muons are detectable on the ground (at a rate of are stacked one on top of the other and their outputs are
about one muon per square centimeter per minute) and then connected together by a coincidence counter.
even in underground mines. Because of their immense A coincidence counter is often an AND gate. This
speed, time dilation increases the half-lives of muons from means unless both connected detectors register a particle
our perspective. However, from the muon’s perspective, at nearly the same time, the coincidence counter will fail
the contraction of length due to relativity shortens the to register a detection. This makes the particle detectors
distance they must travel to reach earth’s surface. sensitive to only the radiation passing vertically through
So, whether its time dilation from our perspective or both detectors. That allows stacked detectors to distinguish
length contraction from the muon’s perspective, muons between background radiation (that comes from every
survive long enough to be the most numerous high-energy direction) and particles like muons (which arrive from the
charged particles detected at sea level. Since muons only high atmosphere).
interact with matter via the weak force (a subatomic force
weaker than electromagnetism), they can pass through
enough matter to be detected in mines.
Cosmic Watch
Cosmic Watch is a desk-top muon detector developed
Detecting Muons by the Physics department at MIT. It uses scintillator
material and a solid-state photomultiplier to generate
In May last year, I launched a muon detector to an signals each time a muon passes through the detector. Best
altitude of 93,000 feet. That detector was significantly of all, the Cosmic Watch is available for $150. The 1.5”
different from the Geiger counters I traditionally launch. A x 2.5” x 3.0” metal box weighs 6.3 ounces and operates
Geiger counter contains a gas-filled tube (the Geiger-Muller from a battery; in this case, a power pack for running
tube) surrounding a center electrode. The body of this or recharging cell phone batteries. Its compact size and
tube acts as its other electrode. When a particle of ionizing weight make it perfect for launching in a BalloonSat.
radiation passes through the tube, it creates a channel of When I was studying physics at Fresno State,
ionized gas (atoms of the gas have lost an electron) that photomultiplier tubes (PMT) were similar to electron tubes.
permits electrons from one electrode in the tube to travel When a single photon of light (which our eyes are not
to the tube’s other electrode. Electrons traveling between sensitive enough to see) struck the window of a PMT, it
two electrodes constitute a current which can be measured freed an electron due to the photoelectron effect. That
with a microcontroller. single electron was accelerated down a chain of dynodes,
The muon detector works differently. It uses a material
called a scintillator that produces a tiny spark of light (a
photon) when an atom in the scintillator is excited by the
close passage or impact of a subatomic particle. Note that
this impact does not have to result in the ionization or loss
of an electron like it does in a Geiger counter. All that is
necessary is that an electron in an atom of the scintillating
material gets excited to a higher energy level. Then, after
a short period of time, the electron will drop back to its
lower energy state and release a photon (so the scintillator
has converted a subatomic particle into a photon of light).
The photons emitted by a scintillator constitute a dim
signal. So, a photomultiplier is attached to the surface of
the scintillator to convert the photons into an electrical
current that can be measured by a microcontroller.
There’s one more issue to consider when fishing

Figure 2: One of the two Cosmic Watch muon detectors I


launched into near space last year.

January/February 2019 89
APPROACHING THE FINAL FRONTIER

or series of electrically charged plates. the SiPM, it creates an electron-hole pair that is accelerated
Each impact between the electron and a dynode by the electric field created by the bias voltage across the
released additional electrons. The effect was that a PMT cell. The accelerating electron-hole pairs ionize additional
created an avalanche of electrons from a single photon. atoms inside the cell to create an avalanche of electron-
As you can imagine, PMTs are somewhat cumbersome hole pairs.
because they are glass vacuum tubes that require high Because of the aluminum case, alpha and beta
voltages. particles find it very difficult to reach the scintillator inside.
One of the things that make this muon detector so This shielding limits the Cosmic Watch to detecting muons
portable is that the Cosmic Watch replaces the old glass and perhaps some stray background gamma rays.
and vacuum PMT with a solid-state version called a silicon The signal created by the SiPM is still too small and
photomultiplier, or SiPM. A SiPM contains many small too short for a microcontroller to detect. Therefore, one
diode-like cells etched into its silicon die and requires op-amp circuit amplifies the signal and a second one
only about 30 volts to operate. Each cell inside the SiPM stretches out the signal. The microcontroller inside the
is biased with a voltage that generates a powerful electric Cosmic Watch muon detector is a 16 MHz Arduino Nano
field within the tiny cell. ATmega328.
When a photon from the scintillator impacts a cell of The coincidence counter function is programmed

90 January/February 2019
into each Cosmic Watch’s Arduino, so they don’t require Results
additional electronics. To use them in coincidence mode, On May 6th last year, I launched my 175th near space
I connect two detectors together with a 1/8” stereo cable flight from Jordan Valley, OR. The flight reached an altitude
and stack one on top of the other. A USB to mini-USB of 93,672 feet and carried cameras (visible and near
cable connects power to the first detector and the second infrared) and radiation sensors (traditional Geiger counter
one gets its power from the stereo cable connecting it to and the Cosmic Watch muon detector). The RM-60
the first. Geiger counter (by Aware Electronics) was connected to
Each detector operates from five volts and 250 mA. a PICAXE-based flight computer. The PICAXE counted the
I use a Royal PowerBurst Turbo battery pack with 11,000 number of pulses (or detections) over 10 second intervals
mAh capacity, which was more than enough for two every 30 seconds and recorded the results in EEPROM
Cosmic Watch muon detectors on a two hour near space memory.
ascent. After recovery of the flight, I downloaded the Geiger
Just before launch, I plug in the battery, press the reset counter data and loaded it into a spreadsheet. I was then
button of one of the detectors, wait two seconds, and then able to create a chart mapping the altitude of the detector
press the reset of the second detector. Data is recorded on and the cosmic ray flux.
the first detector that I reset. The Cosmic Watch recorded each time a detection
occurred. So, the time stamp of each detection
was recorded, rather than the number of
detections over a fixed time interval. Data was
stored on a microSD card inside the primary
detector and copied onto my PC after the flight.
As a result of the way Cosmic Watch records
detections, there was a huge amount of muon
data. The data was loaded into a spreadsheet
where I calculated the muon detection rate by
inversing the time between detections. In other
words, I converted units of ‘seconds’ between
detections to units of ‘per second.’ To smooth
out the data, I averaged 11 neighboring muon
rates and graphed the results. The chart in Figure
4 compares the rate for each radiation detector.

Future Plans
Right now, I have two upgrades that I want
to make to my ability to measure cosmic rays.
The first comes from the fact that my old PC
can’t download data directly from the detectors.
So, I need to open the detectors to remove their
microSD card if I want to look at the muon data.
Rather than opening a detector after each
flight, I recently purchased an extension for the
microSD card slot from AdaFruit. Once plugged
in and the case bolted close, this cable will bring
the SD card slot outside the Cosmic Watch case
to where I can easily access it.
Then, there’s the addition of other radiation
detectors. At last year’s Great Plains Super
Launch in Nampa, ID, Pete Sias introduced

Figure 3: The Cosmic Watch circuit diagram. I


downloaded this schematic from MIT’s Cosmic Watch
website at http://cosmicwatch.lns.mit.edu.

January/February 2019 91
me to the Radiation Watch solid-
state Geiger counter. I still have
a lot to learn about this detector,
but it appears to work a lot like
a traditional Geiger counter by
producing voltage spikes at the
detection of radiation.
I think I’ll combine it with the
Cosmic Watch muon detector
and the RM-60 Geiger counter to
create a single radiation-measuring
BalloonSat. The three detectors will
easily fit inside a zippered soft-
sided lunch bag and operate off
rechargeable batteries. The bag’s
padding will provide insulation for
the cold of near space and shock
protection upon landing.
When done, I could attach
Figure 4: The data seems to indicate that the flux of all particles in a cosmic this lunch box to the rest of the near
ray peak about 10,000 feet higher than it does for the muon flux. This
spacecraft in a moment’s notice and
makes sense because muons are created by cosmic rays entering the
atmosphere. However, I need to repeat this experiment several more times
collect cosmic ray data.
to make sure I get the altitude data correct.) Upwards and Onwards,
Your Near Space Guide NV

92 January/February 2019
■ BY LOU FRENZEL W5LEF OPEN COMMUNICATION

IoT Made Easy


It’s getting easier than ever to
connect stuff to the Internet.

T he whole Internet of Things (IoT) phenomenon has been around for a while now.
You may have already acquired a few IoT devices yourself like an interconnected
thermostat, a video camera for remote viewing, or a voice response device like the
Amazon Echo. Or, perhaps you’ve gone further with things like home controlled lighting
or Internet connected appliances.

But have you tried to create an IoT device on provide some useful knowledge. An example application
your own? If so, you know it is not easy. However, it is a remote video monitor. The video camera sends the
picture to the Internet and the server. You can then
now is easier than ever as many of the manufacturers
connect by Wi-Fi at some remote place with your iPhone
of IoT wireless chips and modules are providing the that lets you see the video in real time.
hardware and software to make an IoT device happen As for applications, they’re all over the place.
with minimum work. An example is Silicon Labs Consumer home uses are a major category with devices
that improve safety, energy savings, and convenience.
Wireless Xpress Bluetooth module that makes short
As mentioned earlier, thermostats, appliances, security
work of a simple IoT application. systems, lighting, and video cams are the most popular.
The artificial intelligence (AI) voice recognition devices
How IoT Works like the Amazon Echo with Alexa, Google Home with
Assistant, and Apple HomePod with Siri have quickly
In case you forgot or just didn’t know, IoT is the idea become popular as they conveniently let you call up music
of monitoring and/or controlling objects or things via the or perform other operations.
Internet or through a dedicated wireless network. Most IoT Another large applications area is industrial. Wireless
applications involve connecting some sensor or actuator monitoring and control in factories is widely implemented
by way of a wireless link to a gateway that connects to an on robots, machine tools, programmable logic controllers
Internet modem. (Refer to Figure 1.) The gateway could be (PLC), and production lines. IoT is heavily adopted in
a Wi-Fi router. process control plants, pipelines, and a wide range of other
At some end point, an applications server collects data industrial applications. Lots of remote sensors are usually
from the sensor and can initiate some action based on that involved.
data. In addition, analysis may be applied to the data to Cities are adopting IoT in controlling street lights,
monitoring parking meters and parking lots,
automatic remote meter reading, and traffic control.
Building automation is a growing category
where IoT systems provide safety and security
as well as comfort. Temperature, humidity, and
lighting are monitored and controlled to provide the
optimum environmental conditions for workers and
energy savings outside of work hours.
Some other applications are medical
monitoring of patients, agriculture monitoring
of crops, wireless links to virtual reality and
Figure 1. A generic arrangement of most IoT applications with augmented reality headsets, automotive uses like
the wireless link to a gateway or router for Internet connection. hands-free Bluetooth cellular calls, and smartwatches.
January/February 2019 93
THE LATEST IN NETWORKING AND WIRELESS TECHNOLOGIES
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2019/01.

The Critical Link in an IoT System technology is LoRa. It’s a proprietary technology but has
One of the primary decisions to be made in building proven itself to be reliable. Sigfox is also proprietary and
an IoT application is the wireless technology to be used. even uses its own networks locally to collect and deliver
There are lots of choices as Table 1 shows. data. Z-Wave is another proprietary technology that is
With so many wireless choices, there’s something widely implemented in consumer and home IoT products.
that will fit any application. One popular option is the IEEE An interesting option is one of the two cellular
standard 802.15.4. It uses direct sequence spread spectrum standards: LTE-M and NB-IoT. Both use the existing 4G LTE
(DSSS) in the 2.4 GHz license-free band to achieve a data cellular networks to link to the Internet. They have good
rate of 250 kb/s. It’s the basis for one of the more popular range and data rate capability but do require cell service.
IoT choices: ZigBee. Although not present in the table, the forthcoming 5G
ZigBee is one of the oldest technologies and the cellular technology will also find IoT applications when it
standard provides specific applications software. Thread is becomes available in 2019 and beyond.
another variation with its unique software that facilitates That leaves probably the most popular IoT choice:
applications development. Bluetooth. It’s one of the oldest of the short-range wireless
Wi-Fi is also used, but mainly as a link to a gateway standards that has enjoyed widespread use and continuous
from the Internet connection modem. It’s overkill for development. The latest versions called Bluetooth 5 or
many IoT uses as its high speed capability is not usually Bluetooth Low Energy (BLE) extend its range, making it far
necessary. more useful.
Two newer versions of Wi-Fi are 802.11af and You probably already use Bluetooth in headsets,
802.11ah. The 11af version takes advantage of the unused speakers, or auto hands-free capability. It’s getting major
TV channels in local areas for spectrum. These 6 MHz attention in many IoT applications. The main problem is
bandwidth channels permit slow to medium speed data that Bluetooth is a complex technology and development
rates and their low frequency (470 to 790 MHz) permits of products and software is a major challenge.
long range coverage. The 11ah version called HaLow is
faster and also offers long range coverage in the 2.4 and 5
GHz bands. Neither 11af or 11ah are widely adopted but
Bluetooth Simplified
are available. Several companies are now supplying not only the
Another popular long range (multiple kilometers) Bluetooth ICs but also complete modules including
Table 1. Wireless technology options for IoT.
Power
Technology Frequency Data Rate Range Consumption Features
Requires upper layers for
802.15.4 2.4 GHz 250 kb/s 100 meters Low
networking.
Bluetooth 2.4 GHz 1, 2.1, 3 Mb/s 100 meters Low Low Energy version 5 is popular.
LoRa < 1 GHz <50 kb/s 2-5 km Low Longer ranges.
High speeds. Cellular service
LTE M Cellular bands 1-10 Mb/s Several km Medium
required.
NB-IoT Cellular bands 0.1-1 Mb/s Several km Medium Cellular service required.
Sigfox <1 GHz 100 b/s- Several km Low Proprietary system.
Thread 2.4 GHz 250 kb/s 100 meters Low Uses Dot-Dot software.
Weightless <1 GHz 0.1-24 Mb/s Several km Low Three versions W, P and N.
Wi-Fi (11n/ 11 Mb/s – 1.7
2.4, 5 GHz 100 meters High Used mainly in gateways.
ac) Gb/s
Wi-Fi (11af) <1 GHz 0.1-1 Mb/s Several km Medium Uses TV white spaces.
Called HaLow; not yet
Wi-Fi (11ah) 2.4, 5 GHz 0.3 – 300Mb/s Several km Medium
implemented.
ZigBee 2.4 GHz 250 kb/s 100 meters Low Widely used IoT standard.
Z-Wave 908.42 MHz 40 kb/s 30 meters Low Popular in home applications.
94 January/February 2019
Figure 2. The Bluetooth module and one of the development boards available. The module size is 15 x 12.9 mm.

antennas that are ready to drop into any new product with PC with the microUSB cable supplied. The green LED on
minimal effort. You don’t need to be a wireless engineer. the module PCB (printed circuit board) should light.
That does leave the software for you to deal with, which is 4. Open Simplicity Studio. Click on Xpress
another major challenge. However, the good news is that Configurator in the upper right part of the screen. This will
some companies are addressing that roadblock too. bring up several windows.
An example is Silicon Laboratories, a vendor that 5. In the upper left window, you should see the device
makes Bluetooth chips and modules. They also make Wi-Fi designation displayed: bgx13p22ga. Select it and click
and ZigBee products but their new Bluetooth offering is Enter.
a real jewel. Called the Wireless Xpress, it lets you make a 6. At the bottom of the screen, click on the Connect
Bluetooth-enabled IoT device with minimal effort and NO button.
programming. Here’s my recent experience with it. 7. Now, go to your iPhone and open the BGX app.
First, get yourself one of the Wireless Xpress BGX13P When it opens, do a scan by pressing Scan on the upper
module starter kits. The module and a sample evaluation left of the screen. That should connect the phone to the
board look like what you see in Figure 2. You can get one module.
at most of the major distributors like Digi-Key or Mouser 8. On the iPhone, click on the right arrow (>) to bring
for about $40. The module connects to your PC via a up the black terminal screen. You can now type something
microUSB cable (supplied with the kit). on the phone and press the Send button to pass it to the
This module has three mechanical pushbuttons and computer. It should show up in the terminal screen at the
three LEDs. It’s designed to operate in a stand-alone bottom.
mode, so can operate as a simple terminal emulator. The 9. Now, try typing something into the bottom window
module will probably find its way into a project with a of the screen on the PC and press Enter. Your message
microcontroller. Silicon Labs has several of these (8051 and should show up on your iPhone screen. Violá! Magic
ARM) that are a good fit with the Xpress module. terminal communications.
Here are the steps I followed to set the module up
to function as a terminal exchange between a PC and an Experiment with things like the range between the
Apple iPhone. phone and module. It should be good for 30 feet or so.
Also, don’t forget to look at all the material related to this
1. Go to the Apple app store and download the BGX on the Silicon Labs website.
Commander Mobile App. The icon is a blue gecko and Anyway, Silicon Labs has made it easy to pair
BGX. two Bluetooth devices. The next step is connecting a
2. Download the software called Simplicity Studio microcontroller module from Silicon Labs to the Bluetooth
from the Silicon Labs website. module for application development. However, that’s an
3. Unpack the module board and connect it to your article for another time. NV
January/February 2019 95
TECHFORUM READER - TO - READER

wind in the same direction? It seems #1 Answers to “newbie” questions


>>> QUESTIONS like winding in the reverse direction always help others. You can create
DC To AC would cancel out the field. Does it plated through holes in your
I have a 100 amp 110 volt DC matter which direction? workshop, but it involves many steps
generator. I want to convert the #1194 Jordan Bracegirdle with chemical solutions.
output to 60-cycle AC. Does anyone Toronto, CN Instead of messy and toxic
have a schematic or info to build a chemicals, why not solder a jumper
converter? How much power loss can through the board to connect
I expect in the final converted output? >>> ANSWERS conductors on both sides? As an
Thanks for any info. [#2182 - February 2018] alternate, use component leads to
#1191 Lucio Saunders Amplifying Plant Signals make a side-to-side connection and
Indianapolis, IN I’m trying to duplicate an ESP solder the leads on both sides of your
experiment described in the book board.
SCSI Card Or Adapter Needed “What A Plant Knows,“ by Chamovitz. If you truly want plated-through
I have a bunch of old optical Basically, I need an amplifier and holes, contact a PCB fabricator that
disks that have data archived from sensor to read signals from stems and will make a run of three or four
about 20 years ago that I would like roots. What frequency response does boards for you with plated-through
to access. I found the stand-alone the amp need? My guess is from DC holes. I have used ExpressPCB and a
drive in a box of old computer junk, to maybe 20 Hz? If this is the case, friend has used OSH Park, both with
complete with the big SCSI cable. then what sort of amp configuration good results.
Problem is that I don’t have the do I need? A multilayer board has etched
computer anymore that has the SCSI copper layers sandwiched between
card to plug it into, and don’t even Mr. Dixon desires to amplify insulating layers and connected with
know where to begin to look for one. electrical signals originated in plant tiny plated-through holes. Search
Is there something comparable stems and roots. This is a perfect Google for multilayer PCB and you’ll
that will work with a modern application for an instrumentation find many helpful cut-away diagrams.
computer? An SCSI to USB adapter amplifier circuit. Instrumentation Jon Titus
maybe? What about drivers? The old amplifiers amplify the voltage Herriman, UT
machine was probably Windows 98. difference appearing between
#1192 Mark Cisneros two sources, neither of which is #2 I don’t know of any easy way
Columbia,TN referenced to ground. to make plated-through holes using
Basic information on homebrew PCB etching materials.
Ringing Of The Bells instrumentation amplifiers and However, if you use double-sided
Is it possible to replicate tubular lots of applications bulletins from copper-clad boards, you could make
bell tones with a microcontroller? I’m IC manufacturers such as Analog front and back etching screens. Just
needing realistic, deep, resonating Devices, Texas Instruments, and make sure you securely attach the
tones. If so, are there any micro Intersil can be found if the phrase front etching screen to the blank and
requirements that would make one “instrumentation amplifier applications” re-drill your holes from the front side.
device more suited over others and is used as an internet search Then, using the drilled holes as
how do I create the tones? I want to argument. a guide, securely attach the back
program short 10-15 sec jingles of my Peter A. Goodwin screen to the blank, ensuring you
own composition. Rockport, MA accurately line it up with the drilled
#1193 Sara Hanchett holes. Then, with both screens still
Forest Grove, OR [#7185 - Jul/Aug 2018] attached, expose both sides of the
PCBs With PTHs blank (assuming photo-resist is used),
Coil Winding Tips Is there a hobbyist method for remove the screens, then develop
I’m looking for some pointers on making circuit boards with plated and etch the board.
winding coils. On a second layer of through holes at home? Also curious When you install the components
winding, should the direction reverse by what is meant by multilayer boards. on the front side, ensure you solder
when reaching the end of the core, I’m just getting started, so forgive me if both sides of the board where a lead
or return to the starting side and this is an obvious newbie question. makes a front to back connection.
96 January/February 2019
>>>YOUR ELECTRONICS QUESTIONS ANSWERED HERE BY N&V READERS

Send all questions and answers by email to forum@nutsvolts.com


or via the online form at www.nutsvolts.com/tech-forum

As for multilayer boards, they’re when soldering to an internal power/ common. The plated through holes
exactly what the description is. ground plane or even bad solder often do not reach the surface of
They’re a sandwich of thin boards, joints (the solder doesn’t make the the finished board. You can achieve
each layer typically one millimeter connection on internal layers), which much of the same effect by adding a
thick, with etched circuitry (single- or is why they’re very expensive to daughter board (a shield in Arduino
double-sided) or an un-etched power design and manufacture. terms) to your design.
or ground plane, glued together Ken Simmons Dale Freye
in exact (i.e., 1/10000” or better) Auburn, WA via internet
alignment so all the through holes
will match up when components are #3 Etch or mill your circuit #4 I gave up making boards years
installed. boards with space for larger holes ago. Hazardous chemicals, lots
When completed, these boards where you need them to be plated of fiddly fine work. Double-sided
can be as thick as five millimeters or through. Insert small grommets made boards require precise alignment, and
so, with eight or more layers! Most for that purpose into the holes and multilayer boards are impossible at
multi-layer boards use through hole peen them over. In most cases, this home.
plating — especially on power and will be unnecessary because you can A multilayer board is a board that
ground planes — to ensure positive just solder parts like resistors on both has conductive layers sandwiched
through hole connections (again, sides of the board. inside the board, usually one for
depending on how well each layer is The use of sockets will make power and one for a ground plane —
aligned when the sandwich is made). working with ICs, DIP switches, and for a total of four layers (top, ground,
They’re soldered using wave- resistor arrays much easier. power, and bottom). More layers are
soldering equipment because hand- Multilayer boards are made up also possible, of course.
soldering risks damaging the board of several thin circuit boards glued Jay R Jaeger
via local overheating — especially together. Four to eight layers are Madison

ADvertiser INDEX Accutrace .................................. 99


All Electronics Corp. ............. 7, 31
■ LOOK FOR ■ SEARCH FOR ■ FIND Find your favorite advertisers here! DLP Design .............................. 31
ACTUATORS EDUCATION Pololu
Electronix Express .................... 78
Hitec Commercial Solutions ME Labs SDP/SI
PoLabs ServoCity ExpressPCB ............................. 41
BATTERIES/CHARGERS
Hitec Commercial Solutions EMBEDDED SYSTEMS TEST EQUIPMENT Hammond Manufacturing ......... 92
Saelig Co. Inc.
BUYING ELECTRONIC Technologic Systems Electronix Express
Hitec Commercial Solutions ....... 2
SURPLUS Pico Technology
All Electronics Corp. ENCLOSURES PoLabs Keyways ................................... 31
Keyways Hammond Manufacturing Saelig Co., Inc.
LDG Electronics .......................... 3
CIRCUIT BOARDS LCDs/DISPLAYS TOOLS
Accutrace Saelig Co., Inc. PanaVise Measurement Computing ........ BC
ExpressPCB
Saelig Co., Inc. LIGHTING PoLabs ME Labs ................................... 78
Reactive Lighting
COMPONENTS TRANSFORMERS PanaVise .................................. 55
All Electronics Corp. MICROCONTROLLERS / Hammond Manufacturing
Electronix Express I/O BOARDS Pico Technology ....................... 14
Saelig Co., Inc. ME Labs TUNERS
Technologic Systems PoLabs ..................................... 41
DATA LOGGING LDG Electronics
Measurement Computing MISC./SURPLUS Pololu ........................................ 15
Pico Technology All Electronics Corp. USB
DLP Designs Reactive Lighting ...................... 31
DESIGN/ENGINEERING/ MOTORS / MOTOR Saelig Co., Inc. ......................... 98
REPAIR SERVICES CONTROL WIRE, CABLE AND
Accutrace Hitec Commercial Solutions CONNECTORS SDP/SI ...................................... 31
ExpressPCB ServoCity
All Electronics Corp.
ServoCity .................................. 31
DEVELOPMENT ROBOTICS
PLATFORMS/TOOLS Electronix Express WIRELESS PRODUCTS Technologic Systems .......... 41, 70
Technologic Systems Hitec Commercial Solutions Technologic Systems
January/February 2019 97
ea ea ea

Our Full Service Capabilities:

(408)748-9600
ITAR I SO 9001:2008 UL Approved
Bring Your Pi to Work!
Measurement Computing now offers
DAQ HATs for Raspberry Pi®
MCC Raspberry Pi measurement HATs were designed to bring high-quality
measurements to the ubiquitous low-cost computer. MCC DAQ HATs are the
perfect solution for adding professional quality DAQ capabilities to the Pi platform.

MCC DAQ HATs are provided with:


• Complete SW library for easy programming
• Full set of examples in C® and Python™
• Free technical support
• Quality from a trusted source

MCC 118 MCC 152


Analog Input Analog Output
• 8 channels • 2 channels
• 100 kS/s • 8 DIO
• 12-bit resolution

Perfect for:
Embedded System Design - Industrial IoT - End-of-Line Test - Remote Monitoring - Edge Computing

Buy with Confidence – Take Measurements in Minutes

1 YEAR

www.mccdaq.com/DAQ-HAT
Contact MCC
1.800.234.4232
©2019 Measurement Computing Corporation, 10 Commerce Way, Nor ton, M A 02766 • info @mccdaq.com

You might also like