Nuts and Volts 2016 02 PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 68
At a glance
Powered by AI
The document describes several electronics projects including a decade box, wind speed tracker, and data logger. It also discusses components like the CSS555 timer IC and adding an analog front end to an Arduino.

Projects described include a decade box for selecting resistor values, a wind speed tracker using a Raspberry Pi, and a simple data logger for monitoring temperature.

The CSS555 is a micropower programmable version of the 555 timer ICs. It operates at low currents and voltages, making it well-suited for long-lasting battery powered projects.

Subscription Information

February ’16 Nuts & Volts — PO Box 15277


North Hollywood, CA 91615-9218
Call 877-525-2539 or go to www.nutsvolts.com
Subscribe • Gift • Renewal • Change of Info

24 Build a Digital Decade Box 34 The Remarkable CSS555


Having the right tool makes any job easier. Here is a The CSS555 is a micropower programmable version of
decade box where you can select the required resistance the 555 family of timer ICs. It operates at a current under
with a couple of switches — without having to go to the 5 μA and a supply voltage from 5.5V down to 1.2V. These
inconvenience of hooking up an ohmmeter to see the qualities make it particularly well-suited for long lasting
actual resistance value. battery and small solar powered projects.
■ By Roger Secura ■ By James Senft

28 Build a Fun Wind Speed 38 Why You Need an Analog


Tracker with a Raspberry Pi Front End and How to Set It Up
I’ve enjoyed tracking wind speed for years with my Davis The analog input to an Arduino Uno has a resolution of
weather station. However, the tiny plot on the station’s only 10 bits. On a 5V scale, this is only about 1 mV of
LCD screen is not very resolved and I want it to be a sensitivity. If you need more sensitivity, don’t look at
whole lot better. The solution: a Raspberry Pi! another microcontroller. Look at adding an analog front
■ By David Goodsell end to your Arduino.
■ By Eric Bogatin

08 Q&A 55 Practical 3D Printing


Reader Questions Answered Here Real World Uses for Electronics Experimenters
Questions on Cat-5 cabling are answered, plus the Breadboard Base with Sidecar Supports
mysteries of electronic filters are explained. I almost always test out my circuit designs on a
breadboard. Unfortunately, there are many times I’ve
connected to a board that doesn’t plug into a breadboard,
14 PICAXE Primer so the only thing holding it together was the connection
Sharpening Your Tools of Creativity wires. Connection wires as the only support makes
Building a Simple Data Logger projects difficult to move around. This 3D printed
Implement a simple 08M2 based data logger that breadboard base with sidecar supports makes projects
monitors and records the real time temperature of a portable.
backyard grill.

58 Open Communication
46 The Design Cycle The Latest in Networking and
Advanced Techniques for Design Engineers Wireless Technologies
ARMed and Dangerous The Internet of Things. Who Needs It?
If you’ve ever written code for any other microcontroller, Now that it’s so easy to connect almost every sort of
you can write code for an ARM microcontroller. This device or product to one another or to a human via the
month, we’ll ARM ourselves with some top-notch tools Internet thanks to the Internet of Things, should we stop
from Segger and load up an STMicroelectronics’ and think about whether just because we can do
STM32F0308-DISCOVERY with the code we write. something we should?

52 Near Space
Approaching the Final Frontier
05 DEVELOPING
Departments 23 SHOWCASE
North American/Guatemala Near Space Alliance PERSPECTIVES
Near space encompasses the entire planet. Therefore, it’s 45 ELECTRO-NET
Leaded Components:
not surprising to hear that amateur radio operators in Reports of their death 61 CLASSIFIEDS
other nations are running their own programs. When an have been greatly 62 NV WEBSTORE
exaggerated.
amateur radio operator from Guatemala asked for help in 64 TECH FORUM
07 READER FEEDBACK
kicking off his first launch, the near space community 22 NEW PRODUCTS 66 AD INDEX
couldn’t resist but help out.
Nuts & Volts (ISSN 1528-9885/CDN Pub Agree #40702530) is published monthly for $26.95 per year by T & L Publications, Inc., 430 Princeland Court, Corona, CA 92879. 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.

4 February 2016
Published Monthly By
T & L Publications, Inc.
430 Princeland Ct.
Corona, CA 92879-1300
(951) 371-8497
FAX (951) 371-3052
DEVELOPING
PERSPECTIVES
by
Bryan
Bergeron,
Editor

Webstore orders only 1-800-783-4624


www.nutsvolts.com
Leaded Components:
Subscription Orders
Reports of their death have
Toll Free 1-877-525-2539 been greatly exaggerated
Outside US 1-818-487-4545
P.O. Box 15277
North Hollywood, CA 91615

FOUNDER
I ’ve been reading and writing about
the imminent demise of leaded
components for decades. Even so, at
And forget the magnified desk
lamp — I have to don a Bosch &
Lomb stereo magnifier and get my
Jack Lemieux least half of my work still involves nose within inches of the board to
PUBLISHER leaded components. After all, what’s see what’s going on.
Larry Lemieux not to like? Leaded components are One sneeze, of course, and
publisher@nutsvolts.com
easy to work with. It’s easy to every SMT component not glued or
ASSOCIATE PUBLISHER/ identify the value of a leaded resistor soldered down will be forever lost in
ADVERTISING SALES
Robin Lemieux
or capacitor with the naked eye, and the dust balls behind my workbench.
robin@nutsvolts.com leaded components are readily I know that experimenters aren’t
EDITOR
available. alone in the battle between SMT and
Bryan Bergeron Besides, I’ve already committed leaded components. I routinely tear
techedit-nutsvolts@yahoo.com the band values — red for two, down equipment for both fun and
VP OF OPERATIONS orange for three, yellow for four, etc. profit, and it’s unusual to find an
Vern Graner — to long-term memory. Then, there’s electronic device devoid of leaded
vern@nutsvolts.com the muscle memory of how to bend components.
CONTRIBUTING EDITORS leads and how to work a soldering Many of the inexpensive devices
Fred Eady Tim Brown iron tip around the porcupine-like made in China — from drone
Paul Verhage Chuck Hellebuyck
Ron Hackett Lou Frenzel
mass of leads when the component controllers to electronic measuring
James Senft Eric Bogatin side is down. devices — are made with a mystery
Roger Secura David Goodsell Why let all that learning go to chip embedded in a black epoxy
waste? blob that is surrounded with leaded
CIRCULATION DEPARTMENT
subscribe@nutsvolts.com I don’t know what I would do capacitors and resistors.
without a good supply of 1/4 watt This is understandable, given the
SHOW COORDINATOR
Audrey Lemieux 10K leaded resistors to use as circuit cost of converting an electronics
probes. When I’m working with an assembly plant from leaded to SMT
WEBSTORE MARKETING
Brian Kirkpatrick
Arduino or other microcontroller devices. Unless you’re building
sales@nutsvolts.com board, it takes only a few seconds to iPhones or electronic watches, why
WEBSTORE MANAGER
wire-wrap a 10K pull-up or pull-down upgrade an assembly plant unless
Sean Lemieux resistor to an I/O pin. Try that with a you have to?
sean@nutsvolts.com surface-mount (or SMT) resistor. The bottom line is that if you’re
Then, there’s the differential in just getting into electronics, don’t be
ADMINISTRATIVE STAFF
Re Gandara infrastructure cost and workbench dismayed — or distracted — by the
real estate. For leaded components, I world of SMT. A traditional
Copyright © 2016 by T & L Publications, Inc. have a simple Weller temperature perfboard, a good supply of leaded
All Rights Reserved
All advertising is subject to publisher’s approval. We
controlled soldering iron, good old- components, and a few schematics
are not responsible for mistakes, misprints, or fashioned needle-nose pliers, and to work from will get you started.
typographical errors. Nuts & Volts Magazine assumes desk lamp magnifier. When you’re ready to make your
no responsibility for the availability or condition of
advertised items or for the honesty of the advertiser. For surface-mount work, I have a circuit semi-permanent, then break
The publisher makes no claims for the legality of hot air station that has the footprint out your soldering iron or wire wrap
any item advertised in Nuts & Volts. This is the sole
responsibility of the advertiser. Advertisers and their
of an oscilloscope, a tool drawer full tool. SMT components, the special
agencies agree to indemnify and protect the publisher of tweezers and stainless steel picks, boards, pastes, and the rest will be
from any and all claims, action, or expense arising from and a half dozen containers of there if you ever need them. NV
advertising placed in Nuts & Volts. Please send all
editorial correspondence, UPS, overnight mail, and
various solder pastes and fluxes.
artwork to: 430 Princeland Court, Corona, CA 92879.
February 2016 5
www.poscope.com/nv

6 February 2016
READER FEEDBACK
Testing Your Metal issue compiling the code for the ToY another problem. The problem is the
Referring back to the August project. ESP8266 developers changed the
2015 Developing Perspectives Not only did the Arduino IDE WiFi.SSID() function from returning a
column about replacing old non- code change from version 1.6.5 to pointer to character to returning a
polarized plugs/cords. I've also had 1.6.6 causing the first issue, the string. Luckily, the fix in my code is
to do this a number of times. If the ESP8266 code changed from version simple.
device is all plastic on the outside, I 1 to version 2 which introduced Continued on page 61
don't worry about it; if it is metal, I
first make sure no AC line is in
contact with the metal case. If that is
the situation, then just go ahead with
the replacement. Otherwise, find the
# " "
problem. Or, if there is no "problem,"
then make sure the common wire
(white) is connected to this
! " !    
connection. That should help it be a    
 
little safer.
Phil KE3FL 
   
    A7>64A867,6?9A9=4.><A
DCBA@?>=><;A:987>65684>A=4>67A@46<3?=A821 $$A3ADA>3>7<A2+A
Just a Fraction Off 0?3/A.?-?.>7<A=2936?9<ABA?9=/A4>9,3/<A2+A*A />6-A.3A'"&A;;A
A reader spotted an error in .?++>7>93A.?6)>3>7<( 846=5A<@?764A076@A38?9,A
Figure 2 of my January 2015 Ham’s 69.A6A0?7>%,?.>A3224A
D'D*&A%AC*A@=<
3/63A)65><A?3A>6<A32A
Wireless Workbench column. The $'$#&A%A$CA@=<
076@A3/>A38?9,A
dimension "1/2 wavelength" should be D'"&A%A#"A@=<
6729.A647>6.A=299>=3>.A=684><;A69A8>
"1/4 wavelength." Sorry about that! $'D*&A%AD"A@=<
>6<?4A=3A32A69A4>9,3/;A>44<A>4<>0/>7>
D'B&A%A!A@=<
Ward Silver 29%4?9>A69.A?9A<327><A+27A#B;!CA27A)27>;

 
$'"&A%A"A@=<



)('&%"
)('&%$#"! 
Watch This  
Regarding Bryan Bergeron’s
recent editorial on magnetics and    
watches, I have observed that the .>64A+27AA/288?<3<;A 7?,/3AC))A729.A
<A0'A8?43%?9A7><?<327<A
tiny spring's windings can be 299>=3A@A32A3/7>>A<>7-2<A +27AD#.=A 2A>13>7964A7><?<327A7>?7>.;AA
<?)4369>2<4A32A3><3A69.A 275<A0>44A29AB%D#.=;AA?))>7A63A420>7A
touching each other when =2)@67>A<@>>.A69.A7>6=3?29A -2436,><;A63>7%=4>67A?9A2++%<363>;
magnetized. This shortens the spring 3?)>A0?3/23A<>A2+A3769<)?33>7'7>=>?->7; ) #%) )('&
somewhat, which results in the watch 20>7A?9@3AB;"%*A.=;A



A AA>. AA"
gaining time. Increased friction at this D;$&A1AD;D&A1A;C&A/?,/;AA   :
AAA A?45%0/?3> AAAA AA" 
point could counter it a bit. )('&#'"  
A AAA/?3>AAAA AAAAAA" AAA


AA7>>9 AAA AAAAA" AAA


Open the watch and observe. 
A AAA63>7%=4>67AAAA AA"AAA
Duco Weytze  :
AAA A63>7%=4>67AAAA AA" 

 
AD!))A0?.>A+<>;A  !

