You are on page 1of 100

Custom Actuator Solutions

After nearly four decades of global


success, Hitec continues to deliver
unrivaled reliability, power, speed, and
durability as a world leader in actuator
design. Hitec customers rely on our
engineering and manufacturing teams
to deliver affordable, precision solutions
for a wide range of applications.
Our off-the-shelf and purpose-built
custom products regularly incorporate
innovative features such as magnetic
encoders, brushless motors and
titanium gears, delivering optimal
performance for all your industrial
and commercial applications.

Hitec Commercial Solutions is


proud to offer extensive actuator
lines, custom services, and a
• Sizes Range from 10 - 33mm variety of unmanned platforms, all
• Contactless Position Sensors engineered to effortlessly conquer
• Wide Voltage Operation your most demanding challenges.
• High-Resolution Programmability
• UAVCAN, CAN & RS-485 Interfaces Available
• Customized Options Available

9001: 2015
14001: 2015
www.hitecnology.com

Actuator Engineering Reimagined


Hitec Commercial Solutions, LLC
9320 Hazard Way, Suite D, San Diego, CA 92123 | (858) 737-9220
Metal Gearmotors
from Pololu

Pololu offers an extensive line of gearmotors (motor+gearbox) in common form factors


but with proprietary features including special windings, brushes, shafts, and gears. For
example, we stock over 100 versions of our 10×12mm micro metal gearmotors. Final
assembly and inspection of gearmotors are done in both our Shenzhen and Las Vegas,
Nevada facilities to maintain stock and minimize lead times. We are constantly
developing new gearmotors, and for sufficient volumes, modifications such as
customized output shafts are available.

Find out more at www.pololu.com


Issue-5 2019 Page 38 38 Build a Radio Pet
08 Nextion Touch Tracker
Screen Display (Part Knowing your pet’s location
is invaluable. With modern
2) technology, there are commercial
solutions giving accurate
In the first article, we downloaded
GPS location for days on end.
the Nextion IDE, built a couple
However, these options are
screens with various objects,
costly. So, as a useful and
and tested it in simulation. For
educational project, I built my
this installment, we’ll actually
own tracker using a simple radio
be loading software onto a
beacon.
real Nextion TFT display and ■ by Ryan Gedminas
interacting with a PIC16F1824
microcontroller programmed
with ME Labs PBP3 BASIC
42 Build an Audio
software. Finally, it will be tested
on a breadboard.
Loop System
The last time I had my hearing aids serviced, I discovered
■ by Mike Holler
that the devices included a T-mode operational feature. The

15 Open Communication T-mode (or Telecoil) setting allows you to receive audio
signals fed to an induction loop, which is just a wire loop
The Latest in Networking and Wireless laid on the floor around the perimeter of the desired area.
Technologies Induction loops can be found in places such as concert
halls, movie theaters, auditoriums, churches, banks, and
Dirt Cheap Wireless Control
public buildings where PA announcements are common. I
I’m a sucker for cheap electronic parts, especially wireless
decided to build an installation for my home. Here’s how it
stuff. Just recently, a catalog from one of my favorite parts
went.
distributors (All Electronics) came in the mail and was
■ by Chris Watson
promoting some wireless modules: a transmitter (TX)
and a receiver (RX) for just a few bucks each. I ordered
immediately. Now that I had these wireless modules, I 48 A Semiconductor-Based High
wasn’t sure what to do with them. I had no plan or goal in
mind. So, I decided I would just experiment for fun. This
Voltage Supply
For those who experiment and build with vacuum tubes,
article sums up what I did and what I learned. an adjustable regulated benchtop high voltage power
■ by Louis Frenzel
supply is essential. Many circuits for such units have

20 REVIEW: Dr Duino’s Starter Kit been described that themselves use tubes. It’s nice to be
consistent, but we can save some bench space and a few
In addition to making breadboarding easier, the new Dr. watts by using semiconductors in such a unit.
Duino Starter Kit can be a useful tool in learning Arduino ■ by Bryant Julstrom KC0ZNG
hardware and software design. Getting into microcontroller
development for the first time can be a daunting 52 A Discussion on dBs and RF
Power Meters
undertaking and anything that can simplify the process will
be welcomed by many. Plus, there are several
other possibilities for how this kit can be used. This article discusses basic
■ by Craig Lindley theory on the decibel unit

28 Build the NixieStar Clock


and its role in electrical
measurements of power,
The NixieStar clock is the second timepiece etc. It also describes the
kit I’ve developed. My aim was to have construction of an RF power
a kit that’s reasonably easy to build with meter which in the past has
intermediate soldering skills (i.e., minimal SMD been difficult to use and
components). I also wanted a clock kit that once expensive to own. With the
it was built, any spouse (including my wife!) breakthrough of new ICs in
would accept it on their wall — even with a recent years, most of the
power cord hanging from it. former problems and expense
■ by Joe Croft Page 52 have been eliminated. This is
a simple and inexpensive unit
4 2019/Issue-5
06 DEVELOPING
Departments 24 NEW PRODUCTS
Subscription Information
Nuts & Volts — PO Box 15277
North Hollywood, CA 91615-9218
Call (877) 525-2539 or go to www.nutsvolts.com
PERSPECTIVES 26 NV WEBSTORE Subscribe • Gift • Renewal • Change of Info
Death, Taxes, and 77 BENCH & BUILDER
Exposure to EMR 94 TECH FORUM For more details on subscribing, see our ad on Page 96.
07 READER FEEDBACK 96 AD INDEX

unit to build, but has the accuracy, resolution, and dynamic range that
was only obtainable in lab quality test equipment a decade or so ago.
This kind of test equipment is almost mandatory for amateurs, radio
frequency work, or test equipment calibration. Also, when built as
described, it’s a very professional looking piece of gear that anyone
would be proud to display on their test bench.
■ by Robert Reed

66 LEDs for Operational Status and


Troubleshooting
Even when a circuit functions as it’s supposed to, it’s not always easy
to tell what it’s doing. Plus, waiting for an output (especially if there’s
a long delay involved) is not always practical. Conversely, if a circuit
does not function, the only means to find out what’s wrong is to
troubleshoot it with either a multimeter or oscilloscope. Wouldn’t it be
great if the circuit itself could tell us more directly what’s wrong?
■ by Klaus Spies

72 Microcontrollers, Software, and You


Most of us have invested some time in learning those things we want
or need to do. Learning how to program is no different, and it can be
an extremely satisfying endeavor. Seeing a device respond to code
you wrote is, well, intoxicating in a good way. My goal is to create
an interest in exploring microcontrollers and encourage you into
investing $5 and some of your time into that exploration. I honestly
think you’ll enjoy the journey.
■ by Dr. Jack Purdum Page 86

78 For IoT Projects, Call JSON


Internet-of-Things (IoT) projects that use sensors, actuators, displays,
or controllers can easily communicate through an MQTT (Message
Queuing Telemetry Transport) server, or broker. The MQTT standard
lets devices publish and subscribe to specific topics. When they
use the JavaScript Object Notation (JSON) format to exchange
information, software can easily interpret or parse it. In this tutorial,
I’ll explain how to create and parse JSON messages.
■ by Jonathan Titus

86 Newton’s Apple
When I was in junior college, I did an experiment in a physics class
that I have never forgotten. It was the classic falling body experiment
to measure the acceleration of gravity; 9.81 meters/sec2. I loved
carefully adjusting the apparatus and meticulously taking the data,
trying to get a result that was as close as possible to the established
value. Frankly, I don’t recall how close I got but it was the thrill of
scientific inquiry that grabbed me. Now, in this age of computer
technology, I thought it might be challenging and fun to see how good
I could do in my garage with a fairly simple DIY apparatus.
■ by David Goodsell

Nuts & Volts (ISSN 1528-9885/CDN Pub Agree #40702530) Issue-5 (Sep-Oct) is published 6X a year 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.
2019/Issue-5 5
DEVELOPING
PERSPECTIVES
Published 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

by Bryan Bergeron, Editor SUBSCRIPTION


Toll Free: (877) 525-2539

Death, Taxes, and Exposure to


Outside US: (818) 487-4545
P.O. Box 15277

Electromagnetic Radiation
North Hollywood, CA 91615
subscribe@nutsvolts.com

A
FOUNDER
s a teenager, I built a 2 KW In discussing the effects of Jack Lemieux
two-meter transmitter to work radiation, it’s important to note that
the OSCAR satellite repeater. radiation can be ionizing or non- PUBLISHER
The transmitter was based on ionizing. Highly energetic ionizing Larry Lemieux
publisher@nutsvolts.com
a spherical 4” diameter vacuum tube radiation such as Gamma rays from
that looked like a radiation target a nuclear detonation causes damage ASSOCIATE PUBLISHER/
used in clinical X-ray machines. to the DNA in our cells, resulting in ADVERTISING SALES
One day — by accident — I cancer and cell death. Less energetic Robin Lemieux
discovered that I could hold a three non-ionizing radiation — such as the robin@nutsvolts.com
foot fluorescent tube in one hand and electromagnetic radiation from a
EXECUTIVE DIRECTOR/
the tube would illuminate during key- cell phone or high frequency ham
PRODUCTION
down of the transmitter. Similarly, like transmitter — does not damage the Sean Lemieux
most of my friends who were hams or DNA, but does cause localized sean@nutsvolts.com
worked in communications, I seemed heating of tissue.
to always have white RF burns on my While there is no question of EDITOR
fingers. Back then, I never thought the detrimental effects of ionizing Bryan Bergeron
techedit-nutsvolts@yahoo.com
much of it. radiation, the National Cancer
Clearly immersing my body in an Institute concludes that non-ionizing CONTRIBUTING EDITORS
electromagnetic field strong enough radiation does not cause cancer Lou Frenzel Mike Holler
to light a fluorescent tube was unsafe (see Cancer.gov). There is, however, Klaus Spies Craig Lindley
Robert Reed Jack Purdum
and — in retrospect — it was a good continued debate over whether the
David Goodsell Jon Titus
thing that the satellite was only localized heating caused by non- Bryant Julstrom Ryan Gedminas
available to me a few minutes a day. ionizing radiation causes other health Chris Watson Joe Croft
The RF burns were simply a reflection problems.
of my lack of appreciation for the Unfortunately, unlike ionizing SHOW COORDINATOR
Audrey Lemieux
immediate effects of RF on skin. Since radiation exposure, there are no
then, I’ve come to appreciate the inexpensive EMR exposure badges. WEBSTORE MARKETING/
potential hazards of electromagnetic And good luck looking to the COVER GRAPHICS
radiation (EMR) exposure. manufacturer for practical guidance. Brian Kirkpatrick
Part of this appreciation comes For example, the instructions to brian@nutsvolts.com
from FCC guidelines; specifically, my 40m loop antenna simply state,
Copyright © 2019
parts 1 and 2 of 47 CFR, 1.1307(b), “It is the responsibility of the owner/ by T & L Publications, Inc.
1.1310, 22.1091, and 2.1093. These operator of this device to follow all All Rights Reserved
guidelines include labeling antennas applicable warnings and precautions All advertising is subject to publisher’s approval.
We are not responsible for mistakes, misprints,
with radiated power levels and regarding human exposure to RF or typographical errors. Nuts & Volts Magazine
assumes no responsibility for the availability or
specifying a minimum safe distance fields.” This warning accompanies condition of advertised items or for the honesty of
from radiation sources. There is an antenna designed to be operated the advertiser. The publisher makes no claims for the
legality of any item advertised in Nuts & Volts. This is
also information available from the within arm’s reach of the operator. the sole responsibility of the advertiser. Advertisers
American Radio Relay League. The Given the FDA’s guidelines on and their agencies agree to indemnify and protect
the publisher from any and all claims, action, or
FCC and ARRL aside, common limiting exposure to cell phone EMR expense arising from advertising placed in Nuts &
Volts. Please send all editorial correspondence, UPS,
sense suggests a degree of caution is by using hands-free tech such as overnight mail, and artwork to: 2279 Eagle Glen Pkwy
necessary. wired headsets and limiting call time, #112-481, Corona, CA 92883.

6 2019/Issue-5
my take is that I should minimize use of my loop antenna. electricity, battery power, or Internet, exposure to EMR
That’s not a practical suggestion. can’t be avoided. Even so, look at the guidelines and use a
Another practical issue is that, even if you don’t work little common sense.
with ham radio or other EMR sources, you’re likely being Forget working with local loop antennas. Use remote
flooded with EMR from cell towers, power lines, and antennas instead. Try QRP (low power) communications
ordinary electric appliances. In my case, there’s a cell tower instead of your 2 KW linear amplifier. And keep your
within a few hundred feet of my office. There’s not much I phone and handheld transmitter antennas away from your
can do to avoid the microwave radiation. head. NV
Short of living underground in the wilderness without

READER FEEDBACK
Article Clarification
Some readers mentioned that the
design procedure in my article, “An
Elegant Approach to Design a Variable
Voltage Divider” does not consider
the load resistance effect on circuit
operation.
The problem can be resolved by
some extra calculations. Figure 1 shows
an example with a 50K Ω load. As
before, the load voltage has to change
from +8 down to -5V.
The first step is to calculate RX and
RY with no load. The second step is to
convert the circuit to the left of the load
into a Thevenin network. Figure 1-b
shows the circuits when the wiper is at
the upper end and at the lower end of
RP. It’s easy to find that VMAX should be
Figure 1. After you define RX and RY for the unloaded circuit (a), connect the load and get the
+8.660V and VMIN should be -5.513V. Thevenin networks for the two end positions of the wiper (b), and recalculate RX and RY (c).
The last step is to recalculate RX
and RY for the new values of VMAX and what is required. The 1% deviation is
VMIN. Figure 1-c displays the result. completely acceptable.
Simulation shows the range of Jordan Dimitrov Figure 2. (below) Load voltages for the two end
load voltages is slightly wider than points of the wiper.

Solutions Really Add Up I was floored by the simple solutions Please pass on my thanks to Mr.
The N&V 2019 Issue-2 has an to circuit modeling that this article Hamilton for his great article.
article called “Circuit Simulation described. Frank Chiechi
Made Easy” that is excellent. I was so impressed I had to send
As a person who almost 50 years this message to thank the author, C.A.
ago studied EE and who has forgotten Hamilton, for giving me the tool I
much of the associated mathematics, needed for many of my projects.
2019/Issue-5 7
Nextion Touch Screen Display
Give your next project a modern look and feel with a
touch screen display!
(Part 2)

In the first article, we downloaded the By Mike Holler

Nextion IDE (integrated development


environment), built a couple screens types who favor paper). I have made numerous notes to
my printed copy. Due to the length, the PBP code will not
with various objects, and tested it be printed in this article but is available in the downloads.
in simulation. For this installment, As a side note, the PBP3 BASIC firmware’s fundamental
function is to convert BASIC to ASM. The ASM created by
we’ll be loading software onto a real PBP is not easily extracted and edited. Also, there’s no easy
way to “port” code from PBP to C. It would have to be
Nextion TFT display and interacting rewritten in C. There is a massive amount of information on
with a PIC16F1824 microcontroller the Internet supporting the Arduino platform for Nextion.

programmed with ME Labs PBP3 BASIC The Premise


software. Finally, it will be tested on a The objective is to create an HMI (Human Machine
breadboard. Interface) using a Nextion TFT display that communicates
with a PIC16F1824 processor to actually do stuff. To keep
it short and simple, we want:
Prerequisites • A real LED that indicates the state of a binary/boolean
It is assumed you have already read the Touch Screen button on the Nextion.
Display Part 1 article in Issue-4 of Nuts & Volts and • An LED that will vary brightness based on an analog
have downloaded the Nextion IDE Editor software (see value from the Nextion using the PWM function in the
Resources). For the PIC side, if you don’t already have PIC.
the PBP3 software, go to http://pbp3.com/download. • A physical button connected to the PIC that will turn
html and grab your copy. (Note, only the PBP3 Gold is something on and off on the Nextion display.
able to program the PIC16F1824. It’s available as a free • An analog reading on the Nextion display to reflect the
30 day trial if you wish to test it.) A PIC programmer will value of a pot on the breadboard.
surely be needed. I strongly suggest you go to www.
Microchip.com and download the PIC16F1824 datasheet This gives us one digital and one analog variable (X2)
for easy reference. Also, we’ll be using real hardware in this going both ways. With these basic tools, you can build
installment which requires a Nextion display, a breadboard, quite an impressive project; you can communicate and
a PIC16F1824 processor, as well as a few ancillaries display digital and analog values both ways, changing them
(resistors, LEDs, a pot, etc.). from either side as needed.
This time, we’ll be frequently referencing the Nextion
Instruction Set. Although it’s available in the IDE (so long
as you’re connected to the Internet), I chose to print it out
The PIC16F1824
for easier reference (I’m one of those 50+ years old school I wanted a mid-grade PIC processor that wasn’t uber
8 2019/Issue-5
Post comments on this article and find any associated files and/or
downloads at www.nutsvolts.com/magazine/issue/2019/05.

new, nor a dinosaur. The PIC16F1824 fits the bill. It has communication protocol requires the RX from one device
ADC, UART, and several other CIPs we won’t be using to be connected to the TX on the other, and vice versa.
for this article. In other words, it’s capable and relatively The PIC RA0 (TX) is connected to the RX pin on the
modern. It has 14 pins (more than we need) but allows for Nextion, and the PIC RA1 (RX) is connected to the Nextion
adding more “tools” to your project later (or debugging). TX pin. We’ll throw a momentary button on RC4 because
it’s digital only. It will use a pull-up resistor R3, making it
The Display Active-Low (when pressed, it’s at ground state; = 0). A
pot on RC2/AN6 gives us an analog value to send to the
Keeping with the “cheap” concept while learning, this Nextion. RA3 is the !MCLR, or RESET pin. It should be tied
article will be built around the smallest NX3224T024_011 to five volts with a 4.7K ohm resistor.
2.4” (240 x 320 pixel) resistive touch display. Nextion sells The power supply is a standard LM7805 with diode
displays as large as 9.0” (800x480 pixels), for a total of protection and capacitor filters. This allows you to use a
eight size choices. If your project requires something larger nine volt battery or a 12 volt bench power supply and still
than 2.4”, you have several options. get the requisite five volts for the circuit.
Figure 2 shows the breadboard loaded as per the
Instruction Set schematic. There are a few extra caps that aren’t in the
schematic for extra filtering, and I omitted the diodes (I
In the previous article, the Nextion Instruction Set have confidence in my bench power supply). I’m using 1K
wasn’t much more than a mere footnote. For this phase, resistors to limit current to the LEDs. You may want to use
the Instruction Set will be referenced quite often. You smaller values to make them brighter.
may wish to print it for easier reference (and notes) as
mentioned previously. At a minimum, be sure you have The Nextion
either the web version or the Instructions tab open in your
Nextion IDE (which requires Internet access). Since we covered how to add objects and set
their Attributes in the first article, that process will be
Schematic
We’ll be
breadboarding a fairly
simple circuit to facilitate
digital and analog inputs
and outputs from and to
the PIC processor, feeding
our Nextion display. When
you look at the schematic
in Figure 1, you’ll see lots
of unused pins on the PIC.
In fact, we could actually
do this experiment with
an eight-pin PIC. The extra
pins are to add more
buttons, switches, knobs,
and other real world
gizmos to your experiment
later. You could also
substitute the PIC16F1824
with practically any other
PIC of your choosing. Figure 1.
According to the PIC Schematic
datasheet, RA0 is the for the PIC/
EUSART TX pin, and RA1 is Nextion
the RX pin. These can also project.
be assigned to RC4 and
RC5, respectively, with the
APFCON0 register. UART
2019/Issue-5 9
Figure 2. Breadboard for the PIC/Nextion
project.

than a 60x60 pixel red circle with


Noise and Lens Flare filters. This
will have to be added to the Picture
library the same way we added
Splash1. From the Picture window,
click on the “+” and add it from
the appropriate file folder. From
the Toolbox, add a new Picture
(p1). Then, in the Attributes pane,
change:

• Picture (p1): pic = 1, x = 130, y =


45, w & h = 60

Nextion Code
Let’s start with the page load
event. From the Attributes drop-
abbreviated here. If something doesn’t make sense, please down, select page0(Page). In the Events window, in the
review Part 1. Preinitialize E... event, add the following code:
We’ll be using the same NX3224T024_11 2.4”
(240x320 pixels) resistive touch screen as in the first article. vis p1,0 //p0 is not visible
n0.val=0 //Clear n0
The display is oriented at 90° horizontal. We’ll also be h0.val=0 //Clear h0
reusing the Splash1 screen (available in the downloads), as
well as the MS_Sans_16 and WideLatin_48 fonts. Click on the yellow button b0 in the display area. In
To configure the screen, we’ll be using objects from the Touch Press Event (12) tab of the Event window, enter
the Toolbox: the following code:

• Picture (p0): pic = 0 (Splash1), x = 0, y = 0, w = 320, h prints 0x06,1 //Sends Cmd Code to PIC
if(va0.val==0) //Previously Off
= 240 {
• Text (t0): bco = 34800, pco = 63488, font = 1 va0.val=1 //Now On
(WideLatin_48), txt = NUTS, txt_maxl = 4, x = 20, y = }else
{
0, w = 120, h = 40 va0.val=0 //Either way, Toggle
• Text (t1): bco = 34800, pco = 65504, font = 0 (MS_ }
Sans_16), txt = AND, txt_maxl = 3, x = 140, y = 10, w prints va0.val,1 //Send State
prints 0xFF,1 //Terminate Sequence
= 60, h = 30 prints 0xFF,1
• Text (t2): bco = 34800, pco = 63488, font = 1, txt = prints 0xFF,1
VOLTS, txt_maxl = 5, x = 200, y = 0, w = 120, h = 40
• Number (n0): bco = 65535, pco = 0, font = 1, val = 0, Next, click on the Slider (h0) at the bottom of the
lenth = 3, x = 220, y = 50, w = 100, h = 40 display area. In the Event window, you have three tab
• Button (b0): bco = 65504, bco2 = 1024, pco/pco2 = choices. The rightmost tab, Touch Move(5), is the one we’ll
0, font = 1, txt = Blink LED, txt_maxl = 9, x = 35, y = enter the following code into:
145, w = 250, h = 40
• Slider (h0): mode = horizontal, bco = 1024, pco = prints 0x07,1 //Sends Cmd Code to PIC
prints h0.val,1
63488 (defaults), wid = 25, hig = 40, val = 0, maxval = prints 0xFF,1 //Terminate Sequence
255, minval = 0, x = 0, y = 200, w = 320, h = 40 prints 0xFF,1
• Variable (va0): Just leave default settings. prints 0xFF,1

For this new project, I added another PNG picture At this time, open the Nextion Instruction Set to review
(NV_A2_LEDr in the downloads) which is nothing more a few things pertaining to the above code. The “prints”
10 2019/Issue-5
command (Section 3 - Operational Commands) instructs this project, but perhaps too small for others.
the Nextion to send data over the serial port. Also note nRx and Work add SYSTEM to the
In the Instructions, there are three print (Send UART) description. Since our Interrupt Handler will be written
options. The “prints” version allows us to send any number in ASM, SYSTEM allows us to refer to these variables
of bytes we want. The “,1” at the end of each line sends by their names without a prepending underscore (nRx
one byte. The print command follows a format that will add instead of _nRx). Lastly, we first declare Work as a BYTE
unnecessary filler bytes that require additional code at the and SYSTEM. Notice how we alias individual bits of Work
PIC end to unravel. with a unique name. In PBP, if you declared Dat VAR BIT,
The first obvious anomaly is the use of prints 0xFF,1 the compiler would assign a memory address for that
three times to terminate a UART transmission. The very single bit. Declaring a Byte, then declaring each bit, you
first thing the Instructions mention is “All instructions over could do Work = 0 and clear each bit in one fell swoop.
serial: are terminated with three bytes of 0xFF...”. We could Furthermore, the ASM syntax doesn’t like BCF Dat but
send anything we wanted over serial, and the Nextion will does like BCF Work, 0.
obediently send it. However, for consistency, we’ll use the Finally, we get to the code. The first line is PAUSE
Nextion convention. When we decipher the PIC code, it 200. When the Nextion first starts, it shoots out 0x00,
will make more sense. 0x00, 0x00, 0xFF, 0xFF, 0xFF, (Startup), then 0x88,
Notice we created a Number object (n0) but nowhere 0xFF, 0xFF, 0xFF (Ready). We can skip all that and start
in the Nextion code did we provide any means of doing communications when both sides are ready. The rest of
anything with it. Also, we added a Picture of a red bulb Start turns off the amber LED (Aled = 0), clears a few
(p1), then turned it off at start-up. Again, nothing further is working variables, fires up Timer 2, enables UART Receive
mentioned in the Nextion code. Changes are handled from (RCSTA.4 = 1), and enables Interrupts (INTCON.7 = 1).
the PIC side of things. Skip over Main for now and let’s look at the
subroutines. Sort loads the Hin array as Bytes are received
PIC16F1824 from the Nextion. When three $FFs are received, it sets our
Mail flag indicating Transmission is Complete. (Dealt with
PBP3 BASIC is a rich, high-level language quite in Main.)
capable of doing virtually anything on an eight-bit PIC. The Next, Clear_Hin rotates through the array, Hin clearing
complete program (NV_A2.pbp) is in the downloads. If you each memory address. The reason for this is we need
are following the bouncing ball with an older pre-v3.0 of to count 0xFF ($FF) Bytes to know when the Nextion is
PBP, you’ll have to change the extension from .pbp to .bas. finished transmitting. As a value could conceivably be
You’ll see that we are doing a few things “the hard 0xFF, it shouldn’t be counted as End of Transmission.
way” instead of using convenient PBP commands. Open Clearing Hin avoids left-over values that could potentially
the program. Starting at the top are the DEFINEs where we contaminate future Receive transmissions.
declare the Oscillator at 4 MHz, and include (commented Filter is where we decipher the Nextion packet.
out) declarations for UART, the ADC, and an Interrupt Looking at the Nextion Instruction Set, Section 7 - Format
Handler (ISR, not commented out), Tog. The line DEFINE of Nextion Return Data, it lists Code Bytes and their
INTHAND Tog will allow us to handle the UART Receive meaning. The subroutine Filter is where we decipher them.
interrupts in an Assembly (ASM) Language Interrupt. As you scroll down through the SELECT CASE offerings, you
Next is the Configurations which include every can match every Code from Nextion to a CASE, plus three
configurable option, denoting its value. If not explicitly extra.
stated, one could assume a default value on start-up, which Referencing the Nextion Instruction Set for a moment,
may not always be the case. It’s better to spell everything notice the Codes are sequentially listed. However, there
out. Tog is listed right after GOTO Init (more on Tog later). are several gaps; 0x06 > 0x10, 0x13 > 0x19, 0x21 >
Right after Init: are the PORT Aliases. I like to define 0x22, 0x25 > 0x64, 0x72 > 0x85, 0x8A > 0xFC, and 0xFF.
every PORT pin, even if it isn’t used. Next are the Special Consider these pockets as empty apartments to house
Function Registers for the Oscillator, PORTs, UART, ADC, your variables (except 0xFF covered shortly). This gives us a
CCP2 (PWM), Timer 2 (used for CCP2), and Interrupts. The total of 215 available slots to assign variables.
APFCON0_1 Registers were needed to place RX, TX, and Back to Filter in the PBP code, CASE $06 is where the
CCP2 on their correct pins. state of our Nextion b0 Button arrives, and CASE $07 is
Lastly are the Variables. A couple notes: The variable for our Slider (h0) value. Additional variables would be
Hin is listed as Hin VAR BYTE[10]. The bracketed 10 assigned other available hex values. CASE $FF is special,
reserves 10 memory addresses — all called Hin — but with as there is no Nextion command 0xFF. Receiving $FF for
offsets. In short, this creates an array to store bytes of Hin[0] indicates we received a real value of $FF for h0 (or
received information from the Nextion. It’s a bit large for something else) and mistook it for the first $FF in the End
2019/Issue-5 11
Figure 3. Micro-standard SD card adapter.

The Memory regions of all PIC


processors are separated into BANKs.
The Program Counter (PC) will go to the
specified Register Address, but only the
last part of that Address (most commands).
If the Bank Select Register (BSR) is on a
different BANK than the one you want, the
PC is sent to the wrong address. The ASM
command BANKSEL is shorthand to get
the BSR to the proper BANK to access the
Register you need.
PIR1 is the Register where we find the
of Transmission sequence. Bytes are shifted one address to RCIF, or UART Receive Interrupt Flag. The actual flag is bit
the left, and the Filter routine is exited (to preserve our Mail 5; or PIR1.5. In ASM, it’s PIR1, 5. BCF is an ASM command
and rDone flags). to clear the bit to 0 (Bit Clear F, where “F” is an Address).
Get_Knob first reads the ADC value of our pot and MOVF allows us to place the value of RCREG into the
decides if it changed (IF Knob != OldKnob THEN). If it has, Working Register, W. We then place that value into our
we send the new value to the Nextion (GOSUB Send_ variable nRx with the MOVWF command.
Knob). Send_Knob sends ASCII “n0.val=“ and our ADC Finally, we need to set two flags: rDone and Dat.
value for Knob. We’re using a variable Kval to determine Since they are bits of our variable Work, they are set with
how many ASCII characters we need to send. IF Knob > BSF (Bit Set F) Work, and either ,1 for rDone or ,0 for
100, THEN we send three digits (Kval = 2). If it’s less than Dat. Finally, the RETFIE command restores our Registers
100, we send two (Kval = 1), and if it’s less than 10, we (Automatic Context Saving; another reason for choosing
only send one character (Kval = 0). FOR b0 = 0 TO Kval the PIC16F1824 over older offerings) and returns the PC to
sends only the needed characters. Without this special the line of code where we were Interrupted.
clause, a value of 99 would read 990 on our Nextion n0. A
value of 7 would read 700. Interrupts and PBP3.1
Back to the top to Interrupt Handler Tog. You can
insert ASM programming into PBP3 one of two ways: The Assembly Interrupt we’re using is one of three
Prepend your ASM command with an “@“ at the leftmost popular methods of handling Interrupts, and the least
of the margin, then add a space or tab before the ASM popular of the three. Assembly language is the native
command (@ NOP). language for any microprocessor. Theoretically, it requires
The other method is to place ASM in the leftmost of the least amount of memory space, and the fewest
the margin before your ASM code and ENDASM at the Instruction Cycles to execute.
end, both of which are used. The PBP manual does cover Assembly Interrupts in the

Resources
ME Labs PBP3
Nextion Main Website http://pbp3.com/download.html
www.Nextion.itead.cc
Microchip
Nextion Editor Software Download www.Microchip.com
www.Nextion.itead.cc/resources/download/
nextion-editor Digi-Key
www.DigiKey.com
Nextion Instruction Set Download
www.Nextion.itead.cc/resources/documents/ All Electronics
instruction-set www.AllElectronics.com

12 2019/Issue-5
Advanced section starting at 6.3 on page 252. PBP3 has state of our button. IF Sw = 0 THEN indicates the button is
ON INTERRUPT GOTO... where the PBP compiler handles pressed (pulled high with R3, grounded when pressed). We
everything for you. You then code in the familiar PBP then send “vis p1,1” to the Nextion — a literal command
language. turning on our red circle. If the Sw button is not pressed,
The third option is the DT_INTS developed by the late “vis p1,0” is sent, turning off the circle.
Daryl Taylor. It requires two Include files, but offers much
more flexibility over On Interrupt GOTO, and is easier to Back to “Main”
program than ASM; essentially, the best of both worlds.
I was privileged to contribute to a digital book on the Scroll back up to the Main routine. The first task is to
subject, which can be found at http://dt.picbasic.co.uk. check to see if our Sw button has changed states. If so, we
(The PBP3 manual does not cover DT_INTS.) tell the Nextion with GOSUB Send_Button. Next, we read
If you only need the UART Receive Interrupt for your the pot value, but only once per 256 cycles through Main
project, the code listed is cut and paste functional. If you (using Rot). Within the Get_Knob routine, we check to see
require Timer or other Interrupts, you may want to change if Knob changed since the last reading. If it did, Send_Knob
to something more familiar. is called.
The third section of Main checks for Framing or Over-
Sending Values to the Nextion run Errors and does a UART RESET if there are any. Fourth,
if the Nextion has sent us anything, we have to load it into
The subroutine Send_Knob requires a bit of our Hin array. When we get our End of Transmission (3 x
explanation. The Nextion Instruction Set tells us that all $FF), we know we have a complete packet and it’s time
transmissions are in ASCII. It also tells us that most Nextion to “read our mail:” IF Mail = 1 THEN : GOSUB Filter. Every
commands can be sent via UART. pass through Main increments our Rot variable. When it
We’ll be using the PBP LOOKUP command to bit-bang rolls over from 255 to 0, we check our Knob value again.
out our Nextion commands. PBP offers a simpler solution This throttles visits to the ADC Register and reduces
than the route chosen. You could use HSEROUT or even congestion for our slow 9600 baud UART.
DEBUG to send data. Nevertheless, follow along as we
manually execute our transmissions. Uploading Our Software
The LOOKUP command sends ASCII “n0.val=“ to
get things started. The ARRAYWRITE command allows The software for the PIC is created in the MicroCode
us to convert up to three digits of Knob to ASCII; using Studio IDE with PBP3.1. Programming a PIC chip is really
array KnobA[3]. A quirk with ARRAYWRITE is when you dependent on the programmer you use. The PICkit3 has its
have a numeric value that is greater than 100, you get process, while the ME Labs U2 programmer (my personal
the expected value, as there are three digits to convert to favorite) uses a different process. I leave it up to you to
ASCII. No problem. If there are fewer than three digits, the know how to program a PIC chip with the programmer you
end result is not what you’d expect. have.
The value 99 becomes 990.
The value 7 becomes 700. Just
below ARRAYWRITE KnobA... is
an IF/ELSEIF statement that limits
how many digits will be sent to
the Nextion. Finally, there’s a FOR/
NEXT LOOP that sends three $FFs.
Note that in the C programming
language (and the Nextion
Instruction Set), hexadecimal is
denoted as 0xFF, while PBP uses
the $FF nomenclature.
The subroutine Send_Button is
very similar to Send_Knob, except
we test our Sw input and send an
ASCII command that reflects the

Figure 4. Actively talking to a PIC.


2019/Issue-5 13
Description Value Digi-Key PN quite difficult to find. For this reason, I’ll cover that
method here.
R1 47 ohms 1/2 watt S47HCT-ND
The SD card slot in most laptops is sized
R2 4.7K ohms 1/4 watt CF14JT4K70CT-ND for the regular SD card. The Nextion takes only
R3 10K ohms 1/4 watt CF14JT10K0CT-ND microSD cards. The solution is something like
R4 1K ohms 1/4 watt CF14JT1K00CT-ND
Figure 3. All Electronics offers SD card adapters
for micro-to-standard. The SD card must be
R5 1K ohms 1/4 watt CF14JT1K00CT-ND
formatted as MS-DOS FAT 32.
RP1 50K Pot 987-1733-ND Make sure the SD card is completely empty
D1 1N4002 1N4002-TPMSCT-ND with no folders. From the Nextion Editor, click on
D2 1N4002 1N4002-TPMSCT-ND File, then “Open build folder.” A new window will
appear with your project(s) listed and the .TFT
D3 Red LED 160-1127-ND
file(s). Copy the appropriate .TFT file to the SD
D4 Amber LED C566C-AFF-CU0W0252CT-ND card. When you create a program in Nextion, it
SW1 NO MOM Button EG2031-ND generates an .HMI file, which is the whole project.
C1 1 µF Elec Cap 493-10461-1-ND The .TFT file is the only thing the Nextion can use
for programming.
C2 .1 µF Disc Cap BC1160CT-ND
Copy the .TFT file to the SD card, remove the
C3 .1 µF Disc Cap BC1160CT-ND micro from the holder, insert it into the Nextion,
C4 100 µF Elec Cap P5182-ND then power it up. You’ll see it loading, running
U1 LM7805 296-47192-ND
through the programming sequence, then finally
it will read, “Update Successed!” (remember,
U2 PIC16F1824 PIC16F1824-I/P-ND
Nextion is a Chinese company). Power-down,
U3 NX3224T024_011 N/A remove the SD card, and you’re done!
Parts List
The Grand Finale
The software for the Nextion is created using the
Nextion IDE. Programming is done one of two ways: serial With your breadboard loaded as per the schematic,
port or SD card. Instructions for using a serial port are quite the PIC programmed with the software in the downloads,
explicit and covered numerous times in various Nextion and the Nextion programmed with the screen we just
documents. However, using the SD card to program was created, you should have a functioning HMI. If you turn the
knob on the breadboard, the Nextion
n0 value should read the ADC value
(0 >> 255). Press the momentary
THE MOST COMPLETE PROGRAMMING TUTORIAL! button and the red circle appears; let
off and it disappears.
• Everything you need to learn to program PIC® micro-
From the Nextion screen, press
controllers is included in this package
“Blink LED” and the amber LED lights
• Learn the fundamental concepts of programming, up. Press it again and the LED goes
including program flow, loops, coding techniques, binary out. Slide the red bar across the Slider
manipulation, device-to-device communication, user (h0) and the red LED gets brighter
interface design, in-circuit debugging, and more! and brighter. Slide it the other way
and the red LED gets dimmer (see
• Includes all the necessary the software, compiler,
$99.99 trainer board, cable, tutorial with exercises and sample Figure 4).
Academic and bulk pricing available You can now add gizmos and
code! transmit digital and analog data back
Check out our other popular products and forth. You have the basic building
for PIC® developers including: blocks for a most amazing modern
creation! NV

PBP3
U2 Programmer
PBP3 Compiler
Prototyping Boards
PICBASIC PRO™ Compiler Experimenter Boards
www.melabs.com
Contact us at info@melabs.com

14 2019/Issue-5
■ BY LOU FRENZEL W5LEF OPEN COMMUNICATION

Dirt Cheap Wireless Control


Playing Around with Wireless Stuff

I ’m a sucker for cheap electronic parts — especially wireless stuff. Just recently,
a catalog from one of my favorite parts distributors (AllElectronics.com) came
in the mail and was promoting some wireless modules: a transmitter (TX) and
a receiver (RX) for just a few bucks each. I ordered immediately. What I got is shown
in Figure 1. Now that I had these wireless modules, I wasn’t sure what to do with
them. I had no plan or goal in mind. So, I decided I would just experiment for fun.
This article sums up what I did and what I learned.

Figure 1. The cheap wireless


modules discussed here. The
transmitter is on the left and
receiver on the right.

First, Do the Research


Of course, there was no
documentation. So, as most of you
do, I did an Internet search. I found
some articles and other useful
stuff. What surprised me was how
many other vendors are selling
these same modules cheaply. Some
company must have dumped a
boatload of these modules on the DIY marketplace. Our
gain.

Transmitter Specifications
The TX module is the small one in Figure 1. The circuit
is a single transistor oscillator and a transistor switch to
apply the data input. Figure 2 shows a simplified diagram
of the TX. The oscillator’s frequency is set by a surface
acoustic wave (SAW) device.
SAW devices are used mainly as filters, but also as a
substitute for a quartz crystal. The SAW resonator in this
TX sets the operating frequency at 433.92 MHz. This is
one of the license-free industrial-scientific-medical (ISM)
frequencies set aside by the FCC for low power short-range
applications.

Figure 2. A simplified hypothetical representation of the


transmitter (TX).
2019/Issue-5 15
THE LATEST IN NETWORKING AND WIRELESS TECHNOLOGIES
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2019/05.

breadboarding socket. Power is a DC voltage in the three


to 12 volt range with five volts recommended. The pin
connections are shown in Figure 3.
The limited documentation that I discovered pointed
out that the TX could transmit without an antenna.
Maximum range is three meters or so. Not very useful. Add
a simple vertical antenna and the range jumps to 30 meters
under the best conditions. You can make an antenna from
6.5 inches of solid copper wire oriented vertically.

Receiver Specifications
The RX is the larger of the modules in Figure 1. I didn’t
find much data on this module other than it seems to exist
in several different versions. It has dimensions of 30 x 14
mm and comes with a four-pin connector. My receiver
module was labeled MX-RM-5V.
Figure 4 shows the pin connections. This illustration
also shows an external transistor switch to operate an LED
for test purposes. The RX operates from 3 to 12 VDC.
The only details on the receiver are that its frequency of
reception is 433.92 MHz and it demodulates OOK/ASK
Figure 3. The TX pin connections. data. Sensitivity is said to be in the -105 to -115 dBm range.
Not bad for a cheap receiver.
This TX is used to transmit digital data. It takes a serial The data rate can be up to about 10 kb/s.
digital bit stream that modulates the oscillator with on-off Theoretically, the RX and TX match to form a complete
keying (OOK) or amplitude shift keying (ASK). What that transceiver. Testing will tell.
amounts to is just turning the oscillator off and on with the
switch transistor.
The TX puts out a binary 1 signal that is a burst of a
Testing the TX and RX
433.92 MHz sine wave equal to one bit of time of the data The ultimate test is to transmit some data and see if the
stream. A binary 0 is sent as no sine wave out. This TX can receiver can recover it. Then, test the maximum range. For
take data as fast as 8 kb/s. The output power is estimated this test, I used two breadboarding sockets; one for each
to be about 10 mW or +10 dBm with a five volt supply. module. I used a 9V battery for both devices.
Physically, the TX is very small: 19 x 19 mm square. The TX supply voltage needs to be dropped to five
It has four connector pins that will plug easily into a volts. I used an available 7805 regulator to do this. The
TO-220 package version is
overkill for this project, but it
was handy. The TO-92 package
version would work just fine.
The RX also gets a five volt
supply. I built a 555 timer IC
oscillator data source for the
transmitter; refer to Figure 5.
It sends out a rectangular
wave with a frequency of 1 Hz
or so. It generates a continuous
stream of alternating binary 1s
and 0s to be transmitted.
For the receiver, I
connected a transistor switch
to flash an LED as the data
is received and recovered.
Figure 4. The RX pin connections showing the external transistor to operate an LED.
Figure 4 shows the details. I
16 2019/Issue-5
THE LATEST IN NETWORKING AND WIRELESS TECHNOLOGIES

used another vertical 6.5 inch solid copper wire as


the antenna that is soldered to the RX PCB (printed
circuit board). This process is a challenge because
the copper on the RX board is so small.
Use the minimum heat and solder as possible
to avoid damage to the PCB and other parts. The TX
has the same problem; the area to solder an antenna
is tiny so requires careful soldering.
Some of the most critical components in this
project are the antennas. Just find some wire that
is stiff enough to stand up straight and that will
also plug into your breadboarding socket. This wire
forms a quick and easy quarter wave ground plane
antenna.
I put the TX and RX on the bench in front of
me. When I applied power to both, the LED did
start to flash. So, the devices were communicating.
However, if I turned off the TX, I still noticed some
flickering of the RX LED output.
Looking at the data output pin with an
oscilloscope showed a jumpy random set of output Figure 5. The popular 555 timer IC generates a rectangular bit
pulses. This is noise picked up by the receiver. stream used for testing.
Reducing the supply voltage on the receiver helps to
reduce the noise. A supply voltage of less than about swap out a suspected bad module for another one. My
four volts reduces the data output pulse voltage. However, initial test didn’t work as the RX was not working. Replacing
it may not be useful in operating something other than a the RX module solved the problem.
flashing LED.
Next, I took the two units out in the back yard and set
the TX on a table. I then held the RX and started walking
Wireless Theory
away. I have a huge yard and I got about 30 feet away There is a way to predict the maximum range of a
before the LED stopped flashing. Not a bad range for such single link between a transmitter and receiver. First, you
small low power devices. can use the mathematical expression for free space path
Range really varies with the terrain. Signals in this loss:
frequency range take a line-of-sight (LOS) path from TX
to RX. Trees block signals and signals do not penetrate dB path loss = 37 + 20 log f + 20 log d
buildings very well. Open free space is what these simple
wireless modules require for best performance. The frequency f is in MHz and the distance d between
A couple ways to extend the range is to boost the the transmitter and receiver is in miles.
transmitter power from the 10 mW with a 5V supply to An important take-away is that free space path
about 16 to 18 mW with 9V. Extending the antenna length loss increases with frequency. The higher the operating
— especially at the RX — should show some improvement. frequency, the higher the path loss. Higher frequency
Playing around with the antenna position and orientation signals just travel less distance for a given power level.
will also help. One thing we need to do is convert our distance
Slowing the data rate down to 1 kb/s or less helps estimate from feet to miles. Let’s see what the path loss
reduce transmission errors and that usually translates to is for 30 feet. Since one mile is 5,280 feet, then 30 feet
longer reliable range. would be 30/5280 = 0.00568 mile.

What If It Does Not Work? dB loss = 37 + 20 log f + 20 log d = 37 + 20 log (433.92) +


20 log (.00568)
The most likely problem is a wiring error. I made dB loss = 37 + 20 log f + 20 log d = 37 + 52.75 - 44.9 =
several myself getting cross-eyed as I tried to wire up 44.85 dB
devices with 0.1 inch spacing between pins. Always
double-check any wiring. Also, maybe one of the modules Next, you should determine the power that reaches
is bad. If you bought multiple modules like I did, you can the receiver. A good estimate is given by:
2019/Issue-5 17
THE LATEST IN NETWORKING AND WIRELESS TECHNOLOGIES

The receiver sensitivity


needs to be better than this for
a communications link to be
established. Using the receiver
sensitivity of -105 dBm, you should
see that -34.8 dBm is a higher
power than -105 dBm; the receiver
should easily pick up the signal with
some gain to spare.
For a given receiver sensitivity
that cannot be changed, the easiest
way to extend the range is to
increase the transmitter power if
possible. Boosting the TX power by
increasing the supply voltage from
5V to 9V should extend the range a
bit more.
This calculation is only an
approximation unless you really
know the transmit power, receiver
Figure 6. The Holtek HT12E CMOS encoder chip that delivers address and data to sensitivity, and antenna gains. There
the transmitter. The transmitted frame is also shown: three bits of header; eight is also the issue of fade margin.
bits address; and four bits of data. This is an additional loss due to
reflections from the ground or other
objects that create multipath signals
Pr = Pt + Gt + Gr - Path Loss that produce multiple constructive and destructive waves.
Add a fade margin of 5 to 20 dB to the total path loss
Pr is the received power in dbm; Gt and Gr are the for longer range links. For such short ranges as used here,
transmit and receive antenna gains. If simple quarter wave it’s not that relevant and can be ignored. Nevertheless, the
antennas are used, their gain is one. Assume a transmit calculation is a good starting point to determine the range
power of 10 mW or 10 dBm. So, the received power is: of your equipment.

Pr = Pt + Gt + Gr - Path Loss = 10 + 1 + 1 – 44.8 dB =


-32.8 dBm
Applications
Most wireless transceivers are tied to a microcontroller
that provides the data to the TX and accepts the data from
the RX. That micro also runs an app, whatever that may be.
A few things come to mind as far as uses: a digital
thermometer; a gate or door opening warning; and a light
monitor. Garage door openers use wireless devices like
this, but operate on 315 MHz. I suspect you could think
up something to do with this. A useful variation is to have a
TX and RX at each end of a wireless path for true two-way
communications.
A missing part of the transceiver is having some kind
of coding and formatting of data available. You could
cobble together something like this with a big batch of TTL
or CMOS gates, counters, and registers. You can also buy
some IC encoders and decoders that will take care of that.

Figure 7. The Holtek HT12D CMOS decoder chip showing


DIP switches to provide an address input that is used to
compare to the received address that identifies the data
to be sent to the output.
18 2019/Issue-5
THE LATEST IN NETWORKING AND WIRELESS TECHNOLOGIES

These could be the Holtek HT12E


encoder for use at the TX and the
HT12D decoder to use at the RX.
These parts are available from
Jameco Electronics (www.jameco.
com).
The HT12E encoder lets you
deliver a simple data protocol
consisting of a frame made up of an
address and data bits. The encoder
shown in Figure 6 accepts eight
bits of address from DIP switches
or some other parallel data source.
The eight-bit address lets you accept Figure 8. The wireless circuit for turning a remote external load off and on.
data input from up to 28 = 256
sources. The chip adds four bits of trigger IC (TTL 74LS14 or CMOS CD4069).
data from switches or another digital source. An on-chip Each time a pulse occurs, the FF will change state.
clock shifts the address and data out along with a header The FF (TTL 74LS107 or 74LS112 or CMOS CD4027) will
that the receiving chip will recognize and sync to. remain in one state until power is removed. Pressing the
The HT12D is a decoder used at the receiver to TX button again will change the FF state. Press the button
identify the device or multiple devices from the data bits; to turn the load on; press the button again to turn the load
refer to Figure 7. This chip accepts the serial data from off.
the receiver, then processes it. It compares the received If the switch contacts bounce, you’ll get multiple
address against its own eight-bit address input so that it pulses that will toggle the FF several times. You can
routes the accompanying data to the four data output lines. minimize this problem by putting a capacitor across the
It will output the data or interpret it and provide an output. 4.7K resistor in Figure 8. Experiment with several sizes to
You can avoid using and programming a microcontroller in see what works. Values in the range from 0.1 µF to 10 µF
some applications by using these CMOS ICs. should work.
If you’re already a micro user and programmer, the
TX and RX are easily interfaced to a microcontroller like
the Arduino. Then, you can program the whole unit to
What Else?
implement the application you choose. There are lots of other wireless modules available out
there for short-range applications. They may be OOK/
Making It Useful ASK devices that are designed for sub-1 GHz frequencies.
Or, they may use FSK or spread spectrum modulation
Blinking an LED 30 feet away is not very useful. that are used in some of the well-known technologies like
Granted this is not a high-tech solution, but with a few Bluetooth, ZigBee, or Z-Wave that work at 2.4 GHz.
modifications, this TX-RX pair can be of value. It’s a good I’ve used some of the Radiometrix TX1 and RX1 FM
tool for turning remote electronic/electric loads off and on modules distributed by Lemos (www.lemosint.com) with
at some distance. Figure 8 shows one possible solution. good success on a couple of wireless projects. If you’re still
A transistor is used to operate a 5V relay. The diode just learning wireless, simple modules like the ones used
across the relay coil protects the transistor when it switches here are best for learning. Give them a try.
off. The relay contacts are connected to an external If you have never experimented with wireless before,
power source such as the 120 VAC line. When the relay these modules are an inexpensive way to try it out.
is activated, the contacts close applying power to the load Wireless has been with us for over 120 years and is widely
— a light or pump or something else. Any external voltage used. However, you’ll discover its real magic working with
source and load can be operated this way so long as the it at this level. NV
relay contacts are rated high enough.
Take another look at Figure 8. When the pushbutton
at the TX is pushed, a burst of 433 MHz RF goes out. The
receiver picks up the signal and demodulates it into a pulse
that will change the state of the flip flop (FF).
The pulse out of the receiver is rounded and noisy,
so it’s cleaned and squared up by applying it to a Schmitt
2019/Issue-5 19
Dr. Duino’s
Starter Kit for
the Arduino Uno
I (like many Nuts
& Volts readers)
have spent many
hours designing
circuits based on
microcontrollers, and
then breadboarding
the circuitry to verif y
proper operation
before committing to
building the actual
project. In many of
my breadboarding
activities, would-be
faults in my design
turned out to be bad
connections between
the components or
connections to the
controller module
itself. Figur e 1: Full y as s e mble d s t ar te r k it w it h an Ar duino att ache d.

T
o make matters worse, every time I’ve had to learning Arduino hardware and software design. Getting
move my breadboard for one reason or another, into microcontroller development for the first time can be
I have had to start the debugging process all a daunting undertaking and anything that can simplify the
over again due to flakey connections. process will be welcomed by many.
So, the moral of this story is to limit the number of I came up with numerous possibilities for how the
connections used during the breadboarding process (if DDSK could be used, including:
possible) to help keep your project working and your
sanity intact. 1. As a trainer for people just getting into the Arduino
This, I believe, was a major motivation for the Dr. ecosystem. Illustrate things like how you read a
Duino Starter Kit (DDSK) for the Arduino Uno from button’s state, read an analog input, or how you use a
drduino.com. This device, as will be described later, can digital output signal to light an LED.
make your breadboarding activities with the Arduino Uno 2. As a platform for writing an Arduino application’s
more robust and trouble-free. code before the associated custom hardware is
In addition, the DDSK can also be a useful tool in available.
20 2019/Issue-5
By Craig Lindley
REVIEW
Figur e 2 : Two -t ie r
cons t r uc t ion of t he
s t ar te r k it w it h an
Ar duino plugge d in
unde r neat h.

3. To allow the piecemeal development of hardware that switches (five if you count the Arduino reset switch which
will eventually be turned into a custom Arduino shield. is broken out separately from the Uno itself for easy
4. As a platform for testing a custom shield for proper access), five LEDs, six potentiometers, and a piezo speaker/
operation. buzzer.
Each Arduino pin is brought out to a three-pin header,
There are lots of possible uses for this starter kit. allowing two possible jumper positions. Position 1 routes
an I/O pin to either input sources on the starter kit itself
The Kit (like pushbutton switches or potentiometers) or to onboard
output devices like an LED or the piezo buzzer.
The starter kit consists of a 4-1/8” x 3-3/4” bright red Jumper position 2 routes the I/O pin to the shield
printed circuit board (PCB) with a large rectangular hole in connectors on the top of the starter kit where your custom
the middle. The PCB has a series of test points, pushbutton hardware would be connected.
switches, LEDs, jumpers, and an RS-232 interface arrayed With this arrangement of jumpers on each I/O pin,
around the board’s perimeter; refer to Figure 1. you can use only the hardware on the DDSK itself; use
An Uno is plugged onto the bottom of the board after a combination of hardware on the DDSK and custom
assembly is completed. The finished assembly has a two- hardware of your own design; or use only your custom
tier arrangement as shown in Figure 2. hardware for development.
The kit arrived in the mail in a small envelope Lots of flexibility for sure.
containing an Arduino Uno clone and a packet of thru-
hole components that need to be manually soldered onto
the PCB. All the hard-to-solder surface-mount components
Test Software
are already in place. Anyone with minimal soldering The downloaded assembly instructions zip file
experience should have no trouble completing the starter contains both a PDF document detailing the assembly
kit’s assembly. process, information on how to download the Arduino IDE
Included with the kit of parts was a card with a (Integrated Development Environment), and how to load
link to the DrDuino website for downloading assembly and run the provided test software for exercising the starter
instructions, documentation, and test code for exercising kit to verify its functionality.
the starter kit once assembly has been completed. See Studying the test program sketch called DrDuino.ino
Resources for the link. The components provided with the will give you a very good idea of how the starter kit works.
kit seemed to be of good quality with the result being that It will also give new Arduino programmers insight as to
the starter kit worked when I finished the construction. how Arduino code is structured.
The kit came with an eight LED NeoPixel strip, but With the test software sketch loaded and operational,
there was no mention of this in the documentation. Not to pressing various pushbuttons will toggle LEDs on the
worry! I put it to use in playing with the starter kit. More on DDSK. The serial monitor output from the IDE shows
this in a moment. the value of the five analog inputs on the Arduino; these
values change as the various onboard potentiometers are
Hardware adjusted.
Finally, pressing pushbutton SW4 will cause a simple
The starter kit consists of four momentary pushbutton song to be played through the piezo buzzer/speaker.
2019/Issue-5 21
REVIEW
A Simple Project NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);

