Download as pdf or txt
Download as pdf or txt
You are on page 1of 100

THE

TIME NOW
Scan for more details.

IS

UPGRADE TO THE D-SERIES SERVO LINE


PREVIOUS UPGRADE
Our engineers have worked diligently
HS-5085MG D85MG
throughout the past year, producing our
HS-5485HB D485HW enhanced, high-performance D-Series.
HS-5495BH D485HW Designed with upgraded features and
HS-5625MG D625MW extreme reliability, this servo line successfully
HS-5665MH D625MW replaces a plethora of your past favorites.
HS-5645MG D645MW Check out the chart pictured here for a quick
HS-5685MH D645MW reference to your D-Series replacements.
HS-5646WP D646WP
HS-7775MG D777MG KEY IMPROVEMENTS:
HS-8775MG D777MG • Programmable PWM Digital Amplifier
HS-7940TH D940TW • 32-Bit MCU with 12-Bit ADC Circuitry
HS-7945TH D945TW • 4096 Resolution
HS-7950TH D950TW • 1M Cycle Long Life Potentiometer
HS-7954SH D954SW • Wide Operating Voltage (4.8 ~ 8.4 Volts DC)
HS-7955TG D955TW • Dual Ball Bearing Supported Output Shaft
HS-7980TH D980TW • 25-Tooth Output Spline

Hitec RCD USA, Inc. | 12760 Danielson Ct. Unit E, Poway, CA 92064 | (858) 748-6948 | www.hitecrcd.com
PROTEUS DESIGN SUITE
Advanced PCB features for professional
board design

Set design rules that apply in user


specified areas of the PCB.
Control the layer stackup and drill ranges
for smarter routing.

Easily length match tracks against each


other or to a target distance.
Edit the fitted status of parts or replace
with pin compatible alternatives.

The Proteus Design Suite provides advanced features at


an affordable price. Try it today!
Visit: www.labcenter.com
Toll Free: 866.499.8184
Tel: 905.898.0665
E-Mail: don.jackson@labcenter.com
youtube.com/c/LabcenterElectronicsLtd
September-
October 2018
Columns Page 90

08 Q&A
Reader Questions Answered Here
Topics discussed this time:
• Humming an Unpleasant Tune
• Computer Mind Tricks

12 The Ham’s Wireless


Workbench
Practical Technology from the Ham World
Filter Design Software
To continue our discussion from last month on filters, this
time we’ll look at the time-tested and free student version
of ELSIE: design software for passive filters. By stepping
through a sample design, you’ll get a feel for how to turn
specifications like we discussed in the last column into a
real filter design.
Filters are one of the most important and widely-used
circuits in all of radio at any frequency. Understanding
how they are specified and used will make you a better
electronics designer, whether you build your own or
90 Near Space
simply buy them from a vendor. Approaching the Final Frontier
Raspberry Pi Zero Flight Computer — Part 3
85 Open Communication My final challenge in designing the RaspPi flight computer
(after collecting and storing sensor data) was to add a
The Latest in Networking and Wireless camera and store its images. After some hair pulling, I
Technologies finally have the RaspPi based near space flight computer
recording both sensor data and pictures on its SD card.
How Phased Array Antennas Work
Phased arrays have been used for years in military radars

Departments
for long range detection of missiles. They’re also widely
used in military and commercial aircraft radars and
some satellites. These phased arrays are expensive, but
today thanks to new technology and higher frequencies,
phased arrays are smaller and more affordable making 06 DEVELOPING 18 NEW PRODUCTS
them practical for new wireless devices. This article is an PERSPECTIVES 82 NV WEBSTORE
introductory tutorial on this special antenna type you need DIY Biotech: The 45 BENCH & BUILDER
to know about. Ultimate STEM Track? 94 TECH FORUM
07 READER FEEDBACK 97 AD INDEX

