Professional Documents
Culture Documents
9001: 2015
14001: 2015
www.hitecnology.com
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
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
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. POSTMASTER: Send address changes to Nuts & Volts,
P.O. Box 15277, North Hollywood, CA 91615 or Station A, P.O. Box 54, Windsor ON N9A 6J5; 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
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)
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.
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.
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
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
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.
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.
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
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);
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
NEW
■ GADGETS
■ TOOLS
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
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.
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.
36 2019/Issue-5
See page 20 for the review.
By Ryan Gedminas
BUILD IT YOURSELF (high school student)
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
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)
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
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.
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
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.
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
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.
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:
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:
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.
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
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.
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.
Schematic 3.
68 2019/Issue-5
Figure 4.
ACTUONIX
R SERIES IOT WIFI WIFI
MICRO LINEAR ENABLED
ACTUATOR BUNDLE DEVICE
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.
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!
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
2019/Issue-5 77
For IoT Projects,
Call JSON
By Jonathan A. Titus
client.subscribe(“ValveCtrl”);
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”);
“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
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];
{?Humidity?:43,”TempC”:”22”,
”TempF”:71.6}
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!
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.
@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”
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.
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?
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?
E D FOR
R
CLEASTOMS
CU
N
R
A
F
TA I W
OM
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.