// Misc variables
Since the NeoPixel strip was included with the kit, unsigned long futureTime;
I thought I would put it to use. I connected the strip as int pixelNumber;
bool countingUp;
follows:
// Setup code goes here
Strip Connection DDSK Pin Connections void setup() {
GND GND // Initialize NeoPixel object
DIN 13 pixels.begin();
4-7 VDC 13
// Initialize variables
futureTime = 0;
I then uploaded the following code to the starter kit: countingUp = true;
pixelNumber = 0;
/* }
Example Code for the Dr. Duino Starter Kit for
Arduino // Main code goes here
This code implements a Larson Scanner with void loop() {
adjustable color and speed. A Larson scanner is
a row of lights which illuminates in a back and // First read the user adjustable values for
forth manner. The Larson scanner is named after color and speed
Glen A. Larson,the man responsible for producing
both the original Battlestar Galactica and Knight // Read the color component values
Rider television shows where the scanners were byte red = analogRead(RED_ADJ);
used on the Cylons robots and on the Knight Rider byte grn = analogRead(GRN_ADJ);
car. byte blu = analogRead(BLU_ADJ);

Potentiometer Analog Input // Combine to form a color value


Function uint32_t pixelColor = pixels.Color(red, grn,
================================================= blu);
RV6 A0 Red Color
Adjustment // Read the speed value
RV5 A1 Green Color byte speedValue = analogRead(SPEED_ADJ);
Adjustment
RV4 A2 Blue Color // Map analog value 0..254 to MIN_DELAY_MS..
Adjustment MAX_DELAY_MS
RV1 A5 int currentDelayMS = map(speedValue, 0, 254,
Speed MIN_DELAY_MS, MAX_DELAY_MS);

NOTE: Make sure JP17 and JP18 on the starter kit // Is it time for a change ?
are in the upper positions or completely removed if (futureTime < millis()) {
or else you won’t be able to download code to the // Turn off all pixels
starter kit. pixels.clear();
*/
// Set the current pixel to the current color
#include <Adafruit_NeoPixel.h> pixels.setPixelColor(pixelNumber,
pixelColor);
// Make sure the jumper for pin 13 is towards the
dot on JP12 if (countingUp) {
#define NEOPIXEL_PIN 13 pixelNumber++;
#define NEOPIXEL_COUNT 8 if (pixelNumber >= 7) {
countingUp = false;
// Assign the color adjustment functions to the }
analog input potentiometers } else {
#define RED_ADJ A0 pixelNumber--;
#define GRN_ADJ A1 if (pixelNumber <= 0) {
#define BLU_ADJ A2 countingUp = true;
}
// Assign the speed function to the analog input }
potentiometers
#define SPEED_ADJ A5 // Make the affected pixel visible
pixels.show();
// Delay values to control speed
#define MIN_DELAY_MS 50 // Calculate future time for next change
#define MAX_DELAY_MS 500 futureTime = millis() + currentDelayMS;
}
// Instantiate the NeoPixel driver }
Adafruit_NeoPixel pixels(NEOPIXEL_COUNT,
The result is a Larson Scanner that is controllable both
22 2019/Issue-5
NEW!
in color and scan speed. Refer to the
code for the details.

Conclusions www.poscope.com
There is utility in having the
DDSK if one is doing a lot of Arduino
Uno development. It can save time
and frustration for the reasons
I’ve discussed. In addition, the
documentation talks about a private
Facebook group and an available 12
lesson training video which I didn’t
have access to for this review.
For Arduino veterans like myself,
this bonus material is unnecessary.
For someone just coming up to speed
with the Arduino, having a forum to
ask specific questions and have lesson
plans available would be invaluable. - USB - PWM
REMOTELY
VIEW AND
I had hoped that a schematic - Ethernet - Encoders
- Web server - LCD
of the starter kit circuit would be - Modbus - Analog inputs

NAVIGATE
available, but none was included in - CNC (Mach3/4) - Compact PLC
- IO
the downloaded documentation or
on the Dr. Duino website.
Finally, I could see this same
approach being used with a
Raspberry Pi, ESP8266, ESP32, or
other microcontroller modules to
8 Channels of
aid in the development of custom Simultaneous
hardware for those devices.
I have to say, the DDSK is a great - up to 256 - up to 32
Monitoring
way to get started. NV microsteps microsteps
- 50 V / 6 A - 30 V / 2.5 A
- USB configuration
- Isolated

Resources PoScope Mega1+ Temp Current


Info about the starter kit can
PoScope Mega50
be found at www.drduino.com.
Assembly instructions for the kit can
be found at www.drduino.com/
Voltage Pulse
pages/downloads.
The Arduino IDE can be
downloaded from https://www.
arduino.cc/en/Main/Software.
-up to 50MS/s
-resolution up to 12bit
6 Warner Road
-Lowest power consumption Warner, NH 03278
-Smallest and lightest
Post comments on this article and -7 in 1: Oscilloscope, FFT, X/Y, Recorder, (603) 456-2011
Logic Analyzer, Protocol decoder, Signal
find any associated files and/or generator madgetech.com
downloads at www.nutsvolts.com/
magazine/issue/2019/05.
2019/Issue-5 23
PRODUCTS
■ HARDWARE
■ SOFTWARE

NEW
■ GADGETS
■ TOOLS

DIGITAL • Precision focusing range 2 cm-9.5 1x ABS baseplate


MICROSCOPE cm (0.8”–3.75”) from the test 1x User manual
object — perfect for soldering

T he Saelig SAE106S Digital


Microscope is a versatile tool
designed specifically for PCB
activities.
• UV filter provided protects the
lens and reduces reflections and
The regular retail price is
$199.99. However, the microcope is
currently on sale for $189.
inspection, but it can also be useful in stray light.
other fields. It can be used as a stand- • Eight LED ring illumination with For more information, contact:
alone device with its built-in 4.3” adjustable intensity control allows Saelig Company
color LCD screen, or be connected to setting optimal illumination levels. www.saelig.com
a PC. Illumination is enhanced by an • Two arm-mounted fill lights on
eight LED adjustable ring light, with either side can be moved freely, RADIOMETRIX
two additional repositionable side
lights. The SAE106S offers 10x-220x
and their brightness can be
adjusted by a dimmer switch.
LORA
magnification for seeing the smallest
The SAE106S also includes the
following Saelig-exclusive additions:
A Peer-to-Peer (P2P) Private LoRa
communication that allows
direct bi-directional communication
• Large 7.75” x 8” non-conducting between any two devices without
ABS plastic base. any gateway infrastructure or uplink/
• 16 GB micro-SD memory card for downlink restrictions imposed by
storing images and video. the LoRaWAN protocol on end
• Micro-SD USB card reader. devices is now available from Lemos
• Updated user guide. International. Higher LoRa receive
sensitivity extends the operating
Visual inspection is the first range in applications where FSK
tool in PCB debugging. Searching transmit power cannot be increased
for missing or charred components, above the unlicensed band ERP limit.
bad solder joints, and solder bridges Features and applications include:
is the first order of business when • Point-to-point, point-to-multipoint
a bad board comes in for repair. with addressing
Look for solder bridges or solder • Customizable 150-960 MHz
whiskers between pads and solder • RF power: +20 dBm (100 mW)
joints — especially between the • Eight digital inputs for remote
pins of fine-pitch SMD chips (but controller
note that adjacent ground pins will • Eight digital outputs for actuator
blemish or trace problem, and can often be bridged by design). If the • Four digital inputs, four digital
store images and videos on an SD problem is a short, there may be outputs for bi-directional remote
card or be transferred to a Windows burned spots on the printed circuit control
PC. The SAE106S includes the board. They can be quite small, but • Wakes up from sleep mode to
following standard features: the normal green solder mask may transmit input status change
• 4.3 inch full HD color LCD be significantly discolored and visible • 250 byte buffer 3.3V TTL UART
screen. 10x-220x continuous under magnification. serial data modem
magnification. Features include: • Channel activity detection (CAD)
• High quality optics for stunning 1x Desktop digital microscope • Packet acknowledgement
1080P images. 1x Stand • Learns pairing addresses for
• High quality precision-adjustable 1x USB cable remote control
stand changes the distance 1x USB 3.0 SD card reader • Industrial/commercial telemetry
between the camera and the 1x SD card and telecommand or non-specific
object and its magnification. 1x UV filter SRD usage
24 2019/Issue-5
• In-building environmental superhet, 128 channel PLL 8 MM REX PINION
monitoring and control
• Security and alarm
synthesizer with TCXO
• Data rates up to 5 kbps for GEARS
• Automated irrigation system standard module
• Size: 33 x 25 x 8 mm • Usable range over 1 km (with
• 779-787 MHz (China), 865-867 100 mW variant)
MHz (India), 863-870 MHz (EU), • Fully screened
902-928 MHz (US) • Feature-rich interface (RSSI,
• 2 MHz TCXO reference with automatic noise squelch, analog,
±2.0 ppm frequency stability over and digital baseband)
-30˚C +85˚C • Incorporates a 1200 baud dumb
• SAW front end filter modem
• Supply voltage range: 4V-16V DC • User configurable via RS-232
• User baud rate: 9600 bps
(default), 19200, 38400, 57600,
115200
interface
• Handheld terminals
• Heavy vehicle/machine remote
I f your build is going to take a
beating, consider the 8 mm REX
pinion gears now available from
• Modulation bandwidth (BW): 7, controls goBILDA. These gears are constructed
15, 31, 62, 125, 250, 500 kHz • EPOS equipment, barcode of hardened steel and mount with
• Spreading factor (SF): 7, 8, 9, 10, scanners two set screws for excellent hold on
11, 12 • Data loggers 8 mm REX shafting. Pricing for the 8
• Coding rate: 4/5, 4/6, 4/7 • Industrial telemetry and mm REX pinion gears is $6.99 in 20T,
• 32 MHz TCXO reference with telecommand 24T, and 30T.
±2.0 ppm frequency stability over • In-building environmental
-30˚C +85˚C monitoring and control
• SAW front end filter • High-end security and fire alarms
5 MM HTD TIMING
• Vehicle data up/download BELTS
• Operating frequency: 458.5-
MULTI-CHANNEL 459.1 MHz or 433.05-434.79
TRANSCEIVER MHz

T he VX2M, also available from


Lemos International, is a 400
MHz band transceiver conforming
• Custom variants from 400 MHz
to 475 MHz on any 3 MHz band
• 23 channels in 458 MHz band,
to the Radiometrix TR2M pinout. It 69 channels in 433 MHz band
uses a sophisticated combination (128 channels max)
of techniques to produce a very • Transmit power: +20 dBm (100
robust device with excellent mW) nominal
resistance to vibration. It meets the
ETSI Category 1 high performance
receiver specification to be used
• Supply range: 4.5V–16V
• Current consumption: 130 mA
transmit, 50 mA receive
T he 5 mm HTD timing belts also
available from goBILDA are
prime for large scale projects which
where the operation of an SRD • Data bit rate: 5 kbps max encounter heavy torque loads. With
may have inherent safety of human (standard module) a taller tooth profile and larger pitch
life implications. It retains all the • Receiver sensitivity: -118 dBm when compared to 3 mm HTD, these
pin-functions of the parent TR2M (for 12 dB SINAD) new belts and pulleys transfer torque
(including noise operated squelch/ • Size: 59 x 38 x 10 mm with less chance of slipping, skipping,
carrier detect and separate digital/ or breaking. The 5 mm pitch timing
analog inputs and outputs). It also Pricing is $170 each. belts are constructed of neoprene
supports the same internal i1200 and have fiberglass cords to nearly
modem as the TR2M. For more information, contact: eliminate stretching. The more coarse
Features and applications include: Lemos Intl. Co., Inc. pitch (when compared to goBILDA’s
• Conforms to EN 300 220-3 and www.lemosint.com 3 mm HTD belt) provides the ability
EN 301 489-3 to handle higher torque loads without
• ETSI EN 300 220-1 Category 1 If you have a new product that you slipping or skipping teeth. Pricing
high performance level receiver would like us to run in our New starts at around $4-$5.
• Any 3 MHz band module from Products section, please email a
400 MHz to 475 MHz available short description (300-500 words) For more information, contact:
as factory tuned custom variant and a photo of your product to: goBILDA
• High performance double newproducts@nutsvolts.com. www.gobilda.com
2019/Issue-5 25
Printed Circuit Boards Build
Arduino Graphics Interface
e t h i n g
TEENSY Graphics Interface
Mass Measurement
Som
Today
!
Wide Range Pulse Generator
Numitron Clock
Continuity Tester
Pi Scrolling Display Search www.nutsvolts.com for these terms and read the articles.
Search store.nutsvolts.com to find the boards.
Analog Style LED Clock Some are available as complete kits too!

Nuts & Volts and SERVO On CD

Getting Started Kits Popular DIY Kits


ARDUINO: A Beginner’s Guide To Amigo Kit
Programming Combo Solar Charge Controller Kit 2.0
Learning Labs 1-3
Geiger Counter Kit
Poor Man’s Seismograph
LED Cube
4 Position HF Antenna Switch
26 2019/Issue-5
To Order Visit
store.nutsvolts.com
or call
1-800-783-4624

Arduino
Graphing Thermometer
3D Printed Enclosure Kit New! Read the article in issue 4,
then get your kit while they last.

2019/Issue-5 27
BUILD IT YOURSELF

BUILD THE NIXIESTAR

CLOCK

The NixieStar clock is the second timepiece kit I’ve


developed. My aim was to have a kit that’s reasonably easy
to build with intermediate soldering skills (i.e., minimal SMD
components). I also wanted a clock kit that once it was built,
any spouse (including my wife!) would accept it on their
wall — even with a power cord hanging from it. The clock
can be built in either 16 inch or 14 inch diameter versions,
depending on the Nixie bar graph tubes used.
28 2019/Issue-5
By Joe Croft

■ FIGURE 1 - Reading the minutes on


the clock.

W
hile my first kit was a
geekier design using
technology for the
clockworks to be more in line with
those of the tubes, this design is meant to be more elegant Circuit Description
and have a more intricate case. It still uses an ATmega328 The clock can be divided into five main sections:
from Atmel for its processor, as well as the Maxim 1771 IC
for the power supply. 1. The low and high voltage supplies.
The two surface-mount components are the real time 2. The CPU with its switches.
clock (RTC) IC that does the actual time keeping and the 3. The RTC.
12-channel digital-to-analog converter (DAC) for driving the 4. The 12-channel DAC.
tubes. It sports a 15F capacitor for maintaining the time 5. The Nixie bar graph tubes and their drivers.
when there is no power. Once fully charged, the capacitor
will keep the time for a month or two with no power. Figure 2 has the schematic CPU portions of the clock
Because the clock only has 12 hands (tubes), to which encompass the first four sections. Figure 3 shows
determine the exact minute that the clock is on takes section 5 (the 12 tubes and their drivers).
counting the blades on the ‘propeller,’ which is comprised The low voltage supplies are simply a single LM78L05
of short segments that rotate around on the 12 lamps. or LM78L33 linear regulator which reduces the 12V to
There can be one, two, three, four, or six blades lit; these 5V and 3.3V, respectively. The high voltage supply is a
indirectly indicate the number of minutes past the five- switching boost supply comprised of a MAX1771 IC and
minute mark indicated by the long hand. associated parts to generate the 150V needed to drive the
One blade is for zero minutes; two is for one minute; Nixie tubes.
three is for two minutes; four is for three minutes; and six The Maxim 1771 operates by effectively shorting
is for four minutes past the five-minute increment. Figure 1 the 12 volts DC to ground through the coil L1 using the
gives a visual representation of this. MOSFET Q1. When it turns off Q1, this releases the coil
There are two buttons and one switch used to set the from ground and a large positive spike is generated, which
time. The switch that is located between the 11 o’clock is then stored in electrolytic capacitor C8. Diode D1 keeps
and 12 o’clock hands will move the time either forward the capacitor from discharging back through the circuit.
or backward one hour with each toggle. The time will be The 1M, 1.2K, and 20K potentiometer in parallel with
moved forward if the switch is
toggled toward the 12 o’clock
hand and moved backward one
hour if the switch is toggled
toward the 11 o’clock hand.
Finer control on setting
the time is provided by the
two buttons on the face. The
left button (while pressed) will
advance the clock forward one
minute every second or so until
it’s released. The button on
the right side of the clock will
advance the clock forward 10
minutes every second until it’s
released. Finally, if both buttons
are pressed simultaneously, the
clock will be paused until they
are released.

■ Circuit board.
2019/Issue-5 29
C8 form a voltage divider which feeds a small voltage back provides a large enough well of energy to help keep the
to the Maxim IC so that it can adjust the pulse’s frequency voltage high enough for the low voltage supplies as the
and duty cycle to regulate the voltage. Capacitor C1 MOSFET shorts the coil to ground.
The CPU
portion handles
the switches which
allow you to set
the time, as well
as feed the correct
values to the
DAC that drives
the tubes. Notice
there’s a hand
■ FIGURE 2 - adjust jumper. This
CPU schematic. jumper will force
the clock into a
mode where it
drives each tube
one at a time at
full length.
This has two
effects. When
the tubes haven’t
been operated for
a long period of
time, they need
to be driven for a
while before they
will illuminate
their full length.
It also allows you
to step the length
of each tube’s
length, so they are
reasonably equal.
This process is
described later in
the article. The
debug jumper —
when cut — allows
debug messages
to be sent out of
the serial port.
The
12-channel DAC
is driven through
the SPI bus of
the processor. It
provides 12 eight-
bit DACs (one for
each tube) that
can be individually
set. Once a
channel’s value is
30 2019/Issue-5
set, that channel’s analog value will be maintained until a The code for the processor is basically a large loop.
new value is set. It checks for the switches to be activated and if they are,
The RTC is controlled through the I2C bus of the deal with the time as needed. If no switch activations are
processor. It provides a trickle charge to the super cap to detected, it then reads the time from the RTC if needed
keep it fully charged for when it’s needed. The IC has an and sets the hands accordingly.
onboard crystal which makes it pretty accurate. Over a One of the biggest issues I had with this clock was
year, it should be within five minutes. noise generated by the high voltage power supply getting
This IC also provides a 32K kHz
signal that’s used as the time base
for the processor (not the system
‘clock’ which is driven at 16 MHz).
All the timers within the code are
based off the signal from the RTC.
The Nixie bar graph tube
and driver are very simple. The
tube itself has two or three pins
depending on size. The larger tube
has three pins. Pin 1 is the anode;
pin 2 is the cathode on the larger
tube; and pin 3 is an auxiliary
cathode.
The tube is driven by always
having 160V on the anode, then
pulling the cathode to ground
through a resistance. A transistor
is used to vary the resistance and
hence the amount of current that
flows through the tube. The higher
the current, the longer the segment
of the cathode is illuminated.
The auxiliary cathode of the
longer tube is used to help ensure
that the cathode will always start
glowing at the bottom of the tube.
With the shorter tube, they use
different metals in the cathode to
help persuade the cathode to start
at the bottom. With either tube,
you must treat them kindly or the
cathode will not glow where you
want it to.
The first rule is to not make
drastic current changes on the
cathode. It’s best to step the current
up and — more importantly — down
at a steady pace. The second rule
(for the shorter tube) is that you
never completely turn it off because
it may not turn back on if you just
want a short segment lit.

■ FIGURE 3 - Nixie bar graph and driver


schematic.
2019/Issue-5 31
Putting in any of the parts backwards will cause the
clock to malfunction and most likely damage the
component and/or the clock.

Construction
First, the obligatory warning! This clock uses
160 volts which is present on the board. Handle
the board carefully! I typically only manipulate the
board by its edges once it’s separated from its ‘outer
square.’
The kit assembly manual is included with the
downloads for this article. It’s more detailed and has
many helpful drawings that you can refer to.
The printed circuit board (PCB) assembly is
pretty straightforward. I start by building both the
low and high voltage supplies and making sure
they’re working. I then place the two surface-mount
chips. These are reasonably easy to solder. I place a
light coat of solder on two opposing corner pads for
each IC, then set the chip on top and heat one of
those corners until the solder melts.
I’ll adjust the chip so it’s properly aligned and
heat up the other corner. I then proceed to solder
■ FIGURE 4 - Mounting the Nixie bar graph tubes. the remaining pins. Remember, it takes just the
tiniest bit of solder for each pin.
After soldering each IC, I inspect them with
onto the 3.3V logic supply. This greatly interfered with the a magnifying glass to ensure the pins are all properly
operation of the RTC (which is a bit fussy about this). A soldered and there are no shorts.
proper layout of the power supply would have probably After those ICs are placed, I install the remaining
helped, but there were space limitations for this. components for the processor. This includes the 1.1 µF
The two steps I used to help combat this was the capacitor, the crystal, the electrolytic capacitor, the two
classic: Put a bigger capacitor on it. The first was to place a ‘Hand Adj’ pins (which should be placed on the back of
big capacitor before the coil of the HV power supply. This the board), and the three 3.3K resistors.
helped ensure that when the coil was shorted to ground, The next parts to install are the three switches. After
there was enough energy to not put a giant dip in the these, I install the three sets of 12 resistors (clocks with the
voltage to the low voltage regulators. The second was to IN-9 tubes only have two).
put a large capacitor very close to the processor and clock The tubes are the last pieces to be installed. It’s
chip to help ensure that they always had reasonably clean important to ‘loop’ the leads of the tubes as shown in
power feeding them. Figure 4.
This board contains parts which must be installed in a This allows the tube to be moved about when
certain direction. The electrolytic capacitors must have the mounting it in the frame. If the leads are too taut when
positive lead (typically, the long lead) inserted into the hole soldered to the board, the tubes will crack and be ruined.
with the square pad. Not all the electrolytic capacitors have The photo shows the smaller tube which only has two pins.
a square pad for the positive lead. Be sure to look for the This is to help you see which two holes should be used.
pad marked with a + symbol on the silkscreen to put the For either tube, the silvered side of the tube should
positive lead into. There are always + symbols by the pad be down facing the board. You should be able to see
for the positive lead of the electrolytic capacitors. the ‘cage’ around the wire when looking down at the
Diodes must have their cathode inserted in the square component side of the board.
hole. The cathode side of the diode has a stripe painted The case construction is a bit more involved. This case
on it. The transistors and the regulator have their outline is my first foray into using a CNC machine. Talk about
silkscreened on the board. Be sure to orient them correctly. learning new skills! Fortunately, I found a nice compiler of
Pin 1 of the CPU has a square pad. You need to rely on sorts that accepts a C like language and creates a G-code,
the silkscreen to show the orientation of the two SMD ICs. SVG, or DXF file.
32 2019/Issue-5
With the case being very geometrical,
this worked well. It allowed me to use my
programming skills to tell the CNC what to
do. That just left learning how to make a
CNC cut a pattern from wood repetitively.
(My family enjoyed a few evenings in front
of the fire pit outside disposing of the
chopped trees I slaughtered in the process!)
The tree massacre was worth it! Not
only did I learn a lot about working with
wood and the CNC, but I can now cut out
all the pieces to a case with my CNC in just
a couple of hours.
The pieces of the case come on five
boards in the kit. Care must be taken
when handling the boards and removing
the pieces from the board. The pieces are ■ FIGURE 5 - The wood crosses.
held in place on the board by small tabs.
If they’re not cut, the wood can break
accidentally and blemish a surface. The
pieces must be cut with an Xacto™ or
similar knife to keep them pretty.
Start by separating the base and the
sticks. Remove the tabs on the sides and
lightly sand as needed. DO NOT OVER
SAND the sticks! If you sand too much, the
sticks will fit sloppily into the slots on the
base.
Be sure to test that the sticks will fit
snugly (but not too snugly!) into the base
(DO NOT GLUE YET). Join the pairs of sticks
(a short stick and a long stick) into little
crosses with a small dab of glue at the joint
between the two. Refer to Figure 5.
They are at 60 and 30 degree angles, so
■ FIGURE 6 - Mounting the crosses on the base.
the crosses are a little odd.
After all the sticks are joined together,
they can be glued on to the base (Figure 6).
The smallest stick fills in the open section of the
clock on the opposite side of where the short stick
butts into the long stick (Figure 7).
It doesn’t take much glue to hold the clock
together. Only put a small amount of glue in the
slots (not on the sides!) of the sticks to help ensure
that glue doesn’t get onto the top surfaces of the
sticks or the base.
Once the glue hardens, you can then sand the
top of the base and sticks with 220 grit or finer
paper to help smooth the surface. Be sure to sand as
close to the direction of the grain as possible. With
the 30 and 60 degree angles of the sticks, you can
only approximate this.
Apply the finish you’ll be using to the base and
the sticks. Be sure to not put any finish on the last ■ FIGURE 7 - Placing the smallest stick.
2019/Issue-5 33
■ FIGURE 8 - The bottom side of the bottom circle with the ■ FIGURE 9 - The bottom of the top circle with the peg
wood pads installed. installed.

without the slot) on the bottom circles as shown in


Figure 8.
Apply a single coat of finish over the entire
piece except for the bottoms of the two pieces of
wood you glued to the circle. These are the surfaces
that will be glued to the sticks above.
Cut the dowels into 1/2” segments, then glue
each segment into the hole in each of the top circles
(Figure 9).
Once the glue hardens, sand the tops of the top
circles with 220 grit or finer paper. Only sand in the
direction of the grain.
Once the glue hardens, apply your finish to the
circles. There are no surfaces that you will be gluing
on these pieces.
Now, glue the bottom circles to the points of the
star by cutting small segments from the remaining
dowels about 5/8” each; put some glue on the tip
and put it into the top of the tip of the star. Then,
apply glue to the small pieces of wood glued to the
■ FIGURE 10 - The face with two of the four standoffs installed. bottoms of the bottom circles and press it on to the
star, having the small dowel passing through the
hole in the circle.
inch of the length of the sticks that form the points. These Be sure the slot in the circle is facing up. Be
will have wood glue applied to them which will not adhere very careful to ensure the slot is facing exactly to the center
well to the finish. of the star and is flat to the plane of the star. If they are not,
Next, we turn to the circles. Carefully cut out each of it will be obvious once it’s complete. Wood glue is very
the 24 circles. Separate the tops from the bottoms. You unforgiving, and you will not be able to fix them once the
can tell them apart by the bottom circles having a hole in glue hardens.
the center that passes through them entirely. You need to The final sub-assembly that needs to be put together
cut small 1” to 1-1/4” segments from the ribs that were is the face. Start by sanding it with the grain using 220
between the sticks and glue them to the bottoms (the side grit or better sandpaper. Apply your finish. Do not let the
34 2019/Issue-5
■ Completed frame.

finish build up in the ‘wells’ for the


pushbuttons on the front of the
face.
Next, screw the four long
standoffs into the small holes on
the backside of the face using a nut
driver. Refer to Figure 10.
Once everything is done to
your liking, it’s just a matter of
putting all the completed pieces
together to finish the clock.
For the 16” clock, put the
tops of the wood pieces for
pushbuttons through the large holes
on the back of the clock. Set the
assembled clock PCB face down
onto the standoffs. Be sure to line
up the holes. Now screw the short
standoffs through the holes in the
PCB and into the long standoffs.
Place this whole assembly — small
standoff down — onto the base, being sure to align the Don’t forget to keep those pushbuttons in place! It’s a
short standoffs with the holes in the base. Insert the 4/40 bit trickier, but it can be done.
screws into the back of the base to secure the clock to it. Set the clock on a flat surface face up. Make sure all
For the 14” clock, the only difference is that you will the tubes are aligned in the slots of the circles and that the
not use the short standoffs. You will instead use the long tips do not go past the slots. Press-fit the small sticks on the
4-40 screws supplied and thread them through the base, top circles into the bottom circles (DO NOT GLUE) and
then the PCB, and then screw them into the long standoffs you are done!
on the face.

1 DS1339C RTC IC 1 C1 390 µF Capacitor


1 78L05 (L4931CZ50-AP) 5V Regulator 2 C2, C5 220 µF 10V Capacitors
1 Q1 IRLS640 MOSFET 1 C3 470 µF 6.3V Capacitor
1 D1 BAV21 250V Diode 1 C4 .1 µF Capacitor
1 ATmega328 Processor 1 C6 1 nF Capacitor
1 78L33 3.3V Regulator 1 C7 2.2 nF Capacitor
12 MPSA42 Transistors 1 C8 4.7 250V Capacitor
1 AD8802 12-Channel A/D Converter IC 1 15F Super Capacitor
1 MAX1771 Boost Power Regulator 4 3/8” 4-40 Screws (Only for clocks with IN-9 Tubes)
12 R1 2.1K Resistors (Only for clocks with IN-9 Tubes) 4 5/8” 4-40 Standoffs
12 R1 3.3K Resistors (Only for clocks with IN-13 Tubes) 4 3/8” 4-40 Standoffs
12 R2 168/169 ohm Resistors (Only for clocks with IN-9 4 7/8” 4-40 Screws
Tubes) 1 150 µH/220 µH Coil
12 R2 475 ohm Resistors (Only for clocks with IN-13 2 SW1, SW2 Pushbutton Switches
Tubes) 1 SW3 SPDT Momentary Switch
12 R3 220K Resistors (Only for clocks with IN-13 Tubes) 1 28-pin Socket
1 .1 ohm Resistor 1 16 MHz Crystal
1 1.2K Resistor 1 Six foot Cable Barrel Connector Assy
1 1M Resistor
3 3.3K Resistors PARTS LIST
1 20K Pot
2019/Issue-5 35
Post comments on this article and find any associated
files and/or downloads at www.nutsvolts.com/ RESOURCES
magazine/issue/2019/05.
Explanation of cold cathode tubes such as neon bulbs and
Nixie bargraph tubes
Burn In https://www.saltechips.com/lab/theory-of-operation-and-
construction-of-the-in-13-nixie-gas-discharge-tube
The Nixie bar graph tubes need time to burn in to
light to their full length when they aren’t used for extended “The GE Glow Lamp Manual” — my bible for circuits of all
periods of time. To do this, put the jumper across the two sorts using neon bulbs as the active component
time adjust pins. This will light each lamp (1 through 12) www.nixieneon.com/main/wp-content/uploads/2018/08/
the full length one at a time. I let the clock sit running ge_glow_lamp_manual_2nd_ed.pdf
overnight like this.
NeoNixie-l Google Group; a great bunch of folks all interested
After they’ve reached their full length, they can then be
in Nixie tubes
adjusted by leaving the jumper in place and using the two https://groups.google.com/forum/#!forum/neonixie-l
buttons on the front of the face and the switch. The right
button will stop the sequencing of the lamps and will move A complete kit for the NixieStar is available in our webstore
the hand forward one lamp for each press. https://store.nutsvolts.com
When the lamp you want to adjust is lit, you can toggle
the switch toward the 12 o’clock hand to lengthen the
hand and toward the 11 o’clock hand to shorten the hand.
Time’s Up!
This control is crude and will wrap around if you try to I really feel the NixieStar clock is a piece of art that can
move beyond the minimum lengths. be enjoyed all the time! I hope you think so too. NV
The left-hand button will resume the normal
sequencing of the lamps. Removing the jumper will allow If you prefer to not purchase a kit, all the instructions
the clock to run normally. To keep from losing the jumper, needed to complete the NixieStar on your own are available in
place it on just one of the two pins. the article downloads.

36 2019/Issue-5
See page 20 for the review.
By Ryan Gedminas
BUILD IT YOURSELF (high school student)

BUILD A RADIO PET


TRACKER

Knowing your pet’s location is invaluable. With modern


technology, there are commercial solutions giving accurate
GPS location for days on end. However, these options are
costly. So, as a useful and educational project, I built my own
tracker using a simple radio beacon.
38 2019/Issue-5
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2019/05.

Sitting on my porch, I watched I made a prototype using an


the neighborhood cat roll around in ATtiny85 that would power a pin on
the gutter, then stroll off down the the ATtiny85 for a half second every
sidewalk. I wondered where he might second. This pin was connected to
have gone. This project is an attempt the data pin of the board and, in turn,
to answer that question and learn caused the transmitter to turn on and
about radios along the way. off with the pin. In theory, this would
Tracking animals is not a new use less power than transmitting
idea. If you do some research about constantly.
electronic locators for small animals, However, after connecting it
you’ll quickly be presented with to an ammeter, I realized that it is
options costing upwards of $100 more power-efficient to route three
that use GPS to locate the collar and volts directly to the data pin, and
a cellular connection to report back have it transmit continuously since
the device’s location. If you look for the ATtiny85 was drawing more
cheaper options, most use Bluetooth power than it saved. With continuous
and simply notify you when the transmission, a name brand coin cell
device is out of range. None of these battery would power it for 48 hours.
■ FIGURE 1. First prototype using an
options were what I was looking for. ATtiny85.
I assembled another version
So, in the spirit of amateur radio, I set without the ATtiny85 by attaching the
out to do it myself. board to a CR2032 coin cell battery holder using hot glue.
The scientific community has driven the development I routed the 3V power to the VCC and Data pins on the
of animal tracking technology since the ability to follow board. I also soldered a thin piece of copper wire to the
movements of animal species can reveal very useful ANT port to act as an antenna. This small copper wire was
information about their behavior. They often use a simple wrapped around the battery holder and was held in place
transmitter that produces a carrier wave on the desired with hot glue.
frequency in short bursts. To receive the signal, any radio receiver capable
To utilize this, a person with a radio receiver tuned to of tuning to 433 MHz would work, although higher
the same frequency uses a directional antenna such as a sensitivity is better. I used a Baofeng UV-5R handheld radio
Yagi-Uda antenna to determine the area where the signal transceiver. In combination with the radio, you’ll need a
is coming from. This direction is referred to as the angle directional antenna.
of arrival. By marking this bearing on a map, moving to
another location and repeating, the approximate location
of the transmitter can be determined as where the two
bearings intersect.
This activity is called radio direction finding. Amateur
radio operators have made a sport out of using directional
antennae and radios to locate a hidden transmitter in
all sorts of terrain. This skill is used by professionals to
eliminate interference and find persons during search and
rescue operations.
To build my own radio direction finding system, I
decided to use a generic 433 MHz radio transmitter
module commonly utilized for Arduino projects. I chose
this because they’re inexpensive, simple to use, and only
require power and a signal to operate.

Radio direction finding techniques are used by multiple


groups such as emergency aid responders, avalanche
rescue, and military reconnaissance. Many civil aircraft have
radio beacons to help locate them in the event of a crash.
Avalanche transceivers help locate people who have been ■ FIGURE 2. Second prototype with battery holder and
buried by snow. wrapped antenna.
2019/Issue-5 39
■ FIGURE 4. Most recent revision with
dipole antenna.

MHz which is 17 centimeters.


■ FIGURE 3. Handmade six-element Yagi-Uda antenna. The Yagi-Uda antenna’s issue was
most likely a poor electrical connection
between the coaxial cable and
driven element. For the antenna,
I tried using an Arrow II satellite
antenna which is a dual band Yagi
meant for sending and receiving
radio signals to and from amateur
radio satellites. It worked very well
in conjunction with a Baofeng UV-
5R.
With this system, I was able to
find the angle of arrival and get a
clear signal from 1/2 mile away in a
dense urban neighborhood. I used
the cell phone application, SigTrax
to assist with plotting the bearings,
but this could be accomplished
with a map and compass.
This method works well in
relatively open areas. However, in
an urban neighborhood with back-
■ FIGURE 5. Bottom half of Arrow II satellite antenna for tracking. to-back houses, the signal reflects
off these buildings and arrives at
A directional antenna is built so that it has significantly a different location than it originated from. So, instead of
more gain in one direction relative to the antenna. Most plotting bearings, I simply followed the direction at which
radio direction finding applications use Yagi-Uda antennas. the signal is strongest and eventually arrived at the source.
I built a Yagi-Uda antenna for 433 MHz with six elements This is because the streets act as a sort of tunnel for the
using copper wire and PVC pipe. radio waves.
After some tests, I realized that there were two issues
with the system: The antenna was not directional enough; SigTrax is an application available for iOS and Android
and the transmitter’s signal was not strong enough.
To fix these issues, I made another transmitter; this one that utilizes the cellular phone’s GPS and inputs from the
with the antenna not wrapped around the battery holder user to assist in triangulating radio signals. This saves a lot
but instead sticking straight off the board. I also added a of time and effort when faced with plotting bearings on a
length of wire to the ground pin acting as a dipole. For this
antenna, I calculated 1/4 of the radio wavelength at 433 map manually.
40 2019/Issue-5
■ FIGURE 6.Transmitter in canvas case attached to cat
collar.

SigTrax App After practicing with the tracker in a stationary


position, I put a snug canvas cover on it and attached it
www.amcept.com/sigtrax
to a collar to put on my cat. After giving the cat some
Radio treats and a pat on the head, I watched him wander away.
https://baofengtech.com/uv-5r Throughout the day (using my antenna and radio), I found
him laying under a car, standing on a fence, and socializing
Antenna with some of the neighbor’s dogs.
www.arrowantennas.com/ Building a radio tracker for your favorite pet can be
arrowii/146-437.html
a very interesting and educational use of electronics. For
less than the cost of a pack of gum, you have a reusable
radio beacon light enough
433 MHz Transmitter Module to be carried by most
Hookup Wire Parts List animals. The components
CR2032 Coin Cell Battery Holder used in the project can also
Handheld Radio capable of tuning to 433 MHz (Baofeng UV-5R) be repurposed for other
projects. NV
■ Schematic. Directional Antenna for Radio

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


2019/Issue-5 41
BUILD IT YOURSELF By Chris Watson

BUILD AN AUDIO LOOP


SYSTEM
The last time I had my
hearing aids serviced,
I discovered that the
devices included a T-mode
operational feature which
could be activated on
request. So, I requested it.
(My hearing aids are the
brand Rexton, available
through Costco.) There are
five operational modes
which can be selected
either by cycling through
the programs using
the pushbutton on the
instrument itself, or by using
a cell phone app which
permits you to control
all sorts of operational
parameters.

T
he T-mode (or Telecoil) setting allows you to receive I decided to build an installation for my home, and
audio signals fed to an induction loop, which is just also to use available parts on hand wherever possible. I use
a wire loop laid on the floor around the perimeter iCircuit, a bargain program available from the Microsoft
of the desired area. Induction loops can be found in Store for $4.99, which can be used for both schematics
places such as concert halls, movie theaters, auditoriums, and simulation. It runs on Windows 10, and is fun and easy
churches, banks, and public buildings where PA to use.
announcements are common. That is where I evolve and simulate my circuits.
42 2019/Issue-5
Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/
magazine/issue/2019/05.

Review the Theory volt secondary; a heatsink mounted power rectifier bridge,
and, of course, my box of TIP30A transistors. The TIP30A is
The magnetic field H at the center of a circular wire a medium power device in a TO220 package with a rated
loop is given by the equation: constant current of one amp, so my design required three
devices in parallel mounted on a good heatsink to provide
H = N.I/2/R this.
The TIP30A has a minimum hFE of 40 which
and the Flux Density: demanded an additional Darlington mode 2N3906 drive

B = µi . µ0 . N.I / (2R)

where H is the magnetic field in ampere-turns/meter; B is


the magnetic flux density in Tesla; µi is the permeability of
material (µair = 1); and µ0 is the permeability of free space
= 4 . π . 10-7 T.m/A. I is the loop current in amps; R is the
loop radius in meters; and N is the number of turns.
In a two-meter radius single-turn loop with a current
of two amps, the flux density B = 0.628 micro-Tesla. To get
an idea of the magnitude of this field, note that the earth’s
magnetic field ranges between 25 to 60 micro-Tesla, and
the field from a refrigerator magnet is over 300,000 micro-
Tesla.

Realistic Design
Parameters
POWER SUPPLY PARTS LIST
A loop of two-meter radius would easily fit in my
home. The audio signal would be a modulation on a Power Transformer Signal 56/4 — used
standing constant current, so a constant current of two or Power Bridge Rectifier Anonymous — used
three amps from a 12 volt power supply would mean a Electrolytic Capacitor 10,000 µF VDC C1, C2
constant power dissipation of 36 watts. Perhaps a lower Op-amp LM358
supply voltage would be okay later. Zener Diode 5.1V D1
According to the available parts theorem, I had a large Power Transistor PNP TIP30A PNP T2, T3, T4
reel of 22 AWG insulated wire on hand, and figured that Signal Transistor PNP 2N3906 T1
if on my prototype system I used a twist of three strands, 1/4W Carbon Film 2.2K R1
I could use them either in series or in parallel to give a 1/4W Carbon Film 56K R2
stronger field (3x) or lower loop resistance. I needed power 1/4W Carbon Film 68K R3
transistors, and had a box of TIP30A
PNP devices available.
My first project was to build
a suitable power supply. Second
would be to build the drive
amplifier, and the third project
would be to build myself a portable
receiver so I could evaluate the
telecoil in my hearing aids.

Power Supply
I assembled a pile of assorted
parts: two used 10,000 µF 40V
electrolytic capacitors; a used Signal
56/4 power transformer with a 14
2019/Issue-5 43
transistor from the LM358 op-amp. The bridge produced signal V2 at the non-inverting input of the first op-amp. This
19 VDC unloaded, so the volt drop across the control amp has unity DC gain and signal gain of about two, giving
elements is about six volts. The power dissipated in the the drive voltage of (V1+V2) at the second op-amp. This
control elements is about 15 watts. voltage is impressed upon the 0.6 ohm resistors generating
the loop current (V1+V2) / 0.6 x 2 [note the two output
drive transistors]; the drive current is (V1+V2) amps. That’s
Loop Drive Amplifier about 2 ADC plus the audio component whose amplitude
is limited to about 1A pk-pk. The 0.6Ω resistors were made
using 24 AWG brass picture wire wound around a vitreous
power resistor.
The headroom available to drive the loop with 2A from
my 12 VDC supply is perhaps 10V, which limits the loop

Diode 1N4148 D2
Ceramic Capacitor 100 nF C3, C4, C5
Ceramic Capacitor 100 pF C6
Op-amp LMC6482
Zener Diode 5.1V D1
Table Text TIP30A PNP T6, T7
Signal Transistor PNP 2N3906 T5
1/4W Carbon Film 10K R4
1/4W Carbon Film 100K R5, R6, R8
1/4W Carbon Film 47K R7
1/4W Carbon Film 3.3K R9
1/4W Carbon Film 1K R10, R11
1/4W Carbon Film 100 R12, R13
Custom Wire Wound 0.6 ohms R14, R15

DRIVE AMPLIFIER PARTS LIST

resistance to a maximum of about


5Ω corresponding to a wire length
of 200 ft (60 ft dia) of single strand
or 600 ft (180 ft dia) of triple strand
22 AWG wire.
By using screw strip connectors
and color-coded pins on the wires,
it was easy to swap from serial to
parallel operational mode.
On testing the loop drive using
the hearing aid T-mode, an iPad
voice recording came through loud
and clear. This signal amplitude was
measured to be about 1V pk-pk.
Success! There was no
The resistance of 22 AWG wire is rated at 19Ω/1000 background noise and no apparent distortion. The signal
feet; my loop measured 1.3Ω in parallel and 3.6Ω in serial was clear at ear level about six feet above the loop, and
mode. The loop is represented in the schematic by the I could walk anywhere within the loop. The signal was
two-ohm resistor and the 2 mH inductance. The current good all over within the loop; outside the loop the signal
through these components is the sum of a constant current decayed to an inadequate level after a distance of about six
and the audio signal current. feet.
In this circuit, a constant DC voltage V1 (one diode I mounted the finished power supply and driver in a
drop referred to the 12 VDC rail) is added to the audio simple plywood housing and added a small cooling fan
44 2019/Issue-5
in reality — is a Hall effect sensor fully integrated into the
A telecoil is a small coil inside your hearing aids. The coil
chip.
works as a small receiver which picks up signals from a loop
The most sensitive discrete linear Hall-effect device
system that acts as an electromagnetic field. Hearing aids
I could find has a sensitivity of 100 mV/mT. Maximum
with an activated telecoil can convert this electromagnetic modulation amplitude is 0.6 µT, corresponding to a signal
field into a sound signal. of 60 µV from the Hall-effect device.
In my application — assuming maximum modulation of
to provide some ventilation. Finally, I added a nylon strap the base flux density — the voltage developed by a small
(located off-center) to make the unit balanced and easier to Ferrite-cored coil (using the following parameters) would
carry. After the fact, I looked up the International Standard be given by:
for induction loops. It calls for a magnetic field strength of
400 mA/meter and a bandwidth requirement of 100-5,000 E = - N . dϕ/dt = - N.A. dB/dt Tesla,m2/Sec that is volts
Hz. My system field H equals N.I/2/R and evaluates to 500
mA/m for the single loop, then 1,500 mA/m for the triple Using a Ferrite bobbin 12.5 mm long and 1.5 mm
loop. diameter, effective permeability of the core is about 30
There’s a commercial loop system marketed by (reduced from material value >3,000 by a demagnetization
Williams Sound which advertises a seven amp system and factor of about 0.01).
advocates an insulated copper tape as the loop material, If = 2,000 turns : A = π x 0.00152/4 = 1.7x10-6 : max
which seems to me to be a good solution to the problem ∆B = 0.6 µT : ∆t = 10-3 (Period of 1 kHz)
of fixing a wire loop to the floor in an unobtrusive and Then, E @ 1 kHz = 2,000 x 1.7x10-6 x 0.6x10-6 x 30 /
reliable way. I see that they also have solved the problem 10-3 = 61.2 x 10-6 = 600 µV
of handheld receivers for folks who don’t yet have suitable This estimate is 10 times the output given by the Hall-
hearing aids. effect device, so the coil approach was decided upon.

Receiver Design Portable Receiver Design


Parameters Design parameters are:

The electronic part of my hearing aid is approximately • Amplifier Gain ~ 2,000 minimum (1V out for 600
a 1/4 inch cube, containing very sophisticated circuitry. µV in)
It’s hard to believe that the magnetic field detector within • Audio Bandwidth at least 300 Hz to 3 kHz
the hearing aid is a discrete conventional ferrite cored coil • Low quiescent power, preferably single AA cell
with many turns of fine wire, but easier to believe that — • Output to be clearly heard in handheld position

2019/Issue-5 45
I chose to not add component
identities (R1, C1, etc.) on the
schematics because it seems to
me unnecessary and makes them
more confusing. Plus, iCircuit
doesn’t generate them anyway.

chip which required a minimum


4V supply. My battery holders
were twin AA, so my supply was
six volts. I found it necessary to use
the filtered pin 7 on the LM386 as
the supply to the front end and to
prevent distortion from noise on the
supply line.
Gain from the LM386 was
selected as 200, and the input
stage 2N2222 was 22; more than
sufficient at 4400. Two problems
arose in mounting the circuit in a
plastic box.
One was using an inductive
pick-up near a loud speaker needs
care in positioning to prevent
feedback, and the second was
proximity to the pick-up coil of
current carrying wiring. The high
RECEIVER PARTS LIST gain system demanded the 2000 pF
Signal Transistor NPN 2N2222 T8 cap to prevent instability.
Ceramic Capacitor 100 nF C7, C8, C9
Ceramic Capacitor
Audio Amp
2 nF
LM386
C10
Wrap-Up
Electrolytic Capacitor 10 µF C11 In conclusion, test of the system showed a comparable
Tantalum Capacitor 1 µF C12 performance between the hearing aid’s built-in Telecoil
1/4W Carbon Film 220K R16 feature and the handheld device. I was surprised that the
1/4W Carbon Film 68K R17 handheld unit was so tolerant of its orientation in the loop
1/4W Carbon Film 33K R18 field. The device was excellent for speech, but sounded a
1/4W Carbon Film 1.5K R19 bit tinny for music.
Speaker 2” dia 8 ohm It was a fun project full of challenges and surprises. It
AA Battery & Holder 1.5V Qty 4 would probably be a more practical system if it ran on a
ABS Plastic Housing 5”x2.5”x1.5” lower loop power supply voltage like 5V, and it would be
Amidon Ferrite Bobbin B-72-111 nice if the receiver ran on a single AA cell.
Single-pole Switch On reflection, it would be possible to make the loop
LED and Series 10K using a surplus 100 foot spool of 50 conductor ribbon
cable. Each conductor is seven strands of 40 AWG listed at
In keeping with my available parts theorem, I found a 0.93 ohms/foot. So, wired in parallel, we would have a flat
few Ferrite bobbin cores (Amidon #72-1111; at least 25 cable with about 1/3 ohm per 100 feet which would make
years old) and a spool of 40 AWG magnet wire. I wound a 5V drive system a reality. Using a ribbon with its low
as many turns of 40 AWG magnet wire as I felt would fit. profile would make the installation unnoticeable. NV
The coil resistance was 62Ω and the inductance
measured 2 mH. Estimated N was between 1,600 and
2,200 turns.
I designed the circuit using the LM386 audio amplifier
46 2019/Issue-5
BEST SERVICE. BEST WARRANTY. BEST VALUE. NO ONE BEATS LDG! CONTACT YOUR FAVORITE DEALER TODAY!

WIRE ANTENNAS for


BALUNS & UNUNS
Not sure which wire antenna is right for your LDG Balun or Unun?

30
Check out this handy chart of popular wire antennas. Just add an
LDG tuner in your shack with any of these antennas and work mostly
80-10 meters with good results. Visit www.ldgelectronics.com to learn
$ ea.
200 Watts PEP
1.8-30MHz
more and see our full line of Amateur accessories.

55' 55'
33'

32'

33'
RBA-1:1
RBA-4:1

44' 88'
65'

RU-4:1 RU-9:1

25' Coax
25' Coax

RU-1:1
RU-1:1

410-586-2177 support@ldgelectronics.com www.ldgelectronics.com


BUILD IT YOURSELF

A SEMICONDUCTOR-BASED
HIGH VOLTAGE UTILITY
POWER SUPPLY
For those who
experiment
and build with
vacuum tubes,
an adjustable,
regulated,
benchtop high
voltage power
supply is essential.
Many circuits for
such units have
been described
that themselves
use tubes. It’s nice
to be consistent,
but we can save
some bench space ■ FIGURE 1. A semiconductor-based adjustable, regulated, high voltage
power supply.
and a few watts
by using semiconductors in such a unit. This example is built
around the LR8N3: a three-terminal high voltage regulator. It
includes 6.3 VAC output for the tube’s filaments and digital
metering. Figure 1 shows the supply.
48 2019/Issue-5
By Bryant Julstrom KCØZNG

The Regulator
Like the familiar LM317, the LR8N3 is an adjustable
positive three-terminal regulator. The big difference is
that the LR8 is a high voltage regulator: Its input can be
as high as 450V. Its output voltage is set by a voltage
divider across its output as with lower voltage regulators;
its maximum output is 12V less than its input.
Its maximum current is 20 mA, so any substantial
supply requires a pass transistor; here, a TIP50. The
LR8 is available in a TO-92 package and typically costs
about sixty cents in small quantities. Figure 2 shows the
regulator circuit.

The Power Supply


The supply is built around a salvaged transformer
■ FIGURE 2. High voltage regulator circuit using the LR8N3
that is typical of power transformers for tube circuits. It three-terminal regulator.
has a center-tapped high voltage secondary — 480V at
55 mA — and two low voltage secondaries: 5V at 2A for
the filament of a rectifier like a 5Y3; and 6.3V at 2A for The meter’s basic circuit measures 0-200 mV, but
other tubes. resistors can be installed to form voltage dividers to
Two diodes form a full-wave rectifier for the high measure other ranges. Here, one meter is set up to indicate
voltage. Their output goes to a choke-input filter, which 0-500V. It reads to the nearest volt; no decimal point is set.
delivers the resulting DC to the adjustable regulator circuit. Current is measured by the voltage drop through a 1Ω
The filter choke was found in my junk box along with the resistor; E = IR, so 0-200 mA through that resistor yields
transformer, whose 6.3V output is available directly. a voltage drop of 0-200 mV. The second meter has no
auxiliary voltage divider, and its third decimal point is set as
XXX.X.
Metering The meters require 9 VDC independent of the circuit
A pair of digital LCD meters report the supply’s output being measured. That voltage is developed by a voltage
voltage and the current drawn from it. Many similar meters doubler from the transformer’s 5V winding. (Relative to
are available; these are Jameco number 108388. the 2A that the 5V winding can supply, the current the

■ FIGURE 3. Circuit of the entire


semiconductor-based power supply.

2019/Issue-5 49
meters draw is inconsequential. This helps keep
the transformer cool.) Two switches control overall
power to the unit and the high voltage output. Each
has an associated indicator. Figure 3 shows the
circuit of the entire power supply.

Implementation
The components in the Parts List may seem a
little vague because almost all of them came from
my parts pile. The transformer was clearly labeled,
but the filter choke was not. I had most of the
small parts and ordered only the meters and the
high voltage regulator. Various substitutions are, of
course, possible.
Most of the supply’s circuitry occupies two
small boards, though the transformer and choke
take up the most space. One board holds the filter
capacitor and the regulator, except for the voltage-
adjustment potentiometer. The second board holds
the 9V supply for the meters. These are mounted on
the back panel of the unit’s enclosure, along with a
line connector and three four-pin Jones sockets for
the supply’s outputs: the adjustable high voltage and
6.3VAC.
The regulator’s pass transistor is mounted — with
■ FIGURE 4.The supply’s back panel, with the two circuit boards an insulator — to the back panel, which acts as a
and connectors. heatsink. Figure 4 shows the back panel with the
two boards and the other parts
mounted.
The front panel holds the two
digital meters, the two switches and
indicators, and the potentiometer
that sets the high voltage. The
space between the two panels
is mostly occupied by the power
transformer and the choke. This
transformer’s wires come out
the bottom, so it’s mounted on
substantial 1/2” standoffs.
A small terminal strip near the
back panel holds the two diodes of
the half-wave rectifier and connects
to the transformer and the choke.
Long standoffs join the front and
back panels to make the enclosure
rigid. Figure 5 shows the inside of
the assembled unit.
Many wires run between
the meters and controls on the

■ FIGURE 5.The interior of the


assembled power supply.
50 2019/Issue-5
■ FIGURE 6.The supply under test
with an adjustable load.

front panel and the boards and


sockets on the back panel. A better
arrangement might have placed the
transformer and choke at the back
of the enclosure, with the circuitry
above or in front of the transformer.
The completed supply’s high
voltage can be varied from about
65V up to about 260V. Figure 6
shows the supply being tested; the
unit on the right is a tube-based
high voltage adjustable load.

Observations
Though this supply can provide
only limited current, it remains
important to attach the pass
transistor to an adequate heatsink.
Suppose the input voltage to the
regulator is 250V, its output is set to 90V, and 50 mA of
current is drawn. The transistor must then dissipate (250 – Parts List
90) x 0.05 = 8.0W.
On the other hand, the 1Ω resistor through which the 1 - 100K, 2W Resistor
output current flows can be small. At 50 mA, the voltage 1 - 100K, 1/4W Resistor
drop through that resistor is only 0.05V, so the power the 1 - 2.2K, 1/4W Resistor
resistor dissipates is just 0.05 x 0.05 = 0.0025W. 1 - 1 ohm, 1/4W Resistor
1 - 500K Linear Potentiometer
Conclusion 1 - 68 µF, 400V Electrolytic Capacitor
As always, variations are possible. A more robust 1 - 20 µF, 400V Electrolytic Capacitor
transformer would allow higher output current. Metering 2 - 22 µF, 50V Electrolytic Capacitors
could use LED or analog meters. The parts could be 1 - 1 µF, 50V Capacitor
arranged differently, perhaps on a single board. In any 5 - 1N4007 Rectifiers
case, a utility supply like this has a small footprint on the 1 - LR8N3 Regulator
bench and supports a wide range of experiments with tube 1 - 78L09 Regulator
circuits. NV 1 - TIP50 NPN Transistor
1 - SPST Toggle Switch
1 - DPST Toggle Switch
2 - 117V Indicators
2 - Digital Meters: 0-200 mV
1 - Power Transformer
1 - Filter Choke
1 - Three-Wire Line Connectors
Post comments on this article and find any associated 3 - Four-pin Jones Connectors
files and/or downloads at www.nutsvolts.com/magazine/ 1 - Knob
issue/2019/05.

Circuit Boards, Hardware, and Connectors.

2019/Issue-5 51
By Robert Reed

A Discussion
on dBs and RF
Power Meters
This article discusses basic theory on the decibel unit and its
role in electrical measurements of power, etc. It also describes
the construction of an RF power meter which in the past has
been difficult to use and expensive to own.

W
hen I first started out in my electronics In the coming years, I grew to love them because they
career, I detested the decibel or anything really boil a lot of math down to simple arithmetic.
connected to it. Like most people, I liked So, what is a decibel? As the prefix implies, it is one
linear relationships and multiples of ten. tenth of a Bel which now begs the question, what is a Bel?
They just seemed to be so much easier to visualize in Alexander Graham Bell (the inventor of the
my mind than logarithmic ratios and terms that I never telephone) did a lot of research work on sound wave
seemed to find a good use for. However, as time went by, intensity as related to the human ear. He determined
decibels were starting to appear everywhere: audio, radio that loudness was perceived in a logarithmic fashion
frequency, and semiconductor datasheets to name a few. rather than a linear one. Through many tests, he set up a
Grudgingly, I forced myself to accept and work with them. standard of units as to the range that the human ear can

52 2019/Issue-5
detect — from barely audible to the threshold of pain. and since I’ll be dealing strictly with RF, it will be assumed
Each unit was a doubling of loudness of the previous that it’s in a 50 ohm environment and dBm will suffice.
unit as the human ear perceived it, yet each unit required For starters, one point must be made perfectly clear:
a tenfold increase of sound wave intensity relative to the dB and dBm are two different terms and each should be
previous unit to achieve that. Starting with a pin drop, all used in its proper place. dB has no value at all and only
the way to the threshold of pain — and if memory serves indicates a mathematical ratio. dBm has an absolute value
me right — there were 13 different levels of these units, and is not a mathematical term per se. The term zero (0)
ranging from barely audible to excruciating painful. dBm may seem strange at first, but this sets the reference
So, 13 units is about 8,000 times louder than the point by which all other values of dBm are referred to:
threshold of hearing as far as the human ear is concerned
(0 to 130 decibels). However, the actual magnitude of
sound wave intensity over this same range is a ratio of
So, what is a decibel? As the
over a trillion to one. The ear adjusts accordingly so that prefix implies, it is one tenth of a
our head doesn’t ‘explode.’ What a remarkable sensor it
is! Bel which now begs the question,
The term Bel wasn’t really established until some what is a Bel?
years later when early Bell Telephone engineers renamed
TUs (Transmission line Units) to the term ‘Bel’ in honor plus dBm (gain) for values above zero and minus dBm
of Alexander Graham Bell. However, Bels were too (loss) for all below zero. Even though it’s stated as “0,”
large and cumbersome to work with when applying it to it does have an absolute value of one milliwatt into a 50
“new technology” and they needed greater resolution of ohm impedance, 0.224 volts RMS or 632 mV P-P.
measurement. There are two common formulas for the conversion
Soon the term deciBel (dB) became the preferred of linear ratios to dB: [10x log of (power level 1/power
function to work with and almost completely erased the level 2)] or [20x log of (voltage level 1/voltage level 2)].
term Bel from specs and math. However, the term Bel still Remember that these are ratios only and do not hold any
has validity, and if you want to drop some jaws, the next absolute power quantity.
time you are discussing a particular amplifier’s gain with The two formulas given are valid for any load
your cohorts, instead of saying it has a gain of 30 deciBels, impedance, as long as the impedance is the same for both
tell them it has a gain of 3 Bels. A perfectly valid (although levels. They are also somewhat interchangeable as by
unpopular) term. Then walk away and see who figures it simple Ohm’s Law. If you know the power ratio, then the
out first! voltage ratio is the square root of that ratio. If you know
Even though the decibel emanated from Ma Bell, it the voltage ratio, the power ratio is the square of that ratio
was not long before it spread like wildfire in the scientific (i.e., doubling the voltage quadruples the power).
community. These days, it’s used everywhere and Even though I use dBs a lot, I only use the math when
with dozens of suffixes to denote particular values and determining power gain across level 1 and level 2 where
references; to name a few: dBm, dBW, dBV, dBc, and the each has a different impedance. What I do use religiously
list goes on. For this article, we’ll are decibel charts.
only concentrate on dBm, but even Voltage Ratio Decibel Power Ratio I like the ones that show 0.1
that needs some clarifying. decibel ratios up to 10 decibels,
The term 0 dBm actually has 1.0 0 1.0 and then unit ratios up to 20
a valid power level and denotes decibels in 10 db steps beyond that.
a reference power level of one 1.12X 1 1.25X Nowadays, most of the time, I see a
milliwatt dissipated in a given close ballpark figure at first glance
load; strictly speaking, it should be 1.4X 3 2X — whether dbs or dBms. A quick
followed with a load impedance check of the chart (if necessary)
value. The most popular are dBm- 2X 6 4X is all that is needed to get a figure
50, dBm-75, and dBm-600, which within 0.1 dB.
refer to RF, cable, and audio in that 3.16X 10 10X I won’t dwell on the math
order. The RMS voltages at these beyond what I have shown due to
power levels are approximately 10X 20 100X the wealth of information on the
0.224V, 0.274V, and 0.775V, Internet of this subject, so you can
respectively. 31.6X 30 1000X take it as far as you would like to
Again, all dBm levels start at go. A very good source for this is a
zero which is the reference point of 100X 40 10000X Rhode & Schwarz write-up, “dB or
one milliwatt. I’ll be working with not dB?” which is available in the
dBm-50 for the rest of this article, Table 1. Key numbers to remember. article downloads.

2019/Issue-5 53
To gain a quick rundown on this subject and a little with a 3 dB loss. A signal level of 13 dBm is coupled into
appreciation for it, take a look at Table 1 and try to the first amplifier. What is the power level in milliwatts at
memorize it. This will become intuitive the more you work the end of the terminated line?
with it. For this example, we’ll first take the longer linear way
to get the answer (going point to point): 16 dB
Alexander Graham Bell (the inventor amp gain = 40x; 19 dB (x80) attenuator and cable
loss (which we can invert and show as gain) =
of the telephone) did a lot of research 0.0125x; 16 dB amp gain = 40x and 3dB (x2) line
work on sound wave intensity as loss (again, invert and show as gain) = 0.5x.
So, 40 x 0.0125 x 40 x 0.5 = 10. Then, 10 x
related to the human ear. 20 mW (which is the 13 dBm input signal) = 200
milliwatts = answer. Again, notice I entered the
Note that the ratios in Table 1 are only a close losses as gains here, so I didn’t have to deal with negative
approximation and are showing gain. To show loss, just signs.
add minus signs in front of them. Also, you can see more Now, for the simpler way: 16 dB - 19 dB + 16 dB - 3
clearly the square/square root relationship between dB = 10 dB — which is a 10x increase of the 13 dBm input
voltage and power for any given decibel ratio. signal = +23 dBm = 200 milliwatt = answer!
After using dBs and dBms for a while, these figures This last method was done in my head in no time flat
will become quite intuitive also. One nice feature of dBs as per Table 1.
is that power multiplication and division is done just by If you’re wondering how I determined the 13 dBm
simple addition or subtraction of two figures. Also, they input signal was 20 mW, then just refer to Table 1 and
reduce linear values of long strings of numbers that can break down 13 dBm into two parts: 10 dB (10x) and 3 dB
be either side of a decimal point, down to a simple three (2x) =20x; 20 x 0 dBm (1 mW) = 20 mW.
or four digits. All the preceding was not meant to be a course on
Most of the time, the term dB is used to spec out the decibel, but rather an introduction of the basics so
parameters such as gain, loss, etc.; dBm, on the other you can better understand the workings and construction
hand, is used mostly for results as to absolute power of RF power meters, which the remainder of this article
levels. Let me give a few examples that may make their will now discuss.
use a little clearer:

(1) A cascaded string of three amplifiers has individual


Background and
power gains of 13 dB, 16 dB, and 27 dB. What is the Construction
overall power gain? Answer: 13 +16 + 27 = 56 dB total
gain. If we use the basic chart in Table 1, we can break 56 I think that most RF engineers would agree that
down to 40, 10, and 6 dB increments, then linearize it: 40 accurate measurement of RF power levels is one of the
dB = 10000x; 10 dB = 10x; and 6 dB = 4x. more difficult measurements to achieve, and they’ll get no
Remember that these stage gains are being multiplied, argument here.
so we just add the dB values and multiply the linear I have used several commercial power meters over
equivalents: 10000 x 10 x 4 = 400,000 for the power gain. the years, depending on the company I worked for at the
Since the voltage gain for these same ratios is always the time. Most of these were HP, which seemed to have a
square root of the power gain, it’s 632.5. If you were only corner on the market due to years of R&D in that field.
interested in voltage gain, you could use just the voltage They were quite reliable and required a special probe
ratios from Table 1. head that measured power by the RMS heating effect
Once you’ve worked with these terms for a while, it’s produced from the detected signal of measurement.
so much quicker and easier to work in dBs and get close Because they measured by the heating method,
approximation answers about as quickly as you can read they were oblivious to wave shape and duty cycle. (This
them. method is far superior to any other type of detection.)
They had an internal calibrator, and some used a small
(2) A string of attenuators that total 19 dB of loss is look-up table for probe zeroing before each session of
inserted between two amplifiers with gains of 16 dB each, testing.
and then drives a 50 ohm terminated transmission line In order to rely on their accuracy, they did require

54 2019/Issue-5
dBs and RF Power Meters
a yearly calibration check from a certified metrology lab converts to an RMS value, and finally outputs that in a log
if measurement records were required for government fashion.
documentation. However, they seldom went very far from Its only shortcoming is that it assumes the RF is a
their original specs other than units that had been abused. reasonable facsimile of a sine wave. However, many
These were extremely accurate units with very detectors work on that principle and invariably this is what
high price tags and, in general, had a 40 dB range of you’ll be working with 99% of the time.
measurement; usually -20 dBm to +20 dBm. I had always The AD8307 has a working range somewhat beyond
drooled over the thought of owning one myself, but their 500 MHz. Its low-end response is only limited by the size
price was way out of my range of affordability. of the input coupling capacitor (AD claims it will work
There were so many occasions of needing to down into low audio frequencies), but can easily handle
measure designed low power RF transmitters, amplifiers, 100 kHz with an 0.22 µF cap input coupling capacitor.
attenuators, filter response, or even my own test I bought a few of these from different distributors to
equipment that would have made life so much easier and characterize before I delved too far into the design stage.
put my doubts at ease. The RF input impedance is approximately 1,100Ωs
As the years went by and with tongue in cheek, I according to AD’s datasheet and this turns out to be
finally decided to look into DIYing my own. A long search an important parameter as will be explained shortly. A
on the Internet turned up a wealth of knowledge on the word of caution here: The 50Ω input load resistor is DC
subject of RF power measurement and several designs coupled to the signal source, so keep this in mind when
from some of the ARRL boys (ham radio) with names I using it.
had seen before and totally respected. I played around The reason for this is that it would require a very large
with several designs and then some of my own before I input coupling capacitor at the lower RF frequencies for
laid down one with what I felt had the optimum features proper operation and would show some deterioration of
(at least for my objectives). matching at the higher frequencies.
Most designs and application notes were based on a The output resistance is spec’d at 12.5K Ω and is not
line of RF detectors produced by Analog Devices (AD): of too much concern in the final design. The datasheet
a chip manufacturer with a lot of experience in this field. listed the frequency response as a slow but steady roll-off
I started by analyzing the datasheets for the nine or so from 50 MHz, down -3 dB at 500 MHz. The chip’s output
chips they produced for RF detection and narrowed is about 25 millivolts DC for every one dBm of input. The
my search down to two: AD8307 and AD5513. These supply voltage can be as low as 2.7 VDC to a high of 5
seemed to be the best suited for general RF power VDC, but best performance is at 5 VDC.
detection and appeared to be an easy IC to work with. Okay. We’ve got enough “vitals” info to get started.
Each of these has advantages over the other as to After reviewing several published designs, it was
frequency response (output accuracy vs. frequency) and evident that the frequency response definitely needed
dynamic range (widest range of signal level detection). some correction to flatten it out. If one’s only interests
I’ll focus on construction of the AD8307 version (the were from the low end to 50 or 60 MHz, then no
construction of the AD5513 variant is almost identical) correction is needed as the output level is almost perfectly
and follow up with the merits of each. These chips are flat in this range. If you desire a much wider bandwidth,
intended for operating strictly in a 50Ω environment and then compensation is in order.
act as the load for any given
source. This is also true for
any commercial power meter
The term Bel wasn’t really established until some
I am aware of. years later when early Bell Telephone engineers
To begin with, as noted,
the AD8307 is an easy chip to
renamed TUs (Transmission line Units) to the term
work with and available in a ‘Bel’ in honor of Alexander Graham Bell.
DIP-8 package if so preferred.
It basically accepts an RF input and sends it through a A lot of the designs I saw used some sort of
series of log detection amps, then on to a DC output frequency adjustment in the form of a compensated
level that relates to the RF input power level. It performs attenuator right at the input to the chip, which apparently
this quite accurately and in a very stable and repeatable worked okay for the original builders. The datasheets
manner. It basically reads the peak voltage of the input, mentioned a roll-off of -3 dB at the high frequency end of

2019/Issue-5 55
dBs and RF Power Meters
will influence the attenuator component values.
No “one size fits all” here.
The biggest drawback to using an attenuator
style compensator contradicts the very reason
I chose this chip in the first place, and that is its
superior dynamic range: +15 dBm to -75 dBm.
This is an incredible range and I did not want
to sacrifice 10 dBm on the low end due to the
attenuator.
There’s another method I’ve used in the past
for frequency compensation and that is adding
inductive reactance in series to the input matching
load resistor (about 50 ohms). This will increase
the input impedance with increasing frequency
and boost the sagging end with very little effect to
the other end.
The downside of this method is an increasing
VSWR and reflected energy with increasing input
Figure 1.
frequency due to load mismatch. Depending on
the value of XL, measurements will start showing
its range. However, a careful inspection of an output vs. an increasing error at some point, so I had to choose the
frequency graph showed about a -7 dB loss at the high value of XL carefully and somewhat subjectively.
end. Hmm ... time to make up a preliminary prototype The first chore was some math for input load
and look into this. vs. output amplitude for different scenarios to get a
This initial board was made up using good layout and reasonable ballpark value, and then home in on that by
RF construction practices to obtain valid results. My tests trial and error. The optimum value came up as 45 nH and
of output vs. frequency showed results very close to the the results are shown in Figure 1. The black line is the
graphical representation: about 1 dB down at 100 MHz; 3 response without compensation and the red one is with
dB down at 300 MHz; and 6.8 dB down at 500 MHz. This compensation.
held true with several AD8307s that I checked. As you can see, the response is quite accurate up to
There are only two ways that I know of to flatten out a about 330 MHz at ± 0.5 dB, and then starts to get more
response curve such as this. One way is to lower the high erratic as it enters the UHF region (with errors up to 0-2
response end to match the low response end (attenuate); dB). This is pretty much what I expected for this method
the other is the exact opposite of raising the low response of compensation. Actually, a 2 dB error is not all that bad
end to match the high response end (boost). for general use power detection.
What I tried to do here is optimize the VHF band at
Even though the decibel emanated the expense of the UHF band; reason being is that I am
most comfortable and do most of my work in that range.
from Ma Bell, it was not long before As for UHF, I occasionally do some work in the ISM and
it spread like wildfire in the scientific FRS radio services, and the aforementioned trade-off has
caused me no major problems.
community. The compensated attenuator method of
compensation would probably have given me a more
The high and low ends are in terms of output uniform roll-off, but much poorer overall response across
amplitude vs. RF input frequency. With my experience these spectrums. Plus, it would still cause some amount of
using compensated attenuators, to flatten out a 7 dB reflected energy at various points. Unfortunately, optimum
difference would likely need a 10 dB Pi-pad attenuator to designs are usually a series of trade-offs.
properly do the job. Since the temperature adjust and offset pins (pin 3,
One other problem here is the pad has to be inserted pin 5) are of little consequence in this application, they
just prior to the chip’s input pin. As I had mentioned, the can just be left floating. That only leaves the output pin
chips stated input impedance can vary somewhat, and this (pin 4) to deal with. As mentioned, this outputs 25 mV

56 2019/Issue-5
per dBm of input. This will have to be scaled to match The pins internal circuitry uses a constant current
whatever read-out is used. In this case, it will be a digital source of 2 µA per dBm of RF input to output a DC level
voltmeter. here. The nice feature of a CC source is you can easily
To save some money, you could use a standard DMM choose the values of P1, R2 for any desired DC level
by bringing these metering points out to a pair of pin at that point. And again, it will be set for 100 mV/dBm
jacks on the rear of the case to accept the DMM probes. decade.
One objective I wanted to accomplish was to keep
the circuit as simple as possible and without any
additional active components aimed at keeping the
The term 0 dBm actually has a valid
current requirements very low to prolong battery power level and denotes a reference
life. Other than a five volt regulator, it only needs
two multi-turn trim pots and a few resistors. In this
power level of one milliwatt dissipated
configuration, it only requires about 10 mA for in a given load.
operation.
At this point, we’ll take a quick run-through of the C5 is chosen for ripple reduction of the detected DC
circuit as shown in Figure 2. The RF test signal enters output. I chose 1,000 pF as it adequately tamed the ripple
SMA connector J1 which is terminated by the series yet still maintained a short enough time constant for good
arrangement of R1, L1. From there, it is coupled via C1 to fidelity of sweep testing amplifiers and filters with very
IC1 pin 8 (RF Input Hi). Pin 1 (RF input Lo) is decoupled steep roll-offs. The offset circuitry P2, R3, R4 completes
to ground via C2. The +5 VDC supply feeds P6, P7 and the circuitry and is there for only one purpose: to trick the
is decoupled via C3, C4. The detector DC output (pin 4) meter into reading the digits we want to see and not the
drives the positive terminal of the digital voltmeter. During actual detector output DC. (More on this in the calibration
the calibration procedure, this will be adjusted for 100 mV procedure.)
per decade of dBm input. The only other thing to mention here is the use of

Figure 2.

2019/Issue-5 57
were a nuisance — especially
when increasing the vertical
sensitivity. I lived with that
design for a while and then
decided to ditch it.
The new version with an
extra dedicated meter battery
really does not hog up much
real estate and with the meter
only drawing 1 mA, it should
last “forever.” Also, I use 50
cent batteries from a local
dollar store for the meter, so
Figure 3. the extra cost is of not much
consideration.
two 9V batteries. My first designs used a single battery for One last word here. If desired, points “A-B” and “C-D”
both the circuit and meter. This required that the meter can be opened and an LM358 optional buffer inserted in
power and inputs share a common ground and measure those spaces. This makes sending the detector’s output
all voltages relative to that point. Due to the meter to the outside world (such as a scope, etc.) a lot easier
“tricking,” the circuitry would now require some op-amps and offers a slight improvement in accuracy and ease of
and also a split supply to accomplish that. calibration. This will only add 1 mA of extra battery load
The negative voltage needed was done quite simply current so as to be insignificant. I decided that this was
with a 7660 inverter chip, and it was very efficient in its the best route to take.
operation. However, this chip really made a racket and Construction of the circuit board is very simple. The
caused switching spikes everywhere that I could not beauty of it is that only the first inch of it deals with radio
totally eliminate. Even though they were present at the frequency. However, I would recommend a ground plane
meter’s input, they were too fast to cause anything but using a single-sided board for the complete circuit. I cut a
minimal errors that most of the time went unnoticed. 1” x 2-1/4” board for this which was mounted to the box
When using the optional scope output jack, however, they with two 3/8” long metal standoffs to the end opposite
the SMA connector.
The circuit components
Figure 4. are a combination of
surface-mount and thru hole
construction. All thru hole
components were mounted
on the glass side of the board
and SMD devices were used
only for the RF input section
as shown in Figure 3 and
Figure 4. Keep traces short
and components close in this
section.
The SMA connector
should be as close as possible
to the 8307 chip. The SMA
to chip input trace shown
in Figure 3 was longer than
necessary to accommodate
any changes that I may have
wanted to make here. No
changes were needed, and

58 2019/Issue-5
dBs and RF Power Meters
that trace could have been shorter. The coil L1 is a length
of 2-3/8” #26 wire and loosely wound in a few turns
to better fit in its designated space. If you use a more Figure 5.
common 24-gauge wire, allow a little extra length of a
1/4” or so. The winding pitch and coil dimensions are not
critical here, but the key word is “loose.”
You may notice a bracket shoved up tight to the
SMA base. This was to offer support on that end of the
board because the only circuit board standoffs used are
at the opposite end of the board. This can be cut from
a dielectric material (I used wood) approximately 1/8”
thick and cut to length so as to tightly capture the SMA
in place when the cover(s) are installed, keeping the SMA
very ridged so it can stand up to many cable connections/
disconnections.
As shown in Figure 5, the back panel entry hole was
cut larger than needed to allow more positive clearance
for the SMA connector and to give ohmic clearance to the
cable connector shell to chassis ground to better simulate All the assemblies fit snugly in an extruded aluminum
a full 50Ω environment right from the DUT (Device Under housing with removable covers, and it measures
Test) to the board’s launching point. approximately 4” L x 3” W x 1-1/2” H. It was purchased
A DPDT power switch and scope out phono jack
complete the hardware used here. Four leads were
brought off the board to a small four-pin connector which
then branch out to the battery (two) and the meter (two).
The batteries were installed in vertical snap clips.
Now for a word about meter requirements. The digital
readout should have the following requirements:

• 200.0 mV max sensitivity range


• 10 megohms of input impedance
• Ability to display a two-volt range
• Selectable decimal point location
• Leading zero suppression
• Independent operation from nine volt battery
• Very low current draw; usually requires LCD
readout
• Polarity sign (does not need to show positive
polarity)

That last requirement is very important as some


readings would be ambiguous without it. Example: A
meter reading displays 10 but what is it? +10 dBM or -10
dBm? No way to tell without a polarity sign!
Although there are many meters available, the
meter I used was a CX101A which fulfills all the above
requirements. Plus, I’ve used these in the past with very
good results. The meter snaps into a close tolerance panel
cut-out. Again, I used a miniature four-pin connector to its
flying leads. These also branched out to its own battery
(two) and the circuit board connector (two).

2019/Issue-5 59
dBs and RF Power Meters

Figure 6.

on eBay (they’ve been quite plentiful for a while now). As This chip is a current hog and the circuit draws 35
I said, it’s a snug fit which requires some fairly accurate mA. With that in mind, I added an external power jack
machining. So, if you’re not quite up to speed on these for times when it sees extended bench use. You’ll want
skills, you may want your housing to be a bit larger. a bigger board for the AD5513 model or if you add the
As mentioned previously, construction of the AD5513 optional buffers on the AD8307 model, and, of course,
version is almost identical to the AD8307 model. Figure the housing that they fit in.
6 shows its schematic. The major difference here is that Either of these chips cost about $11-$12 and are
L1 is not needed and this chip is only available in an SMD available through Mouser and Digi-Key, but they do
style which is a small 16-pin PLCC package. Although it appear on China eBay in an evaluation board style
averaging $15 for the AD8307 and $27 for the
One point must be made perfectly AD5513.
The trim pots are 25-turn, but 10-turn would
clear: dB and dBm are two different be acceptable. All capacitors (except the few
terms and each should be used in its 10 MFD ‘lytics ) are MLC ceramics/50V and all
resistors are 1% metal film. Since the calibration
proper place. resistors are in a string with trimmer pots, you can
get by with 1% resistors that are close in value
has 16 pins, it only needs eight islands as the pins marked to the ones shown on the print or even 5% carbon film
‘NC’ can be either soldered to the ground plane or left of the nearest values. However, R1 should be kept at
floating. 1% metal film and at least a 0.25 watt rating (or better

60 2019/Issue-5
yet, 0.5 watt). The metal film versions have superior RF calibrating these meters is an HP RF generator from the
performance as compared to carbon film. The op-amp ‘80s. Most of the generators from that era had incredibly
chips can be socket installed if used, but the AD8307 accurate attenuators and superior flatness across their
and/or AD5513 should be soldered directly to the board range. In all the years of checking and cross-checking
for the best RF performance. across its range against new product specs and other
quality test equipment, it has always proved trustworthy.
Calibration and Use Other owners of that gear have also echoed my
sentiments, saying that it was about as accurate as one
Once the circuit board is completed, give it a close could read the meter.
inspection before applying power to it. The AD chips are With that said, I used an output range of +20 dBm
fairly expensive, so you want to be doubly sure about to -80 dBm at a frequency of 10 MHz for calibration in
power connections and polarity. After power-up,
connect a DMM from the positive terminal of the
internal voltmeter to ground. Inject an RF signal of 0
dB has no value at all and only
dBm into the SMA input. (I’ll discuss the signal issue indicates a mathematical ratio. dBm
in a while, but for now, I’ll just continue with the
calibration.)
has an absolute value and is not a
For starters, set the CALIBRATION pot for a mathematical term per se.
DMM reading of approximately 900 mV DC. Next,
you’ll need a way to attenuate the input signal in 10 dB regards to dynamic range and an output of 0 dBm for
steps of at least four steps (more steps are better). You’ll checking wide band frequency response. I also made up
need to adjust the pot for very close to 100 mV of change a ‘standard’ test cable using quality RG-58 cable and with
for every step of attenuation. This will involve some quality type N to BNC connectors. It’s 36” long and easily
back and forth adjustments but try to get as close to the reaches between any gear on the bench or from bench to
100 mV steps through all the attenuated levels you are cart.
measuring. This eliminates at least one variable for future tests
Again, four steps down to -40 dBm is adequate but and calibration checks.
if you have the means to go further, then do so. You Again, and before I get into possible signal sources,
should end up with no more error than 1 or 2 mV per I would like to categorize power meter accuracy vs.
step of the target value. Don’t worry about where the 0 performance level. This is the order in which I would rate
dB value ends up; only that it tracks the other steps. It will them:
probably end up somewhere in the 880 to 920 mV range
(referenced to ground); not important. • ± 3 dB: JUST BARELY ADEQUATE for non-critical
When you’re satisfied with your results and with the testing. These specs are still used in equipment
input signal set at 0 dBm, adjust the OFFSET pot so that such as oscilloscope bandwidth, various
the internal meter reads exactly zero. This completes the amplifiers, etc.
calibration procedure and depending on the AD chip • ± 1 dB: GOOD. Accurate enough for a majority
used, it should be quite accurate all the way to the bottom of testing.
of its linear range (deeper than -70 dBm for the AD8307 • ± 0.5 dB: VERY GOOD. Adequate for almost any
and -55 dBm for the AD5513). testing.
When measuring signal levels below that, at first the • ± 0.1 dB: EXCELLENT. Adequate for any testing
reading will begin to deteriorate a little and then more and more confidence in the results.
rapidly as it approaches the noise floor. You can expect • << ± 0.1 dB: COMMERCIAL LAB TESTING. Well
about 5 dB lower than the linear portion just before it hits beyond what most would ever need.
the noise floor. The noise floor is the reading you get with
no signal inputted and the meter is just reading its own For the two meters I’ve described in this article, I
internally generated noise at that point. Any input signal would rate the AD8307 meter in the good range and the
below this level will hardly even register on the meter. AD 5513 meter in the good to excellent range. With lab
Now some words about accuracy and test signals. quality meters that are at and beyond the excellent range,
Any piece of test equipment can only be as accurate there is one caveat: maintaining a near perfect match
as the standard it is calibrated to. My “standard” for between the source and the load (which is the meter

2019/Issue-5 61
PARTS LIST FOR AD5513 MODEL PARTS LIST FOR AD8307 MODEL Now back to signal sources
used for calibration. Obviously,
R1 52.3Ω 1/4W or 1/2W (preferred) R1 52.3Ω 1/4W or 1/2W (preferred)
you want to use the best signal
R2 56.0K Ω 1/4W R2 7.15K Ω 1/4W source you own, or can “beg,
R3 32.4K Ω 1/4W R3 7.5K Ω 1/4W borrow, or steal” for this task.
R4 7.68K Ω 1/4W R4 1.21K Ω 1/4W This can end up being anything
from a top-of-the-line RF signal
R5 1.21K Ω 1/4W
generator down to a low
C1, C2, C8 0.22 MFD 50V MLC C1,C2 0.22 / 50V MLC grade function generator. The
C3, C5, C6 0.001 MFD 50V MLC C3,C5 0.001 / 50V MLC higher quality the source, the
C7 1000 MFD 16V Electrolytic C4,C7 0.1 / 50V MLC easier the calibration will be
(such as a flat signal amplitude
C4, C10 0.1 MFD 50V MLC C6,C8 10 MFD / 16V electrolytic
output and a quality built-in
C9, C11 10 MFD 16V Electrolytic attenuator). There is one saving
L 45 nH (see text) grace here and that is you can
P1 10K Ω 10T or 25T use a test signal as low as 1
MHz since it’s well within the
P2 1K Ω 10T or 25T P1,P2 2K Ω 10T or 25T
pass band of either of the two
IC RF Detector AD5513 IC RF Detector AD8307 meters. At these frequencies,
IC Buffers LM358 IC Optional LM358 almost any “service grade”
Buffer function generator and scope
IC Regulator 78L05 IC Regulator 78L05 will work okay.
No matter what you use,
Schottky BAT25 DVM CX101B
diodes the sine wave input levels you’ll
be concerned with are: 0 dBm
DVM CX101B
/632 mV P-P; -10 dBm /200
NOTE: All resistors are 1% tolerance. Except for RI, they do not need to be the exact value. mV P-P; -20 dBm /63 mV P-P;
Values within 5% are acceptable. -30 dBm /20 mV P-P; and -40
dBm /6.3 mV P-P. The negative
in this case). The setup requires high quality cable and 30 and 40 dBm levels are rather low, but the scope can
connectors for starters, and in a lot of situations, special use an X1 probe to measure all of these levels — even
test jigs which require more and more construction right at the meter’s input connector.
precision as the frequency enters the lower UHF band At 1 MHz, mismatching and probe capacitance will
and upwards. not be much of a problem. You can adjust the different
To make use of these instrument’s very high accuracy, levels as you go through the calibration procedure (which
all setup errors must be eliminated. Not an easy task tends to get annoying) or you can build up a 50Ω Pi
if you’re attempting to measure a low level signal of 2 attenuator network on a solderless breadboard with
stub-outs for each level point. An
Most of the time, the term dB is used to spec upgrade to this would be to tack in
a rotary switch in place of the stub-
out parameters such as gain, loss, etc.; dBm, on outs.
the other hand, is used mostly for results as to One last thing to mention
here: While perusing all the AD
absolute power levels. datasheets early in my research,
there was a detailed explanation in
GHz at 0.03 dB resolution. Without a lot of care in these one of them that pertained to how these RF log detectors
regards, one will have lost a lot of accuracy and paid a lot work. Most of it was a lot of high-tech theory, but what
of money for readings that are far from highly accurate. really caught my eye was the part that mentioned their
Fortunately, for the average user that the meters presented response to square waves.
here are intended for, we don’t have to go to those It was shown that a square wave of exactly half of the
extremes — especially at the lower frequencies. peak-peak value of a sine wave would give the same DC

62 2019/Issue-5
dBs and RF Power Meters
voltage output from these chips. Doing a little math on reading.
this, I actually came up with levels that were -3 dB lower With that kept in mind, these meters work well
for the square wave vs. sine wave. I was a little skeptical using square waves and they can also be used for
that this would work, so I fired up my function generator calibrating. My function generator has a 50Ω output
and set it up for a 1 MHz sine wave 0 dBm output (632 impedance, 10:1 variable attenuator, and two switched
mV P-P) which read 0.0 dBm on the RF power meter. 20 dB attenuators. Surprisingly, the two switched
Next, I switched to a square wave of exactly half attenuators gave very accurate results. I tried to go
of that amplitude (316 mV
P-P) and was pleasantly
surprised to see a 0.0 dBm
I think that most RF engineers would agree that
readout on the meter. accurate measurement of RF power levels is one
Apparently, the way
these chips analyze the of the more difficult measurements to achieve, and
input waveform has to they’ll get no argument here.
do with peak values and
cresting factors that give those results on square waves deeper than that with an external wide band attenuator,
(remember, I had previously mentioned that these but results I got below -40 dB were losing accuracy. I’m
chips rely on a reasonable facsimile of a sine wave for not sure why. I think with a little development work, this
accurate measurements). I still had faith in my math and problem could be remedied, and a descent calibrator
am sure that a high-priced power meter using thermal could be built up, but I did not pursue it any farther.
sensing rather than voltage would give the lower The two chips used in this article are quite amazing

PicoScope
2000 Series
Oscilloscopes
Benchtop performance and
power that fits in your pocket.

2-CHANNEL, 4-CHANNEL AND MSO MODELS

DARD From
DECODE 20 SERIAL PROTOCOLS AS STANDARD
$115
ER MEMORY
UP TO 128 MS BUFF
WIDTH
MHz BAND
UP TO 100 ND POW
ERED
T ED A
NNEC
USB CO
For more information visit www.picotech.com/A393
Email: sales@picotech.com. Errors and omissions excepted. Please contact Pico Technology for the latest prices before ordering
dBs and RF Power Meters
in their performance. They’re very stable and repeatable,
and will rival accuracies of commercial power meters in Conclusion
your lab that you could only dream of owning several
years ago. A few last words to close out this article. Due to
Of the two meters shown here, the big question the excess length of magazine space this subject would
is which one to build. The AD8307 has a tremendous require and in order to discuss additional ancillary
dynamic range of about 85 dBm, while the AD5513 has circuits, etc., I have info packets available by email. This
superior accuracy and excellent performance over a wide would cover some auxiliary circuits such as calibrators,
band of frequencies. My limit for testing the latter one was scope interfaces, etc., including an interface circuit that
520 MHz, but the datasheets show good performance is especially useful for setting up the scopes vertical
beyond 3.5 GHz. Since I couldn’t pick one over the other, attenuator to match any dB value per graticule you would
I ended up building both of them. desire. Thus, sweep testing would give perfect sweep
One last item to mention here is the small golden displays of flatness and roll-offs in calibrated dBs.
object shown in Figure 5. This is a 20 dB attenuator And, as I have done in past articles, if you have any
which can be inserted between the meter and test cable. questions or need additional information, you can email
I bought this on eBay for $7. This adds 20 dB more to me at rjr@ncweb.com. NV
the high-end range of measurement to these meters; the
AD8307 model now has a dynamic range of 105 dBm, Post comments on this article and find any associated
which is a power range of >2 watts (~ 10V RMS) down to files and/or downloads at www.nutsvolts.com/
< 0.1 nano watt (~70 uV RMS). Pretty impressive! magazine/issue/2019/05.

www.embeddedARM.com
TS-7180
Single Board Computer

696 MHz i.MX6 UltraLite CPU


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

Board Support Packages,


Source Code and Toolchains
Available

64 2019/Issue-5
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.
LEDs for
Operational
Status and
Troubleshooting
By Klaus Spies

T
his is solved, in part, by a light that turns on with it doesn’t mean your downstream circuit is getting power.
an on-off switch. For simple circuits, that might Anything from faulty connectors, cold solder connections,
be enough — especially when considered from a break in the wiring, and the on/off switch can be the
a manufacturing standpoint. A manufacturer guilty culprit. (That’s why I’ll install a power-on LED to the
needs to keep costs as low as possible, which main power traces on the circuit board itself instead of at
means keeping the parts count low. So, you don’t often the power switch.)
find things like extra LEDs that show what’s happening The next step is to make sure we’re getting any
when dealing with a circuit you’ve bought. external signals that our circuit needs to do its thing. Is
Unfortunately, for more complex circuitry, the single the incoming signal positive or negative logic? Depending
power-on indicator (Figure 1) on whether or not the input signal can handle the drive
is not going to be enough to Figure 1. current (typically 20 mA drive current required by LEDs),
indicate what’s happening. a driver is needed. Schematic 1A shows the wiring for
While this might not be an issue positive logic. A logic “1” will cause the LED to light, while
with a project that works (as Schematic 1B shows requirements for negative logic by
long as it keeps working), circuits using Q1 as an inverter while Q2 drives the LED.
that need troubleshooting will need to provide more The same technique may be required downstream,
information. Let’s take a closer look at how and where to depending on where we tap a signal from. For example,
add LEDs that can provide the help that we need. the 555 timer — capable of 150 mA of source or sink
Even a simple “power on” LED can be misleading. For current — can drive the LED and current-limiting resistor
example, if your power supply’s power-on indicator is lit, directly. Refer again to Schematics 1A and 1B.
66 2019/Issue-5
Even when a circuit functions as it’s supposed to, it’s not always easy to
tell what it’s doing. Plus, waiting for an output (especially if there’s a long
delay involved) is not always practical. Conversely, if a circuit does not
function, the only means to find out what’s wrong is to troubleshoot it
with either a multimeter or oscilloscope. Wouldn’t it be great if the circuit
itself could tell us more directly what’s wrong?

Schematic 1A.
Schematic 1B.

will provide an overview of operation.


The same technique can be applied to other points When a single indicator is not enough — like when
in a circuit; for example, a clock circuit used for timing. A there are a lot of individual LEDs, we need to check if
blinking LED will show that other oscillators are working, a counter is operating correctly, or if we need to count
while a solid on or solid off LED will show that the timer is events (like how often a circuit performs a given operation)
either not working or held in “RESET” mode (see Notes). — we need to upgrade to the next level by providing a
Schematics 1A and 1B can be added at any point in a numerical display of what’s going on.
project where we want to check for a signal. If we look at multiple LEDs indicating several different
To avoid confusion, using different colored LEDs and actions taking place in our circuit, these multiple signals
labelling them on the front of the box housing the circuit can be seen as a binary word. For example, if the circuit is
2019/Issue-5 67
Post comments on this article and find
any associated files and/or downloads
at www.nutsvolts.com/magazine/
issue/2019/05.

on and in standby mode, the inputs of single LEDs


Schematic 2. are lit in such a way that they represent either a
binary “1;” for actual operation, a binary “2;” invalid
(or no) input, a binary “3;”a non-functional digital
timer, a binary “4;” and so on.
When these signals are fed into U1 (a 14511
seven-segment latch/decoder/driver) of Schematic 2,
the seven-segment display will show the appropriate
number. This is much easier than having to glance
over a multitude of separate LEDs! This method
can also be used to indicate the position of a rotary
switch. One example of this application is adding
a digital channel display to an older CB radio that’s
been converted to 10M or 12M.
To develop this idea further, to where
our LED circuit does the actual counting,
a 14516 (binary up/down counter) can
be added (Schematic 3). Depending on
how it’s wired, this IC can count either up
Figure 2. or down. It also has the capability to be
preset to a particular number if needed.
This application is great for counting
events, and is of particular use when the
events happen faster than the human
eye can see (like the rapid scanning of a
circuit), or if we’re counting events that
we don’t have the patience to sit and
watch.
Figure 3.
Schematics 2 and 3 have intentionally
been kept simple as to keep them “de-
cluttered,” to more easily demonstrate
the techniques of using seven-segment
displays in our projects. These schematics

Schematic 3.

68 2019/Issue-5
Figure 4.

Notes for Figures 1-4 and Schematics 1A and 1B: Photo 1.


1. Figure 1 shows the basic nomenclature of an LED,
regardless if it’s a single unit or part of a multi-LED
display. In a single LED round package, the anode has the
longer of the two leads and is always the more positive of
the two leads.
2. Multi-segment displays (seven-segment is the most
commonly used) are typically designated as either
“common cathode” or “common anode” (see Figures 2 can be developed further quite easily for multiple seven-
and 3). segment displays in order to count to higher numbers.
Seven-segment displays have an additional benefit in
3. Figure 4 shows the seven-segment display LED the form of a decimal point. This is typically not needed in
assignments (letter corresponds to the LEDs shown the applications discussed here, and therefore not used. In
this application, they can be used to indicate when a clock
in Figures 2 and 3). Package size varies depending is operating.
on the physical size of the LED (10-18 per package
size); Jameco P/N 17209 (MCD Electronics P/N GNS- LED Options & Considerations
5011ABx-11 [0.50” single digit display] used here for an Do we mount LEDs directly on the circuit board or
example). on the front panel of our project box? If all you want is to
use LEDs for initial troubleshooting (or troubleshooting
4. Current-limiting/voltage drop resistor required for all later when something goes wrong), then the first option is
LEDs; omitted here for clarity. probably the best route to go. On the other hand, if you’d
rather have easy access to operational status — at least the
key points — then the second choice is probably the path
Notes for Schematics 2 and 3: that makes the most sense.
There’s also the practical side of things to consider.
1. Seven-segment displays may not fit into standard IC If there are a lot of inputs, outputs, and decisions made
sockets, depending on size (width, not just length). by your circuit, then having everything displayed on the
front of your project box will make things cluttered and
2. Resistance values will vary on not only supply voltages
may even present a bit of “information overload.” I think
chosen, but by LED specifications as well. some combination of the two ideas mentioned would be
3. U1 and U2 can be chained together for multi-number in order. Fortunately, there are plenty of options to fill both
needs as shown in Photo 1. The top row (L-R) shows a 90˚
displays (single number display shown for clarity). circuit-mount LED, typically used on the edge of a printed
2019/Issue-5 69
circuit board (PCB) when the PCB is mounted in such a “RTTY Detector,” CQ: Amateur Radio Magazine, September
way that the edge with the LED is near the front panel of
2018, pages 32-6.
an enclosure (or on a card used in racks); a rectangular
LED; and typical “bullet” shaped LEDs most commonly “Microphone PTT Time-Out Timer,” CQ: Amateur Radio
used on both circuit boards and front panels. Magazine, January 2019, pages 55-8.
The second row shows (L-R) a two-digit seven-segment
display (which are either common cathode or common +12V — the most commonly available voltage in ham shack
anode; refer to Figures 2 and 3) and a 10-segment bar and mobile environments. They also can be operated
graph LED. While more types exist, the ones shown here at +5V, should we want to apply these principles to TTL
are the most common and often used. circuits. Resistor values have not been specified for this
Since pinouts of the seven-segment display can vary reason, as well as to allow for variations of the LEDs used
by manufacturer, the segment on the front of the display (2V, 20 mA versions may be the most common, but check
is referenced by letter (see Figure 4) to make drawings your datasheets first!).
on schematics more universal; actual assembly pinouts Also — especially when using a good number of
are provided in the datasheets of the displays; again see LEDs — be sure to heatsink the power supply regulator (if
Figures 2 and 3. running a separate supply for this circuitry) and/or when
running multiple seven-segment displays at the full rating
of 20 mA for each segment, since currents can easily be
Conclusion several hundred milliamperes. NV
CMOS ICs have been utilized to allow for operation at

EASILY ADD MOTION TO


YOUR PROJECT WITH THE
ACTUONIX IOT WIFI BUNDLE

ACTUONIX
R SERIES IOT WIFI WIFI
MICRO LINEAR ENABLED
ACTUATOR BUNDLE DEVICE

VISIT ACTUONIX.COM FOR PRODUCT


INFORMATION AND PROJECT RESOURCES

70 2019/Issue-5
Microcontrollers,
Software, and You

Series 1

Unless you’ve been sleeping under a rock for the past couple of years, you’ve noticed
that more and more products use microcontrollers in one way or another. From your
car to your oven and toaster, microcontrollers are everywhere.
Why? A microcontroller with more computing power than a
A major reason is because the software that drives mainframe of 40 years ago costs less than a morning latte.
these microcontrollers can be used to control other However, we’re not here to program a microcontroller
elements of the product or its environment. People talk to do open heart surgery. We want to know how to make
into their watch and a thermostat a thousand miles away these devices do what we want them to do. Perhaps we
gets adjusted. A package service rings a doorbell and want to make a solar collector that tracks the sun for
the homeowner “answers” the door, even though they’re maximum power gain throughout the day. Perhaps we
on vacation. Not only does the software make products just want to make a simple robot that does nothing more
more flexible, the microcontrollers are incredibly cheap. than follow a line on the floor. Perhaps it’s a device that
72 2019/Issue-5
By Dr. Jack Purdum Post comments on this article and find any associated files and/or
downloads at www.nutsvolts.com/magazine/issue/2019/05.

augments our favorite hobby, like something that converts any preconceived notions about how things should be
our keystrokes at a keyboard into Morse code. Can’t think done.
of a project for yourself? Really? Well, do an Internet search I have a somewhat different way of teaching
using “Arduino projects” and see what happens. I just did programming concepts that I’ve developed over the past
that and got 65.5 million hits! I’ll bet one of those hits four decades and they work pretty well. Also, I sincerely
would be something that you would enjoy building. believe you will find it to be an enjoyable journey if given
The common thread in all this impetus towards more half a chance. So, let’s get to it.
and more use of microcontrollers is the flexibility that
software brings to the table. Take a single microcontroller
and find 65 million adaptations of it. Amazing how creative First, Gather the Tools
the human mind is. And, as you know, each adaptation We begin our journey using the Arduino family of
means somebody had to do the programming for those processors (Uno, Nano, and Mega 2560), mainly because
microcontrollers. And that’s where you come in. As I open they can be purchased in a variety of stores and there’s
the door and you stroll past me, you look at me and say: about a bazillion lines of free program code you can use
“But I don’t know how to program.” for your projects. This huge body of code comes to us
Don’t care. through the open source movement, where thousands of
That’s an excuse — not a reason — for not trying some programmers have given freely of their talents. There are
software-based projects. When you got your first bike, tens of thousands of programs available to you, where you
did you just jump on it and do a 50K ride? How much can stand on their shoulders to create your own programs.
preparation did you go through to get your first driver’s The tools needed to program the Arduino family
license? (and others) are also free and the microcontrollers are
Most of us have invested some time in learning those inexpensive (i.e., less than $5 for a Nano). Later on, we’ll
things we want or need to do. Learning how to program add the STM32F1 (e.g., “Blue Pill”), ESP32, and Teensy 4.0
is no different, and it can be an extremely satisfying microcontrollers.
endeavor. Seeing a device respond to code you wrote Why these additional microcontrollers? There are
is, well, intoxicating in a good way. My goal is to create several reasons: They are also cheap ($2 to $20); their
an interest in exploring microcontrollers and encourage programming tools are also free; and they can all be
you into investing $5 and some of your time into that programmed using those same tools.
exploration. I honestly think you’ll enjoy the journey. Finally, these other microcontrollers have a much
deeper resource pool: more program (i.e., Flash) memory;
Where to Start? more data space (i.e., SRAM); and more Input/Output
(I/O) pins — all of which boot-scoot your data around the
For me, it would be great if you knew absolutely circuit at up to 37 times faster than a Nano!
nothing about programming. The reason is because no All the programming activity you’re going to
experience would mean you haven’t acquired any bad do takes place in something called the Integrated
programming habits. It would also mean you don’t have Development Environment, or IDE. To create an executable

There are two flavors of the Arduino Nano: the Nano and the Nano Pro Mini. As you can see, the Nano on the left has
a mini B USB connector
on the board, which makes
connecting it to your PC via
a USB cable very convenient.
The Nano Pro Mini on the
right does not include the
USB connector. So, while
the Pro Mini may cost a little
less, you have to construct
the equivalent of a USB cable
between your PC and the
Nano. If you value your time
Nano at more than a penny an Nano Pro Mini
hour, buy the Nano.
2019/Issue-5 73
microcontroller program, you need a text editor to write “Recent Documents” which allows you to quickly reload
the program (i.e., the program source code); a compiler to the last document you used. If you look at the Arduino
convert your English-like C language program statements IDE and click on the File menu option, you’ll see an Open
into instructions the computer can understand; a linker Recent option that presents a list of the source code files
to combine what you wrote with other code from the you have recently accessed. Where did that file list come
open source libraries designed for your specific type of from?
microcontroller; and a serial monitor so you can see the Somewhere on your system, the IDE, word processor,
output produced by your program (if you want to). All or spreadsheet program has stored a list of the files you
these tools — from the text editor to the serial monitor — have used recently. As part of the Initialization Step, the
are embedded in the Arduino IDE. program first went to that place, loaded that file list, and
The process of downloading and installing the Arduino made it part of the Open Recent menu option.
IDE is well documented elsewhere. However, we have Other common activities that are part of establishing
posted a set of instructions in the article downloads to the operating environment might include opening a printer
help you through the download and install process for port, creating a database connection, opening a Wi-Fi link,
the IDE if you haven’t already done so. That document initializing a temperature or humidity sensor, or any one
also encourages you to buy at least one Arduino Nano for of a thousand other things your program may need to do
experimenting. before it can function properly.

Second, Think Step 2. Data Input


My guess is that after you finished installing the Expressed in its simplest terms, all a computer program
Arduino IDE, you connected your Nano to your PC, loaded does is take data into the program in one form, process
the Blink program (using the File → Examples → 01.Basics that information, and then output that data, but in a
→ Blink menu sequence), compiled, and uploaded it. Now new form. If you’re writing an email program, the data
you’re sitting there staring at your Nano which is dutifully most likely is coming into the program from a keyboard.
blinking its onboard LED at you once every second. If However, data could be coming in via a database
you leave and come back tomorrow, it will still be there connection, from a disk file, from a fire sensor, a retinal
blinking at you. Clearly, that’s not the ultimate reason you scanner, from thousands of different sources.
bought your Nano. The point is a useful program is going to require some
No, you bought it because either you are inquisitive form of input data.
by nature or you have something else in mind for your Alas, incoming data can be corrupt. Database
Nano “down the road.” So, how do you move from point connections can be broken, Wi-Fi links can disappear,
A (where you are now) to point M which is the project you sensors can fail, and humans do make typing mistakes.
have in mind? Well, it’s the old Elephant Problem: How do The point is, it is almost always a good idea to verify the
you eat an elephant? Answer: One bite (byte?) at a time. data if at all possible. If someone is applying for a driver’s
There’s a beautiful simplicity about programming: Any license and later on in the application, they tick the Blind
program — no matter how complex — reduces to what I’ve checkbox, you might want to ask some further data
named the Five Program Steps. Therefore, the first thing verification questions.
you should do when confronted with a programming task The old saying: Garbage In, Garbage Out means that
is think through the Five Program Steps. the results of a program are no better than the data that
drives the program. Therefore, the Data Input Step assumes
that every attempt possible has been made to verify the
Step 1. Initialization data.
Simply stated, the Initialization Step establishes
the environment in which the program is to execute. Step 3. Processing
Establishing the run-time environment for your program Once the verified data is part of the program,
involves doing things behind the user’s back, before they something is done to that data to transform it from its
see anything on the output device (e.g., display, LEDs, web current state to the desired state. That data transformation
page, etc.). is guided by an algorithm. An algorithm is nothing more
For example, you have all probably used a word than a methodology that is applied to the input data to
processor or spreadsheet that has a menu option for generate the new output data.
74 2019/Issue-5
For example, an algorithm to generate the square of a what’s called a sentinel to do away with a few extraneous
number, n, is to take n and multiple it by itself. If n is 3, the program statements.
square of n is n multiplied by n yields the square of n (s = What I’m trying to show here is that as you gain
n * n, or 9 = 3 * 3 where an asterisk in this case indicates programming experience, the way you write your own
multiplication). However, there is almost always more than code just gets better and better.
one way to skin a cat. Yep, algorithms matter.
Some years ago, I discovered quite by accident a
different algorithm for squaring a number:
Step 4. Output
The square of a number n is equal to the sum of its first It wouldn’t make much sense to expend the effort
n odd integers doing the first three steps if you didn’t have plans for the
new data when the processing was finished. Perhaps the
Using this algorithm to square a number, we find: most common way to see the output from a program in
the Arduino environment is via the serial monitor.
Square of 3 = 1 + 3 + 5 The serial monitor is an object in the IDE that lets you
9=1+3+5 use simple statements to display things via the USB cable
from your microcontroller to your PC’s monitor.
Square of 5 = 1 + 3 + 5 + 7 + 9 However, there are also thousands of other possibilities
25 = 1 + 3 + 5 + 7 + 9 for output. Indeed, most of the programs I write often
direct the output to a TFT color display controlled by the
While this is a very inefficient way to square a number, microcontroller. In other cases, the program output might
the point is valid: There are many possible algorithms for a be nothing more than to load a new program based on the
solution to the same problem. A programmer I know was values determined in the first program.
hired by a very large company and his first assignment was Other programs might be responsible for updating a
to address a sales report problem. Sales data came in each person’s record in a database, or dialing a phone number,
night before 1 AM from all over the world. The task was or sounding an alarm and dialing 911, or opening a
to take that sales data and prepare income statement and valve that allows two vats to be mixed. The number of
inventory reports before 8 AM the following morning. The possibilities is limitless. The good news: It’s your program.
reports were always late. Send the output where you want to!
After a closer examination of the processing of
that data, the programmer formulated a new algorithm.
The new report generation code implemented the new Step 5. Termination
algorithm that processed the data and constructed the The purpose of the Termination Step is to gracefully
same reports in 47 minutes. end the execution of the program. The key here is the word
One time I was looking for a good way to search “gracefully.” Too often, programmers simply terminate the
through a disk data file looking for a certain pattern program without any real thought to what they are doing.
of words. I read an article on the Boyer-Moore string Not good.
matching algorithm. The authors used a brute force If your program reads a list of recently opened data
searching method as the baseline point for judging the files during the Initialization Step, the Termination Step
Boyer-Moore effectiveness. The article’s brute force should update and store that modified list. If your code
algorithm took 42 seconds to search a given data file. opened a database connection, your code should close
Because I didn’t have their brute force algorithm code, I that connection. Same for disk file handles, printer ports,
wrote my own. Oddly, my brute force algorithm processed Wi-Fi, and other connections.
the same file in about six seconds. Why the difference? In general, any resources you borrowed from the
Actually, in this case, the algorithms were almost the system or its environs during your program execution
same, but I used several C library routines and tricks that should be returned to that system. Leaving open disk files
they could not do in their language of choice (i.e., Pascal). or dangling port (or other) connections is just impolite and
First, the C library routines I used are “standard” wrong. In the words of my mom: “Clean up your mess!”
library routines which are often written in hand-tweaked So, the Termination Step seems to follow the adage
assembly language by guys with propeller caps and are that all good things must come to an end. Well, not really.
much brighter than I am. Second, my algorithm used Microcontroller programs are often written to run forever.
2019/Issue-5 75
How effective is the Empire State Building fire alarm Your Assignment
system if you shut it down at 5 PM and don’t restart it until Okay, you are now equipped to look at any program
tomorrow at 8 AM? How about traffic light controllers? and think of it in terms of the Five Program Steps, and
Refrigerators? Air traffic control radar? It kinda seems like a that’s exactly what I want you to do. Take a look at the
good idea to keep artificial hearts going most of the time, Blink program you probably ran earlier and identify the
too! Five Program Steps.
The point is that many microcontroller programs are Think about a program you’d like to write. Take a sheet
assumed to never shut down. Such “perpetual” programs of paper and write down the Five Program Steps, leaving a
have three causes for their shutdown: 1) power removal; 2) couple of inches between each heading. Now, fill in each
component failure; or 3) a program reset (i.e., a do-over!). step with those things you think you need to do to get
We shall see examples of such “perpetual” programs later from point A to point M.
in this series. The rest of this series is designed to help you make
that move from point A to point M. NV

76 2019/Issue-5
Bench and Builder
USB Add USB to your next project--

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

For The www.dlpdesign.com

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

!!!Set Up Your Own Stereo FM Radio Station!!!


Progressive Concepts has everything needed to set up
and run your own FM Broadcasting Station:
Stereo FM Transmitters, Antennas, Coaxial Cables,
Mixing Boards, Automation Software, and much more!
WWW.PROGRESSIVE-CONCEPTS.COM

2019/Issue-5 77
For IoT Projects,
Call JSON
By Jonathan A. Titus

Internet-of-Things (IoT) projects that use sensors, actuators, displays, or


controllers can easily communicate through an MQTT (Message Queuing
Telemetry Transport) server, or broker. The MQTT standard lets devices
publish and subscribe to specific topics. When they use the JavaScript
Object Notation (JSON) format to exchange information, software can easily
interpret or parse it. The JSON standard defines a payload format that may
include strings, values, objects, and Boolean “true” and “false.” (See the
sidebar, MQTT Broker Setup and Note 1.)
78 2019/Issue-5
in Figure 1. Of course, you can use other I/O
devices.

MQTT: A Short Introduction


To communicate through an MQTT broker,
each transmitting IoT device must indicate the
topic of the communications it will publish.
Likewise, each receiving IoT device must tell
the MQTT broker what topics it wants to
subscribe to. The Arduino PubSubClient library
handles the details for us, so to subscribe to the
topic ValveCtrl, for example, our software uses
this statement:

client.subscribe(“ValveCtrl”);

An ESP8266 module that ran the statement


above will receive all MQTT messages that
include the topic ValveCtrl. The topic goes
between quotation marks and is case sensitive.
Thus, ValveCtrl and VALVECTRL represent
different topics.
When an IoT device publishes information
through an MQTT broker, it uses the following

I
format which we call an MQTT message:
n this tutorial, I’ll explain how to create and parse
JSON messages. My software examples use the client.publish(“topic”,”payload”);
Arduino integrated development environment
(IDE) along with the Arduino ESP8266WiFi and For example:
PubSubClient libraries. Example code is complete
and ready to use in ESP8266 Wi-Fi modules. My client.publish(“ValveCtrl”,”close”);
experiments use an ESP8266 module as a publisher
and another as a subscriber.
They communicate with each other via my Wi-Fi
access point that connects them to a remote (free!)
MQTT broker. No direct link exists between one
ESP8266 module and the other.
The ESP8266 modules provide an internal
microcontroller, so you don’t need an external
Figure 1. Circuit diagram for
microcontroller board (Note 2). If you’re not familiar the publishing ESP8266 that
with the ESP8266 modules, you can find many connects to power and a
online experiments and tutorials that explain how to DHT22 sensor module. The
use these popular inexpensive devices to connect subscribing module connects
to a WiFi hot spot. I used “D1 Mini” modules that to a PC that supplies power
cost under $5. There are also several articles by and a terminal-emulator
Craig Lindley on using the ESP8266 that have been program. The Arduino IDE’s
published in Nuts & Volts. built-in terminal works well.
The DHT22 temperature and humidity sensor
make a good data source for ESP8266 and Wi-Fi
experiments. You’ll need the DHT.h library and the
Adafruit Unified Sensor Library.
I connected the DHT22 sensor’s serial output to
pin D1 on the ESP8266 D1 Mini module as shown
2019/Issue-5 79
Figure 2. Five devices indicates this IoT device will
communicate information to receive all messages under the
each other through an MQTT main topic ValveCtrl.
broker. An MQTT message A plus sign (+) provides a
lets you format information wildcard for one subtopic level,
in several ways. so if you want to receive On-Off
messages for only Valve1 and
Valve2, you could use:

client.
subscribe(“ValveCtrl/+/On-
Off”);

Use a JSON Payload


Instead of publishing three
MQTT messages — one for each
of the three topics described
earlier — a JSON payload lets you
combine many sets of data in a
The MQTT broker will send the close string to only IoT single publish operation. My DHT22 IoT “weather station”
devices that have subscribed to the ValveCtrl topic. The measures temperature (degrees Fahrenheit and Celsius)
payload may contain a string or a value. Figure 2 illustrates and relative humidity via the Arduino DHT.h library and
several communications between IoT devices and an returns a floating-point value. For example:
MQTT broker. In this example:
float h = dht.readHumidity();
1. The GPS Clock publishes Time information. It does
not subscribe to any topics. Only the Clock Display and The ESP8266 “weather station” will publish the data
the Status Display subscribe to Time, so only they receive that follow. I included the units in parentheses for clarity.
Time messages. Neither the Clock Display nor the Status They aren’t part of the payload.
Display publish information.
2. The Valve device publishes ValveStatus information h = 43 (relative humidity, percent)
that the Status Display and the Valve Control devices c = 22 (Celsius temperature)
subscribe to. Based on the ValveStatus data, the Valve f = 71.6 (Fahrenheit temperature)
Control module decides how to respond. Only the Valve
subscribes to messages with the topic ValveCtrl, so it alone The JSON standard lets us send name-value pairs in
receives messages on this topic. the format:

“name”:”value”
Set Up Subtopics, Too
The topics in MQTT messages may have subtopics, “name1”:”value1”, “name2”:”value2”,
“name3”:”value3”,..
much as a PC’s hard drive has folders and subfolders. The
following subscribe functions provide examples:
You may use a string, “43”, or the value 43, to
client.subscribe(“ValveCtrl/Valve1/On-Off”); represent a numeric quantity:
client.subscribe(“ValveCtrl/Valve2/On-Off”);
client.subscribe(“ValveCtrl/LEDS”);
“Humidity”:”43” or “Humidity”:43
The subscribe text may include the “wildcard”
characters number-sign (#) and plus (+). A “#” in the text A colon separates each name from its associated value,
signifies a subscription request for all topics below a given and a comma separates name-value pairs. A numeric value
level. Thus, the statement: may use the characters plus or minus, a decimal point, and
numerals 0 through 9. A JSON payload always starts with
client.subscribe(“ValveCtrl/#”); a left brace and ends with a right brace. Do not put spaces
80 2019/Issue-5
between characters! If you try to send this MQTT message in a client.
In this next JSON payload example, I didn’t use the publish statement as shown above, you’ll have problems
software variables h, c, or f. Instead I used a name: and wonder why. An MQTT message uses quotation
marks to enclose the topic and the payload, but the JSON
{“Humidity”:43,”TempC”:”22”,”TempF”:71.6} payload also uses quotation marks to identify names and
values.
Remember, the MQTT message includes a topic and To avoid conflicts about which quotes “belong” to
a payload. Only the payload contains information in the which information, the JSON payload must protect its
JSON format. I have included the topic and the JSON internal quotation marks by “escaping” them. You have
payload (underlined) in the following MQTT message: encountered the escaped characters \n and \r used in
programs to cause a display to go to a new line or to return
client.publish(“Station1”, “{“Humidity”43, the cursor to the left margin.
“TempC”:”22”,“TempF”:71.6});
In the same way, a backslash will escape quotes within

MQTT Broker Setup


For experiments, I use a free “Cute Cat” MQTT 1. In the Connection name section, enter CloudMQTT.
broker account at CloudMQTT (www.cloudmqtt.com). 2. In the Hostname section, choose tcp:// and enter
This account allows as many as five users or connections, your mqttServer URL.
and it has a maximum data rate of 10 kbits/sec. Those 3. In the Port section, enter the mqttPort number.
limits will accommodate a small arrangement of IoT 4. Click on the Generate a random ID button. You’ll
devices. Paid accounts start at $5 per month. receive a long ClientID. Copy this ID and keep it
When you create an account, you receive a server handy.
name, a user name, a password, and a port number. I 5. Check both Clean Session and Automatic
recommend you take a screen image of the “Instance Connection.
info” and put it in your lab notebook. You’ll need that
6. If not already set, choose a Keep Alive time of 120
information so your IoT devices can connect to the
seconds
broker, and you might need it for communication tests.
7. In the Credentials section, enter your CloudMQTT
The example code requires them, along with your
User Name. Enter your CloudMQTT Password.
local Wi-Fi network name and password:

const char *ssid = “yourNetworkName”; When you start MQTTLens the first time, it asks
const char *password = for Connection Details. Now you can monitor your IoT
“yourNetworkPassword”;
const char *mqttServer = “XXX.cloudmqtt.com”; device communications and you also can transmit test
const int mqttPort = port number given by messages.
cloudMQTT;
const char *mqttUser = “cloudmqtt assigned
userName”;
const char *mqttPassword = “assigned by Get the Software
cloudMQTT”;
The software that accompanies this article has many
Note: The port number is a numeric value, not a comments to help you understand what statements do
string. and their function within each program.
The ZIP folder includes two program folders:
Troubleshooting
Program 1. sketch_TempHumid_JSON_Rev_2NV
If you need to troubleshoot or test communications Program 2. sketch_String_Decode_Rev_10NV
to and from an MQTT broker, download and run the
MQTTLens application from Google. You can run it Each program requires your Wi-Fi router or hot-spot
within the Chrome browser. name and password. It also needs the MQTT broker
This application requires the CloudMQTT log-in information described earlier. The section of code for this
information or equivalent information from whatever information shows empty strings in which you insert your
broker you use. information. Do not leave blank space in the strings.
2019/Issue-5 81
the JSON payload. The red characters that follow show the Create a JSON Payload
properly escaped marks.
Software could publish this message. To create a payload in the JSON format, a program
may simply concatenate strings. In Listing 1, the function
client.publish(“Station1”,”{\”Humidity\”: dataUpdate reads values from the DHT22 sensor, checks
43,\”TempC\”:\”22\”,\”TempF\”:71.6}”);
to ensure it receives valid floating-point numbers, converts
the floating-point numbers to strings, and then assembles
A subscribing ESP8266 module receives the original a JSON payload. (You can probably think of other ways to
JSON payload with the internal quotes intact; they’re no create a payload.)
longer “escaped.” The name-value pairs may include any
information you choose, such as: “fuel”:”gasoline” or
“speed”:”km/hour,” and so on. Receive a JSON Payload
After an MQTT broker receives a message
\\ Update the temp (F & C) and humidity readings with the topic Station1, it will publish that
void dataUpdate() message to all devices that earlier subscribed to
{ the Station1 topic. The broker does not broadcast
float h = dht.readHumidity(); messages to all connected devices. Let’s assume
float c = dht.readTemperature(); an IoT weather station display called WX-Display
float f = dht.readTemperature(true); subscribed to the Station1 topic, so it will receive
//Check for a data failure Station1 messages. How does the WX-Display
if (isnan(h) || isnan(c) || isnan(f))
software handle the messages?
The PubSubClient library includes an object
{
named loop and uses it this way:
//Print error message
Serial.println(“Failed to read from DHT sensor!”); void loophere()
} {
client.loop();
String humidValue = String(h); //Convert float data to }
String celsiValue = String(c); //strings
String fahreValue = String(f); This loop object executes during each run
through the loophere loop. According to the
//Create JSON payloadout to send to MQTT server library’s API documentation, the software in the
//Refer to: JSON Style Guide WX-Display should regularly call this function to
String payloadout = “{“; let the client “process incoming messages and
payloadout += “\”Humidity\”:”; maintain its connection to the server.” The loop
payloadout += humidValue;
does just that (Note 3). This loop object requires
a callback function. For simplicity, think of this
payloadout += “,”;
payloadout += “\”TempC\”:”;
Listing 1. as an interrupt service routine that goes into
effect whenever the WX-Display receives a new
payloadout += celsiValue;
Station1 message. The callback function for an
payloadout += “,”; ESP8266 module looks like this:
payloadout += “\”TempF\”:”;
payloadout += fahreValue; void callback(char *topic, unsigned char
*payload, unsigned int length)
payloadout += “}”; {
Serial.println(payloadout); //Optional print put your message-parsing code here...
}
char attributes[200];

//Create character array The callback function provides:


//Publish the name and value pairs to server
1. char *topic: A pointer to the first
payloadout.toCharArray(attributes, 200);
character in the topic string.
client.publish(“esp/test”, attributes);
2. unsigned char *payload: A pointer to the
}
first character in the payload.
//---- END of dataUpdate() function ----- 3. unsigned int length: The length of the payload.
82 2019/Issue-5
With this information, software in the display
can parse the received JSON payload and display
the temperatures and humidity. You will see pointers
as char* xyz, and as char *xyz. They mean the same
thing: xyz is a pointer to character-type information.
(For more information about callback functions, see Figure 3. Output from
Note 4.) the ESP8266 module that
subscribes to the esp/
test topic that provides
Parse Your JSON Payload the humidity and
Programmers use JSON objects, or payloads, temperature data.
in many applications, so you can find a library of
JSON parsing or decoding software for almost any
language, including C++ for the ESP8266 modules.
Although programmers have used the ArduinoJson
library, I found it overly complicated for simple JSON
Payloads that comprise name-value pairs. tests and parses them, and displays information on a
That format will suffice for all but the most demanding terminal emulator.
IoT projects, so I created a function that parses name-value Feel free to use the open source code in any way you
payloads. I called it JSON_Parse and here’s how it works. choose.
The payload comes through to the WX-Display device
with quotation marks intact:
How the Parser Code Works
String testString = My parser code requires three arrays to save name-
{“Humidity”:43,”TempC”:”22”,”TempF”:71.6}
value pairs and it needs a “big number” I’ll explain later.
My example code set an upper limit of five name-value
You cannot pass a string of characters to a C or C++ pairs, but you may change this as you wish:
function, so the JSON_Parser function requires a
pointer to the first character in the payload (Note 6).
In the statement above, testString points to the left- Notes
hand brace ({). Now, the function call to JSON_Parse
looks like this: 1. Download the MQTT v3.1.1 specification at http://
mqtt.org/documentation. Many websites provide explanations
int returnCode = JSON_Parse(testString); and tutorials that discuss and demonstrate how to set up a free
MQTT account as several companies. For the JSON standard,
In effect, the variable testString equals the please visit www.ecma-international.org/publications/files/
memory address for the first unsigned char ({) in the ECMA-ST/ECMA-404.pdf.
JSON string. The pointer testString + 1 gives us the 2. Although you use the Arduino IDE to create programs
address for the second character (“), and so on, one that run in ESP8266 modules, the module does not include
character at a time. an Arduino-type microcontroller. It uses a custom MCU based
Unsigned characters have values between 0 on the Tensilica Xtensa instruction set architecture (ISA). For
and 255, which encompass all ASCII characters and information, visit https://0x04.net/~mwk/doc/xtensa.pdf.
codes such as linefeed (LF), carriage-return (CR), and 3. For the PubSubClient library descriptions, visit https://
bell (BEL). The function returns a returnCode value pubsubclient.knolleary.net/api.html.
that indicates an error, if any. 4. https://www.geeksforgeeks.org/callbacks-in-c.
The example code you can get in the article 5. “How are backslash escape sequences implemented in
downloads produces information a terminal compilers?” at https://stackoverflow.com/questions/8633769/
emulator will display as shown in Figure 3. In my how-are-backslash-escape-sequences-implemented-in-
experiments, I used the topic “esp/test,” and you’ll compilers.
find it in the two example programs. 6. Jensen, Ted, “A Tutorial on Pointers and Arrays in C.”
One program runs on an ESP8266 that Available as a free download from https://pdos.csail.mit.
published the DHT22 information. The second edu/6.828/2009/readings/pointers.pdf.
program receives messages with the esp/test topic,
2019/Issue-5 83
Figure 4. The JSON_Parse SP8266 attached to the sensor produces
flowchart shows how a a JSON payload that includes the current
JSON payload gets split into temperatures (°C and °F) and the relative
name-value pairs and how
humidity (%).
it interprets numeric values
and string values. The JSON_Parse function first counts
the commas in the payload and adds 1 to
give us the proper number of name-value
pairs. Commas separate name-value pairs
and the DHT22 payload includes two
commas for three name-value pairs.
The function also checks the payload
for a left brace at the left and a right brace
at the right. If the JSON payload doesn’t
meet that requirement, the function
returns error code 99.
In sections A and B in Figure 4,
the function finds the first two quotes,
replaces them with question marks (?),
and extracts the string between them. This
string gives us the first name, Humidity.
The question marks act as “fillers” that
keep the original JSON payload string a
constant length. The software will ignore
them when it next looks through the
payload for quote marks.
The name Humidity goes into array
element JName(1). The payload now looks
like this:

{?Humidity?:43,”TempC”:”22”,
”TempF”:71.6}

At point C, the function tests for a


colon (:) after the last question mark. If the
function doesn’t find a colon separator, it
returns with error code 98. If it detects a
colon, it next tests the following character.
If it finds a quotation mark (D), it
performs the same operation used for
the name (E): The two quotation marks
get replaced with question marks and the
value portion of the name-value pair gets
placed in JValue[1].
#define arraySize 5 The ESP8266-DHT22 JSON-payload shown just above,
String JName[arraySize];
String JValue[arraySize]; however, includes an “unquoted” numeric value, 43. Thus,
float JNumber[arraySize]; the character after the first colon is not a quotation mark,
const float bigNumber = 0xFFFFFFFFFF; //trillions! so the function then tests the character at that location
for a plus (+) or minus (-), or a digit between 0 and 9 (F).
At its start, JSON_Parser (the function) prints the MQTT Detection of one of these characters indicates a numeric
message topic and JSON payload. You may remove or value. The 43 gets converted to a floating number and
comment-out these lines. saved in JNumber(1).
Figure 4 illustrates the function’s operations in The JSON_Parse function uses elements in three global
flowchart form. In this example and in the accompanying arrays — JName[], JValue[], and JNumber[] — for each name-
code, I use a payload from the DHT22 sensor. The value pair in a payload. If the value arrives as a text string,
84 2019/Issue-5

Titus - For IoT Projects Call JSON - Issue-5 2019.indd 84 1/27/2020 6:12:19 PM
the JSON_Parse function saves it
in the JValue array. Resources
If the value arrives as a Santos, Rui, “ESP32 with DHT11/DHT22 Temperature and Humidity Sensor
numeric value, it goes into the using Arduino IDE,” https://randomnerdtutorials.com/esp32-with-dht11-dht22-
JNumber array. The array used temperature-and-humidity-sensor-using-arduino-ide. Many thanks to Rui for his
depends on whether you send a
helpful online tutorials that started me on my ESP8266 projects.
value within quotes or a numeric
quantity without quotes.
When a numeric value goes “Overview of MQTT Protocol,” Kii Corp., https://docs.kii.com/en/guides/
into the JNumber[x] element, thingifsdk/non_trait/mqtt/protocol_overview.
the JValue[x] element holds an
empty string. Likewise, when For topic-name rules, see: “MQTT Essentials Part 5: MQTT Topics & Best
a text value goes into the Practices,” https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-
JValue[x] element, bigNumber practices.
(0xFFFFFFFFFF, or about 1.1
trillion) goes into JNumber[x]. any error code it finds. The example software tests the
In some cases, you might test the contents of arrays and also tests for a returned error code. NV
JNumber[x] for a very large number and if so, assume the
value went into JValue[x]. Or, it could test JValue[x] for an
empty string and assume a numeric value went into the
JNumber[x] array element. Post comments on this article and find any associated
In all cases, your application software should test the files and/or downloads at www.nutsvolts.com/magazine/
value returned from the JSON_Parse function and act upon issue/2019/05.

2019/Issue-5 85
When I was in junior college,
I did an experiment in a
physics class that I have never
forgotten. It was the classic
falling body experiment to
measure the acceleration of
gravity; 9.81 meters/sec2. I
loved carefully adjusting the
apparatus and meticulously
taking the data, trying to get
a result that was as close as
possible to the established
value. Frankly, I don’t recall
how close I got, but it was the
thrill of scientific inquiry that
grabbed me.

THE GOAL
Now, in this age of computer
technology, I thought it might be
challenging and fun to see how good I
could do in my garage with a fairly simple
DIY apparatus. Figure 1 shows the tower
I built to drop a 3/4” steel ball down an
evacuated pipe, past four photogates.
In operation, the four timers
simultaneously start when the ball is
Figure 1. The released at the top and stop in sequence as
72””Tall it passes each photogate.
evacuated drop By knowing how far apart the gates
tower has four are and how long it takes to traverse
photogates and between them, the acceleration of gravity
timers. The steel
can be calculated. The big question is how
ball takes about
600 milliseconds accurate would it be?
to drop. Spoiler alert: The final results knocked
my socks off!

EBAY COMES TO THE


RESCUE, SORTA?
When I first started this project, I was
planning on building the photogates and
timers from scratch; possibly even using
a microcontroller to tie it all together. The
photogates would consist of an LED on
one side and a photodiode on the other.
86 2019/Issue-5
By David Goodsell

Newton’s
Apple
The falling ball would block the beam and stop the
associated timer. An Arduino could probably handle
the timing and digital display functions.
However, one morning as I was searching eBay,
some guy was selling surplus educational Cenco
photogates and timers ready to go for only $34 each
(see Figure 2). They were originally used in schools
to measure the very thing I was doing. So, I bought
four of them in the hope that they would save me a
bunch of time and effort. Three timers were enough
to do the job, but four would allow averaging. Little
did I know how much tweaking they would require
to meet my expectations. Nothing is ever easy!

DESIGNING THE TOWER Figure 2. Cenco produced photogates and timers for
the educational market. I bought four sets on eBay
for $34 each.
I decided to make the tower as tall as practical,
so the timers would have a large count and The four photogates were mounted along the
maximize the data resolution. Referring back to Figure backbone at exactly 21.500” ±0.010” intervals. Also
1, I designed the tower as a two-part structure. The included was a breadboard because I knew that sooner
“backbone” of the structure was a 3” x 1.5” x 84” long or later, I’d probably be adding something or other. An
U-shaped piece of 1/8” thick aluminum. It was easy to Arduino Micro was used to control the electromagnet and
mount the timers and photogates on its flat surfaces. generate the start pulses for the timers.
The backbone was mounted on an MDF wood base
with diagonal braces to stabilize it. Three adjustable feet
allowed me to make it perfectly level, so the ball would DESIGNING THE EVACUATED
drop exactly down the center of the evacuated pipe. PIPE
The second part of the structure was a hollow 2”
diameter aluminum pipe for the vacuum. It was 72” long At the top of the pipe was an electromagnet (Figure 3)
and connected to the backbone near the top and bottom. which held the ball while the pipe was being evacuated to
2019/Issue-5 87
with this arrangement, so I fabricated
and installed small aluminum inserts to
improve the alignment and reduce the
beam aperture to 0.050”. Much better!
Located at the bottom of the pipe
(Figure 6) was the “collection cup.” It
was partially filled with small lead shot
to cushion the ball’s sudden stop. Notice
that the cup also has an O-ring to seal it
to the bottom surface of the pipe.
The whole structure was precisely
leveled by dropping a plumb bob on
a string down the exact center of the
vacuum pipe and adjusting the leveling
feet.

THE VACUUM
SYSTEM
Figure 3. An electromagnet holds the 3/4” steel ball at the top
while the 2” pipe is evacuated. When the ball is released, the four The vacuum system uses a 2.5
timers are simultaneously started. CFM pump from Harbor Freight that
was normally used to service
refrigerant systems; refer to
Figure 7. The specs said it
would go down to 80 microns
and by golly it did! That was
more than sufficient because
any remaining drag would have
a negligible effect.
On eBay, I found a vintage
Veeco vacuum gauge and
thermocouple sensor to go
with it. Of course, I could have
used one of the new digital
vacuum gauges, but I love the
Figure 4. Sealed glass windows allow the beam to pass from one side of old stuff. I also found a very
the pipe to the other. The falling ball blocks the beams and stops the nice Veeco bellows shutoff
counters. valve to isolate the pipe just
before doing a drop.
a reasonable level; i.e., less than 100 microns; 100 microns
would leave about one part in 10,000 of air. Notice the
thin black O-ring that sealed the cover to the top edge of MEASURING THE DISTANCES
the 2” pipe. BETWEEN THE PHOTODIODES
Figure 4 is a close-up of the windows for the
photogate beams. I fabricated them from small pieces of Accurately measuring the distances between the
microscope slides and sealed them with Hysol 1C epoxy. photodiodes was the trickiest and most critical part of
Amazon sells a 4 oz kit of 1C under the name Loctite. the whole experiment. To get the accuracy I wanted,
The infrared LEDs and photodiodes that Cenco used I purchased an NIST certified 24” precision ruler from
were a small size and loosely inserted inside their black McMaster for $134. Gulp. It was calibrated to +-0.0001”.
cylindrical plastic housings (see Figure 5). I wasn’t happy Figure 8 illustrates how I used the 24” certified ruler to
88 2019/Issue-5
Figure 5. Small inserts with 0.050” holes
were retroFItted to the photogates to
improve alignment and reduce the beam
size.

calibrate four small ruler segments mounted on


a 72” aluminum “transfer ruler.” Figure 9 shows
the tower tilted over backwards, with the transfer
ruler ready to be inserted into the pipe.
The ruler was slowly slid in until it blocked
the beams one at a time. Using a microscope,
the precise reading (+-0.001”) of the respective
ruler segment was noted each time a beam was
blocked. The final distances were:

@80 degrees F
D1 (T1 to T2) = 21.512” +-0.001”
D2 (T2 to T3) = 21.519” +-0.001”
D3 (T3 to T4) = 21.501” +-0.001”

Figure 6. The sealed cup at the bottom contains


tiny lead shot which cushions the falling ball. Figure 7. The vacuum pumping system uses a 2.5 CFM
The FInal velocity of the ball is about 5.99 m/sec pump from Harbor Freight to pump the air out of the
(13.4 mph). sealed pipe. The vacuum is typically <100 microns.
2019/Issue-5 89
Figure 8. To measure the distance between
photogates, a 24” certiFied ruler was used to
position four ruler segments at precise 21.500”
intervals on a 72” aluminum ruler.

I was also concerned about the thermal expansion


coefficient of the aluminum backbone, which was 12 x
10-6 per degree F. This parameter was important because
the photogates were connected to the backbone, and any
change in its length would affect the calculations. So, I
taped two thermocouples along the tower. During testing,
the ambient temperature varied from 78 to 83 degrees
which produced a length change of 0.004”. This doesn’t
sound like much but it counted.

THE FUN PART: TAKING


DATA
A typical test went as follows:

1. Reset the timers. Figure 9. The aluminum ruler was slowly slid into
2. Turn on the electromagnet. the tilted-down vacuum pipe until each beam was
3. Lift up the magnet and insert the steel ball. blocked and its position noted within ±0.001”.
4. Replace the magnet and pump down the pipe for
about five minutes.
5. Turn off the magnet. What went right:
6. Listen as the ball falls into the cup with a clunk.
7. The ball accelerates to about 6 m/sec (~13 mph) 1. There were no leaks in the vacuum system.
by the time it reaches the bottom in 611 ms. 2. The timers started and stopped perfectly.
8. Read the values of the four timers and type them 3. I plugged the numbers into the computer, and it
into the computer. calculated the acceleration of gravity. History was
9. Note the calculated result and see how close it is being made!
to the expected value.
90 2019/Issue-5
What went wrong: Final solution: I added a master 1.0000 MHz oscillator
that fed all four timers; refer to Figure 10.
1. After doing a dozen drops, the calculated values
were way off — 2.5% low. What a disappointment! New Problem: There were only five digits on the
2. The answer was supposed to be 9.806 m/sec2. I timers. I needed six digits for the new 1 MHz clock.
got an average of 9.564 m/sec2. Solution: Just let the extra digit roll over. From previous
3. What the heck was wrong? testing, I already knew what the value of the rolled-over
digit would be. I double-checked the Cenco timers with a
separate six-digit counter. Right on the button.
NOW COMES THE 99%
PERSPIRATION PART: Problem: The Cenco photodiodes were slow to
respond when a beam was blocked.
SOLVING ALL THE PROBLEMS Reason: A look at the Cenco circuitry revealed the
Before starting this project, I found several examples photodiodes were operating in the photovoltaic mode.
on the Internet of how other Physics classes conducted Solution: Change the circuit to the photoconductive
similar experiments. mode, which is much faster.
However, I like to do things my own way first as a Complication: The photoconductive mode required
challenge, then refer to the published knowledge
if I bog down. I think of it as a learning process Designator Component Digi-Key, unless noted
and if something doesn’t work quite right, I R1 Resistor, 360, 1/4W 360QBK-ND
enjoy trying to solve the problems myself. R2 Resistor, 20K, 1/4W 20KQBK-ND
R3 Resistor, 10K, 1/4W 10KQBK-ND
Problem: My initial results were 2.5% low.
They should have been 9.806 m/sec2, or so I R4 Resistor, 1 meg, 1/4W 1.0MQBK-ND
thought. R5 Resistor, 20 ohms, 5W 696-1072-ND
The Obvious: Gravity is not the same all R6-R13 Resistor, 51K, 1/2W 51KQBK-ND
over the Earth. You need to factor in the local
C1 Capacitor, 0.1 mfd, 50V 399-4151-ND
altitude and the latitude. I had accounted for
altitude but had completely left out a term for D1 Diode, Schottky, 1N5818 1N5818DICT-ND
latitude. Q1 Transistor, NPN, 2N3904 2N3904FS-ND
Fact: People at the equator tend to be Q2 FET, Power, IRLU120NPBF IRLU120NPBF-ND
spun off the Earth. If a person at the North
U1 IC, Inverter, 74LS04 296-1629-5-ND
Pole weighs 100 pounds, they would weigh
approximately 1/2 pound less at the equator. U2 IC, Buffer/Driver, 74LS244 296-1653-5-ND
Solution: The Internet had a plethora of U3, U4, U5, U6 Op-amp, LMC6484 LMC6484IN/NOPB-ND
sites that calculated the “theoretical” value OSC1 Oscillator, 1.0000 MHz CTX150-ND
for any location on Earth. The corrected value
MAG1 Electromagnet, 6V, 326 mA eBay, China
for my location was 9.7941 m/sec2. (@2965’
altitude and 34.5° latitude). ARD1 Arduino Micro 1050-1066-ND
Result: My experimental values were much T1, T2, T3, T4 Timer & Photogate eBay, Cenco
closer now, but still about 1/2% low and they PS1 Power Supply, 12V, 2A 285-1884-ND
varied by ±1%. What else should I look at?
PS2 eBay, HP-6235A

Possible Problem: The maximum clock BP1 Buzzer, Piezo Jameco 335557
speed of the Cenco timers was 10 kHz. SW1 Pushbutton, Handheld eBay, Switchcraft
Analysis: A quick analysis showed that a PUMP Pump, Vacuum, 2.5CFM Harbor Freight
faster clock would vastly reduce the variation.
SENSOR Tube, Vacuum TC, DV-3M eBay, Misc
Solution: Open the Cenco timers up and
connect them to an external 100 kHz clock. GAUGE Gauge, Vacuum eBay, Veeco
Result: Much improved, but it still could be
better.
Parts List
2019/Issue-5 91
a negative bias on the photodiodes, so I had to add new scratch instead of buying the Cenco units, I would have
external op-amps and a -5V supply as seen in Figure 10. anticipated and designed-out many of the problems I
encountered. Unfortunately, I was blinded by my original
Last Problem: The Cenco LEDs were overdriven (23 idea that I could simply take a bunch of old discarded
mA), causing the photodiodes to saturate which slowed the educational units and make them sing. Luckily, it all worked
recovery time down by 100s of microseconds. out.
Solution: Put a little trimmer in series with each LED
and lower the current to around 3 ma.
Confirmation Technique: Modulate the LEDs at 1 kHz THE BIG FINALE!
and note the response of the photodiodes on the scope.
Result: I adjusted the LED drives, so all the photodiode Success times two! I could hardly believe how close
recovery times were equal to 10 µs. This resulted in a huge the experimental results were to the expected number.
improvement in data variation. Check out Figure 11 for a typical series of 10 ball drops.
Notice that the average is only off by +.0004. Not too
In Hindsight: shabby!
If I had just built the photogates and timers from Figure 12 shows how the data from one of the drops
was reduced. Over the next several days, I took many
Figure 10. The 1 MHz clock fed all the timers. runs and they were all very similar. The results were so
RetroFitted op-amps improved the performance consistent that I was at a loss as to what else could be
of the photodiodes by using them in the
photoconductive mode.

92 2019/Issue-5
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2019/05.

Figure 11. After making numerous


improvements to the apparatus, a plot
of 10 drop tests showed very small
errors. The results more than met my
expectations!

Seriously though, I had already spent


four months part-time on this project and
had achieved results that were far better
than I had ever expected. It was probably
time to move on. So, I packed up the tower,
put it in the shed, and turned my attention
to the next fun project: a Z-pinch machine.
I always welcome any comments or
corrections at dsgoodsell@verizon.net. NV

POSTSCRIPT
When I was initially assembling the tower
and mounting the timers, I encountered a
mechanical interference problem, as clearly
illustrated in Figure 13. My question to you
is this: Did I cut a notch in the aluminum
diagonal support or did I bandsaw a groove
in the gray timer cover?

Figure 12. Data reduction involved using the


distances between the photodiodes and the
transit times between them. Dozens of drops
produced similarly accurate results.

improved.
Now that I had nailed four significant digits, perhaps
I should go for five? Maybe I could do a better job of
controlling the temperature gradient along the tower?
Or, I could get really serious about a comprehensive
error analysis. Or, how about improving the distance
measurements by buying a 72” NIST certified ruler from
McMaster for only $805.11?

Figure 13. Houston, we have a problem. Back to the


drawing board.
2019/Issue-5 93
TECHFORUM READER - TO

>>>YOUR ELECTRONICS QUESTIONS


ANSWERED HERE BY N&V READERS
- READER

drop across the resistor. Hence, the


>>> QUESTIONS >>> ANSWERS voltage on the collector must be
at logic 1. When the transitor is on,
Dish Projects Wanted [#11187 - Nov/Dec 2018] current flows through the collector
I have a couple of small satellite About Resistors and pull-up resistor. A voltage drop
dishes (Direct TV I think) with Could someone explain what pull- now exists across the resistor causing
receivers that have been sitting in the up and pull-down resistors are, when the collector voltage to drop below
garage for a while. I hate to throw out and how they’re used, and how to the level of logic state 1. The more
technology that could be repurposed. calculate their values? current that flows, the bigger the
Anyone have an idea for a cool DIY voltage drop.
project I could reuse them for? #1 To begin with, positive voltages When a component is specified
#05191 Devin Martel are considered ‘up’ and negative as open collector, the designer must
Durham, NC voltages are ‘down.’ A resistor supply the pull-up resistor. This is
connected to a positive voltage on the case for the I2C communication
Guitar Tuner one end and to a circuit element interface. The designer may choose
I’m trying to build an electronic on the other end will be pulling the a large pull-up resistor to limit current
guitar tuner. Is there an IC available to circuit element up to the positive and extend battery life, but there is
generate the proper tones? voltage, if there is no current. If a trade-off due to unavoidable stray
#05192 Hamish Morisset you want current to flow, you must capacitance (C) at the output. A large
Norcross, GA figure how much and compute the resistor will increase the RC time
resistance from: R=V/I; where V is the constant and slow down the response.
Triangle Waves voltage drop across the resistor. Pull- Mike Hasselbeck
I need a circuit to generate a up resistors are often used with an IC Albuquerque, NM
triangle wave from zero to five volts. that has an open collector output.
#05193 Charles A. Parham Pull-down resistors are most #3 The basic idea of a pull-up or
Galveston,TX often used on the emitter of an NPN pull-down resistor came from some
transistor. If the base of the transistor logic families which had output pins
Car Detection has a positive voltage applied, the connected to the collector of the
I’m looking for help designing negative voltage could be zero output transistor stage. There was
a circuit to detect cars driving up (ground). In any case, you need to no internal connection to a power
my private road. I have in mind know something about the circuit to supply, so the output did not respond
something like the wire loop compute the resistor value. to logic states if no other connection
embedded in roads to sense cars at Russell Kincaid was made. A suitable resistor was
a traffic light. Can you explain the Milford, NH tied to the plus supply, so when the
principle behind this method and base of the transistor was held low,
how a basic DIY version might be #2 A pull-up/pull-down resistor the output went to the supply voltage
implemented? resolves a voltage ambiguity that may (pulled up to the supply); when the
#05194 Ulrike Krüger exist on a circuit node. These resistors base of the transistor went high, it
Laconia, NH are commonly used with transistors in would pull down the output to
digital switching operations. ground. The open collector allowed
Diesel Computer Mods A pull-up resistor connects a node outputs to be wire ORed together
There are several entities that will to logic 1 voltage (e.g., 5V) and a pull- saving parts. By connecting several
modify the settings on the engine down connects to logic zero (ground). outputs to the same resistor, if any
control computer for a diesel Chevy For example, a bipolar transitor used of them went low it would pull the
pickup to increase power. I assume for digital switching has a pull-up resistor down (an OR situation).
they are adjusting the timing curves resistor connecting logic 1 voltage to Values for these are usually
and other parameters. Is there an the collector node, i.e., the transistor suggested in the datasheets for
adapter and software available for me switch output. When the transistor the parts. To calculate a value, get
to experiment with this myself? is off, no current flows through it the max output current from the
#05195 Karel Dostál or the pull-up resistor. Ohm’s Law datasheet and use your supply
Covina, CA shows there can be no voltage voltage and Ohm's Law to compute
94 2019/Issue-5
Send all questions and answers by email to forum@nutsvolts.com
or via the online form at www.nutsvolts.com/tech-forum

the smallest allowed resistor. A cheap (<$10.00) solution is to use a suggestions?


The idea has been extended to wireless doorbell. For that, read on.
resistor networks which aid in driving Get a wireless doorbell from eBay #1 Sonoff makes a bunch of home
high speed signals through long like this one: https://www.ebay.com/ automation Wi-Fi devices. I have
lines. A Google search on impedance itm/400ft-Wireless-Doorbell-Twin- several of their products which I got
matching and line driving will get you Wall-Plug-in-Waterproof-Cordless- off eBay and AliExpress. Just type
started on this variant. Door-Chime-Kit/152986512099 “Sonoff” on the search line. They do a
Warren O. Wilderson ?hash=item239eb4eae3%3Am% lot more than just switch devices on
Eagle Point 3Amxl6HSV0iPKKQ83VnZkaAfw or off. I paid about $6 for a single-
&LH_BIN=1. channel and about $15 for a four-
[#3194 - Mar/Apr 2019] Set the output voltage of the DC- channel. Rated 10A @ 120 VAC.
Troubleshooting Circuit Needed DC converter to match the battery Simple to setup, the device just
I’m looking for a circuit using a voltage of the doorbell pushbutton needs to be within range of your
piezo buzzer that I can hear from circuit. The battery will not be used. router. The free app is only available
the room above the cellar. It will be Short the switch contacts inside for Andriod/Apple phones, although
connected to a Taco Heating Zone the doorbell pushbutton. they say you can use a PC if you
Valve on the boiler in the cellar for When the thermostat sends run it through an “Android Emulator”
troubleshooting the thermostat when 24 VAC to the Taco, the DC-DC program. Never tried this though.
it goes on and off. converter will output whatever Harold
voltage it is set to, to make the Rochester, NY
Get a DC-DC converter like the wireless doorbell chime or the piezo
one in Figure 1. buzz. When the thermostat is open, #2 The easiest way to do this
Get a diode, resistor, and there will be no voltage out of the would be to buy some TP-Link KASA
capacitor per the schematic and converter. modules. No hub required — just
build the new circuit. Note the Ed plug them in, load the app, and in a
capacitor must be rated at least 35 via email couple of minutes, you’re done. AND,
volts. Connect the new circuit to the they work with Alexa/Google Home.
existing circuit: A to A and B to B. [#3193 - Mar/Apr 2019] Bruce Robin
The diagram shows a doorbell Devices/Software/Scheme For Naples, FL
pushbutton — more on that later. In Wi-Fi Remote Control Using
place of the doorbell pushbutton, Smartphone #3 If all you want to do is to be
you can connect whatever piezo you I would like to control a pair of able to remotely control an AC outlet
want that is within the capability of simple low current AC sockets (ON/ via a mobile device from anywhere,
the DC-DC converter you get. The OFF) from my cell phone. I would like then simply buy a WEMO Mini Smart
problem with piezo buzzers is that it to use a combination of an existing Plug. These are sold in Home Depot
is impossible to predict whether you app, a PIC style device (Arduino for about $25. They connect to your
will hear them from the room above. or whatever), and a Wi-Fi module home Wi-Fi, are very easy to install,
to connect it to my and have apps for both Android and
existing Wi-Fi. I do not Apple iOS devices.
see why a $100 hub These Smart Plugs have a
DC-DC Buck Step-down
n FIGURE 1. Regulator Converter should be needed. I’m switched AC outlet capable of
4.5~65v to 3V 6V 9V stuck on finding the carrying up to a 15A load. No
12V 24V 48V Module. cell phone app and code to write, nothing to build. Just
the Wi-Fi module. I download the app, plug the WEMO
would assume that I Smart plug into any AC outlet, follow
would have to write the app instructions, and you’re up
the appropriate code and running in five minutes. Install as
for the PIC device. I many devices as you need remotely
can interface the PIC switched outlets.
with a relay, probably Roger Baker
a solid-state one. Any Redmond, WA
2019/Issue-5 95
ADvertiser INDEX
Accutrace ................................. 99
Actuonix Motion Devices ......... 70
CQ Magazine ........................... 85
■ LOOK FOR ■ SEARCH FOR ■ FIND Find your favorite advertisers here! DLP Design ............................. 77
ACTUATORS PLATFORMS/TOOLS Hitec Commercial Solutions DMMCheckPlus ....................... 59
goBUILDA Dr. Duino Pololu Dr. Duino .................................. 37
Hitec Commercial Solutions Technologic Systems
RADIO Electronix Express ................... 41
ANTENNAS EDUCATION Progressive Concepts
LDG Electronics Dr. Duino ExpressPCB ............................ 76
ME Labs RF CONNECTORS goBILDA ............................ 77, 98
BATTERIES/CHARGERS PoLabs W5SWL Electronics
Hitec Commercial Solutions Hammond Manufacturing ........ 36
EMBEDDED SYSTEMS ROBOTICS
BUYING ELECTRONIC Saelig Co. Inc. Hitec Commercial Solutions ...... 2
Electronix Express
SURPLUS Technologic Systems goBUILDA Keyways .................................. 77
Keyways ENCLOSURES Hitec Commercial Solutions Labcenter Electronics .............. 65
Hammond Manufacturing Pololu
CIRCUIT BOARDS LDG Electronics ....................... 47
Accutrace HAM GEAR TEST EQUIPMENT
ExpressPCB CQ Magazine DMMCheckPlus MadgeTech .............................. 23
COMPONENTS LDG Electronics Electronix Express Measurement Computing ....... BC
Electronix Express Pico Technology
KITS PoLabs ME Labs .................................. 14
Saelig Co., Inc. Dr. Duino Saelig Co., Inc. Pico Technology ...................... 63
DATA LOGGING Zeppelin Design Labs
MadgeTech TOOLS PoLabs .................................... 23
LCDs/DISPLAYS
Measurement Computing Saelig Co., Inc. PoLabs Pololu ......................................... 3
Pico Technology Saelig Co., Inc.
MICROCONTROLLERS / I/O Progressive Concepts ............. 77
DESIGN/ENGINEERING/ BOARDS TRANSFORMERS
REPAIR SERVICES Hammond Manufacturing Routakit ................................... 97
Dr. Duino
Accutrace ME Labs Saelig Co., Inc. ........................ 71
DLP Design Technologic Systems USB
ExpressPCB DLP Design Technologic Systems ............... 64
Labcenter Electronics MOTORS / MOTOR W5SWL Electronics ................. 77
CONTROL WIRELESS PRODUCTS
DEVELOPMENT goBUILDA Technologic Systems Zeppelin Design Labs .............. 45
96 2019/Issue-5
I
TAR FFS
NO

E D FOR
R
CLEASTOMS
CU
N

R
A
F

TA I W
OM

SAM / ITAR Registered I SO 9001:2015 UL Approved


Bring Your Pi to Work

Thermocouple Measurements on a Pi
The MCC 134 thermocouple measurement HAT provides best-in-class,
professional-grade accuracy. Up to eight MCC DAQ HATs can be stacked onto
one Raspberry Pi® allowing users to create multifunction DAQ solutions based
on this low-cost computer.

MCC 134 DAQ HAT


• Four thermocouple inputs
• 24-bit resolution
• 1 second update interval
• Supports most thermocouple types
• Complete SW library for easy programming
• Full set of examples in C® and Python™
www.mccdaq.com/DAQ-HAT

©2019 Measurement Computing Corporation, 10 Commerce Way, Norton, MA 02766 • info@mccdaq.com

You might also like