Cover photo credit: J.L. Lee/NIST Nuts & Volts (ISSN 1528-9885/CDN Pub Agree #40702530) is published bi-monthly for $26.95 per
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
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.

4 September/October 2018
Subscription Information
Nuts & Volts — PO Box 15277
North Hollywood, CA 91615-9218
Call 877-525-2539 or go to www.nutsvolts.com
Subscribe • Gift • Renewal • Change of Info
Page 26
For more details on subscribing, see our ad on Page 97.

Projects & Features


22 Build a Customizable Musical
Doorbell 60 Pawlicki’s Posers
This is the first in a series of questions to encourage
When my wife and I moved into our current home a few readers to think about electricity and electronics in ways
years back, it didn’t have a doorbell. We live on a quiet that, perhaps, they had not before. My intent is to improve
cul-de-sac, so it really wasn’t a problem as we had few understanding how electricity behaves and how it can be
callers. After a while, I installed a wireless doorbell that made to do what we want.
lasted about three years. Recently, after writing the series POSER #1: How does electricity know to light the bulb
of articles on “A Digital Analog – When a PIC Can Replace a while leaving everything else dark?
555,” I decided to make one using a PIC. ■ by John Pawlicki K8AG
■ by Larry Cicchinelli

26 Build the MIDI Replay Stomp 62 Meet the Microbitx: A Simple


Box to Build, Yet Challenging All-Band
The MIDI Replay Stomp Box is both a MIDI configuration Transceiver Kit
tool for applying a song’s keyboard settings, plus a four- Rarely has there been as much interest in a high frequency
track recorder providing accompaniment for songs. Other radio as that shown to the Microbitx created by Ashhar
features include foot-switch control, looping, transpose, Farhan. Low-power enthusiasts have rushed to place
keyboard splits and layers, a metronome, plus syncing their order for this exciting (and a bit challenging) new
data with its own PC desktop app and writing to standard transceiver kit.
MIDI files. ■ by Steve Jackson
■ by Jeremy Leach

69 FPGAs for the Hobbyist: NTSC


40 Super Simple Projects for
Shield
Learning Soldering and More If you have read my previous Nuts & Volts articles in the
I’ve had a couple fun circuit ideas in the back of my head FPGAs for the Hobbyist series, you already know that I’m a
for years and started playing with them, changing things big fan of Embedded Micro’s Mojo V3 FPGA Development
and finally formalizing them. They’re simple and are a good Board. Embedded Micro offers a handful of expansion
exercise in soldering and circuit basics. shields for the Mojo V3. However, at the time I wrote this
■ by Phillip Karras article, there was no video shield available. Well, I don’t
know about you, but that sounded like a great project to
46 Ready Player 2: CC3200 Wi-Fi & me! So, let’s go on a journey to design a video shield for
the Mojo V3.
IoT MCU — Part 1 ■ by Ryan Clarke KJ6MSG
The February 2018 issue article “Build the IoT Sump Pump
(or Pretty Much Anything IoT)” generated curiosity about 76 Mass Confusion: The End of the
Kilogram as We Know It
some of the tools utilized to create the device. It’s time to
“ready Player 2” and penetrate deeper into the utilization
of some of the software and hardware features that come This November, in Versailles, France, representatives from
with CC3200 Launchpad and Code Composer Studio (CCS). 57 countries are expected to make history. They will vote
■ by Patricia & Mirza Kolakovic to dramatically transform the international system that
underpins global science and trade. This single action will
54 Can You Trust Your Voltmeter? finally realize scientists’ 150 year dream of a measurement
system based entirely on fundamental properties of nature.
Sometimes I wonder which of my portable digital
The International System of Units — informally known
voltmeters I can trust — the B&K, Fluke, or Amprobe.
as the metric system — will change in a way that is more
Usually, they’re pretty close but it bugs me not knowing
profound than anything since its establishment following
whether they are right on the nose.
the French Revolution.
■ by David Goodsell
■ by C. A. Hamilton
September/October 2018 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

SUBSCRIPTION

I f you’re a regular reader of Nuts


& Volts, then you might have the
impression that STEM (Science,
— were developed long before the
wheel.
So, why all the renewed
Toll Free: (877) 525-2539
Outside US: (818) 487-4545
P.O. Box 15277
North Hollywood, CA 91615
Technology, Engineering, and Math) interest in DIY Biotech? In a subscribe@nutsvolts.com
and maker activities are limited to word, accessibility. Just as the PC
areas such as robotics, electronics, revolutionized computing, recent FOUNDER
3D printing, laser cutting, and developments have made it possible Jack Lemieux
microcontrollers. However, the oldest for anyone with a scientific bent to PUBLISHER
maker activity on the planet — DIY practice DIY Biotech in their kitchen Larry Lemieux
Biotech, including genetic engineering or garage. publisher@nutsvolts.com
and cell-based manufacturing — is One such development is CRISPR
poised to change everything. (a gene splicing technique) that can ASSOCIATE PUBLISHER/
DIY Biotech is a rapidly evolving be performed by the average middle ADVERTISING SALES
Robin Lemieux
field that contains components of school student. If you can transfer the robin@nutsvolts.com
genetic engineering and microbiology, contents of one test tube to another
among others. In recent years, DIY and use a sterile technique, you can EXECUTIVE DIRECTOR/
Biotech has appeared in middle and perform CRISPR experiments. PRODUCTION
high school STEM programs as, for In addition to new easily Sean Lemieux
sean@nutsvolts.com
example, transformed bacteria that performed and affordable gene
glow in the dark or fluoresce under manipulation techniques, the cost EDITOR
UV light that produce a perfume-like of outfitting a DIY lab has dropped Bryan Bergeron
scent. precipitously over the past five years. techedit-nutsvolts@yahoo.com
For example, the photo included For example, PCR machines — which
CONTRIBUTING EDITORS
here shows colonies of E-Coli are essentially DNA photocopier Ward Silver Kristen McIntyre
bacteria on an agar-filled petri dish. devices — typically sell new for Lou Frenzel Paul Verhage
Using simple desktop microbiology $10,000 or more. Today, you can David Goodsell Steve Jackson
techniques, one of my students, find fully functional PCR machines Mirza Kolakovic Patricia Kolakovic
Ryan Clarke John Pawlicki
Nhi Dinh, inserted gene coding for on eBay for $200. Similarly, used
Clark Hamilton Jeremy Leach
the glow-in-the-dark proteins from a incubators (low temperature ovens) Phillip Karras Larry Cicchinelli
jellyfish into the E-Coli. and gel electrophoresis machines can
Of course, glowing bacteria fall be had for pennies on the dollar. SHOW COORDINATOR
short of the major transformations Thanks to a few companies in Audrey Lemieux
produced by the large pharma and support of the DIY Biotech effort, the
WEBSTORE MARKETING/
agricultural laboratories. You’ve biological raw materials — from agar COVER GRAPHICS
probably heard of the transgenic to coat the petri dishes, antibiotics Brian Kirkpatrick
tomatoes made by inserting pig DNA to select for genetically modified brian@nutsvolts.com
into tomato DNA. If you live in the bacteria, and sterile tools, to non-
Copyright © 2018
USA, it’s difficult to avoid eating or virulent EColi bacteria — are readily
by T & L Publications, Inc.
drinking GMO (Genetically Modified available and affordable. For example, All Rights Reserved
Organism) products. I’ve had great success with The Odin All advertising is subject to publisher’s approval.
We are not responsible for mistakes, misprints, or
It’s tempting to treat DIY Biotech (the-odin.com), Amino Labs (amino. typographical errors. Nuts & Volts Magazine asumes
no responsibility for the availability or condition of
as the new kid on the block. In bio), and Carolina Biological Supply advertised items or for the honesty of the advertiser.
reality, however, while robotics and Company (www.carolina.com). The The publisher makes no claims for the legality
of any item advertised in Nuts & Volts. This is the
microcontrollers have been around Odin caters to the BioHacker crowd, sole responsibility of the advertiser. Advertisers
for decades, DIY Biotech has been while Amino Labs and Carolina and their agencies agree to indemnify and protect
the publisher from any and all claims, action, or
around for thousands of years. Biological Supply Company are more expense arising from advertising placed in Nuts &
Volts. Please send all editorial correspondence, UPS,
Fermented foods and grains — think traditional STEM suppliers for middle overnight mail, and artwork to: 2279 Eagle Glen Pkwy
beer, wine, mead, yogurt, and cheese and high school students. #112-481, Corona, CA 92883.

6 September/October 2018
If you’re currently into, say, kit from The Odin ($159). This
communications, then you might kit is much more involved than
fear that making the move to DIY the Amino Labs product, but
Biotech means selling your DMM you’ll learn some advanced
and oscilloscope to buy a used techniques such as how to use a
PCR machine. Don’t do it! The micropipette.
more you bring to the table, the In addition to the CRISPR
better. kit, I’ve had good luck with the
Use your 3D printer to fluorescent yeast add-on kit
make an affordable centrifuge. ($80). The Odin’s full Genetic
Buy an old PCR machine in Engineering Home Lab Kit
need of repair and use your ($1,699) is a bit overwhelming.
electronics skills to debug the importantly, a PDF project book. I found it’s a good value, but it’s not
microcontroller. Need to monitor Just wipe the swabs between for the novice. You’d be better off
bacteria growth in agar? Make an your toes, on your kitchen working with the more affordable kits
optical density measurement device countertop, etc., swab the agar, and initially.
with a green LED, a phototransistor, then place the petri dishes in a warm So, stay tuned! I’ll have a few
and an Arduino. Pick up an old Gel place. In a couple days, you’ll see all follow-up articles in Nuts & Volts to
Electrophoresis device on eBay and sorts of bacterial and yeast colonies. gauge reader interest in DIY Biotech.
power it with a low-current 100 VDC You’ll probably notice a distinct odor By the way, if you’re of age and
power supply of your design. as well. want to try your hand at the oldest
So, let’s say you’re convinced to Next, I’d try a kit from Amino DIY Biotech practice on the planet,
at least explore DIY Biotech, but you Labs. I’ve used the Engineer-it Kit then consider the Bro oklyn Brew
have absolutely no experience with ($33) with great success. It’s fun Shop Everyday Beer Making Kit ($40,
microbiology. What’s next? First go and you’ll get to pour your own Amazon). If you can boil water, then
to Amazon.com and pick up a set of agar plates and mix the DNA. The you can brew beer.
premade agar petri dishes. I’ve had kit comes with everything you need. Plus, you can always buy
great results with Evviava Sciences There’s also a Udemy course that’s additional yeast if you want to try
Amazing Bacteria Science Kit ($22.45, linked to the project. your hand at green fluorescent beer.
Amazon). The kit contains 10 agar If you’re ready for more of a NV
plates, some sterile swabs, and, most challenge, then consider the CRISPR

READER FEEDBACK
Music to My Ears Contributing to the Cause
Bryan Bergeron’s editorial in the May/June issue has I have been passing around articles to local ham clubs
really hit home. It was just last year I dusted off my 10 I thought would be of interest from Nuts & Volts issues.
year old stereo amp and large speakers to really hear how I know at least six people have joined the magazine as a
terrible the latest MP3s have become. result of just my feeble efforts. Many more are looking the
Having listened to them for the last several years using mag over and are considering joining Nuts and its sister
only headphones or small speakers on the computer, I was publication, SERVO Magazine, including my 15 year old
blown away concerning all the nuances that I missed in the niece near Seattle who wants to be an EE. I introduced
latest songs and how full the music really seemed. Sad to your mag to her classes.
say, I now miss the fully enveloping sounds during my runs. You are doing a great job as the interest I see locally
However, I can’t wait to get home to really listen once from 16 to 82 year old citizens can attest. You are helping
again. us generate more EmComm volunteers. You folks are
Russ Wizinsky making a bigger impact than the aggregate numbers might
tell. Quality followers will stay subscribers longer. We need
Your comments are much appreciated. I assume/hope radio folk without gray hair ... you are a really important
someone out there at Bose or maybe even Apple is working cog in the national infrastructure.
on a set of tiny earbuds that reproduce the REAL sound that Keep up the great work.
can be had from a pair of old fashioned theater speakers. Jim NB6TE/USN code school, 1967
Bryan Bergeron

September/October 2018 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.

• Humming an UnpleasantTune
that the amplifier cannot reproduce the higher voltage
parts of the waveform, so the voltage actually just stops
rising. It’s as if the top of the waveform is “clipped”
• Computer Mind Tricks away.
Clipped sine waves — the form of the voltage
variations on the AC mains — are almost like square
Humming an Unpleasant Tune waves, particularly as the clipping occurs lower

Q
and lower down the sine function. Square waves have
When I hook up my Amazon Dot to an external
amplifier, I get a constant hum. I tried using an
expensive audio connector (Monster), but the
hum persists. I’ve heard that ground loops could
be the cause, but I don’t know how to verify there’s a
ground loop. Can you give me some pointers?
Tim Powell
Adelphi, MD

A
Hum like this can often be difficult to diagnose.
It usually comes from the power line’s 50 or
60 Hz electromagnetic interference. This is
compounded by the relatively high impedance ■ FIGURE 2. Harmonic content of a clipped sine
inputs to and high gain of most amplifiers. (Wikipedia CC BY-SA 4.0 by Binksternet).
If you know someone who plays the electric guitar
(like my son does), you can really hear this effect. It’s a lot of harmonic content, which we know from doing
accentuated because of the high gain that guitar players something called a Fourier decomposition. This operation
like to use to provide “distortion.” The high gain actually decomposes a time-domain waveform into its frequency
drives the amplifiers into a state called clipping (Figure 1). components — a series of sine waves at a given phase,
When this happens, the input signal is large enough amplitude, and frequency.
When you look at it that way, you see that there are
many odd harmonics — multiples of the base frequency
by an odd integer (Figure 2). These odd harmonics are
particularly objectionable to our ears (that’s a whole
other thing to discuss sometime), and that’s why we hear
this unpleasant hum. If it were just at 50 Hz or 60 Hz,
we wouldn’t hear it that well. Our ears don’t respond
sufficiently at that frequency.
All of this is well and good, but how do we get rid of
the hum you’re hearing? Let’s first look at the potential
ways we could be coupling that energy from the mains
into the audio amplifier.
One would be stray electromagnetic fields. In a
typical home environment, these fields are present and
significant. If you have an
■ FIGURE 1. A clipped
sine wave. oscilloscope handy, you can
observe this. Just turn the
8 September/October 2018
QUESTIONS and ANSWERS
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2018/09.

gain up high and put a finger on the probe. J1 R1 OUT


You’ll likely immediately see a very distorted
sine wave with a base frequency of 50 or 60
IN J3
Hz, depending on your AC mains frequency.
These fields will easily induce a voltage on an
amplifier’s high impedance input.
One way to reduce the effect (it cannot Vin Vout

R2
be eliminated), is to both lower the gain of
the amplifier and lower the input impedance.
We can do this with a resistor network
attenuator at the input to the amplifier J2 OUT
(Figure 3). More current will be required
IN J4
to get an equivalent voltage, thus lowering
the impedance. We can then increase the
n FIGURE 3. Voltage divider based amplifier attenuator.
gain of the amplifier (turn up the volume) to get the
amplification we need. The attenuation will follow the
usual resistor voltage divider equation: actually works?
Jose Hauser
Vout = Vin R2/(R1+R2) Beaumont, TX

A
Another possible way that the hum in getting in is Let’s take a look. It depends on what you mean
what you mentioned: a “ground loop.” I find ground to be by “works.” They all output some data, but
an ill-defined term, so let’s just think of this case as stray whether you can make sense of those data is
voltage differences and currents flowing through the AC another matter.
mains, including the so-called safety ground. These voltage I’ve been interested in this area for a while. A couple
differences can become currents that flow in the wire of years ago, I bought a NeuroSky device and got the SDK
coupling the devices together; in this case, the Amazon to play with sensing brain states. My interest is in sleep. I
Dot and the amplifier. There are numerous causes for a have always had trouble sleeping and was hoping to use
condition like this, including faulty house wiring. some brain state data to drive how to induce sleep using
To break the circuit that may be carrying such currents, binaural beats. I’ve had some success using binaural beats
we can couple with magnetic fields instead. We do this in iOS apps I wrote for myself to help my sleep, and I
with an audio isolation transformer. There are many that wanted to enhance that. Interestingly, a device called the
are targeted at audio frequencies and typical audio system Sleep Shepard Blue independently implemented some of
impedances. RadioShack used to carry these in their stores, my ideas, but not all.
but there aren’t many RadioShacks left. In principle, it was an interesting idea, but what I
I did find them, however, at Jameco on the web for found was that the data coming from the EEG device were
only a few dollars. Keep in mind that the response of a unreliable indicators of my brain state. It was also difficult
transformer will be frequency dependent, so it will tend to to sleep with that thing strapped to my forehead and
roll off the low frequencies and emphasize the high. You earlobe, or at least to keep it on while I was lying in bed
might have to compensate for this using some simple filters trying to sleep.
to get music quality audio back again. Looking around the web for the current state-of-the-art,
It would probably be worth trying the attenuator first, I found that there are some very cheap hacks that can be
since it’s so easy to implement. If that doesn’t work, try the done with EEG based toys. The Star Wars™ Force Trainer
isolation transformer. seems to be a popular device to modify.
It has a NeuroSky EEG board inside that can be used,
Computer Mind Tricks along with the toy headgear. Serial data are output from

Q
a pin on that board, and an Arduino or Raspberry Pi can
I want to get into brain control — especially be used to read the output. I found an Instructables article
for flying drones. I’ve read the sub-$100 EEG that shows how to do it at www.instructables.com/id/
monitors are a joke, and that the best system Control-A-Computer-With-Your-Mind/. That’s a $40
out there is an open source monitor for over solution, but it’s probably not very good. There may only
$1,000. Do you know of an affordable brain interface that be three channels of data, which doesn’t give you much to
September/October 2018 9
QUESTIONS and ANSWERS

work with. device for a cool $800. These higher-end devices want you
NeuroSky also has the MindWave Mobile 2, that may to use saline pads to achieve better skin contact, so the
be a step up from the original MindWave, but I’m not sure. signals will be larger and more consistent.
The website seems to put the emphasis on comfort, as Interestingly, the EMOTIV devices have gyros, an
opposed to more functionality. It’s still around $100. accelerometer, and a magnetometer in them so that head
Stepping up in capability, there are some interesting position and motion will be readable. That could be an
devices by EMOTIV (http://emotiv.com). There is a five- interesting source of data for controlling systems.
channel one for about $300 and a squid-like 14-channel Of course, you can try to build your own. This is harder
from a mechanical perspective than
it is from an electrical perspective, in
my opinion. You’ll need some sort of
instrumentation amplifier that should
be able to detect the differential
signals that are in the microvolt
region and amplify them up to some
reasonable level. Then, they will have
to be digitized. This is where it gets
more difficult since some of them are
below 1 Hz.
A reasonable analog-to-digital
converter would be necessary that is
coupled down to those frequencies,
and then there needs to be a way to
get the data into a computer. With
enough space, that’s not too hard,
but then you also need to create a
low resistance coupling mechanism
for the sensing wires to your head.
You need to mount all of this on that
mechanism.
Lastly, the computer will want to
do some sort of frequency analysis to
try to classify the signals. It’s doable,
but it will be a fair amount of work to
package it reasonably.
Another idea might be to get
several of those Star Wars Force
Trainer devices and increase the
number of channels using several
NeuroSky boards and more coupling
points on the head. That could be a
way to get something that works like
the EMOTIV device implemented
cheaply.
It’s hard to say if all of this
is enough to get good data for
controlling a drone. I tend to
be skeptical of getting anything
interesting from an EEG that
corresponds to fine motor control.
I think that the position and motion
controls on the EMOTIV devices will
be more interesting and useful. NV
10 September/October 2018
Romi
Versatile robot platform with
integrated battery compartment,
Balboa motors, and wheels; several
add-on board options available
Programmable balancing
robot kit that can stand
itself up and drive
around on two wheels

...and more
Everything from Zumo
mechanical parts and Complete integrated Mini
jumper wires to motor Sumo robot on a tracked
drivers and voltage chassis, featuring a
regulators variety of sensors

Finding the right parts for your robot can be difficult, but you also don’t want to spend all
your time reinventing the wheel (or motor controller). That’s where we come in: Pololu
has the unique products—from A-Stars to Zumos—that can help you take your robot from
idea to reality.

Find out more at www.pololu.com


THE HAM‘S WIRELESS WORKBENCH ■ BY WARD SILVER N0AX
hwardsil@gmail.com

Filter Design Software


Once you start, it’s hard to stop!

If you’ve ever lived close to an AM broadcast station, you


probably experienced the phenomenon known as fundamental
overload. It occurs when a receiving device is functioning entirely
properly but unable to reject a strong signal. The receiver might be a
wireless telephone, a scanner, or even a TV or radio receiver. The AM
signal is completely legal but just too strong, disrupting the function
of the receiver or overriding the desired programming.

Our Example Filter


Hams often experience fundamental Filter Design Software
overload on the 160 meter band (1.8–2.0
MHz) which is adjacent to the AM broadcast There are quite a few software packages and services to choose from.
(BC) band (550 kHz–1.7 MHz). Antennas Some are stand-alone software you install on your PC and others run on a
for those frequencies pick up a lot of AM website (usually a company’s website). The supported filter designs can be
band RF, overloading the input circuits and active (op-amp based), passive (RC, RL, RLC), or both.
creating distortion or false signals inside Proprietary websites may only use components that are produced
the receiver. The usual solution is to install by that company, but if your filter doesn’t have extreme requirements,
a high-pass broadcast-reject filter at the you can often switch to equivalent parts by any company. An advantage
receiver input, attenuating the unwanted of proprietary design tools, generally, is that they take into account more
AM signals below 1.6 MHz while passing component characteristics and can help avoid trouble in high-performance
the desired 160 meter signals with little designs.
attenuation. Remember that simulator programs such as LTSpice (en.wikipedia.
So far, so good, but a filter that doesn’t org/wiki/LTspice) require that you come up with a design first. You have
attenuate signals very much above 1.8 to provide all the component values before determining how the circuit will
MHz while attenuating them significantly work.
in the adjacent broadcast band is not a FilterLab
simple thing to design. There are tables and www.microchip.com/developmenttools/ProductDetails/
equations, but they are tedious to work with. filterlabdesignsoftware (active)
Practically, you’ll need to build the filter with WEBENCH® Filter Designer
standard-value components as well, and that www.ti.com/design-tools/signal-chain-design/webench-filters.
will affect filter performance too. Sounds like html (active)
a job for some filter design software, doesn’t Filter Wizard
it? www.analog.com/designtools/en/filterwizard (active)
There are several filter design software
packages ranging from simple calculators AADE
to sophisticated CAD programs. Luckily for www.ke5fx.com/aadeflt.htm (passive)
hams and other experimenters, there are ELSIE
plenty of free or low-cost programs to try www.tonnesoftware.com (passive)
(see the sidebar). Filter Design and Analysis
In this column, I’ll illustrate the time- sim.okawa-denshi.jp/en/Fkeisan.htm (active, passive)
tested and free student version of ELSIE: RF Filter Design
Design software for passive filters made from www.iowahills.com/9RFFiltersPage.html (passive RF)
inductors (L) and capacitors (C); thus, the
12 September/October 2018
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/2018/09.

name, L-C. By stepping through a sample design, you’ll


get a feel for how to turn specifications like we discussed
in the last column into a real filter design.

Using ELSIE
Begin by downloading the current version of
ELSIE (2.82 as of mid-June 2018) from Tonne Software
(www.tonnesoftware.com). Follow the install wizard’s
instructions, then run ELSIE. Begin by clicking New
Design.
Now it’s time to tell ELSIE what kind of circuit you
want. This is the filter’s topology describing the general
arrangement of the filter components. (Filter basics were
covered in the previous column.)
Since we’re designing a broadcast-reject filter for
160 meter reception, we need a high-pass response. n FIGURE 1. The third-order AM broadcast-reject filter
ELSIE gives us two choices for high-pass filters: capacitive schematic and the design parameters used or calculated
input and inductive input. by the ELSIE program.
A capacitor in series with the filter at the input
(capacitive input) blocks any DC and low frequency show the general behavior for each family.
signals, so select that topology. For our filter, we need a very sharp rolloff that passes
Next, we must select from the many types of LC filter signals with little attenuation at 1.8 MHz, but with lots of
circuits called families — each with a slightly different attenuation at 1.6 MHz — the highest frequency of the AM
type of response. For example, the Butterworth family broadcast band at which full-power stations are permitted.
has a very flat response but a gradual roll-off between the (Above 1,600 kHz in the US, AM stations are limited to
passband and the stop band. The Chebyshev family allows 10 kW during the day and 1 kW at night. These smaller
some variation in the passband and stopband in trade for a stations are less likely to cause overload problems than the
steeper rolloff. full-power 50 kW transmitters.)
Bessel filters have a constant time delay through the Chebyshev would be a good choice, but the Cauer
filter in the passband. If you click the ? button next to family is even better at creating the necessary steep rolloff.
Butterworth in the Family section, a pop-up window will The tradeoff is that attenuation of the Cauer filters varies
quite a bit in the stopband. That’s okay, as long as we
maintain the minimum required attenuation. So, select
What is Q? Cauer as the filter family.
Now, the program needs some performance
Q is the symbol for “quality factor” and for inductors specifications entered at the right-hand side of the screen.
(L) and capacitors (C), it represents the losses in the How much attenuation (Stop Band Depth, AS, in dB) is
component. Q is the ratio of the component’s reactance (X) enough for our filter? In my experience, 40 dB is enough
to its resistance (R). The resistance accounts for all losses in to keep even nearby AM stations from clobbering a
the component, such as for skin effect, dielectric losses, and modern receiver. For Ripple Bandwidth (FC), enter “1.8M”
other parasitic effects. (1.8 MHz) as the lowest frequency of the filter passband.
The highest frequency at which we want our 40 dB of
Q=X/R attenuation, “1.6M” (1.6 MHz), is the Stopband width (FS).
Filter Order (N) can be thought of as the number of
A perfect L or C has zero resistance, so its Q is infinite. resonances created by pairs of L and C components. The
A perfect resistor, R, has no reactance, so its Q is zero! higher the order, the more components are required to
Typical values of Q for capacitors used in RF circuits are create the circuit. Start by entering a filter order of 3 to see
around 1,000. Inductors have Q values of 250 and below. if we can meet our design goals.
Try different values of Q for the components in your
design and watch for the effect in the simulated filter Viewing the Filter Response
responses.
To set up the program’s calculations and display
September/October 2018 13
PRACTICAL TECHNOLOGY FROM THE HAM WORLD

Analysis stop frequency of 10 MHz.


Leave all other selections and values
at their original default settings.
Before looking at the filter
response plot, click the Schematic
tab at the top of the screen to
show the information in Figure 1.
Passband ripple (21.3 dB) and the
component maximum/minimum
ratios are calculated by the program.
Now, click the Plot tab for the
frequency response graph of Figure
2. Place the cursor on the blue
response line and hold down the
left mouse button. At the bottom
of the screen, you’ll see the filter
performance at that frequency. The
figure shows performance at the
response peak of 1.93 MHz.
Move the mouse to the stop
band notch near 1.5 MHz to find
attenuation there (-69 dB at 1.49
n FIGURE 2. Frequency response of the third-order filter shows too much MHz). Attenuation varies by more
variation in attenuation across the 1.8-2.0 MHz 160 meter band and does not than 20 dB over the 160 meter band
meet the 40 dB attenuation requirement at 1.6 MHz. — that’s too much! A third-order filter
can’t meet our specifications, so create
configuration, click the Analysis tab. This is where the a higher-order filter. (While you’re at it, use the Design
inductor and capacitor Q are specified (250 and 1,000, window to select different filter families and compare their
respectively). Lower values of Q result in less stopband responses.)
attenuation and less sharp rolloff, among other effects.
Leave them at their default settings for this exercise.
Specify an Analysis start frequency of 0.5 MHz and an
Interactive Design
This is where the value of easy-
to-use design software becomes
apparent. Instead of re-starting a
laborious design process, simply
re-enter new specifications and try
again. Return to the Design tab and
increase the filter order from 3 to
4, then click Plot. Performance is
improved but attenuation still varies
by more than 10 dB across 160
meters.
Back at the Design tab, increase
the filter order to 5, resetting FS to
1.6 MHz. (The program changes
some values when order is changed.

n FIGURE 3. Frequency response


of the fifth-order filter meets
the broadcast band rejection
requirement with only 3 dB of
variation in the 160 meter band.

14 September/October 2018
Check your settings whenever you
change filter order.) This response
(Figure 3) is much more useful.
Attenuation varies by about 3 dB (1/2
S-unit) across the 160 meter band,
and we just meet our design goal with
-40 dB of attenuation at 1.59 MHz.
Click the Save tab to hold on to this
design version before proceeding.
Imagine doing this in the “good
old days” before the desktop PC
became a commodity! For each
design, detailed calculations would
have to be worked out with a calculator or n FIGURE 4. The schematic of the fifth-order filter after standard 5%
series component values are substituted for exact calculated values. Filter
slide rule at numerous frequencies, then
performance is substantially unchanged from the exact value version.
plotted on graph paper if reviewing the full
response was necessary. Today’s process
takes seconds and allows a lot of “what if” experimentation no tuning to provide useful performance.
that was impractical before.
Testing a Real Filter
Standard Value Components After publishing this design in QST (January 2016
The schematic shows all the component values are issue), I received an email from Scott Roleson KC7CJ who
in a reasonable range. Nevertheless, I don’t think your built a very nice version of the filter, shown here in Figure
local component vendor will have, say, 538.436 pF 5. He used a sturdy die-cast aluminum box, even making
capacitors in stock, nor do you want to have to adjust the PCB (printed circuit board) from scratch. The capacitors
variable capacitors. Now is the time to redesign the filter are silvered-mica with a 5% tolerance. For the inductors, he
using standard fixed-value parts. This will degrade filter used miniature encapsulated components.
performance a bit, but remember that we can continue to Roleson created an interesting way of bypassing the
work with the design. filter. Using individual SPDT subminiature toggle switches
Return to the Design window and click the Nearest at the input and output avoided a multi-pole switch that
5% tab. You’ll be presented with several options, including might have allowed unwanted signals to “leak” from the
changing all the components to the nearest standard value filter’s input to the output through internal capacitance.
in the 5% series. A piece of aluminum rod has a hole in each end that slips
Other options include just changing the capacitors or over the switch handles so that both are moved together
inductors, assuming you’ll wind the Ls
or tune the Cs. You can also change
just the capacitors or inductors, and
the program will re-calculate the
remaining values exactly so that you
can tune up the filter yourself.
Let’s take the easy way out
and select the first option to use all
standard values. Return to the Design
tab, then check the schematic shown
in Figure 4. How about performance?
Viewing the frequency response, not
much has changed.
We have a little more variation
across the band (now 4 dB), but
attenuation at 1.6 MHz is still the
same, only failing to reach 40 dB
below 840 kHz by less than a dB. This n FIGURE 5. KC7CJ’s homemade version of the BCI filter.
design can be built with off-the-shelf components requiring
September/October 2018 15
AM broadcast-reject filter. His version is receive-only and
uses components rated for low power. The commercial
filter is rated for 300 watts and can be installed in the
output of a regular transceiver.

Stopband Attenuation
In Figure 6, you can see there are deep notches
in the filter’s stopband. (Compare the as-built filter to
the predicted performance in Figure 3 — an important
verification step.) That’s okay — we selected a filter family
(Cauer) that obtains a steep rolloff by placing notches at
strategic frequencies. However, it’s not realistic to give
the attenuation of those notches (51, 63, and 58 dB
right-to-left) as the filter’s ability to reject AM broadcast
n FIGURE 6. The input-to-output amplitude response (S21) (BC) signals.
of KC7CJ’s filter. The vertical scale (shown in blue at the The stopband attenuation of this filter is measured
upper left) is 10 dB/division. The reference level at the top at the maximum of the two peaks in the stopband, 39
of the graph is 20 dBm. The frequency range is from 1 kHz
dB of attenuation at about 750 kHz. Did this amount of
(given as “0” where a low-frequency artifact is shown) to 10
MHz at 1 MHz/division. “MC” refers to a Master Calibration attenuation satisfy the original design specification for 40
file having been applied to the measurement. The VNA dB at 1.6 MHz? There is plenty of attenuation at 1.6 MHz
output (TX level) has been attenuated by 10 dB. due to the notch placed there but across the entire BC
band, we just barely missed by about 1 dB. Pretty good,
nevertheless.

Insertion Loss
A close look at the filter’s response shows that
the shape is very close to what ELSIE predicted, right
down to the passband ripple between 1.8 and 4
MHz above the filter’s cutoff. Roleson’s filter rolls
off a little higher than expected, hitting 10 dB of
attenuation at 1.8 MHz. Since this is a receive-only
filter, that extra 7 dB of attenuation at 1.8 MHz (we
only wanted 3 dB) isn’t a serious deficiency and the
filter will work fine.
As the response flattens out, we can see there
is about 3 dB of attenuation between 4 and 5 MHz.
Similar to how we measure stopband attenuation,
n FIGURE 7. The frequency response of a commercial BC-reject this “worst case” attenuation in the filter’s passband is
transmitting filter. Graph scales are the same as for Figure the filter’s insertion loss.
6. S21 is the filter’s input-to-output response; S11 (Return In Figure 7, you see a very different filter response
Loss) shows the power reflected by the filter at its input and (the blue trace) for the commercial filter. Because it’s
represents input impedance. The filter’s internal construction is expected to be used at 100 watt power levels or higher,
shown in the inset.
insertion loss must be minimized. From the inset photo
of the filter components, you can see that larger toroidal
— simple! Inside the filter, Figure 5 shows the short piece inductors are used. These have far lower resistance than
of 50 Ω coax that routes signals around the filter in the the molded components used in the receive-only filter that
BYPASS position. are wound with very fine wire.
I set up my vector network analyzer (VNA) to measure The commercial filter’s insertion loss is less than
his filter’s input-to-output attenuation from 1 kHz (referred 0.5 dB from about 2.2 through 10 MHz. The tradeoff is
to as “zero” frequency) through 10 MHz. Along with the steepness at which the response rolls off. While the
Roleson’s version of the filter, I also tested a commercial commercial filter has very good attenuation (70 dB) at
16 September/October 2018
PRACTICAL TECHNOLOGY FROM THE HAM WORLD

low frequencies, it doesn’t reach our


required attenuation of 40 dB until 1.25
Receiving versus Transmitting Filters
MHz, which is well inside the BC band. Receiving filters only have to handle signal levels of a few volts at most.
This is a consequence of selecting the
Signal powers are measured in milliwatts. If the small components used have a
different filter family, requiring extra
bit of loss, that usually doesn’t have a big effect unless the filter is intended to
components to construct. Sometimes
be very “sharp.”
you just have to compromise!
Transmitting filters, on the other hand, require components that can handle
hundreds (or thousands) of volts and high currents of several (or dozens of)
Filter Wrap-up amps. The skin effect of an inductor’s wire — constraining current flow to a thin
layer along a conductor’s surface — becomes a significant concern because
I hope you enjoyed this short tour
it raises the resistance of the component. Dielectric loss in a capacitor has the
through filters and filter design. Filters
same effect. In both cases, the extra resistance dissipates power.
are one of the most important and
Before building a filter that will be connected to a transmitter output,
widely-used circuits in all of radio at any
study filters made for that frequency and power level to learn what types of
frequency. Understanding how they
components are used. Also study how the filter is constructed and whether the
are specified and used will make you a
components require cooling or special orientation to avoid coupling between
better electronics designer, whether you
them.
build your own or simply buy them from
a vendor.
You’ll find a lot more information about filters for all The International Microwave Handbook. Many hams who
frequencies in the various amateur radio publications, such have gone on to engineering careers got their start with
as the ARRL Handbook and for VHF/UHF/microwaves in these two books.
the excellent book from the Radio Society of Great Britain, Dive in. The water’s fine! NV

September/October 2018 17
PRODUCTS
■ HARDWARE
■ SOFTWARE

NEW
■ GADGETS
■ TOOLS

FLEXRES can display up to a million cycles. development kit enables users to

O’SCOPES Serial decoding and analysis is


included as standard. Decoding helps
write their own applications for the
PicoScope 5000D hardware. Drivers

P ico Technology has now


introduced the
PicoScope 5000D Series
users to see what is happening in for Microsoft Windows, Apple Mac
(macOS), and Linux
(including Raspberry Pi
FlexRes oscilloscopes and Beaglebone) are
and MSOs that feature included. Example code
up to 16 bits of vertical (hosted on the Pico
resolution with up to 200 Technology GitHub
MHz bandwidth and 1 pages) shows how to
GS/s sampling speed. interface to third-party
FlexRes hardware employs software packages such as
multiple high-resolution Microsoft Excel, National
ADCs at the input Instruments LabVIEW, and
channels in different time- MathWorks MATLAB, and
interleaved and parallel programming languages
combinations to optimize like C, C#, C++, and
either the sampling rate Visual Basic .NET.
to 1 GS/s at eight bits, PicoScope 5000D
the resolution to 16 bits Series oscilloscopes are
at 62.5 MS/s, or other priced from $1,155 for the
combinations in between. 5242D two-channel 60
PicoScope 5000D MSO models their design to identify programming MHz model through to $3,025 for the
add 16 digital channels, providing errors and check for signal integrity top-of-the-range 5444D four-channel
the ability to accurately time- issues. 200 MHz mixed-signal model.
correlate analog and digital channels. PicoScope 5000D Series
Digital channels may be grouped oscilloscopes feature a SuperSpeed For more information, contact:
and displayed as a bus with each USB 3.0 connection, providing Pico Technology
www.picotech.com
bus value displayed in binary, hex, lightning-fast saving of waveforms
decimal, or level (for DAC testing). while retaining compatibility with
Advanced triggers can be set across older USB standards. The PicoSDK®
both the analog and digital channels. software development kit supports
TEMPERATURE
PicoScope 5000D Series continuous streaming to the host SENSORS
oscilloscopes also have waveform
capture memory up to 512
megasamples. Deep memory
computer at rates up to 125 MS/s.
PicoScope software takes
advantage of modern PC processing
L OGIC CONTROLLED
TECHNOLOGIES is now
producing easy to connect with
enables the capture of long-duration power with an equation editor that DS18B20 temperature sensors
waveforms at maximum sampling allows users to define complex from Maxim Integrated Products,
speed. waveform mathematical functions. Inc. Coupled with a 3.5 mm stereo
PicoScope’s DeepMeasure™ These include filters (low-pass, connector, the DS18B20 is easily
tool uses the deep memory to high-pass, bandpass, and bandstop), interfaced with low-cost stereo wiring
analyze every cycle contained in trigonometry, exponentials, harnesses. This allows for quick and
each triggered waveform acquisition. logarithms, statistics, integrals, and inexpensive temperature monitoring
It displays results in a table, with the derivatives. Waveform maths can also
parameter fields shown in columns be used to plot live signals alongside
and waveform cycles shown in historic peak, averaged, or filtered
rows. The current version of the tool waveforms.
includes 12 parameters per cycle, and The PicoSDK software
18 September/October 2018
networks to be from indirect lightning
created in various strikes and power surges.
environments. Fairview Microwave’s
The price for each 45 new coaxial lightning
is $25. Volume and surge protectors were
discounts are designed to be used in Wi-
available. Fi networks, active antenna
LOGIC systems, cellular networks,
CONTROLLED GPS systems, and public
TECHNOLOGIES is also offering a safety communications systems.
waterproof version of the DS18B20 These new high
temperature sensors. The price for it performance RF coax surge
is $30 each. Volume discounts are protectors feature VSWR as low
available for it as well. as 1.1:1, max power as high as
2 kW, multi-strike capability, low
Iron Pi CM8 insertion loss, and are available
with Type-N, 4.3-10, and 7/16
DIN connectors. The new
models are CE and RoHS compliant These pocket-sized analyzers
and support frequency ranges from capture and decode the widest range
DC to 6 GHz. of USB 2.0 device classes plus Type-C
For more information, contact: link states and Power Delivery 3.0
Fairview Microwave messages. Both the Mercury T2P and
www.fairviewmicrowave.com T2C utilize the industry leading CATC
Trace analysis software for verifying
and debugging USB and PD protocol
In addition, LOGIC issues.
CONTROLLED TECHNOLOGIES
T2C/T2P USB 2.0 Power Tracker is a versatile
has partnered with JCore Systems ANALYZERS power analysis tool for testing power
LLC as a distributor of their cloud
connected hardware — the Iron Pi —
and services.
S aelig Company, Inc., has
announced the availability of
the new Teledyne LeCroy Mercury
delivery protocols and guides USB
Power Delivery (PD) designs to
safely provide appropriate charging
Use of the Iron Pi hardware T2P and T2C USB 2.0 analyzers, low currents across a growing range of
allows connect inputs and outputs cost, robust USB Type-C protocol USB devices. The Power Tracker
to be controlled and monitored from analyzers with upgraded VBUS tool monitors the real time voltage
the cloud. The Iron Pi combines (power) analysis, and optional support and current on VBUS, VCONN, and
a Raspberry Pi compatible core for DisplayPort™ Auxiliary channel the USB Type-C Communication
with hardware built for the rigors of message decoding. Channel (CC), and it displays voltage
industrial computing. Because the They offer full support for and current in a histogram format as
Iron Pi software is open sourced, USB 2.0 protocol testing and adds well as simultaneous synchronized
you’ll be able to create your own advanced USB Type-C analysis message level traffic.
custom solutions. The Iron Pi capabilities. There are two base These advanced analysis
hardware is available for $800. models: the Mercury T2C and the capabilities come in a low cost/high
new Mercury T2P, which adds the quality device that includes the widely
For more information, contact: Power Tracker™ graphical analysis of implemented alternate mode (Alt
LOGIC CONTROLLED VBUS and CC voltages. Mode) of Type C - DisplayPort (DP).
TECHNOLOGIES
www.logictechs.com

COAXIAL SURGE
PROTECTORS
F airview Microwave, Inc., has
recently introduced a new family
of coaxial surge protectors that were
developed to protect wired and
wireless communications equipment
September/October 2018 19
The Mercury T2P offers the ability from classic to modern sounds to
to capture and decode DisplayPort create music in any genre. First-time
Auxiliary channel messages, including synth users get instant gratification
configuration messages, enabling DP from this easy-to-use instrument
connectivity troubleshooting. with 100 presets and an easy-to-play
Power Delivery 3.0 protocol keyboard with selectable scales and
capture is also available as a licensed an arpeggiator.
option. This mode provides full While UNO Synth is
analysis and decoding of all PD monophonic, its two independent
packets over the CC link including oscillators can be tuned differently to
Source/Sink communication, generate interesting pad-like interval
Authentication, Firmware Update, and sounds and octaves. Pulse-width
Alt-Mode commands. modulation of each oscillator offers
advanced modular-style timbres from
For more information, contact:
a higher torque alternative to their classic synths.
Saelig Company
www.saelig.com popular precision spur gear motors. The UNO Synth keyboard also
These motors come equipped doubles as a step-edit control for
with relative quadrature encoders for its built-in 100-pattern sequencer.
closed feedback loop speed control Sequences can be programmed
3/8” X-RAIL or position control applications. You in real time or in steps (with
GUSSET can also just supply power to the modulatable synth parameters per

S ervoCity now has available 3/8”


X-Rail gusset for $3.99 (two-pack).
These 90 degree aluminum brackets
motor wires for more simple builds
that only require speed control.
step).
In addition to a built-in delay
effect, five instant performance
For more information, contact:
are an excellent way to create or beef modulations are also available (Dive,
ServoCity
up joints when using X-Rail. www.servocity.com Scoop, Vibrato, Wah, and Tremolo)
for added real time playability and
instant dynamic expression during
HARDWARE performances.
SYNTHESIZER UNO Synth’s ultra-compact
dimensions make it among the
smallest monophonic
synths available. Its
light weight (only
400g) and battery
power (4xAA
included) or USB
power supply (for
battery power banks)
give musicians the
They measure 3/8” from the freedom to make
mounting surface to the center of the music anywhere.
mounting hole so that you can fasten MIDI IN and
two overlapping pieces of X-Rail OUT enables
to one another, or you can make a connection to a
more conventional 90 degree joint IK Multimedia’s first hardware master keyboard or any MIDI gear for
by placing two X-Rail pieces on the synthesizer — the UNO Synth — use in a live or studio rig as a sound
same plane, extending in opposite is now available. Designed for module.
directions. everyone interested in rich, true Via USB MIDI, UNO Synth also
analog sound, this monophonic synth conveniently integrates directly with a
offers a wide sound palette and easy DAW running on Mac/PC computers
SPUR GEAR programmability in an ultra-portable or mobile devices, without additional
MOTORS battery-powered format for on-the-go hardware interfaces.

A lso now available from ServoCity


are spur gear motors with
encoders, priced at $26.99.
music creation, live performance, or
studio recording, all at an affordable
price of $199.99.
For more information, contact:
IK Multimedia
The 5200 Series gear motors are UNO Synth delivers everything www.unosynth.com
20 September/October 2018
BUILD IT YOURSELF

Build a Customizable Musical

DOORBELL By Larry Cicchinelli

When my wife and I moved into our current home a few years back, it didn’t
have a doorbell. We live on a quiet cul-de-sac, so it really wasn’t a problem
as we had few callers. After a while, I installed a wireless doorbell that lasted
about three years. Recently, after writing the series of articles on “A Digital
Analog — When a PIC Can Replace a 555,” I decided to make one using a PIC.

T he unit I implemented can be operated in either of


two modes:
sequence. Closing any one of the four switches will apply
power to the processor. Once the PIC is turned on, the
software turns on Q2 which keeps the power on even
1. Select from among eight different tone sequences if the switch is released. If the diodes are NOT installed,
from a single doorbell switch. the operation is such that switches 0 through 2 are now
2. Up to four doorbell switches, each with its own tone jumpers. They are decoded to determine which of eight
sequence, for different doors/locations. tone sequences is played when Sw3 is closed. Only closing
Sw3 will turn on Q1.
A combination of the two can be implemented if you The three inputs of the PIC have their weak pullups
want to modify the code provided in the article downloads. enabled; the software will invert the state of switches 0
through 2 after reading them. So, in this case, grounding a
switch creates a logical one.
Circuit The output circuit is a simple common emitter driving
The circuit for the doorbell can be seen in Figure 1, the speaker. The PIC can drive up to 20 mA, but that’s not
and is relatively simple. If diodes D0, D1, and D2 ARE enough to get a reasonable volume from a speaker.
installed, then up to four switches can be used to indicate The speaker I used is rated at 2W and its 92 dBA is
up to four different locations — each having its own tone loud enough for our rather quiet home. Since it’s 8Ω, the
22 September/October 2018
Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/
magazine/issue/2018/09.

maximum power applied to it will be about 1.26W with a add an external power transistor if you need lots of volume.
4.5V supply. Note: The RMS voltage of a 0V based/50% If you look at the board layout in Figure 2, you can see
duty cycle square wave is that the speaker connections are quite close to both the
battery pins as well as Q3. This was done deliberately to
Vrms = Vpk ÷ √2 keep the high current path of the speaker away from the
rest of the circuit.
Refer to https://masteringelectronicsdesign.com/how- Note that the current for the speaker does not go
to-derive-the-rms-value-of-pulse-and-square-waveforms for through Q1. This was done because I didn’t want the high
more details. current to be switched by Q1. My first design had the
The PN2222 can drive a larger speaker if you need current go through it, which created a problem. Due to
more volume. I used the PN2222 instead of a newer
transistor (such as the 2N3904) because the PN2222
can handle more collector current: 1A vs. 200 mA. R5 is
present because there is very little volume until you reach
about 2.5V driving the base resistor.
If you use a more powerful speaker, you may want
to decrease the value of R5, or eliminate it completely by
replacing it with a jumper. If you need more sound output,
a larger speaker will work, but I would not use one less
than 8Ω.
I tried a speaker I have with taps for 40Ω, 20Ω, and
10Ω. The speaker (about 30 years old with no power rating
on it) is 5” x 7” and was quite loud using any of the three
taps, with the 10Ω tap being the loudest. I recommend
that you use a diode across the speaker input since most
speakers present an inductive load.
You can also use a higher voltage supply for just the
speaker. You’ll still need a lower voltage for the PIC; it will
operate anywhere between 2.5V and 5V. You’ll need to be
careful that you don’t cause the PN2222 to dissipate too ■ FIGURE 2.
much power. Its spec is about 0.6W. Of course, you can

■ FIGURE 1.

September/October 2018 23
■ FIGURE 3.
above the board. Since jumpers 0, 1, and 2 are
not installed, I’m using sequence 0.

Software
The software is very much table-driven.
There are three tables that the program uses:

1. Frequency of available notes


2. The notes to play for a sequence
3. Which sequence to play

The table of the notes looks like this:

C4 dw HIGH .137, LOW .137 ;262


D4 dw HIGH .154, LOW .154 ;294

C4 and D4 are the label references for


the two notes shown; dw is the assembler
directive to store a word or words at the
current memory location. HIGH and LOW are
the assembler syntax that selects the high byte
and low byte of the value to be stored. (Even
though the program memory is 14 bits per
the higher current used by the speaker, the voltage on the location, only eight bits can be accessed using memory
output of Q1 varied enough to cause the circuit to function read commands.) The comments show the frequency of
erratically. I would have had to lower the base resistor the note for the entry.
considerably if I wanted to keep that design. The value stored must be the desired frequency
I found that with the final version of the circuit, I could multiplied by 0.524, which is due to the accumulator
not measure the current draw with my meter (Fluke 79). length of the NCO and the frequency of the CPU clock
I put a 1K resistor in series with the supply and there was driving it. There are comments in the source code that
less than 1 mV across it. So, the current must be less than 1 explain this more fully. The frequencies used in the table
µA when the system is off. for the notes were obtained from https://en.wikipedia.org/
All the parts are thru-hole with no SMDs (surface- wiki/Scientific_pitch_notation.
mount devices). Resistors R1 and R2 were mounted The table must be completely within the first 256 bytes
vertically to save board space. The volume control, R4, is of program memory. This allows the sequence lists to use a
mounted close to the edge of the board for convenience single byte entry for the address of each note to be played.
and is a vertically mounted trim pot with a “thumb wheel” The table can be expanded to cover as many notes as you
adjustment. You can mount a horizontal trim pot instead to may need, provided you stay within the 256-byte limit.
have a side adjustment. There is a conditional assembly directive following
I mounted the PIC (U1) in a socket, but you don’t the table which will cause a warning message if the table
have to do that. I used 1N914s for the diodes since I had becomes too big. The table can be increased beyond this
a supply of them, but almost any signal diode (such as 256-byte limit as long as you make the appropriate changes
1N4148s) will do. in the routine that accesses them, as well as the entries in
As you can see from Figure 3, the board is quite small: the table described next.
1.3” x 1.3”. I soldered the wires for the speaker directly to Within the table is an entry for MC_NOTE. This is the
the board instead of using a connector. The white dot to note I use for those sequences for which I have not defined
the left of the B1 connector is a score from a silver marking a song or other sequence. The notes I have entered are the
pen (which I always use to indicate the positive connection Morse Code dots and dashes representing the number of
of the power supply). the sequence (1..7) based on Sws 0-2.
The board is light enough that I used a single 2-56 The next table contains the lists of notes used for the
mounting bolt and standoff to attach it to the housing. sequences of the eight possible states of Sws 0-2. This is an
There is room enough for the three AA cell battery holder example for sequence 0 (Sw3 closed, Sw0..2 open):
24 September/October 2018
Sequence_0 ; Amazing Grace - 1st line note has a specific number. All the rest are multiples of
dw D4, QUARTER EIGHTH. The definition for the eighth note essentially
dw G4, HALF specifies the tempo of the notes being played. The current
dw B4, EIGHTH definition is 0.25 which equates to 250 milliseconds.
dw G4, EIGHTH The last table contains the addresses of the eight
dw B4, HALF sequences as follows:
dw A4, QUARTER
dw G4, HALF Sequence_Table
dw E4, QUARTER dw LOW Sequence_0, HIGH Sequence_0
dw D4, HALF ...
dw 0 ; terminate the list dw LOW Sequence_7, HIGH Sequence_7

Here’s the list showing the Morse code notes for Upon power-up, the program first initializes the
sequence 1: hardware and then reads the switches. It inverts the state of
the switches and doubles the value since each entry in the
Sequence_1 ; .---- Sequence table is two bytes, and saves it for processing.
dw MC_NOTE, DOT The main loop of the program starts by turning on Q2
dw REST, DOT which latches Q1 on so that even if the doorbell switch is
dw MC_NOTE, DASH released, the power will stay on. Next, it uses the stored
dw REST, DOT switch value to determine the address of the sequence to
dw MC_NOTE, DASH play. After playing the sequence, it turns off Q2 allowing
dw REST, DOT power to be removed from the processor if the switch has
dw MC_NOTE, DASH been released.
dw REST, DOT The program will execute the main loop up to three
dw MC_NOTE, DASH times as long as a doorbell switch is closed. If the switch is
dw REST, DOT still closed after the third time, the program lowers the CPU
dw 0 frequency and executes a one instruction loop forever — or
until the switch is released and power is removed from the
Each list contains two values for each note to be PIC.
played: the low byte of the address of the note from the The Parts List doesn’t include the batteries (I’m using
previous table, and the length of the note. The length is three AA cells), printed circuit board (PCB), or housing.
essentially the number of milliseconds to play the note. The The battery, speaker and Sw0-3 are set up to use .1” pin
DOT is defined as an EIGHTH and a dash is 3*DOT. headers and sockets if you wish, but they aren’t necessary
The note lengths are definitions. Only the EIGHTH (and also are not in the Parts List).
I purchase most of my parts from Digi-Key
Description Value Name Quantity since I typically send a check with my order
Battery Holder BC3AAW-ND 1 so that shipping is free. If you use this service,
C1 10 nF 399-4148-ND 1 please be sure to include any applicable state
taxes.
D0, D1, D2, D3 1N914 1N914BCT-ND 4
Both the schematic and board layout were
Q1 2N3906 2N3906D26ZCT- 1 done using DipTrace (www.DipTrace.com).
ND
There’s a free version available on their website
Q2 2N7000 2N7000TACT-ND 1 which will handle this circuit quite easily.
Q3 PN2222 PN2222ATACT-ND 1 So, there you have it. A simple,
R1, R3 47K 47KQBK-ND 2 customizable doorbell. Now, it’s your turn to
chime in! NV
R2 10K 10KQBK-ND 1
R4 5K 3352W-502LF-ND 1
R5 4.7K 4.7KQBK-ND 1 If you would like to build this project and want
R6 560 560KQBK-ND 1 a single board, you can email me at k3pto@
Spk1 8 ohms 102-3544-ND 1 arrl.net. If you want three boards, you can
U1 16F18313 PIC16F18313-I/P- 1 order them directly from OshPark: oshpark.
ND com/profiles/K3PTO.
September/October 2018 25
BUILD IT YOURSELF

Build the MIDI Replay


STOMP BOX By Jeremy Leach

As the last notes of the song ring out, it’s only seconds before the next song
starts. You’re the band’s keyboard player and a bead of sweat is on your brow
as you quickly glance at the set list, pick the instrument settings, remember to
transpose, tweak the volume, set the keyboard splits, and then begin to play.
You make it but only just!
A look from the impatient
drummer says it all! As the
song continues, your mind
wanders to how you wish it
was all easier ... how you’ve
always wanted to add some
strings and bass to the song
but can’t ... the frustration
of only having two hands ...
(cue dream sequence).

■ FIGURE 1.The MIDI Replay Stompbox.

T he MIDI Replay Stomp Box (fondly shortened to ‘the


Box’) is born from this very experience and more
than delivers on the dream. It is both a MIDI configuration
tool for applying a song’s keyboard settings, plus a four-
track recorder providing accompaniment for songs. Other
features include foot-switch control, looping, transpose,
keyboard splits and layers, a metronome, plus syncing data
with its own PC desktop app and writing to standard MIDI
files.
Figure 1 shows the Box in Performance mode; Figure
2 in Edit mode; and Figure 3 looks inside the Box.
At the heart of the system is a PIC16F648A
microcontroller, with its main job being to process MIDI
messages. Data is stored in an external battery-backed
■ FIGURE 2.The Box being used in Edit mode.
26 September/October 2018
Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/
magazine/issue/2018/09.

■ FIGURE 3. Opening the Box.


■ FIGURE 4. How the Box is used.
SRAM (Static Random-Access Memory). Three other
microcontrollers handle the user interface, foot-switch How It Works — Plug and
control, and metronome. All microcontroller software is
written in C, using Microchip’s MPLAB IDE (integrated Play
development environment) and the XC8 compiler. The Box simply interfaces to any MIDI compatible
keyboard instrument via two MIDI cables in a loop-back
MIDI — The Enabler that’s Taken for Granted configuration. This is shown in Figure 4.
Keyboard instruments have a keyboard controller
It’s likely you have heard of MIDI (Musical Instrument and tone generator inside. The keyboard controller
Digital Interface). It lets musical and computing devices recognizes all user input via the keys, buttons, sliders, and
communicate in a common language, and has existed so forth, then sends the relevant MIDI messages to the
since the 1980s. However, it seems there is little tone generator which creates the sounds. This is called
acknowledgement or reflection on what a profound
local control and is usually a setting accessible via the
‘enabler’ MIDI has been.
It’s staggering what MIDI has done for music. Any keyboard’s configuration screen.
post-70’s pop song is likely to have involved MIDI. Music Local control must be turned off when the Box is
‘sequencers’ which tie all the tracks of a song together all used. The Box receives MIDI messages from the keyboard
use it. Almost all musical keyboards and devices have MIDI (keyboard controller) and sends messages back (to the
sockets that let them talk to each other. tone generator). The flexibility of MIDI means you are
The underlying concept of a ‘common language’ is so not limited to using the internal tone generator and can
powerful. Human evolution exploded because of it. This connect to other sound modules or keyboards if you wish.
project wouldn’t be possible without it. When the first, With a set list of songs loaded on the Box, you tap a
beautiful, musical score of a recording effortlessly ‘fell out’
foot-switch to configure the keyboard for a song. Another
of the MIDI Replay Box via a sequencer, it seemed like a
click, and the Box plays a section of recorded backing to
‘free lunch’ — too good to be true!
MIDI is also profound in that it’s about the ‘control’ accompany your real time performance. A ‘Life on Mars’
of music rather than the ‘audio’ itself. It’s like recording example MP3 is available with the article downloads and
the actions of the musicians rather than the sound they has been recorded on the Box. The piano track can be
produce. That’s clever: You can edit notes, durations, muted, and the strings used as backing.
tempo, transpose, even instruments used — all without The Box has a Performance mode (Box on the floor)
having to re-record anything! Plus the storage of ‘actions’ and an Edit mode (Box on the desktop or keyboard-top).
is tiny compared to recording audio. Editing is via buttons and performing is via foot-switches. In
September/October 2018 27
■ FIGURE 5.The ■ FIGURE 6.The
logical diagram. musical diagram.

Performance mode, the display is in large font. between the two is inter-woven in real time.
The MIDI controller contains a Song Manager and
Note Processor with supporting memory and timer. The
Logically Speaking — A memory stores notes and song configuration data. The
Dynamic Duo timer controls beats and song position.
Figure 5 shows the logical system diagram, consisting The user interface has buttons and a display, plus
of a user interface and MIDI controller. Communication a metronome with speaker, headphone output, and
associated volume control. The metronome
is used to give vital timing cues when using
backing.

Musically Speaking
— A Best Buddy
The musical diagram in Figure 6 gives
an overview from a musical perspective and
summarizes the ‘dream’ of the project. To
a musician, the Box makes life much easier
and presents exciting possibilities.
Internally, the Box contains song
settings and recordings. Each song has
four tracks on separate MIDI channels. For
each track, you can set the level, transpose,
instrument, and playable range.
In Performance mode, the language
of the Box is simply ‘songs,’ ‘sections,’ and
‘start/stop.’ Having the configuration of a

■ FIGURE 7. From Box to standard MIDI file


(seen through Anvil Studio).
28 September/October 2018
■ FIGURE 8. At the touch of a button:
Keyboard splits and ranges.

song taken care of at the click of a foot-


switch is quite a luxury!
Externally, the Box interfaces not only to
a keyboard but also to the MIDI Replay app
for Windows™.
Figure 7 shows a musical score
generated by a free sequencer called Anvil
Studio, from a track recorded on the Box.
Figure 8 shows an example of how ranges can be used
for splits and layers.

Design Challenges of a
Real Time MIDI System
So, how do we turn this logical and musical overview
into a reliable high-performance system? The stakes are
high because system failure mid-performance could be
very embarrassing!
This is a real time system with a demanding spec: The
notes a musician plays must be processed seamlessly and
without delay, applying range and transpose logic, echoed
out on selected channels, and possibly recorded. At the

Task Scheduling Strategies

In real time computing systems where a lot of tasks


need to be performed, task scheduling is important. This
is a complex subject with many variants. The simplest is
what’s called round-robin where there’s a loop and each
task in the loop is run one after the other; the loop then
repeats over and over. At the other extreme is a real time
operating system with complex features and operation
■ FIGURE 9.The physical diagram.
aiming for the minimal possible delay in execution.
The middle ground contains a round-robin with
interrupts. Interrupt routines deal with the very urgent
same time, any previously recorded tracks might also play
needs of the hardware and then set flags. The main loop back. We know that ‘without delay’ is not possible. The
polls the flags and does any follow-up processing required key words that come to mind are latency, accuracy, and
by the interrupts. precision. For a good musical experience, latency must
An example might be incoming UART data that if left ideally be 10 milliseconds or less, timing accuracy similar,
too long could be overwritten by the next incoming data notes must never ‘stick,’ and the user interface must be
byte. The time-critical task of retrieving the data is handled snappy and reliable.
as soon as the interrupt fires by moving the data byte into It helps to think about a likely worst-case scenario
a circular buffer. However, processing the data byte is rather than an absolute worst-case. For example, a likely
usually what’s called a ‘soft’ real time requirement and can worst-case recording scenario is not tripping onto the
be handled later by the main loop when it gets around to it. keyboard and playing every note simultaneously! Rather it’s
Although it’s useful to think of a robin hopping round probably recording 10 to 20 notes per second for ‘busy’
each task, Wiki tells us that the term actually dates from music, down to almost nothing for very sparse music.
the 17th century French ‘ruban rond’ (round ribbon), Taking this pragmatic approach, if we occasionally
describing the practice of signatories to petitions against drive the system beyond this likely worst-case and
authority (usually government officials petitioning the introduce additional hardly noticeable delay, then so be it!
Crown), appending their names on a document in a non- Suddenly, this project begins to look within the reach
hierarchical circle or ribbon pattern. of a modest mid-range microcontroller.
September/October 2018 29
■ FIGURE 10.The MIDI replay PCB.

MIDI replay PCB; a user interface PCB; and an


LCD display PCB. As in any electronics project,
the choice of each microcontroller is a balance
of many factors including: the tasks to perform;
the component cost; ease of use; features;
physical size; code capacity; and memory
capacity.
The user interface PCB responds to button
pushes and drives the LCD display. As a PCB, it’s
relatively simple. It also holds the overall voltage
regulator for the system.
The LCD display PCB contains a standard
20x4 character display and uses the ubiquitous
Hitachi HD44780 LCD controller. The interface
to the PCB is parallel to improve performance.
The MIDI replay PCB is worthy of greater
discussion.

The MIDI Replay PCB


The Physical Design — the Core Module
The end result after much thought and practical This is the core of the system and is a module by
consideration is the physical design depicted in Figure 9. design, so it can be used in other systems. A photo of the
The design has three printed circuit boards (PCBs): a PCB is shown in Figure 10.
The PIC16F648A processes everything MIDI
related. An associated 20 MHz crystal drives its
clock at full throttle. A 23LCV512 high speed
battery-backed SRAM device is used to store note
data and song configuration data. Two smaller
PIC12F683s process the foot-switch messages
and the metronome beats. A 6N138 opto-coupler
shapes the incoming MIDI signal into a digital
waveform.
Finally, an audio circuit filters and outputs the
metronome Pulse-Width Modulated (PWM) ‘beats’
via a piezo speaker and headphone socket.
Apart from MIDI, all communication with the
board is via commands that control recording,
playback, and other functions. There are 26
commands in total. The communication protocol
is straightforward and can be bit-banged from any
microcontroller.
The full circuit diagram is provided with the
article downloads. You’ll notice that there are three
MIDI outputs (each with double-inverter buffers).
Having three is useful if you want to output to
multiple physical MIDI devices.
If you don’t need foot-switch control and a
metronome, then the minimum circuit is simply

■ FIGURE 11.The MIDI controller chip — very busy


PIC!
30 September/October 2018
a PIC16F648A with associated crystal, SRAM,
optocoupler input, and double-inverter output (or Resources
equivalent).
History of multi-track recording
https://en.wikipedia.org/wiki/History_of_multitrack_recording
The PIC16F648A Bruce Springsteen’s Nebraska albums made on a four-track
MIDI Controller — A Portastudio
http://tascam.com/news/display/226
Very Demanding Boss
Wiki’s comprehensive summary of MIDI
This chip has a very difficult job to do and https://en.wikipedia.org/wiki/MIDI
needs to work like greased lightning. Figure 11
provides an overview. In many systems, you would SparkFun’s very readable summary of MIDI
expect the user interface to be the master, but https://learn.sparkfun.com/tutorials/midi-tutorial/all
here this MIDI controller chip is the ‘boss’ out of
necessity. Harmony Central’s fascinating history of MIDI
www.harmonycentral.com/articles/a-brief-history-of-midi
The USART (Universal Asynchronous Receiver-
Transmitter) receives and transmits MIDI data via The MIDI Association’s summary of MIDI messages
FIFO (First in First Out) buffers in internal RAM. https://www.midi.org/specifications-old/item/table-1-summary-of-
The ISR (Interrupt Service Routine) handles the midi-message
reading and writing to the buffers. Separate to this
is the main program loop that runs a variety of A review of embedded scheduling techniques
https://www.embeddedrelated.com/showarticle/969.php
tasks.
The thing that matters above all else in A general overview of memory management
our system is that we must never ever lose any https://en.wikipedia.org/wiki/Memory_management
received data. The PIC16F648A has a one byte
receive register in the USART that receives the A nice explanation of interfaces and ‘encapsulation’ that can be an
MIDI data. As soon as this is filled, the byte must analogy of MIDI talking to all sorts of devices
www.eeng.dcu.ie/~ee553/ee402notes/html/ch01s04.html
be transferred to the receive buffer in RAM.
Otherwise, it will be overwritten. Kaiser Chiefs MIDI Tech tells of ‘MIDI Madness’ during live
Another essential is that any note messages are performance (at end of article)
handled accurately and promptly. If they are being https://www.soundonsound.com/people/roger-lyons-kaiser-chiefs-
recorded, then they must be time-stamped ideally midi-tech
within 10 milliseconds of the ‘real’ time to maintain
accuracy. If they are output (either echoed from Hitachi HD44780 LCD controller
https://en.wikipedia.org/wiki/Hitachi_HD44780_LCD_controller
the input or played back from recorded data), this
must be fast to avoid noticeable delay. Technically Overview of scheduling techniques
speaking, there’s a need for low jitter and low https://www.embeddedrelated.com/showarticle/969.php
latency.
All code has been carefully crafted and all Parallel and distributed computing
unnecessary steps eliminated while keeping overall https://en.wikipedia.org/wiki/Distributed_computing#Parallel_and_
distributed_computing
functionality. The ‘Pro’ (paid monthly) version of
compiler-optimization is used in MPLAB to ensure A Statistical Response-Time Analysis of Real Time Embedded
maximum speed (and minimum code size). Tricks Systems
such as bit-shifting instead of slower multiply https://ieeexplore.ieee.org/document/6424817
have been used. The PIC16F648A is driven at its
maximum operating frequency of 20 MHz. messages but only send one status message to indicate
It was decided to write all software in fully-optimized they are of type ‘note on.’ Running status can reduce note
C without any handwritten assembler. This was purely a data by a third, so is fully utilized in this design.
practical decision, realizing that highly optimized code can The MIDI controller PIC not only processes MIDI
still be extremely fast and much easier to write. messages, but also applies the logic of transposing,
The MIDI protocol has a trick up its sleeve called tempo management, and playable ranges. It adjusts
running status that lets you only send a status byte when recorded tempo using a timer1 pre-scalar lookup, plus
the status changes from the previous message. This means it communicates data with SRAM and interfaces to the
that, for example, you can send a string of ‘note on’ other microcontrollers! Because this chip is so busy and
September/October 2018 31
everything is time-critical, it must be the master.
Imagine being in a crowded restaurant with
friends and placing an order for drinks. The waiter
leaves, then later returns weaving between tables,
holding the drinks on a tray above his head. It
makes sense that he is in control, not you — even
though you’re the customer. He judges the time-
critical swerves and swoops to make it safely back
to your table.
The UI controller PIC must request to send a
message to the MIDI controller PIC, which when
ready acknowledges with a handshake. The MIDI
controller PIC controls the clock signal that ‘pulls’ in
the message and will possibly interrupt reception to
do other time-critical tasks.

Round-robin
Scheduling with
Interrupts
The type of scheduling used to manage tasks in
the MIDI controller PIC is called round-robin with
■ FIGURE 12. Spreading the load with parallel processing. interrupts. This is a scheme that balances the need
for simplicity against the demands of immediate real time
processing.
The main loop shown in Figure 11 can be thought
of as a spinning wheel, where each task on the wheel is
traversed in series (round-robin).
The ISR handles received and transmitted bytes,
routing them to and from associated buffers. The tasks are
simple and so critical that they are handled immediately in
the ISR.
The ISR also sets a flag when the timer ‘ticks,’ plus sets
the song position variable. However, the actual processing
of the tick occurs in the round-robin loop.

Beware the Buffer


Buffers are admittedly essential in many systems to
smooth demand peaks, but need to be used with caution
in real time systems.
They smack of procrastination: Doing things when it
suits you and alleviating the immediate stress. However,
this doesn’t help when there’s a tight schedule!
Also, putting things off can just postpone throughput
issues. If the rate of emptying water from a leaking boat is
less than the rate of water being taken on board, then the
boat will eventually sink!
The height of the boat is like the buffer size. In real
time systems, we must design for a shallow boat to ensure
tasks are completed promptly and must ensure we empty
water from the boat quickly! It’s easy to think all we need
■ FIGURE 13.Three different command ‘languages.’ to do is slap in big buffers to overcome real time issues.
32 September/October 2018
Spreading the Load with presses because they are relatively infrequent.
Parallel Processing — The MIDI controller sends beat messages to the
metronome controller. Because of pin shortages on the
Working as a Team PIC16F648A, we cheekily piggy-back an LED pin. Because
The MIDI controller PCB also has true parallel the ‘play’ LED is synchronized with the beat, we send
processing to improve throughput. Figure 12 gives an a very short three-time-slot burst of signal at every beat
example of what each processor is doing at a snapshot in transition. This signal is invisible to the eye.
time; the MIDI controller is midway through processing a Lastly, the MIDI UI controllers communicate using
received note. At the same time, the foot-switch controller standard SPI (bit-banged) that has an additional initial
is listening for a foot-switch press; the metronome handshake. Before comms start, the sending device flags
controller is listening for a ‘beat’ command; and finally, the that it wants to send, then waits for a handshake. The MIDI
UI controller is busy updating the display. controller is always the SPI master.
Parallel processing needs efficient inter-processor
communication. This system uses three protocols (shown
in Figure 13), each one carefully designed for their unique
SRAM and Dynamic
purpose. Memory Allocation — The
The foot-switch controller sends commands to the
MIDI controller via a burst of pulses, with the pulse width
Memory Game
representing the command. This is a single-pin solution A movie theater can’t just allocate seats sequentially.
without any handshaking. The presence of a pulse is If people cancel their bookings, the ‘holes’ must be filled
polled by the MIDI controller. A batch of pulses is sent in if possible. The same goes for our SRAM data. We need
sufficient number to ensure the MIDI controller always what’s called Dynamic Memory Allocation (DMA).
receives the command. Figure 14 gives an overview of how SRAM is used.
After reception, the MIDI controller doesn’t listen If all we ever wanted to do is add data, then all would
again for a while. This system works well for foot-switch be easy. However, the reality is that we can delete songs

■ MIDI Replay schematic.

September/October 2018 33
Ref Des Name Value Notes
23LCV512 512 Kb SPI Serial SRAM with 23LCV512 Probably good idea to have an associated
Battery Backup DIL socket in case RAM ever needs replacing
(although it shouldn't).
74LS04N Hex Inverter DM74LS04N
B1 Horizontal Lithium Battery PCB Check pin spacing to ensure it fits with PCB
Mounted Holder for CR2032 holes.
Battery
C1 Capacitor 33 pF
C2 Capacitor 33 pF
C3 Capacitor 100 nF
C4 Capacitor 100 nF
C5 Capacitor, Non-Polarized 10 µF Important that it's bipolar because it needs
Bipolar electrolytic to cope with reverse voltage.
C6 Capacitor 100 nF
C7 Capacitor 100 nF
D1 Diode 1N4148
D2 Diode 1N4148
D3 Diode 1N4148
D4 Diode 1N4148
FOOTSWITCH Footswitch Microcontroller PIC12F683_P Recommend an associated DIL socket so that
this chip can be reprogrammed if necessary.
METRONOME Metronome Microcontroller PIC12F683_P Recommend an associated DIL socket so that
this chip can be reprogrammed if necessary.
MIDI MIDI Controller Microcontroller PIC16F648A_P Recommend an associated DIL socket so that
this chip can be reprogrammed if necessary.
MIDI_SENSE LED-3R_Orange 3 mm Round
PLAY LED-3R_Green 3 mm Round
R1 Resistor 220
R2 Resistor 1K
R3 Resistor 470R
R4 Resistor 4K7
R5 Resistor 4K7 MIDI Replay
R6
R7
Resistor
Resistor
10K
2k2
Parts List
R8 Resistor 220
R9 Resistor 220
R10 Resistor 220
R11 Resistor 220
R12 Resistor 220
R13 Resistor 220
R14 Resistor 220
R15 Resistor 100
R16 Resistor 470
REC LED-3R_Red 3 mm Round
UI Header 6-pin
VO1 Optocoupler 6N138
X1 Piezo Transducer PCB Mount Low Profile. Diameter, pin spacing, and pitch are all
Requires an external oscillator important, so it can fit on PCB. Also get one
circuit to operate as a buzzer or without internal oscillator because we are
sounder. Dia 29.7 mm; Ht 7 mm; generating the waveform from code.
Pin Pitch 15 mm
XTL1 20 MHz Crystal
Volume Potentiometer A1M LOG ALPHA
MIDI IN socket 5-Pin DIN Chassis Panel
Mounted Female Socket 180
Degrees
MIDI OUT socket 5-Pin DIN Chassis Panel
Mounted Female Socket 180
Degrees
Enclosure (Optional) Die-cast Aluminium Enclosure Hammond Diecast Aluminum The 1590XX Hammond enclosure is a great
Stomp Box Enclosure size for this project. Note that drilling of the
Size: 1590XX (145 x 121 x 39 box needs VERY careful measuring to get a
mm)" good result.
4 x PCB Spacers PCB Round Spacer Outer Diameter: 6.3 mm; Inner Dimensions are just suggested and are not
(Optional) Diameter: 4.2 mm; Overall critical.
Length: 10m

34 September/October 2018
MIDI and the Horror of Stuck Notes

Any keyboard player experienced with MIDI knows


of the dreaded ‘stuck note.’ This is where a note has
been sounded via a ‘note on’ MIDI message but the
corresponding ‘note off’ message has gone AWOL due to
system malfunction.
If the instrument being played is one without
natural decay — such as an organ or strings — then the
stuck note will sound indefinitely. In a live performance
scenario, this can be extremely embarrassing and
stressful, with a frantic search for the off switch or ‘all
notes off’ MIDI panic button!

plus change track recordings. DMA allocates memory to


requesting processes and tries to re-use ‘holes,’ thereby
making best use of limited memory resources.
There are many DMA methods. This design uses a
simple fixed-block memory pool approach. Recorded note
data is divided into blocks of 256 bytes in SRAM. Each
block has a header byte to indicate: if the block is empty; if
it’s the last block in a sequence; or the address of the next
block in the sequence. Note events are stored sequentially
inside a block.
This method is perfect for sequentially recorded
MIDI events, but we must choose the block size carefully.
Ideally, it’s a size that allows bit-shifting to calculate
addresses (being faster); is big enough to ensure time ■ FIGURE 14.The SRAM memory layout and Dynamic
spent processing block-headers is insignificant; and is small Memory Allocation.
enough to minimize internal fragmentation.
Internal fragmentation is when a block is only partially
used, and the unused bytes of the block are inaccessible
and wasted. This isn’t ideal but is unavoidable. Reducing
the block size reduces this wastage but increases the effect
of block overheads.
The 23LCV512 SRAM chip can store 2,000+ note
events. The capacity doesn’t equate to duration, in contrast
to recording audio.
The 23LCV1024 is the 23LCV512’s big brother with
double the memory. So, why don’t we use this instead?
The answer is because of addressing and access times. The
23LCV1024 has 24 bits addressing whereas the 23LCV512
has 16 bits. The more memory, the longer the path to the
data. Since memory is accessed, often in our solution we
want to reduce access time. We compromise between
memory size and speed.
Also, we use a simple algorithm to locate a free
memory block. It scans all blocks until a free one is found.
The more memory, the slower this process can be.

Track Pointers — Keep


Things on Track ■ FIGURE 15.Track pointers for the current position.
As this is a recording and playback system, we must
September/October 2018 35
Ref Des Name Value Notes
C1 Capacitor 100 nF
C2 Capacitor 100 nF
C3 Capacitor-Polarized 100 µF
D1 Diode 1N4001
LCD Display Module 20x4 Alphanumeric LCD Display There are many modules out
HD44780 there based on the HD44780
controller. Dimensions are
important if using suggested
Hammond enclosure. Module
used is roughly 98 x 60 mm.
Note that the design drives the
display in parallel mode.
LCD IDC Connector to connect to IDC2X8M. 1565524 Multicomp
LCD module Connector, PCB, Transition, IDC,
16-way
LCD_CONT Trimmer Pot for LCD Contrast. 6 10K
mm Cermet Horizontal Variable
Trimmer Potentiometer
LED_PLAY LED-3R_Green 3 mm Round
LED_REC LED-3R_Red 3 mm Round
MIDI_CTRL Header 6-pin
UI Controller
R1 Resistor 2K2
R2 Resistor 2K2
Parts List
R3 Resistor 10K
R4 Resistor 560
SW_DOWN Tactile Switch 6x6 mm Tactile Switch - Button
Height 6 mm
SW_LEFT Tactile Switch 6x6 mm Tactile Switch - Button
Height 6 mm
SW_OK Tactile Switch 6x6 mm Tactile Switch - Button
Height 6 mm
SW_PLAY1 Tactile Switch 6x6 mm Tactile Switch - Button
Height 6 mm
SW_REC Tactile Switch 6x6 mm Tactile Switch - Button
Height 6 mm
SW_RIGHT Tactile Switch 6x6 mm Tactile Switch - Button
Height 6 mm
SW_STOP Tactile Switch 6x6 mm Tactile Switch - Button
Height 6 mm
SW_UP Tactile Switch 6x6 mm Tactile Switch - Button
Height 6 mm
U1 5V Power regulator IC 7805
UI_CONTROLLER UI Controller, Microcontroller PIC16F883_SP Recommend an associated DIL
socket so that this chip can be
reprogrammed if necessary.
Cable Ribbon cable 16-way (or more).
Just tear off length as required.
Button Caps (Optional) Round Tactile Button Caps for 6
x 6 x 9.5 mm
4 x PCB Spacers (Optional) PCB Round Spacer Outer Diameter: 6.3 mm; Inner Dimensions are just suggested
Diameter: 4.2m; Overall Length: and are not critical. Just need to
10 mm ensure all components are held
clear of metal enclosure!
Power Socket (Optional) Power Socket for the Enclosure Panel/Chassis Mount Connector
with nut 5.55 mm bore 2.1 mm
pin
36 September/October 2018
■ UI controller schematic.

■ FIGURE 16.The UI controller


PCB.
know the current position for each
track. Figure 15 shows how we
make use of track pointers.
When recording a song
section, we can record up to four
tracks simultaneously. Note data for
each track is sequentially written to
SRAM inside linked memory blocks. The actual amount of
data stored for each track can be vastly different.
To find the current position of each track, we must
scan the track events, comparing the event time-stamps
to the overall song position. Pointers refer to the located
positions.

The PIC16F883 User


Interface Controller —
the Second Fiddle
This chip is on the UI controller PCB shown in Figure
16 and is the slave to the MIDI controller PIC; its tasks are
less time critical. However, it still has much to do, managing
user navigation and input, updating the LCD display, and
setting LEDs. It uses a powerful menu-navigation technique
to cram as much as possible onto the chip.
Many of the tasks are relatively simple in comparison
to the complexity of the MIDI controller. The most difficult
challenge is designing a menu system where values can be
■ FIGURE 17.The user interface system.

September/October 2018 37
■ FIGURE 18. A close-up in Edit mode.

navigated and edited. The approach taken here uses


a Value Navigation Table.
Figure 17 shows part of the display. The
characters on the display are either background or
part of value blocks. The background characters are
held in EEPROM and are used as the basis of the
display. The value blocks contain overlaid values.
Values are held in a data structure as integers.
The Value Navigation Table contains information
about the location and size of each value block, and
the navigation between blocks.
Much code is written to translate raw integer
values into different displayed types (whole number,
percentage, time, note name, on/off blob, etc.).
Values are edited using increment and decrement
buttons, with the step size depending on the
duration of the button press.
Figure 18 shows song 1 with the verse
selected. The position is 0 seconds, the duration
is 29.7 seconds, and track 2 is enabled for
playback.
In Performance mode, the LCD digit size is
made large by using custom characters and a
ROM-based character map.

Seamless Transitions
— The Smooth
Operator
Foot-switch presses don’t change a song
section immediately. Rather, they tell the Box
that after the current section is finished playing,
the clicked section is the next section to play. It’s
■ FIGURE 19. Load testing. more like a pending section change. As long as
you have set the track durations accurately, this
will result in beautifully smooth transitions between
sections.
The sections are either looped or normal (not
looped). When a looped section ends, it will either
loop again, or if there is a pending section change,
playback will hop to the new section. Normal
sections will either stop when the end is reached or
hop to a pending section change.
This makes operating the Box in Performance
mode extremely simple. The only thing to worry
about is telling the Box which section to go to next.
You can tell it at any convenient point during the
currently playing section.

■ FIGURE 20. Measuring jitter.


38 September/October 2018
How It Performs — The
Grand Finale!
After considerable design and build effort, the result
is a system that performs excellently! However, ‘excellent’
needs some quantifying.
In chaotic real time systems, it’s often best to use
statistical Response-Time Analysis (RTA), which highlights
probable performance rather than absolute performance.
Figure 19 shows a test measuring response to a spike
load on the system. A batch of 18 note events is sent to
the Box at the same time (simulated by a sequencer). In
practice, this is very unlikely to happen and even a few
milliseconds difference in ‘note on’ reception would
alleviate the load on the microcontroller.
The histogram shows how the recorded notes are
time-stamped. As we can see, virtually all are processed
and stamped after 30 milliseconds, and over half within 10
milliseconds. This is good considering we are unlikely to
ever notice a 10 millisecond delay!
Figure 20 shows a test measuring ‘Jitter’ when the
system is under moderate load. A stream of ‘note on’
messages spaced 34 milliseconds apart is blasted at the
Box. The Box echoes this stream to its output on two
channels — the overall load being in the order of 180 MIDI
events per second. The recorded message spacing should ■ FIGURE 21. MIDI Replay desktop app.
be 30 milliseconds (the Box has a timing precision of 10
milliseconds). As we can see from the histogram, most are
indeed recorded at this interval. However, almost half are The app is a fundamental part of the whole system,
recorded at 40 milliseconds. Considering this represents and acts as the bridge between the box and high-level song
quite a hefty unrealistic load, even this result shows the management and editing capabilities.
system response is fully acceptable! The app can be downloaded from https://collectany.
blob.core.windows.net/midireplay/setup.exe.
Clicking this link downloads the setup.exe which
The Desktop App — Load you then run. Select ‘run anyway’ when the Windows
and Go! protection screen is displayed (Microsoft recognizes this
Figure 21 shows a screenshot of the MIDI Replay app app as from an unknown publisher). You will automatically
for Windows™ that accompanies the Box. get updates to this app if any are made.
Song settings and recorded tracks are communicated
Note Latency and What Human Beings can to the app via MIDI ‘Sys-Ex’ data messages. Recordings
Detect are saved to standard MIDI files that can be edited by any
Sequencer app.
Latency is the delay between pressing and hearing a The app lets you define songs and put songs into sets
note. This is a delicate topic with hot debate over what level that can be synced with the Box. The keyboard player can
is noticeable, but it’s commonly accepted that less than 10 load up a set before a performance and simply click and
milliseconds is not. One thing to reflect on is that sound go at the gig!
waves take 10 ms to travel 12 feet in distance! The software is written in .NET and C# as a ‘WinForms’
Hardware based MIDI devices (dedicated lumps of application. The full solution and associated files are
kit) often have a performance edge compared to software included with the article downloads.
based ‘virtual’ devices because the hardware can be Time to stomp on! NV
honed and crafted to minimize latency. A PC musical
app competes against all sorts of background processes,
including very mundane ones such as checking for email or
updating the antivirus definition.
September/October 2018 39
Super By Phillip Karras

Simple I’ve had a couple fun


circuit ideas in the

Projects for back of my head for


years and started

Learning
playing with them,
changing things, and
finally formalizing

Soldering them. They’re simple


and are a good

and More exercise in soldering


and circuit basics.

The Dead 9V Battery be putting out usable light down to about a quarter volt.
This is way below where a rechargeable battery would be
Flashlight ruined. I went with an on-off-on switch because an on-off
I’m sure that by now, most of you have come across a version wouldn’t have the option of driving the 3V ultra-
circuit called a “joule thief.” This is a simple self-oscillating bright white LED directly. You could also build two circuits:
voltage booster which most people build to use with either one to use the resistor; and one not using the resistor for
an AA or AAA battery. Any “dead” 1.5 volt battery will when the battery is below four volts.
do, where the voltage has dropped to about 1.0-1.1 volts I find that once the 9V battery is reading 3-4 volts
or lower. The fact is that you can use a good battery as when using the resistor and LED, it can be used without
well, and probably every one of the small flashlights on the the resistor to drive the LED. At this point, the internal
market that use only one AAA or one AA battery is using a resistance of the 9V battery is high enough to limit the
joule thief circuit. current, so no external resistor is needed.
This will be a great way to use the dead AA and AAA Also, I’ve measured these currents at around 10 mA,
batteries I end up with from battery-operated things around which is not even close to the 30 mA max current, or even
the house. So, what can one do with all those dead 9V the recommended 20 mA for longer life for these LEDs.
batteries? These are generally down to about six volts Remember that it’s the heat generated by the LED that
and seem to be useless since they are rather low current eventually kills it. Two ways to limit the heat buildup are to
batteries even when new. either drive the LED intermittently — as is done when using
The circuit I want to discuss here is one that would the joule thief circuit — or limiting the DC current to below
be a great project for a newbie to learn about
soldering on. All that is needed is an ultra-bright
white LED, a 220-330 ohm 1/8-1/4 watt resistor,
a “dead” nine volt battery, battery holder, and
something to put it all in. You can add an on-off
switch or even an on-off-on switch.
A word of warning here for those who
use rechargeable batteries: Do NOT use a
rechargeable battery in one of these flashlights.
It will be dead when you take it out because the Schematic 1:
simple version of these circuits will use the battery Dead 9V battery
down to below a half volt. Being one of the more flashlight.
efficient projects I’ve built, this circuit will still
40 September/October 2018
Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/
magazine/issue/2018/09.

Photo 3: The plastic wrap box.

can do searches online to find articles on this construction


technique. A good one I’ve come across is by K7QO.
Photo 1: Dead 9V battery flashlight. Manhattan Style construction uses small islands for solder
points. These are usually cut from double-sided copper-clad
20 mA, which a dead 9V battery seems to do on its own circuit boards. The bottom side is then soldered to another
due to its higher internal resistance. single-sided copper-clad board and positioned to follow
We can make the circuit by simply connecting the the circuit; either to make it easy for the signal, easy to
battery to the resistor and LED in series, with a switch to construct, or both. The top side of each little island is then
turn it off by disconnecting the battery from the resistor. used to connect various leads. These islands can be either
Schematic 1 shows the circuit using the on-off-on switch round or rectangular.
with the resistor across the two outputs of the switch. The difference between Manhattan style construction
Photo 1 shows the simple circuit using the on-off-on and these soldering islands is that there is no way to
switch to either use the resistor or not use it, depending connect the soldering islands to a copper-clad circuit
on the voltage the battery can maintain while driving the board without shorting out the entire circuit. These islands
LED. It’s not easy to tell if the 9V battery is weak enough must either be glued to something — another board or the
to drive the LED directly, so the safest bottom or side of a box, for example
way to tell is to use a voltmeter, or to — or float with enough room between
wait until the LED is obviously getting them that they will not short out.
dimmer and try it without the resistor. Another method is to use very
After I built this circuit, I came up high-valued resistors — 1 MΩ or more
with a much simpler way to attach — to keep all the solder islands at a
the resistor. In my new approach, the good distance from each other. When
resistor is soldered to the two ON using these with a joule thief circuit,
sections of the on-off-on switch, and we have the stiff resistor, LED, and
then one wire from one of those ends transistor leads to help maintain the
is connected to the cathode of the distance between the solder islands.
LED. This reduces the amount of wire I use this island method because
needed. I hope you enjoy building this there are times when I need to
circuit. Now, you can use those dead connect more than just two wires
9V batteries as small flashlights or even or leads together. I find that a small
as personal nightlights. solder island makes this very easy to
do. Using only the wires or leads is far
more frustrating because the lead or
The Simple Joule wire never wants to stay in the position
Thief Night Light I need long enough for me to solder
it to the other leads. Or, as I warm up
as a Soldering the other two or more leads already
Island Project soldered together, one of them pops
My use of the term “soldering off and I have to fight with all the leads
islands” here is similar to the Photo 2: Close-up of resistor attached to the to get them back together.
Manhattan style of circuit building. One switch. Other than using a soldering island,
September/October 2018 41
Photo 4: The solder islands’ joule thief.

the only other method I’ve used is to tie them all with
another piece of wire. Then, of course, as soon as I do Photo 5: Joule thief in box with solder islands hidden.
that, I realize I need to connect another lead or two to
the tied and soldered bunch of leads. find that pre-tinning them removes those sharp edges. Plus,
The material I’ve found that works really well is it makes a nice island of solder that can be reheated to
something we all throw away or recycle. This past week, melt only a section of the whole island, thus making it very
I noticed that my wife had recycled a plastic wrap box easy to add wires or leads.
(Photo 3). Photo 4 shows two soldering islands cut from the
It wasn’t very flat, so I removed it to take it apart plastic wrap cutting strip.
and flatten it. I noticed that the metal cutting edge was This project didn’t really need these soldering islands
still attached to the box so I removed it to place it into a since only two leads and one piece of wire from the
different recycling bag. inductor are the most connected together. However, it did
In looking at it, I wondered if I could solder something make soldering them together much easier than getting
to it. So, instead of recycling the cutting strip, I tested it the leads of the transistor and LED lined up and then tied
and found that soldering to it worked very well. I decided together by the inductor wire and soldered together.
to make a night light out of a joule thief circuit using two The inductor was then bent back to be above the
small pieces of this material as soldering islands. transistor and LED before installing it in the small plastic
These islands made soldering multiple wires to the box. Positioning the parts as well as the entire circuit was
same point very easy, even though they were not attached not critical either in relation to each other or in the box.
to a board. Also, while the ends of this material are sharp, I I completed this project with a small switch and two
battery clips: one for an AA battery and the other for an
AAA battery in parallel so that either size battery could be
used without needing a converter case for the AAA battery
to resize it to a AA battery.
A small amount of “liquid tape” was used to keep the
battery clips and the circuit from moving around. The liquid
tape can be removed if needed to service the circuit in the
future, and it’s strong enough to hold up to normal use.
Photo 5 shows the finished joule thief night light in a
box with the soldering islands hidden under the inductor.
Photo 6 shows the bottom of the box with the
soldering islands visible.

Combining the Dead


Battery 9V Flashlight and
Joule Thief Night Light
This project is simply combining the previous two
projects into one box and making it work with the same
Photo 6: Joule thief night light with soldering islands visible. LED. There are many ways to do this. I built two in order to
42 September/October 2018
Photo 7: Photo 8: Using
Dead battery two LEDs to
9V + joule separate the
thief night two power
light with sources.
DPDT switch.

test out some part-saving ideas. blocking diode. I figured I’d use another LED to do the
Generally speaking, the more parts we try to save, blocking since I could then get light out of it as well. This
the more complex a circuit becomes. This was definitely saved the expense of the DPDT switch but added a minor
the case with this combined project. It’s no longer super cost for the second LED. This saved a little money probably
simple, but it’s not all that difficult either. at the expense of a shorter battery life.
I’ll explain a bit first, and then show the photos of the You’ll also notice that I removed the AAA battery
two different approaches. I’ll include the schematic as well. holder. This was because I found that the AAA battery will
The first circuit used two switches: an on-off-on single work in a double-A battery holder. It’s not as secure, but
pole switch for the 9V dead battery side of the project; as a night light it doesn’t need to be. As a flashlight for
and a double-pole-double-throw (DPDT) switch for the two children, I’d keep the AAA battery holder.
AAA and AA battery holders. This powers the joule thief With an on-off-on switch, I found another way to
circuit and also disconnects the 9V battery section to the hook up the double- and triple-A holders. Use the center
off joule thief circuit. In this circuit, the two battery holders connector of the switch for the output to the joule thief
are connected together in parallel so only one battery at a circuit, and then each battery holder could attach to the
time can be in a holder; refer to Photo 7. switch on either side and could be selected to supply
In the second circuit, I used two LEDs to separate the power separately.
9V battery from the joule thief circuit. This was necessary In this way, all three batteries could be installed. As
because I removed the DPDT switch and replaced it with one starts to get too dim, the weak battery could be turned
a second on-off-on switch. This meant there was no way to off and then one of the other batteries could be switched
separate the 9V from the joule thief circuit via the common in. Check out Photo 8.
positive lead of the LED. By adding a second LED in series Schematic 2 shows the two LED AA and AAA battery
with the first LED, this LED could be
used as a blocking diode, restricting the Schematic 2: Two LED version
current path from the 9V battery to the of the dead 9V/dead AA/AAA
joule thief circuit. battery nightlight.
The joule thief circuit is now
connected to the second LED in the
series and so it drives both LEDs. This
means that the joule thief circuit had
to boost the voltage to ~ 6V to turn on
both LEDs in series. The only reason the
joule thief stops at 3V is because that’s
when the LED turns on and stops the
voltage increase of the oscillator. So, the
oscillator boosts the voltage to what is
needed to turn on both LEDs.
By removing the more complex
and expensive switch, I had to add the
September/October 2018 43
Screenshot 1. Two LED trace battery 1.1V.

Screenshot 2. Two LED trace battery 0.6V.

section with the power lead-in for the dead 9V


battery. Take the power to the LED there and
feed it in between the two LEDs as shown.
In the oscilloscope trace in Screenshots 1
and 2, we can see that the voltage for the two
LED joule thief circuit goes up to almost 6.5V
with a battery at 1.1V. It goes to 5.84V when the
battery gets down to 0.6V.
So, there you have it. Some fun simple
circuits to light up your life. NV

Introducing the

1(:39-U
0LQL&LUFXLW%RDUG+ROGHU

'(6,*1('
In G )25 29(5
V PrInt
no W o

t
F
Pa
F
n l
erInG U
e 7+(('*(
Fron n eI Nr &20321(17
s i g
D e N IT – WE MACH E IT %2$5'6
G Model
YOU DESI re s
220
e n c lo s u
s to m P a n e ls &
Cu
c tu ri n g
•  M a n u fa w a re
aD S o ft
• F re e C Innovative H
Holding
olldi
o din
ngg SSolutions
olutio
ol utiio
ut ons
n
h ip p in g q u ir e m e
n ts
• F re e S rd e r r e
o
• n o M in
im u m
800-759-7535
u il t in 5 Days
• B
www.frontpanelexpress.com

44 September/October 2018
USB
Bench and Builder
Stuff to keep your
Add USB to your next project--
It's easier than you might think!
USB-FIFO USB-UART USB/Microcontroller Boards

electronics hobby
RFID Readers Design/Manufacturing Services Available
Absolutely NO driver software development required!
www.dlpdesign.com

interesting!

setting your ideas into


AM Page 1
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

ME Equipment WANTED! DEC and VME


l Equipment Corp & Equipment WANTED!
a VME Systems & Parts Digital Equipment Corp
uy - Sell - Trade and
yways 937-847-2300 or Motorola MVME Systems
buyer@keyways.com and Parts
Buy - Sell - Trade
CALL KEYWAYS 937-847-2300
or email buyer@keyways.com

September/October 2018 45
Ready Player 2:
CC3200 Wi-Fi
& IoT MCU
The February 2018 issue article, “Build the IoT Sump Pump (or Pretty Much
Anything IoT)” generated curiosity about some of the tools utilized to create the
device. It’s time to ready Player 2 and penetrate deeper into the utilization of some
of the software and hardware features that come with CC3200 Launchpad and
Code Composer Studio (CCS).

Part 1 By Patricia & Mirza Kolakovic

We will demonstrate step-by-step: CCS Installation and Setup


For this step, you will need to download CCS for
• CCS installation and setup your OS from http://processors.wiki.ti.com/index.php/
• How to use the temperature sensor on the CC3200 Download_CCS. We chose Windows Offline Installer for
LaunchPad this article. First, unzip the file, run setup, and choose the
• How to adopt a third-party project to work with your default install folder (c:\ti). You’ll then be asked to select
environment your processor support. Choose CC32xx Wireless MCUs
• How to upload your code to the external Flash as shown in Figure 1 and then go to the next step.
memory Keep selected debug probes by default and click
Finish. Once installation is complete, click on Finish again
and Code Composer Studio v8 should start
up. It will ask you to select the Workspace
directory.
For this demonstration, we left the
default and clicked Launch. At this point,
CCS will display the Getting Started tab and
is ready for use. However, before we start
using it, we need to get a few more items.
Next, we’ll download CC3200SDK from
www.ti.com/tool/cc3200sdk.
First, we used Windows Installer for
CC3200SDK. Second, we used Service
Pack Installer for CC3200SDK. To be able to
download these files, you will have to register
with Texas Instruments (TI) by creating an
account and logging into that account. The
Figure 1. CCS processor support. software is free.
Once these files are downloaded, run
the installer and select the default installation
directory (c:\ti).
The last item required is the

46 September/October 2018
Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/
magazine/issue/2018/09.

programming utility UniFlash 3.4.1.


Go to www.ti.com/tool/uniflash
and make sure you download
v3.4.1 with support for CC3200
(the offline installer used for this
article). Again, you will need your
account with TI to be able to get
this free utility. Once downloaded,
unzip and run the setup file.
If you have Windows 10,
you’ll need to run this setup file in
Windows Compatibility Mode. We
allowed Windows to automatically
select compatibility and it picked
Windows 8 mode.
Select the default installation
directory (c:\ti\unflash_3.4). On Figure 2. CCS, SDK, and UniFlash home directory.
the Select Components menu
window, all boxes are checked by
default. Keep these defaults and go
to the next menu. On the Select
Debug Probes menu, no boxes sdk directory. In the ..\docs folder, you’ll find numerous
should be selected. Select Next and Finish. documentation and user manuals. All of the examples are
Once installation is complete, let it launch and make documented and their pdfs are located here as well under
sure UniFlash starts up. We have now achieved CCS the ..\examples directory. The temperature sensor example
installation and setup! Figure 2 is what the installation we’ll use is documented in the CC32xx I2C Application.pdf.
directory should look like once everything is installed. This example demonstrates how to access and read
the onboard temperature sensor and accelerometer via an
I2C bus. We’ll cover the details of accessing and reading
Temperature Sensor on the the temperature sensor but accomplishing the same for the
CC3200 LaunchPad accelerometer follows a similar procedure.
We’ll use one of the SDK examples to demonstrate In the ..\hardware folder, you’ll find the necessary
how to use CCS to edit, compile, and run programs schematics. Sheet 4 contains the temperature sensor. Refer
on CC3200. Go to C:\ti\CC3200SDK_1.3.0\cc3200- to Figure 3.

Figure 3. TMP006 temperature


sensor.

September/October 2018 47
Figure 4. Open
Perspective.

Figure 6. Import example.

Figure 5. Open Perspective dialog. I2C SCL and SDA are on pins CC_GPIO_10 and
CC_GPI_11, respectively, so you need to make sure the
jumpers J2 and J3 are put in place. The sensor address pins
are configured for the 0x41 I2C address.
Now it’s time to fire up CCS. You can close the
Getting Started tab. Click on the Open Perspective button
(see Figure 4) located in the upper right corner.
A menu will pop up with a choice of different views.
We mostly switch between Edit and Debug views.
Figure 7. CCS Simple. Typically, CCS switches automatically. However, if you
would like to go back to edit
mode, select CCS Edit or CCS
Simple as shown in Figure 5.
To demonstrate this feature,
we’ll do an example. Go to Project
→ Import CCS Projects... First, the
Import Wizard will open up. Click
on the Browse button and navigate
to i2c_demo in the ..\example
folder. Hit Finish. Refer to Figure 6.
Go to View and select Project
Explorer. Once Project Explorer
pops open, you should see the
i2c_demo folder. Expand it to
see project files and double-click
on main.c. Now, go to Open
Perspective (from Figure 4 above)
and select CCS Simple. You should
have a display resembling Figure 7.
To clear your workspace,
minimize the windows that you
48 September/October 2018
no longer need. Also, move and
arrange windows for ease of use.
Once your screen is organized to
your satisfaction, you can begin to
edit source files and compile.
This example should compile
straight out of the box. However,
before we proceed, we should
check the project properties and
make sure they are appropriate
for our demonstration. These
projects are a carryover through
many CCS releases and sometimes
adjustments are needed. Following
are the changes we had to make
to compile CC3200_SDK v1.3.0
i2c_demo under CCS v8.
Right-click on the project name
in the Project Explorer and select
Properties. Select the General tab
and make sure the latest compiler Figure 8. Compiler version.
version is selected; see Figure 8.
Now, select the ARM Compiler tab and if flag --float_ calls driverlib low level functions to open, close, read, and
support=fpalib is set, click on Edit Flags and change fpalib write peripheral.
to none (Figure 9). Click OK, Apply, and Close. Pinmux.c - Configures pins and peripherals.
Go to Project and click on Build Project. The console
will open and if successfully compiled, you should get the Unpack your CC3200, remove the jumper on header
confirmation “Build Finished” as seen in Figure 10. P1 between Vcc and pin P58 if installed, and make sure
Before we proceed with the i2c_demo, let’s explore jumpers J2 and J3 are populated. Connect your LaunchPad
what this code does. to your PC, and the onboard LEDs will come to life.
The application communicates with the user (Terminal In CCS under View, select Other. A new menu pops
Emulator) over UART. It accepts commands to read/write up. Type “target” in the search box and select Target
registers on a specified I2C device and displays results on a Configurations as shown in Figure 11.
terminal.
For Terminal
Emulator, we
used the free
application PuTTY.
The source code
of interest is in the
following files:

Main.c - Figure 9.
Initializes the Compiler
board, reads flags.
commands via
UART, processes
I2C commands,
writes results to
UART.
i2c_if.c/
uart_if.c - I2C/
UART interface
API wrapper that
September/October 2018 49
Figure 10. Build
finished.

.out file that’s


located in your
Workspace folder.
If you selected all
default options
during installation,
it should resemble
Figure 15.
Click OK.
Now the program
is loaded in
RAM, the target
initialized, the PC
points to main,
and all is ready to
Right-click on User Defined run.
and select Import Target Next, you need to open
Configurations. Navigate to C:\ your Terminal Emulator. Go to
ti\CC3200SDK_1.3.0\cc3200- Windows Device Manager and
sdk\tools\ccs_patch and select expand Ports. This will show
CC3200.ccxml as shown in what COM port LaunchPad is
Figure 12. If asked, choose to connected to. In this case, it was
copy files. COM4 (Figure 16).
Click on the green bug Now, start up PuTTY. In the
button on the toolbar to start category window, select Serial
the debug session. Debugger and set it up as in Figure 17 and
will start up and if everything click Open.
loads correctly, you should see Figure 11. Select Target The PuTTY terminal should
the Stellaris In-Circuit Debug Configurations. open a blank terminal screen. In
Interface. Refer to Figure 13. CCS, hit F8 to run the program.
Right-click on the In-Circuit The terminal will come alive
Debug Interface in the Debug and after printing out the title,
window and select Connect command usage, and parameters,
Target. You are now connected you’ll see a cursor waiting for a
with the target and the target command to be entered (Figure
is suspended. Open Debug 18).
Perspective and you should see a display similar to what is In this example, we want to read the TMP006 ambient
in Figure 14. temperature register. We can use the readreg command.
Next, we need to load the program. Go to Run and We need to give it TMP006 I2C address 0x41 and a pointer
select Load and Load Program. You need to specify the to the temperature register. From the TMP006 datasheet,
the pointer register value is
Figure 12. Import Target Configurations. 0x01. Then, we specify how

Figure 13.
Stellaris
In-Circuit
Debug
Interface.
50 September/October 2018
Figure 14. Debug
perspective.

many bytes we
want to read.
As you can
see in Figure 18,
the command
returned two
bytes: 0x0B and
0x90.
To calculate
the temperature in
Celsius, we right-
shift this number
by 2, convert it
to a decimal, and
divide by 32:
Figure 15. Load program.
0x0B90 => 0000 1011 1001 0000 > 2 =
0000 0010 1110 0100 = 740(10)

740 / 32 = 23.125 deg C

We heated up LaunchPad using a hair


dryer and did the register read again. The board
returned 0x1AFC which converts to 53.9°C.

cmd#readreg 0x41 0x01 2


I2C Read From address complete Read contents
0x1a, 0xfc,

Figure 16. COM port.

Figure 17. PuTTY configuration.

September/October 2018 51
www.poscope.com

- USB - PWM
- Ethernet - Encoders
- Web server - LCD
- Modbus - Analog inputs FIGURE 18. PuTTY terminal.
- CNC (Mach3/4) - Compact PLC
- IO
Conclusion
The IoT sump pump device design featured in the February issue initiated
several requests for additional details. So far, we’ve explained CCS installation
and set-up, and how to use the temperature sensor on the CC3200 LaunchPad.
Stay tuned for Part 2 as we further explore two more items of the device
design: How to adopt a third-party project to work with your environment; and
how to upload your code to the external Flash memory. NV
- up to 256 - up to 32
microsteps microsteps
- 50 V / 6 A - 30 V / 2.5 A
- USB configuration
- Isolated
THE MOST COMPLETE PROGRAMMING TUTORIAL!
PoScope Mega1+ • Everything you need to learn to program PIC® micro-
controllers is included in this package
PoScope Mega50
• Learn the fundamental concepts of programming,
including program flow, loops, coding techniques, binary
manipulation, device-to-device communication, user
interface design, in-circuit debugging, and more!
• Includes all the necessary the software, compiler,
$99.99 trainer board, cable, tutorial with exercises and sample
Academic and bulk pricing available
code!
Check out our other popular products
-up to 50MS/s for PIC® developers including:

PBP3
-resolution up to 12bit
U2 Programmer
-Lowest power consumption
-Smallest and lightest PBP3 Compiler
-7 in 1: Oscilloscope, FFT, X/Y, Recorder, Prototyping Boards
Logic Analyzer, Protocol decoder, Signal
PICBASIC PRO™ Compiler Experimenter Boards
generator
www.melabs.com
Contact us at info@melabs.com

52 September/October 2018
By David Goodsell

Can You
Trust Your
Voltmeter?
BUILD YOUR OWN
Sometimes I wonder which of my portable
Or … you can build your own reference out of
digital voltmeters I can trust — the B&K, parts in your junk box. Figures 2 and 3 show a simple
breadboard I made in an hour or so and the schematic.
Fluke, or Amprobe. Usually, they’re The only component I didn’t have on hand was the
AD584.
pretty close but it bugs me not knowing There are two grades of AD584s for hobbyists — J
and K — which specify the accuracy of the outputs. J is
whether they are right on the nose. +30 mV and K is +10 mV for their 10.00 volt outputs.
The IC in the breadboard is the K version and the spec
sheet lists a max error of +3.5 mV for the 2.500 volt
Of course, I’m just being picky because I output. You can see that the measured error is a lot less
seldom need more than three or four digits of — only +1.0 mV. That’s one part in 2,500. Good enough
for most measurements!
accuracy, but it sure would be nice to know
the answer. Fortunately these days, there are
a number of very accurate voltage reference
circuits that you can build or purchase for a few
dollars. A ready-to-use unit made by Agilent
is shown in Figure 1. It puts out 2.500, 5.000,
7.500, and 10.00 volts and costs less than
$20 on eBay. The actual precisely-measured
voltages are recorded on the side label, good
to six digits. The heart of it is a laser-trimmed
Analog Devices AD584 voltage reference IC.

FIGURE 2. My DIY breadboard uses a laser-trimmed AD584


DIP; 2.500V output is accurate to 1 mV.

FIGURE 3. The schematic of the DIY breadboard can use two


versions of AD584s, depending on the accuracy desired.

FIGURE 1. This $20 voltage reference module switches


54 September/October 2018 between 2.500, 5.000, 7.500, and 10.00 volts, and has a built-
in USB rechargeable battery.
Post comments on this article and find any associated
files and/or downloads at www.nutsvolts.com/
magazine/issue/2018/09.

FIGURE 4. My vintage Model 630 Triplett VOM is accurate


to within 1/2% after decades of hard use.

Just for fun, I dug out my old Model 630NA


Triplett VOM with its cool anti-parallax mirrored scale
to see what it would read. I magnified the image in
Figure 4 and estimated the reading to be 2.488 volts.
The manual for the meter stated the accuracy to be
+1-1/2% of full scale. Bottom line: My Triplett was
accurate to within 1/2% on the three volt range. Not
too shabby for a meter as old as the hills!

EFFECT OF TEMPERATURE came in shiny black Bakelite


I’m not going to discuss the effect of temperature housings that cost $40 in 1963
on any of the voltage references I’ll be covering later in dollars. On a whim, I bought a
this article because that is a whole other brand new one (actually 39
subject itself. Plus, it’s been extensively FIGURE 5. years old) made by Eppley
covered in scientific studies. Temperature The Weston Laboratory on eBay for $50.
is a critically important parameter for standard It’s a real beauty. See Figure
many types of references, but the effects cell made by 5 for a size comparison to
Eppley was
are quite small for hobbyist ICs. the modern AD584 DIP.
the world’s
For example, the 5.000 volt output primary voltage For almost 80 years
of an AD584 only varies about +1.25 mV standard for (from 1911 to about 1990),
over the full industrial range of 0°C (32°F) over 70 years. these shiny black housings
to 70°C (158°F). If you are interested, I called Weston cells reigned
conducted temperature tests on an AD584 and the results supreme as the world’s
are graphed in Figure A in the sidebar. primary and secondary voltage
standards. Inside the housing was a simple glass vial filled
with a bunch of high purity chemicals. Figure 6 shows one
THE BLACK BOXES of the H-shaped vials with the chemicals at the bottom of
Voltage references (or standards) in the past weren’t each leg and filled with a liquid to just above the halfway
quite as small or inexpensive as the current ICs. They point.
The chemicals
included mercurous
and cadmium
sulfates, cadmium-
mercury amalgam,
and an electrode
of shiny metallic
mercury in the lower
right leg. Platinum
wires were used
to bring out the
voltage. The voltage
was produced by
the interaction
between these
chemicals and was
a little over one volt;

FIGURE 6. Inside the


standard cell was a glass vial filled with chemicals that generate an
Figure A. Temperature plot of AD584 IC 5.000V output
accurate and stable voltage.
shows just 2.5 mV variation from 0°C to 70°C.
September/October 2018 55
Calibration labs and cell manufacturers would
periodically send their cells to Washington and
NBS would issue a certificate stating their precise
measured voltages, good to one microvolt. The most
stable type of cells — called “saturated” cells — were
so delicate that they could not be tipped more than
45 degrees and had to be hand-carried all the way to
and from NBS.
Cell manufacturers (like Eppley) would also
maintain super-accurate saturated reference
standards at their facilities, so the individual
secondary cells they sold would be traceable back to
NBS. Figure 7 shows the slightly wrinkled certificate
that came with my Serial Number 864673 Eppley
FIGURE 7. The manufacturer provided a calibration certificate along with Standard Cell, certified to six digits. My secondary
each cell, good for one year. cell is the “unsaturated” type which is not sensitive
to tipping and can be shipped in the regular mail.
1.0193 +.0002 volts to be exact.
Calibration labs in companies throughout the world
used these cells to calibrate their voltmeters so the NOTHING IS EVER EASY
specifications of the electrical components and equipment Just owning the neat cell was not enough. Now, I
they produced would be comparable for all users. The wanted a “good” digital voltmeter to measure it, not my
cells could only supply a few microamps (never more than four-digit Fluke. I wanted to know exactly what the voltage
100 µa) when used. Typically, a laboratory potentiometer was, to at least six digits or more. So, I checked the price
which used zero current from the cell when balanced, was of a refurbished 7-1/2 digit HP: $2,550. Gulp! What about
used to generate other precise higher voltages to calibrate eBay? How about a vintage 6-1/2 digit HP3456A for $99?
regular voltmeters. Bingo! Check it out in Figure 8.
There was an interesting caution in the cell’s operating When it arrived, all the digits came on. However,
instructions, “If a cell is shorted for 30 minutes, allow five pushing the Test button triggered an error of “-4.0000”
weeks for it to recover to within 75 µV.” Lesson: Don’t which made me suspicious. So, I shorted the input
short them or it’s a long wait. terminals and it displayed all kinds of random digits, not the
0.000000 I expected.
After several days of taking it apart, measuring different
TRACEABILITY TO NATIONAL voltages, and searching for people with the same problem,
BUREAU OF STANDARDS (NBS) I found the answer. Not good! The older HP3456A
voltmeters (like mine) had a design flaw. The three ROMs
Although Weston cells were very stable, they still on Board #A4 tended to lose their memories after several
needed to be periodically checked against the nation’s years. I said a few words I can’t repeat.
super-accurate primary standard cells located at the After more research, I found some enterprising
National Bureau of Standards (NBS) in Washington, DC. experimenters who had figured out how to replace the
bad ROMs with more modern EPROMs,
like 2716s or 2732s. It sounded like a fun
challenge until I realized how many hours
it would take to pull the chips, modify
the address pins, download the files, and
burn the new EPROMs. Even then it might
not work and it would still need to be
calibrated.
So … I caved in and bought another
HP3456A from a regular test equipment
house, for three times the money, and they
calibrated it to the original specs. When
it arrived, I checked to see if the ROMs

FIGURE 8. After 39 years, the voltage produced by


this cell had only dropped 0.115 millivolts.

56 September/October 2018
HP redesigned their HP3456A voltmeter to replace three defective ROMs with one larger memory chip.

FIGURE B. Old HP3456A (serial #18467) with three defunct FIGURE C. Newer HP3456A (serial #19178) with redesigned board
ROMs. and a single ROM.

had been replaced. Big surprise! Board #A4 had been other words, a precise frequency would produce a precise
completely redesigned by HP. No more three ROMS, voltage, every time.
just one big one. Hopefully, it won’t die like the others. A few millivolts was not a very useful calibration
Figures B and C in the sidebar show photos of HP’s board source, so developers fabricated an integrated circuit type
redesign. structure that had an array of thousands of tiny junctions
The final chapter to this story is better than the all in series, all adding up. It took 20,208 tiny junctions to
beginning. The fellow who sold me the original non- produce one volt and almost 300,000 to make 10 volts.
working unit gracefully refunded my $99 and told me to Figure 9 shows a microscopic view of an early one volt
keep it as a door stop. All in all, it turned out for the better. version. If you look closely, you can see the serpentine
array of junctions, although the whole chip was only about
3/4” wide.
SERIOUS MEASUREMENTS
The Figure 7 cert for the 39 year old black beauty was
1.01928 volts. However, some Weston cells were known
to lose a small amount of voltage over the years; about 30
µV/year: -30 µV x 39 years = -1560 µV (1.56 mV). Quite a
bit!
With my newly acquired and calibrated HP3456A in
hand, Figure 8 showed the actual loss and it was much,
much less: 1.019280V - 1.019165V = 115 µV, i.e., a 0.115
mV loss in 39 years. Amazing! Maybe the lower loss was
because of the brand-new condition of the cell and benign
storage in a warehouse all that time. Who knows?

NEW TECHNOLOGY FIGURE 9. This highly magnified view of a superconducting


Meanwhile, time marched on and new technologies Josephson junction array has 20,208 tiny junctions that
popped up to challenge the Weston cell. In this case, it was generate 1.000000 volts. Photo courtesy of NIST.
the Josephson junction which proved to be 1,000 times
more accurate and stable. Figure 10 is a view of a typical complicated laboratory
In 1962, a graduate student at Cambridge University setup using several cylindrical liquid helium dewars
named Brian Josephson derived a series of equations that (pronounced do’-ers) to cool the integrated arrays to four
postulated that two superconducting electrodes separated degrees above absolute zero and provide the microwave
by a thin layer of insulation would create a special junction, power to the junctions. Figure 11 is a very simplified
now known as a Josephson junction. If an AC microwave diagram of the arrangement of the junctions, showing the
signal was applied to the electrodes, pairs of Cooper flow of the precise microwave signal.
electrons would tunnel through the insulator and create a Typical frequencies are around 75 GHz. Also for
tiny millivolt level DC voltage across the electrodes. The simplicity, the current-bias wires that determine the
significance was that the value of the tiny DC voltage could operating point of the array and polarity of the DC outputs
be locked to the frequency of the microwave signal. In are not shown.
September/October 2018 57
FIGURE 10. A primary voltage standard setup uses a tank of liquid
helium to cool the Josephson junction array inside it to 40K. Photo
courtesy of NIST.

not occur overnight. It took several decades before the first


practical system was ready for everyday use — other than in
a laboratory setting operated by PhD physicists.
If you want to know even more about Josephson
junctions, there are quite a few scientific papers on the
Internet. Check Wikipedia too.
BTW, if you have some extra cash laying around,
you can buy a turnkey 10V programmable Josephson
instrument from the NIST (National Institute of Standards
and Technology) for the bargain price of $220,600. Or …
you could build one in your basement.

ARE MY METERS ACCURATE OR


NOT?
Nowadays, 10 volt Josephson Voltage Standard (JVS)
systems are located in over 70 facilities around the world, Finally, I checked all the voltmeters in my shop against
with new more compact and programmable systems being a trimmed 5.00000V IC reference as shown in Figure 12.
developed as we speak. However, all this development did It was kind of anticlimactic because ALL the meters were
right on the nose, including some analog panel meters.
So now, I have no doubts about the accuracy of any DC
voltage measurements I make in the future.
You might wonder why meters need to be periodically
calibrated if they always seem to be right on. The answer is
simple. In my youth, I briefly worked in the calibration lab
of a large aerospace company and asked the supervisor
the same question. He said “You may think they’re alright,
but they could have been dropped or zapped out on the
[production] line. You never know until you check ‘em.”

WRAPPING IT UP
While it might be fun to have your own world-class
super-precision Josephson instrument in your basement,
taking delivery of liquid helium each month might make
FIGURE 11. The value of the DC output of this simplified array the neighbors wonder.
diagram is locked to the frequency of the input microwave power.
In lieu of that, you can easily build or buy a perfectly
good IC voltage reference and set your mind at ease about
the accuracy of your meters. At least you’ll know for sure
which meter you can trust. NV

ITEM DESCRIPTION SUPPLIER


C1, C2 Capacitor, 0.1 µF, 50V Digi-Key, P4525-ND
D1 Diode, 1N914 Digi-Key, 1N914BCT-ND
LED LED, Red Junkbox
R1 Resistor, 20K ohms Digi-Key, 20KQBK-ND
U1 Regulator, 15V, 100 mA, 78L15 Digi-Key, MC78L15ACPFS-ND
U2 Voltage Reference, AD584K Digi-Key, AD584KNZ-ND
SW1 Switch, Slide, SPDT Digi-Key, EG1903-ND
TP1-4 Binding Post, Pair, Red & Black Jameco 77691 (get three pair)
Breadboard Solderless Breadboard Jameco 2155452
Battery (2) 9V Alkaline Walmart
FIGURE 12. My Fluke DMM is right on the nose compared Holder (2) Battery Holder, 9V Digi-Key, BH9VW-ND
to a precision voltage source.
Voltage Standards Parts List
58 September/October 2018
Pico2204A SSA3021X
10MHz 2-Ch Oscilloscope Spectrum Analyzer

Passport-sized 2-ch PC-based 9 kHz – 2.1 GHz range and measures


scope. Compact alternative the magnitude of an input signal
to benchtop instruments. versus frequency over the full
100MSa/s in your laptop bag, frequency range of the instrument.
traveling toolkit, or for demos. Light weight and small size (15.5”
Built-in AWG, serial decoders & x 8.2” x 4.6”), with a user friendly
$ 139 two X1/X10 passive probes. $ 1,395 interface on a large 10.1” TFT LCD.
Free Shipping Free Shipping

IkaScope WS200 GPS Series


30MHz Wireless Oscilloscope Linear DC Power Supplies
WiFi-connected 30MHz scope-in-a- High quality linear DC power
probe for isolated measurements supplies with digital display meter
on tablets, smartphones and PCs. and remote control. Low ripple/
200MSa/s sampling rate, maximum noise, overload and reverse polarity
input +/-40Vpp. Turns on when protection. 18V/5A to 30V/3A
probe touches circuit. Weighs 2 oz. versions. Features constant voltage
299.95
Starting at
$
Free Shipping
For Windows, Mac, Linux. $ 199 and constant current operation.
Free Shipping

DS 1054Z SDS 1202X-E


50MHz 4-Channel Oscilloscope 200MHz 2 Ch Oscilloscope
High quality 4-channel 50MHz Excellent 200MHz Oscilloscope.
Oscilloscope. 1GSa/s + 30,000 wfms/s. 1GSa/s + 100,000wfms/s. 14Mpt
Innovative technology hits a new price memory for zooming on fast
point for reliable four-channel scopes. glitches. Very low-noise front-end.
12 Mpt memory for zooming on fast Common adjustments quickly
glitches. Large 7” TFT color display is accessible with single-button
$ 349 very easy to read. FREE carry bag! $ 379 control. Free serial decoders!
Free Shipping Free Shipping

CircuitGear Mini “I founded Saelig in 1988 to search the


CGM-101 Oscilloscope world for unique electronic control
components and test & measurement
Combination oscilloscope/waveform
equipment, including: economical
generator/digital I-O in one small, low oscilloscopes, PC and RF spectrum
cost unit. 2MSa/s dual channel, 200 kHz analyzers, USB and logic analyzers,
11-bit oscilloscope, DDS AWG, 8-ch I/O. Alan Lowne, CEO AWGs, pure RF sources, DMMs,
dataloggers, SPI/I2C controllers, high-reliability industrial and panel PCs,
USB powered, no AC adaptor required.
EMI enclosures, USB serial converter cables and lots more. ‘Saelig’ is an
Open source software for Windows, Olde English word meaning ‘happy, prosperous, and blessed’.
$ 99.95 Linux and Mac. That is what we wish for our customers!”
Free Shipping
What makes Saelig different? Take a look at our website’s
‘Values’ statement - www.saelig.com/values.htm
• Saelig Company, Inc. • www.saelig.com • sales@saelig.com • 1-888-7SAELIG
(1-888-772-3544)
Pawlicki’s Posers
By John Pawlicki K8AG

This is the first in a series of questions to encourage readers to think about electricity
and electronics in ways that, perhaps, they had not before. My intent is to improve
understanding on how electricity behaves and how it can be made to do what we want.

These kinds of questions rarely show up on high school or even college exams, yet
they demonstrate an understanding of electronics beyond the formulas. I hope these
questions help people get a real feel for how electricity works.

How Does Electricity Know to Light Up a Light Bulb?

T
urn on a light switch. Assuming that you’re the wires, metal parts of the light fixture, and the closed
living where electricity is available and switch) or stop electricity (like the surrounding air, plastic,
someone has paid the electric bill, the light and ceramic parts of the light fixture, etc.).
will come on. Turn it off and the light goes off Conductors (like wires) allow electricity to flow with
again. Electricity seems to be smart enough little pressure. Insulators (like air) stop the flow of electricity
to light the light bulb, while leaving the rest of completely. Using conductors and insulators, electricity is
the apparatus — the switch, wires, fuses in the channeled to pass through the device that we want to use
fuse box, and pole transformers, etc. — alone. power to generate light: the light bulb.
The light bulb must have something that these other
#1: How does electricity know to light the bulb devices, wires, switches, transformers, etc., do not.
while leaving everything else dark? For devices to use power from electricity, they must
neither completely stop nor freely allow the flow of
The light bulb must be different than the rest of the electrical charges. For the most part, we can think of three
equipment. What differences cause electricity to ignore all different types of things:
that equipment but have such a pronounced effect on the
light bulb? 1.) Devices or materials that stop electrical charges
If everything is working as it should — other than the from moving.
light bulb — all of the other equipment must either conduct 2.) Devices or materials that allow electrical charges to
electricity (pass charges with very little restriction like move freely.
3.) Devices or materials that restrict but
not prevent electrical charge flow.

The most interesting devices and


materials are those in the third category.
The characteristic of a device that
restricts charge flow is called resistance.
Too much resistance and a device can
The light at effectively stop charge flow, as with
my bench.
switches turned off, air surrounding the
devices, coating on wires, etc.
Too little resistance and charges simply
pass through the device as with wires and
60 September/October 2018
Post comments on this article and find any associated
files and/or downloads at www.nutsvolts.com/ NEXT POSER: Pushing charges around.
magazine/issue/2018/09.

Here, the bulb is on, yet the wires to the light remain dark
and cool.

closed switches. voltage — then no power is used. If charges pass through


However, the right amount of charge restriction causes with no restriction, again, no power is used. Only by
energy to be used in the device. The device can glow or partially restricting charge flow can we use power from a
heat or move or make sounds or many other things. Power power source.
is being used by such devices. Charge flow restriction (resistance) is a characteristic of
the light bulb allowing it to generate power from electricity
Summary where wires and switches and the surrounding air remain
inactive. If we can learn how to use wires and switches and
If a device is to use power, it must pass some charges other devices, we can begin to make electricity do what
but not freely. If no charges pass — no matter how high the we want. NV

PicoScope 5000D Series ®

PC Oscilloscopes

The engineer’s mixed-signal,


flexible-resolution solution.
For engineers in mixed-signal environments, capturing both high-speed
digital measurements and high-precision analog waveforms is easier
with a PicoScope® 5000D. Its innovative FlexRes® architecture
combines multiple, high-resolution ADCs so users can
selectively optimize sampling rate or resolution as needed.
In addition, 5000D MSO models allow users to accurately
time-correlate digital and analog channels and apply advanced
NEW
triggers across both. Include its powerful set of standard software
features, and a 5000D is both a great solution and a great value.

FlexRes 8- to 16-bit resolution MSOs available with


Up to 200 MHz analog bandwidth 16 digital channels
Up to 512 MS capture memory
130,000 waveforms per second
2 or 4 channels, available MSO

Includes serial bus decoding (18 protocols), spectrum analysis, mask limit
US$ 1155 - 3025
testing, arbitrary waveform generator, software development kit (SDK) and
segmented memory all standard, with free software updates and 5-yr warranty.

learn more: www.picotech.com/A130 or 800-591-2796 ©2018 Pico Technology LTD. All rights reserved. Pico Technology, PicoScope and FlexRes are registered trademarks of Pico Technology LTD.
September/October 2018 61
Meet the Microbitx:
A Simple to Build, Yet
Challenging All-Band
Transceiver Kit By Steve Jackson

Rarely has there been as much interest in a high


frequency radio as that shown to the Microbitx.
Low power enthusiasts — better known as QRP
operators as well as ham radio hobbyists — have
rushed to place their order for this exciting and
challenging new transceiver kit.

Introduction the user community.


Apparently, the
Ashhar Farhan VU2ESE defective chips are from a
— the polymath from series marked “WX.” Farhan
Hyderabad, India — whose is advising all users who
Bitx series of transceivers have chips from the WX
has taken ham radio’s QRP series to replace them with
world by storm, is following a chip which is known to
his recent Bitx40 success work. Several users have
by offering the impressive replaced the defective chip
Microbitx transceiver, also with the JRC 2073D, and
known in ham radio circles others have used the very
as the Ubitx (which we’ll reliable LM386. Be advised,
refer to it as here). however, that the LM386
1. Blown audio chip from a MicroBitx transceiver.
Having recently is not pin-compatible with
introduced the Ubitx to an eager market, Ubitx’s chip and will require an interface
Farhan has been struggling to keep up to be used.
with the high demand for his new radio Additional fixes for the audio chip
while receiving reports from many users problem can be found on Ubitx.net but
that Ubitx’s audio chips are failing — some most of them require somewhat complex
of them failing in spectacular fashion modifications to the main board.
(Figures 1 and 2). Unfortunately, Farhan’s decision
True to form, Farhan has wasted no not to use chip sockets and instead
time in addressing the problem, but as of solder the chips directly to the board has
this writing he’s been unable to nail down unnecessarily complicated the repair.
the exact cause of the chip’s failure. He’s Farhan stated on his website that the
also not able to say how many of the Ubitx boards were thoroughly tested prior
2. Another blown audio chip.
defective chips have made their way into to being shipped. Still, the defective chip
62 September/October 2018
The first signal that sputters through the ether, past
your mess of wires, into your ears, and out of your
hand into space, is stuff of subliminal beauty that is
the pleasure of the home-brewer alone.
Ashhar Farhan

made its way onto some of the Ubitx


transceivers and is causing difficulty for
the users who bought them.
A more detailed explanation of the
failing audio chip can be found on the
website. Sadly, the failing audio chip is a
black mark on what is otherwise a well-
built and effective transceiver.
About the Ubitx
Technically, Ubitx is very well
designed. It’s an all-band, computer
controlled, and menu-driven transceiver,
which will operate in either voice (SSB) or
Morse Code (CW) modes. Ubitx puts out
between seven and 10 watts of power
on the 40- and 80-meter bands, and
from two to five watts on 20 meters and
above.
Similar to the Bitx40, the Ubix is sold
as a kit (Figure 3) at the very reasonable
price of $129 which includes shipping,
making it one of the most affordable all-
band transceivers in today’s market.
(Shipping for Ubitx is free, but Indian
Post is known to be exceedingly slow. For 3. Microbitx kit prior to assembly.
an additional $10, the kit will be shipped
by DHL which can deliver it within 10 days
of your order. Unfortunately, due to the
unexpectedly heavy demand, shipping on all
Ubitx transceivers has been delayed several
weeks.)
Farhan does not provide technical
support of any kind. Instead, users who
require assistance are referred to the Ubitx
user community for support. The two primary
sites where support can be found are Ubitx.
net and Group.io.Bitx20.
All information about Ubitx is “open
source.” Every schematic, every line of
code, and every page of documentation
are provided to the user. Farhan has often
referred to the Bitx series as experimental and
has invited users to put their own ideas into
action.
Tinkerers and hackers are welcomed, as
well as any user who desires to build or
4. Block diagram of the Microbitx transceiver.
modify the Ubitx.
September/October 2018 63
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2018/09.

7. Schematic for the Microbitx


low-pass filter.

generator.
Farhan has named this combination of
devices “the Raduino.” Generic firmware for
the Raduino comes preinstalled, and more
enhanced versions can be found on user
websites.
The Silicon Labs’ SI5351 frequency
generator has greatly reduced the complexity
associated with building multiple band
transceivers.
By including just one 25 MHz crystal to
serve as the frequency reference, the SI5351
can digitally generate oscillations in the range
of 8 kHz to 160 MHz. To paraphrase Farhan,
the SI5351 has reduced the complexity of
multiband transceivers to a relatively trivial
matter.
5. Up-conversion schematic for the Microbitx transceiver. Neither Ubitx nor its predecessor (the
Bitx40) would have been possible at their low
Farhan believes that by referring the Ubitx users to the price were it not for the Si5351.
general user community for support, everyone will benefit The Ubitx uses an up-conversion, double superhet
from the combined knowledge and experience of the design (Figure 5) to the first intermediate frequency of 45
world’s most competent Bitx users. MHz, eliminating the need for large band-pass filters. At 45
MHz, the roofing filter is 15 kHz wide.
On the Technical Side The signal is down-converted to 12 MHz where an
Ubitx is a state-of-the-art design (Figure 4), with eight-crystal filter (Figure 6) is used for both CW and SSB.
economy playing a role in each decision. Farhan has The eight-pole filter in the second intermediate frequency
sought throughout Ubitx’s design to balance cost with is 2.3 kHz wide.
reliability. The receiver front end has a 0-30 MHz low-pass filter
The control center for Ubitx is the Arduino Nano which is used to keep out signals from FM broadcast
microcomputer which is coupled with an Si5351 frequency stations; refer to Figure 7. This design utilizes a doubly
balanced diode mixer which is made up of two
matched Bat54SL diodes. No amp is required here
because sensitivity at this point is adequate.
Ubitx uses four intermediate frequency
amplifiers which don’t require transformers; each
one has a gain of 16 dB.
Generic 2N3904 transistors are used throughout
the transceiver with four 2N3904s serving as
push/pull drivers to the finals section which uses
inexpensive IRF510 field-effect transistors.
Following the finals are four filters which are in
6. Eight-pole filter schematic for the Microbitx. place to prevent harmonic distortion on the output
signal.
64 September/October 2018
Operator Interface
Another feature of the Ubitx which is
not usually found in low power radios is the
comprehensive and well-conceived operator
interface. Ubitx operators can access a host of
menu options simply by depressing the tuning
encoder. These options include a receive
incremental tuning (RIT), dual variable frequency
oscillators, a CW keyer, calibration, and many
others. Most of the menu options have logical
defaults which are easily overridden.
To enter CW mode from single side-band
mode, the operator need only press his CW key.
The Raduino will return to SSB mode when it
senses that the operator has stopped keying.
The Ubitx kit comes with a completely built
and tested main board, Raduino, and all the
peripherals and parts. It doesn’t include a speaker, a
power supply, or an enclosure.
Building the Transceiver
Instructions for building the Ubitx transceiver
are found on Hfsigs.com. A note to new builders:
The Ubitx build does require soldering. Some prior
experience with kit building and schematic reading
will be very helpful. Ubitx can be assembled by
following the wiring diagrams shown in Figures
8. Farhan’s wiring diagram for the Microbitx.
8 and 9. Or, if the builder prefers, Farhan has placed
more detailed instructions on
his website.
As you build Ubitx, be very
careful that the main board
doesn’t get exposed to static
electricity. Even the smallest
charge of static electricity can
destroy a board’s circuitry.
Included with the kit is a
1N4007 diode which is to be
connected across the power
connector to prevent damage
from short circuits and other
spikes in power. Unfortunately,
the 1N4007 diode doesn’t
provide adequate protection.
Every builder should place
a two-amp fast blow fuse in
the positive line of the power
supply. It’s much better to take
the time to add a fuse than to
stand by helplessly while your

9. Another wiring diagram


for the Microbitx from
Wiki build.
September/October 2018 65
the opening is marked
and scored, I drill four
relief holes; one on the
inside of each corner.
The relief holes will
stop me from cutting
beyond the mark. I use
a rotary tool with a
cutting disc to cut the
opening.
Openings for
the encoder, volume
control, and other parts
are relatively easy to
cut. I prefer to cut these
types of openings with
a hand drill, but some
builders have been
successful using a metal
punch.
When laying out
the enclosure, it’s best
to place the openings
for the power and
antenna connector in
10. Microbitx transceiver ready for testing. the rear panel of the
box. The openings for
printed circuit board burns. the keyer, speaker, PTT, microphone, and volume control
The code keyer must be connected, even if you don’t should be placed on the front panel of the box.
plan to use the Ubitx for Morse Code. Once cutting and drilling are completed, I lightly sand
I used an on/off toggle switch for my PTT (push to talk) the box and follow that by applying a coat of automotive
switch, but a standard microphone can be added if desired. primer. Any primer will likely work, but I’ve found that
There are plenty of schematics online which show how a paint will adhere to automotive primer quite well. Once
hand microphone can be connected to a Ubitx. the primer has dried, I paint my enclosure with a lightly
The microphone, CW keyer, and speaker are textured paint which is very good at covering scratches on
connected to the Ubitx through three 3.5 mm sockets the metal.
which are included with the kit.
The Moment of Truth
Building My Enclosure I’d built a nice enclosure and completed the Ubitx
As I’ve done with past projects, I fabricated my assembly. The time had now come to test my unit (Figure
enclosure from a thin metal box which was once used as 10). Like many hobbyists, I’ve often used the term “smoke
a cookie tin. I like using this type of enclosure because test” in a joking manner, but with the Ubitx audio chips
they’re inexpensive and plentiful, and can be found in overheating and exploding, that phrase didn’t seem quite
many different shapes and sizes. as funny as it once did. It was now time to find out if the
Perhaps the best feature of using this type of material audio chip on my Ubitx was going to work.
is that a nice enclosure can be fabricated by using I made one more scan of the wiring to ensure each
common hand tools. Learning how to build an enclosure part was correctly connected and switched on 13.8 volts of
from thin gauge metal has at times been tricky business, the power.
but over the years, I’ve acquired a few techniques that To my satisfaction and relief, my Ubitx powered up
work well. without blowing the audio chip. As I listened, however,
The most difficult task in fabricating an enclosure from the audio began to degrade and show signs of distortion.
a thin metal box is cutting the opening for the 16x2 mm After operating for a few minutes, the audio became too
LCD. I like to begin by carefully marking the spot for the distorted to be understood.
LCD opening and then scoring it with a sharp edge. Once I performed the tuning procedure described on Hfsigs.
66 September/October 2018
11. My Microbitx transceiver
with enclosure and speaker.

com and it’s here that I realized


my audio chip wasn’t working.
No matter how I tried, I couldn’t
tune my Ubitx to a point where
the audio was distortion-free. The
audio appeared to be better when
my Ubitx first powered up, but
soon, even those few moments of
audio clarity disappeared, and it
was impossible to understand SSB
audio. My audio chip had failed
like the ones being reported on the
forums.
Replacing the Bad
Audio Chip
the task of changing it will be much simpler than it was the
WThe defective audio chip was in a hard to get to spot first time around.
and somewhat challenging to remove. As I replaced the There are a couple ways to remove the defective chip.
defective chip with the JRC2073D, I made sure to use a I did it by clipping the pins of the chip from the top and
chip socket, so should the new chip have to be replaced, then removing each pin one at a time. As I replaced the

www.embeddedARM.com
TS-4900
Computer on Module
WiFi and Bluetooth Enabled
1 GHz i.MX6 Computer Module
Single or Quad Core

TS-7970
Single Board Computer
1 GHz i.MX6 ARMCPU
Single or Quad Core
Up to 2 GB DDR3 RAM
4 GB MLC eMMC Flash
Choose your own adventure. WiFi and Bluetooth

Board Support Packages,


Source Code and Toolchains
Available
September/October 2018 67
defective chip, I made certain to wear my grounding strap failing chip. I feel certain these builders have the best of
to prevent damaging the main board with static electricity. intentions, but how can a user who needs to make these
Once the JRC2073D chip was installed, the Ubitx modifications have any confidence that the proposed
really came to life. Its audio is now crystal clear with changes are feasible?
practically zero distortion. Now, my Ubitx sounds the way I recently read an exchange on a forum where a Ubitx
it was meant to sound. builder posted a question regarding tuning. The fellow who
I’ve yet to make any contacts while using the new answered his post suggested that the way to resolve the
audio chip but prior to the old chip going bad, I made tuning issue was to reinstall the firmware on the Raduino.
several contacts with one of them being almost 700 miles Perhaps reinstalling the firmware was the correct answer
from my station. While testing with the new audio chip, but changing the firmware to address a tuning issue
the Ubitx put out the advertised 10 watts of power on appears — at first thought — to be a bit extreme. Again,
40-meter SSB. how can the user have any confidence that this will work?
My Ubitx is assembled and working very well! You can I was told of another incident on a forum where a
see it in Figure 11. builder was heavily criticized by forum members when
they mistook his question to be personal criticism of
Farhan.
Final Thoughts Of course, none of these concerns would matter very
While I’m hesitant to end on a negative note, I do have much if Farhan’s target market consisted of only engineers
some concerns about Farhan’s philosophy of support. and technicians who possess the technical experience and
As it currently stands, every problem, question, or ability to modify the Ubitx as needed.
support issue of any kind is referred to the user community However, Farhan has stated that one of his primary
on the Internet. The problem with the audio chip is a goals is to use the Bitx series of radios to bring amateur
good example. Builders on several forums have suggested radio to potential users who don’t have a technical
hardware modifications to the main board to remedy the background or who lack access to other sources of
support. With these users in mind,
I question whether the support
offered is comprehensive and reliable
enough.
As a big fan of Farhan and the
entire Bitx series of radios, I view this
lack of direct support as a weakness
in an otherwise great product.
No one wants to see the price
of these radios increase, but it
seems at the very least, one specific
website should be maintained which
can serve as a central repository
of information where builders can
visit and have confidence that their
questions and problems will be
addressed correctly.
Despite the early problems, Ubitx
is an excellent transceiver which
has brought a much-needed jolt of
excitement to the world of low power
ham radio. Ubitx is a worthy addition
to the Bitx family, as well as to the
ham radio hobby.
Farhan and company should be
very proud of Ubitx, and as hobbyists
and builders, we should all be happy
that we get to participate in the
evolution of a radio that is sure to last
for many years to come. NV
68 September/October 2018
By Ryan Clarke
KJ6MSG @kj6msg

FPGAs for the Hobbyist:


NTSC Overview
First thing’s first: What video standard should we use

Shield
as the basis for the shield? The standard that makes the
most sense is HDMI. After all, it’s purely digital and lends
itself to FPGAs (field-programmable gate arrays). However,
Embedded Micro has an HDMI shield and it would be silly
to reproduce their efforts.
How about VGA? It’s really not too tough to
If you have read my previous Nuts & Volts implement the VGA standard on an FPGA, and most
monitors and televisions have a VGA input. Plus, VGA is a
articles in the FPGAs for the Hobbyist tried and true project for FPGAs. I have a better idea! Let’s
go with an old friend: the ubiquitous NTSC standard.
series, you already know that I’m a big You may recognize it as the yellow RCA jack
fan of Embedded Micro’s Mojo V3 FPGA (composite video) or mini-DIN (S-video) on the back
of your television. NTSC is an old analog standard and
Development Board. Embedded Micro offers it’s certainly not the easiest to decipher or implement
on an FPGA, but almost every video input device in the
a handful of expansion shields for the Mojo US includes it as an option. Come on, this will be fun!
(Disclaimer: This was extremely frustrating at times.)
V3. However, at the time I wrote this article, Okay, how do we do it? Like I said before, the NTSC
there was no video shield available. Well, I standard is not simple to implement on an FPGA (more
on that to follow), but thankfully there are already devices
don’t know about you, but that sounded like a on the market that do a lot of the heavy lifting. The device
we’ll use is the Analog Devices AD723 RGB-to-NTSC/
great project to me! So, let’s go on a journey PAL Encoder. This device accepts analog RGB and digital
to design a video shield for the Mojo V3. synchronization signals as inputs and generates the
September/October 2018 69
Post comments on this article and find any associated files and/or
downloads at www.nutsvolts.com/magazine/issue/2018/09.

Figure 1. NTSC Shield schematic.

appropriate analog NTSC signal as both composite and nice to have two frame buffers so that we can page flip.
S-video output. That requires 600 KiB of storage, which leads us to a 1 MiB
As a tradeoff between color depth and ease of RAM device. Long story short, I settled on the Alliance
construction, I decided on an eight-bit 3-3-2 RGB color AS7C38096A 1M x 8-bit 10 ns SRAM. See Figure 1 for the
palette. What does that mean? Well, it means there are shield schematic.
three bits for red, three bits for green, and two bits for
blue, totaling 256 colors. (As a side note, the reason
that blue only gets two bits is because the human eye is Construction
less sensitive to the color blue.) The RGB input must be Fair warning here! If you don’t like soldering SMT
between 0-714 mV, which we can easily achieve with a (surface-mount technology) devices, then I have bad news:
binary-weighted resistor DAC (digital-to-analog converter). The entire shield — except for the expansion headers and
Okay, so we’ll generate an NTSC signal, but I think output jacks — is SMT. It’s really not that bad, honest! The
we need more. Wouldn’t it be nice to have some video hardest part to solder is the 14.31818 MHz color burst
memory to play with? Although the Xilinx Spartan-6 on the oscillator (U2). It’s lead-less and the footprint isn’t exactly
Mojo V3 has a bunch of onboard Block RAM (64 KiB), it’s huge, but with a little bit of patience it doesn’t take much
not enough for a reasonable frame buffer. No problem! fuss.
We’ll just add external RAM to the shield! We need that PRO-TIP: Be careful when soldering the SRAM. It has
video RAM to be fast, but it also needs to have enough many fine-pitch leads and it’s very easy to bridge them
capacity. while drag soldering (this may or may not have happened
Let’s target a resolution of 640x480, which is to me). If you have the ability to reflow solder, then this is
equivalent to VGA. At one eight-bit byte per pixel, we all mostly trivial.
require 300 KiB of storage. I personally think it would be There’s no preferred sequence to solder the shield.
70 September/October 2018
Figure 2. Completed NTSC shield.

Figure 3.
Prototype NTSC
shield.

Resources Video Basics


Hackaday.io Project Page https://www.maximintegrated.
https://hackaday.io/ com/en/app-notes/index.
project/25560-ntsc-shield mvp/id/734

OSH Park PCB Page Video Formats and Required


https://oshpark.com/shared_ Load Terminations
projects/dF2GZoa9 www.analog.com/
media/en/technical-
Github Page documentation/application-
https://github.com/kj6msg/ notes/478955693AN205.
ntsc-mojo pdf?doc=adv7125.pdf

Analog Video 101 AD723 Datasheet


www.ni.com/white- www.analog.com/media/en/
paper/4750/en technical-documentation/data-
sheets/AD723.pdf
Television Safe Areas
Redefined AS7C38096A Datasheet Figure 4. NTSC raster scan (ntsc-tv.com).
https://www.nab.org/xert/ www.alliancememory.com/
scitech/pdfs/tv031510.pdf pdf/sram/fa/as7c38096a.pdf
during the same year as the attack on Pearl Harbor. So,
why is it difficult to implement on an FPGA?
I started with the integrated circuits, then moved to the Well, when the standard was first written, it was
resistors, capacitors, and inductor, and finally finished with designed for black and white televisions. Sometime later in
the jacks and headers. It took me about two days to solder 1953, the engineers added color. Since most people still
by hand, working about two hours each day. owned black and white televisions, the engineers had to
I would definitely recommend using a continuity figure out how to integrate color information into the older
tester to make sure you haven’t bridged any pins. Oh, I signal. They had to do this while simultaneously retaining
forgot to tell you ... you can prototype the video portion backwards compatibility. This makes the standard a bit
of this board. I used a different encoder (AD725) with a interesting. No, really!
breadboard adapter and there are some minor changes to If you read about the history and how the engineers
the schematic. The completed shield can be seen in Figure made it happen, it’s quite fascinating! Anyway, the color
2 and the prototype in Figure 3. The prototype schematics information is stored by varying the amplitude and phase
are available with the article downloads. of the color burst signal (actually 3.57545 MHz). That kind
of analog work doesn’t mesh well with FPGAs.
From the 10,000 foot view, an NTSC signal is made of
NTSC Standard frames, fields, and lines. A frame is one complete picture
The NTSC standard is old. How old, you ask? I’ll give on the screen and a field is one half of a frame. Okay, I
you a hint: The first iteration of the standard was developed know what you’re saying ... “huh?” The NTSC signal is
September/October 2018 71
Figure 5. Vertical synchronization lines
(SMPTE 170M-2004).

interlaced, which means each field contains every other those black lines. That leaves 484 active video lines per
line of a frame and a complete frame is constructed by frame. Since we’re going to be working with digital logic,
displaying alternating fields. it’s a lot easier to round that down to 480 lines.
The fields are labeled as either an odd field or an even What about horizontal resolution? Some quick public
field. The field rate is 59.94 Hz, making the frame rate math: For a 29.97 Hz frame rate and 525 vertical lines, we
29.97 Hz. Each field contains 262.5 lines, which consist of have about 63.56 µs per line. However, approximately 10.9
video and synchronization signals. I think I heard another, µs of each line consists of the horizontal synchronization
“huh?” Yes, fields contain half lines and when added signal, leaving 52.66 µs of active video. To generate 640
together, the entire frame is 525 lines. This does actually horizontal pixels in that time, we would need a 12.15 MHz
make sense once you see how the electron beam traverses pixel clock. To keep the math easy, we round that up to
the screen in Figure 4. 12.5 MHz and black out the extra pixels. Figure 6 shows
So, our NTSC picture has a vertical resolution of 525 the profile of an active video line with the appropriate
lines, which is not too bad for an old analog signal! Not synchronization signals.
quite. Some of those lines are vertical synchronization Alright! We squeaked a 640x480 resolution out of
signals which consist of a series of pre-equalizing pulses, NTSC! Well, sort of. I know, you’re getting sick of the curve
vertical synchronization serrations, post-equalizing pulses, balls. Although it’s true we can output that many active
and blank lines. Figure 5 should clear all that up for you. pixels, the unfortunate reality of NTSC video is that there
There are at least 20 vertical synchronization lines in are areas of a picture that may or may not be shown. The
each 262.5 line field, which leaves 242.5 active video lines two basic restrictions are the action-safe area and the title-
per field, or 485 active video lines per frame. To be honest, safe area. Long story short, we will use action-safe because
half lines are a bit frustrating to deal with, so let’s make you should be able to see that region on most modern TVs.
72 September/October 2018
By the NTSC specification, the action-safe Figure 6. Horizontal
synchronization and
area is defined as 93 percent of the total picture. active video.
Because we are running a 12.5 MHz pixel clock
and generating 658 active pixels, this results in 612
action-safe pixels. To make the math easier, let’s
shrink that to 600 horizontal pixels.
We need to retain the 4:3 aspect ratio of a
standard definition television. This leaves us with a
vertical resolution of 450 lines, which is exactly 93
percent of 484 vertical lines! Our final resolution is
600x450, which is a bit non-standard. That’s okay! If
you look at past video game systems and computers
that output NTSC, they all ran at non-standard
resolutions.

SRAM Interface
Enough with that cryptic NTSC video standard!
Time to move on to the SRAM, which is a bit easier
to manage. I suggest you follow along with the
device’s datasheet while reading this section. The
SRAM Chip Enable (#CE) signal is hard-wired low
on the shield to enable continuous selection. This
simplifies the SRAM controller logic and because
of this, a read operation depends entirely on the
Output Enable (#OE) signal. Data is available 10 ns after the current horizontal sample and vertical line in a pair of
an address change. However, it’s not valid until 4.5 ns after registers (h_count_ff and line_ff).
#OE transitions low. Let’s look at some important sample and line numbers.
The write operation is a little different. The address For horizontal synchronization:
must be stable for 0 ns before Write Enable (#WE)
transitions low. Yup, zero setup time! The #WE signal must • Front Porch: 19 samples / 1.52 µs
then be held low for 8 ns and the address
must continue to remain stable for 2 ns C1, C2, C3, C5, C7, C10, C11 0.1u 445-14600-1-ND
after #WE transitions high. This translates C4 27p 399-9341-1-ND
to a minimum write cycle time of 10 ns. C6, C8 10u 478-8150-1-ND
The exact details of the SRAM controller
module will be outlined later in the article. C9 0.01u 445-14599-1-ND
J1 MD-40SM CP-2240-ND
Verilog Design J2 RCJ-014 CP-1403-ND
We are done with the hardware! Time L1 68u 445-15774-1-ND
to talk about the Verilog logic. The NTSC R1, R3, R6 510 311-510ERCT-ND
module (ntsc.v) consists of a pixel clock
R2, R4, R7 1K 311-1.0KERCT-ND
(pixel_clock.v) and a sync/pixel generator
(ntsc_sync.v). The pixel clock divides the R5, R8 2K 311-2.0KERCT-ND
50 MHz Mojo V3 clock by four and emits R9, R10, R11 75 311-75ERCT-ND
a 20 ns tick at 12.5 MHz. This keeps the
sync/pixel generator synchronous with the R12, R14, R16 374 311-374FRCT-ND
Mojo V3 master clock. That’s pretty simple! R13, R15, R17 301 311-301FRCT-ND
Unfortunately, the sync/pixel generator is a
U1 AD723ARU AD723ARUZ-ND
bit more complicated.
The sync/pixel generator outputs the U2 ASV-14.31818MHZ-EJ-T 535-9310-1-ND
current pixel coordinates as well as the U3 AS7C38096A-10TIN 1450-1067-ND
horizontal and vertical synchronization
Stackable Headers Embedded Micro Digi-Key Part #s
signals. To accomplish this, it keeps track of
September/October 2018 73
pixels each) on the screen. The pattern linearly
increases the red and blue values on the horizontal
axis (four blues for each of the eight reds) and
increases the green value on the vertical axis (eight
greens). The color bar test is rather simple: Each of
the eight full-scale RGB values are displayed as a
series of eight vertical bars on the screen. The video
portion is done!
Let’s take a look at the SRAM controller
(sram_ctrl.v). The controller accepts a read or write
command and executes via a finite state machine.
Although the SRAM is capable of 10 ns operation,
the state machine takes 60 ns to complete either
operation. I know, that’s rather slow, but it simplifies
Figure 7. NTSC test module output. the coding. The Verilog logic should be self-
explanatory.
To test the SRAM, I wrote a series of test
• Sync Tip: 59 samples / 4.72 µs routines (sram_test.v). The first test is a data bus test (data_
• Half Line: 397 samples / 31.76 µs bus_test.v), which tests each data bus line (DQ0 to DQ7).
• Full Line: 794 samples / 63.52 µs The pseudo-code is:
• Active Region: Samples 165 to 764 (x = 0 to 599) / 48 µs
write DQ0 (0x01) to 0x00000
verify DQ0 at 0x00000
For vertical synchronization: repeat for DQ1 through DQ7

• Pre/Post-Equalization Pulse: 29 samples / 2.32 µs The next test is an address bus test (addr_bus_test.v),
• Vertical Serration: 59 samples / 4.72 µs which tests each address bus line (A0 to A19). This test is a
• Pre-Equalizing Pulses: Lines 0 to 5 bit more involved:
• Vertical Serrations: Lines 6 to 11
• Post-Equalizing Pulses: Lines 12 to 17 initialize A0 (0x00001) through A19 (0x80000)
with 0xAA
• Half Line: 18 (even) and 525 (odd)
• Field End: 524 (even) and 525 (odd) write 0x55 to 0x00000
• Active Region: Lines 58 to 507 (y = 0 to 449) verify A0 through A19 unchanged
write 0xAA to 0x00000

By convention, we’ll start each frame with line one, write 0x55 to A0
which is the first line of the odd field. The vertical line verify 0x00000 and A1 through A19 unchanged
write 0xAA to A0
register increments by two to generate the interlaced video repeat for A1 through A19
signal. You may notice that the vertical line register actually
counts to 526 lines. This is a simple hack to solve the half The final test is the device test (device_test.v), which
line problem. verifies that each address can hold both a zero and a one
The synchronization signals are enabled and disabled bit. This test is fairly straightforward:
based on the horizontal sample number and vertical line.
Additionally, the active video signal (active_video) indicates write 0x00 to 0x00000
write 0x01 to 0x00001
that the sync/pixel generator is in the active video region. repeat through 0xFFFFF
Therefore, the pixel coordinates are valid. verify 0x00000 through 0xFFFFF
To test the NTSC module, I wrote a test module (ntsc_
write 0xFF to 0x00000
test.v) which implements a font ROM test (font_test_gen.v), write 0xFE to 0x00001
a palette generator (rgb_332_palette.v), and a color bar repeat through 0xFFFFF
generator (color_bars.v). The font ROM test prints all 256 verify 0x00000 through 0xFFFFF
characters in the included 4 KiB font ROM, which is based
on the classic Code Page 437 VGA 8x16 pixel character The results of the tests are displayed on the Mojo
set. If you’re a DOS veteran, you will remember it well! V3 LEDs (*LED0 *to LED2) and the final test complete
The test prints the characters in a 64x4 matrix at indication is indicated on LED7.
the top of the screen. Next, the test module outputs the
complete 256-color palette in a 32x8 block pattern (16x16
74 September/October 2018
Testing miniature computer using the NTSC shield as the video
sub-system!
Several Verilog test benches are included to verify the I’d like to acknowledge Dr. Pong P. Chu’s book,
operation of the video and SRAM test modules. The NTSC FPGA Prototyping by Verilog Examples. The book was
test benches generate a BMP file to simulate viewing the instrumental to me understanding how to implement a
output on a television screen, as seen in Figure 7. The SRAM controller. The book also provided insight on how to
code converts the eight-bit 3-3-2 RGB color to a 24-bit implement a video controller. Although Dr. Chu references
RGB color to prevent having to deal with indexed palettes the VGA standard, it was helpful for me to translate it to
in the BMP file. the NTSC standard. Until next time, have fun! NV

Conclusion
There are some issues with the
NTSC shield design. At this point,
ALLELECTRONICS.com
Surplus & New Parts & Supplies since 1967
there is no way to turn on and off
the video signal via the FPGA since
the AD723 enable is hard-wired.
Order Online or Toll Free 1-800-826-5432
The same is true for the SRAM, as 25FT CATEGORY WATERPROOF AUDIO
we discussed earlier. Additionally, 5E PATCH CABLE TRANSDUCER
the NTSC sync/pixel generator Snagless molded RJ45, These transducers produce
depends on a lot of combinational 350Mhz, UTP, Pure Bare sound by conducting
logic. This can be tightened up with Copper stranded 24AWG, Blue vibrations into the surface
more registers and it’s something I’m CAT# CB-525 they are attached to.

2
$ 50 10 for $2.25 each Connect to an audio source and press it
planning on fixing in the future. 100 for $1.85 each against the nearest table, wall or cardboard
each
There are also some issues with box and hear surprisingly good sound re-
the video output. You will notice 0.95" SPHERICAL MAGNET production. Waterproof and heat resistant,
dot crawl on the composite output they are ideal for marine, RV, sauna or golf
0.95" (24.5mm) spherical magnet, cart. 2.4” diameter. 8 Ohm, 20 Watt.
when looking at the color bars. This possibly neodymium, with a fairly
is normal at the boundary between strong pull. Black in color with a
CAT# AT-20
2 for $
2900
two different colors, but it can be
distracting.
shiny metallic finish.
CAT# MAG-162 1
$ 50
each
36" MICRO-USB CABLE -
Another issue is pixel jitter. 4-OUTLET POWER STRIP VERY SPECIAL PRICE
This happens because the AD723 WITH 10 FT. CORD We just received a bunch of
is operating asynchronously from these Micro-USB to USB
Compact, power cables, and we'd like to
the Mojo V3. To fix this, the NTSC distribution strip with move them. One of
shield would have to be redesigned 15A circuit breaker/ the most popular
lighted power switch.
to send the 14.31818 MHz color charge and sync cables for smart phones,
Heavy-duty 10' tablets, cameras and other portable devices.
burst oscillator to the Mojo V3. 14/3 power cord with Connects to USB port in cars, computers
Clock domain crossing logic would space-saving right-angle and chargers. 3' overall length.
be needed to synchronize the two plug. Keyhole slots in rear to
CAT# CB-427
allow wall or desk mounting.
1
$ 50
systems. You know what? I’ll leave 10 for $1.25 each
that as a fun project for you!
So, what can we do with this
9.25" x 1.60" x 1.20" high. cULus. $
CAT# PST-40 7 95
each
each
100 for $1.00 each

92 PIECE ASSORTMENT OF
thing, anyway? Well, you already have HIGH-VOLTAGE TASER GEARS, PULLEYS, AXLES ETC.
a 256 font ROM at your disposal. COMPONENT Large set of 92
It wouldn’t be too tough to write Converts 3.7 Volts to approx- various sized
a video interface for the Mojo V3 imately 18,000 Volts. The main plastic gears,
serial port. With the 1 MiB SRAM, component in a taser/ stun gun, racks, wheel set,
it creates quite a spark and a loud pulleys, belts and
you could certainly make a video crackling noise when the probes axles. A lot of stuff
game system on the Mojo V3. Oh, I are within 1/2" inch of each other. at a nice price!
forgot to mention! The NTSC shield is 1.35" x 1.55" x 0.31". The output CAT# GR-53

9
leads have pointed probes attached.
compatible with the Embedded Micro $ 95
SDRAM shield. Put a soft processor
core on the FPGA and design a
Warning: Operate carefully!
CAT# HVS-01
$
950 each
set

September/October 2018 75
Mass Confusion By C. A. Hamilton
vmetrix@comcast.net

The End
of the Kilogram
as We Know It
This November, in Versailles, France, representatives from 57 countries are
expected to make history. They will vote to dramatically transform the international
system that underpins global science and trade. This single action will finally realize
scientists’ 150 year dream of a measurement system based entirely on fundamental
properties of nature. Photo Credit: J.L. Lee/NIST

The International System of Units, informally known as the metric system — the way in which the
world measures everything from coffee to the cosmos — will change in a way that is more profound
than anything since its establishment following the French Revolution.

It will be a turning point for humanity.

E
very day, scientists and engineers use measurements So, let’s talk about the volt. The volt is a derived unit
in design and research, but most of us give little which means that once the kilogram, meter, second, and
thought to the basic definitions of our measurement ampere are defined, the equivalence of mechanical and
system, and fewer still know that in the next year those electrical power dictates the definition of the volt. See the
definitions are in for some major changes. Take the volt, for formal definition below.
example. The creation of the metric system in 1790 was the first
Readers of this magazine ought to know the definition time that scientists had the idea that measurement units
of the volt, but I’ll bet that most don’t. I graduated with should be connected with constants of nature. At the time,
three engineering degrees and at the time, I could not have the Earth itself was seen as the best constant of nature. So,
told you the definition of the volt. Last year, at my 50th the second was defined as 1/86400 of a day, the meter
college reunion, I gave a seminar in the EE Department on was a best estimate of 10-7 of the distance from the equator
electrical metrology. Most of the EE professors and many to the north pole, and the kilogram was taken as 10-3 of the
students were present. I asked, “Who knows the definition weight of a cubic meter of water.
of the volt?” … Silence. Since neither the surface of the Earth or a box of water

One volt is defined as the difference in electric potential between two


points on a conducting wire when an electric current of one ampere
dissipates one watt of power between those points.
76 September/October 2018
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2018/09.

make useful working standards, the formal definition of the constants that are more fundamental than the details of the
meter became the distance between two scratches on a Earth. With the invention of atomic clocks, the second was
platinum iridium bar, and the kilogram became the mass of the first quantity to be redefined in terms of a fundamental
a cylinder of platinum-iridium. Both these artifact standards constant and is now defined as the duration of 9 192 631
have been preserved for more than a century in a vault at 770 (fcs) oscillations of the Cesium atom.
the BIPM (Bureau International des Poids et Mesures) near In 1983, the invention of lasers allowed the speed of
Paris. light to be defined as c = 299 792 458 m/s thus defining
Beginning about 1900 with the development of the meter.
quantum mechanics, it became clear that nature has

The meter is the length of the path traveled by light in a vacuum


during a time interval of 1/299 792 458 of a second.

T he Josephson effect (V = hƒ/2e) has connected the
volt to a known frequency ƒ and the constants h and e
(e = electron charge and h = Planck’s constant). The Von
If we could apply a known force to an unknown mass
and then measure the acceleration, we could calculate
the mass. The problem is that to be an improvement over
Klitzing Effect has made possible a laboratory realization of the artifact kilogram, both A and F should be measured to
the quantum resistance h/e2 = 25812.80757 ohms. better than about three parts in 108.
If we apply a Josephson voltage to the quantum Acceleration can be measured with the required
resistance, Ohm’s Law gives the resulting current I = V/R accuracy by counting fringes from a moving mirror in a
= ƒ e / 2. Of the primary physical and electrical quantities, laser interferometer. We can calculate a magnetic force
all but the kilogram now has a quantum realization. The between two current-carrying coils from knowledge
kilogram has resisted redefinition for nearly five decades. of the currents and the detailed geometry of the coils.
Even more concerning is that over the last 70 years, Unfortunately, uncertainty in the geometry leads to
the artifact kilogram in Paris appears to have lost about 50 an uncertainty in the force that falls several orders of
micrograms relative to six copies that — among themselves magnitude short of the required three parts in 108.
— are more stable. Only the kilogram is standing in the In 1980, Brian Kibble suggested a beautiful way to
way of a redefinition of the metric system in terms of the circumvent this problem. His apparatus is a balance scale.
fundamental constants e, h, c, and ƒces. On one side is the unknown mass. On the other side is
Think about it. At present, all our measurements a coil that can move vertically in a magnetic field. The
of mass depend on a comparison to some other mass balance works in two modes: calibration mode and force
and ultimately to that block of platinum-iridium in Paris. mode.
How could we measure a mass in terms of fundamental In calibration mode (switch open), the coil is moved
constants? The first thought is Newton’s Second Law F = vertically at constant speed S. From Faraday’s Law, this
MA or M = F/A. produces a voltage:
V = BLS
Figure 1. The golf
ball sized cylinder Since V and S can be measured with high accuracy,
of platinum-iridium the product BL can be calculated BL = V / S — in effect
that has defined calibrating the apparatus without the need for a detailed
the kilogram since
1905.

Figure 2. This
apparatus
compares
electrical and
mechanical power
and is generally
referred to as a
watt balance (BL ≈
50 Vs/m).
September/October 2018 77
knowledge of the magnetic field or the coil geometry. labs for almost four decades. After many redesigns and
In force mode, a current I is applied to the coil to millions of dollars, the goal of three parts in 108 is clearly in
produce a force IBL to exactly balance the gravitational sight. Independently designed experiments that are going
force Mg (g = acceleration of gravity) of the unknown on now around the world should soon confirm the viability
mass. So, we have: of a quantum-based mass standard. If all goes as planned,
Mg = IBL or M = IBL / g the kilogram redefinition will occur in November of this
year.
Assuming the product BL has not changed between Looking at the big picture, over the last seven
the two modes, we can substitute the measurement of BL decades, the legacy artifact standards (meter, kilogram,
to get: second, and ampere) have been used to measure the
M = (I V) /( S g ) constants of nature with ever greater accuracy; in each
or case, reaching an accuracy limited by the stability of those
MgS = IV (Mechanical Power = Electrical Power) legacy standards. Going back to the original idea that our
measurement system should be based on the constants of
V, S, I, and g can all be quantum-based measurements nature, the obvious path is to assign defined values to the
as described above. The equation above shows that this electron charge e, Planck’s constant h, the speed of light c,
apparatus equates electrical and mechanical power, so and the cesium oscillation frequency ƒcs (or some similar
it’s commonly called a Watt Balance. As a result from the quantum frequency).
Josephson equation for voltage of the volt, when we place With those four definitions soon to be formalized, all
a known mass on the balance, the experiment boils down the quantities mass, distance, time, energy, power, voltage,
to a measurement of Planck’s constant h in terms of the current, and resistance will be measured in units derived
kilogram, meter, and second. from fundamental constants.
Conversely, by defining the value of h together with For metrologists, this is an earth-shaking change, but
already defined values of c and ƒcs, the kilogram becomes since the values of the fundamental constants will be
a quantum-based unit wholly derived from the definitions chosen to align the old and new measurement systems,
of e, h, c, and ƒcs. most of us will not notice the difference.
Needless to say, driving the uncertainty of this mass
measurement below three parts in 108 is a daunting task •
that has been pursued at NIST and other national standards THE PROJECT
As a science project in do-it-yourself physics, it’s fun
to imagine other ways to make a mass measurement by
equating mechanical and electrical energy; something
simple that might achieve 1% or better accuracy. My
first thought was to use a DC motor to lift a mass M at a
constant speed S.
Assuming no losses, we can equate the electrical
power into the motor to the mechanical power of lifting M,
so we have:
IV
P = IV = MgS and M =
gS
I gave this a try, but unquantifiable losses in the
motor and particularly the gear head made this method
unacceptable.
From the point of view of universal elegance, the
motor lifting experiment — as well as the watt balance
experiment described above — fall short because both
measurements must be performed in a measurable
gravitational field. If we were traveling in a space ship to

Figure 3. A watt balance constructed at NIST as part


of the kilogram redefinition project. Note the bell jar at
top that is lowered so that measurements are made in
Photo Credit: J.L. Lee/NIST a vacuum to eliminate atmospheric buoyancy errors.
78 September/October 2018
another solar system, these methods could not maintain a Figure 5. The PCB for the mass
quantum-based mass standard along the way. measurement experiment.

A Better Way
The gravity and gear head problems can be avoided if,
instead of lifting the mass, we measure the energy required
to spin a mass. Physics 101 tells us that the energy of a
solid spinning cylinder is:
(π2 / 4) MD2 ƒ2

where M is the mass of the cylinder in kg, D is the diameter


in meters, and ƒ is the rotational velocity in revolutions/
second.
Now, suppose that we set the cylinder spinning with a
motor and measure the electrical energy Ee = IVT required
to spin the cylinder up to a rotational rate of ƒ in a time T.
I and V are the current and voltage applied to the motor.
Equating the electrical and mechanical energies, we have:
4IVT
IVT = (π2 / 4) MD2 ƒ2 and solving for M M =
π2D2ƒ2
This equation ignores electrical resistance loss and
friction in the motor. As you will see in the circuit design
that follows, we can measure and eliminate these losses. motor, plus make possible the accurate measurement I, VT,
Figure 4 shows a motor drive and measurement and ƒs by eliminating the effects of friction and resistance
block diagram that when calibrated against standards losses. While Figure 6 looks complicated, it’s just the
of time, voltage, current, and length allows an accurate combination of four relatively simple circuits.
measurement of the product IVT and ƒ. Briefly, it works as At the upper left, op-amp U3 uses positive feedback to
follows: implement a latching comparator. The start button latches
We measure D with a digital caliper (our length the U3 output into positive saturation (13V), providing
standard). When the start button is pushed, a constant the control voltage for the motor and starting the voltage
current is applied to the motor. As it spins up, ƒ is integration via relay K12. When the motor voltage rises
compared to a preset stop value ƒs. At the same time, to a value set by trimpot VR11, U3 will flip to negative
the product VT is accumulated in an integrating amplifier. saturation, turning off the motor and integration.
When ƒ = ƒs, the integration is shut off. I is measured with At the lower left, op-amp U1 (LM7171) provides
an ammeter. VT is measured with a voltmeter, and we have a motor drive with ±100 mA capability. Depending on
everything required to calculate M. switch S1, the drive is constant voltage or constant current.
Figures 5 and 6 show a measurement circuit and its Constant current is achieved by returning the motor
PCB (printed circuit board) that is designed to power the current to ground through R3 and using the voltage across
R3 as the feedback for U1.
A small paper tab on the rotating cylinder intersects
an LED-detector pair to produce a pulse waveform at the
rotation frequency. The frequency of this pulse waveform
and thus the rotation rate can be measured with a
frequency counter or oscilloscope.
At the upper right, U7 is a programmable timer that is
used to calibrate the VT integrator U4. The LS7210 has an
internal oscillator with a frequency set by C40 and R40; in
this case, 2,795 Hz. The timer counts a specific number of
oscillations set by five digital inputs at pins 9-13. Grounding

Figure 4. A concept diagram for measuring the mass


of a spinning cylinder by equating mechanical and
electrical energy.

September/October 2018 79
Figure 6. The schematic of the PCB in Figure 5

only pin 13 sets the count at 16369, yielding a time delay article downloads.
of 5.856 s. My motor was harvested from a defunct CD drive.
At the lower right is U4 — the VT integrator that I turned up the brass cylinder on my mini-lathe. Suitable
is started and stopped by relay K12. Switch S4 selects disks in brass (~$20) or steel (~$5) are available from
resistive feedback through R31 for simply amplification, McMaster Carr. To run the experiment, you’ll also need
or capacitive feedback through C31 for integration. In a ±15V DC power supply, a digital voltmeter, and a
integration mode, the U4 output ramps up at a rate frequency counter or oscilloscope.
proportional to the voltage input. Button B3 shorts the
capacitor and resets the output to zero.
I designed the circuit using parts available in my shop, CALIBRATION
but if you buy it all, the total will be about $60 plus the The circuit of Figures 5 and 6 has five modes of
PCB. The PCB and its layout files are available with the operation: four calibration modes and one run mode. In
mode 1, we’ll calibrate integrating amplifier
U4 by applying a 10.00V reference voltage
input for a precise time and then adjust the
gain so that Vout equals exactly 0.1VT. The 10V
reference voltage and Vout are both measured
with our voltage standard: an Agilent 34420
six-digit voltmeter.
In mode 2, we calibrate the motor voltage
by correcting out the component of motor
voltage caused by the motor resistance. With
25 mA applied to the motor, we prevent the
motor from spinning so that the motor voltage
is I Rm where Rm is the resistance of the motor.
Trimpot VR30 is then adjusted to subtract
the voltage I Rm from the input to the integrator.
Figure 7. Motor current as a function of motor voltage. This ensures that the part of the motor
voltage associated with resistive loss is excluded from the
80 September/October 2018
Cylinder Diameter (D) m 0.0351 0.0351 0.0351 0.0351 0.0351 0.0351 comparator U3 trips off. This
Applied Current A 0.0209 0.026 0.0317 0.0317 0.0317 0.0399
sets the spin-up stop point at a
known frequency ƒs, measured as
Friction Current A 0.01 0.01 0.01 0.01 0.01 0.01 described previously.
Effective Current (I) A 0.0109 0.016 0.0217 0.0217 0.0217 0.0299 Mode 5 is the main
Measured VT V-s 35.9 21 14.6 25.8 30.2 19 measurement mode — what we’ve
Max RPS (F) Hz 23.81 23.2 21.7 29.4 32.26 30.3 been getting ready for. Press the
reset button to zero the integrator
Calc Mass Kg 0.227 0.205 0.221 0.213 0.207 0.204
and the start button to start the
Table 1. Experimental Results. spin-up and the VT integration. When the rotation rate ƒ
reaches the set point ƒs, latch U3 will turn the motor and
integrator output Vout. the integration off. The DVM will read the 0.1VT product —
In mode 3, we measure the motor voltage as a the last data point needed to calculate M.
function of motor current when the motor is running at Table 1 is a spreadsheet showing experimental
constant speed. Since there is no other load, all the motor data and the resulting mass calculation for a range of
current is used to overcome friction. drive currents I and cut-off frequencies ƒs — all of which
In Figure 7, we can see that the current required to should produce the same result. The scatter of the results
overcome friction varies only from about 9 to 11 mA over in Table 1 is a measure of the uncertainty of the mass
the range from 0 to 7V So, in a spin-up from 0 to 7V, we determination.
can compensate for friction by subtracting 10.0 mA from The average of the five measurements shown is 0.213
the measured motor current. Kg. I would expect it to be slightly high because I havn’t
In mode 4, we set the integration stop point to accounted for the mass of the rotating parts in the motor
occur when the rotation rate ƒ is at a precise value. With which add about 1% to the total moment of inertia. My
7V applied to the motor, adjust VR11 slowly CW until kitchen scale gives the mass of the rotating cylinder as
0.210 Kg.
Mass Experiment Parts List This little science project tries to give an inkling of
the complexity of metrology research. It
4 TL071IP U3,U4,U5 Operational Amplifier touches a multitude of areas in physics,
1 AD620ANZ U2 Instrumentation Amplifier electrical engineering, and metrology
1 LM7171BIN U1 Op-Amp 100 mA including energy, power, and moment
2 AGN20012 K12,K40 12V DPDT Relay of inertia calculations, op-amp circuit
1 LT1460GCZ-10#PBF U6 10.00V Reference design, DC motors, error correction,
1 LS7210 U7 comes with PCB Programmable Timer and uncertainty analysis — a perfect
3 LEDs 11,12,40 Red LED combination for a physics or EE lab
1 H21A1 OC1 Slotted Optical Switch experiment.
2 2N3904 Q15,Q40 NPN Transistor
The idea of a fundamental
measurement of mass using a motor and
4 EVQ-11A04M B1,B2,B3,B4 Tactile Switch
a spinning flywheel was chosen because
3 1N914 D12,D30,D40 Diode
it’s doable with modest hardware and
1 MFR-25FBF52-49.9 R3 Resistor 49.9 ohms 1% effort. I’m sure that NV readers will
2 MFR-25FBF52-1k R12,R64 Resistor 1K see a multitude of refinements and
1 MFR-25FBF52-4.7k R61 Resistor 4.7K improvements — that is the stuff of
4 MFR-25FBF52-15k R1,R11,R13,R14 Resistor 15K metrology.
3 MFR-25FBF52-10k R2,R41,R42 Resistor 10K 1% Refinement of the much more
5 MFR-25FBF52-47k R15,R40,R50,R51,R62 Resistor 47K 1% complex watt balance is a process that
2 MFR-25FBF52-100k R30,R31 Resistor 100K 1% continues in multiple national standard
1 Digi 496-2316ND C40 Capacitor 0.01 µF laboratories around the world and is
11 Digi 478-3192ND Bypass at op-amps Capacitor 0.1 µF homing in on a mass uncertainty of
3 Digi 399-4390ND C1,C12,C64 Capacitor 1 µF three parts in 100,000,000 — roughly
3 Digi 493-1548ND C31,C40,C50 Capacitor 100 µF
the weight of a fly’s wing relative to the
kilogram. When that happens, the metric
1 Jameco 2217781 M1 DC Motor
system will finally be defined in terms
1 McMaster Carr 7786T12 Flywheel Flywheel, Steel of the speed of light, the charge on an
A limited supply is available in the NV webstore and comes with the electron, the Planck constant, and the
1 PCB
LS7210* (U7). Gerber files are also available in the downloads. Cesium frequency. NV
September/October 2018 81
Musical Kits
Altura Theremin
MIDI Controller Kit Macchiato Mini Synth Kit

Macchiato Mini Synth Kit

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

Nuts & Volts and SERVO On CD

82 September/October 2018
To Order Visit
store.nutsvolts.com
or call
1-800-783-4624

Our Most Popular Clock Kits

September/October 2018 83
■ BY LOU FRENZEL W5LEF OPEN COMMUNICATION

How Phased Array Antennas Work


One of these exotic antennas is
in your future.

W hat do you think of when you hear the term antenna? Do you picture a cell phone
tower, an old TV antenna, a vertical whip antenna used for CB radio, or a wire
antenna used by hams? Or, something else completely?

Antennas come in a wide range of forms f = 300/λ


depending on the application, service, and λ = 300/f
frequency of operation. Some antennas you Here, λ is in meters and f is in MHz.
can’t even see -- like the four or five units in your For example, a frequency of 1,296 MHz has a
wavelength of:
smartphone. These antennas are single element
devices, a metal structure, or printed circuit λ = 300/1296 = 0.23 meters or 23 cm
board (PCB) pattern that are connected to a A half wavelength is:
receiver or transmitter by a transmission line. λ/2 = 11.5 cm or about 4.5 inches
Now, another type of antenna is emerging to address (NOTE: There are 2.54 cm per inch.)
the forthcoming exotic 5G cellular systems and other
advanced wireless products like Wi-Fi routers. This antenna Also keep in mind that the length of an antenna
is the phased array: a group of antennas that work together depends on the frequency of operation. A half wavelength
to provide some significant benefits and capabilities not is generally computed with the expression:
available with the simple antennas we know.
L = 492/f
Phased arrays have been used for years in military
radars for long range detection of missiles. They’re also where f is the frequency in MHz and the length L is in feet.
widely used in military and commercial aircraft radars and This formula can also be used where L is in meters:
some satellites. These phased arrays are expensive, but
λ = 150/f
today thanks to new technology and higher frequencies,
phased arrays are smaller and more affordable making The higher the frequency, the smaller the antenna. At
them practical for new wireless devices. This article is an
introductory tutorial on this special antenna type you need
to know about.

Antenna Types
Different types of antenna elements are used to make
up an array. Those commonly used in phased arrays are the
dipole and patch; refer to Figure 1. The dipole is a basic
half wavelength conductor fed at the center. A patch is
usually a half wavelength copper square on a PCB. Other
antenna types have been used. The spacing between the
antenna elements varies with the design but is generally a
little more or less than a half wavelength.
Remember the relationship between frequency (f) Figure 1. Common antenna types: (a) half wave dipole; (b) patch.
and wavelength (λ):
September/October 2018 85
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/2018/09.

Figure 2. The radiation patterns of a dipole (a) and a patch (b).

the lower frequencies, the antennas are just too large to


be practical. For example, at 30 MHz, a half wavelength is
about 16.4 feet long. A multiple array would be enormous.
However, at 5 GHz or 5,000 MHz, a half wavelength is
only:
Figure 3. A 16-patch array on a PCB. The back of the
λ/2 = 150/5000 = 0.03 meters or 1.18 inches
board is a solid copper backplane that serves as a
Bigger arrays at the higher frequencies are smaller and reflector. Feed lines are not shown.
more practical.
Many of the new 5G cellular systems will operate in collection of multiple antennas arranged in a matrix of rows
the millimeter wave bands; 28 GHz is an example. One and columns or some other pattern.
half wavelength at this frequency is only: Figure 3 shows an example using 16 square patch
antennas on a PCB. The antennas in the matrix are
λ/2 = 150/28000 = 0.00536 meters or 0.21 inches
individually fed units, but collectively they work together
A half wavelength at 60 GHz (a popular unlicensed as a single antenna. The backside of the PCB has a copper
frequency band) is only: backplane that acts as a reflector. Feed lines are not shown.
The whole idea of the phased array is to achieve some
λ/2 = 150/60000 = 0.0025 meters or roughly 0.1 inches
needed features. These key features are:
At these frequencies, large arrays can be packaged in a • Gain – Gain is like amplification. Some types of
small space. The antenna array may even be small enough antennas boost the signal level or effective radiated
to integrate on a semiconductor chip along with the power (ERP) as if greater signal power is used. Gain
related circuitry. This translates into phased arrays inside applies to both transmitting and receiving.
smartphones and other portable equipment. • Directivity – Directivity implies that the antenna
Figure 2a shows the radiation pattern of a basic dipole. is more effective in one direction or another.
Its figure 8 pattern causes most power to be radiated Directivity means that the signal is narrowly focused
broadside from the antenna element and also some in in one direction. This focusing of the signal is what
other directions, except in those directions at the ends of creates the antenna gain. Figure 2 showed the
the antenna elements. By using multiple antennas in an broad radiation pattern of a standard dipole and the
array, the radiation pattern can be shaped into a narrower radiation pattern (or lobe) of a phased array.
beam as shown in Figure 2b. This pattern or lobe is • Interference Minimization – Pointing the antenna
made up of multiple signals from multiple antennas in the in a particular direction means that it’s less effective
array. The signals are focused, making them stronger and in the other directions. This feature helps eliminate
allowing the beam to be pointed in a desired direction. or reduce interference for signals coming in from
other directions. Nulls can be created to take out
Phased Array Defined undesirable signals.
• Steerable – Phased arrays can be adjusted to
A phased array is two or more antennas used together reposition a lobe on-the-fly. The direction of the signal
to provide some desired characteristic or feature not can be changed electronically to optimize the gain.
available with a single antenna. An array is usually a This allows them to scan horizontally and/or vertically.
86 September/October 2018
signal level and phase to each
antenna element.
Phase shifters introduce a
short delay that can be varied.
These phase shifters and
attenuators can be adjusted
electronically so that changes can
be made quickly as needed.
Figure 4 shows how the
phase shifters influence the
composite signal. The red curve
represents the wave front from
each antenna. With no delay
on the top antenna and equal
incremental delays on the lower
elements, you can see that the
delayed waves occur further out
in time to the right. Then, they
combine to create a composite
Figure 4. An original approach to implementing an array with wave front that is shifted upward at an angle.
separate circuits. The phase increments are selected to create a This older method used separate
lobe of a desired width and point in a desired direction.. attenuators, phase shifters, and other
components. A newer approach is modular.
Phased Array Operation That is, the antenna element and related
transmit and receive amplifiers, shifters, attenuators, and
Phased arrays implement what we call beamforming. switches are packaged together as a module; refer to
This is done by taking the radiation patterns of each of Figure 5. In transmit mode, the signal from the transceiver
the antennas in the array and adding them together in passes through the attenuator, phase shifter, and T/R
such a way that they concentrate the energy into a narrow switch to the power amplifier and then to the antenna.
beam or lobe. The individual antenna signals are said to In receive mode, the signal from the antenna passes
be interfering with one another either constructively or through the T/R switch to the low noise amplifier and
destructively. Some signals combine to form a stronger through the phase shifter and attenuator to the receiver
composite signal, while others partially cancel one another section of the transceiver.
out.
The radio signal to be transmitted is a sine
wave. When you algebraically add two sine
waves of the same frequency but different
phases, you get another sine wave of the
same frequency but with a different amplitude
and phase. By manipulating the phase and
amplitude of the signal at each antenna, the
composite beam can be varied in both width
and length (power level). Plus, the beam can
be steered to point in a desired direction.
There are several ways to implement
the phased array. The older analog method
is shown in Figure 4. The RF signal from the
transmitter power amplifier (PA) is sent
to a power divider that splits the RF into
Figure 5. The modular approach to building phased array packages with
equal amounts of signal, creating multiple
all components on a single chip. The attenuators and phase shifters are
paths to the antennas. The signals pass
electronically changed by an external microcontroller that is programmed to
through attenuators and phase shifters implement a desired beam width and direction.
that allow individual adjustment of the
September/October 2018 87
THE LATEST IN NETWORKING AND WIRELESS TECHNOLOGIES

These modules can be packaged


together as an array as needed.
Today, semiconductor technology
lets you put one or more modules
on a single semiconductor chip.
A good example of a
commercial product available to
implement phased arrays is the
Anokiwave family of millimeter wave
phased array front-ends. The AWMF-
0139 operates in the 24 to 26 GHz
band allocated to the coming 5G
cellular networks It encapsulates
four modules per IC. Figure 6 shows
how 64 of these chips can be used
to make a 4 x 64 = 256 element
array. Another similar IC is Analog
Devices ADAR1000.

MIMO
Phased array antennas can also
be used for multiple input multiple
output (MIMO). MIMO is a technique Figure 6. The Anokiwave AWMF-0139 IC contains four antenna modules.
that transmits the same data with multiple These ICs are mounted on the back of the PCB with the patch array on the
antennas over the same path in the same front.
bandwidth. This does two things.
First, each signal takes a slightly different route to the For example, the 256-element array could be arranged
receiving antennas. The result is less fading and greater to provide four 64-element arrays or sixteen 16-element
data reliability. Second, MIMO multiplies the data rate by arrays. With beam steering capability, the signal path can
a factor that is determined by the number of transmit and be optimized for best performance.
receive antennas. Common configurations are 2 x 2, 4 x 2, Also, 5G cellular radios operating in the millimeter
4 x 4, and 8 x 8, where the first number is the number of wave bands will use MIMO to give gigabit data rates. The
transmit antennas and the second number is the number of big hurdle is putting a phased array into a smartphone
receive antennas. handset. Initially, two antennas will be used and later will
A multi-element phased array can be partitioned into be increased to four. MIMO is also widely used in Wi-Fi
sections making it suitable for some MIMO applications. routers. NV

88 September/October 2018
SAVE 20%
INSPIRATION ■ INNOVATION ■ IMPLEMENTATION ■ COMMUNIT Y
Use Code
September 25-27, 2018 Servo20
Santa Clara Convention Center, Santa Clara, CA

Take Your
INSPIRATION ■ INNOVATION ■ IMPLEMENTATION ■ COMMUNITY

Career to
the Next Level
2018 Features Expanded Plus!
Opportunities: ■ Pre-Conference Workshop
■ 25 sessions designed specifically on Big Data
for engineers ■ A 1-Day Deep Dive into AI
■ 9 sessions on building your ■ 6th Annual Pitchfire Start-up
robotics business Competition
■ 60+ sessions that meet the ■ VC Office Hours at the
needs of the entire industry Start-Up Incubator
■ Demos from leaders in the
robotics industry

2018 Keynote Speakers


Ken Goldberg Deepu Talla
William S. Floyd Jr. Distinguished Vice President & General Manager
Chair in Engineering, UC Berkeley of Autonomous Machines, NVIDIA

REGISTER TODAY! ■ RoboBusiness.com


NEAR SPACE ■ BY L. PAUL VERHAGE

Raspberry Pi Zero Flight


Computer — Part 3
I
was pretty amazed at what I did for the camera portion of my Raspberry Pi Zero
Flight Computer – I ended up incorporating 3D design and 3D printing into making a
BalloonSat. Let’s see now, that’s a combination of electronic PCB design, programmable
microcontrollers, and 3D design and printing to explore near space – pretty cool if I say so
myself.

On the left is a small Raspberry Pi Zero. I’ve connected it to the expansion


board that I designed in Part 1 to create a RaspPi BalloonSat flight computer.

A Camera for the Raspberry Pi get it?). Without its IR filter, this camera images visible and
reflected infrared light. Meaning it’s a terrific camera for
My final challenge in designing the Raspberry Pi flight detecting the chlorophyll of green plants. I then discovered
computer (after collecting and storing sensor data) was just how easy it is to take and store camera images on the
to add a camera and store its images. So, I did an online
search for Raspberry Pi cameras and found the camera and Figure 1
code. Best of all, I found that a second kind of camera for
the Raspberry Pi is available, one called a NoIR camera.
This is a camera without the infrared-blocking filter (no IR,

The NoIR (great name, by the way!) camera is your


typical 8 MP digital version, except that its hot
mirror has been removed. This means the NoIR camera
can record images in both the reflected visible and near
infrared light. Check out Public Lab’s Infragram website
for the benefits of using a camera that can do this. It’s at
infragram.org.

90 September/October 2018
APPROACHING THE FINAL FRONTIER
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2018/09.

Figure 2
Now all I had to do is create a
case for the bare NoIR camera —
preferably one that will let a servo
rotate the camera as well. So, I
applied my beginner-level 3D design
skills to the task of designing and
printing a camera case and rotator.
If successful, this would let a single
camera-servo combination replace
multiple cameras.

TinkerCad to the Rescue


Last school year, my
engineering class at the Treasure
Valley Math and Science Center
It took a few iterations to create the two halves of the camera case. Now, the
camera fits inside its case very well. (Boise school district) partook
in a competition called FabSlam
(check out the Digital Harbor
Figure 3
Foundation to learn more about
joining this competition). The 3D
design software recommended for
FabSlam is TinkerCad. TinkerCad
is a web-based app where you can
shrink-expand and add-subtract simple
shapes to create larger, more complex
finished products. I found TinkerCad
easier to learn and use than Blender
(of course, it doesn’t have all the
features of Blender). So far, I’ve used
TinkerCad to create a lot of items to
support my amateur science habit —
the rotating camera case of the
NoIR being one of them.
When fully assembled, the
These two side-by-side brackets bolt together, trapping the camera case
between the servo and a nut and bolt axle opposite the servo.
rotating camera case looks like
Figure 4 (contact me if you’d like
a copy of the STL file I created).
Pi’s SD card. A servo attached to the case can rotate the camera
It takes just one line of code to instruct the camera to to point it in any position within a 180 degree arc (down,
take an image and four lines of code to create a unique straight out, and up). I found sample servo code online and
name for each image file to store on the SD card. To do then modified it to my particular needs. My code is shown
the following, I used the code below: here:

ImageFile = ‘image’ # create the name pwm=GPIO.PWM(13,50) # create a 50 Hz PWM


of the image file signal on pin 13
y = str(counter) # increment the pwm.start(2) # position servo with
image file’s number a 2% duty cycle
ImageFile = ImageFile+y # concat the name time.sleep(.75) # give servo 0.75
and number of the image file seconds to reach
ImageFile = ImageFile+’.jpg’ # add the jpg file pwm.stop() # turn off PWM signal
type to the name time.sleep(1.5) # wait 1.5 seconds
camera.capture(ImageFile) # get a picture before moving servo
September/October 2018 91
APPROACHING THE FINAL FRONTIER

The one surprise I discovered while testing my code


is that the servo is jittery. This jitter makes me suspect that
the Raspberry Pi isn’t constantly applying a 50 Hz signal to
the servo. It may be that the Pi has to take turns performing
other tasks in addition to the 50 Hz signal generation. If
true, then when the Pi switches between tasks, the servo
signal drops out briefly creating the jitter I observe. If I can’t
find a way to remove the jitter, then I’ll instruct the Pi to
turn off the servo signal while the camera records an image.

My Results
After some hair pulling, I finally have the Raspberry
Pi-based near space flight computer recording both sensor
data and pictures on its SD card. Figure 5 is a screenshot
showing the contents on the Pi’s SD card after a practice
mission.
It’s been a real challenge getting to this point. As I
said last time, the Raspberry Pi and PICAXE work a lot
Figure 4 differently from each other. This has frustrated me at times
because of things like library importing and configuration

Wouldn’t you know it. I ran out of filament


after printing most of my camera
rotator. So, you really don’t have to print it in two colors
issues that the PICAXE doesn’t require. However, I guess
this goes with the territory with learning how to use a
general (and more capable) microcomputer.
like I did (in fact, I’d recommend printing it in black so Onwards and Upwards,
sunlight will keep the camera electronics warmer).
Your Near Space Guide NV

Figure 5

A folder and the contents of a file are shown on this monitor. On the left is the open file with the GPS, weather station,
and Geiger counter data. On the right is the folder of the image files recorded by the camera. All I need to do now is
insert a thumb drive into the Pi and copy all the files on to its SD card. I now know how to get the flight data from the Pi to
my PC for further analysis.

92 September/October 2018
Drone License
I’ve mentioned a few times in my column that I have a drone I like to fly (Blade Chroma). I’ve been learning how
to use it as a platform to do amateur science along with photographing my house and my vacations. Many readers
know that in August 2016, the FAA made a pilot’s license for drones (the Part 107 Remote Pilot) available to the
public. Now, every drone pilot making money with his or her drone must first pass this test and receive their license.
Well, in early July, I passed my test (90% of 60 questions) and got my license! I learned the material for free (but
had to pay for the test) and I suspect that many Nuts & Volts readers would like to do the same. So, let me share the
online — and best of all — free materials that I used to learn everything and prepare for the test. Please know that I am
not affiliated with these people nor am I receiving compensation from them. I’m just a happy client.
First of all, a big thanks to Tony Northrup for his excellent free FAA Part 107 sUAS and drone certification study
guide. It’s a great two hour video lecture. However, he did make a mistake at the end. Humid air is less dense than dry
air. Therefore, on humid days your drone props will not be as effective.
Second, hats off to the 3DR (3D Robotics) company. They have over 100 free practice questions online that you
can use to test your knowledge. Some of the questions looked a lot like the questions I got on my test.
Next is Rupprecht Law P.A., which is a law firm with a drone law specialty. Jonathon’s emails asked some very
tough questions that really test just how much you understand about Part 107 and reading sectional charts. Sectional
charts can be a complex mess in some places and you’ll want to get proficent at reading them. If you need help with a
future drone business, this law firm is there to help you.
Finally, being no slouch in making the skies safe for air travel, the FAA has put out a Part 107 study guide. Be sure
you read it as you are prepare for your test.

Tony Northrup
https://northrup.photo/free-faa-part-107-suas-drone-certification-study-guide
3DR (3D Robotics) Company
https://3dr.com/faa/drone-practice-tests
Rupprecht Law P.A
https://jrupprechtlaw.com/part-107-knowledge-test.
FAA Part 107 Study Guide
https://www.faa.gov/regulations_policies/handbooks_manuals/aviation/media/remote_pilot_study_guide.pdf.

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


September/October 2018 93
TECHFORUM READER - TO - READER

by Oregon Scientific for use as


>>> QUESTIONS weather station sensors. I would like Don’t expect a ferrite or neodymium
to use them for a data acquisition and magnet to gain back much strength.
Scoping Out Some Advise monitoring application. Does anyone First, determine the alignment
Certain techs and engineers still know what frequency and mode of the original magnet. Rubberized
have a need to sample and view they operate on and how I might use magnetic backing, for example, often
composite/NTSC video in its three them to send data to a PC to record has stripes of opposite polarity on
axes form, that is: X axis (horizontal), seasonal trends? Would I need a one side; these would be impossible
Y axis (vertical), and Z axis (intensity). microcontroller to interpret the output to repair. A horseshoe magnet — often
In the past, this was or could it be read directly by the PC found on hand-cranked generators —
accomplished using a CRT o’scope: and then logged and displayed using or a bar magnet is easier to fix.
horiz sweep to H input; vert sweep to software such as MakerPlot? Simplest is to put the old
V input; and video to Z, or intensity #9184 Jai Hooley magnet in contact with a strong
modulation input. Since CRT scopes Edmonton, AB permanent magnet, e.g., a large
are bulky, heavy, and, in most cases, rare-earth magnet, letting it align by
not battery powered, a PC/digital >>> ANSWERS greatest attraction (North touching
scope with capture capability would [#5184 - May/June 2018] South). Tap the old magnet a
be very handy for field use. New Life For Magnets few times with a hammer to help
None of the scope ads I’ve seen Has anyone tried to revive rearrange domains. More effective
list these features. Can anyone make permanent magnets that have is to wind wire around the magnet
some recommendations? weakened over time? What is the best and pass a large pulse of DC
#9181 Paul Dendrenos method? Can they be made “good current through the coil. Capacitive
Barstow, CA as new” or is it better to just replace discharge magnetizers are simple
them? to build, but involve high currents
Resonator Frequency and voltages and present some
I have in my junkbox what I #1 I would try making and using an safety hazards. See https://www.
believe to be ceramic resonators. electromagnet to re-magnetize your rcgroups.com/forums/showthread.
What is the best way to test them to magnets. Works well for bar magnets; php?307133-Inexpensive-
determine their frequency? for other shapes, it might be a bit magnetic-flux-(gauss)-meter/
#9182 Donald Frazier more involved. page3&highlight=capacitor%20
Geneva, IL Since many “standard” type discharge%20magnetizer for more
magnets are made from magnetic details.
Something Strange With The metal placed into a magnetic field to Dr Moishe P
Range begin with, I would say if this can be via Internet
The effective range of the key done for your magnets, you stand a
FOB for my Ford F150 seems to have good chance of making them every #3 Unless there’s something
decreased over recent months. While bit as good as they were originally. special about the old magnet, it’s
it used to work from distances of Phil Karras usually easier and cheaper to replace
75-100 yards easy, now I need to be via email them. A case I’m familiar with where
nearly right in front (10-20 yards) of it’s worth “recharging” old magnets is
my vehicle to operate the systems. #2 There are a few ways to partially in old motorcycle magnetos.
I changed to a fresh battery, but revive some types of magnets. In this case, we put a coil with
no difference. Is it likely there is an However, the more powerful the a core inside the magnets and then
antenna problem? If so, where is it magnet was originally, the more pass a high current for a short period
located and is there a test procedure? “brittle” is the arrangement of of time. The field from the coil has to
#9183 Les Waldroup domains, and the harder it is to be much stronger than the original
Charlotte, NC realign them. magnet but doesn’t need to be
For that reason, remagnetization maintained for very long. Discharging
Wireless Data To PC is most useful for antiques, a capacitor into the coil is a good way
I have a number of wireless ornaments, or teaching devices made to achieve this.
temperature/humidity sensors made of materials such as carbon steel. Too little field and nothing
94 September/October 2018
>>>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

happens; too high a field does deg C at reasonable currents like a transistors. Why? Because the reverse
no harm. Make sure the field you few milliamps. This works pretty well temp curve cancelled the xistor
generate is in the same direction as for silicon diodes like the 1N400x temp curve. So, we built several little
the magnet or you’ll wipe out any and the 1N914. It also works well for circuits to monitor the temp. So, a
remaining magnetism and possibly the base-emitter junction of a silicon series circuit that lets a low current
reverse its polarity. planar transistor (almost anything in through your diode, monitored with
Robin Hartley a TO-92) — especially if you short out a sensitive meter, will give a value for
New Zealand the base-collector junction. I haven't different temps.
tried it, but I think it doesn't work as Caution! Some diodes are
#4 I'm not sure that time is the well for point-contact germanium sensitive to light, so take that into
cause of loss of magnetism of diodes like a 1N34 (which might account. The 1N914 and 4148 were a
permanent magnets. They normally include your “crystal” diodes). common device. Never messed with
lose their magnetism by three Joseph Feng the gallium devices. Just be cautious.
methods. San Jose, CA They are easy to let the smoke out.
1. Heat. Good luck in your endeavors.
2. Physical shock. #2 I’m not certain what you mean Tom Sides
3. Exposure to opposing magnetic by “crystal diodes” but most modern Phoenix, AZ
field. semiconductor diodes can be used
I have two large toroidal magnets as temperature sensors. A standard [#7181 - Jul/Aug 2018]
which sit on a tube with opposite silicon diode will have a forward Smooth LEDs?
poles facing each other. The top voltage drop, usually stated as “0.6V” What makes some LED
magnet ‘floats’ about 2 cm above or “0.7V.” However, it varies with replacement bulbs dimmable,
the bottom one. They have been like temperature. Typically it will drop while others are not? Some of the
this on my workbench for at least about two millivolts per degree C. By replacements I have purchased do not
10 years and there is no discernible measuring that drop and calibrating dim very smoothly. They seem to dim
difference in the distance between at two extreme temperatures, the in steps and then just turn off before
them, so I don’t believe they have lost current temp can be determined. lowering to where I need them to be.
any of their magnetism. The diode should have its The previous incandescents dimmed
The magnets weigh about 100g cathode connected to ground and the much more smoothly down to a
so the force required to hold the anode should have a resistor to the soft glow. Is there a different (maybe
floating magnet against gravity is positive supply. The voltage measured more expensive) type/technology
about one newton. I have no idea between the junction of the resistor / that would more closely emulate
where the energy to do this for 10 anode and ground will be the forward the incandescents? I’m using an X10
years has come from and I have not voltage to measure. controller for the dimming. Could this
found a physicist who can provide a If by crystal diode you mean be the problem?
satisfactory answer. I will keep asking! the old “cat’s whisker” crystals (e.g.,
Mike galena), I suspect they will have much #1 Different bulbs behave
via Internet lower voltage drop. However, it will differently, so you have to try some
probably still show a temperature options. There are some test results
[#5185 - May/June 2018] sensitivity, so may work. Silicon on the X10 Forum that you might find
Measuring Heat With Crystal diodes work pretty well. useful. X10 dimmers dim in 16 levels,
Diodes For an indepth explanation so some bulbs may not dim smoothly.
I have a bunch of crystal diodes with lots of math and theory, look Bruce Robin
in my junkbox that I want to use to here: https://www.eetimes.com/ Naples
measure heat. I seem to remember a document.asp?doc_id=1279718.
circuit for it some years back. Anyone William Cooke #2 I can’t answer specifically what
have a simple circuit or explanation of Clarksville,TN is different about dimmable LED
how it should work? lamps, but will note that the type of
#3 Texas instruments always dimmer is important. You need to use
#1 Theoretically, the forward- encouraged its engineers to use a dimmer specifically designed for
biased voltage drop is about -2.2 mv/ a diode in the emitter of their LED lamps.
September/October 2018 95
>>>YOUR ELECTRONICS QUESTIONS ANSWERED HERE BY N&V READERS

I have had good luck with Lutron Bill van Dijk bars, etc., due to the timing between
CL dimmers that are made specifically Carp, Ontario your camera’s shutter and the TV’s
for LED lamps. These are not X10; screen image refresh.
I have not seen any X10 dimmers [#7182 - Jul/Aug 2018] 2. Install a stand-alone DVD
for LED lamps. Also note that X10 TV Image Capture recorder between your cable box and
light controls generally only work What’s the best way to capture TV, or connect the recorder to your
for incandescent lamps; they need images from my TV? I’m looking to TV’s video out jack using a suitable
a bit of current flowing through the do something like a computer “print interface cable. What you’ll do is
filament to work correctly. screen.” record the program to the DVD (use
For LED lamps, I have used the DVD-R discs) and use the machine to
relay based X10 switch WS13A with #1 This would be most easily finalize the recorded DVD (make it
good success. It also works with CFLs. accomplished using an HDMI splitter playable on other DVD drives) when
Dan Koellen AI6XG and an HDMI-capture device used the recording is complete.
Roseville with your computer. Then, play that DVD on your
HDMI-capture devices can computer’s DVD drive; use the
#3 An LED is a beautiful dimmable be external (to the computer) for computer’s playback program (i.e.,
device; lower the current, and the PC or Apple machines, or can be Media Player for Windows) to
output brightness goes down. This implemented as a pluggable card get to the screen to capture; then
can be done through simple resistors, for use with a PC desktop machine PAUSE the playback. Use the image
or through PWM (Pulse-Width (assuming that the machine has capture feature of the player to take
Modulation). That is the good news. an unassigned motherboard PCIe a snapshot of the video image, then
In order to use an LED as a house connector available). save it to your disc. Be aware: The
incandescent lamp replacement, Connect the splitter to the resolution of the DVD-recorded
something needs to be done to make television program source — e.g., a material will be no better than the
that possible. First of all, the voltage cable box. Using an HDMI cable, video signal (Composite, S-video,
is WAY too high; it is AC (the LED connect one of the splitter outputs HDMI) fed to the recorder.
prefers DC), and we need to feed to the television set. Using a second After you’ve screen captured your
it the correct current. So, a power HDMI cable, connect the remaining images to your computer, use your
supply module is included to convert splitter output to the HDMI-capture Image Editing utility to clean up, etc.,
the 120 (or 220) volt AC to some device. the images for your use.
small DC current appropriate for the Record the program material Now then, there’s a more
LED used. using the software provided with the expensive way to do it. It involves
Herein lies the problem. This PS HDMI-capture device. See Newegg et installing a video capture card into
module is designed to deliver x mA to al., for available devices. your PC. Like the DVD recorder
the LED more or less regardless of the Peter A. Goodwin option, you’ll have to patch the video
input. When you adjust the input, the Rockport, MA signal from the cable box or TV’s
PS module tries to compensate to the Video Out into your video capture
point where it no longer can — often #2 There are two inexpensive ways card.
resulting in a flickering light. These are to do a print screen from a TV screen: This way, you can watch TV
the now non-dimmable LED bulbs. 1. Put a digital camera on a using your PC and — using the Video
To make this “house” LED bulb tripod and set it up in front of the Capture Application Software —
dimmable, a radically different PS screen — ensure the TV screen fills capture a snapshot in (more or less)
module must be built. It must sense the viewfinder and ensure the flash real time. Also, you can record the
that the input has changed (due to is off. When you want to capture program — while you’re watching it —
the dimmer setting), and adjust the something, just take a picture of the to your PC and edit/manipulate the
LED current accordingly. Not easy to screen. recorded material at your leisure.
do and, of course, more expensive. After that, connect the camera to The big advantage is your
Several designs have been your PC via USB cable and download captured images will (typically) be the
marketed; some better than others. In the screen capture. Be aware: The screen resolution of your computer’s
most cases, even with a “dimmable” resolution of the photographed display (or at least much better than
LED bulb, a special dimmer is image will be limited by the screen the inexpensive options above).
required. It is a mess, and most still resolution of the TV screen AND Ken Simmons
don’t work perfectly. don’t be surprised if you get screen Auburn, WA
96 September/October 2018
ADvertiser INDEX
Accutrace .................................. 99
Alan’ Electronic Projects ........... 45
All Electronics Corp. ........... 75, 84
■ LOOK FOR ■ SEARCH FOR ■ FIND Find your favorite advertisers here! Autonomous DoD Summit ........ 84
ACTUATORS DESIGN SOFTWARE MISC./SURPLUS DLP Design .............................. 45
Hitec RCD USA, Inc. Labcenter Electronics All Electronics Corp. Electronix Express .................... 93
BATTERIES/ DEVELOPMENT MOTORS / MOTOR ExpressPCB ............................. 10
CHARGERS PLATFORMS/TOOLS CONTROL Front Panel Express ................. 44
Hitec RCD USA, Inc. Technologic Systems Hitec RCD USA, Inc.
ROBOTICS Hammond Manufacturing ......... 17
BUYING ELECTRONIC EDUCATION Electronix Express Hitec RCD USA, Inc. .................. 2
SURPLUS ME Labs Hitec RCD USA, Inc.
All Electronics Corp. PoLabs Keyways ................................... 45
Pololu
Labcenter Electronics ................. 3
CIRCUIT BOARDS EMBEDDED SYSTEMS SDP/SI
Accutrace Saelig Co. Inc. ServoCity Lemos Technologies ................. 45
ExpressPCB Technologic Systems MakerFaire ............................... 21
TEST EQUIPMENT
PCB Fab Express
Saelig Co., Inc. ENCLOSURES Electronix Express Measurement Computing ........ BC
Front Panel Express PoLabs ME Labs ................................... 52
COMPONENTS Hammond Manufacturing Saelig Co., Inc.
PanaVise .................................. 44
All Electronics Corp.
EVENTS TOOLS PCB Fab Express ..................... 68
Electronix Express
Autonomous DoD Summit PanaVise
Octopart Pico Technology ....................... 61
Maker Faire PoLabs
Saelig Co., Inc. PoLabs ..................................... 52
RoboBusiness TRANSFORMERS
DATA LOGGING Hammond Manufacturing Pololu ........................................ 11
Measurement Computing LCDs/DISPLAYS RoboBusiness .......................... 89
Pico Technology Saelig Co., Inc. WIRE, CABLE AND
CONNECTORS Saelig Co., Inc. ......................... 59
DESIGN/ MICROCONTROLLERS All Electronics Corp. SDP/SI ...................................... 45
ENGINEERING/ REPAIR / I/O BOARDS
SERVICES ME Labs WIRELESS PRODUCTS ServoCity ............................ 45, 98
Accutrace Technologic Systems Lemos Technologies Technologic Systems ................ 67
ExpressPCB Technologic Systems
September/October 2018 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.

Perfect for:
• Embedded system design
• Industrial IoT
• End-of-line test
• Remote monitoring
• Edge Computing
• Validation/verification test

MCC DAQ HATs are provided with: MCC 118


• Complete SW library for easy programming • 8 channels/board,
• Full set of examples in C® and Python™ up to 64 channels/system
• Free technical support • 100 kS/s board,
• Quality from a trusted source up to 320 kS/s system

Buy with Confidence – Take Measurements in Minutes

1 YEAR

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

You might also like