79A29>A+<>A<423A?932A   ! 
TOYing with Buggy Code 302A0/?4>A@72-?.?9,A
If you are having trouble @723>=3?29A+27A823/A=?7=?3<;A
compiling the code from my article in 72-?.><A6A<>=29.A<423A69.A6A/23A4?9>A0?3/   
the November 2015 issue on the 69A?9%4?9>A83%<@4?=>A=7?)@A=299>=327;
TOY project, I have isolated the
problem to the new 1.6.6 version of
)('&#("' 
 

the Arduino IDE for Windows.
It seems there is a bug in that 
version of Arduino which is causing   
the problems. The solution is to go ?9,<329A%#A$C;A >04>33A6=567.A C#DDAA: A A

back to version 1.6.5 and the )('&#" :;A369.67.ADBA5>A5>8267.;AD"&A1A*;C&;



  : A=299>=327A29A*A=684>;A 

 
problems all go away.
  
 )('&% "!
However, I identified another 

February 2016 7
■ WITH TIM BROWN
Q&A
In this column, Tim answers questions about
all aspects of electronics, including computer
• Cat-5 Cabling
hardware, software, circuits, electronic theory,
troubleshooting, and anything else of interest to
• Electronic Filters Explained
the hobbyist. Feel free to participate with your
questions, comments, or suggestions. Send all
• Mailbag
Post comments on this article at www.nutsvolts.
questions and comments to: Q&A@nutsvolts.com. com/magazine/article/february2016_QA.

Cat-5 Cabling can be hooked up as TIA 568A or TIA 568B in either

Q
AT&T U-verse uses a four-pair Cat-5 cable straight through, rollover, or cross-over configurations (see
between its gateway and set top box. Are all Figure 1).
four pairs in use for the TV service? I'd like to These pairs of wires have tight twists to ensure a level
break out one pair to serve as a regular phone of resistance to crosstalk and interference. Changing this
jack. I do not have AT&T's IP phone service but just a twist such as when installing the RJ45 plug is a hot topic in
regular wire line phone. the networking field, so you don't want to change this
— Art Wiegand twist unless absolutely necessary. Recommendations
essentially are don't untwist more wire than is required to

A
Category 5 cabling uses unshielded twisted wire fit in the plug, which is about 1/2 inch for RG45 plugs and
pairs to reduce the effects of crosstalk and receptacles. Untwisting more wire than necessary will
interference without using shielding as is utilized leave your installation subject to crosstalk and interference
in coaxial cables to reduce costs and simplify which can greatly reduce data rates.
installation (it is a lot easier to crimp RG45 plugs onto In case you want to run a phone line from the
cables than to attach connectors to coax). Category 5 Network Interface Device (NID) instead, I found an
cabling has four sets of unshielded twisted pairs arranged excerpt from the AT&T U-verse Forum web page on how
by color groupings (color and white with color stripe) to hook up U-verse Cat5 cables from the NID (the box on
using the colors green, orange, blue, and brown, which the outside of a residence which hooks your home to the
telco's network) to the Residential Gateway (RG;
■ FIGURE 1. the "modem" box inside the residence which
splits signals to user devices) at
https://forums.att.com/t5/U-verse-2014-
Archive/what-2-wires-from-cat-5-go-to-the-
outside-nid-box/td-p/3536669. According to the
site: "Traditional phone pairs used by U-verse
techs are blue pair line 1 phones, orange pair
for line 2 phones, green pair for U-verse. If this
is Internet only in the house, use either blue or
green pair; if you planning on using POTS or
VOIP, we recommend using green pair."
Now, for your specific question about Cat5
cabling from the RG to the Set Top Box (STB); I
will use my U-verse equipment as an example (I
only have a standard phone line and Internet
service, so I use one Ethernet port for the
computer, and wireless for laptops and
smartphones). My Motorola NVG510 RG has
cable receptacles for phone lines 1 and 2, DSL
broadband input, and five Ethernet outputs —
plus wireless capability. Below is a list of the
standard Ethernet Cat5 connector pin
assignments. Ethernet cable pin assignments
(TIA 568A/B cables) do not use blue and
brown pairs:
8 February 2016
QUESTIONS and ANSWERS

1: Data (TX +)
2: Data (TX -)
3: Data (RX +)
4: Ground (-)
5: Ground (-) ■ FIGURE 2.
6: Data (RX -)
7: Power (+) active (use inductors, capacitors, and resistors along with
8: Power (+) transistors or operational amplifiers).
Before I discuss filters, let's go back and look at the
Your STB most likely has an external power basics: resistance, capacitive reactance, and inductive
connection, so you are probably not using Power Over reactance. Resistance is the opposition to the flow of
Ethernet (POE). Theoretically, the wires hooked to pins 7 electrical current regardless of the signal's frequency from
and 8 could be used as a phone line pair and — if your DC to the maximum signal frequency. Capacitive
RG does not use the Ethernet grounds — you could use reactance is the opposition to the rate of change of the
pins 4 and 5 also. As for me, I would not disturb the voltage of a signal. Capacitive reactance is a function of
Ethernet cable for just one pair and risk degrading my the capacitance and the frequency of the signal, XC =
network speed and reliability. 1/(2πfC), where XC is the capacitive reactance, f is the
I am assuming that you have a Cat5 cable with RJ45 signal frequency, C is the capacitance, and π is the
plugs on each end (plugged into the receptacles on the number 3.1417.
RG and STB), so you would have to "cut into" the cable to Inductive reactance is the opposition to the rate of
access the pairs. Regular phone cable is cheaper than new change of the signal current, XL = 2πfL, where XL is the
Cat5 cables (about $2 for a 20 foot phone cable with RJ1 inductive reactance and L is the inductance. In theory, this
plugs installed, versus $6 for Cat5 with RJ45 plugs if you is simple. In the real world, however, all electronic
damage the Cat5 cable in the process), so I would leave components have varying degrees of resistance,
the Cat5 cable alone. capacitance, and inductance, so all three opposing entities
Another option — if there is no phone receptacle are present in all device components. Resistors are
already in the room — is to use a wireless phone which designed to minimize capacitance and inductance;
will hook to your regular phone line and transmit the capacitors are designed to minimize resistance and
phone signals throughout the house (cuts down on inductance; and inductors are designed to minimize
crawling under the house to replace old phone cables resistance and capacitance.
which at this stage in my life is no longer fun). Let’s look at passive signal filters first. Looking at the
equations above, we can deduce that for a pure
The Mysteries of Electronic Filters resistance, opposition to a signal is independent of
frequency so it passes all signals equally. For a pure
Explained capacitor, the capacitive reactance decreases with
increasing frequency. So, a capacitor will pass higher

Q
Could you explain how an electrical signal filter frequencies better than it will pass lower frequencies
works? (capacitors will block DC or 0 Hz signal frequencies). For
a pure inductor, the inductive reactance increases with
increasing frequencies. So, an inductor will pass lower
— Jodie Pokabla frequencies better than it will pass higher frequencies
Dearborn, MI (inductors will pass a DC signal unattenuated).
Figure 2 shows the schematic diagrams for simple low

A
Signal filters for electronic
devices are used to allow certain
frequencies to pass (bandpass Q&A SIDELINES
filters — BPF), block higher Cat-5 Cabling
https://forums.att.com/t5/U-verse-2014-Archive/what-2-wires-from-cat-5-
frequencies (low pass filters — LPF), block go-to-the-outside-nid-box/td-p/3536669
lower frequencies (high pass filters — HPF),
block certain frequency bands (band The Mysteries of Electronic Filters Explained
rejection filters or notch filters — BRF), or http://sim.okawa-denshi.jp/en/Fkeisan.htm
pass all frequencies (all pass filters — APF). www.changpuak.ch/electronics/Butterworth_Bandpass_active.php
Filters can also be classified as passive (use www.calculatoredge.com/electronics/ch%20pi%20low%20pass.htm
only inductors, capacitors, and resistors) or http://t-filter.engineerjs.com
February 2016 9
■ FIGURE 3. ■ FIGURE 5.

■ FIGURE 4. Voltage is easier to measure (most


amplifier gain is specified as voltage
gain), so, R is the value of circuit
resistance, C is the value of circuit
capacitance, and L is the value of
circuit inductance. The phase shift for
the RC circuit is ϴ = -arc tan(2ΠfRC);
pass filter circuits using a resistor and capacitor (RC filter) for the LR circuit, the phase shift is ϴ = -arc tan(2ΠfL/R).
or a resistor and an inductor (LR filter). Figure 3 shows the Arc tan is the arc tangent function found on
signal versus frequency response (Bode Plot) of a low pass spreadsheets and scientific calculators. I have shown the
filter. phase shift characteristics of the filter circuits to illustrate
At the cutoff frequency for the RC filter, R = XC. For that the output signal's phase will be changed relative to
the LR, R = XL. The cutoff frequency for the RC LPF is fC = the input signal phase around the cutoff frequency, in case
1/(2ΠRC), and the voltage gain (Vout/Vin) is AV = maintaining signal phase relations is important to a design.
1/(2ΠfC(SQRT(R2 + (1/(2ΠfC)2)))). For the LR LPF, the Figure 4 shows the schematic diagrams for simple
cutoff frequency is fC = R/(2ΠL) and the voltage gain high pass filter circuits using a resistor and capacitor (RC
(Vout/Vin) is AV = R/(SQRT(R2 + (2ΠfL)2)). Where fC is the filter) or a resistor and an inductor (LR filter). Figure 5
frequency at which the mid range signal level is reduced shows the signal versus frequency response of a low pass
by 70.7 percent or three decibels [Voltage Gain in dB = filter. The cutoff frequency for the RC HPF is fC =
20log10(Vout/Vin), the decibel gain can be defined using 1/(2ΠRC) and the voltage gain is AV = R/(SQRT(R2 +
the power ratio as 10 log10(Pout/Pin) because the number is (1/(2ΠfC)2))). For the LR HPF, the cutoff frequency is fC =
the same since power is proportional to voltage squared. R/(2ΠL) and the voltage gain is AV = 2ΠfL/(SQRT(R2 +
(2ΠfL)2)). The phase shift for the RC
circuit is ϴ = arc tan(1/(2ΠfRC)) and
for the LR circuit, the phase shift is ϴ =
arc tan(R/2ΠfL). Sorry about all of the
parentheses in these equations, but
that is the way equations are
presented for entry into a spreadsheet
or programmable calculator.
■ FIGURE 6. High pass and low pass filters can
be used to modify the lower and
10 February 2016
MAILBAG
Re: Furnace Data Acquisition letters except for C which has a black wire (usually).
In the August 2015 issue, you gave several ideas to Thanks for giving us insight from a different
Edward Ganshirt on how to go about monitoring a perspective.
furnace. You were focused on using a current sensor to
interface with a high voltage motor wire inside the Re: Automotive Battery Amp-Hour Capacity at Slow
furnace. I just wanted to point out that the low voltage Discharge
lines of the thermostat are another option, and no current I enjoyed the November 2015 Q&A question on the
sensor would be needed. automotive battery amp-hour. Can you add the golf cart
The thermostat wires offer the additional benefit of battery to this discussion? Many of us RVers use a golf cart
being available both inside the furnace and at the actual battery for house batteries for a couple of reasons: (1)
thermostat, in case someone wanted to build a nice device They are usually less expensive; and (2) The house
showing live data on an LCD. batteries don't need to be short time/heavy discharge
automotive batteries. Other than that, I don't know exactly
Judy May W1ORO, Union, KY how they compare between auto and deep cycle (more
expensive) batteries.
Judy, looks like you caught me in an Einstellung Bob Smith, Prescott, AZ
moment where I just looked at the method proposed in
the questions and not a better solution. I am excited about Batteries used in Recreational Vehicles (RVs; a.k.a.,
receiving information from you because we need more house batteries) are similar to the batteries used to crank a
women involved in the field of electronics (I taught at a vehicle (a.k.a., chassis batteries or starting batteries). The
community college for 23 years and that was the case exception is RV batteries are designed for deep discharge
throughout our state). The fact that you are a ham radio at a relatively low current draw for extended periods of
operator shows a real love of electronics. time while they power the appliances and other devices
Using the thermostat contacts would be a better inside the RV. RV batteries operate without being
solution since they are easily accessed inside the residence immediately recharged as is the way starting batteries are
and safer since they use a lower voltage. An HVAC operated.
thermostat operates using 24 volts AC derived from the RV batteries are rated in amp-hours (Ah — roughly
HVAC unit line power via a transformer. Figure A shows time of useful operation at a given current draw) and
the wiring of an HVAC thermostat with my idea for reserve capacity (RC — number of minutes at 80 degrees
reading the heating and cooling contact closures with a Fahrenheit that the battery can deliver 25 amps until it
microcontroller such as a PIC, Atmel, or Arduino. The drops below 10.5 volts) instead of cold cranking amps
voltage in the thermostat is 24 VAC, so you need a couple (CCA) as is specified for starting batteries which are
of bridge rectifiers to convert to DC; a couple of capacitors immediately recharged. A 12 volt group 24 RV battery
to smooth the ripple; and a couple of 7805 three-pin provides 70 to 85 Ah. Wiring two batteries in parallel will
voltage regulators to convert the final output to 5 VDC for double the Ah, but you must be careful that the batteries
input to the microcontroller. supply current equally to the load.
Once you have the signal to the microcontroller, it can Two of the larger six volt golf cart batteries wired in
be used to log on/off times, calculate usage rate, etc. Be series can be used in place of the RV battery (provided
aware that some thermostats do not have the "C" ground, there is sufficient space) to provide 180 to 220 Ah. As in
while others used in heat pumps have W2 for secondary all rechargeable lead acid batteries — in most cases — RV
heat, and O and B for reversing valves. The wiring colors batteries fail due to overcharging (poor regulation of the
(red, green, yellow, orange, blue, and white) match the alternator causes water loss and plate deterioration) and
undercharging (repeatedly deeply
discharged without fully recharging or
leaving for months without charging —
solar trickle chargers are a good
investment for RVs that are not used
frequently enough to keep the
batteries charged).
Battery life is dependent upon
how deeply the battery is discharged
before recharging (a battery
discharged to 50 percent before
■ FIGURE A. recharging will last twice as long as a
battery discharged to 80 percent
before recharging).

upper ranges of signals, respectively, such as an audio audio frequency function generator as shown in Figure 6
signal. Try to envision how you could use the LPF and HPF to measure the frequency responses of the LPF and HPF
to modify the bass and treble portions of an instrument circuits on sine signals (30 to 1,000 Hz for LPF and
signal. For an experiment, use an oscilloscope and an 10,000 to 15,000 Hz for HPF).
February 2016 11
■ FIGURE 7. dividing the Vout on channel 2 by the
Vin on channel 1 for several
frequencies and use the results in a
spreadsheet to draw the Bode Plot.
You can measure the phase shift
by connecting Vin to the vertical
channel (one of the normal inputs)
■ FIGURE 8. and Vout to the horizontal channel (sometimes called X or
sweep), and then determine the phase difference from the
resulting Lissajous figures. By substituting potentiometers
for resistors, you can vary the frequency response of these
filters. Any readers out there who are interested, send me
your results and I will try to publish as many as possible.
If there are simple filter circuits, then there are
complex filter circuits. If one filter is good, then adding a
second filter should be twice as good, right? In reality, two
cascaded RC LPFs make the system better than twice as
good. Figure 7 shows the cascaded low pass filter and
Figure 8 shows frequency response curves for the simple
(in blue) and two cascaded (in purple) RC filters which
demonstrate the cascaded filter's cutoff frequency is lower,
and the slope of the "roll off" portion of the curve is
steeper (sharper filter). By adding additional cascaded RC
LPF filter stages, the roll off slope can be made even
steeper, which brings us closer to an ideal filter in which
the roll off portion would be straight up and down.
In reality, adding filter stages can produce
■ FIGURE 9.
predictability problems since each cascaded stage affects
the other stages (this is beyond the scope of Q&A to
cover, but there are many engineering texts dealing with
this aspect of filter design). The cutoff frequency for the
two-stage cascaded RC LPF is fC = 1/(2Π
SQRT(R1C1R2C2)).
If cascading two RC LPF gave us a sharper frequency
response, what about cascading an HPF with an LPF?
Figures 9 and 10 show this arrangement and the
associated frequency response curve. You can easily see
that this filter has both high and low cutoff frequencies,
but it allows frequencies between these two to pass. Thus,
it is called a bandpass filter. The two cutoff frequencies
are: fH = 1/(2ΠR1C1) and fL = 1/(2ΠR2C2). The center
frequency is fCENTER = SQRT(fHXfL). The phase response
can be calculated from ϴ = arc tan((f/( fH - fL))(f/fCENTER -
fCENTER/f)).
For the BPF, we define the bandwidth as BW = fH - fL
and the quality factor Q = fCENTER /BW, or Q is the circuit
reactance divided by the circuit resistance. The bandwidth
■ FIGURE 10.
is inversely proportional to Q; as Q increases, the
bandwidth decreases. So, by decreasing the circuit
resistance, you can decrease the bandwidth. BPFs are
CAUTION: Use isolation transformers on the used to eliminate unwanted signals, while allowing wanted
generator and o-scope to avoid shock hazards and short signals such as audio or television signals.
circuits that can damage your expensive equipment. If Band Rejection Filters (BRF) are also known as notch
your o-scope will do ratios, the gain calculation is filters or band stop filters, and are used to eliminate
simplified. Otherwise, you can calculate the gain by unwanted signals such as a nearby FM radio station that
12 February 2016
■ FIGURE 11.
■ FIGURE 12.

interferes with the station you wish to listen to. Figure 11


shows a twin T band stop filter schematic and Figure 12
shows the frequency response curve for the twin T.
The BRF frequency response is like an inverted version
of the response for the band pass filter. The center
frequency for the twin T is fCENTER = 1/(2ΠRC) and a eliminates loading effects which can change the tuning of
bandwidth of BW = 2/(RC). The twin T is actually a high the filter. Figure 13 shows the schematic of an active
pass filter (C2, C3, and R3) in parallel with a low pass filter multiple feedback band stop filter and Figure 14 shows
(R1, R2, and C1) where the notch is created by the this filter's frequency response. The center frequency of
combined parallel resonances of these two filters which the circuit is fCENTER = 1/(2ΠSQRT((1/R4C2)(1/R1+1/R2)))
produces a high impedance to the signal in the stop band. and band width is BW = 2/(R4C), where the gain of the
Sometimes the BRF is used to eliminate power line op-amp G = -(R6/R3). By adjusting the op-amp gain, you
frequencies in audio systems. can easily adjust the notch bandwidth.
So far, we have looked at passive filters which have no All Pass Filters (APF) provide equal gains for all input
active elements (transistors or amplifiers). By adding an signals over a range of frequencies (flat frequency
active element such as an operational amplifier (op-amp), response) by phase shifting the various frequencies in a
the filter can be built without inductors, which are large at predictable manner. The APF can be used as a delay
low frequencies and are difficult to implement in an equalizer or phase corrector. Figure 14 shows an active
integrated circuit. The active filter bandwidth and center APF and the phase delay produced by this filter. APFs are
frequency can be controlled by varying resistors; the used in audio system reverberation units and speaker
output of the filter is greater which helps subsequent crossovers.
stages, and the filter is isolated from the load which I have left out a lot of filters such as Butterworth,
Chebyshev, Bessel, Pi, L, Surface Acoustic Wave
(SAW), multi-pole, Sallen Key, etc. Also, I have
not covered a lot of filter design in the form of
Laplace transforms, transfer functions, and
■ FIGURE 13.
impulse response, which are the subjects of
college engineering classes. See Q&A
SIDELINES for online filter calculator websites.
NV

■ FIGURE 15.

■ FIGURE 14.

February 2016 13
PICAXE PRIMER ■ BY RON HACKETT
www.jrhackett.net

Building a Simple Data Logger


As I mentioned in the previous installment
of the Primer, this time we're going to
far beyond the operating range of both the DS18B20 and
continue our exploration of the FRAM the MCP9700A. The obvious solution is to use a
thermocouple sensor. Some thermocouple sensors are
breakout board that we experimented with capable of measuring temperatures in excess of 2,000°F,
last time (Adafruit.com product #1895), and and many inexpensive units can easily handle 900°F and
higher.
implement a simple 08M2 based data Similarly to thermoelectric coolers, thermocouple
sensors are based on the “Peltier effect,” but they function
logger that monitors and records the real in a “reverse” manner. In a thermoelectric cooler, a DC
current flows through the junction of two dissimilar pieces
time temperature of a backyard grill. of metal, causing the temperature of one piece of metal
(outside the cooling chamber) to increase, and the
However, before we get into the details of temperature of the other piece of metal (inside the
cooling chamber) to decrease. A thermocouple sensor
our current project, I think a little also contains a junction of two dissimilar metal wires, and
applying heat to this junction causes a minute current flow
background information will be helpful.
that’s proportional to the temperature of the heat source.
These sensors are available in several different “types”
t’s probably an understatement to say that I’m a bit of a which are distinguished by the two specific metal alloys
I backyard grilling and smoking enthusiast. My wife would
probably say “fanatic” since I do own a half dozen or so
used in the sensor.
The problem, however, is that thermocouples require
grills and smokers (she may be right!). an extremely sensitive analog amplifying circuit to provide
For quite a while now, I’ve been thinking about how I accurate readings. Until recently, thermocouple amplifiers
would go about developing a temperature control system have been somewhat expensive and slightly complicated
for one of my kamado grills. For readers who aren’t to use in a PICAXE project. However, just recently, I was
obsessed with charcoal grilling and smoking, kamados are once again searching for a thermocouple amplifier, and I
among the most versatile backyard cookers available found a new one at Adafruit.com that was exactly what I
(IMHO), primarily because they are capable of needed to get started (see Figure 1). All the surface-mount
maintaining a cooking temperature anywhere from 70°F or parts are pre-soldered, so it’s only necessary to install the
80°F, to well over 800°F! In case you’re wondering what two-pin screw terminal for the thermocouple sensor wire
anyone in their right mind would want to cook at those and a four-pin male header for inserting the amplifier into
extreme temperatures, 70°F or 80°F is ideal for cold- a breadboard.
smoking items like salmon or cheese, 225°F is perfect for The Adafruit thermocouple amplifier board is based
slow-smoked baby back ribs, and commercial pizza ovens on the AD8495 K-type thermocouple amplifier from
often operate at temperatures as high as 900°F! Analog Devices; it outputs an analog voltage signal, so it
Until now, two major problems have prevented
me from actually getting started on a grill/smoker
temperature control project: one is hardware
related, and the other is software related. We’ll get
to the software problem before we’re finished this
month, but let’s start with the hardware problem
which is related to temperature sensors. The two
sensors that we’ve used so far (DS18B20 and
MCP9700A) both max out at 257°F, so they
certainly aren’t usable when baking a pizza. Even
the usual grilling temperature of 450°F to 550°F is ■ FIGURE 1. AD8495 thermocouple amplifier board (front).
14 February 2016
SHARPENING YOUR TOOLS OF CREATIVITY

■ FIGURE 3. Thermocouple probe.

■ FIGURE 2. AD8495 thermocouple amplifier board (back).

only requires one pin for interfacing. The board is so easy


to use that a manual isn’t even required. All the necessary
information is printed on the back of the board (see
Figure 2). We’ll get into the details when we begin our
experiments this month, but there’s one thing I want to
mention at this point.
Because the board provides an analog output,
interfacing it with a PICAXE processor is almost identical to
the MCP9700A based temperature measurement project ■ FIGURE 4. Thermocouple connector pair.
we covered back in the December 2012 issue of Nuts &
Volts. As a result, if you have no interest or need to The AD8495 printed circuit board (PCB) can be used
monitor any temperatures higher than 257°F, you can with any K-type thermocouple sensor. This type of sensor
easily substitute an MCP9700A sensor for the AD8495 is readily available on the Internet, but I chose one from
board and thermocouple sensor in any of this month’s Auber Instruments (see Figure 3 and Table 1) because its
experiments. The only software change would be to edit physical dimensions suited my requirements and it can
the portion of the software that converts raw ADC (analog- measure up to 900°F, which is sufficient for my
to-digital converter) input to degrees Fahrenheit, so that it application. The Auber thermocouple comes with two
matches the one we used in the original MCP9700A standard spade connectors that can easily be removed, so
project. Also, the techniques we’ll be using to record and the probe can be directly connected to the Adafruit
display data can be readily applied to just about any data thermocouple amplifier board.
logging project you may want to implement. However, when I ordered the probe, I also ordered a
pair of thermocouple connectors — one of which is a
Table 1. Product # Source female panel-mount connector (see Figure 4 and Table 1)
because I plan to eventually mount the electronics inside
2
I C Non-Volatile FRAM
Breakout Board — 256 kBit 1895 adafruit.com a plastic project box. Also, the male connector fits into the
(32 kByte) standard female connector on one of my multimeters, so I
K-Type Thermocouple can use the probe that way as well.
Amplifier Breakout Board 1778 adafruit.com
(AD8495)
K-Type Thermocouple Probe
Experiment 1: Using a Thermocouple
for Smoker or Oven TC-K3MM auberins.com to Measure Temperature
(max 900°F)
In this experiment, we’re simply going to test the
Thermocouple Connectors, thermocouple interface to make sure it’s functioning
Connectors auberins.com
Male and Female correctly. The schematic for the experiment is presented in
February 2016 15
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/article/february2016_PICAXEDataLogger.

for this month’s Primer, and print a copy of the


ThermoTest.bas program for reference.)
Let’s begin with the conversion of the 10-bit ADC
value that’s input from the AD8495 board. As you can see
in the program listing, we’re using the 08M2’s internal
fixed voltage reference (FVR) for the readadc10 command.
We used the FVR back in the December 2012 column
with the MCP2700A temperature sensor in a battery-
powered system, so I won’t repeat all the details here.
(You may want to re-read that article before proceeding.)
In the earlier article, we were using a three-cell
alkaline battery pack, so we used an fvrsetup FVR2048
■ FIGURE 5. command to configure the ADC reference voltage at
Schematic for
Experiment 1. 2.048V. This time, we’re going to use a +5V supply so we
can configure the reference voltage at 4.096V, because
our supply voltage will never be lower than the reference
voltage. As you know, a 10-bit ADC reading can have any
one of 1024 values. This means that each ADC step is
equivalent to an increase of 4 mV because 4 mV * 1024
steps = 4.048V, which is our reference voltage. This makes
the conversion from the ADC reading to mV simple. Using
the variable names defined in the ThermoTest.bas
program:

mVolt = 4 * ADCval

Now, let’s focus on the millivolt to Celsius conversion.


As I mentioned earlier, all the documentation we need is
printed on the back of the AD8495 board, so we’ll start
with the temperature formula that’s printed on the back:
Vo — 1.25
T = (Vo — 1.25)/5 mV =
5 mV

In the above equation, the two terms in the numerator


are in volts, but the denominator is in millivolts. That’s a
little confusing and we can’t work in volts anyway, so let’s
■ FIGURE 6. Breadboard setup for Experiment 1. re-write the above equation so everything is in millivolts:
mV — 1250
Figure 5. As usual, it doesn’t include the standard PICAXE T=
programming circuit, so, of course, you will need to 5
include it to download the program. My breadboard setup Next, we multiply the top and bottom of the fraction
is shown in Figure 6. As you can see, it’s really simple. by 2 (we’ll soon see why!):
There are only two points I want to mention. First,
there’s no need to ground both the AD8495 ground pins; T = mV — 1250 * 2 = 2 mV —2500
just connect either one of them to ground. Second (and 5 2 10
more important), the two thermocouple leads are
polarized. Make sure you observe the correct polarity At this point, we have the following equation:
when connecting them to the AD8495. (The red lead is
2 mV — 2500
generally the positive lead, but check the documentation T=
for the thermocouple you use to be sure.) 10
The software for this experiment (ThermoTest.bas) is
also simple, but some of the conversion computations are If you refer back to the “documentation” on the back
not. So, let’s take a look at them. (Before continuing, you of the board, you will see that the variable “T” is in
may want to go to the article link, download all the files degrees Celsius. However, don’t forget that we can’t
16 February 2016
directly compute a result like 22.6°C, so we need to “fool” For my final experiment, I reconfigured the mini-torch
the PICAXE compiler (which can only work with integers) to emit a pointed blue flame, and waved the flame back
by working in tenths of a degree, and then inserting a and forth about two inches from the end of the probe.
decimal point in the appropriate position. We can The temperature gradually increased to more than 750°F,
accomplish that by multiplying the above equation by 10, at which point I stopped because that’s about as hot as I
which simplifies the equation by eliminating the intend to run my kamado. You may want to run your own
denominator. For clarity, the following equation uses the experiments to test your setup. Just make sure you don’t
variable names that are defined in the ThermoTest.bas exceed the maximum safe temperature for the
program: thermocouple probe you use.

tCx10 = 2 * mVolt — 2500 Experiment 2: Implementing a Simple


Now that we’ve computed the temperature in tenths Data Logging System
of a degree Celsius, we need to convert that result to At this point, we’re ready to put together a simple
Fahrenheit. By now, you’re probably familiar with the data logging system for monitoring and recording real time
standard equation: temperature measurements. We’re going to use the
Adafruit FRAM board from the previous column, the
9*C
F= + 32 Adafruit AD8495 board thermocouple amplifier board,
5
and a thermocouple sensor from Auber Instruments as we
However, we need to work in tenths of a degree discussed near the beginning of this article (refer to Table
Fahrenheit, so we’ll again use the variable names that we 1). However, as I mentioned earlier, you can easily replace
defined in the ThermoTest.bas program and change the 32 the last two items with an MCP9700A sensor if you don’t
(degrees) to 320 (tenths of a degree): need to do any high temperature monitoring.
Before we proceed, I also need to explain how I
9 * tCx10
tFx10 = + 320 intend to use the data logging system. I want to be able to
5
monitor the kamado’s real time temperature at two-
second intervals, and display it on a seven-segment four-
Keeping in mind the fact that the compiler performs digit LED so that I can adjust the kamado vents as
all calculations in order (from left to right), we can re-write necessary to maintain the temperature within an
the above equation in the following form: acceptable range. I also want to log the temperature data
to the FRAM at one-minute intervals so that I can later
tFx10 = 9 * tCx10 / 5 + 320 view the data in an Excel chart.
At some point in the future, I intend to make the
Now that we’ve calculated the real time temperature entire system wireless, but for now I’m going to store the
in tenths of a degree Fahrenheit, we need to separate real time data in the FRAM on the monitoring circuit and
each of the digits in the tFx10 variable so that we can use a “sneaker-net” approach to physically carry the
correctly place the decimal point. The bintoascii command FRAM inside the house to my Mac. There, I’ll insert the
is a convenient way to do that, and the sertxd command FRAM into a second breadboard circuit that will read the
inserts the decimal point in the correct position. data and serially send it to my Mac so I can view it in an
To experiment with the program, download it to your Excel chart. Ultimately, I would also like to add the ability
breadboard setup. You should see the real time to control the temperature, so that it remains stable over
temperature updated in the terminal window every two long periods of time. However, I think of that goal as
seconds. “phase 2” of a larger on-going project. For now, I’m just
I conducted three simple experiments with the focused on the monitoring aspect. With that in mind, let’s
program. For the first experiment, I used a small electric move on.
“hot pot” to bring some water to a boil, and then inserted The schematic for the temperature logging circuit for
the thermocouple probe into the boiling water. The this experiment is presented in Figure 7, and Figure 8 is a
temperature increased fairly quickly and stabilized at photo of my breadboard setup. The LED display that I’m
213.2°F, which is accurate enough for me. (I live at sea using is the stripboard project we completed way back in
level.) For my second experiment, I used a small butane the April 2010 installment of the Primer, but you can use
mini-torch that I have set up as a hot-air gun for heat any serial LED display that you prefer. Because the LED’s
shrinking wire insulation. I held the tip of the hot-air input pin is connected to pin C.0, which, of course, is the
emitter a fraction of an inch from the end of the probe, 089M2’s serout programming pin, you will see a series of
and watched the temperature increase to more than garbage characters rapidly displayed whenever you
400°F. download a new program to the 08M2 on the
February 2016 17
■ FIGURE 7. Schematic #1 ■ FIGURE 8.
for Experiment 2. Breadboard setup #1
for Experiment 2.

breadboard. I expected that it might be necessary to cycle 1. The iteration time of the main do/loop is two
the breadboard power after each new download in order seconds. The accuracy of the loop timing is accomplished
to properly initialize the LED display, but that didn’t turn by using the 08M2’s built-in time variable, which
out to be true. However, it could be an issue for some automatically increments once every second at 4 MHz or
LED displays, so you may want to keep it in mind. 16 MHz. (At 8 MHz, the incrementing interval is two
The FRAM breakout board is the same one I used in seconds; at 32 MHz, the incrementing interval is 0.5
the previous Primer. In other words, four of its pins have seconds.) The program runs at 16 MHz so that it can
been snipped as shown in Figure 9. As we discussed last easily accomplish all its processing tasks within the two
time, this arrangement simplifies the breadboard setup, second time frame.
and it also makes it easy to move the FRAM board back 2. If you implemented Experiment 1, you may have
and forth between the two breadboard circuits we will use noticed that the temperature reading tends to “wobble”
in this experiment. up and down a bit. To minimize
Before we move on to the this, the program takes 10
software for our data logging temperature measurements in a
circuit, I want to mention one one second time span, and then
more point: Don’t forget to computes the average of the 10
connect pin 1 of the FRAM readings.
board to the upper +5V power 3. Here, the program
rail. That connection isn’t visible executes a secondary do/loop
in Figure 8, but it’s the reason that allows the remainder of the
the PICAXE programming two second iteration time to
adapter has to be offset from its elapse.
usual position in line with the 4. Just before looping back,
08M2. we compute the remainder that
The program for the occurs when the time variable is
temperature logging circuit divided by 60. The remainder
(FRAMdataLogger.bas) does will only be zero when one
require some explanation. As minute (60 seconds) has
usual, the number preceding elapsed. If so, the data is stored,
each of the following comments the minute variable is
refers to the corresponding incremented, and the time
number along the left edge of variable is reset to zero
the program listing: ■ FIGURE 9. FRAM board with four pins removed. 5. This is an easy method of
18 February 2016
rounding off. At this point, the tempF variable is in tenths
■ FIGURE 10.
of a degree, so if we simply divided it by 10, we would Schematic #2 for
truncate the “tenths” digit, not round it off. By first adding Experiment 2.
5 to tempF, any value of 5 or greater in the tenth’s digit of
tempF will be increased by enough to cause a “carry” to
the one’s digit; if the value of the tenth’s digit is less than
5, adding 5 will not cause a “carry” to occur. As a result,
when we then divide tempF by 10 (truncating the tenth’s
digit), the presence or absence of the “carry” correctly
rounds the result to an integer.
6. The LED display that I’m using is based on the
MAX7219 display driver, which requires a value of 15 to
blank any digit in the display. Therefore, if you use a
different LED display, you may need to modify this portion
of the code. Also, the four values are displayed from left
to right, so sending 15 as the first value results in the left-
most digit being blanked.
7. We want to right justify the displayed temperature
value, so digits don’t “bounce back and forth” whenever
tempF increases or decreases above or below the value of
100. Therefore, if tempF < 100 degrees, we send another
value of 15 to blank the second digit from the left, and
then send the two-digit value of tempF. On the other
hand, if tempF >= 100 degrees, we just send the three-digit
value of tempF. As a result, the LED display is always right
justified.
8. Each time the four bytes of data are stored in the
FRAM, two additional “end of file” (EOF) markers (i.e., two
values of 255) are also stored. When we power-down the
program, carry the FRAM inside the house to the data
reader breadboard, and transfer the data to the PC, the
data reader software uses one of those values to
determine when to stop transmitting the data to the PC. ■ FIGURE 11. Breadboard setup #2 for Experiment 2.
Of course, it is possible for the minuteL variable to have a
value of 255. For example, if a “low and slow” cooking The software for the data reading circuit
session lasts longer than four hours and 15 minutes, (FRAMdataReader.bas) is also really simple. There’s also
minuteL would equal 255 at that point in time. However, only one point here I want to clarify about how the
we would have to cook something for more than 45 days program uses the EOF marker to determine when to stop
to store a valid data value of 255 in the minuteH variable! processing the data. When I first wrote the program, it
So, as we’ll soon see, the data reader program stops included the following code:
reading the data as soon as minuteH contains the EOF
marker. hi2cin FRAMloc,(minL,minH,tempFL,tempFH)

At this point, we’re ready to move on to the data do


reading portion of this experiment. Fortunately, this sertxd (#minute,”,”,#tempF,CR,LF)
portion of the experiment is much simpler than the data FRAMloc = FRAMloc + 4
logging portion we just discussed. The schematic for the hi2cin FRAMloc,(minL,minH,tempFL,tempFH)
data reading circuit is presented in Figure 10, and my loop until minH = EOF
breadboard setup — which is identical to one we used in
the previous Primer — is shown in Figure 11. If you compare the above code snippet to what’s
This circuit really doesn’t require an explanation. The written in the program listing, you can see that both
only point I want to mention is that the +5V connection to versions essentially implement the same set of tasks. What’s
pin 1 of the FRAM board — which wasn’t visible in the the difference? (I’m glad you asked.) See if you can figure it
temperature monitoring and logging circuit (see Figure 8) out before I explain why I modified the original code.
— can be clearly seen in Figure 11. In the above code, the first four-byte data entry is read
February 2016 19
other words, the data line that includes the EOF marker is
not sent to the terminal window. That’s what I thought I
wanted, but each time I tested the program I had the
uncomfortable feeling that somehow the processing may
have been terminated before all the data was sent to the
terminal. (I guess you could say I have a trust issue.)
To make myself feel better, I re-wrote the software as
shown in the program listing. If you trace through that
do/loop, you will see that the data line that includes the
EOF marker is sent to the terminal before the until portion
of the do/loop tests for it and terminates the loop. That
makes me feel better, and removing the invalid data line
before making the Excel chart is easier (and cheaper) than
going into therapy for my trust issue.
It was easy to set up the temperature data logging
system with my kamado. I just drilled a small hole in the
side of the kamado, inserted the thermocouple probe
■ FIGURE 12. Experiment 2 in action. through the hole, and placed the breadboard data
monitoring circuit on one of the kamado’s side tables as
before entering the main do/loop, where it’s processed. you can see in Figure 12. The Excel chart for one of my
The last statement inside the loop reads the next line of recent grilling sessions where my “target” temperature was
data, and then the loop iterates. When the EOF marker is 450°F is presented in Figure 13. In the chart, you can
read into the minH variable, the “until” portion of the clearly see the (somewhat delayed) effect on temperature
do/loop statement immediately ends the processing. In whenever I manually adjusted the opening of the intake

20 February 2016
air vent on the kamado.
I’ve been using this setup for a
few weeks now, and it has
provided me with a considerable
amount of data for phase 2 of my
larger project (i.e., using a PICAXE
circuit to control the kamado’s
temperature for longer “low and
slow” cooks). However, even if I
never get to that project, the
temperature monitor has provided ■ FIGURE 13. Test results for Experiment 2.
an unexpected side benefit. I can
now see the kamado’s current
temperature from my kitchen window. I no longer need to if I can use an 08M2 circuit for that purpose, and so far
run outside every few minutes to do that. the results are very good.
In fact, after I finish this installment, my very next We can’t get into the details this month because
project is to design a PCB version of the monitoring we’re out of space again, but next time, that’s what we’ll
circuit, install it in a project case, and include a larger LED do. Even if you have no need to control a smoker of any
display to make viewing the kamado’s current temperature sort, being able to interface a PICAXE processor with an
even easier. SSR makes a variety of electrical control projects possible.
I’m sure you can think of one or two possibilities for your
What’s Next? own projects.

Now that we can accurately monitor the temperature See you next time. NV
of an outdoor grill and/or smoker,
the next logical step would be to
develop a PICAXE project that can
also control the temperature. Of
course, there are already
commercially available devices that
provide this capability for charcoal
grills and smokers by controlling the
speed of a fan that feeds air to the
fire. In fact, I already use a DigiQ
DX2 digital controller from
BBQguru.com, and it does its job
very well.
However, in addition to my
outdoor charcoal grills and smokers,
I also have an electric smoker
installed in the furnace room of my
basement (you can never have too
many smokers!), so I decided to
experiment with using a PICAXE
circuit to monitor and control its
temperature.
Obviously, we can’t use a fan to
control the heat in an electric
smoker, but it’s easy to interface a
solid-state relay (SSR) with a PICAXE
processor, and plug the smoker into
an AC outlet that’s controlled by the
SSR.
In fact, I’ve already conducted a
few preliminary experiments to see
February 2016 21
■ HARDWARE

NEW PRODUCTS ■ SOFTWARE


■ GADGETS
■ TOOLS

TRACKED
ROBOT KIT
A gent 390™ is a powerful tracked
robot platform now available
from Actobotics®. Incorporated is a pricing without motors is $329.99. Dual Gear Rack Kit is great for
smooth ball bearing supported drive projects that require symmetric linear
track system to achieve high PERPENDICULAR/ movement from a common center
maneuverability and omnidirectional point using a PWM signal.
control. Although the contact patch
PARALLEL DUAL The kit includes the servo and all
on the tracks is smooth, they still GEAR RACK of the required hardware. Both the
offer fantastic traction and climbing perpendicular and parallel versions of
ability. KITS the kit retail for $99.99.
The 18” x 16.42” aluminum
chassis provides an extremely rigid
base which can carry well over 50
A lso available from ServoCity is
the 785 Dual Gear Rack Kit
which is a simple way to create linear
For more information, contact:
ServoCity
lbs. The flat top plates offer an easy motion using a rotational servo. This www.servocity.com
way to attach additional components kit is ideal for steering rack setups or
directly to the platform, and the other applications requiring smooth SEVEN-SEGMENT
center track idler can be shifted to be linear motion.
closer to the front or back. The kit comes with the multi-
LED DISPLAY
The side plates (triple channel rotation Hitec HS-785HB servo which FOR THE RaspPi
brackets) are tied together using 6-32 allows for up to 9.6” of travel (up to
tapped aluminum standoffs that also 19.2” of total travel) from each of the
serve to hold the belt in place.
These plates incorporate the
gear racks when sending the proper
PWM signal from a servo controller.
T he Joey is a compact four-digit
seven-segment LED display board
for the Raspberry Pi — recently
Actobotics hole pattern for mounting The kit is constructed of 6061 T6 released by Gooligum Electronics —
other components. Because builders aluminum components and wear- which makes it easy to display
may already have motors they want resistant Delrin plastic to create a numeric data or simple text which
to utilize for driving the Agent 390, durable yet lightweight assembly. remains visible even when another
ServoCity offers this kit with or The framework has several expansion board is mounted on the
without the 313 RPM HD precision mounting options and integrates Pi. It is physically thin and slides over
planetary gearmotors and mounts. seamlessly with the rest of the the Pi's GPIO pins, allowing other
Pricing with motors is $389.99; Actobotics line of products. The 785 add-ons to be attached in the usual
22 February 2016
NATIONAL RF, INC.
R
N F

Plug-in
way. It connects Coil Forms
via the
Raspberry Pi’s
I2C bus and Misc
coexists nicely Elec
WxSat Odds
with other I2C & Ends
Antenna
devices. In the
unlikely event Visit www.NationalRF.com for this
and other Radio Products!
of a clash, the Office: 858-565-1319
Joey's I2C
address can be
changed. It QKITS LTD
doesn’t use any sales@qkits.com
dedicated GPIO pins, so it can chemistries, including the latest LiHV Arduino •
coexist with almost any other add-on. cells. Raspberry Pi
The Joey provides three digital The microprocessor control and
inputs in addition to those available an internal resistance meter make this Power Supplies
on the Raspberry Pi. These inputs a key component of the workshop. MG Chemicals
can be accessed by your programs to Hitec’s free “Charge Master” RFID
enhance the functionality of your software allows full PC control of the $8.50
project. X2-700 through its integrated USB flat rate shipping
The Joey comes with port, from basic setup to full software
comprehensive documentation and a analysis of a battery’s health and 1 888 GO 4 KITS
Python support library which makes performance. Visit us at: www.qkits.com
it easy to display formatted numeric Users can streamline operations
values, and even short text messages. with the new Synchronous Mode as
To get started, a set of example the second output port automatically
applications is provided, including a mirrors channel 1 settings to charge
CPU temperature monitor (as shown multiple similar batteries with
in the photo), a clock, and an IP minimal setup time. The Multicharger MDE8051 Trainer
by Digilent
address display (which can be set up is reliable and durable, and a must-
to run whenever the Raspberry Pi have charger for all seasoned
boots). hobbyists.
The Joey LED display board The estimated retail price is
retails for $8. Bulk purchase and $214.99.
educational discounts are available. NKCelectronics.com/MDE8051
For more information, contact: Includes the MDE8051 training board, power
For more information, contact: Hitec RCD USA, Inc. supply, serial cable
Gooligum Electronics Purchase Orders are accepted from Educational Institutions ,
www.hitecrcd.com US Government and Research Centers
www.gooligum.com

DC/DC
Stock Drive Products
MULTI Setting Ideas Into Motion

CHARGER One-Stop Shop for


M
H itec’s powerful X2-700
Multicharger is a
sophisticated charging
EX
EXPLORE
DESIGN
DE
choice for all high BUY ONLINE
BU
amperage batteries. This
DC powerhouse features w
no minimum requirement
two 700 watt output ports
for increased capacity and
supports all battery
February 2016 23
BUILD IT YOURSELF

BUILD A DIGITAL By Roger Secura

DECADE Post comments on this article and


find any associated files and/or
downloads at www.nutsvolts.com
/magazine/article/
february2016_DigitalDecadeBox.

BOX

I
Having the right tool makes any job easier. Just try n addition to the main players, there
are a few hacker tools (black boxes)
and remove a sparkplug without a good deep-well that some of the financially challenged
(like me) build to help in the process of
circuit design and testing. One of these
socket and wrench. The same holds true in the electronic contraptions is the resistor
“decade box.” A resistor decade box is a
field of electronics. The multimeter, signal chain of resistor networks which allows you
to “dial in” any resistor value you need
generator, oscilloscope, and frequency counter are simply by adjusting a few knobs. If you
can’t afford a commercial decade box, I
just some of the “tools” that not only speed up the would suggest checking out Frank
Muratore’s article in the April 2014 issue of
design process, but reduce the urge to pull one’s Nuts & Volts and build your own. His
simple black box design is low in cost and
hair out in frustration. real easy to build — I use it all the time.
24 February 2016
As nice as Muratore’s
design works, however, the
potentiometers he
employed in his design are
notorious for their
sensitivity. That means you
have to hook up your
ohmmeter and adjust the
knobs back and forth
several times in order to
get the exact resistance
you need. What I really
wanted was a decade box
where I could select the
required resistance with a
couple of switches — ■ FIGURE 1.
without having to hook up
an ohmmeter to see the
actual resistance value. To
solve that problem, I
designed the digital decade
box presented here.
This is a great project
for the beginner. You’ll get
to sharpen your soldering
skills for your next project.
What follows is the
construction and operating
instructions you’ll need to
build and operate the
decade box.

Circuit
Operation
The circuit for the
decade box is shown in
Figure 1. You’ll notice that
in order to select a
■ FIGURE 2.
resistance value (440.520K,
for example) we select the
appropriate DIP switches in each column according to the DIP switch selected for a resistance value.
value we need.
This completes the circuit, and the total resistance of Construction
all the switches will be available at the output (A, B). It’s
important that you set all DIP switches that The layout for the circuit is shown in
are not selected for a resistance value to ■ FIGURE 3. Figure 2. Place the DIP switches on the top
zero ohms (switch # 10). In other words, if side of the perfboard (no solder pads) and all
you select 10K for a resistance value, all the the resistors on the bottom side of the board
other DIP switches must be set to zero ohms (solder pads). The board is small, so count
(switch #10 - ON). Remember, you have to the holes carefully. You should see two holes
complete the electrical circuit in order to get between each DIP switch. Insert DIP
a 10K resistance at the output (A, B). switches #1and #2. Place them on the top
On the other hand, don’t forget to move side of the board (no solder pads).
the zero switch to the off position for any Before you start soldering anything,
February 2016 25
ITEM QTY DESCRIPTION PART# SOURCE
Black Box 1 Plastic Box — 5.3" x 3.3” x 1.6” TB-4 www.allelectronics.com
Perfboard 1 3-1/8” x 4-5/16” PC-4 www.allelectronics.com HARDWARE
Test Leads 1 Banana Plug to Mini-Grabbers TL-5 www.allelectronics.com

ITEM QTY DESCRIPTION PART# SOURCE


R1
R2
1
1
1 ohm,1/4W, 5%
2 ohm,1/4W, 5%
1.0QBK-ND
2.0QBK-ND
Digi-Key
Digi-Key
PARTS LIST
R3 1 3 ohm,1/4W, 5% 3.0QBK-ND Digi-Key
R4 1 3.9 ohm,1/4W, 5% 3.9QBK-ND Digi-Key scotch tape both DIP switches to
R5 1 5.1 ohm,1/4W, 5% 5.1QBK-ND Digi-Key the surface of the board so they
R6 1 6.2 ohm,1/4W, 5% 6.2QBK-ND Digi-Key don’t pop out during the
R7 1 7.5 ohm,1/4W, 5% 7.5QBK-ND Digi-Key
soldering process (trust me, it
R8 1 8.2 ohm,1/4W, 5% 8.2QBK-ND Digi-Key
R9 1 9.1 ohm,1/4W, 5% 9.1QBK-ND Digi-Key works). Take the one ohm resistor
R10 1 10 ohm,1/4W, 5% 10QBK-ND Digi-Key from the Parts List and bend it
R11 1 20 ohm,1/4W, 5% 20QBK-ND Digi-Key according to Figure 3.
R12 1 30 ohm,1/4W, 5% 30QBK-ND Digi-Key Now, turn the board over
R13 1 40.2 ohm,1/4W, 5% 40.2XBK-ND Digi-Key and insert the one ohm resistor
R14 1 49.9 ohm,1/4W, 5% 49.9XBK-ND Digi-Key into the DIP switch terminal holes
R15 1 60.4 ohm,1/4W, 5% 60.4XBK-ND Digi-Key as shown in Figure 2. Yes, it’s a
R16 1 69.8 ohm,1/4W, 5% 69.8XBK-ND Digi-Key
little tight, but the resistor leads
R17 1 80.6 ohm,1/4W, 5% 80.6XBK-ND Digi-Key
R18 1 90.9 ohm,1/4W, 5% 90.9XBK-ND Digi-Key and the DIP switch terminals will
R19 1 100 ohm,1/4W, 5% 100QBK-ND Digi-Key fit into the same solder pad
R20 1 200 ohm,1/4W, 5% 200QBK-ND Digi-Key holes. Solder one side of the
R21 1 300 ohm,1/4W, 5% 300QBK-ND Digi-Key resistor (one ohm) lead to DIP
R22 1 402 ohm,1/4W, 5% 402XBK-ND Digi-Key switch #1 and the other lead to
R23 1 499 ohm,1/4W, 5% 499XBK-ND Digi-Key DIP switch #2. Don’t insert the
R24 1 604 ohm,1/4W, 5% 604XBK-ND Digi-Key
next resistor (two ohm) until you
R25 1 698 ohm,1/4W, 5% 698XBK-ND Digi-Key
R26 1 806 ohm,1/4W, 5% 806XBK-ND Digi-Key are confident it’s a good solder
R27 1 909 ohm,1/4W, 5% 909XBK-ND Digi-Key joint. Repeat this procedure (one
R28 1 1K ohm,1/4W, 5% 1.0KQBK-ND Digi-Key resistor at a time — one ohm to
R29 1 2K ohm,1/4W, 5% 2.0KQBK-ND Digi-Key nine ohms) until you have all the
R30 1 3K ohm,1/4W, 5% 3.0KQBK-ND Digi-Key resistors mounted between DIP
R31 1 4.02K ohm,1/4W, 5% 4.02KXBK-ND Digi-Key switch #1 and DIP switch #2 (see
R32 1 4.99K ohm,1/4W, 5% 4.99KXBK-ND Digi-Key Figure 4.) Notice that switch 10
R33 1 6.04K ohm,1/4W, 5% 6.04KXBK-ND Digi-Key
on each DIP switch is just a
R34 1 6.98K ohm,1/4W, 5% 6.98KXBK-ND Digi-Key
R35 1 8.06K ohm,1/4W, 5% 8.06KXBK-ND Digi-Key jumper wire.
R36 1 9.09K ohm,1/4W, 5% 9.09KXBK-ND Digi-Key Okay, here’s the tricky part.
R37 1 10K ohm,1/4W, 5% 10KQBK-ND Digi-Key Once all the resistors are
R38 1 20K ohm,1/4W, 5% 20KQBK-ND Digi-Key mounted and soldered across
R39 1 30K ohm,1/4W, 5% 30KQBK-ND Digi-Key DIP switch #1 and #2, solder all
R40 1 40.2K ohm,1/4W, 5% 40.2KXBK-ND Digi-Key the other terminals of DIP switch
R41 1 49.9K ohm,1/4W, 5% 49.9KXBK-ND Digi-Key
#1 together as shown at the
R42 1 60.4K ohm,1/4W, 5% 60.4KXBK-ND Digi-Key
R43 1 69.8K ohm,1/4W, 5% 69.8KXBK-ND Digi-Key bottom of the photo in Figure 4
R44 1 80.6K ohm,1/4W, 5% 80.6KXBK-ND Digi-Key and at the top of the photo in
R45 1 90.9K ohm,1/4W, 5% 90.9KXBK-ND Digi-Key Figure 5. The trick is to cut off
R46 1 100K ohm,1/4W, 5% 100KQBK-ND Digi-Key the lead of a resistor you don’t
R47 1 200K ohm,1/4W, 5% 200KQBK-ND Digi-Key need and lay it across the DIP
R48 1 300K ohm,1/4W, 5% 300KQBK-ND Digi-Key switch terminals, then solder all
R49 1 402K ohm,1/4W, 5% 402KXBK-ND Digi-Key the terminals together (again,
R50 1 499K ohm,1/4W, 5% 499KXBK-ND Digi-Key
scotch tape helps). You’ll need to
R51 1 604K ohm,1/4W, 5% 604KXBK-ND Digi-Key
R52 1 698K ohm,1/4W, 5% 698KXBK-ND Digi-Key use six resistor leads as jumpers
R53 1 806K ohm,1/4W, 5% 806KXBK-ND Digi-Key for all six DIP switches, and one
R54 1 909K ohm,1/4W, 5% 909KXBK-ND Digi-Key lead for the resistors located on
SW1-SW6 6 DIP Switch SPST, 10SEC CT20810-ND Digi-Key DIP switch #6.
26 February 2016
Author’s note: VERIFY ALL RESISTANCE
VALUES BEFORE SOLDERING.
Unfortunately, the company where I
purchased my resistors sent the wrong
resistance value for one resistor. I was
forced to string three resistors together
to make 60K. This made it difficult to fit
in between the other resistors. Also,
don’t bend and cut all the resistors in
this project at the same time. You’ll get
confused as to what resistor value you
have laying on your work bench. This
will force you to get out the ohmmeter
and verify the resistance value –
annoying!
■ FIGURE 4.

■ FIGURE 6.

■ FIGURE 5.

When you complete the


soldering, your decade box should
look something like Figure 6. Premium tools for makers and creators
Lear n PIC programming e
Cr eat
original projects for Raspberry Pi
Final Note
Some precision resistors can
only be purchased in minimum
quantities of 100 or 1,000 pieces.
When I designed this decade box, I
made the decision to buy a few
resistors that were as close to the
required value as possible (60.4K for
a 60K), rather than purchasing 100 Tutorials and training board The Wombat prototyping board
resistors just to get one that is Clear lessons Provides easy access to all GPIO pins
exactly 60K. If you want a more C and assembler Adds functionality to your Pi, such as:
accurate response from your resistor Hands on examples analog inputs, LEDs, pushbuttons,
decade box, then you may want to Includes enhanced mid-range PICs USB serial console port
search the Internet for lower Includes a set of projects to get you started.
tolerances. NEW! See our Raspberry Pi display add-ons
I hope you enjoy your new tool
for decades! NV www.gooligum.com
February 2016 27
BUILD IT YOURSELF

BUILD A FUN WIND SPEED


TRACKER WITH A By David Goodsell

RASPBERRY
PI

For years, I’ve had a Davis weather station and enjoyed tracking the wind —
especially the sudden gusts that rattle the windows. However, the tiny plot on
the station’s LCD screen is not very resolved and I wanted it to be better ... a
whole lot better. The solution: a Raspberry Pi!
28 February 2016
Post comments on this article and find any associated files and/or
downloads at www.nutsvolts.com/magazine/article/
february2016_RaspPiWindSpeedTracker.

The Big Picture


I was gassed when I realized that a Raspberry Pi (RPi)
could run a plotting program like “Gnuplot” and generate
spiffy real time plots of wind speed on one of the small
LCD displays from Adafruit (refer to Figure 1). The best
part was customizing the display to look just the way I
wanted it to.
The seven inch 1280 x 800 display looks great on my
wall. The colors are vibrant and the resolution is more
than I could hope for. During operation, the RPi updates
the peak wind speed once per minute, 1,440 times a day,
24/7, and resets at midnight. It’s fun to watch the peaks
climb higher and higher, as I wonder if the house is going
to blow away.
The schematic diagram of the project is shown in
Figure 2. I realize that some of the functions could be
combined to reduce the parts count, but I already had
most of them in my stock so I shoved them all into a box ■ FIGURE 1. The Adafruit seven inch 1280 x 800 LCD
and started programming. Figures 3 and 4 show the box plots the max wind speed at one minute intervals,
1,440 times a day.
mounted under my desk.

Davis Anemometer RESOURCES


www.adafruit.com (displays and Raspberry Pis)
As seen in the schematic, the project starts with the www.ebay.com (anemometers)
anemometer on the left. Many years ago, I purchased a www.davisnet.com (anemometers)
www.dfrobot.com (cheap 2x16 LCD shield)
Davis Model 7911 anemometer and it’s still working today www.digikey.com (general components)
(see Figure 5). I checked eBay and there are some less www.parallax.com (SX28 IDE)
expensive units from overseas, but their outputs may not Arduino Cookbook, by Michael Margolis, 2013

■ FIGURE 2. An Arduino Mega 2560 is


the heart of the system and coordinates
all the functions.

February 2016 29
■ FIGURE 3. The control box contains three processors: a
Parallax SX28, Arduino Mega 2560, and Raspberry Pi 2. ■ FIGURE 4. Here, 8-10 GPS satellites are
typically in use (as shown on the LCD), even with
the GPS receiver mounted indoors.
be compatible. Both eBay and Amazon sell the older
model 7911. occurring in 2.250 seconds: 10 pulses = 10 MPH; 20
The cups in the Davis unit rotate a magnet past a pulses = 20 MPH; and so on. The unit also contains a 20K
magnetic sensor once every revolution. The calibration is ohm continuous-rotation potentiometer which can be
extremely simple. You count the number of pulses used to track the direction of the wind. However, I didn’t
use the pot in this project.
The output of the anemometer is filtered to
eliminate any noise from the sensor or the 75 feet of
cable running through the attic. I didn’t employ any
lightning arrestors, although whenever a
thunderstorm comes along I can’t help but think
about whether the next lightning strike is going to
electrify my desk and me with it!
The pulses from the cups are counted by an
Arduino (also used in this project) for exactly 2.250
seconds and stored in a small array. This counting
process repeats every 2.250 seconds until a full
minute has elapsed, so there are approximately 25
readings/minute. Next, the peak wind speed from
the 25 readings is determined and stored as the next
■ FIGURE 5. The Davis anemometer data point to be plotted, i.e., each minute the peak
measures the number of rotations in 2.25 during the past minute is plotted. Of course, you
seconds; 10 rotations/2.25 sec = 10 MPH.
could plot the average value for the past minute
instead of the peak.
30 February 2016
GPS Receiver and
Decoder
For the time base, I chose the Garmin GPS receiver
shown in Figure 6, mainly because I already had it left
over from a previous project. I could have used an RTC
(Real Time Clock) but then I would have had to add more
buttons to set the time. Besides, in my junk box I also had
a Parallax SX28 microcontroller programmed to parse the
sentences and output the time and date over a 9600 baud
five volt line. I bought a bunch of SX28 protoboards when
Parallax had an End-Of-Life sale several years ago; they are
handy for small projects like this one.
The time and date are parsed from the GPS RMC
sentence and the number of satellites in use is taken from
the GGA sentence. As you’ll notice in Figure 4, I display
the number of satellites on the 2x16 LCD, only because I
am awed by the whole GPS concept and love to see it
working. The Garmin unit works fine inside my single-story ■ FIGURE 6. Using a GPS receiver to extract the time
house, but your reception may vary. and date doesn’t require setting, but an RTC
For some obscure reason, I decided to write my own could be substituted.
Arduino routine to convert UTC time to local time/date,
instead of adapting a Library routine. Big mistake! It 8. The GPS GMT time/date from the SX28 is
looked simple enough, but then I realized that I would converted to local time as it comes in.
have to include time zones, leap years, and daylight
savings. Garf! After many hours of debugging, I got it The biggest problem I had with the programming was
working and confirmed that it converts the UTC data to juggling the code for the three different processors. The
the correct time and date for all 50 states. Just enter your SX28 used assembly language, the Arduino used C, and
Time Zone (TZ) in the Setup Section of the code before the RPi required a combination of command-line
you load it. If you are not in the US, simply adapt the programming and Python. I had a heck of a time keeping
code to fit your location. track of which language I was using at any one time. Plus,
it was my first experience with Python, so there was a
Program Flow learning curve. Fortunately, the Internet has a cornucopia
of helpful hints and I was able to work my way through
The basic program flow is as follows: the problems. I also bought several books and tapped my
knowledgeable friends.
1. In the background, the Arduino measures wind This project was also my first experience with the
speed at 2.250 intervals, and the SX28 reads the GPS fantastic free Gnuplot plotting program. It was fun to
time/date and number of satellites. customize the display, but it was almost impossible to stop
2. At the end of each minute, the SX28 sends a pulse tweaking it. (You know how it is.) I chose to locate the
to the Arduino. main Gnuplot configuration file in the Arduino because I
3. The Arduino then: needed to update many of the displayed numbers 1,440
a. Determines the peak velocity for the past minute times a day. Normally, the config file would be
and adds the value to the daily array (1440 points). permanently located in the RPi main directory. Instead, I
b. If the daily maximum velocity has increased, it send an updated config file to the RPi at the end of each
moves the red fid mark and value to a new point, and minute, at 115200 baud.
sounds an audio signal. The source code for the Parallax SX28, Arduino Mega,
c. It serially transmits updated config and data array and RPi is available at the article link. Also available is a
files to Gnuplot in the RPi. document explaining how to install the necessary support
4. The RPi sends a new HDMI plot to the LCD applications/tools for the RPi.
monitor, but in a small window.
5. The RPi expands the window to fill the LCD screen. Booting Up and Other
6. Steps 3, 4, and 5 are repeated at the end of each
minute, 1,440 times per day. Details
7. Everything resets at midnight. Getting all three processors to boot up concurrently
February 2016 31
DESIG COMPONENT was almost my downfall. I could not
Digi-Key (unless noted)
R1 Resistor, 10K 10KQBK figure out how to autostart the .py
R2 Resistor, 470 ohms 470QBK
program on the RPi. I scoured the
R3-R5 Resistor, 1K 1.0KQBK
Internet for several days and tried
numerous suggestions. No joy.
R6 Resistor, 330 ohms 330QBK
R7 Resistor, 3.3K 3.3KQBK PARTS Finally, I found a reference to an
autostart file located deep within the
R8
D1, D2
Resistor, 1.8K
Diode, 1N914
1.8KQBK
1N914BCT
LIST /etc/xdg/lxsession/LXDR-pi
subdirectory. The reference suggested
C1 Capacitor, 1.5 mfd 35V 478-1853
adding @lxterminal and the name of
C2, C3 Capacitor, 0.1 mfd 50V 399-8994-1
the wind speed program to the file,
SW1 Toggle Switch, SPDT 480-3077
and bingo! It took off. Now, if the
SW2 Pushbutton, N.O. RadioShack
power fails, the three processors boot
SW3 Toggle Switch, SPDT CKN1023 themselves up, collect data for several
LED1 LED, Green RadioShack minutes, and start plotting a full
LCD1 LCD Shield, 2x16 DF Robot, DFR0009 screen. It’s amazing that the system
PS1 Power Supply, 5V, 12V 102-2527 runs all day and night, day after day
Q1, Q2 FET, 2N7000 2N7000TACT with no glitches. That’s a total of 1,440
U1 IC, 74LS14 Schmitt Trig 296-3638-5 plots/day x 365 days = 525,600
MEM1 Thumb Drive, 8 GB Best Buy plots/year.
SPKR1 Insignia Portable Spkr Best Buy Speaking of problems, the
BOX Carlon/Cantex, 6x6x4 Lowe's/Home Depot Arduino Mega has a subtle
shortcoming. Not all of the pins of the
Note: The major components/boards are labeled on the schematic. 2560 controller chip are connected to
the header on the board, and some
are fairly important. For example, most of the external
inputs to the six timer/counters are missing. I found this
The
T he E
Easiest
asiest W
Wayay tto
o Design Custom out the hard way when I thought I could use any one of
Front
Front Panels
Panels & Enclosures the timers to count the pulses from the anemometer. I
checked the Mega schematic and found that there were
no external (Tn) connections to Timers 1, 2, 3, or 4. Only
Timers 0 and 5 were hooked up. However, Timer 0 was
tied up by the Mega to support some of the timing
functions, which left just one Timer: T5.
In fact, the most important code for counting the
anemometer pulses uses Timer 5 and is only five lines
long:
You design it We machine it
to your specifications using and ship to you a TCNT5 = 0x00 //reset timer/counter 5
our FREE CAD software, professionally finished product, TCCR5B = 0x06 //start timer/counter 5, on
Front Panel Designer no minimum quantity required
//falling edge of external pulse
//on T5
 Cost effective prototypes and production
runs with no setup charges delay(2250) //continue counting for 2.250
 P
 owder-coated and anodized finishes in
//seconds
various colors TCCR5B = 0x00 //stop timer/counter 5
 elect windspeed = TCNT5 //transfer count to global
 S from aluminum, acrylic or provide
your own material //variable
 Standard lead time in 5 days or express
manufacturing in 3 or 1 days BTW, I spent considerable time trying to downsize the
“over-qualified” Arduino Mega to an Uno. The largest
array in the program required 1,440 bytes and the Uno
had 2K bytes. It seemed like there was plenty of extra
RAM, but I just couldn’t get it to play nice. Plus, with the
FrontPanelExpress.com Uno, I had to invoke a software serial port because I
needed two ports with different baud rates. The software
32 February 2016
port worked fine by itself, but when I folded it into the full
program it caused a number of mysterious interaction
problems that I got tired of trying to sort out. So, I stayed
with the Mega. There is only so much time. (Any ideas?)
I also added a 16 x 2 LCD display to the system for
debugging and to display other parameters. I really love all
the USB connectors on the RPi. They allowed me to
connect a wireless keyboard/trackball in order to make
changes to the program and a Flash drive to save the
changes — not to mention the convenient five volt power
for the speaker.

Construction
Punching the round and rectangular holes in the thick
plastic box and its cover was a snap this time, mainly
because I had purchased a Grizzly benchtop milling
machine a while back. In the past, making such holes
involved a lot of elbow grease, i.e., get out the big rattail ■ FIGURE 7. Fabricating the box and its cover was a
snap with my benchtop milling machine.
file and have at it. With the machine, I milled a big hole in No more filing for hours!
the cover as shown in Figure 7, and mounted a fan filter
over it to let air circulate around the processors. The
power supply is mounted externally to allow plenty of good news, though. My house may still blow away, but at
airflow through it. least I’ll know how fast it went down the street. NV

Sound
After the whole system was successfully running, I had
yet another brainstorm: Why not add sound? For example,
there could be a “ding” every time an extra-large gust of
Motor Control
wind came along. So, I did it. The RPi required yet another
app called Pygame to make it happen. I recorded the • 15 Amps Per Channel
sound I wanted using Audacity and put the .wav file in the • Dual Channel
pi directory. Now, it dings four or five times a day when • Quadrature Encoders
the wind picks up. I tried using the HDMI audio output • DC Brushed Motors
jack on the little monitor, but the correct command line • USB / RC / Serial
instructions eluded me. So, I went with the audio output
jack on the RPi board and it worked great.
• 45 Amps Per Channel
The Future • Dual Channel
• Quadrature Encoders
The future for this project is wide open. Gnuplot can • DC Brushed Motors
easily handle multiple plots in different colors and line • USB / RC / Serial
styles. You can measure temperature, humidity,
barometric pressure, whatever. Although I think my next
plot to add is going to be another wind speed • 160 Amps Per Channel
measurement, but this one will be generated by a no- • Dual Channel
moving-parts ultrasonic anemometer. Ultrasonic wind
• Quadrature Encoders
sensors typically have a time constant of 0.25 seconds or
• DC Brushed Motors
less, which will catch the fast rise time gusts that the Davis
• USB / RC / Serial
unit completely misses. I can’t wait to see how the two
plots compare.
The RPi and Adafruit LCD have opened up a whole
new world of dedicated displays for me — no more tying
up my laptop or desktop monitor. There is bad news and
www.ionmc.com
February 2016 33
The Remarkable
CSS555
The CSS555 is a micropower
By James Senft (a.k.a., TinkerJim)
programmable version of the 555
family of timer ICs. It operates at a
current under 5 μA and a supply Another application of the CSS555 in the standard
(unprogrammed) mode is the solar engine shown in
voltage from 5.5V down to 1.2V. Figure 4. Here, the circuit is a sort of monostable
These qualities make it particularly arrangement with a more or less constant voltage (about
1.4V usually) on the trigger and threshold pins, which is
well-suited for long lasting battery supplied by a photodiode (a suitable LED, actually). The
and small solar powered projects. supply voltage to the circuit varies as the storage capacitor
Cs charge from a solar cell, or discharge through the load
It can be used in standard 555 when the output pin goes high.
configurations as supplied, but it is It goes high when the supply reaches three times the
trigger voltage, and goes low when the supply drops to
also user programmable to 1.5 times the photodiode voltage.
produce extended timing periods. The original concept for this solar engine circuit was
devised by Manfred Schaffran and Wilf Rigter in 2003
when only the 7555 timer was available. The CSS555
greatly improves the efficiency since the circuit now takes
Standard 555 Micropower under 5 µA during periods when the storage capacitor is
charging up. The various available 7555s required
Operation anywhere from 50 µA to 180 µA. A CSS555 equipped
The CSS555 is pin-for-pin compatible with the solar engine has operated perfectly from a tiny solar cell
customary 555 series timers as Figure 1 indicates. supplying a mere 15 µA.
Therefore, application circuits have the familiar 555 The little robot “Walker” in Figure 5 is equipped with
topology as, for example, in the astable circuit illustrated this circuit, a good size solar cell atop his head, and,
in Figure 2. presently, a 0.22F capacitor. He periodically waddles
However, the micropower nature of this IC allows around in a little circle (one of his arms/legs is longer than
using external components with values that demand much the other) whenever he has gleaned enough energy from
less power. For example, the LED blinker in the electronic
paperweight in Figure 3 uses the above astable circuit
with timing resistors RA = 10M, RB = 47K, and a 0.22 µF
timing capacitor. It blinks perpetually on the energy stored
in a 1F capacitor charged from a small photovoltaic cell
taking in typical desktop lighting.

FIGURE 2. Astable circuit diagram. Note that the reset


FIGURE 1. The CSS555 has the same pinout. pin must be held high for the chip to be active.
34 February 2016
5555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555
Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/
magazine/article/february2016_CSS555TimerICs.

the surrounding light. More information on all these


projects can be found at Instructables.com. The ultra low
power feature of the CSS555 truly excels in projects such
as these. FIGURE 3.
This
Extended Mode Operation electronic
paperweight
holds down
The second remarkable feature of the CSS555 is that papers by
it is user programmable for extremely long timing periods automatically
— from hours to days — with small value capacitors. The utilizing the
chip includes an internal counter that tracks the capacitor ambient
charge/discharge cycles and changes the output pin state gravity field.
when the selected number of cycles has occurred. Figure It also blinks.
6 illustrates this with a counter value of 10.
Selectable counter values go in multiples of 10: from
100 = 1 (the standard 555 mode) up to 106 = 1M. Figure 7
illustrates a monostable circuit set up for a delay of about
16 minutes using a capacitor of only 100 pF (which is built
into the CSS555C variety of the chip).
For the extended functions, access to a programming
board is needed, of which two are available from Custom
Silicon Solutions (CSS; www.customsiliconsolutions.com).
The “EZ Programmer” shown in Figure 8 works from two
AAA cells, reads the current settings on the chip, shows
them via LEDs, and will reprogram the chip according to
the positions selected for the switches. It is extremely easy
to work with this programmer. FIGURE 4. The CSS555 as the heart of a very efficient
The other programmer (a deluxe version) is supplied solar engine circuit.
in the CSS555C Demonstration Kit. It works through a
computer via USB and the configuration settings can be During idle periods, it would consume a negligible level of
selected from drop boxes. The screenshot of this power, taking less than a half dozen microamps between
programming package in use shown in Figure 9 shows button pushes. Of course, a microcontroller first came to
many of the options that are selectable for this timer. mind but experience with this fan showed that it could
provide adequate comfort when its series-connected pair
A Practical Application
The following project illustrates a very practical
application of the CSS555 operating in the extended
mode. The 5” battery powered fan in Figure 10 proved
itself well worth the few dollars it cost. Whenever
conditions got a bit warm, I used it on the desk or next to
the easy chair when just a little quiet breeze was all that
was needed to maintain comfort. It was indeed quiet —
especially on the low setting — which seemed to be the
most used.
This fan was so quiet, in fact, that more often than
not, I would altogether forget the thing was on and fail to
turn it off. When I’d return to the scene and reach to turn
it on, I would find to my dismay that it was already on, but
with two dead D cells! Reminder notes placed in various
locations proved futile.
After a couple of summers of this, it finally dawned on
me that the CSS555 in extended monostable mode
offered a nice solution to this problem — and a significant
savings in D cell batteries! It could be configured to run FIGURE 5. “Walker the Robot.” He is energized by the
for around 15 minutes after just a touch of a button. solar cell on his head.
February 2016 35
5555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555

FIGURE 7. One-shot circuit using extended mode,


FIGURE 6. Waveforms of the CSS555 running as a giving an on time of 16.3 minutes.
monostable in extended mode with its counter set to 10.
Also at this setting, the timer trip levels of
the IC are set farther apart: 10% and 90% of
the supply voltage, instead of the usual 1/3
and 2/3. This lengthens the delay time (i.e.,
output pin high) by about 3X to:

(Counter)•(2.197)•(RA + 2•RB)•CT

Figure 11 shows the schematic used for


FIGURE 8. “EZ Programmer” from Custom Silicon Solutions. the fan circuit. With a counter setting of 104,
RA = 3.3M = RB, and CT = 4.7 nF, this circuit
of batteries wore down considerably below 1.5V. This was gives a measured on time of some 17 minutes, which
well below the brownout voltage for the micros on hand. works out just fine. When the fan turns off (which in itself
With the EZ Programmer, the CSS555 could be set for is very satisfying to one who has gone through so many D
“low voltage” operation, which allows it to function from cells due to forgetfulness!), if it starts feeling a bit warmish,
1.2V. just another touch of the button restores comfort. When
leaving the scene when the fan is still
going, it could be turned off via the
built-in Off-Low-High slide switch. I
usually just let it go, knowing that it
will turn itself off in a few minutes
and then be standing by ready to go
with a tap on the button tomorrow
or next week — or whenever it is
needed — with its batteries in
essentially the same condition.
A simple MOSFET to control the
motor was ruled out since (as
mentioned above) it was desired to
have operation when the supply gets
below 1.5V. This would not have met
the gate threshold voltage for the
MOSFET on hand. However, I had
several LCA717 OptMos chips in my
parts box. The LCA717 is an
excellent device for motor switching
applications. It requires only 1.2V
forward to turn on the load, and has
very low on resistance. The LED
36 February 2016
5555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555

FIGURE 9. Screenshot of the computer-based CSS555


programmer.

within needs 2 mA which is negligible relative to the


current draw of the motor, which in the fan ranges from
about 180 mA on low to 350 mA on high (with new
batteries).
The LCA717 has the advantage (for some FIGURE 10. The “O2Cool” personal fan powered by two
applications) of using a separate power source for the D cell batteries.
load, which is the way the circuit schematic here is shown.
In this fan application, both the timer and the load share
the same two series-connected D cell batteries. Figure 12
shows the completed circuit board, which was easy to fit
in the cavity of the fan base.

FIGURE 12. Circuit board of the now battery-saving fan.

Conclusion
I hope this short article will serve as an indication of
the capabilities of this relatively new timer. The documents
that CSS has prepared for these chips give much more
information. They are very thorough, easy to follow, and
have plenty of illustrations — some of which have been
presented here (with permission of course!). The
information sheets available for downloading from the CSS
website include SPICE models, timer delay and adjustable
FIGURE 11. Schematic of the one-shot circuit used for
controlling the fan motor. Note the bypass capacitor duty cycle calculators, and a collection of application
across the supply and ground; 0.1 μF suffices in such circuits showing the many ways this remarkable timer can
applications. be put to work. NV
February 2016 37
Why You Need an
Analog Front End
and How to Set It Up
By Eric Bogatin
How to make your
Post comments on this article and find any associated files
and/or downloads at www.nutsvolts.com/
magazine/article/february2016_AnalogFrontEnds.
sensors talk nice to
your microcontroller
The analog input to an Arduino Uno has a resolution of only 10 bits. On a 5V
scale, this is only about 1 mV of sensitivity. If you need more sensitivity,
don’t look at another microcontroller. Look at adding an analog front end to
your Arduino.

S
ingly or together, a general-purpose op-amp and an distinguishes “physical computing” from generalized
instrumentation amplifier — each operating on 0V to computing as with microprocessors.
5V power supplies — are the It’s the sensors that translate some
building blocks to an analog front end to quality in the physical world and turn it
any microcontroller. Here’s a practical into an electrical quantity — a voltage, a
way you can turn your Arduino into a current, a resistance — which may vary
high performance sensor measuring with time or frequency. It’s up to us as
instrument. gadget designers to set up the
microcontroller to read this electrical
Physical Computing quantity and turn it into information we
can act on.
An Arduino is about as smart as a We have three options for inputs
fruit fly. I base this on the gate count of from sensors to an Arduino: a high level
the Atmel AVR 328 microcontroller — the encoded digital signal; a low level digital
brains of the Arduino board — which is a voltage; or an analog voltage.
little less than 100,000 gates, including Some sensors — like the T5403
the 32K of memory and all the registers. sensor from SparkFun shown in Figure 1
A fruit fly has 100,000 neurons. — have a lot of electronics already
Just as the brain of a fruit fly integrated into them. This sensor
processes sensory input information measures barometric pressure, turns it
about the world around it and translates into an electrical signal, and then
this into a fruit fly’s action, an Arduino encodes this in an I2C digital interface.
(and all microcontrollers) processes FIGURE 1. T5403 barometric All the electronics on the sensor
inputs from the outside world and turns pressure sensor with an board — the sensor itself, the analog
them into outputs. This is really what I2C interface. front end, the ASIC, and the memory —
38 February 2016
FIGURE 3. Close-up of the TMP36
temperature sensor.

FIGURE 2. The electronics that turn the resistance


measurement into an I2C signal that is then read by the
microcontroller (source: EPCOS datasheet).

dramatically simplify what we must do to integrate this


sensor with the microcontroller. In this case, just plug
it into a few digital pins and install the library. All the
low level functions of reading the resistance,
converting it to a voltage, filtering it, conditioning it,
even compensating the electronics with the
measured onboard temperature, and ending up with
a calibrated barometric pressure is all done “under
the hood” for us by the electronics shown in Figure
2. That’s a lot of processing power in a tiny space —
all for less than $15.
Some sensors output a low level digital signal,
like a rain gauge. This sensor just sends a click
every time a bucket is filled and emptied. It’s up to
us to count the clicks with a digital I/O pin and
keep track of the total rain fall.
Then, there are all the sensors which just FIGURE 4. Measured temperature of the TMP36 when
I touched it and let go.
output an analog signal. This is where the analog
front end conditioning we add to the system can
dramatically improve the quality of the measured back is a discrete level — a number between 0 and 1023.
information. We sometimes refer to the units of these levels as analog-
to-digital units (ADUs). When analog accuracy is
Limitations to Sensor Measurements important, or in general as a good habit, I use the 3.3V
onboard reference as the reference to the ADC channels
in an Arduino (see the sidebar). I also add a large capacitor to the
An example of a sensor which outputs a voltage is the reference channel just to reduce any AC noise on this rail.
TMP36 temperature sensor also from SparkFun. It comes With a voltage scale of 0V to 3.3V, this means the
in a small three-terminal plastic package shown in Figure voltage resolution is 3.3/1023 = 3.2 mV resolution. In
3. One pin is connected to +5V; another pin is connected general, we should measure the reference voltage level for
to gnd; and the middle pin is the voltage output that is the ADC, Vref, with a three-digit DMM. Then, the voltage
directly proportional to temperature, with a sensitivity of on the pin in volts is V[volts] = ADUs/1023*Vref.
10 mV/°C and 0V at -50°C, or 100°C/V. The TMP36 sensitivity is 100°C/V. With a discrete
The output voltage from this temperature sensor can level resolution of about 3.2 mV, the Arduino has about a
be read directly by one of the analog input pins on the 0.3°C per ADU resolution. This may be fine for reporting
Arduino. Here’s where we encounter the fundamental ambient temperature, but may not be sensitive enough
limitations with the Arduino analog input pins. when we care about very small temperature changes.
Each analog input pin of the Arduino is a 10-bit ADC I wrote a sketch to read one of the analog channels of
(analog-to-digital converter). This means there are only an Arduino Redboard from SparkFun. I averaged about
2^10 = 1024 discrete voltage levels the ADC can report. 100 readings in about 100 msec, and scaled the voltage
When we “read” an analog pin, the integer that comes into a temperature value. The analog channel reading in
February 2016 39
ADUs was converted into a temperature in my sketch I printed the temperature values every 100 msec to
using temp [degC] = (ADU/1023 x Vref) * 100 – 50. The the serial port and used MakerPlot to read the serial port
50 is there because the output voltage is 0V at -50°C. and plot the temperature. I did no calibration at all of the

Improve the Quality of Your Analog introduce errors; the magnitude of which will depend on what else
the microcontroller is doing. This sort of problem is incredibly hard
Measurement Using the 3.3V Pin as the Vref to debug. Better to avoid the chance of it ever happening.
The way around this problem is to use either another external
The ADC (analog-to-digital converter) pins of the Arduino reference voltage source or use the 3.3V reference supply brought
compare the voltage at their input to a reference voltage to out on many Arduino boards. On the SparkFun Redboard, this is a
generate the 1024 different output levels. The default condition is to separately regulated supply which has nothing connected to it. Its
use the +5V rail on the die of the microcontroller as the reference voltage noise is very low. I measured it to be less than 2 mV peak-
voltage. to-peak — even with 42 mA of switching current from the I/O pins.
You might think that the + 5V rail is very low noise; after all, it Since it is available for free, it’s always a good habit to use this
comes from either the regulated USB power supply or the onboard as the ADC Vref. The downside is that this will limit the maximum
regulated +5V supply if you are using an external power supply. If voltage range the ADC can sense. With an analog front end, this is
the microcontroller is not driving any outputs and its current draw not an important limitation.
on the power rail is low, then the noise on the power rail can, in To use an external reference voltage, in the void setup()
fact, be low. function, you must add the line:
I wrote a sketch for my Arduino to toggle five digital outputs off
and on really fast. The rail noise I measured on the board was about analogReference(EXTERNAL);
5 mV peak-to-peak when the outputs were switching, but not driving
anything. This is about the resolution of the ADC and would I also measure the analog reference voltage with a three-digit
contribute negligible ADC measurement noise. DMM and add a line near the beginning of each sketch where I can
However, when the digital I/O pins draw some current, this has add the specific reference voltage level:
to come through the impedance of the power rail supply and its
output voltage — which everything on-die uses — will drop. float Vref = 3.290;
I connected the five toggling outputs into 330 ohm resistors
which then drove LEDs. We can estimate the current draw of each Then, when I read an analog pin, I can calculate the actual
I/O. There is about 25 ohms of output impedance on the output voltage on that pin using:
transistor of each Arduino I/O pin. There is about a 2V drop across
an LED. If the output voltage from one I/O pin when not driving a Value_volts = analogRead(A0) /1023 * Vref
load is 5V, then the voltage drop across the (25 + 330) ohm resistors
is 5V – 2V = 3V, and the current draw from the pin and the
power rail per pin is:
(5V — 2V)
I = = 8.5 mA
355Ω
I had five I/O pins toggling. This was a total current
draw of 8.5 mA x 5 = 42 mA of current from the +5V rail. I
measured the voltage drop on the +5V rail on the board as
about 35 mV peak-to-peak. This corresponds to an output
impedance of the power supply of:

ΔV (35 mV)
Routput = = = 0.83Ω
ΔI 42 mA
This is very close to what I measured independently
for a USB power supply. I measured an onboard regulator
output impedance of the Redboard (when powered by an
external 9V supply) to be 1.4 ohms, in comparison.
This 35 mV of noise on the board level power rail is
almost identical to what I measured as the rail noise on the
die itself. Of course, we can’t probe the on-die power rail
directly, but we can see the on-die power rail voltage by FIGURE A. Voltage noise on the various power rails while five digital I/Os
setting a digital I/O pin as HIGH, and measuring its output toggled off and on. Top trace: Voltage on one of the digital pins showing its
voltage. After all, when its output is HIGH, the output pin is voltage switching. Next two traces down: Measured rail voltage noise on
effectively connected to the +5V on-die voltage rail. This is the
same voltage that would be used by the ADC reference the board and on the output of a digital pin set to HIGH. This shows the 35
channel in its default condition. Figure A shows all the mV noise on the power rail when 42 mA of current switches. Fourth trace
measured voltages. down: The +5 V rail voltage noise on the board with no current drawn by
The consequence of this is that when there is little the I/O. The noise level is down to 5 mV. Bottom trace: Voltage noise on the
current drawn by the microcontroller, there is probably no +3.3 V reference with 42 mA of switching current. The scale for all except
impact on the measurement accuracy of the ADC channels.
However, if the microcontroller is also switching current the digital I/O signal is 10 mV/div. The triangle shape is because the five
around, the reference voltage will drop and this will contribute I/O are sequentially turned on one at a time and then
to measurement errors in the ADC values. turned off one at a time.
More importantly, this voltage noise on the Vref line will

40 February 2016
sensor. Figure 4 shows the measured temperature when I Voutput = G x (V+ — V-)
touched the sensor and let go.
In this example, you can see the ambient temperature The value of G is often as high as 1,000,000. The
of about 22°C before I touched the sensor. It rose about secret to using op-amps effectively is using combinations
2°C quickly in about three seconds. I let go and it cooled, of R and C elements in a feedback circuit to enable useful
taking a longer time. features. Whole books are written about op-amp circuits
On the cooling leg, you can clearly see the 0.3°C with specialized functions. A really great handbook by the
temperature steps corresponding to the resolution limit of legendary Walter Jung called Op-Amp Applications
the Arduino’s ADC. This is not a sensor limitation; it is an Handbook can be downloaded for free. The circuit we’ll
Arduino limitation. look at in this article is the non-inverting amplifier.
When the signal we care about is a small signal, we In the non-inverting amplifier, the input signal goes
just don’t have much sensitivity available from the 10-bit into the V+ pin, and a simple resistor divider circuit
Arduino analog inputs. connects the output pin to the V- input as shown in Figure
Problem #1 is the small resolution available with the 5. The gain in this circuit is:
10-bit ADC. We just can’t see small changes with only 3

( )
mV resolution even using the smaller Vref of 3.3V. R2
G= 1+
Problem #2 is there is a DC offset on the signal R1
(about 0.75V in this example). We can improve this by
adding some gain, but we have to be careful not to
exceed the 3.3V maximum voltage input to the ADC. This Since this amplifier is often the first circuit to interface
would be a maximum gain of about four. with a sensor, it is sometimes referred to as a pre-amp. An
Problem #3 — just marginally an issue with this sensor important feature of the amplifier — in addition to
— is the output impedance of the sensor and what the amplifying the signal — is to change the output impedance
ADC pin needs to see. Section 23.6.1 of the Atmel of the sensor. It can take a sensor with really high output
manual states: “The ADC is optimized for analog signals impedance and provide a comparable signal level (or even
with an output impedance of approximately 10 kΩ or higher) with an output impedance of a few ohms. This
less.” Where this spec comes from is explained in the solves problem #3.
sidebar. Among the three top suppliers of op-amps — Analog
The output impedance of a sensor is a measure of Devices, Linear Technology, and Texas Instruments (TI) —
how much current it can source or sink. According to its there are almost 500 different versions to choose from. I
specs, the TMP36 has a maximum output current of about
50 uA of current draw possible. With roughly a 1V output The Input Impedance of an Arduino ADC Pin
voltage, this is an output impedance of 1 V/50 uA = 20K The Arduino input impedance of an ADC (analog-to-digital
ohms. This is in the gray area of possibly a problem — converter) pin is specified as 100 megohms. It sounds high and would
especially when looking at fast data acquisition. be wonderful, but this is not the complete story. The first circuit
One way of getting around these three problems and element the pin sees on-die is a multiplexer which switches each of
the six Arduino ADC pins into the actual sample and hold circuitry to
enabling accurate and high resolution measurements from be read by the ADC circuitry. This input has the equivalent of 14 pF of
a wide variety of sensors is using an analog front end capacitance.
between the sensor output and the microcontroller input When the Arduino pin is read, the pin is switched into this
to condition the analog signal. capacitance. The sensor driving this pin must charge up this 14 pF of
capacitance before it is read to get an accurate value. If it is still
charging when the pin is read, the value will be inaccurate.
An Analog Front End Essential Element: If the source impedance of the sensor is 10K ohms, then the RC
time constant is 10^4 ohms x 14 x 10^-12 F = 0.14 usec. If we wait for
the Op-Amp six time constants, the signal will be within 0.2% of its final value. This
is 1 μsec — about the fastest possible acquisition time for an analog
We refer to all the electronics from the sensor channel.
element to the input pin of the ADC as the analog front If the output impedance of the sensor looks like a resistor of no
end. While there is a huge variety of off-the-shelf building more than 10K ohms, then the voltage read by the ADC will have
block circuits we can use in the analog front end, the two settled to its final value before the voltage is actually read. If the
output impedance is larger than 10K ohms, there is a chance the
most important building blocks to solve all sensor voltage will not have stabilized before it is read and the first
interface problems are operational amplifiers and measurement may not be accurate.
instrumentation amplifiers. An operational amplifier — This sort of problem is incredibly hard to debug. As risk reduction
affectionately shortened to op-amp — is a super high gain in your design, just avoid the problem by always using a low enough
output impedance for the sensor.
differential amplifier. Its output voltage is proportional to This is the origin of the Atmel spec recommending the sensor
the difference in voltage between its two input pins, output impedance be less than 10K ohms to drive one of the ADC pins
referred to as the V+ and V- inputs: and not lose accuracy even in the worst case.
February 2016 41
100°C/V. With a resolution of 0.0032V, this is a
temperature resolution of 0.32°C.
With a gain of 3.245, the output sensitivity of
the pre-amp is 100/3.245 = 30.8°C/V. The voltage
resolution of the 10-bit ADC is still 0.00323V, but
this is now equivalent to 30.8 x 0.00323 = 0.1°C.
Much better.
This helps solve problem #1. Figure 6 shows
the recording of the raw output from the TMP36
sensor into A0 of the Arduino’s ADC, and the
output of the LM358 with the gain of 3.245 into
A1. I converted the ADU values from A1 into
temperature using:

FIGURE 5. Circuit diagram of the non-inverting amplifiers using an Temp[degC] = (ADU/1023*Vref/Gain_opAmp) x 100 — 50
op-amp, taken from Walter Jung’s Op-Amp Applications Handbook.
An Analog Front End Essential
Element: the Instrumentation
Amplifier
We still have problem #2. The voltage out of
the pre-amp is about 2.5V. We want to see small
changes on top of this large DC value. We really
would like to subtract off a DC value and amplify
what is left. This is the perfect job for an
instrumentation amplifier.
An instrumentation amplifier is very similar to
an op-amp. Its output voltage is related to the
difference voltage between its two inputs by:

Voutput = G x (V+ — V-)


FIGURE 6. Measured temperatures of the same TMP36 using the scaled
value directly from the sensor and after a gain of 3.245 in a pre-amp. However, the gain in an instrumentation
Note the resolution improvement from 0.3° to 0.1°. amplifier is typically adjustable from only 1 to
1,000. It does not use feedback from the output
voltage to the input; instead it’s just a straight up
found one that I use all the time because it has pretty differential amplifier.
good specs, runs off the +5V single supply from an Instrumentation amplifiers are most commonly used
Arduino, and comes in an eight-pin DIP. Best of all, it only to amplify small differential signals such as in
costs $0.29. As a bonus, it comes with two independent electrocardiogram monitoring or in resistance based
op-amps in one package for this low price. sensors. They are at the heart of a Wheatstone bridge.
I use the LM358 op-amp — manufactured by TI and For our temperature sensor application, we can use
available from Jameco and other distributors. It’s not the the instrumentation amplifier to subtract off the DC
highest performance op-amp, but at this price, is a great voltage we provide at the V- pin and amplify what is left.
general-purpose version and is incredibly easy to use. There are hundreds of different instrumentation
In the application of the TMP36 temperature sensor, amplifier options to choose from — each with slightly
the nominal output signal level is about 0.75V at room different specs and price points. The instrumentation
temperature. I wanted to increase this signal level so it is amplifier I use the most with an Arduino is the AD623
higher, but still below the 3.3V of the Vref. I chose to use manufactured by Analog Devices and available from
a gain of about three, resulting in a nominal voltage level Jameco.
out of the op-amp of about 2.25V. I used resistors of 22K It runs off the single +5V from the Arduino, comes in
ohms and 9.8K ohms, resulting in a gain factor of (1 + an eight-pin DIP package, is really easy to set up, and
22K/9.8K) = 3.245. costs less than $5. The gain is selectable with a single
The original sensitivity of the TMP36 sensor was resistor, Rg, from 1 to 1,000 using:
42 February 2016
Resources
T5403 barometric pressure sensor from SparkFun:
www.sparkfun.com/products/12039

SparkFun Redboard:
www.sparkfun.com/products/12757

TMP36 temperature sensor:


www.sparkfun.com/products/10988

Makerplot for reading the serial port data and plotting:


www.makerplot.com

Atmel Manual:
www.atmel.com/images/doc8161.pdf

A great op-amp applications handbook


you can download for free:
www.stu.edu.vn/uploads/documents/080509-212459.pdf

L358 from Jameco:


www.jameco.com/webapp/wcs/stores/servlet/ FIGURE 7. Complete circuit with sensor, pre-amp, and
Product_10001_10001_23966_-1 instrumentation amplifier.
AD623 from Jameco:
www.jameco.com/webapp/wcs/stores/servlet/Product
Display?langId=-1&storeId=10001&productId=1780985
&catalogId=10001&CID=CAT151PDF

Rg = 100 kΩ/(G − 1)

In this application, I wanted to use a gain of 10.


The DC voltage was provided by a simple 10K ohm
10-turn pot connected between the 3.3V reference
and ground. The center tap signal — which I could
adjust — was connected to the V- input of the
AD623. The final circuit with the TMP36, pre-amp,
and instrumentation amplifier is shown in Figure 7.
This analog front end circuit was implemented in
a breadboard adjacent to the Arduino Redboard.
The amplifiers were powered off of the 5V rail of the
Redboard. The two sensitive voltages used the 3.3V
reference pin on the Redboard.
I added a few capacitors to the voltage rails to
keep the noise down. Figure 8 shows this
configuration.
In this circuit, the original 100°C/V sensitivity FIGURE 8. The complete system configured on a breadboard connected
was changed to 100°C/V /3.245/10 = 3.1°C/V. With to an Arduino.
a resolution of the least significant bit still 0.00323V,
the temperature resolution is 3.1 x 0.00323 = 0.01°C. plotting tool, MakerPlot.
Now we’re talking. With these three different temperature readings
We have three different sensitivity levels of available, I did the same experiment: touching the sensor
temperature measured in this circuit: the direct readings; very briefly and watching the temperature rise quickly and
the direct readings increased in sensitivity by 3x; and the fall slowly. In the slow decline in temperature, the
direct reading increased in sensitivity by 30x. All the resolution limits of 0.3°C and 0.1°C are clearly seen.
conversion from ADUs into voltage and then into The smoothly varying temperature on this plotted
temperature is done in the sketch. scale of 0.1°C per division is an indication of the 0.01°C
It’s the final temperature values which were printed to resolution of the signal after the instrumentation amplifier.
the serial port and available for plotting by my favorite Figure 9 shows these comparisons.
February 2016 43
FIGURE 9. Shows the same experiment as before. I touched the sensor
briefly and recorded the unconditioned voltage from the sensor, the
voltage from the pre-amp, and the voltage from the instrumentation
amplifier. You can see the impact of the higher sensitivity on the
smoothness of the plots. Top trace: Resolution of 0.3°C from the TMP36.
Middle trace: Resolution of 0.1°C from the pre-amp. Bottom trace:
Resolution of 0.01°C from the instrumentation amplifier.

Conclusion
When we have the good fortune of using a sensor FIGURE 10. Maxwell — the cat scanner — monitoring every
with a high level voltage and a low output impedance, we aspect of this experiment.
can just connect it to one of the ADC pins of an Arduino
and get 10 bits of resolution with little effort. large DC offset, we can leverage an analog front end to
However, if we want to push the limits of sensitivity or condition the signal and get the most value from the 10-
take advantage of sensors which have high output bit ADC in the Arduino.
impedance, small scale signals, or small signals riding on a Two essential devices dramatically simplify the design
and implementation of an analog
front end: the op-amp and the
instrumentation amplifier. The
LM358 op-amp is the perfect
general-purpose version and the
AD623 is the perfect general-
purpose instrumentation amplifier
which play well with an Arduino.
Of course, there is often more
than one right answer to any design
challenge and there are multiple
ways of interfacing sensors to a
microcontroller. The op-amp and
instrumentation amplifier are sharp
arrows to have in your quiver of
design solutions.
To ensure the integrity of the
measurements in this article, I
incorporated a cat scanner to
monitor each operation.
Figure 10 shows the bench set
up with the cat scanner in
operation. NV
44 February 2016
ELECTRONET
For the ElectroNet
online, go to
USB
USB-FIFO
Add USB to your next project--
It's easier than you might think!
USB-UART USB/Microcontroller Boards
RFID Readers Design/Manufacturing Services Available



www.nutsvolts.com Absolutely NO driver software development required!
click Electro-Net

 



www.dlpdesign.com






)

RoHS
www.servomagazine.com

COMPONENT
COMPON T LEDss • LE
LED
LED BULBS
ULBS
BS
S • LED ACCENT
A EN
ACCEN
ENT LIGHTS
LIGH

Wanna learn more about electronics?


www.nutsvolts.com
Did you know that Nuts & Volts Did You Know Preferred
now has a weekly content Subscribers get access to all the
newsletter? Want to get it? digital back issues of
You have three ways to sign up:
• Visit us on Facebook and click on “Join My List.” Nuts & Volts for free?
• Using your cell phone, send “NVNEWSLETTER”
as a text message to 22828. Call for details
• Visit the Nuts & Volts FAQs to sign up at
nutsvolts.com/faqs 1-877-525-2539
February 2016 45
THE DESIGN CYCLE
■ BY FRED EADY

ARMed and Dangerous


I’ve decided to ARM myself. No, I didn’t go
out and buy a fully automatic black market
M4A1, and no, I didn’t plop down big bucks
for a brand new chrome-plated Colt .45 semi-
STM32F0308-DISCO’s integral USB portal. The
automatic pistol. I am ARMed with a Segger STM32F0308-DISCO can also be powered externally with
+5 or +3.3 VDC.
J-Link PRO that is fully supported by the
Segger Embedded Studio. By the time you The STM32F030R8T6
finish reading this month’s offering, you will The STM32F030R8T6 is the Number 2 device in its
also be ARMed and dangerous. family when measured by its internal resources. If you are
new to ARM, there is no reason to fear this “new-to-you”
technology. ARM devices are made up of Flash, SRAM,
Target Practice UARTs, SPI portals, I2C subsystems, clocks, timers, and I/O
pins. You can say the same for any other general-purpose
The bull’s eye is in the form of an STM32F030R8T6, microcontroller. In addition, most ARM microcontrollers
which is mounted on the STM32F0308-DISCO (DISCO for are dirt cheap and deliver a mighty punch for the penny.
DISCOVERY) evaluation board you see under the lights in The STM32F030R8T6 comes standard with 64K of
Photo 1. The evaluation board is modest in terms of Flash and 8K of SRAM. There are seven 16-bit timers, two
onboard goodies. However, every STM32F030R8T6 I/O SPI portals, two I2C portals, two USARTs, and 18 channels
pin is pulled out to a male header post. So, you can of ADC (analog-to-digital converters). Depending on how
exercise the STM32F030R8T6 I/O subsystem to your you use its resources, the STM32F030R8T6 can man up to
heart’s content. 55 GPIO pins. The maximum operating speed is 48 MHz
The intent of the STM32F0308-DISCO evaluation with a GPIO toggle rate of 12 MHz. If you need a
board is to allow low cost ARM development using an watchdog timer, the STM32F030R8T6 has one of those
entry-level Cortex M0 device. To that end, an onboard ST- pinned up too. If you count them all up, there are 11
LINK/V2 programmer/debugger is incorporated into the timers available.
evaluation board’s design. Power is derived from the Operational power supply voltages for the
STM32F030R8T6 range from 2.4 VDC to 3.6
VDC. The STM32F030R8T6 also includes a
real time clock that can be backed by an
external battery. A useful feature of the
STM32F030R8T6 that is not found on the run-
of-the-mill microcontrollers is its SysTick timer.
The SysTick timer is a free running 24-bit
countdown timer that can be used in various
ways. The ability to assign the 55 GPIO pins to
external interrupt duty is also a useful
STM32F030R8T6 quality. Interrupt handling is
supported by the STM32F030R8T6’s NVIC
(Nested Vectored Interrupt Controller).
The STM32F030R8T6 is fully supported by
datasheet documentation, reference manuals,
code libraries, and sample code. All of the
■ Photo 1. There are only a couple of user LEDs and user pushbuttons aforementioned information can be had for a
on this little evaluation board. If you want to light up the world or drive free download.
some external relays, the STM32F0308-DISCO comes with an extra
blank printed circuit board that can be fitted to the evaluation board’s If you’re an old hat at microcontroller
pair of headers. design and programming but have no ARM
46 February 2016
ADVANCED TECHNIQUES FOR DESIGN ENGINEERS

■ Screenshot 2. We are starting from scratch and will be


■ Screenshot 1. Since we will only be working with the writing code for an STM32F030R8T6 Cortex-M
STM32F030R8T6, we will only install the STM32F0xx CPU microcontroller. This entry window informs the Segger
support package. Embedded Studio as to the type of project template we
wish to use. Note that we have also defined the location of
experience, I recommend reading its datasheet through. the new project.
You will be amazed at how much the STM32F030R8T6
has in common with your favorite microcontroller.

Segger Embedded Studio


The Segger Embedded Studio (referred to as SES for
the remainder of this article) consists of a code editor, a
C/C++ compiler, and an integrated debugger that can take
advantage of the Segger J-Link PRO hardware
debugger/programmer. SES is a free download as long as
you don’t use it commercially. In free mode, the Studio is
unrestricted and has no time limit. It’s very easy to use
and comes well documented.

Setting Up for the STM32F0308-DISCO


The SES is a powerful ARM development
environment. However, out of the box it doesn’t have a ■ Screenshot 3. It would be a good idea to let the Segger
Embedded Studio know which Cortex-M microcontroller we
clue as to what we want it to do. So, the first thing we want to work with. So, we tell it here.
have to do is provide the SES with STM32F030R8T6
information that it can use to help us achieve a successful
compilation of our code.
Since we will only be working with the
STM32F030R8T6 this time around, we’ll only load the
STM32F0xx CPU support package. The support package
contains project templates and system files we will need arguments.
to work with the STM32F030R8T6. The STM32F0xx CPU
support package is installed using the SES’s Package
Manager. As you can see in Screenshot 1, the STM32F0xx
CPU support package is installed and ready for use.
RESOURCES
In Screenshot 2, we inform the SES that we would like JumpStart API J-Link PRO
to write some C or C++ code targeting an STM32F0xx JumpStartMicroBox Segger
Cortex-M microcontroller. The executable code template ImageCraft www.segger.com
has been selected as shown in the screen capture. www.imagecraft.com
February 2016 47
Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/
magazine/article/february2016_DesignCycleARMDevelopment.

programming/debugging adapter portal for


the J-Link PRO.
The J-Link PRO you see in Photo 2
sports a standard five-pin JTAG interface
positioned on a 20-pin male header. The
STM32F030R8T6 uses a two-pin SWD
(Serial Wire Debug) programming
interface. SWD replaces the five-pin JTAG
interface with a clock pin (SWCLK) and
bidirectional data pin (SWDIO). The
SWCLK signal is attached to the JTAG TCK
pin, while the SWDIO signal overlays the
JTAG TMS signal. The SWD conversion is
very easy to perform. The construction
plan is laid out in Schematic 1 and the
■ Screenshot 4. Our new project is ready to be fleshed out. This is also a physical result is shown in Photo 3.
good time to explore the features offered by the Segger Embedded Studio. We must remove the pair of CN2
jumpers. Removing the jumpers severs the
logical link between the STM32F0308-
DISCO’s built-in ST-LINK/V2 programmer/
debugger and the STM32F030R8T6. We can
still get power for the STM32F030R8T6 via
the STM32F0308-DISCO’s USB portal.
The original idea behind the CN2
jumpers is to allow the STM32F0308-
DISCO’s built-in ST-LINK/V2 to be used as a
standalone programmer/debugger via the
CN3 header pins.
If we’ve assembled our SWD interface
correctly, the SES should see the J-Link PRO
■ Photo 2. In addition to its standard programming/debugging duties, the and allow a connection. Screenshot 5
J-Link PRO’s Ethernet interface allows multiple unit debugging over an confirms our success. The STM32F0308-
Ethernet network. Our immediate need is the J-Link PRO’s ability to DISCO is powered up and attached to the J-
interface to our STM32F030R8T6 using an SWD programming interface.
The target socket is loaded with a 1.27 mm SWD adapter. Link PRO, which is recognized by the SES.
It’s time to write some code.

We have given enough information to the SES to build First Shots


a skeleton of our project. SES has also assembled the
necessary include and startup files according to the entries If we are to be successful ARM programmers, we
we made during the new project setup process. The must understand the ARM architecture. Although reading
leftmost area of Screenshot 4 displays our DesignCycle1 the datasheets and reference manuals is a great way to get
project layout, while the right hand area of Screenshot 4 familiar with ARM, there is another way you can increase
welcomes us to the SES. This is a good place to stop and your ARM knowledge. Once you’ve done your reading,
explore the features of the SES. you can apply what you’re learned to help with your
understanding of the contents of the stm32f0xx.h file. In
Attaching the J-Link PRO this case, the stm32f0xx.h file is formally known as the
CMSIS (Cortex Microcontroller Software Interface
Now that we have the SES pointed in the Standard) Cortex-M0 device peripheral access layer
STM32F030R8T6 direction, we will need to perform some header file. The stm32f0xx.h header file consists of a
hardware work that will allow us to utilize the combined configuration section that allows us to specify the target
power of the J-Link PRO and the SES. device and crystal frequency. The stm32f0xx.h header file
The STM32F0308-DISCO is packaged with a bare also contains data structures and address mapping for all
through-hole printed circuit board (PCB) whose hole pitch of the device’s peripherals.
(0.10 inches) matches that of the STM32F0308-DISCO’s Peripheral register declarations, bit definitions, and
pair of male headers. We will use this bare PCB to craft a macros to access the peripheral hardware registers are
48 February 2016
■ Schematic 1. All we need to
convert a five-pin JTAG interface
into a two-pin SWD interface is a
20-pin male header and some
wire wrap wire.

and the resultant SYSCLK frequency (48 MHz). The


system_stm32f0xx.c file also dictates the AHB (Advanced
High-Performance Bus) and APB (Advanced Peripheral
Bus) prescaler settings. The AHB and APB busses are all
■ Photo 3. This is a shot of the STM32F0308-DISCO set to run full speed without prescaling. This is important
mounted on the bare printed circuit board. The 20-pin information in that our LEDs are attached to GPIOC,
JTAG header is wired into the female headers according
to Schematic 1. which operates on the AHB2 bus. Here is the code to
enable the GPIOC peripheral clock:
also part of the stm32f0xx.h header file. Being able to
associate the contents of the stm32f0xx.h header file with void main(void)
{
the datasheet and reference manual information is key to // Enable GPIOC Peripheral clock
understanding how the ARM microcontrollers work and RCC->AHBENR |= RCC_AHBENR_GPIOCEN;
how to write code for them. With that,
let’s begin by placing a reference to the
stm32f0xx.h header file at the beginning of
our code:

#include <stm32f0xx.h>

The STM32F0308-DISCO schematic


can be found in the user manual
(UM1658). Once you access the
schematic, you will see that the
STM32F0308-DISCO’s pair of user-
accessible LEDs are attached to GPIO pins
PC8 and PC9. The SES project creation
process placed the system_stm32f0xx.c file
in our project tree. The contents of the
■ Screenshot 5. The STM32F0308-DISCO is powered up and attached to the
system_stm32f0xx.c file define our clock J-Link. The Segger Embedded Studio is signaling that it’s
source (internal 8 MHz HSE with 6x PLL) ready to go to work.
February 2016 49
So, our code points to the RCC boundary address
(RCC), accesses a member of the structure within the
boundary address space (AHBENR), and changes its value
by setting a bit (RCC_AHBENR_GPIOCEN).
Now that the GPIOC bus clock is running, let’s move
on and set up the GPIO pins PC8 and PC9. We must
write some code to define each pin’s mode (input or
output), output type (open drain or push-pull), speed, and
pull-up status. Here is the code to define the mode:

■ Screenshot 6. This capture of the RCC reset and clock // PC8,PC9 = output mode
control structure was pulled from the stm32f0xx.h header GPIOC->MODER |= (GPIO_MODER_MODER8_0);
file. We are interested in the AHB entry. GPIOC->MODER |= (GPIO_MODER_MODER9_0);

GPIOC runs on the AHB2 bus in the boundary


Let’s break down the clock enable code. Take a look address space 0x48000800–0x48000BFF. This is verified
at Screenshot 6, which is a capture of the RCC (Reset and by address entries in the stm32f0xx.h header file:
Clock Control) structure contained within the stm32f0xx.h
header file. The RCC peripheral operates on the AHB1 #define PERIPH_BASE ((uint32_t)0x40000000)
#define AHB2PERIPH_BASE (PERIPH_BASE +
bus with a boundary address space of 0x4002100 – 0x08000000)
0x400213FF. This boundary address is defined as the #define GPIOC_BASE (AHB2PERIPH_BASE +
0x00000800)
RCC_BASE within the stm32f0xx.h header file:
Now, we can once again define the pointer to the
#define PERIPH_BASE ((uint32_t)0x40000000) structure:
#define APBPERIPH_BASE PERIPH_BASE
#define AHBPERIPH_BASE (PERIPH_BASE +
0x00020000) #define GPIOC ((GPIO_TypeDef *) GPIOC_BASE)
#define RCC_BASE (AHBPERIPH_BASE +
0x00001000)
Screenshot 7’s first entry is our structure
Now that we have the boundary address, we can element/register of interest (MODER). You can also see
define RCC as a pointer to a structure. The structure is the other GPIO pin properties whose knobs we will need
located at address RCC_BASE: to twist.
Here are the GPIO mode bits that will configure PC8
#define RCC ((RCC_TypeDef *) RCC_BASE) and PC9 as outputs:

We can use the structure pointer to access elements #define GPIO_MODER_MODER8_0


((uint32_t)0x00010000)
within the RCC address space. These elements are defined #define GPIO_MODER_MODER9_0
in Screenshot 6 and consist of a set of registers. ((uint32_t)0x00040000)
Registers are normally made up of a number of bits.
We want to control bits within the registers. In this case, The GPIO pins are configured as push-pull by default
we want to set a bit that enables the GPIOC bus clock: on power-up or reset. So, the code we are writing is
academic. We’ll write it anyway:
#define RCC_AHBENR_GPIOCEN
((uint32_t)0x00080000) // push-pull output
GPIOC->OTYPER &= ~(GPIO_OTYPER_OT_8);
GPIOC->OTYPER &= ~(GPIO_OTYPER_OT_9);

Note that we cleared the output type bits (&= ~)


versus setting them (|=). If you are an AVR programmer,
this type of bit set/clear coding is something you do quite
often. I think you’ve got the idea. So, here’s all of the
GPIO configuration code:
// Enable GPIOC Peripheral clock
RCC->AHBENR |= RCC_AHBENR_GPIOCEN;
// PC8,PC9 = output mode
GPIOC->MODER |= (GPIO_MODER_MODER8_0);
■ Screenshot 7. The GPIO structure elements necessary to GPIOC->MODER |= (GPIO_MODER_MODER9_0);
configure all of the STM32F030R8T6’s GPIO subsystems are // push-pull output
defined here. GPIOC->OTYPER &= ~(GPIO_OTYPER_OT_8);
50 February 2016
GPIOC->OTYPER &=
~(GPIO_OTYPER_OT_9);
// max speed
GPIOC->OSPEEDR |=
(GPIO_OSPEEDER_OSPEEDR8);
GPIOC->OSPEEDR |=
(GPIO_OSPEEDER_OSPEEDR9);
// no pullup/down resistors
GPIOC->PUPDR &=
~(GPIO_PUPDR_PUPDR8);
GPIOC->PUPDR &=
~(GPIO_PUPDR_PUPDR9);

LEDs are for Blinking


The structure pointer scheme worked
well for us in the GPIO configuration
code. Guess what? It works equally well
for the manipulation of the GPIO pin ■ Screenshot 8. I can’t show you the blinking LEDs, but I can give you an
states. This code should look familiar: idea of how the Segger Embedded Studio looks when running
in full debug mode.
do{
GPIOC->BSRR = GPIO_BSRR_BS_9;
//set PC9 STM32F030R8T6’s GPIO pins, the door is open to coding
GPIOC->BSRR = GPIO_BSRR_BR_8; for the remaining STM32F030R8T6 peripherals.
//reset PC8
delay(); In the meantime, you can add the STM32F030R8T6, J-
GPIOC->BSRR = GPIO_BSRR_BR_9; Link PRO, and SES to your Design Cycle. NV
//reset PC9
GPIOC->BSRR = GPIO_BSRR_BS_8;
//set PC8
delay();
}while(1);

You can find a reference to the BSRR register in


Screenshot 7. We already know how GPIOC fits into the
picture. As one would expect, the GPIO_BSRR_BS_x bit
patterns are contained within the st32f0xx.h header file:
#define
#define
GPIO_BSRR_BS_8
GPIO_BSRR_BS_9
((uint32_t)0x00000100)
((uint32_t)0x00000200)
(480) 837-5200
#define GPIO_BSRR_BR_8 ((uint32_t)0x01000000)
#define GPIO_BSRR_BR_9 ((uint32_t)0x02000000)

Our LED blinky program won’t work without some


code representing the delay() function:
void delay(void)
{
unsigned long i,scratch8;
for(i=0; i<0x000FFFFF; ++i)
{
++scratch8;
}
}
The delay code is nothing more than standard C.
There’s no science to this delay routine. I just stuffed in
enough “Fs” to make a half-second blink rate.

More to Come
I’ll leave you with Screenshot 8, which is a screen
capture of the SES running our little blinky program in
debug mode. Now that we can flip bits on the www.embeddedARM.com
February 2016 51
NEAR SPACE ■ BY L. PAUL VERHAGE

North American — Guatemala


Near Space Alliance
Near space encompasses
the entire planet;
therefore, it’s not
surprising to hear that
amateur radio operators
in other nations are
running their own
programs. When an
amateur radio operator Figure 2: The pallet is a 10 inch square of 1/4”
Coroplast and the spacer is made from a
from Guatemala asked sheet of the thinner 3/16” thick Coroplast that
for help in kicking off his was cut, folded, and taped together. Most
glue will not adhere to polypropylene, so I
first launch, the near resorted to taping the ends of the Coroplast
space community together. The spacer stands four inches tall.
couldn’t resist but help
Figure 1: A gift to Guatemala. This near
out. spacecraft and a weather balloon were
mailed to Guatemala so that amateur radio
ast summer, Juan Munoz TG9AJR operators in this Central American country
L emailed the GPSL Yahoo group
asking if the near space community
could start their own program of exploring
near space.
could help him start a program in his
home country of Guatemala. Juan
stated that he already had an APRS
tracker and GPS for the near possible. Once they start exploring,
spacecraft, thanks to Zack Clobes it’s easy for them to keep exploring.
W0ZC of Kansas. What he needed One way to make this possible is to
next was a balloon, parachute, and design airframes that are easy to
airframe. Michael Willett K5NOT of assemble and flexible in function.
northeast Texas and I eagerly Reusable lunch bags are one
provided additional assistance by simple way to make airframes for
donating the balloon, parachute, and near space, but they can be difficult
airframe to Juan’s endeavor. The to modify for a wide range of
balloon and parachute were ready to experiments. For this reason, I think
send to Juan; it was the airframe that this makes them better for backup
needed assembly. It’s Juan’s airframe trackers and not primary near space
and later modifications to the design exploration vehicles. Therefore, for Figure 3: Three pallets and two
that I want to talk about this time. Juan, I built an airframe from spacers stacked together created
this three level avionics deck. I
Styrofoam like those I use for mine. drilled holes through the center of
Promoting Amateur Near However, I wanted to avoid using each pallet after finding out that
Styrofoam packing peanuts to keep they were difficult to remove from
Space Exploration with the avionics in place inside the the airframe without them.
Easy-to-Make Airframes module. So, I modified the internals
It’s one of my desires that all of the airframe to secure the peanuts. This resulted in Juan’s
interested amateur radio operators be experiments without packing the airframe being built around a stack
able to reach near space as easily as open internal space with packing consisting of corrugated plastic
52 February 2016
APPROACHING THE FINAL FRONTIER
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/article/february2016_NearSpaceAirframes.

pallets and separators.

The Pallets and Spacers


The name for the corrugated
plastic used for the pallets and
spacers is Coroplast, and it’s available
in some hobby shops and most
plastic shops. The plastic used in
Coroplast is Polypropylene — a
plastic that has a slick surface that’s
difficult to glue anything to. However,
Coroplast is very stiff and lightweight.
The avionics and experiments are Figure 4: This block of Styrofoam
bolted to the pallets which are made fits snuggly into one of the
airframe’s experiment ports. The
from 1/4” thick Coroplast. Normally, Styrofoam block is sandwiched into
I just use 3/16” thick Coroplast in my place by a slightly larger sheet of
airframes, but the 1/4” thick variety foamed PVC plastic on the outside
is significantly stiffer and will stand up of the airframe and a thin sheet of
better when heavier items are bolted polystyrene on the inside.
to it. I used 3/16” thick Coroplast for
the spacers since they’re turned edge me to communicate and program the Figure 5: These fabric straps are
up and very resistant to flexing and flight computer without opening the attached to a second airframe I
made. The fabric straps are
bending in this orientation. Figures 2 airframe. Plus, it also indicates the grosgrain tape and I get them by
and 3 show a spacer and the stacked status of the flight computer through the yard from a crafts store. The
pallets and spacers. a series of four LEDs. red color of the straps ought to
To attach the panel, I cut a make the airframe stand out.
The Airframe square out of the bottom front of the
airframe and bolted the circuit board rectangle is bolted to a slightly larger
After completing the avionics of the control panel to the airframe. rectangle of foamed PVC (Sintra is its
pallets and their spacers, I could turn The panel’s location on the airframe commercial name) so the Styrofoam
my attention to building the airframe makes it easy to see and access. can’t fall inside the airframe. A thin
since I knew how much space was Next, I needed a simple way to sheet of polystyrene plastic is located
required to hold the stacked pallets. add experiments — like cameras — to inside the airframe to keep the
The airframe — an opened-top box — the airframe without having to make rectangle of Styrofoam from falling
is constructed from 3/4” thick new openings in the airframe and outside the airframe.
Styrofoam sheets glued together with patching up old ones every time I Nuts, bolts, and washers in each
hot glue and then wrapped in changed experiments. So, I cut two corner attach the sandwich of
package tape. The tape compresses additional openings (called
the glued seams and adds color to experiment ports) into the
the exterior of the Styrofoam box. If airframe, but on the sides this
the color of the package tape is a time. These experiment ports
dark one, then it will also increase provide a way to connect
the airframe’s internal temperature by experiments to the outside of
absorbing solar radiation during its the airframe or to let sensors
mission into near space. peer outside the airframe
After gluing the airframe together, while their electronics remain
I cut openings into three of the inside the warmer airframe.
airframe’s sides. The first opening is The experiment ports measure Figure 6: A view from the back. The
for the control panel which is located three inches tall and six inches antenna plane and antenna itself are
in front of the airframe. The control wide. The openings are sealed lightweight; therefore, only three bolts
are required to attach the Coroplast plane
panel has switches for powering the with Styrofoam rectangles that to the airframe. All bolts in the airframe
flight computer on and off, and a bolt to the openings with four need to use nylon locking nuts, or
programming header and LED bolts (one in each corner). nylocks. Their nylon inserts insure they
indicators. The control panel allows The outside of the Styrofoam will not rattle loose during a mission.
February 2016 53
paul@nearsys.com

a part of the airframe, it’s held in


place on a plane of Coroplast which
is bolted to the back of the airframe.
This places the antenna and its plane
where it can’t interfere with the
airframe’s three openings.
The antenna’s RG-174 coax
cable passes into the interior of the
airframe through a small hole drilled
through a Styrofoam wall. The
opening is then sealed with a drop of
hot glue to prevent it from becoming
a source of cold air leaking into the
Figure 7: This is Guatemala’s airframe. A small notch cut into one
module. It shows the two bungee of the vertical spacers creates a small
cords wrapped around the hatch. Eye
bolts and fender washers provide gap between the pallet and spacer so
places for the bungee cords to hook the RG-174 coax can reach the
onto the airframe. transmitter on the flight computer.

Polystyrene, Styrofoam, and Sintra


Figure 8: An X-ray view of the Airframe Hatch
securely to the airframe. When airframe. The sheet of foam
changing the experiments for a rubber keeps the battery (which The airframe’s hatch is made
mission, I only need to make new is on top of the top pallet) in from two sheets of Styrofoam that I
Styrofoam rectangles that are specific place. When the hatch is bungeed glued together. The hatch’s top
for the experiment and then cover down, the foam rubber squeezes square of Styrofoam has the same
the battery and keeps it from
the experiment port. (This sure beats moving during the mission. dimensions as the outside of the
constructing an entirely new airframe airframe, and its inner sheet is 1-1/2”
every time an experiment changes!) smaller so it snuggly fits inside the
The airframe connects to the a null, since the signal is theoretically airframe’s top opening. By sliding the
parachute and other modules with a zero here). hatch’s smaller Styrofoam square into
pair of fabric straps. The straps — At first glance, this sounds like a the airframe, the hatch is prevented
which are 7/8” wide grosgrain — pass bad design since ground assets are from sliding around the top of the
below and up the sides of the tracking from below the near airframe. I added a plastic knob to
airframe. The straps are bolted to the spacecraft (the null at the top is the center of the hatch just to give it
airframe and form a harness for unimportant since no one is tracking a handle. A 2” long sheet metal
attaching the parachute and other above the near spacecraft). However, screw and washer attaches the knob
modules. The top ends of the straps the null is a small region on the to the hatch without crushing the
fold over so split metal rings can be ground and it’s infrequent that a Styrofoam when it’s tightened.
used to connect the parachute. There tracking crew is directly below the Two bungee cords hold the
are loops of Dacron kite line tied to near spacecraft. Most often, tracking hatch to the airframe. The bungee
holes in the bottom corners of the crews are some distance away from cords are 10” long and thin, since
grosgrain where BalloonSats and the near spacecraft and not directly they don’t have a lot of weight to
other payload modules are beneath it. Therefore, chase crews hold in place. Metal eyebolts and
connected to the airframe. receive sufficiently strong signals for hooks bolted to the airframe are used
the majority of the mission. to hook the bungee cords in place.
The Antenna Also, because of the popularity Feel free to use this near space
of amateur radio, there’s always a airframe design, or modify it for your
There are many types of radio ground station some distance away particular needs. I would be
antennas, but the design I recommend from the near spacecraft and in interested in hearing about any
for near spacecraft is the quarter-wave reception of the near spacecraft. variations done to the design. As
dipole. This antenna design produces Many of these stations are called soon as Juan completes his first
a signal that’s uniformly strong in the Internet Gates, or IGates and they mission, I’ll be sure to share the
horizontal plane and grows gradually put the airframe’s position reports on results here.
weaker at points directly above and the Internet where chase crews can
below the antenna (the point directly access them over a smartphone. Onwards and Upwards,
above and below the antenna is called Since the antenna is permanently Your Near Space Guide NV
54 February 2016
PRACTICAL 3D PRINTING ■ BY CHUCK HELLEBUYCK
REAL WORLD USES FOR THE ELECTRONICS EXPERIMENTER

3D Printed
Breadboard Base
with Sidecar Supports
I almost always test out my circuit designs on a breadboard. So, when I find a
unique breadboard base, it catches my eye. I was cruising Thingiverse.com and
came across a rather interesting but simple breadboard base with slide-in sidecar
style board supports (Figure 1). There are so many times I’ve connected to a board
that doesn’t plug into a
breadboard, and the only
thing holding it together was
the connection wires. The
connection wires as the only
support makes the project
difficult to move around. This
3D printed breadboard base
with sidecar supports that are
spring loaded with a rubber
band make the whole design ■ FIGURE 1.
Assembled unit
portable. I just had to print this on my 3D printer and try it out. with sidecar
board.

he original design is from Thingiverse user Patshead. base through guide holes on the sides. Two sidecars are

T It’s called the Breadboard Spring Vise (though I like


my sidecar name better). The side sections have
triangulated shaped arms that slide under the breadboard
connected to each other with a rubber band as
mentioned. The design has two pieces: a base to hold the
breadboard and the sidecar which can slide in from either
side. This requires three
objects to print: one base
(Figure 2) and two sidecars
(Figure 3). Each 3D design
has pads on the corners to
help hold them down to
the platform of your 3D
printer. You can get the
same effect with adding a
■ FIGURE 2. Breadboard base. ■ FIGURE 3. Sidecar. brim or a raft. The idea is

February 2016 55
Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/
magazine/article/february2016_Practical3DPrinting.

■ FIGURE 4. Pieces to assemble.

When I printed this on my da Vinci 1.0, one of the


sidecar’s surface areas seemed large enough to hold it
down, but the edge lifted a little during the print. The
sidecar still works but I’ll probably reprint it at some point.
All the design pieces fit on my larger da Vinci 1.0 3D
printer (200 mm x 200 mm), but just about any printer
can produce these because you can print them
individually on even the smallest machine.
A 4” x 4” bed size (100 mm x 100 mm) can accept
any of the parts individually. The base has five triangular
holes in the sides and slots that run horizontally. This
design was for a medium sized breadboard, however,
there is also a design available for a larger size
breadboard. The sidecars are offset so the one on the
■ FIGURE 5. Rubber band inserted. right uses two of the five triangular holes, while the one
on the left uses two more. This leaves a center groove for
the rubber band to run through. I gathered up all the
pieces (Figure 4) I needed to assemble it, including the
medium sized breadboard, rubber band, base, and two
sidecars. Then, with a little help from a tiny screwdriver, I
fed the rubber band into the center slot (Figure 5). The
sidecars have cone shaped posts on the bottom to accept
the rubber band loop.
The rubber band pulls the sidecars into the base at
the same time from the same rubber band. The base has a
V-groove on the side to accept a circuit board edge; the
■ FIGURE 6. Sidecar grooves hold the board.
sidecar also has the same groove (Figure 6). This allows
just about any circuit board two inches wide or less to be
to create more surface area so the plastic stays flat and held in place. Then, you can use jumper wires to the
doesn’t warp while cooling. These are then broken off board from the main breadboard. I installed a stepper
after printing. I decided to leave them on the base to motor board that I will control from a microcontroller. The
allow it to be clamped or screwed down to a board if I stepper motor board is an ETT-Mini board I found at
wanted in the future. www.futurlec.com/Mini_SMCC.shtml. They have lots of

56 February 2016
■ FIGURE 7. Circuitry added to breadboard ■ FIGURE 8. Prusa I3 style printer from WanHao.
holder.

different mini boards to choose from, but some don’t offer printer since it is so small it can easily fit on any
pins that fit in the breadboard. They do have header pins workbench. Unfortunately, Hobbyking.com has since
that can be pushed through with a solder iron but this discontinued that printer.
sidecar option makes it easier to just leave them as they A Prusa I3 style printer (Figure 8) is another great
are and connect to the breadboard with a few jumper option. Many are offered as kits on eBay, but you can find
wires. The circuit shown in Figure 7 is not a complete one assembled for around $400. Another option for those
circuit as I took the picture as a demo. The focus of this that want less complexity but are willing to settle for less
article is to show how a 3D printer can actually make your printer temperature and settings control is the da Vinci Jr
electronics bench even easier to work at as you can easily (Figure 9). It prints PLA plastic only but does a good job
print custom tools like this. There are a lot of different at just $349 fully assembled.
options for breadboard holders on Thingiverse.com and I did several review videos on this printer at my
elsewhere. You can also easily design your own with YouTube Channel (youtube.com/elproducts).
programs such as Tinkercad, which is like building with When I got my first 3D printer, I wasn’t sure if I would
blocks. Once you have a 3D printer, it’s amazing how use it enough. Now, I don’t know what I would do
many little helpful gadgets like this breadboard holder with without it. Check out my YouTube channel for more tips
a sidecar can be found and printed. Another option is to on how to get started with 3D printing. I host a show
create a custom board holder with grooves to fit one called Filament Friday every week. NV
particular board. If you need to build up 10-20 boards,
then having a holder that you can slide the board into the ■ FIGURE 9. The da Vinci Jr.
grooves to hold it in place while you solder can save you
a lot of time. Or, just use this same rubber band
adjustable method for a variable side holder. The
possibilities are endless.

Fabrikator Update
In my last article, I introduced the Fabrikator Mini 3D

Resources
Check out my website My 3D designs:
and blog: www.thingiverse.com/
www.elproducts.com elproducts/designs

My YouTube Channel: Tinkercad:


www.youtube.com/elproducts www.tinkercad.com

February 2016 57
OPEN COMMUNICATION n BY LOU FRENZEL W5LEF
THE LATEST IN NETWORKING AND WIRELESS TECHNOLOGIES

The Internet of Things:


Who Needs It?

B W ith everyone writing or is one key target (Figure 2 is a good


y now, you have talking about the IoT, you
would have to say this is the next
example). So are major appliances
like the refrigerator, the washing
probably heard of big technological thing. After all, it
allows for a host of “interconnecting.”
machine, or the coffee maker. The
reason for the interconnection has yet

the Internet of Things Do you want your refrigerator to


communicate with your HVAC
to be determined in some cases, but
as an example, the refrigerator may

(IoT). Also called the thermostat? Or, do you care if you


can turn your sprinkler system off and
report its physical status back to the
manufacturer or you may want to be
on while you are on vacation? How able to turn the coffee maker off or
Internet of Everything, about sharing your fitness data from on remotely.
your smartwatch with your trainer Other applications in the smart
this is the concept of over the unsecured Internet? That all home are security systems, door
sounds pretty amazing. locks, video cameras, or baby
connecting every sort The fact is IoT is happening right
monitors. Pool pumps, sprinkler
systems, garage doors, lighting, and
of device or product now. Potentially, there could be as
many as 50 billion or so devices
other stuff are additional examples.
I will admit to buying a video
to one another or connected by 2020, according to
recent research. That will affect you,
camera that I can monitor on my
iPhone. The video cam talks to my
to a human via the me, and just about everyone else. So,
be prepared.
Wi-Fi router which has an Internet
connection via my cable company.

Internet. Now that IoT Defined


My iPhone has an app that links

most of the affluent IoT is the concept that a device


can be monitored or controlled
world is connected to remotely from anywhere by way of an
Internet connection. The basic idea is
the Internet, why not illustrated in Figure 1. A device such
as a sensor talks to a remote server
connect everything that, in turn, is connected to a tablet
or smartphone. The computer could
else? We have the just collect the sensor data over time
for later analysis. Or, someone with
power and the a smartphone could be monitoring
the sensor output in real time. There
technology, so let’s do are all sorts of other variations and
scenarios.
this. But is this a good areasOne of the largest application
is the smart home. This is a
Figure 2. The Nest thermostat is a
popular IoT product using Wi-Fi that

idea? home where many devices can be lets you control and monitor your
connected. The HVAC thermostat HVAC remotely.
58 February 2016
THE LATEST IN NETWORKING AND WIRELESS TECHNOLOGIES
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/article/february2016_OpenCommunication_Iot.

“Thing”

Application
Server

Sensor
Gateway InternetI Cloud

Thermostat
Smartphone
Figure 1. A simplified view of how the Internet of Things works. The “thing” connects to a gateway wirelessly. The
gateway has the Internet connection to the cloud. At the other end of the link is a server dedicated to the application.
This, in turn, links via a cellular connection to a tablet or smartphone.

by way of the cellular network to a can be done easier, more affordably, there are a number of critical issues
remote server that collects the video and on a larger scale. that developers must consider when
for the camera and forwards it to my Another term you will hear creating an IoT product or system.
phone. Totally neat. related to the IoT movement is Here are just a few examples:
While the smart home will machine-to-machine (M2M). M2M • Privacy and security.
probably be the largest sector of has been around for years also, and • Interoperability of devices and
the IoT, there are other application has been used for remote monitoring systems.
sectors. A big one is the industrial of vending machines, unmanned • Ease of setup and installation.
Internet of Things, or IIoT. Here is facilities, and truck fleets. It primarily • Managing large data collections.
where factories, plants, oil, and gas uses the cellular network rather than • Multiple standards.
fields can monitor and control things the Internet for communications. As for security, we all want our
from afar. Sensors of all sorts are the M2M is basically a blurry part of IoT data to be secure. We do not want
main interest where temperature, (in my opinion). our systems hacked to capture and
flow, mechanical position, There are all sorts of other use whatever data we collect. Nor do
pressure, and other critical physical applications emerging such as in we want some outside entity to take
characteristics can be observed in real medical and fitness monitoring, control of our system. This means
time. Other things to be controlled wearables like smartwatches, that our devices must use some form
are motors, pumps, relays, solenoids, agriculture, the smart grid, and smart of encryption and authentication.
robots, programmable logic cities and drones. It will be interesting Luckily, most new IoT chips and
controllers (PLCs), and machine tools. to see what new uses develop. products do have built-in security
Such monitoring and control has measures.
been going on for years, however,
now with new IoT technology such as
Adoption Issues To have all devices talk to the
gateway or to one another, they must
wireless and Internet connectivity, it IoT is happening right now, but all use the same wireless standard and
February 2016 59
THE LATEST IN NETWORKING AND WIRELESS TECHNOLOGIES

protocol. With multiple standards and


protocols in use, this is a problem. In What is 802.15.4?
addition, even if the same standards 802.15.4 is one of the Institute of Electrical and Electronic Engineers’
and protocols are used, minor (IEEE) short range wireless standards. It works in several of the
variations can keep devices from unlicensed spectrum, but primarily in the 2.4 to 24.835 GHz spectrum
working together. This will require where Wi-Fi and Bluetooth reside. It uses direct sequence spread
rigid testing and certification to spectrum (DSSS) with differential BPSK or offset QPSK modulation.
ensure interoperability. Data rates can be up to 250 kb/s. The typical power output is 1
Ease of installation is a huge mW or 0 dBm. The range is up to 10 meters or so, depending on the
issue — at least for the consumer. environment. It uses very low power, so can operate from a battery for
If installation and setup processes years. This standard implements the physical (PHY) and media access
are complex, arcane, and lengthy, control (MAC) layers of the OSI networking model. Other networking
consumers will just be frustrated and layers are built on this, based on the application.
home IoT could be a flop — all the This is a popular model as other standards are based on it, including
more reason to take the extra design ZigBee, ISA 100-11a, WirelessHART, and Thread.
time to make sure installation is a
snap. ensure that sensors can run for years chips and modules. Some examples
IoT systems are designed to on a single battery. Certification is are MQTT, JSON, IPSO, IoTivity,
capture data. This they do well. They available to make sure all devices AllJoyn, and Apple’s HomeKit. A
can collect a massive amount of data work together. popular standard is 6LoWPAN that
is a short time. This means having ZigBee is another standard that is lets other protocols use the IPv6
enough memory to store the data. a major contender — especially where Internet protocol.
Then, what do you do will all that lots of sensors are involved. Based A more recent example is
data? Do you display it, analyze it, on the IEEE 802.15.4 standard (see Thread. Thread uses the popular IEEE
or what? Some early studies of IoT sidebar), ZigBee’s mesh topology lets 802.15.4 wireless standard, but adds
indicate that 70 to 90 percent of you build systems with hundreds or a mesh topology protocol to handle
all the data collected is never used. even thousands of sensors. It’s a great many sensors or other devices.
(That kind of statistic kind of makes choice for business and industry.
you wonder why the application was
implemented in the first place.) This is
Yet another standard showing up
in smart home products is Z-Wave.
Been There, Done That
a major issue to think through before This is a simple wireless technology The idea of IoT is not new. It
investing in IoT. that is ideal for low data rate home has been around for decades. We
Multiple standards is a key monitoring and control. It is low cost
issue as indicated earlier. Wireless and interoperable.
used to call it remote monitoring
standards are a good example. Of course, there are many and control telemetry. To me,
There are many short range wireless others to look at. There is Weightless IoT is just telemetry on a grander
technologies that will work with IoT. that uses the white spaces on
All are vying for a piece of the IoT vacated VHF and UHF TV bands. scale, thanks to the Internet
pie. Wi-Fi is probably one of the LoRa is another that uses the lower and lots of low cost/low power
early leaders in this race. It is highly frequencies below 1 GHz. Both
developed with multiple variations, Weightless and LoRa promise longer wireless products.
plus an in-place certification process. range connectivity up to several miles Now that it’s easier than ever
Most homes have a Wi-Fi router in applications where the devices are
to create products we can operate
already in use. These days, virtually some distance away.
all laptops, tablets, and smartphones Cellular connectivity is also an remotely or collect data from,
include Wi-Fi. It is a good reliable option. There are cell phone chips I suspect IoT will become even
choice and an early leader in the and modules, and most wireless
standards battle. Wi-Fi is fast and carriers offer connection services. more successful and prolific.
convenient, but can be expensive This is a good reliable choice for more Although, personally, I’d be
overkill for many simple sensor critical applications.
applications. Let’s not forget the software side
okay with us bringing back X10
Bluetooth is another good choice. of IoT. There are multiple different power line controllers and the
It is widely available in smartphones, software protocols for handling the Clapper. NV
and the new low energy version will data. These operate with the wireless
60 February 2016
READER FEEDBACK Continued from page 7

Change line #124 in the file ThinkingOfYou.ino to: We apologize to Mr. Rucker and for any
inconvenience(s) our oversights caused readers.
const char *ssid = WiFi.SSID().c_str(); NV staff

and the code will compile cleanly.

Errata on the Coop Boss


Craig Lindley
CLASSIFIEDS
In the January 2016 issue, John Rucker’s article on LIGHTING
“SmartThings and the Device Maker” had some
updates/changes that missed getting in. First off,
SmartThings® is a registered trademark name/brand.
Secondly, there are four figures that needed to be
replaced because of a software update. So, the new
graphics for Figures 11, 12, 14, and 15 are included here.
Finally, when referring to Figure 1, please note that
the following letters represent the items in the article text
that were shown in bold: HARDWARE
A = Motor Connection WANTED
B = Main I/O Header
C = DC In DEC EQUIPMENT
D = Aux Port WANTED!!!
Digital Equipment Corp.
E = Antenna and compatibles.
Buy - Sell - Trade
ROBOTICS CALL KEYWAYS 937-847-2300
or email buyer@keyways.com

 
AUDIO/VIDEO

Speakers
FIGURE 11. FIGURE 12.

Components


  Project
Accessories

Want to learn Tools and


Tech Aids
more about
robotics? Visit us online to request
a sales flyer and to receive
Go to a special offer!
www.servo parts-express.com/nuts
FIGURE 14. FIGURE 15. magazine.com 1-800-338-0531

February 2016 61
For comple t e pr oduct de t ails, visi t our webs tor e!!
The Nuts & Volts WEBSTORE
GREAT FOR DIYers!
Beginner's Guide to 3D Printing Electronics Workshop Programming the Raspberry Pi
by Companion for Hobbyists Second Edition: Getting Started
Chuck Hellebuyck by Stan Gibilisco with Python
This book was In this practical by Jack Simon
written to answer guide, electronics
the questions most expert Stan This practical book
beginners need Gibilisco shows you, has been revised to
answered. It covers step by step, how to fully cover the new
many of the popular set up a home Raspberry Pi 2,
3D printer choices workshop so you including upgrades
and then uses the can invent, design, to the Raspbian
under $500 build, test, and operating system.
Da Vinci 1.0 from repair electronic Discover how to
XYZprinting to circuits and gadgets. configure hardware
show you how easy Electronics and software, write
it is to get started. I take you through using Workshop Companion for Hobbyists Python scripts,
Tinkercad software for creating your own provides tips for constructing your create user-friendly GUIs, and control
custom designs. I go further and show you workbench and stocking it with the tools, external electronics. DIY projects include a
how to take a simple design and send it off components, and test equipment you’ll hangman game, RGB LED controller, digital
to a professional 3D printer. This book was need. Clear illustrations and interesting clock, and RasPiRobot complete with an
designed for anyone just getting started. do-it-yourself experiments are included ultrasonic rangefinder.
$24.95 throughout this hands-on resource. $15.00
$25.00

Make Your Own Programming the Intel Edison: Beginner's Guide to Reading
PCBs with EAGLE Getting Started with Processing Schematics, 3E
by Eric Kleinert and Python by Stan Gibilisco
Featuring detailed by Donald Norris
illustrations and Navigate the roadmaps
step-by-step Learn To Easily of simple electronic
instructions, Make Create Robotic, circuits and complex
Your Own PCBs with IoT, and Wearable systems with help from
EAGLE leads you Electronic an experienced
through the process Gadgets! engineer. With all-new
of designing a art and demo circuits
schematic and Discover how to set up you can build, this
transforming it into components, connect hands-on, illustrated
a PCB layout. You’ll your PC or Mac, build guide explains how to
then move on to Python applications, and understand and create
fabrication via the generation of standard use USB, Wi-Fi, and high-precision
Gerber files for submission to a PCB man- Bluetooth connections. Start-to-finish electronics diagrams.
ufacturing service. This practical guide example projects include a motor Find out how to
offers an accessible, logical way to learn controller, home temperature system, identify parts and connections, decipher
EAGLE and start producing PCBs as robotic car, and wearable hospital element ratings, and apply diagram-based
quickly as possible. alert sensor. information in your own projects.

$30.00 $20.00 $25.00


How to Diagnose and Fix Programming PICs in Basic Programming Arduino
Everything Electronic by Chuck Hellebuyck Next Steps: Going Further
by Michael Jay Geier If you wanted to learn with Sketches
how to program by Simon Monk
Master the Art of microcontrollers, then
you've found the right In this practical guide,
Electronics Repair book! Microchip PIC electronics guru Simon
microcontrollers are Monk takes you under
In this hands-on being designed into the hood of Arduino
guide, a lifelong electronics throughout and reveals professional
electronics repair the world and none is programming secrets.
guru shares his tested more popular than the Also shows you how
techniques and eight-pin version. Now to use interrupts,
invaluable insights. the home hobbyist can manage memory,
How to Diagnose and create projects with these little program for the
Fix Everything microcontrollers using a low cost Internet, maximize seri-
Electronic shows you how to repair and development tool called the CHIPAXE
system and the Basic software al communications,
extend the life of all kinds of solid-state perform digital signal
devices, from modern digital gadgetry to language.Chuck Hellebuyck introduces
how to use this development setup to processing, and much more. All of the 75+
cherished analog products of yesteryear. build useful projects with an eight-pin example sketches featured in the book are
$24.95 PIC12F683 microcontroller. $14.95 available for download. $20.00

62 February 2016
Order online @ store.nutsvolts.com
Or CALL 1-800-783-4624 today!
EDUCATIONAL CD-ROM SPECIAL

February 2016 63
TECHFORUM READER - TO - READER

knowledge as he gets older. Figuring WHEN the hand-crank is being used.


>>> QUESTIONS that almost any profession he chooses When I stop hand-cranking it, that’s
will benefit from exposure and when lighting stops. I assume the li-on
Thirst For Knowledge proficiency in this area, and it can’t battery is not being charged (no white
I’ve been an NV subscriber for be accomplished overnight. stuff around it for poor connection).
years. I have an interest, but not a Any insights, thoughts, sources, The black/plastic transistor is
proficiency — yet. Some articles I books, coursework, etc., anyone marked as SC8050. NTE (NTEinc.
understand, some I do not, and I can share would very much be com) doesn’t have a replacement
really would like to get to the point appreciated, as well as any thoughts for it. Can someone suggest a
where I can run with most things on where you see all this going in the replacement and if it’s NOT the
presented in each issue, as well as next 20 years, so maybe I can guide transistor, suggest where the problem
in other magazines. Coming up on my grandson to get out in front of might be?
retirement, I will have more time to things. #2163 Nate Franklin
invest in areas of interest. So, I’m Thank you in advance for Schererville, IN
looking for guidance in a couple of anything you can share.
directions. #2161 Mark McCurdy
1. I want to get proficient building Grapevine, TX
things using small microprocessors
(home automation, data loggers 68HC11 To DS1302 RTC
for temp and humidity, robotics, I recently purchased what some
small handheld computers, hacking would consider a dinosaur when
appliances, other??), but I’m not sure it comes to microcontrollers: a
where to start and the best way to 68HC11. I purchased it at an estate
learn. I’ve built a few PCs over the sale because it was one I used while
years, and while I would have to dust attending school. My question is
off my memory, I have programmed a where can I find info on creating
little in the past with Visual Basic and a program that would allow me to
SQL. interface the SPI to a DS1302 RTC?
2. I want to get more #2162 Michael Bennett
knowledgeable in AC/DC electronics. Kankakee, IL
I’ve taken a basic fundamentals
course at community college a Cranky Flashlight
number of years ago, but would I have a three-LED hand-crank
like to refresh that and get on flashlight. I’ve included a copy of
a path to continue building my the PCB (orange) hoping to find out
knowledge base in all aspects, be where the problem may be. The
it AC/DC electronics, computers, switch (SW1) provides two modes of
communications, etc. lighting: one LED only (LED2) and all
3. I have a two year old grandson LEDs (LED1-LED3); in the OFF mode,
and I want to get him excited about the hand-crank is to be used in order
technology, programming, math, to recharge the 3.6V rechargeable
engineering, etc., at age appropriate battery.
levels, and see what — if anything The hand-crank flashlight works
— he might want to do with the in either of the two modes ONLY

All questions AND answers are submitted by Nuts & NO GUARANTEES WHATSOEVER are made by the
Volts readers and are intended to promote the exchange publisher. The implementation of any answer printed in
of ideas and provide assistance for solving technical this column may require varying degrees of technical
problems. All submissions are subject to editing and will experience and should only be attempted by qualified
be published on a space available basis if deemed suitable individuals.
by the publisher. Answers are submitted by readers and Always use common sense and good judgment!
64 February 2016
>>>YOUR ELECTRONICS QUESTIONS ANSWERED HERE BY N&V READERS

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


or via the online form at www.nutsvolts.com/tech-forum
the spike.
>>> ANSWERS Tim Brown
via email
[#1161 - January 2016]
Clipping The Spike #2 When controlling
I’m using an Arduino to inductive loads, I like
control a set of relays, and both the to use an N-channel
microcontroller and relays share a MOSFET such as a
9V power bus. I plan to put a diode can cause arcing across the contacts 2N7000, BS107, or equivalent to
across the relays to clip any reverse or spike on electronic components control the device in addition to the
voltage spikes. Is there anything else which leads to their demise. flyback diode. This provides further
I should consider to prevent a spike For a DC powered circuit, you isolation and reduces the current
from shutting down the processor? could add a snubber circuit (series requirement of the Arduino just in
resistor and capacitor) in parallel case you want to control more that a
#1 The inductive reaction from with both the diode and relay coil as couple of relays.
opening a circuit which contains an shown in Figure 1. Just make sure the Gene Sellier
inductor (relay coil) is due to the resistor and capacitor can handle the Fairhope, AL
reverse voltage generated by the power discharged from the diode coil
collapsing magnetic field around the when the contact opens. For an AC [#1162 - January 2016]
coil when the current is interrupted by circuit, you can use a properly sized Capacitor Forming
opening the contact. This high voltage Metal Oxide Varistor (MOV) to snub I’m trying to resurrect an old

February 2016 65
>>>YOUR ELECTRONICS QUESTIONS ANSWERED HERE BY N&V READERS

Halicrafter’s communications receiver best to use a variable-voltage (variac) a live chassis. Most later sets used
from at least the ‘50s. I’m planning transformer to increase voltage slowly an isolated internal ground system
to replace the electrolytic capacitors over several days. Note that variacs to minimize the hazard. It’s safest
in the power supply with capacitors I are usually not isolated. An alternative to work on AC-DC sets using an
salvaged from a more recent TV set. method is to power up with an isolation transformer — especially if
However, I’ve read that incandescent lamp socket in series you’ll be connecting any AC-powered
electrolytic capacitors — once formed with the AC line, starting with a 60 test gear. You can make your own
at a certain voltage — can take watt bulb and increasing the wattage using back-to-back filament or power
months, if not years, to reform at a gradually. Turn the set off occasionally transformers of appropriate power.
new voltage. Until then, the capacitor and check for excessive heating. Good luck with your repair!
value can be significantly off from I have repaired many radios using Stanley Pitman
what’s on the label. higher voltage TV capacitors, and via email
Can anyone shed some light? have never known one to take more
than a week, unless it was defective. If #2 Let me start with a rule of
#1 The thin aluminum oxide the TV parts aren’t ancient, they may thumb: Electrolytic caps drop some
dielectric (energy-storing) layer in still be sufficiently formed for your value if formed to higher voltages
electrolytic capacitors is formed on new (lower) voltage, but for safety, (within working range). This is
the specially-treated anode metal, follow the above procedures. because of thickening of the barrier
and the electrolyte contacts the outer There is a strong shock hazard layer, BUT this can vary. That’s why
can (on early parts) or the cathode posed by AC/DC sets. Many early most are rated plus or minus 20%.
foil (on later “dry” parts). When versions of these sets had all B(-) They generally only need to be big
radios have been unpowered for a connections grounded to the chassis, enough (power filter or bypass). Don’t
very long time, electrolytic capacitors including one side of the switched expect much value drift moving to
tend to lose their dielectric layer and line cord, no matter which way it’s a lower voltage. Other concerns are
their voltage rating, but not usually plugged in. Missing or wrong size with internal resistance (can screw
much capacitance. They may destroy screws or knobs or rotting rubber with bypass performance in audio
themselves and other parts when re- mounting grommets could make stages, and heats cap at high duty
powered, unless slow-start techniques outer metal cabinets lethal. Some cycle).
are used to renew their dielectric. otherwise well-built later radios, Nick Vitinaros
When restarting long-idle sets, it’s such as the Hallicrafters SX-41, had Grand Blanc, MI

nLOOK FOR

3D PRINTERS/CNC
nSEARCH FOR
Find your favorite advertisers here!

Probotix ....................................... 44
nFIND
ADvertiser INDEX
National RF................................... 23 Qkits ............................................ 23
Servo City/Robot Zone ................ 67
All Electronics Corp. �������������� 7
DEVELOPMENT PLATFORMS Anaren �������������������Back Cover
AMATEUR RADIO AND TV Anaren ...........................Back Cover RF TRANSMITTERS/ AP Circuits ��������������������������� 20
National RF................................... 23 RECEIVERS Cleveland Institute of
EDUCATION National RF................................... 23
BUYING ELECTRONIC Cleveland Institute of Electronics..65 Electronics ��������������������������� 65
SURPLUS Command Productions ................ 21 ROBOTICS Command Productions �������� 21
All Electronics Corp. ...................... 7 NKC Electronics .......................... 23 Cleveland Institute of Electronics..65 ExpressPCB �������������������������� 6
Poscope ......................................... 6 Ion Motion Control ....................... 33
CHARGERS Front Panel Express LLC ���� 32
Parallax, Inc. ................................ 65
Hitec .............................................. 2 ENCLOSURES Servo City/Robot Zone ................ 67 Gooligum Electronics ����������� 27
Front Panel Express LLC ............ 32 Hitec �������������������������������������� 2
CIRCUIT BOARDS TEST EQUIPMENT
AP Circuits ................................... 20 KITS & PLANS Ion Motion Control ��������������� 33
NKC Electronics .......................... 23
ExpressPCB .................................. 6 National RF................................... 23 National RF �������������������������� 23
Poscope.......................................... 6
Front Panel Express LLC ............ 32 NKC Electronics .......................... 23 NKC Electronics ������������������ 23
Saelig Co. Inc. ............................... 3
Gooligum ..................................... 27 Qkits ............................................ 23
PCB Shopper ............................... 36 Servo City/Robot Zone ................ 67 PanaVise ����������������������������� 20
Saelig Co. Inc. ............................... 3 TOOLS Parallax, Inc. ������������������������ 65
MICROCONTROLLERS / I/O PanaVise ..................................... 20
Poscope.......................................... 6 PCB Shopper ����������������������� 36
COMPONENTS BOARDS
All Electronics Corp. ...................... 7 Ion Motion Control ....................... 33 Poscope ��������������������������������� 6
Parallax, Inc. ................................ 65 Parallax, Inc. ................................ 65 WIRE, CABLE AND Probotix ������������������������������� 44
Qkits ............................................ 23 Technologic Systems ................... 51 CONNECTORS Qkits ������������������������������������ 23
All Electronics Corp. ...................... 7
Servo City/Robot Zone ................ 67 Saelig Co. Inc. ����������������������� 3
DESIGN/ENGINEERING/ MISC./SURPLUS
REPAIR SERVICES All Electronics Corp. ...................... 7 SDP/SI ��������������������������������� 23
Cleveland Institute of Electronics..65 WIRELESS PRODUCTS Servo City/Robot Zone �������� 67
ExpressPCB .................................. 6 MOTORS / MOTOR CONTROL Anaren ...........................Back Cover
Technologic Systems ����������� 51
Front Panel Express LLC ............ 32 Ion Motion Control ....................... 33 Technologic Systems ................... 51
66
66 February 2016
February 2016
Learn more

JOIN THE Today

EVOLUTION.
2005

1945

1905

Evolve to app-based control


with AIR for Wiced Smart!
If you’re ready to evolve from fixed control panels
Get “mobile smart” populated with dials, buttons, keypads, and LCD
in 3 easy steps: displays to mobile-app based control of your
Get your AIR ffor Wicedd embedded product – check out Anaren’s AIR for Wiced Smart module,
Smart dev kit at your featuring Broadcom’s Wiced Smart Bluetooth® chip (BCM20737).
distributor of choice.
(See our website
ebsite for a
Not only does our small-footprint, SMT, and pre-certified all-in-one
t.)
current list.) module save you the time, effort, and trouble of designing your
own radio... It’s supported by our industry-exclusive Atmosphere
Develop your
ur wirelesss
sic app using
link and basic usin
ng
development ecosystem that lets you develop your basic embedded
ve Atmosphere
our exclusive Atmoosphereere code and app code in one, easy-to-use development tool – for a far
developmentnt tool.. speedier product development cycle and time-to-market. Follow the
With our AIR for Wiced
steps at left to join the evolution, right now!
Smart module on board, www.anaren.com/AIRforWiced
proceed in record time to 800-411-6596
nal,
a prototype and final, In Europe: 44-2392-232392
mobile-app development!
opment!

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy