Sunteți pe pagina 1din 68

D930SW D954SW D955TW

Operating Voltage Range 4.8V ~ 7.4V


No Load Speed Range 0.11 ~ 0.07 Sec @ 60° 0.19 ~ 0.12 Sec @ 60°
8.0 ~ 13.0 kg-cm 18.0 ~ 29.0 kg-cm 18.0 ~ 29.0 kg-cm
Peak Torque Range
112 ~ 182 oz-in 251 ~ 404 oz-in 251 ~ 404 oz-in
Maximum Current Draw 5,200mA
Dimensions 40.0 x 20.0 x 37.0mm / 1.57 x 0.78 x 1.46 in
Weight 66g / 2.33 oz 68g / 2.40 oz 66g / 2.33 oz

Hitec continues to expand our innovative D-Series servo line with the latest introduction of our Premium trio, the D930SW,
D954SW and D955TW. Powered by our 32-bit MCU (Microcontroller Unit) and 12-bit ADC (Analog to Digital Converter)
industrial science, this high-resolution, ultra-durable gear group delivers exactly what you need and have come to expect
from Hitec. Our D930SW is the perfect upgrade from the HS-8330SH; the D954SW replaces the HS-7954SH while the
D955TW is the advanced version of the HS-7955TG. Servo Engineering ReimagIned!!!

Hitec RCD USA, Inc. | 12115 Paine Street | Poway, CA 92064 | (858) 748-6948 | www.hitecrcd.com |

Full Page.indd 2 5/30/2017 7:06:19 AM


Full Page.indd 3 5/30/2017 7:10:32 AM
July 2017
TOC - Jul 17_TOC NV Mar 15.qxd 5/30/2017 7:04 AM Page 4

s
etail
ore d ibing,
Subscription Information
Fo r m r
ubsc n
on s our ad o
Nuts & Volts — PO Box 15277

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

18 Build an Adaptable Controller 42 Building Your Own


Microcontroller
Last month, we saw how Project SMART students put
together a flight controller that can be used in near space
ballooning projects. This month, we’ll introduce the Ever wanna make your own MCU? Then, follow along

23 tDCS — Brain Hacking?


software and highlight some of its key features. with this discussion that can be useful for anyone wanting
■ By Richard Levergood and Maria Panacopoulos to learn about computing basics, microcontrollers,
embedded programming, and/or VHDL.
■ By Fàbio Pereira

I’ve been following recent exciting research in


neurostimulation using transcranial direct current
stimulation (tDCS), so I thought I’d design a simple circuit Page 36

30 Build an ESP8266 World Clock


to try it out myself.
■ By Walt Noon

Build on previous ESP8266 projects to add a customizable

36 Working with I2C Sensor


world clock to your arsenal of time keepers.
■ By Craig A. Lindley

Devices

Departments
Here’s a quick beginner-friendly tutorial that shows you

Columns
how to interface and read data with this popular serial
protocol.
■ By Derek Hildreth

05 DEVELOPING 60 NV WEBSTORE

08 Q&A
PERSPECTIVES 62 TECH FORUM
What’s in Your Grab-and-Go? 65 CLASSIFIEDS
06 READER FEEDBACK 65 ELECTRO-NET
17 NEW PRODUCTS 65 AD INDEX

50 The Ham’s Wireless


17 SHOWCASE
Reader Questions Answered Here

Workbench
Topics discussed this month:
• A Simple Current Source
• A Block Heater Power Indicator

12 The Spin Zone


• Arduinos and LEDs — Redux
Practical Technology from the Ham World
The Solar Eclipse and Ham Radio
Tune in to a very unusual on-the-air experience when
Adventures in Propeller Programming there will be a rarely-seen total solar eclipse happening

55 The Design Cycle


this August.
A Block On the Old Chip
BlocklyProp is a fun and easy way to build a Propeller
program — piece by piece — using blocks. You should
give BlocklyProp a try. If you're new to the Propeller, it's a
way to get started without the worry of syntax rules. If
Advanced Techniques for Design Engineers
Put on a PiFace
you're a crotchety old dude like me, it's another tool to
Trying to bake up a Raspberry Pi with Python? Shake the
help others and, perhaps, to look at code from a different
snake and bake your Pi with B4J! This month, we will
point of view.
mount a PiFace on our Raspberry Pi and mix up some
Cover Model: Shasten Johnson application code using a free Rapid Application
Layout and Art by Matthew Roddy Development tool called B4J.
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 July 2017
Bergeron - Developing Perspectives - Jul 17_Dev Perspectives - ReadFeed Feb15.qxd 5/30/2017 6:16 AM Page 5

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 What’s in Your Grab-and-Go?
Subscription Orders
Toll Free 1-877-525-2539
Outside US 1-818-487-4545
I own two grab-and-go bags: one for
survival and one for the phone calls
for help on a friend’s stereo, computer,
a car dashboard or other tight space.
The mirror is also a life saver in
cramped quarters, as it allows me to
P.O. Box 15277 or quadcopter. The survival bag has the inspect connections without full
usual flashlight, matches, water disassembly.
North Hollywood, CA 91615
purification tablets, bandages, A standard 35W Weller soldering
FOUNDER tourniquets, and pain killers. My grab- iron with a lightweight cord works in
Jack Lemieux and-go for electronics is a little more just about any environment that has
involved, and the contents shift a bit AC power available. If I’m going to
PUBLISHER with the technology I’m likely to work on a circuit installed on a boat or
Larry Lemieux encounter on my “rescue missions.” otherwise away from the mains, I’ll
publisher@nutsvolts.com As listed below, most of the kit can bring along a small butane torch. The
ASSOCIATE PUBLISHER/ be categorized as instruments, tools, Proxxon Microflame Burner works well
ADVERTISING SALES parts, or safety related. in windy environments and is easy to
Robin Lemieux refill with generic butane.
robin@nutsvolts.com Instruments: I’ll add to my core selection of
Digital multimeter parts as the task demands. However, at
EDITOR
Bryan Bergeron
Clamp-on AC ammeter a minimum, my bag contains an
techedit-nutsvolts@yahoo.com assortment of fuses — both automotive
Tools: and the standard 0.25 x 1.25” 3AG
VP OF OPERATIONS Flashlight variety — with a few values ranging
Vern Graner 1” diameter extendable mirror from one to five amps.
vern@nutsvolts.com Magnet My favorite method of solder
CONTRIBUTING EDITORS Diagonal cutters removal is to use braid. It’s less messy
Fred Eady Kristen McIntyre 6” Crescent wrench (2) and much more compact than the
Richard Levergood Maria Panacopoulos Driver kit with screw and bolt head Teflon-tipped solder suckers.
Jon McPhalen Ward Silver attachments On the top of my list of safety
Fàbio Pereira Derek Hildreth Small rubber mallet supplies is a set of clear closed
Craig Lindley Walt Noon Tweezers goggles. By closed, I mean that the top
35W soldering iron and sides are rubber/plastic, with small
CIRCULATION DEPARTMENT Swiss army knife ventilation holes. I don’t like the simple
subscribe@nutsvolts.com sunglasses style eye protection because
SHOW COORDINATOR Parts/Disposables: it’s all too easy for debris to enter the
Audrey Lemieux Assorted fuses eyes.
Electrical tape Band-aids and sanitizer are for the
WEBSTORE MARKETING Duct tape inevitable minor cuts that I’m likely to
COVER GRAPHICS Solder encounter, simply because accidents
Brian Kirkpatrick Solder wicking braid happen.
sales@nutsvolts.com 8” Tie-wraps (6) As with my disaster grab-and-go
WEBSTORE MANAGER/ bag, my electronics grab-and-go is for
PRODUCTION Safety Related: quick response to an immediate need.
Sean Lemieux Medium Band-Aids® I’ve found it covers 80% of my house
sean@nutsvolts.com Alcohol-based hand cleaner/sanitizer calls to friends. Your grab-and-go might
Clear goggles include other instruments, tools, and
ADMINISTRATIVE STAFF parts depending on your interests and
Re Gandara The instruments include a small the typical needs of your friends.
Fluke DMM with a set of good sharp If you don’t have enough spare
Copyright © 2017 by T & L Publications, Inc. leads. A small inexpensive Extech tools to create an electronics grab-and-
All Rights Reserved
All advertising is subject to publisher’s approval. We
clamp-on AC ammeter is my insurance go, then the next best thing is to create
are not responsible for mistakes, misprints, or when working with AC powered a checklist of what to pack when you
typographical errors. Nuts & Volts Magazine assumes systems in which the circuit breaker is get a repair/help request.
no responsibility for the availability or condition of theoretically in the “off” position. I like I’ve found the hard way that
advertised items or for the honesty of the advertiser. to verify that the circuit is, in fact, simply tossing tools and parts in a
The publisher makes no claims for the legality of dead. backpack and heading out the door
any item advertised in Nuts & Volts. This is the sole The tools in my grab-and-go bag without thinking through what I’m
responsibility of the advertiser. Advertisers and their
agencies agree to indemnify and protect the publisher
are largely generic, multi-purpose, and likely to need is a recipe for
from any and all claims, action, or expense arising from self-explanatory. I love my head- disappointment and wasted time.
advertising placed in Nuts & Volts. Please send all mounted light because I inevitably run What’s in your grab-and-go? NV
editorial correspondence, UPS, overnight mail, and out of free hands when working behind
artwork to: 430 Princeland Court, Corona, CA 92879.
July 2017 5
Reader Feedback - Jul 17_Layout 1 5/30/2017 6:18 AM Page 6

READER FEEDBACK
computers to monitoring and data been running Linux on my Dell Inspiron
Reader Response to breaches. 1545 laptop for over eight years. It is
Bryan Bergeron’s If you would like to fix your system, on the third keyboard; I forget how
June 2017 Editorial you will need to dump the OS and many batteries I have gone through. I
on “Real Electronics” reinstall everything from the ground up. am also on at least my fourth hard
The problem is probably not a drive. It came with MS Vista — which I
hardware issue. More than likely you never even booted.
The idea of computerizing
have viruses, spyware, and trojan I see little or no value in the
everything is all about squeezing more
horses. "Internet of Things." I have a few old
money out of the consumer. Washing
Another big drag on system Tek analog oscilloscopes which are
machines and stoves used to last 30
resources is Norton and other so-called definitely not Internet ready, but I can
years.
multi-use utility packages. Norton will fix them when they break. I do not
Now, the computerized versions
slow a system that can run Win7 at a need my microwave or toaster
last one to five years. Planned
decent speed by as much as 20%. Also, connected to the Internet.
obsolescence has reached new heights.
it only protects against infections that it The toaster pops when the toast is
Publicly traded corporations are
has definitions for. You see, the ready and the microwave beeps. They
required by law to be greedy.
infection is already on your system and do not need a web page. Imagine a
I have been a ham radio operator
your network before Norton can even hacker messing with your Internet
for about 50 years. I have radios from
do its job. Oops! Not good! connected toilet — or shower.
the 1950s and 1960s that still work
The best protection is with a wired I have a McIntosh amp (solid-state)
fine. My new computerized radio will
router/firewall. Wireless systems are which I have fixed three times in the 30
not last that long!
inherently insecure as the bad guys can years I have owned it. I also have a
Nowadays, most people are
sit outdoors with a laptop and steal Mac MX115 tuner preamp that is
carrying a tracking device with them
your data. Even if it is encrypted, they halfway through a recap.
(smartphone), screens have TV cameras
still have a copy of it and now they can I am much more a "fixer" than a
watching the viewers, politicians say
take it and use a much more powerful "maker." I enjoy fixing these old things
things that are the opposite of the
machine to break the encryption. and getting them working. It clears my
truth. George Orwell knew what he
I am an electronics hobbyist, head after a day of writing software.
was talking about in "1984." The
retired master automobile technician, Mike McGinn KD2CNU
Internet has its uses, but I don't want to
computer technician, and a somewhat
depend on it for everything. It will fail
competent programmer. I have seen a Hey Mike, I hear you. I enjoy
occasionally.
lot of changes in electronics and cars playing with the latest tech available,
Doug Reid
over the last six decades. I like being but at home use old reliable devices.
able to fix things without having to find My Mac amp is tube type. No Internet
Thanks Doug! I agree with most of
a technician to do it for me. connection to my refrigerator or
your points.
I am also an electronics and disposal. I too enjoy fixing things. That
Bryan Bergeron
computer scrounger. I really enjoy Nuts said, I have an elderly parent who lives
& Volts and drop everything else to alone and it would be great to verify his
My primary computer for years
read it when it shows up in my toaster was used in the morning, etc.
was a XP 32-bit machine running on
mailbox. I just wish that I had For me, however, give me the retro
hardware that I built. I do not buy pre-
subscribed to it sooner. God bless! tech.
made systems. I don't like the software
Richard R. Pope Bryan Bergeron
packages and I especially don't like
Reedsburg, WI
having only a recovery disc instead of
I feel your pain! I tried Ubuntu
the complete OS disc.
Thanks for sharing your experiences, (10.10) when I was gifted an old
I have built a dual processor MB
Richard. I'm right there with you on the Thinkpad. It loaded and ran fine.
with Intel Xeon E-2603 v3 six core
subscription services. I keep an old When I bought a new HP 15, the
CPUs running at 2.1 GHz. I have 32
machine on my desk with out-of-date first thing I did was to format over
GBs of RAM and I am running Win8.1
Photoshop and similar programs that I Windows 10 and install Ubuntu
64-bit Pro. I finally hit a wall with XP
own on disc. 14.04LTS. I think I spent $15 for a copy
and I needed Win8.1, but it won't run
Bryan Bergeron of Ubuntu Magazine just to get the
on my XP hardware.
distribution CD.
This will probably be my last MS
There are ways around the I installed Wine for the couple of
OS. I will not use OSes nor software
subscription software model. For office times I wanted to run a Windows only
that depends on a subscription service
software, there is Open Office and package.
and/or the Internet. These requirements
Libre Office. There is also Linux. I have James Lynes KE4MIQ
also open up your network and
6 July 2017
Reader Feedback - Jul 17_Layout 1 5/30/2017 6:18 AM Page 7

Thanks for reaching out with your but it is a disturbing trend. make a habit of storing my iTunes library
story. Yeah, I guess it's inescapable for Had this been the unofficial policy as local MP3 files, and backing those
those of us working with tech. back in the early days of computers, up.
Bryan Bergeron garage-based companies like Apple and I know that eventually the Apple
Microsoft would never have come to cloud will blow away with the other
I could not agree with you more. I fruition. Imagine if Motorola had stated clouds, or cost a fortune to access.
have been saying the same thing for that when you bought a 6805, you Bryan Bergeron
decades, but it goes so much deeper. could only use it in certain pre-
My first experience with the prescribed circuits.
"subscription" model was the failed I don't know about society as a
Would you like to receive Nuts & Volts’
Circuit City video disc, DIVX. You whole, but for me, I will stick with my
purchased the physical media at a physical LPs and CDs for music. I'll stick weekly content newsletter? You have
greatly reduced cost versus traditional with physical media (including my three ways to sign up:
DVD discs, and then each time you beloved LaserDiscs and Selectavision
wanted to watch the movie, you had to discs) for movies. I'll stick to open • Visit us on Facebook and click on “Join My
pay a "rental" fee. source programs and data I can modify
My first impression was, what to my hearts’ content — all stored and List.”
happens when this goes bust? You're running on my own hardware. • Using your cell phone, send
essentially stuck with a coaster. Sure As an independent thinker, I will
enough, my prediction came true do whatever I want with hardware that
“NVNEWSLETTER” as a text message to
shortly thereafter. I purchased with cold hard cash. 22828.
Now, despite that failed Derek Tombrello KM4JAG
• Visit the Nuts & Volts FAQs to sign up at
experiment, "cloud" based services
encompass almost every aspect of life. Thanks for sharing your thoughts. I nutsvolts.com/faqs
VUDU and its kin have taken up where
DIVX died; iTunes stores your music
library; TinkerCAD and other online
programs are gaining acceptance as the
norm; even your data is stored in the
cloud in many cases.
Every bit of this is doomed to
obsolescence by design. At least in the
case of DIVX, Circuit City could have
released a patch before going under
that would have unlocked the discs to
give buyers the multimedia for which
they paid. When companies like VUDU
go under, you've lost not only the
money you've put out on these
nonexistent ones and zeros, but you've
also lost the data.
Even worse than that, though, is
the public-accepted model of buying
hardware and being told by the
manufacturer what you can and cannot
do with it. The Nintendo 3DS leaps to
mind as but one example. I understand
the desire to hinder piracy, but piracy is
not the only reason to "root" hardware.
It would be like buying a PC and
Microsoft telling you that you cannot
install Linux on it. If you do, they will
disable your hardware. I can't
understand why the public in general
has collectively agreed to give so much
power over their lives to corporations,
July 2017 7
Q&A
n WITH KRISTEN A. McINTYRE

In this column, Kristen answers questions about all aspects of electronics, including computer
hardware, software, circuits, electronic theory, troubleshooting, and anything else of interest to
the hobbyist. Feel free to participate with your questions, comments, or suggestions. Send all
questions and comments to: Q&A@nutsvolts.com.
We start with the simple current source

• A Simple Current Source that you’ve probably seen me use before in this
column. It’s based on a bipolar transistor (see
Figure 1). To understand how it basically works,
• A Block Heater Power Indicator we will make some simplifying assumptions.
These assumptions are not entirely true, but
• Arduinos and LEDs — Redux allow us to look at the effects which are
dominant as the circuit tries to supply current.
For this discussion, we will assume that: a)
A Simple Current Source the base current is negligible; b) Vbe is always 0.6V; c) the

Q
I am doing some experiments and need a transistor can be modeled from collector to emitter as a
constant current source as a reference. Most current source itself; and d) that β — the current gain — is
of the designs I have seen appear overly quite high.
complicated to me, and the off-the-shelf units With these assumptions in place, you’ll notice that
are too expensive. Is there a simple constant current source the base is held at a particular voltage with respect to the
circuit design you can recommend? I need something in power supply common point using a zener diode, D1.
the range of 0-12V and 1-100 mA. In this case, it’s a 5V diode. With assumption b) above,
Terry Keith we can see that the emitter will be at 4.4V. Next, we use
Los Angeles, CA assumption a) to say that the emitter current is about the
same as the collector current. That means we can calculate

A
Building a functional current source is actually the emitter current by simply doing a V = IR calculation,
quite simple. The major considerations are how using 4.4V for V; R is the emitter resistor, R1 in the
much voltage and power needs to be supplied, schematic.
and how stable it needs to be — particularly With the values shown, the emitter current is 100 mA.
thermally. Let’s take a crack at this first without much Using assumptions c) and d) tells us that the collector will
consideration for stability. We’ll assume that we are going work to make its current be 100 mA also, if that’s possible.
to control the current with a simple resistor that could With that, we have a roughly 100 mA current source.
also be a potentiometer. Regulating the current under What are the limitations, though? First, you may notice
computer control with an Arduino or some other single that the lowest voltage at which the collector can be and
board computer is quite doable, but adds an extra level of still function as a current source is somewhere a bit above
complication. 4.4V. Below that value, junctions in the transistor might
become forward biased
that we don’t usually use
that way. Current might
begin to flow in ways that
break our assumptions,
and thus the current won’t
be what we expect.
Under some
circumstances, the
transistor will go into
saturation, keeping it from
responding quickly to
changes that might make
it behave as a current
source again. How can
we fix this to match the
0-12V range?
n FIGURE 1. Simple NPN current source. n FIGURE 2. “Upside down” PNP current source. There are a
8 July 2017

McIntyre - Q&A - Jul 17.indd 8 5/29/2017 2:08:18 PM


QUESTIONS and ANSWERS
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2017/07.

A Block Heater
Power Indicator

Q
I am a diesel
head who
drives a 2002
F250. I noticed
that when I plug in the
engine block heater, there
is no indicator light to
tell me that the cord is
actually attached to 120
VAC. Do you have a circuit
n FIGURE 3. JFET current source. for rigging up some kind of
indicator safely?
couple of different solutions. One n FIGURE 4. Thermally stabilized NPN current source. Mark Newsom
would be to lower this circuit below Franklin, TN
the 0V point (where the triangular ground symbol is). That

A
would work fine, but might be inconvenient. The other This should be a rather straightforward task, I’m
would be to turn the circuit upside down using a PNP thinking. There are a number of LED indicator
transistor, and raise the supply voltage to compensate for lights that you can buy that already have the
the 4.4V lost by the base voltage (see Figure 2). proper current-limiting resistors. This puts
Another thing we might do is reduce the voltage of everything in one package and keeps you from having to
the zener diode. This last technique has the drawback insulate everything quite so carefully with those small LED
of reducing thermal stability. Bipolar transistors have the leads and a resistor. A search on the Internet for “120V
characteristic that Vbe drops considerably with increases in LED” shows me many different lights of different colors
device temperature. FETs can also be used in a similar way that range around $3 to $5. You can just get a small panel
with fewer components (see Figure 3) using their property mount LED indicator. I would not recommend routing the
of voltage control at the gate, but FET Vgs thresholds are AC mains far from the heater since that might become a
also affected by temperature. hazard if there was ever a problem with the insulation.
Thermal compensation can best be done by using The LED indicator will likely flicker a bit from it only
another transistor (Q2, Figure 4) to put in some negative lighting on half of the 60 Hz sine wave, but that should be
feedback. This negative feedback will try to keep the fine for most people. I personally have a high flicker fusion
current constant based on Q2’s Vbe. This requires that rate, so I tend to notice that. Anyway, carefully solder the
Q2 be thermally isolated from Q1. There is an additional LED indicator into the heater and mount it as you please,
benefit that the required voltage to
get Q1 to act as a current source is
reduced (it will work down to a little
above 2 x Vbe).
Note that you can easily invert
this to use PNP transistors. It doesn’t,
however, compensate for all thermal
variations — particularly ambient ones.
The best way to compensate for almost
all of the thermal variations — short
of matched devices — is to use large
amounts of negative feedback by
employing an op-amp with a precision
voltage reference (Figure 5). I have
used this technique on precision
measuring equipment I’ve designed.
The op-amp power supplies should
be between the 0V and 18V points. n FIGURE 5. Op-amp based current source with stabilized voltage source.
July 2017 9

McIntyre - Q&A - Jul 17.indd 9 5/29/2017 2:08:18 PM


being careful to keep the AC mains insulated and safely thermometer that I can use to see how much the part
away from anything that might abrade the insulation. That might heat up. Let’s see what happens.
should work well. I propose an experiment where I try to find the lowest
voltage/highest current LED in my parts box and turn it on
Arduinos and LEDs — Redux for an extended period of time using the Arduino. I have a
spare Arduino Mega that I’m not using at the moment. I’ll

Q
I once came across a minimal component also try to measure the current. With the thermometer, I’ll
design with an ATtiny and LED without a resistor see if the part or the LED heats up beyond a reasonable
and had the same question as Mike in the temperature for the devices in question. Here we go.
February column: Wouldn’t this burn up the I wrote a couple of lines of Arduino code to make
microcomputer? I don’t think 20 mA is a current-limited pin 6 an output and high, and began the experiment by
output; it’s the safe maximum current without converting letting the Arduino board’s temperature stabilize in that
the driver transistors into fuses. The datasheet does have configuration. I took a reading of the Atmel device’s
the answer in the Pin Driver Strength graph showing output temperature with the infrared thermometer. I then
source/sink voltage vs. current (the graph stops at 20 mA, downloaded the code and measured the voltage on pin
i.e., is not a knee). 6 with no load. The starting values were 86˚F and 4.98V.
Carl Hage Those are the nominal values.
Next, I stuck the LED anode into the pin 6 header.

A
I have actually received a couple of responses I used a clip lead to connect the cathode to my digital
like this. My assertion was that the outputs ammeter, and the LED came on nice and bright blue.
are current limited and well protected. Who Measuring the current, it was 44 mA. That’s not bad for
knows, I might be wrong. There’s nothing like this device. I then reconfigured the meter to measure
an experiment to try to answer such a question. I have a the voltage with the LED in-circuit, and it was 3.46V.
bunch of LEDs in my parts box and an Arduino that I’m That’s about what I expected. It seemed to be working as
willing to sacrifice to the cause! I also have an infrared predicted. Refer to Figure 6 for a picture of the test setup

TS-4900
Computer on Module
Choose your own adventure. WiFi and Bluetooth Enabled
1 GHz i.MX6 Computer Module
Now Supporting Ubuntu Core

1GHz Single or Quad Core Cortex A9 ARM CPU Starting at


Up to 2GB DDR2 RAM $109
Qty 100
4GB MLC eMMC flash storage
WiFi and Bluetooth radios on-board $144
Qty 1
High speed industry standard connections
Rugged, Industrial with Fanless -40°C to +85°C Range

Now Supporting:

For more details go to: TS.TO/UC

www.embeddedARM.com

10 July 2017

McIntyre - Q&A - Jul 17.indd 10 5/29/2017 2:08:19 PM


while it’s up and running.
Now let’s cover the long term
durability and temperature test. The
amount of power being dissipated in
the driver on the Atmel chip should be
1.54V x 44 mA ≈ 68 mW. That should
not produce much of a temperature
rise and indeed it doesn’t. After 30
minutes, I couldn’t measure any
significant change, though the infrared
thermometer I was using is not that
stable over multiple measurements and
the result changes with where it was
targeted. It hovered around 86˚F.
So, there you have some
experimental evidence that an Arduino
is just fine driving an LED directly,
without a current-limiting resistor. This
is not to say that all situations like that
are fine; just that this particular driver
is current limited, so the LED and the
device are very happy working this
way.
Just for fun, I changed the code to
make it blink too! NV n FIGURE 6. Arduino LED direct drive experiment.

July 2017 11

McIntyre - Q&A - Jul 17.indd 11 5/29/2017 2:08:20 PM


McPhalen - Spin Zone - Jul 17_Spin Zone - Aug 15.qxd 5/30/2017 6:19 AM Page 12

THE SPIN ZONE ■ BY JON MCPHALEN


ADVENTURES IN PROPELLER PROGRAMMING

A Block On the Old Chip


One of my greatest joys is teaching others how to program microcontrollers so they can
do what they want to do — not just what others have done before. We should, of course,
learn from others when we can, but the real fun is in original program creation. About a
week before the Transworld trade show, my friend Kip at Pale Night Productions asked for
a very difficult BASIC Stamp 1 program. I fixed a cup of coffee, sat down at my desk, and
started coding. Two hours later, the program worked as Kip wanted, and he now deploys
it in one of his escape room props (I saw it in action at the show). What's interesting
about this is that I caught myself being extremely happy with the results of my work. I
want more people to experience this joy.
flowcharts on a whiteboard. While not quite the same

K
en Gracey, the CEO of Parallax, has been my friend
for 20 years, and like me, he loves to teach people thing, now I can drag and drop programming blocks that
how to create with Parallax microcontrollers. Over generate standard code (Propeller compatible C).
the past year, I have seen a huge renewal in Ken’s love of BlocklyProp differs from more traditional programming
the Propeller — not that it has ever waned, mind you. With tools in that it is web-based and runs through a browser.
the implementation of a new programming tool, Ken On our end, we run a small client app which allows the
seems to be on a non-stop tear around the country BlocklyProp server to provide compiled code that is
teaching students and their teachers the joys of Propeller downloaded into a Propeller board. This does, of course,
programming. His joy is infectious, and that — I believe — require a live connection to the Internet to run
is the key to inspiring others. BlocklyProp.
The tool I speak of is called BlocklyProp: a visual Being web-based, there is a bit of a process to get up
programming environment based on Google’s Blockly and running, but don’t worry! It’s quite painless. First,
which, in turn, is loosely based on MIT’s Scratch point your browser to:
programming language.
There are several implementations of Blockly for a http://blockly.parallax.com/blockly
variety of platforms. For example, MIT App Inventor 2 is
used to create Android applications. This was my first Click on the Register Now! link and provide the
exposure to Blockly programming, and I have used it to necessary details: screen name, email, and password. A
create several small mobile apps that communicate via confirmation email will be sent to you. You’ll click on a
Bluetooth with various Propeller boards. link in that email to confirm your registration.
Some will logically wonder why an experienced At this point, you can go to the BlocklyProp home
programmer would embrace a system clearly intended for page and log in with your email address and password.
beginners. I can give you a couple reasons. First, it’s a Once logged in, you’ll need to download and install the
proven programming tool, and as I love to help others get BlocklyProp client. There is a link at the bottom of the
started in microcontrollers, this may be the nudge that page for this. Download the installer that is appropriate for
pushes a newcomer over the edge into writing their own your computer: Mac, Windows 32-bit, or Windows 64-bit.
programs. Most newcomers find Blockly inviting, and the After running the client installer, it’s a good idea to restart
colorful drag-and-drop blocks help them succeed with your computer to ensure the latest FTDI drivers are
simple projects very quickly as they work through to more running.
complex tasks. I allowed the installer to create a desktop shortcut for
Here’s another reason: Being a visual programming the client. Double-clicking brings up the client window as
environment, Blockly engages different areas of the brain. shown in Figure 1. Click Connect to start the client, then
I frequently step away from my computer to draw click Open Browser; this second step will open your
12 July 2017
McPhalen - Spin Zone - Jul 17_Spin Zone - Aug 15.qxd 5/30/2017 6:19 AM Page 13

To post comments on this article and find any associated files and/or downloads, go to
www.nutsvolts.com/magazine/issue/2017/07.

■ FIGURE 1. BlocklyProp client.

system browser and take you right to the BlocklyProp


home page where you can log in.
Once back into the system, a menu across the top of ■ FIGURE 2. Project definition.
the page will allow you to view community projects,
select from one of your own projects, or create a new As I selected the “Other” board type, all pins are available
one. We’ll start by creating a new project. A drop-down from this list. This will not be the case with some boards.
menu will present Scribbler Robot and Propeller C. Select The second block contains a variable that defines the
the latter. pin to be used. In either case, drag the block onto the
You’ll be presented with a page where you can canvas and connect to the bottom of the terminal block,
describe the project and select the board that it runs on. change the pin number to 26, and leave the state high.
In my case, I’m using the Propeller Activity Board (PAB), With the LED on, we need a delay. In the Control
but I am going to select “Other” for board type (Figure 2). menu, there is a pause block. Drag this under the make
Why? Because the “Other” board type doesn’t limit PIN block and set the time to 500 ms.
access to blocks as some board types necessarily do. That Right-click on the make PIN block and select
said, this comes from the added responsibility of knowing Duplicate. Drag this block under the pause block, and set
my hardware. I do! the state to low. Duplicate the pause block and drag it
Click on the Next button and select Private. I think it’s under the second make PIN block. Leave the timing at
a good idea to keep my projects to myself until they are 500 ms.
fully wrung out and ready for others to work with. We’re done! The final program should look like Figure
BlocklyProp allows us to go back and make a project 3. Above the programming work space, you’ll see five
public (Shared) when it’s ready to impress the world. round icons; two are green and have downward-pointing
Finally, click on Finish. That big blank space that arrows. Select the arrow without a horizontal bar to
consumes most of the screen is our programming work download to the Propeller RAM without overwriting the
space. On the left is a vertical menu with BlocklyProp EEPROM (that’s what the other icon does). When you do
elements. Let’s start with the obligatory “Hello, World!” this, you’ll see the programming status window pop up,
blinking LED example, shall we? followed by the terminal that happily prints our message
Click on Control to get a fly-out menu of the various as the LED blinks every second.
control elements. As most programs contain an infinite To be honest, it took me far longer to type and for
control loop, we will use the simple repeat block (third
from top); click on and drag this block to the canvas.
This block has a drop-down menu that is defaulted to
“forever.” For our master loop, that is what we want.
From the Communicate menu, select Terminal, and
then drag the Terminal print text block onto the canvas
and insert it into the repeat block. You’ll notice that the
terminal block contains a string variable that is preset to
“Hello.” Change this as you please.
■ FIGURE 3.
The PAB has an LED connected to P26, so we’ll BlocklyProp
make that blink. From the Pin states menu, select make Hello World.
PIN. Oh, there are two. Note that one of these two
blocks has a drop-down menu to select the affected pin.
July 2017 13
McPhalen - Spin Zone - Jul 17_Spin Zone - Aug 15.qxd 5/30/2017 6:19 AM Page 14

Jon “JonnyMac” McPhalen


jon@jonmcphalen.com

you to read the preceding paragraphs than it would to for practical delays where a milliseconds timer would be
build a simple program like this from start to finish. That’s more convenient.
the point: BlocklyProp allows us to build a program If you’re a regular reader, you know that I’m not a big
through an intuitive process and does us the big favor of fan of the Arduino, but I do use it from time to time to
handling pesky syntax details like curly braces and help my friends. One of its saving graces (for me) is the
semicolons (something I always forget about when millis() function that gives us the number of milliseconds
programming in C). since reset. Using millis(), we are able to create programs
In listening to Ken talk about BlocklyProp, this is about that appear to multi-task.
the extent of instruction that most students need. After Here’s how we can use it (this is pseudo-code):
that, they are allowed to roam free in the system to
xtimer = millis
accomplish personal or assigned tasks. You should do that ytimer = millis
too (after finishing my column, of course).
Explore the menus. If you’re new, some items may not repeat forever
if (millis – xtimer) >= XTIME
make sense right away, so ignore them until later. If you’re xtimer += XTIME
an experienced programmer, this is the time to get a feel do_x_process
for the various menus and the elements they contain. if (millis – ytimer) >= YTIME
For those that want to take a look under the hood, ytimer += YTIME
click on the Code button in the upper right-hand part of do_y_process
the screen. Here’s what we get:
This simple framework adds a lot of power to
/* SERIAL_TERMINAL USED */ applications, allowing us to do more work in a core (the
// ——— Libraries and Definitions ———
#include “simpletools.h” Arduino only has one) while not wasting time with
pause().
// ——— Main Program ———
int main() The first step is to synthesize a milliseconds timer in
{ the Propeller. We will create a function that manages the
while (1) timer; this function will contain an infinite loop that will be
{
print((“Nuts & Volts”)); launched into its own cog. From the Functions menu,
print(“\r”); drag a function block onto the work space and name it
high(26);
pause(500); “background.” From the Variables menu, drag a variable
low(26); block onto the canvas and change its name to “ms1Tix.”
pause(500); This value will be the number of system clock ticks in one
}
}
millisecond, which is to say the clock frequency divided
by 1000. Can we have a variable assignment that is an
In the beginning, we don’t need to look at the expression in BlocklyProp? We can.
generated C code. Down the line, however, BlocklyProp Open the Operators\Numbers menu, drag a math
will likely become a bridge to programming with operator (topmost) block onto the canvas, and connect it
traditional tools. For my part, I copied the code produced to the ms1Tix block. Now, set the operator to division. In
by BlocklyProp into SimpleIDE, made modifications, and the System menu, locate the system block and drag this
ran it. into the first parameter space of the math operator block.
The blinker project that we just created could, in fact, The system block defaults to “counter.” Change this to
run on any microcontroller that has a Blockly “clock frequency.” Complete the expression by dragging a
environment. The ability to use multiple cores is what sets number value block from the Values menu into the
the Propeller apart from the rest, and even in a beginner- second parameter space of the math operator block, and
friendly system like Blockly, we can create sophisticated then change the value to 1000.
multi-core programs. By now, you have the hang of using BlocklyProp, so
The output of the next LED blinker program will I’m going to point you to Figure 4 as a guide to
match the first, but will use a framework that allows us to completing the background function.
do other work while waiting for the time to change the Here’s what’s going on in the background function: A
state of the LED. The lesson here is that pause() is the variable called ms1Tix is initialized to the number of
devil and should be avoided when possible. system clock ticks in one millisecond. Next, a variable
Okay, then. How do we create a delay without using called sysMillis (our timer) is initialized to zero. The final
pause()? A simple way is to track the time between two variable, sysT0, is initialized to the current value of the
points. system timer. This variable allows us to run the repeat
As you may know, the Propeller has a system counter loop at exactly 1,000 Hz.
that runs at the system clock speed; in BlocklyProp, this Inside the repeat loop, we add the value of ms1Tix to
defaults to 80 MHz. This is great for short delays, but not sysT0 to create a new target for the Pause until block.
14 July 2017
McPhalen - Spin Zone - Jul 17_Spin Zone - Aug 15.qxd 5/30/2017 6:20 AM Page 15

■ FIGURE 4. Background
function.

T IN G
U V P R IN
F E R IN G
NOW OF
T PA N E L
FRON N E RI T
I G
D E S – WE MACHINE
GN IT
YOU DESI re s
lo s u
ls & E n c
C u s to m Pane
c tu ri n g
 a n u fa
tM
■ FIGURE 5. Modified w a re
A D S o ft
LED blinker. tF re e C
h ip p in g e n ts
tF re e S e q u ir e m
im u m O rd e r R
tN o M in
5 Days
tB u il t in
www.frontpanelexpress.com

When the code drops through Pause until, the value of


sysMillis is incremented.

Author’s Note: At the time of this writing, I am


lobbying the BlocklyProp team to rename the Pause until
block to Wait until to prevent confusion with the standard
pause block. This block compiles to waitcnt() which (to
me) justifies the name change.

We don’t want to call the background function


directly because the code will be trapped in its infinite
loop. What we want to do is launch it into its own cog so
that it does, in fact, run in the background.
Drag a new processor block from the Control menu
onto the work space, and put it at the top. Open the
Functions menu and grab the run function “background”
block. Drag this into the new processor block.
There is something important to point out here: The
new processor block compiles down to cognew(). Hence,
it should only contain a single run function block. That
function can call other functions as required.
July 2017 15
McPhalen - Spin Zone - Jul 17_Spin Zone - Aug 15.qxd 5/31/2017 10:49 AM Page 16

Parallax, Inc.
www.parallax.com
Propeller boards, chips, and programming tools

■ FIGURE 6. Clean main loop.

■ FIGURE 7. LED 26 function.

Okay, we have a background milliseconds timer. Let’s


put it to use. Figure 5 shows the modified master block
which takes advantage of the timer. Yes, I know this looks
somewhat complicated, and it is certainly more
sophisticated than the original example. What we gain
from the effort, however, is a lot of time that is no longer
wasted sitting in a pause block; valuable time we can use
to handle other processes.
Finally, I like to keep my master program loop tidy by ■ FIGURE 8. LED 27
calling discrete atomic functions. I created a final blink function.
demo (sans terminal output) that will flash both LEDs on
the PAB. By removing the terminal output, the P26 Give BlocklyProp a try. If you’re new to the Propeller,
flashing can be simplified to toggle. For the P27 LED, we it’s a way to get started without the worry of syntax rules.
create an asymmetric flash by varying the state time based If you’re a crotchety old dude like me, it’s another tool to
on the LED condition. See Figures 6, 7, and 8. help others and, perhaps, to look at code from a different
I know that blinking LEDs is not as glamorous as point of view.
running a robot, but the framework we just put together
is excellent for robots and all sorts of other schedule- Until next time, keep Spinning and winning with the
based processes. Propeller! NV

Your Single Source of Electronic Equipment, Tools, and Components

01DM820B 01DMMY64 01DMM9803R Sweep Function Generator


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

01DS1102E 01SDS1052DL DC Power Supplies


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

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

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


16 July 2017
New Products - Jul 17_Layout 1 5/30/2017 6:21 AM Page 17

■ HARDWARE

NEW PRODUCTS ■ SOFTWARE


■ GADGETS
■ TOOLS

range as BR/EDR or
BPA LOW ENERGY classic Bluetooth.
BLUETOOTH The Bluetooth low
PROTOCOL energy specification
allows new lower power
ANALYZER wireless devices to

S aelig Company, Inc., has


announced the availability of
the BPA low energy Bluetooth
interoperate within the
Bluetooth ecosystem.
The BPA low energy
Protocol Analyzer from Teledyne
Bluetooth protocol
LeCroy — a powerful, portable
analyzer is available for
protocol analyzer for wireless
$995.
transmissions that adhere to
Bluetooth low energy specifications. connected devices or piconets,
decrypting and decoding the data For more information, contact:
Ideal for field or lab use, the BPA
transmitted and received by the
Saelig Company
low energy analyzer is USB powered, www.saelig.com
eliminating the need for an external devices using various profiles and
power supply. This analyzer supports protocols.
all of the mandatory Bluetooth low With the BPA low energy
energy features through Bluetooth analyzer, setup is easy and does not
version 4.2, and ships with Frontline require synchronization to devices.
software allowing Bluetooth For coping with proprietary wireless
developers the ability to see events as protocols, the BPA low energy ships
they occur live, decoding and with DecoderScript software, which
decrypting the Bluetooth data for full enables proprietary data to be fully
analysis and troubleshooting issues. decoded and displayed in the
Smaller than a deck of cards (3.5" Frontline software along the other
x 1.75" x 0.71"), this BPA low energy Bluetooth profiles and protocols.
analyzer decodes all Bluetooth low Developers of Bluetooth low
energy traffic — including advertising energy wireless technology will
packets, data packets, and LL control appreciate the BPA low energy's no-
packets. It scans all three advertising hassle device setup for decoding —
channels concurrently, allowing a just plug the BPA low energy analyzer
single BPA low energy analyzer to into a PC's USB port and it is ready
detect connection requests from for reliable development and problem
initiators on any of the three solving. Engineers will find this
advertising channels. analyzer invaluable as they create and
Once the connection is debug innovative wireless Bluetooth
established, the BPA low energy low energy enabled products.
analyzer follows the link across all Bluetooth low energy technology
Bluetooth low energy channels, is intended to provide lower power
capturing and displaying information consumption and lower cost, while
sent back and forth between the maintaining a similar communication
July 2017 17
Levergood - Spinning into near space Part 2 - Jul 17_Blank Project NV.qxd 5/30/2017 6:23 AM Page 18

BUILD IT YOURSELF

Build an Adaptable Controller


for Your Near Space
BALLOONING
MISSIONS Part
2

By Richard Levergood and Maria Panacopoulos

I hope you enjoyed “Spinning” into near space last month, where we introduced a
flight controller that you can use in your own near space ballooning projects. This
month, we’ll introduce the program and highlight a few of its key features. The
program has evolved over the past five years to keep up with changes in the flight
controller and to accommodate new sensors. Although it works as-is for the specific
flights we completed in the past, you should review and modify the program to meet
your own needs.
18 July 2017
Levergood - Spinning into near space Part 2 - Jul 17_Blank Project NV.qxd 5/30/2017 6:23 AM Page 19

To post comments on this article and find any associated files and/or
downloads, go to www.nutsvolts.com/magazine/issue/2017/07.

Overview of the Code ALTCUT = 175 ' cut initiated above the
' altitude (m) if mission
' time > ALTTIME(s)
ALTTIME = 60
Programming was done using the free Propeller Tool
programming software and Spin — the native language for DESC_EN = TRUE ' TRUE allows autonomous
the Propeller. We also relied on several library “objects” ' cut based on a continuous
' descent, false disables
from the Parallax Object Exchange. DESC_ALT = 10_000 ' altitude above which
For Mac users, you can run Propeller Tool under Boot ' descent cut is enabled
Camp™ or Parallels™. Or, download PropellerIDE from the ' (m)
DESC_REQ = 10 ' number of descent
Parallax website. At this time, it is beta. ' measurements needed to
The program has undergone many revisions since first ' initiqate a cut
written. You can download the current version and all the BURN_TIME = 30 ' elapsed mission time(s)to
needed objects in a zip file from the article link. You may ' burn cutter after cut
use if freely if the MIT license and credits to original ' initiated
authors are kept with the programs. WRITE_PERIOD = 2 ' # time interval between
' writes to SD card and PST
Mission Options RECO_EN = TRUE ' TRUE enables recovery
The program starts with a long list of constants that ' beeper, FALSE disables
are used to configure each mission: RECO_BEEP_TRIG = 12_000
' mission time (s) at which
' to start recovery beeps
CON 'Mission Options RECO_BEEP_PER = 15
' Mission box definition in seconds ' time period (in # of
' test Launch Site, Exit 10 Warner ' loops) between recovery
NORTH = 158_400 '44 deg ' beeps
SOUTH = 154_800 '43 deg
EAST = 255_960 '71.1 degrees VREF = 2500 ' reference voltage for ADC
WEST = 259_200 '72 deg ' (mV)
BASE_ALT = 50 'base altitude in meters,
'for pressure altimeter
'calibration Features can be enabled or disabled by assigning
certain constants a value of TRUE or FALSE, as detailed in
PST_EN = TRUE ' TRUE loads Parallax
' serial terminal; FALSE the comments. Other constants are assigned important
' does not numeric values specific to the mission. For example, the
ADC_EN = TRUE ' TRUE loads the ADC driver constants NORTH, SOUTH, EAST, and WEST define what
' at startup, FALSE does
' not we call the “mission box:” the boundaries within which
CTR_EN = TRUE ' TRUE enables the counter the balloon and payload are allowed to drift. You can scan
' at startup using CTRA, the comments to find the meaning of the others.
' FALSE does not
ALT_EN = TRUE ' TRUE loads the Parallax
' 29124 altimeter at GPS and Position
' startup, FALSE does not
Code in the main loop compares the current GPS
LEDSTROBE_EN = FALSE position to the mission box. If “out of bounds,” the global
' true starts the FAA variable outbox is TRUE:
' required strobe light
' driver. FALSE does not.
T_ON = 100 ' strobe on time (ms) 'assess GPS status-------------------------------
T_OFF = 1500 ' gate off time (ms) nsats := gps.n_satellites
if (gps.hasgps == FALSE or nsats < 4 )
MTIME_EN = FALSE ' TRUE allows autonomous ' test for valid gps signal
' cut based on mission High(LEDSatFXQ)
' time,FALSE disables ' turn on FXQ warning indicator LED
MCUT_TIME = 10 ' elapsed mission time(s) else
' when cut is initiated ' there are 4 or more satellites locked on
low(LEDSatFXQ)
MBOX_EN = FALSE ' TRUE allows autonomous ' turn off FXQ warning indicator LED
' cut based on mission box, latsecs := gps.n_lats+(gps.n_latm*60)
' FALSE disables +(gps.n_latd*3600)
BOX_DELAY = 60 ' elapsedtime (s) outside ' compute latitude in seconds
' the mission box before lonsecs := gps.n_lons+(gps.n_lonm*60)
' cutting +(gps.n_lond*3600)
' compute longitude in seconds
ALTCUT_EN = FALSE ' TRUE allows autonomous outBox := lonsecs > WEST or lonsecs <
' cut based on altitude, EAST or latsecs > NORTH or latsecs <
' FALSE disables SOUTH

July 2017 19
Levergood - Spinning into near space Part 2 - Jul 17_Blank Project NV.qxd 5/30/2017 6:23 AM Page 20

' check if outside mission box variable ttock that toggles every second, like a ticking
if outBox == TRUE
high(LEDMissionBox) clock:
' turn on alarm LED
else PRI softrtc | t0, i
low(LEDMissionBox) '' Software RTC
' not out of the box , turn off warning LED '' -- runs in standard "clock" mode
'' Jon "JonnyMac" McPhalen (aka Jon Williams)
'' Copyright (c) 2010 Jon McPhalen
The code that actually initiates a cut is contained in ''revised by ral, 2016.
the PUB Linecutter method. The balloon can be
t0 := cnt
autonomously cut free from the payload if the flight drifts repeat
beyond the mission box boundaries, the mission box if (Clock[REG_RST] < 0) ' reset flag?
MBOX_EN is TRUE, and signals from at least four GPS longfill(@Clock, 0, 6) ' yes, clear
' everything
satellites have been acquired. This is provided as an waitcnt(t0 += MS_001) ' wait 1ms
example. The method includes additional criteria for
cutting the payload free; for example, when descent is if (++Clock[REG_MS] == 1_000) ' one second?
Clock[REG_MS]~ ' clear ms
detected and at a certain time or altitude. ttock := 1
To prevent premature cutting, the payload must be if (++Clock[REG_SC] == 60)
' inc secs, check for 60
outside of the mission box for more than BOX_DELAY Clock[REG_SC]~
seconds before cutting: ' clear secs
if (++Clock[REG_MN] == 60)
'check for mission box state and evaluate cut -- ' inc mins, check for 60
elseif nsats >3 and MBOX_EN == TRUE Clock[REG_MN]~
if outBox == TRUE ' mission is outside ' clear mins
' of mission box if (++Clock[REG_HR] == 24)
if outTime == 0 ' if the out of box ' in hrs, check for 24
' clock is zero... Clock[REG_HR]~
outTime := missionTime ' clear hours
' set the initial out of box clock to the if (Clock[REG_DY] < posx)
' current mission time ' days below max?
else ++Clock[REG_DY]
dtime := missionTime - outTime ' increment
' time difference clock is current seconds minus else
' initial seconds ' else
if dtime > BOX_DELAY Clock[REG_DY]~
' cut if out of mission box for however many ' clear
' seconds
High(LineCut)
' turn on pin driving transistor/relay The clock is zeroed when the Flight Enable tab is
High(Beep) pulled by calling the resetClk method. Next, the main loop
' sound warning piezo
cutActive := TRUE starts and mission time is calculated using hour, minute,
' cut is on so set cut flag and seconds values accumulated by the softrtc method.
cutTime := missionTime
' define time cut turned on Notice that the missionTime unit is seconds — a
cause := 10 convenient scale for keeping track of time that avoids the
need for floating point values in units of minutes or hours.
if outBox == FALSE
'reset out of box clock The statement low(LEDSD) turns off the SD warning
dTime := 0 indicator LED if the SD card is successfully mounted:
outTime := 0
repeat until ina[FlightEnable] == 1
'hold until jumper pulled
Timing resetClk
Of course, it is important to keep track of time when
logging data. Because our total elapsed time will be a '------------------------------------------------
matter of a few days rather than weeks or months, a 'main loop
handy software clock by Jon McPhalen meets our needs '------------------------------------------------
repeat
(see N&V July 2010). The clock runs independently and ' used for testing
uninterrupted in its own processor (known as a “cog”). ' outa[RLY1]:=!ina[IN1]
' outa[RLY2]:=!ina[IN2]
The method is launched with this bit of code: ' toggle(Driver)
'start the software clock ---------------------- missionTime := (CLOCK[REG_HR]*3600)+(CLOCK
cognew(softrtc, @RTCStack) [REG_MN]*60)+ CLOCK[REG_SC]
pause(50) ' calculate mission time in seconds

The method itself is shown next. It includes a global ' assess SD card status ------------------------

20 July 2017
Levergood - Spinning into near space Part 2 - Jul 17_Blank Project NV.qxd 5/30/2017 6:23 AM Page 21

if (sdRecording == FALSE) into every Propeller chip (see Resources sidebar). They
'flight tab pulled, not yet recording SD card
OpenNewFile each work independently, so there are no worries about
'open new sd card file. OpenNewFile method missing a pulse while the processor is busy doing other
toggles value of sdRecording
if(sdRecording == TRUE) things.
' a 1 means card successfully mounted The code that reads the pulses is simple. First, the
low(LEDSD) counter is configured and started in a method named
'turn off warning LED
ctrInit. The counter the pulse count is totaled in is a
register that is accessed within the main loop, as shown in
The state of the ttock variable controls the frequency the code block above.
of the main program loop shown next. Execution in the This block of code also computes the average counts
loop is paused when ttock = 0, and continues when it is per minute for each interval before it writes to the SD
toggled to 1 by the softrtc method. This results in a one card, then zeros the register. The global variable total
second period for the main loop. Writes to the SD card maintains the pulse count total for the entire mission. This
occur at the time interval specified in the constants has worked very well, helping us detect the altitude at
section. This arrangement allows reading and responding which maximum cosmic radiation occurs (Pfotzer
to sensors every second, but reduces the amount of data maximum) on several missions:
written to the SD card to a manageable amount:
' pulse counter
' regulate write to SD card and PST------------- if (CTR_EN == TRUE)
if (missionTime => lastWrite + WRITE_PERIOD) ' check if Geiger counter or scintillator is
' write to SD card and PST at interval = ' used
WRITE_PERIOD cpm:=phsa*60/WRITE_PERIOD
lastWrite := missionTime ' compute mean cpm for the write period
' re-initialize lastWrite to current missionTime total:=total+phsa
if (sdRecording == TRUE) ' totalize the counts
' call write to SD card method if write function phsa := 0
' enabled ' zero the ctra
WriteSD (missionTime, meters, nsats,
cpm) SD Card Data and Serial Terminal Display Formats
if (PST_EN == TRUE)
PrintPST (burntime,meters, nsats, cpm) Two Spin methods are responsible for data output:
PUB WriteSD writes data to the SD card; PUB PrintPST
prints to the serial terminal. You will probably need to
Analog-to-Digital Conversion modify the code in both methods depending on what
The ADC is enabled using ADC_EN in the constants sensors you use. We included a lot of example code in
section. The following code reads the four ADC channels these sections for your reference.
and calculates the digital equivalent of the analog sensor
voltages: Future Modifications
After flying Version 1 and Version 2 many times, we
' get ADC data---------------------------------- are very pleased with the performance of the board. The
if ADC_EN == TRUE
' is ADC enabled? upgrades that led to Version 3 need flight time before we
repeat adcCh from 0 to 3 consider it “certified.”
adu [adcCh] := adc.read(adcCh,1)
' read analog to digital units After our PCB file was submitted for manufacturing,
mvolts[adcCh] := adu*vref/4096 we realized that it would be useful to allow quick
' convert to millivolts using 12 bit resolution selection of either onboard or external LEDs. A simple
' and reference voltage
pause(10) solution is a jumper that ties either group of cathodes to
ground. We added this feature to the design files.
The next step, of course, is to convert the voltage to The only planned upgrade to the code is to add the
the desired physical quantity such as, for example, BCD routine. Code to read the digital inputs and control
temperature or light intensity. How to do this depends on the two small relays and high current driver are not
the calibration equation for your specific sensor. We often included in the downloadable program. You can easily
leave the millivolt units in the SD card data file, and have add necessary code to the existing structure as the need
the students import the *.csv file into a spreadsheet arises.
program for further calculation and analysis.
Use of the Controller
Counter Starting up the controller in the field is simple if your
As described above, J8 is a handy way to connect sensors and software have already tested on the bench.
with devices that generate a pulse output. Counting pulses Start by inserting a micro-SD card into the card socket. We
is easily done using one of the 16 counter modules built have used a 2 GB SD card from Parallax many tens of
July 2017 21
Levergood - Spinning into near space Part 2 - Jul 17_Blank Project NV.qxd 5/31/2017 10:45 AM Page 22

times and they always work well. the controller is acquiring contact with GPS satellites. It
Next, power-up the board and watch the four will go off after four or more satellites are acquired. It
indicator LEDs. All will be on for a second test, with a may blink on and off several times if you are in an area
double chirp from the piezo buzzer. They will all be off. with a limited sky view.
The green heartbeat LED (labelled HB) should begin The red MBX LED will initially be on. After the
pulsing with a two second period, indicating the program satellites are acquired, it will stay on if you are outside the
is running. The red SD LED will come on briefly, then mission box, or go off if inside.
quickly go off if the SD card is mounted successfully. The red LED next to the big cutter relay should be
The red FXQ LED will be on for a minute or so while off. If it is on, watch out! There is a problem. That means
the real contact is closed and power
is being sent to the nichrome cutter.

FREE
If so, there will also be an audible
warning from the piezo buzzer.
Be sure to delete all of the files
on the SD card before each flight. A
new file is created — to a maximum
PCB Layout Software & of 99 — every time you boot-up the
PCB Schematic Software controller. This can happen quickly if
you do a lot of pre-flight testing. The
controller will freeze when the file
limit is reached.
The serial terminal is a
convenient way to evaluate pre-flight
sensor and program performance.
Simply start the Parallax Serial
Terminal quickly after the controller
is started. Sensor data and program
function information will be
displayed.

Final Thoughts
The original goal for the 2013
mission was to capture an image of
3 PCBs 3 PCBs 3 PCBs the aurora borealis from 100,000

$
41 $
61 $
81
feet. Although that was not
+ shipping + shipping + shipping successful, the project was successful
in many other ways. We all learned a
2-layer 2-layer 4-layer lot, and for several students the
MiniBoard MiniBoardPro MiniBoardPro project motivated changes in college
(Shipped in 1 business day) (Shipped in 2 business days) (Shipped in 3 business days) and career plans.
I would enjoy hearing from you if
you decide to build and launch one
of these. Please send your thoughts
1 DOWNLOAD our free CAD software to me at rlevergood@london
Now Offering derry.org. NV
2 DESIGN your 2 or 4-layer PCB

3 CHECK your design with xCHECK DRC


SMT
4 SEND us your design with just a click
STENCILS Project SMART
– Nano Coating available–
Project SMART is a month
long summer program for talented
5 RECEIVE top quality boards in just days
incoming junior and senior high
school students (visit http://project
MADE IN THE USA | www.expresspcb.com
smartspacescience.sr.unh.edu).
22 July 2017
Noon - Brain hacking - Jul 17FINAL_Blank Project NV.qxd 5/31/2017 10:53 AM Page 23

BUILD IT YOURSELF

tDCS — By Walt Noon


To post comments on this article and find any
associated files and/or downloads, go to

BRAIN
www.nutsvolts.com/magazine/issue/2017/07.

HACKING?
Operating an armed military
drone half way around the
world is not only a complex
task, but allows for no margin
for error. Lives are quite literally
on the line. The training of
drone operators is necessarily
in depth and intense. Faced
with the problem of training
personnel quickly enough,
DARPA (Defense Advanced
Research Projects Agency)
decided to try an absolutely
extraordinary approach ...

This is a “for fun and experimentation” project and is not


intended to offer medical advice whatsoever.
July 2017 23
Noon - Brain hacking - Jul 17FINAL_Blank Project NV.qxd 5/30/2017 6:26 AM Page 24

make a working tDCS unit is almost


frighteningly simple.
In fact, from a strictly circuitry
standpoint, it qualifies as one of those great
“evening projects” we all love.
However, even though this technology
is over 100 years old and every study seems
to tout the safety of these tiny currents, I
want to emphasize that this is certainly a
“fringe” electronic project in every sense!
I am not an expert nor a medical
professional, but simply a hobbyist who has
had some interesting experiences with this
device that I would like to share with you as
one of the amazing group of readers of
Nuts & Volts. So, proceed with caution!
Another great thing about exploring
offbeat topics like tDCS are the many other
■ FIGURE 1. strange and useful things you always seem
to discover along the way! So, don’t be

S
eizing on recent exciting research in surprised if we take a couple quick detours to project
neurostimulation using transcranial direct current completion.
stimulation (tDCS), DARPA scientists attached salt
water electrodes to the temple and left shoulder of drone A Quick Look at the
operator trainees. After passing very small direct currents
of a few milliamps through the electrodes, scientists were Schematic
“shocked” to find that new pilots attained the skills All that is required for a working device is that we
needed to pilot the drones in half the time normally produce a regulated current of between .5 and 2 mA
required. through a pair of salt water electrodes attached to the
The results were so striking that extensive double skin.
blind testing followed using “sham” currents and control Because skin resistance can vary enormously from
groups, only to find the same results. person to person (I’ve measured resistance between the
Though the idea of using small DC voltages for brain electrodes of anywhere from 1.5K to 5K with different
stimulation is more than 100 years old, the immense people), a minimum voltage of approximately nine volts is
publicity from the well controlled DARPA experiment and needed (2 mA at 9 volts = 4.5K skin resistance).
the simplicity of the design has led to a great deal of both Voltage ranges on commercial units run all the way
professional and amateur interest.
I was first introduced to the ITEM DESCRIPTION
idea by a friend who had been R1 330 ohm
treated for major depression using R2 470 ohm
just such a tDCS machine. His R3 75 ohm
R4 50 ohm
observation was that though he R5 37 ohm
did not feel as if his problems had C1-C2 10 mfd electrolytic
gone away, he said it was “as if a D1-D2 1N4148 (Any general-purpose will do)
net that had been dragging him LED Any 1.8-2.2 VDC
down had been removed after the IC1 ICL7660SCPA voltage converter
IC2 LM334 voltage regulator
treatment,” allowing him to get on S1 Three-position switch
his feet again and deal with his life
PARTS
ST1 Two-pole terminal block
positively.
Many studies show
encouraging results for decreasing
Misc: USB cable
26 Ga stranded hookup wire LIST
1.5" stainless steel fender washers
anxiety, addiction, lessening
Kitchen sponge
depression, and even increasing
concentration. Case: RadioShack 270-1801 (large)
The actual circuitry needed to Or, if ambitious: Hammond 1551GBK (small)
24 July 2017
Noon - Brain hacking - Jul 17FINAL_Blank Project NV.qxd 6/7/2017 11:14 AM Page 25

 !

■ FIGURE 2.



  

  


   


 
  
 



"# $ 
  % & $
 
 
 





 !'$$ ()$*($




    


    


    

     !"!

#
$ % &
' "   
(

 ! )* +  ,-. /


# 0

from nine volts to 18 volts and more. Important Note: Never power any tDCS unit from a
In what is strictly my personal opinion, anything below device that connects — even indirectly — to line current
six volts seems to produce no effect, and above 12 volts under any circumstances.
can occasionally lead to skin irritation (if used with smaller
electrodes). The basic schematic is shown in Figure 2 and uses a
For our schematic, I wanted to power this device simple 7660 voltage converter (configured as a voltage
directly from a cell phone for convenience, or even with doubler with the diode and cap multiplier). The output of
an inexpensive rechargeable cell. So, I thought it would be the converter is coupled to an LM334 voltage regulator.
particularly useful to get power from a USB port Three switched positions allow selection of
connection. Figure 1 shows a USB cable and suitable approximately .5, 1.5, and 2 mA settings.
case. In this configuration, the 7660 will boost the five volt

■ FIGURE 3.
July 2017 25
Noon - Brain hacking - Jul 17FINAL_Blank Project NV.qxd 5/30/2017 6:26 AM Page 26

■ FIGURE 7.

If you are making a scrap drawer assembly and don’t


happen to have an LM334, it is important to make certain
that the voltage regulator you use is stable at very small
currents of less than 2 mA. Figure 3 shows the simple
completed perfboard assembly.
Note: For experimentation, it’s possible to replace S1
with a single 100 ohm potentiometer connected to R5 if
■ FIGURE 4. you would like infinite adjustment (within the set range)
for your own experimentation.
USB output to approximately 11.5 volts to Last, a simple ammeter can be
overcome skin resistance, and the LM334 connected as shown in series with your
will then limit current to between .5 and 2 anode to verify your output for testing.
mA, depending on the feedback resistor. When prototyping my first tDCS, I used the
100 ohm pot mentioned above, and built
the ammeter into the case as in Figure 4.

Making Your
Electrodes
■ FIGURE 5.

■ FIGURE 6. Method 1

Figure 5 shows the traditional way electrodes


were made for most of the university and military
studies I’ve seen. A simple piece of copper screen is
attached (often sewn) to a small clean sponge
approximately 1/4” thick. A wire is soldered to the
screen, and attached to your tDCS device.
The actual material a sponge is made from is
largely unimportant, though a higher density is
preferred for best conduction. (A very porous
sponge can lead to some skin irritation due to the
lack of contact.) Figure 6 shows typical sizing of
sponges.
26 July 2017
Noon - Brain hacking - Jul 17FINAL_Blank Project NV.qxd 5/30/2017 6:26 AM Page 27

■ FIGURE 8.

■ FIGURE 10. sponge. Disposable electrodes usually last several months.


You can make a very conductive and durable
homemade wire glue by simply mixing a flexible variety
Method 2 such as Goop™ brand glue with graphite. The more
graphite you can mix into the glue, the better the
Recently, better commercial units have used smaller conduction (Figure 10).
(1.5” diameter) sponges in holders that make them easy to
clean and replace. Figures 7 and 8 show a simple design Important Note: Make absolutely sure to wash new
that will allow our unit to work the same way. sponges thoroughly before using them the first time. Many
Using a plastic cap from any jar, a stainless steel supermarket sponges have bleach-like preservatives in
fender washer, and some “wire glue,” an excellent them when shipped which can irritate skin! (Don’t ask me
sponge/electrode holder can be made. Make certain your how I know.)
plastic cap is at least 1.5” in diameter, and cut a
section of sponge 1/4” thick to fit very snugly into
the cap.
Strip the insulation from perhaps the last 2” of
one of your leads, and feed it into the plastic cap as
shown.
Coat one side of a stainless steel or brass washer
with wire glue, and press it into the cap until the
glue dries. This creates a conductive seat when dry
for our sponge to sit on; yet, sponges can be
popped in and out easily for cleaning or
replacement.
This arrangement would probably work without
the wire glue, and a brass washer could certainly
have the wire soldered directly in place. However,
given the fact that everything will be soaked in salt
water, the wire glue and stainless steel washer have
proven highly resistant to corrosion.
Figure 9 shows the completed sponge
electrodes, and the full unit.

Method 3
■ FIGURE 9.
As a quick alternative, you can make a
disposable electrode by just using the wire glue to
attach the wires and “any old” washer directly to the
July 2017 27
Noon - Brain hacking - Jul 17FINAL_Blank Project NV.qxd 5/30/2017 6:26 AM Page 28

■ FIGURE 12.

■ FIGURE 11.

The Phone App


Although you could use any battery powered USB (or
other) source to power your tDCS, why not use a battery
most of us have handy with us all the time: our
smartphones! I’ve written a quick free phone app that can
be used to time a session, display electrode placements in
3D, and even power a tDCS device directly from your and elsewhere for less than $5. I’ll make the phone app
phone. Getting power from your phone’s data port can be available for anyone who would like it on a special web
useful for many low power electronic projects as well. page for Nuts & Volts readers at noonco.com/tdcsnv.
The easiest method of getting power from your phone
is to use an On The Go (OTG) cable as in Figure 11. This Electrode Placements
is available for both iPhone and Android. By plugging an
OTG cable into your phone, you not only get USB and Montages
functionality, but can also power low current devices like There are some very spectacular in-depth manuals
our tDCS circuit (or anything else) directly. regarding electrode placement available on the Internet.
Keep in mind, not all phones are compatible with So, I’ll just cover the topic very briefly here. I’ll also make
OTG. However, you can download a free OTG checker links to these manuals available later in the article.
for your phone from any app store to make sure it’s In short, electrode positions are found using the
compatible. International 10/20 system. The numbers ‘10’ and ‘20’
If your phone is not OTG compatible, you can still simply refer to the fact that the distances between
power a tDCS circuit very easily from a “power bank” cell adjacent electrodes are either 10% or 20% of the total
phone recharger or any battery powered device with a front-back or right-left distance of the skull.
USB port. Power bank devices are available from Amazon Measurement is made from the nasion which is the
point between the forehead and nose, and
■ FIGURE 13. the inion which is the lowest point of the
skull from the back of the head.
Figure 12 shows the distribution of
possible positions from that basic
measurement.
So, if in your research, an electrode is
said to be placed at F3, this measurement
and chart will give you an excellent
placement reference.
Though I’m sure precision placement is
ideal, because electrode coverage areas are
large, most people I have spoken to have
simply used 3D models already set up to
show relative placement. Figure 13 shows
three typical placements. I feel these three
28 July 2017
Noon - Brain hacking - Jul 17FINAL_Blank Project NV.qxd 5/30/2017 6:26 AM Page 29

are among the best researched placements, but many I strongly recommend researching tDCS devices
more options are available with a quick Internet search. before experimenting if this topic has caught your
Typical times for sessions are between 20 and 30 interest. Many of the stories are wildly interesting and
minutes, and can be repeated in 48 hours. Electrodes can entertaining.
be held in place on the head very easily with a couple of Does it really affect your brain? Or, is this yet another
women’s hair bands. example of the latest fad in placebos?
I base my evaluation of “is it working” I certainly have an opinion, but I’ll leave it to you to
(voltage/electrode position, etc.) on a tiny flash of light form your own. NV
(called a phosphene) that is often witnessed just as the
device is disconnected. This is a flash of light that is seen
only in your mind.

Wrap Up
It’s always a pleasure for me to delve into “strange
science,” and I hope it has been for you as well! I tend to
be a very skeptical person by nature, but do feel after
experimenting with this device, it has been a fascinating
and worthwhile project and experience.
I’ve been interested in electric therapies since Dr.
Robert Becker’s book, The Body Electric caught my
attention just out of high school many years ago. The
topic of “electrotherapy” makes for many nights of good
reading.

July 2017 29
Lindley - ESP8266 World Clock - Jul 17_Blank Project NV.qxd 5/30/2017 6:28 AM Page 30

BUILD IT YOURSELF
By Craig A. Lindley

Build an ESP8266
WORLD CLOCK
What do most movie scenes of the stock market trading floor and most high-end
international hotels have in common? They both have world clocks that allow people
to see the time and date in remote locations of the world.

W
orld clocks are important to business as they Enabled, Arduino Compatible Microcontroller” in the
allow companies and/or individuals to have an October 2015 issue.
idea of the time of day and date where their 2. “Thinking of You” article in the November 2015 issue.
customers reside. There is nothing more embarrassing 3. “ESP8266 NTP Clock” article in the June 2016 issue.
than calling an international client in the middle of the 4. “ESP8266 Weather Clock” article in the November
night because you figured the time difference incorrectly. 2016 issue.
World clocks can even be important to families that have 5. “ESP8266 RSS News Reader” article in the January
members distributed across the US or the world so they 2017 issue.
know when would be a good time to make contact.
In order for world clocks to be useful, they must be The hardware used in articles 3, 4, and 5 is exactly the
accurate; they must show the time and date correctly for same, so there is just one hardware setup (be it a
each location; and they must take worldwide Daylight breadboard or a printed circuit board [PCB]). With
Saving Time into account. different software, you can have an NTP clock, an NTP
To assure the accuracy of this world clock design, I clock and weather station combination, or an RSS news
have opted to use the Network Time Protocol (or NTP) as reader.
the provider of time information. NTP can provide time Now, with this article, the exact same hardware can
accurate to within a second to devices over the Internet, function as a world clock as well.
which is good enough for our application here. The world clock design presented here has some
Basing a digital clock design on NTP requires access rather interesting attributes, including:
to the Internet which can be expensive to implement, but
allows for a very simple clock design for a couple of • It uses NTP, so it sets itself automatically whenever
reasons. it is powered up. There is no need for switches or buttons
First, no battery backup circuitry is required to for setting the time or date. In fact, there are no switches
maintain the time setting. If clock power is lost, the or buttons at all in this design.
connection to the Internet will automatically be re- • It uses a time zone library that automatically deals
established once power is restored, and the clock will with Daylight Saving Time (DST) worldwide, so there is no
automatically set itself to the correct time. need to reset the clock when the time changes or to click
Second, no controls for manually setting the time and a button to enter/exit DST.
date are typically necessary because the
time and date are set automatically. Hardware Parts List
The ESP8266 family of devices makes Part Source
inexpensive access to the Internet possible,
NodeMCU LUA Amica R2 Module Electrodragon.com
so it is a natural to use in digital and world
clock applications. Readers of Nuts & Volts Adafruit.com - Product ID: 358 or
1.8” TFT SPI LCD Display SainSmart.com 1.8 ST7735R TFT LCD
may remember my previous articles using Module with MicroSDSKU:20-011-920
these amazing devices: USB Cable - USB A to USB Micro B RadioShack or similar
USB Power Supply Capable of at
1. “Meet the ESP8266: A Tiny, Wi-Fi RadioShack or similar
least 1A @ 5V
30 July 2017
Lindley - ESP8266 World Clock - Jul 17_Blank Project NV.qxd 5/30/2017 6:28 AM Page 31

To post comments on this article and find any associated files and/or downloads,
go to www.nutsvolts.com/magazine/issue/2017/07.

• It currently has a round ■ FIGURE 1. ESP8266


robin display of time and date world clock wiring
for Sydney, Frankfurt, London, diagram/schematic.
New York, Houston, Denver,
Phoenix, and Los Angeles, and
you can change these for other
locations if you want to modify
the code provided.
• The clock can run in 12
or 24 hour formats.
• It runs a finite state
machine that will recover
automatically if network
connectivity is lost and then
regained, and it will recover
from power outages
automatically as well.
• The design consists of
two components only: a NodeMCU Amica ESP8266
module and a 1.8” LCD display. One cannot build many
circuits simpler than this.
• This world clock can be built for as little as $22.

As soon as you power-up this design, it accesses NTP


time wirelessly via the Internet, and then calculates and
displays the time and date in the cities mentioned above.
There is nothing to set or configure, and it will continue to
display the time and date until it is powered down. You
might call this a no fuss world clock because there is
nothing users have to do.
When DST arrives in one or more of the target
cities/time zones, it will automatically be taken into
consideration. It even knows how to deal with places like
Arizona which don’t use DST.
The world clock presented here is an adaption of the
world clock example program included with the Timezone
library which will be described later. My contribution is
the use of NTP as the source of the time data; the state
■ FIGURE 2. ESP8266 world clock breadboard.
machines that allow the clock to recover from Wi-Fi,
Internet, or power disruptions; and the formatting and
display of the time and date information on the LCD Table 1 as they might not be completely clear from the
display. Fritzing diagram.
Both the Adafruit and the SainSmart displays have a
Hardware micro SD memory card connector and interface which
can be used with the ESP8266 although they are not
The hardware Parts List shows the components required for this project.
required to build a world clock and where to get them. As
you can see, there isn’t much to it. Software
Figure 1 shows a Fritzing diagram for the world clock.
Figure 2 shows the design wired up and working on a The software for the ESP8266 world clock was
breadboard. As implied above, the clock is powered via a developed using the Arduino IDE (integrated development
USB cable and a USB power supply module, or environment). I used version 1.8.0 for MacOS, but you
alternatively, it can be plugged into a USB port on your should be able to use the Arduino IDE on Windows as
computer. The wire-by-wire connections are shown in well. Refer to my previous articles or the Resources
July 2017 31
Lindley - ESP8266 World Clock - Jul 17_Blank Project NV.qxd 5/30/2017 6:28 AM Page 32

Table 1. Resources
NodeMCU Amica Pin Adafruit 1.8” Display Connections Information about NTP can be found all over the
D4 D/C Internet. See www.ntp.org for detailed information.
D5 SCK
Information about time zones can be found at
D7 MOSI https://en.wikipedia.org/wiki/List_of_UTC_time_offsets.
D8 TFT_CS
Information about programming the ESP8266 in the
3V3 RESET
Arduino environment can be found at
3V3 LITE github.com/esp8266/Arduino and also in my articles
3V3 3V3 previously mentioned.
GND Gnd Information about the NodeMCU Amica can be found
at www.electrodragon.com/product/nodemcu-lua-
Table 2. amica-r2-esp8266-wifi-board.

File Description Information about the Adafruit 1.8” TFT SPI LCD display
can be found at www.adafruit.com/products/358.
Main program which initializes the
hardware for operation and runs a Information about the SainSmart display can be found
ESP8266WorldClock.ino finite state machine that insures at www.sainsmart.com/sainsmart-1-8-spi-lcd-module-
the Wi-Fi connection to the Internet with-microsd-led-backlight-for-arduino-mega-atmel-
is continually maintained. atmega.html.
Code for formatting and displaying
time and date information on the The ST7735 display driver library can be found at
LCD, and a finite state machine https://github.com/sumotoy/TFT_ST7735.
that controls the order that time
zones are displayed in; which time The Time library can be found at
zone is currently being displayed; https://github.com/PaulStoffregen/Time.
and how long each time zone is
DisplayFSM displayed. The Timezone library can be found at
https://github.com/JChristensen/Timezone.
Time Change Rules (described
shortly) for each time zone are also unzip the file and copy/move the ESP8266WorldClock
defined in this file, and the
conversion of NTP’s UTC time to directory into your computer’s Arduino directory. The
local time,zone time is perform zip file also contains the versions of the libraries I used
here as well. during program development.
Functions for sending UDP packets It is important to use these versions as newer or
NTP.h to NTP servers on the Internet and older versions may not function correctly. The library zip
retrieving the returned UTC time. files should be unzipped as well, and then moved into
TextGraphicsFunctions.h Misc. functions for formatting text your Arduino/Libraries directory for use. Remember the
data for display on the LCD. Arduino IDE — if running — must be restarted to
A subclass of the Timezone class recognize new libraries after you install them.
TimezoneExt.h that contains the Time Change Whereas the hardware for this world clock borders
Rules in addition to a name on the trivial, the software/firmware for the clock is a bit
assigned to the time zone.
more involved and complex. The files which make up
the program are described in Table 2. In addition
Table 3. to the files listed in Table 2, the Arduino libraries
Library Source shown in Table 3 are also required.
TFT_ST7735 https://github.com/sumotoy/TFT_ST7735
Time https://github.com/PaulStoffregen/Time
User Configuration
Timezone https://github.com/JChristensen/Timezone
of the World Clock
Software
sidebar for how to set up the Arduino IDE on your The world clock’s software must be configured before
computer for targeting ESP8266 type devices. Make sure the clock will operate correctly. All user configuration
to select “NodeMCU 1.0 (ESP-12E Module)” as the board items are found in the file ESP8266WorldClock.ino. Please
type in the Tools menu. locate the following text in that file:
The ESP8266 world clock software is available at the
article link; the file is called // ******************************************
Lindley_ESP8266WorldClock.zip. To use this software, // Begin user configurable items

32 July 2017
Lindley - ESP8266 World Clock - Jul 17_Blank Project NV.qxd 5/30/2017 6:28 AM Page 33

■ FIGURE 3. Initial Wi-Fi connection display. ■ FIGURE 4. Typical world clock time zone
display page.
// ****************************************** Fi network. If this screen doesn’t change to a time zone
// Set your WiFi login credentials display similar to Figure 4, it means there were problems
#define WIFI_SSID “XXXXXX” logging on to the Wi-Fi network. If this is the case, go
#define WIFI_PASS “YYYYYY” back and verify that the WIFI_SSID and WIFI_PASS entries
in the code are correct and that the Wi-Fi network is
#define USE_12_HOUR_FORMAT true working.
#define PAGE_DISPLAY_TIME_SECS 20 The Wi-Fi login display will be replaced by the first
#define PAGE_DISPLAY_TIME_MS time zone display page once a Wi-Fi connection is
(PAGE_DISPLAY_TIME_SECS * 1000) established. The clock should run as long as power is
applied and it will sync its time to an NTP time server
// ****************************************** every five minutes, making the clock very accurate. Each
// End user configurable items time zone page will be displayed for the configured time
// ****************************************** interval in a round robin fashion. By default, this means
the time and date will be displayed in the following order:
First and most importantly, you must modify the code Sydney, Frankfurt, London, New York, Houston, Denver,
with the SSID and password of your Wi-Fi network. Phoenix, and Los Angeles.
Otherwise, the clock won’t be able to access the Internet, The clock will continue to run as long as power is
and by extension, the NTP servers that provide the time. applied. If the Internet connection is dropped, the clock
Next, you must decide if your clock will operate in 12 or will maintain the time itself. If Wi-Fi goes down but the
24 hour format. Set USE_12_HOUR_FORMAT to true to clock remains powered, the clock will continually try to re-
run your clock in the 12 hour format or it will establish Internet connectivity and will re-sync with NTP as
automatically operate in the 24 hour time format. soon as possible. If power is lost to both the clock and the
Finally, you can configure how long each time zone Wi-Fi network, when power is restored, the clock will
page is displayed. By default, the time is 20 seconds, but reboot, wait for the network to come back up, and will
you can make this longer or shorter depending on your then reconnect automatically.
preference.
The code can be compiled and uploaded to the Time Zones, Time Zones,
NodeMCU device once the configuration data is set and
all of the required libraries have been installed in the Time Zones
Arduino environment. Wrapping my head around worldwide time zones was
the most difficult part of writing this code. Think about it.
World Clock Operation It’s a somewhat easy task to calculate offsets from the
time in your location to any time zone in the world, but
The clock should start immediately once the software what happens when the time zone you are interested in
is compiled and uploaded. Figure 3 shows the clock’s changes to or from DST (or whatever it may be called in a
display while a connection is being made to the local Wi- particular location). To compound the problem, there is
July 2017 33
Lindley - ESP8266 World Clock - Jul 17_Blank Project NV.qxd 5/30/2017 6:28 AM Page 34

no world standard that I am aware of that says the time TimeChangeRule usMDT = {“MDT”, Second, Sun, Mar,
changes from standard to DST and back have to occur on 2, -360};
the same date and time in all locations. TimeChangeRule usMST = {“MST”, First, Sun, Nov,
Luckily, the time zone library used in this application 2, -420};
(written by J. Christensen) has this kind of smarts built in. It TimezoneExt usMT(“Denver”, usMDT, usMST);
is our responsibility, however, to define Time Change Rules
for each time zone that explain to this library the rules for The first rule, usMDT, is for when DST starts in my
each location. location. It says the time change occurs the second
To define the appropriate Time Change Rules for each Sunday of March at 2 am, and that during DST we are
time zone requires gathering the following information: offset a negative 360 minutes or -6 hours from UTC time.
the day of the week the time change occurs; which week The second rule, usMST, is for standard time that starts the
of the month the change occurs in; at what hour the first Sunday of November again at 2 am. During standard
change occurs; and the offset in minutes of the time zone time, we are -7 hours from UTC time. Note: There is no
from Universal Coordinated Time (or UTC) when the mention of the day of the month that time changes as that
change occurs. is different every year.
Two rules are required for each time zone: one for the These two Time Change Rules are then combined into
change to DST and another for the change back to a TimezoneExt object called usMT that is given the name
standard time. Since I live in Colorado, I’ll use the Time “Denver” which will be displayed for the Mountain time
Change Rules for the Mountain time zone as an example. zone on the LCD. Using these rules, the UTC time
The following code fragment was extracted from the file returned from NTP is converted to local time for the time
DisplayFSM.h: zone, so that is what gets displayed on the world clock.
Arizona is unique in that they don’t use DST in their
// US Mountain Time Zone (Denver, Colorado state (they may have the right idea). Arizona is on
// Springs, Salt Lake City) standard Mountain time the whole year. To accommodate

34 July 2017
Lindley - ESP8266 World Clock - Jul 17_Blank Project NV.qxd 5/30/2017 6:28 AM Page 35

this, the TimezoneExt object specifies usMST for both of zones of your choice. The world clock code should
their Time Change Rules as shown below: automatically adapt to any changes you make to the
timeZones array. If you have a large distributed family, for
// Arizona is US Mountain Time Zone but does not example, you might want to have your world clock display
// use DST the time and date where each family member lives.
TimezoneExt usAZ(“Phoenix”, usMST, usMST); You’ll want to check the time and date for any time
zones you add. This can easily be done by Googling,
After all the Time Change Rules and the TimezoneExt “time in XXXX” where XXXX is the name of a city in the
objects are defined in the file DisplayFSM.h, the time zone you added.
TimezoneExt objects are placed into an array called
timeZones: Conclusion
// All of the timezones we want to display The world clock presented here is one of the simplest
// time for projects one could build, plus it can be done for around
TimezoneExt timeZones [] = { $22. Two components connected with six wires is all it
ausET, CE, UK, usET, usCT, usMT, usAZ, usPT takes.
}; Plug your world clock into your computer, update the
user configuration info, compile the code, and upload it to
The world clock code walks through this array your world clock. You should be good to go. Now you
sequentially, and displays the time and date information can feel like you are living in a high-end international hotel
calculated for each time zone. as you have access to times and dates all over the world.
Because you have access to the software, you could As always, have fun! NV
change the order of the time zones displayed, remove
time zones you are not interested in, or add new time

HIGH-PERFORMANCE
HIGH-PERFORMANCE
8-CHANNEL O
OSCILLOSCOPE
SCILLOSCOPE
The
The PicoScope
input
PicoScope 4824
4824 is a llow-cost,
input applications.
applications. With
ow-cost, po
portable
rtable solution
With 8 high-resolution
solution for
high-resolution analog
for multi-
analog channels
multi-
channels you
you
12-bit 20 MHz
resolution
can ea
easily
sily an
analyze
alyze aaudio,
udio, ultr
ultrasound,
asound, vib
vibration,
ration, po
power
wer and bandwidth
timin
timingg o
off co
complex
mplex ssystems.
ystems.

T
The
he PicoScope
PicoScope 4824
4824 hashas the
the power
power and functionality
functionality to
to d
deliver
eliver
accurate
accurate results.
results. It also
also ffeatures
ea
e tures d
deep
eep memory
memory to to analyze
analyze
multiple
multiple serial
serial buses
buses susuch
ch as
as UART,
UARRT, I2C, SPI,
SPI, CAN,
CAN, CAN
CAN FD
LIN
and LI Npplus
lus control
control and driver
driver signals.
signals.

Also
Also ffeatures:
ea
e tures:
• H igh-performance ar
High-performance bitrary w
arbitrary aveform ggenerator
waveform enerator
• A dvanced digital
Advanced digital tr iggers
triggers

8
• SSerial
erial b us decoding
bus decoding
• Su perSpeed USB
SuperSpeed USB 3.13.1 Gen interface
Gen 1 interface
• Windows,
Windows, Mac Mac and Linux
Linux software
software
256 MS
channels buffer memory

For
For m
more
ore inf
information
formation pplease
lease visit www
www.picotech.com/us108
.picotech.com/us108
Em
Email:
ail: sal
sales@picotech.com.
es@picotech.com. Er
Errors
rors and omissions
omissions excepted.
excepted. Please
Please contact
contact P
Pico
ico T
Technology
ec
e hnology for
for the
the latest
latest p
prices
rices be
before
fore o
ordering.
rdering.

July 2017 35
Hildreth - Working with I2C Device - Jul 17_Blank Rough NV.qxd 5/30/2017 6:31 AM Page 36

Working
with I C
2

Sensor
Devices
By Derek Hildreth
Technologic Systems

To post comments on this article and find


any associated files and/or downloads, go to
www.nutsvolts.com/magazine/issue/2017/07.

Let’s take a look at what is required to read sensor data from an I2C
interface (a.k.a., I2C, IIC, TwoWire, TWI). In particular, we’ll be reading
data from the NXP MPL3115A2 altimeter/barometer/temperature
sensor. The principles found here can also be applied generically, even
to your ambifacient lunar wane shaft positioning sensor of your
turboencabulator.

Why I2C friendly. Therefore, we’re going to be using a convenient


ready-made breakout board from SparkFun (part no. SEN-
I2C is a very popular go-to for sensors because of its 11084; www.sparkfun.com). The only assembly required
simplicity and expandability over other interfaces such as is to add some breakaway headers for ultimate
UART and SPI. SparkFun (a Colorado based company breadboard friendliness. If we were to go into production,
which markets to the maker crowd) has a nicely written we’d order the sensor direct from NXP and make our own
and friendly tutorial on I2C you should take a look at if printed circuit board (PCB) daughter boards for use with
you’re interested in more. For this article, it’s sufficient to our single board computer (SBC) or module.
say I2C has been winning the hearts of sensor
manufacturers, and has thus become very popular for Pro Tip: There are many outfits like SparkFun providing
complex smart sensors. breakout boards to choose from, such as Pololu, Adafruit,
Seeed Studio, and Trossen Robotics just to name a few.
Prototyping with the
MPL3115A2 Breakout Board Hookup to a Single Board
NXP’s MPL3115A2 sensor — with its tiny footprint —
Computer
isn’t what you would call prototyping or breadboard Now that we have the sensor, it’s obvious we need to
36 July 2017
Hildreth - Working with I2C Device - Jul 17_Blank Rough NV.qxd 5/30/2017 6:31 AM Page 37

connect it to something
with an I2C interface to
read the data. Most any
SBC or even
microcontroller could
do the job, but we’re
going to reach for our
handy Technologic
Systems’ TS-7970 high
performance industrial
SBC with Wi-Fi and
Bluetooth, since we
have an IoT-like end
goal in mind.
The MPL3115A2 breakout board requires no more
than 3.3 VDC and a connection to SDA (I2C Data) and
SCL (I2C Clock). There are two interrupt pins that can be (https://github.com/ControlEverything Community) that
used for things like events and triggers, but we’re not has working example code for Python, C, Java, and more.
going to use those in this article. All of this is brought out Take a look for yourself at the ControlEverything
on the header designated as HD3 on our TS-7970 (see Community/MPL3115A2 github repository.
section HD3 of the TS-7970 manual available at
https://wiki.embeddedarm.com/wiki/TS-7970). Pro Tip: If you are interested in using Python, you’ll
When we’re all hooked up and powered on, the I2C need to install python-smbus first
interface is brought out to the Linux device file /dev/i2c-1 (https://pypi.python.org).
(see section TWI of the TS-7970 manual). This number
might change depending on your system, so be sure to Once we have a basic understanding of how to
run i2cdetect -l to get a list of I2C interfaces on your board. program for I2C from looking at examples and
documentation, we need to dive into the specifics of our
Note: We’re making a couple assumptions at this sensor using the MPL3115A2 datasheet.
point. One is that you already know how to boot and Luckily, NXP also provided a really nice application
connect to your board. If you’re following along with a TS- note — Data Manipulation and Basic Settings of the
7970, you may want to take a look at the Getting Started MPL3115A2 Command Line Interface Driver Code — which
Guide (available at the same link as the manual). Another helps further our understanding of how to interface with
assumption we’re making is that you’re running Linux and this sensor. In section 11 (Quick Start Setup), you’ll find a
have i2c-tools installed. flowchart showing necessary steps to read altimeter data.

Programming the I2C Client Pro Tip: Since we don’t plan on using the events to
trigger an interrupt pin, you should be able to skip the
Official documentation for programming an I2C client step of enabling data flags in PT_DATA_CFG.
in C can be found in the Linux Kernel in /i2c/dev-interface.
(You can find documentation
mentioned in this article at
www.embeddedarm.com.)
We don’t have to be stuck
using C though. You can reach for
C++, Python, Java, or others. For
this article, we’re going to work
with C for learning purposes, and
because we know C is uber fast
where hardware is involved.

Pro Tip: When researching how


to interface with the MPL3115A2, I
stumbled upon a fantastically
convenient repository in the
ControlEverything community

July 2017 37
Hildreth - Working with I2C Device - Jul 17_Blank Rough NV.qxd 5/30/2017 7:18 AM Page 38

This is what our prototype


connections will look like.

Sanity Check Using i2c- 00:


0 1 2 3 4 5 6 7 8 9 a b c d e f
-- -- -- -- -- -- -- -- -- -- -- -- --
tools 10:
20:
--
--
--
--
--
--
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Before we dive into C code, let’s test our connections 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
and do some basic sanity checking using the tools 50: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
included in i2c-tools, like i2cset, i2cget, and i2cdetect. 70: -- -- -- -- -- -- -- --
First, let’s use i2cdetect to both verify which device
file and I2C slave address. By running i2cdetect -l, we see a
list of I2C busses like so: This tells us there is an I2C slave device detected at
the 0x60 address. We’re on our way! Let’s try reading the
root@ts-imx6:~# i2cdetect -l register WHO_AM_I, which is defined as 0x0C. According
i2c-0 i2c 21a0000.i2c I2C adapter
i2c-1 i2c 21a4000.i2c I2C adapter to the datasheet, the value 0xC4 should be returned. Let’s
root@ts-imx6:~# see using i2cget -y 1 0x60 0x0C:

On our TS-7970, we know that /dev/i2c-0 is used root@ts-imx6:~# i2cget -y 1 0x60 0x0C
0xc4
internally to connect the FPGA (field-programmable gate
array) with the RTC (real time clock) as mentioned in the
manual, so that leaves us with /dev/i2c-1. We can then use Perfect! For now, let’s conclude our little sanity check.
that information to detect chips connected to /dev/i2c-1 If you’re looking for some homework, you could manually
by running i2cdetect -y 1, like so: step through the flowchart using i2c-tools to see what the
raw data looks like.
root@ts-imx6:~# i2cdetect -y 1 We’re going to move onto the C program.
38 July 2017
Hildreth - Working with I2C Device - Jul 17_Blank Rough NV.qxd 5/30/2017 6:31 AM Page 39

The C Program
We’re going to make things easy on ourselves and use
the ControlEverythingCommunity/MPL3115A2 example
code as our base. This uses the same principles as taught
in the official Linux I2C documentation and is well
commented. Let’s take a look:
#include <stdio.h>
#include <stdlib.h>
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>
#include <fcntl.h>

void main()
{
// Create I2C bus
int file;
char *bus = "/dev/i2c-1";
if((file = open(bus, O_RDWR)) < 0)
{
printf("Failed to open the
bus. \n");
exit(1);
}
// Get I2C device, TSL2561 I2C address
// is 0x60(96)
ioctl(file, I2C_SLAVE, 0x60);

// Select control register(0x26)


// Active mode, OSR = 128, altimeter
// mode(0xB9)
char config[2] = {0};
config[0] = 0x26;
config[1] = 0xB9;
write(file, config, 2);
// Select data configuration
// register(0x13)
// Data ready event enabled for
// altitude, pressure,
// temperature(0x07)
config[0] = 0x13;
config[1] = 0x07;
write(file, config, 2);
// Select control register(0x26)
// Active mode, OSR = 128, altimeter
// mode(0xB9)
config[0] = 0x26;
config[1] = 0xB9;
write(file, config, 2);
sleep(1);

// Read 6 bytes of data from address


// 0x00(00)
// status, tHeight msb1, tHeight msb,
// tHeight lsb, temp msb, temp lsb
char reg[1] = {0x00};
write(file, reg, 1);
char data[6] = {0};
if(read(file, data, 6) != 6)
{ float altitude = tHeight / 16.0;
printf("Error : Input/Output float cTemp = (temp / 16.0);
error \n"); float fTemp = cTemp * 1.8 + 32;
exit(1);
} // Select control register(0x26)
// Active mode, OSR = 128, barometer
// Convert the data // mode(0x39)
int tHeight = ((data[1] * 65536) + config[0] = 0x26;
(data[2] * 256 + (data[3] & 0xF0)) / config[1] = 0x39;
16); write(file, config, 2);
int temp = ((data[4] * 256) + (data[5] sleep(1);
& 0xF0)) / 16;
July 2017 39
Hildreth - Working with I2C Device - Jul 17_Blank Rough NV.qxd 5/30/2017 6:31 AM Page 40

// Read 4 bytes of data from


// register(0x00)
we were able to successfully interact with an I2C sensor.
// status, pres msb1, pres msb, pres Now, you should have the skills and know-how to apply to
// lsb your specific I2C sensor project.
reg[0] = 0x00;
write(file, reg, 1);
read(file, data, 4); Take It a Step Further
// Convert the data to 20-bits
int pres = ((data[1] * 65536) + We alluded to the subject of Internet of Things (IoT)
(data[2] * 256 + (data[3] & 0xF0))) / earlier, so let’s expand on that. As mentioned, our TS-7970
16;
float pressure = (pres / 4.0) / has Wi-Fi capabilities, and it also has the ability to run a
1000.0; full-fledged web server. Meaning, we could take this a step
further and periodically record our sensor data to a
// Output data to screen
printf("Pressure : %.2f kPa \n", database and then display the data on a web page, both
pressure); in real time and historical charts.
printf("Altitude : %.2f m \n",
altitude); You could also install node.js and develop a nice REST
printf("Temperature in Celsius : %.2f API, making it easy for others around the world to pull
C \n", cTemp); data from. The obvious use for this particular sensor is
printf("Temperature in Fahrenheit :
%.2f F \n", fTemp); making a mini-weather station, but I’m sure you can come
} up with a more clever use.
Once you have this copy/pasted or downloaded to
your board, you’re ready to compile and run it. Compiling Conclusion
is simply done using the command gcc mpl3115a2.c -o
mpl3115a2. Running ./mpl3115a2 will produce the In reading this article, you should’ve come away with
altitude, pressure, and temperature: a bunch of information on how to interface with an I2C
sensor device. We started by looking at why I2C is a
root@ts-imx6:~/projects/altimeter-sensor$ gcc popular choice and pointed you towards a beginner-
mpl3115a2.c -o mpl3115a2
root@ts-imx6:~/projects/altimeter-sensor$ ./mpl3115a2 friendly I2C tutorial. Then, we looked at what it takes to
Pressure : 85.36 kPa begin prototyping with a real sensor — from buying a
Altitude : 20623.69 m
Temperature in Celsius : 23.56 C breakout board to referencing documentation for register
Temperature in Fahrenheit : 74.41 F addresses and doing sanity checks.
Finally, we sank our teeth into some C code and came
Sweet success! You could do like I did and out with altitude, pressure, and temperature data.
immediately go check the pressure accuracy against your You should now feel comfortable in applying these
favorite weather website and the altitude against a GPS or development principles to your own sensor for your
terrain map. However, the point of celebration here is that project. Now, go build something amazing! NV

40 July 2017
The new starting point for robotics

Find out more at www.pololu.com/romi

Full Page.indd 41 9/6/2016 6:13:47 AM


By Fabio Pereira

Building
My love affair with microcontrollers and
microprocessors began back in 1988 when I was
working toward a technical degree at CEFET-PR

Your Own
(a four year Brazilian secondary/technical school
and university located in Curitiba). I began by
learning the basics while exploring the classic

Microcontroller
Zilog Z-80 (Figure 1a).

F
ast forward through a career of programming that
included authoring some books on microcontroller
programming (see Resources), starting a small
design house (ScTec), and finishing a post-
graduation program at CEFET-SC (another Brazilian
university located in Florianopolis). This was in 2008, when
I had more contact with programmable logic and VHDL
and my curiosity was peaked. Years later in 2016, I found a FIGURE 1A.The Zilog Z-80A (courtesy of Wikimedia Commons).
very affordable FPGA (Field-Programmable Gate Array) kit
and decided to give it a chance, and started learning more
about FPGA technology.
What would be better than designing a softcore to
learn more about VHDL (VHSIC hardware description
language), FPGAs, and microprocessor cores themselves?
I ended up choosing a modern Z-80 relative: the Zilog
Z8 Encore! (a.k.a., eZ8; Figure 1b). It’s an eight-bit
microcontroller core with a simple -- yet powerful --
instruction set and a very nice on-chip debugger. With its
lightweight IDE (integrated development environment) and
free ANSI C compiler, it is an excellent project to learn
(and also teach) about embedded systems.
Before diving into the depths of the core operation,
VHDL, and FPGAs, let’s take a glance on the Zilog Z8 FIGURE 1B. Zilog eZ8.
Encore! features.

Zilog Z8 Encore!
The eZ8 is an eight-bit microcontroller family based on
Zilog’s successful Z8 family and on the great Z-80 heritage.
It features a Harvard CISC machine with up to 4,096 bytes
of RAM (file register and special function registers area), up
to 64 KB of program memory (usually Flash memory), and
up to 64 KB of data memory (RAM). The eZ8 core also
includes a vectored interrupt controller with programmable
priority and an on-chip debugger which communicates
with the host computer using asynchronous serial
communication. These microcontrollers are packed with a
very nice peripheral set, ranging from versatile 16-bit timers
to motor control timers, from multiple UARTs (IrDA ready) FIGURE 1C. FPz8 on an FPGA.
42 July 2017

Pereira - Ez8 - Jul 17.indd 42 5/30/2017 5:21:01 AM


Post comments on this article and find
This article is focused on learning how a any associated files and/or downloads at
www.nutsvolts.com/magazine/
microcontroller core is designed, and is intended issue/2017/07.

for educational use only. Please visit www.zilog.


com and check the manufacturer product line to
select a microcontroller that fits your project needs
Some devices also include a second
(from eight-bit Z8 Encores! and eZ80 Acclaims to data space (up to 65,536 addresses) which
can only be accessed by using LDE/LDEI
the 32-bit ARM Cortex-M3 based ZNEO32! which instructions. This area can be used to store
includes advanced motor control capabilities). less used data (as reading/writing to it is
slower than the RAM/SFR area).

to USB devices, and much more (visit www.zilog.com to


check the full product line). FPz8
One major feature of the eZ8 programming model is The first implementation of FPz8 uses a very
the lack of a fixed accumulator. Instead, any of the 4,096 conservative and hardwired design approach with two
possible RAM addresses can work as accumulators. The main buses: one for program memory, and another for
CPU treats its main RAM (the file and SFRs — special register memory. As I chose not to include a data memory
function registers — area) as a big set of CPU registers. In area, the LDE/LDEI instructions are not implemented.
order to accomplish that, RAM is split into register groups The program memory buses comprise a 16-bit
(there are 256 groups of 16 working registers each). An instruction address bus (IAB), an eight-bit instruction data
instruction usually works within a single working register bus (IDB for reading data from program memory), an eight-
group, which is selected by an SFR named RP (register bit instruction write data bus (IWDB for writing data to
pointer). Note that all SFRs are located at the last page of program memory), and a PGM_WR signal which controls
RAM (addresses starting from 0xF00 up to 0xFFF). writing to program memory. FPz8 includes 16,384 bytes of
Regarding the instruction set, there are 83 different program memory implemented using synchronous block
instructions split into two opcode pages. It comprises RAM (which means program memory content is lost when
usual instructions for basic operations such as addition, the device is powered down).
subtraction, logical operations, data manipulation The five register area buses comprise three for the file
instructions, shifting instructions, change-of-flow register area (user RAM), and another two dedicated to
instructions, some 16-bit instructions, bit testing and special function registers. There is a main 12-bit file register
manipulation, 8x8 multiply, etc. address bus (FRAB), an eight-bit file register input data bus
The program memory area is organized so that the first (FRIDB), an eight-bit file register output data bus (FRODB),
addresses are dedicated to special purposes. Addresses an eight-bit register input data bus (RIDB), and finally an
0x0000 and 0x0001 are dedicated to the configuration eight-bit register output data bus (RODB) for writing into
options; addresses 0x0002 and 0x0003 store the reset SFRs. The FPz8 includes 2,048 bytes of user RAM memory
vector; and so on. Table 1 shows program memory implemented using synchronous block RAM.
organization. Figure 2 shows a block diagram of the FPz8; you can
see the CPU, two memory units (one for program storage
0x0000 Option bytes and the other for data storage), and also an external timer
module.
0x0002 Reset vector Note that I am not using bidirectional buses for any
interconnects in this project. Unidirectional buses are
0x0004 WDT vector simpler to use, although they are less space efficient.
The VHDL description of the FPz8 is large and a bit
0x0006 Illegal instruction vector complex, so I am going to split its operation into some
modules to ease comprehension:
0x0008 to 0x0037 Interrupt vectors
1. Instruction queueing engine
0x0038 to 0xFFFF User program memory area 2. Instruction decoding
3. Interrupt processing
4. Debugger
Table 1. Simplified program memory organization.
July 2017 43

Pereira - Ez8 - Jul 17.indd 43 5/30/2017 5:21:01 AM


FIGURE 2. FPz8 block diagram.

Instruction Queueing Engine else


if (IQUEUE.FULL=’0’) then
Fetching instructions is a primary task for any CPU. The IQUEUE.QUEUE(IQUEUE.WRPOS) := IDB;
FPz8’s Harvard architecture enables concurrent fetching FETCH_ADDR := FETCH_ADDR + 1;
and data access (due to separate buses for instruction and IAB <= FETCH_ADDR;
data). That means the CPU can fetch a new instruction IQUEUE.WRPOS := IQUEUE.WRPOS + 1;
while another is reading or writing into data memory. IQUEUE.CNT := IQUEUE.CNT + 1;
The eZ8 has a variable length instruction word end if;
(instruction length varies from one byte up to five bytes); end if;
some instructions are lengthy but run faster than others. end if;
That way, a BRK instruction has a length of one byte and if (IQUEUE.CNT=7) then IQUEUE.FULL:=’1’; else
runs in two cycles, while an LDX IM,ER1 is four bytes long IQUEUE.FULL:=’0’;
and runs in two clock cycles. end if;
So, how can we successfully decode all these Listing 1. Instruction queue engine.
instructions? With an instruction queue; that is, a
mechanism that keeps fetching bytes from program
Fetching is controlled by a main enable signal
memory and storing them into an eight-byte array:
(CAN_FETCH) which can be disabled in some special
cases (interrupt processing, by LDC/LDCI instructions or
if (CAN_FETCH=’1’) then debugger access). There is also a structure (IQUEUE) which
if (IQUEUE.FETCH_STATE=F_ADDR) then stores several internal parameters (fetching state, read
FETCH_ADDR := PC; and write pointers, queue array itself, a counter, and a full
IAB <= PC; indicator).
IQUEUE.WRPOS := 0; The queue counter (CNT) is used to identify the
IQUEUE.RDPOS := 0; number of bytes available for use (reading) in the queue.
IQUEUE.CNT := 0; The decoder stage uses this number to verify that the
desired number of bytes for the instruction is already
IQUEUE.FETCH_STATE := F_READ; available in the queue.
44 July 2017

Pereira - Ez8 - Jul 17.indd 44 5/30/2017 5:21:01 AM


Instruction Decoding
This is where the actual magic
happens. The instruction decoder
reads opcodes from the instruction
queue and translates them into
corresponding operations.
Instruction decoder design
started by figuring out the relation
among all the instructions and
addressing modes. At first sight, it is
easy to see that some instructions
(Figure 3) are grouped by column
(DJNZ, JR cc,X, LD r1,IM, JP
cc,DA, and INC r1). Decoding an
INC r1 instruction is simple: On
these single-byte instructions, the
high nibble specifies the source/
destination register and the lower
nibble specifies the instruction itself
(0xE).
Most instructions can be
classified according to some basic
rules:

1. Columns (the lower nibble


of an opcode) usually specify an
addressing mode: Column 0x9
instructions, for instance, mostly
use the IM,ER1 addressing mode
and are four bytes long (the second
byte is the immediate operand and FIGURE 3. Opcodes by groups.
the two last bytes are
the destination extended
address).
2. Rows (the
higher nibble of an
opcode) usually specify
an operation: Row 0x0
instructions are mostly
addition operations; row
0x2 instructions are mostly
subtraction operations, and
so on.

If we look at row 0x1,


we can see that columns
0x0 and 0x1 are RLC
instructions, and columns
0x2 up to 0x9 are ADC
instructions. So, we can
design an ALU which
takes a nibble as input
(the higher nibble from
the opcode) and decodes FIGURE 4. CPU_DECOD state.
July 2017 45

Pereira - Ez8 - Jul 17.indd 45 5/30/2017 5:21:02 AM


DEC, DA, COM, RL, CLR, RRC, SRA,
SRL, RR, and SWAP).
Now, let’s take a look inside
the CPU_DECOD state. Refer to
Figure 4.
Within the CPU_DECOD state,
we can see that a lot of action
takes place. In the beginning, some
temporary variables are initialized
to a default condition. Note that
NUM_BYTES is very important
as it controls how many bytes
were consumed by the instruction
decoder. Its value is used in the last
part of this stage to increment the
PC (program counter), advance the
queue read pointer, and decrement
the number of available bytes in the
queue.
Following the initialization
section, we can see the interrupt
processing section. It is responsible
for detecting any pending interrupts
and prepares the CPU accordingly.
FIGURE 5. FPz8 interrupt system. I’ll cover this in the next section.
The actual instruction decoding block checks whether
it accordingly. While this would work for columns 0x2 to a low power mode is not active and also if the debugger
0x9, we would need another approach for the first two mode is off (OCDCR.DBGMODE=0). Or, while in debug
columns. mode, a single step debug command was issued (OCDCR.
That is why I ended up writing two units: one ALU DBGMODE=1 and OCD.SINGLE_STEP=1). It then checks
which concentrates on most arithmetic and logical the available bytes in the queue and proceeds with
instructions; and a second unit (Logical Unit 2, or LU2) decoding.
which performs other operations shown in columns 0x0 Some instructions (mostly the singlebyte ones) are
and 0x1 (not all operations seen on those columns are completed within the CPU_DECOD state, while others
performed by LU2). The operation codes for both ALU and need multiple states until they are fully completed.
LU2 were chosen to match opcode rows shown in Figure Note that some instruction decoding can make use of
3. several functions and procedures written specially for the
Another important detail is that all instructions within FPz8:
the same column and group are the same size in bytes,
thus can be decoded in the same decoder section. yy DATAWRITE — This procedure prepares buses for a
The decoder design makes use of a large finite state writing operation. It selects whether the destination is an
machine (FSM) which advances on each clock tick. Every internal SFR, an external SFR, or a user RAM location.
instruction starts in the CPU_DECOD stat. This is where yy DATAREAD — This is a reciprocal function for
the decoder actually decodes the opcodes, prepares DATAWRITE. It is used to read a source address and
buses and internal supporting signals, and steps to other automatically chooses whether it is an internal SFR, an
execution states. Among all those states, two are widely external SFR, or a user RAM location.
used by a lot of instructions: CPU_OMA and CPU_OMA2. yy CONDITIONCODE — Used for conditional
Can you guess why? If you said because they are related to instructions (such as JR and JP). It takes a four-bit condition
ALU and LU2, you are absolutely right! code, tests it, and returns the result.
OMA is short for One Memory Access and it is the last yy ADDRESSER4, ADDRESSER8, and ADDRESSER12 —
state for all ALU related instructions (ADD, ADC, ADDX, These functions return a 12-bit address from a four-, eight-,
ADCX, SUB, SBC, SUBX, SBCX, OR, ORX, AND, ANDX, or 12-bit source. They use the content of the RP register
XOR, XORX, CP, CPC, TCM, TCMX, TM, TMX, and some to generate the final 12-bit address. ADDRESSER8 and
variants of LD and LDX). On the other hand, CPU_OMA2 ADDRESSER12 also check for any escaped addressing
is the last state for all LU2 related instructions (RLC, INC, mode.
46 July 2017

Pereira - Ez8 - Jul 17.indd 46 5/30/2017 5:21:02 AM


yy ADDER16 — This is a
16-bit adder for address offset
calculation. It takes an eight-bit
signed operand, sign extends it,
adds it to the 16-bit address, and
returns the result.
yy ALU and LU2 — These were
discussed previously, and perform FIGURE 6. On-chip debugger UART (note the DBG_RX synchronizer).
most arithmetic and logic operations.
available on the real hardware, except for those related
to data memory (debug commands 0x0C and 0x0D); the
Interrupt Processing read runtime counter (0x3); and the read program memory
As I said before, eZ8 has a vectored interrupt CRC (0x0E).
controller with programmable priority. At first, I thought One thing I would like to highlight is care is needed
this section would not be so difficult because interrupts when dealing with asynchronous signals inside FPGAs. My
are no big deal, right? Well, when I started to figure out first design didn’t account for that while processing the
how to do all the needed tasks (saving context, vectoring, DBG_RX input signal. The result was absolutely weird. My
managing priorities, etc.), I realized it would be tougher design had worked flawlessly in simulation. I downloaded
than I first thought. After a couple hours, I came up with it to an FPGA and started playing around with the debug
the current design. serial interface by using a serial terminal (my FPGA board
FPz8’s interrupt system ended up being simple. It has has a built-in serial-USB converter).
eight inputs (INT0 to INT7); a global interrupt enable (IRQE To my surprise, while most of the time I could
bit located in IRQCTL register); two registers for priority successfully send commands and receive the expected
setting (IRQ0ENH and IRQ0ENL); and one register for results, sometimes the design would simply freeze and
interrupt flags (IRQ0). The design makes use of a nested IF stop responding. A soft reset would make things go back
chain which generates a vector address upon detection of to their proper operation, but that was intriguing me. What
an interrupt event regarding an enabled interrupt. was happening?
Figure 5 shows a compressed view of the interrupt After a lot of tests and some Googling, I figured out
system. Note there is a first IF statement with a symbol that it was possibly related to the asynchronous edges of
ATM_COUNTER. This is a simple counter used by the ATM the serial input signal. I then included a cascaded latch
instruction (it disables interrupts for three instruction cycles, to synchronize the signal to my internal clock and all the
allowing atomic operations). problems were gone! That is a tough way to learn that you
One last comment regarding interrupts: The interrupt must always synchronize external signals prior to feeding
flag register (IRQ0) samples interrupt inputs every rising them into complex logic!
edge of the system clock. There are also two buffer I must say that debugging and refining the debugger
variables (IRQ0_LATCH and OLD_IRQ0) which store the code was the hardest part of this project; mostly because it
current and last state of the flags. This allows interrupt edge interacts with all the other subsystems including buses, the
detection and also synchronizes the external inputs to the decoder, and instruction queue.
internal clock (FPGAs don’t work well with asynchronous
internal signals).
Synthesizing and Testing
Once fully compiled (I used Quartus II v9.1 sp2), the
On-Chip Debugger FPz8 core used up 4,900 logic elements, 523 registers,
This is probably the coolest feature of this softcore as it 147,456 bits of on-chip memory, and one embedded nine-
allows a commercial integrated development environment bit multiplier. Overall, the FPz8 uses 80% of the EP4CE6’s
(IDE; such as Zilog’s ZDS-II) to communicate, program, available resources. While this is a lot, there are still some
and debug software running on the FPz8. The on-chip 1,200 logic elements available for peripherals (my simple
debugger (OCD) is comprised of a UART with autobaud 16-bit timer adds up to around 120 logic elements and 61
capability and a command processor attached to it. The registers). It even fits on the smallest Cyclone IV FPGA —
UART performs serial communication with a host PC, the EP4CE6 — which is the one mounted on the low cost
and delivers commands and data to the debugger state mini board I used here (Figure 7).
machine which processes debug commands (the debugger The mini board features (along with the EP4CE6
command processing FSM is located inside the CPU_ device): an EPCS4 serial configuration memory (mounted
DECOD state). on the bottom side); an FTDI serial-to-USB converter
My OCD design implements almost all commands chip as well as a 50 MHz crystal oscillator module; some
July 2017 47

Pereira - Ez8 - Jul 17.indd 47 5/30/2017 5:21:02 AM


FIGURE 7. Altera Cyclone IV EP4CE6 mini board.

buttons; LEDs; and pin headers to access FPGA pins. There


is no integrated USB-Blaster (for FPGA programming),
but the package I bought also included an external FIGURE 8. Debugger settings.
programming dongle.
As for the real world tests, needless to say, the FPz8 are the same as in Figure 8. Uncheck the “Use page erase
didn’t work the first time! After thinking a bit and reading before flashing” option, and select “SerialSmartCable”
compiler output messages, I figured out that it was as the current debug tool. Don’t forget to also check if
probably a timing issue. This is a very common dilemma the FTDI’s virtual COM port is correctly selected as the
when designing with programmable logic, but as this debug port (use the Setup button). You can set the desired
was my second FPGA design ever, I didn’t pay enough communication speed as well; 115,200 bps works very
attention to it. well for me.
Checking the timing analysis messages, I could see Note that when connecting to the FPz8, the ZDS-II
a warning that the maximum clock should be around 24 IDE will show a warning message informing you that the
MHz. At first, I tried using a divider-by-2 to generate a target device is not the same as the project. That happens
25 MHz CPU clock, but it wasn’t reliable. I then used a because I didn’t implement some ID memory areas. Just
divider-by-3. Everything started to work perfectly! ignore the warning and proceed with the debugging
That’s why FPz8 currently runs at 16.666 MHz. It is session.
possible to achieve higher speeds by using one of the Once the code is successfully downloaded, you can
internal PLLs to multiply/divide the main clock in order to start the application (GO button), step instructions, inspect
get a resulting clock lower than 24 MHz, but higher than or edit registers, set breakpoints, etc. As with any other
16.666 MHz. good debugger, you can, for example, select the PAOUT
register (under PORTS group) and even change the state of
the LEDs connected to PAOUT.
Programming and Debugging Some simple C code examples can be found at the
Using the FPz8 is very simple and straightforward. article link.
Once the design is downloaded to the FPGA, the CPU Just keep in mind that the FPz8 has a volatile program
will start running any program loaded in memory. You can memory. Thus, any program downloaded to it is lost when
supply a hex file and use the MegaWizard Plug-in Manager the FPGA is powered down.
to change the program memory initialization file. That way,
your application code will start running following a reset
signal. Closing
You can use the Zilog ZDS-II IDE to write Assembly This project took me a couple weeks to complete, but
or C code, and generate the necessary hex files (I usually it was delightful to research and design a microcontroller
select the Z8F1622 as my target device as it also has 2 core.
KB of RAM and 16 KB of program memory). Thanks to I hope this project can be useful for anyone wanting to
the on-chip debugger, it is also possible to use the ZDS-II learn about computing basics, microcontrollers, embedded
IDE to download code to the FPz8 using a serial debug programming, and/or VHDL. I believe that — if paired with
connection (USB, in our case). a low cost FPGA board — the FPz8 can provide a fantastic
Before connecting, make sure that debugger settings learning (and teaching) tool. Have fun! NV
48 July 2017

Pereira - Ez8 - Jul 17.indd 48 5/30/2017 5:21:03 AM


CEFET-PR: www.utfpr.edu.br
References CEFET-SC: www.ifsc.edu.br/index.php
ScTec: www.sctec.com.br
HCS08 Unleashed: https://www.amazon.com/HCS08-Unleashed-Designers-Guide-
Microcontrollers/dp/1419685929
Zilog eZ8 CPU Manual (UM0128): www.zilog.com/docs/UM0128.pdf
Zilog Z8F64xx Product Specification (PS0199): www.zilog.com/docs/z8encore/PS0199.pdf
Zilog ZDS II IDE User Manual (UM0130): www.zilog.com/docs/devtools/UM0130.pdf
Zilog ZDS-II Software Download: http://store.zilog.com/index.php?option=com_
ixxocart&Itemid=1&p=product&id=94&parent=5
Zilog Microcontroller Product Line: http://zilog.com/index.php?option=com_
product&task=product&businessLine=1&id=2&parent_id=2&Itemid=56
Project Files available at https://github.com/fabiopjve/VHDL/tree/master/FPz8
FPz8 at Opencores.org: http://opencores.org/project,fpz8 䤀渀焀甀椀爀攀 昀漀爀
䌀甀猀琀漀洀椀稀愀琀椀漀渀℀

A L L
E L E C T RON I C S
www.allelectronics.com Order Toll Free 1-800-826-5432
PROJECT BOX, 3M SAFETY GLASSES WITH
4" X 3" X 1.6" LED LIGHTS
Black ABS plastic Adjustable, ultra-
project enclosure. bright LED lights
Interlocking lid secured integrated into stylish
with self-tapping screws. safety glasses providing
Interior slots for pc boards. illumination right where you need it.
$ 00
Includes hardware.
3
each
CAT# SG-11 $
10 for $2.75 ea. 11 95 6 for
CAT# MB-173 each $11.50 ea.

12 VDC GEAR MOTOR


Great little motor for
100 AMP BRASS BUSS BAR
motion / robotics Bocatech® Inc BTMH-15B
projects. 520 RPM @ 100 Amp, 48 Vdc / 300 Vac
12 Vdc, 250 mA (no load rating). · 2 feed terminals
1” diameter x 2.25” long. 6mm flatted shaft. 1/4-20 brass studs
· 10 distribution terminals 8-32 brass screws
· Solid brass on insulated base $ 95
CAT# DCM-475
· 5-3/4" x 1-1/4" x 1-1/16" 6
25 for $5.00 each
$ 95
5 each
100 for $4.50 each
CAT# BR-100
each
10 for $6.50 ea.
SPECIAL - 12 VDC 2 AMP
POWER SUPPLY 5VDC 5 AMP 25W
5' cord with 2.1mm coax plug. POWER SUPPLY
cULus. Was $11.75 each. Mean Well# S-25-5.
3.90" x 3.85" x 1.43"
vented metal cabinet. Voltage
CAT# PS-1227 $ 95
6
adjustable 4.75 - 6.75V. LED indicator.
100 for $6.40 ea. each

Short-circuit, over-voltage, over-load protec-


HOOK-UP WIRE, tion. UL, CE. 10 for
$ 00
8-PIECE BUNDLE CAT# PS-255 7 $6.50 ea.
Great for projects.
each

Bundle of 8 three
foot lengths of 2 for $ 100 2-CONDUCTOR LOCKING
assorted colors. CONNECTORS W/ LEADS
100 for 40¢ each Pins on 2.5mm
centers. Black
CAT# HW-24

nylon housing. Female side can be snap-


35MM PIEZO ELEMENT mounted into a chassis. 12" color-coded
2" pigtail leads. leads, 22 AWG stranded wire. $ 35
CAT# PE-63 CAT# CON-240 1 each
眀眀眀⸀椀爀爀漀戀漀琀甀猀愀⸀挀漀洀
10 for $1.20 each • 100 for 95¢ each
䌀愀氀氀 愀琀 㠀㠀㠀ⴀ㌀  ⴀ㠀㤀㘀㘀
2 for $ 100 100 for 40¢ each

July 2017 49

Pereira - Ez8 - Jul 17.indd 49 5/30/2017 5:21:06 AM


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

The Solar Eclipse and Ham Radio


Tune in to a very unusual on-the-air experience.

The Eclipse and Radio


“Look out here she comes, she’s comin’, The optical effects of an eclipse are relatively obvious
Look out there she goes, she’s gone, and well-understood. Partial solar eclipses are fairly
common and lunar eclipses even more common. Not
Screamin’ straight through Texas many of us have witnessed totality, but most people have
Like a mad dog cyclone.” seen some type of eclipse. What very few people have
“Texas — 1947,” Guy Clark

Here It Comes
Guy Clark’s classic song about an
express train could be about the upcoming
solar eclipse — just change the third line to
“Screamin’ through America” and the title to
“August — 2017!” I hope you have Monday,
August 21st circled on your calendars in
bright red ink. A total solar eclipse will be
seen on that day by millions of people from
Portland, OR to Charleston, SC. Many more
millions will see a partial eclipse. The US
couldn’t have a better opportunity.
While totality — in which the entire
solar disc is blocked by the Moon — will
be viewable at any point along the path for
about two minutes, some portion of the
Sun will be covered by the Moon across
the US (including Alaska and Hawaii),
Canada, Central America, the Caribbean,
and some of northern South America. The
orthographic map from NASA in Figure 1
shows how much of the Sun will be covered
and the approximate time. If you are one of
the lucky ones, the path of totality shown by
the blue line will be close enough for you to
see the fully-covered solar disc.

n FIGURE 1. An orthographic map showing


where the eclipse will be visible in the
Western Hemisphere. The path of totality
is the heavy blue line, with the width
indicating the length of totality. The grid is
labeled with the fraction of the Sun that will
be covered at that location (0.2 is 20%).
(Graphic courtesy of NASA.)

50 July 2017

Silver - Hams Wireless Workbench - Jul 17.indd 50 5/29/2017 2:08:58 PM


PRACTICAL TECHNOLOGY FROM THE HAM WORLD
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2017/07.

frequency bands
Eclipse Information available to it than
If you want more information on August’s eclipse, here are some good sites: any other service.
• NASA — Complete information on the eclipse With the new 630
(eclipse.gsfc.nasa.gov/solar.html) meter band (476
• Space — How to View the Eclipse Safely kHz) and the 2,200
(www.space.com/33797-total-solar-eclipse-2017-guide.html) meter band (136
• Astronomy Magazine — 25 Eclipse Tips kHz), hams will
(cs.astronomy.com/asy/b/astronomy/archive/2014/08/05/25-facts-you-should-know- have access to
about-the-august-21-2017-total-solar-eclipse.aspx) frequencies from
• NOAA Space Weather Prediction Center — Lots of real time information about radio conditions well below the AM
(www.swpc.noaa.gov/communities/radio-communications) broadcast band to,
well, light.
observed is the effect an eclipse has on radio propagation. Time of day is pretty easy to control. Assuming
As the May and July 2016 columns explained, someone is “out there” to make a contact, you can try
ultraviolet (UV) light from the Sun creates the ionosphere any band at any time. Having been at this radio business
by giving enough energy to electrons for them to escape since 1906, hams like to think we understand propagation
from the outer shells of atoms of gas; mostly oxygen and pretty well. However, there is always something new
nitrogen. coming up. Either better equipment or protocols or science
These free electrons and the positively-charged ions enables us to “try something different,” and there is usually
left behind can act like charges in a wire that respond something new to be discovered around every bend in the
to a voltage. That means the ionosphere is a very weak ionospheric road.
conductor that can affect the electromagnetic radio waves The eclipse is particularly interesting this way. It is one
passing through it. The main effect is bending or refracting thing for night to slowly fall as the Sun sinks below the
the waves in a way that returns them to the surface of the horizon; it’s quite another for a complete day-night-day
Earth. The effect is that of a reflecting surface high above cycle to occur in three hours or less! (Totality will only last
the Earth — the ionosphere starts at about 30 miles up and for a couple of minutes at most, but the partial phases will
extends to around 200-250 miles. last up to three hours depending on how close you are to
Not every wave gets the same treatment, however. the path of totality.) This means the solar UV will have a
The higher the wave’s frequency, the less it is bent. Above sudden well-defined disruption as suggested by Figure 2.
some frequency, the wave can’t be bent enough to
return and so is lost to outer space. At the other end
of the spectrum, the ionosphere becomes lossier
and lossier, eventually soaking up all of the signal so
that none of it returns to the Earth below a certain
frequency. Between these two limits, the waves are
bent, channeled, guided, and otherwise pushed
around.
More UV during the daylight hours raises the
level of ionization. This allows the ionosphere to
bend higher frequency signals more, supporting
long-distance “skip” of 2,500 miles or more above
10 MHz. Below 10 MHz, more UV means more
absorption by the ionosphere’s lower layers. The n FIGURE 2. A sketch of how solar UV irradition of the
signals never make it through to those long-distance ionosphere will change during the eclipse. (Graphs are not to
bending layers. At night, the situation reverses. scale.) The dashed gray line shows the regular diurnal (daily)
The outcome of all this wave bending is which variation in UV exposure.
signals we can receive depends on a variety of
factors: signal frequency, season, solar and geomagnetic We know from past experience that a total eclipse
activity, and time of day are the most significant. The of the Sun does have a big impact on ionospheric radio
easiest things we can control and vary to see what happens propagation. The eclipse duration will be long enough
to our signals are time of day and frequency. for those separated electrons and ions to find each other
Hams have a lot of frequency choices. In fact, next again — a process called recombination — and we’ll have
to the military, amateur radio has a bigger variety of nighttime propagation.
July 2017 51

Silver - Hams Wireless Workbench - Jul 17.indd 51 5/29/2017 2:08:58 PM


Bending on the higher frequency bands will fade and software written by Alex Shovkoplyas VE3NEA (www.
the signals will zip off into space — those bands will “close” dxatlas.com/cwskimmer) — can receive Morse code (CW)
to long-distance propagation. Simultaneously, absorption at and radioteletype (RTTY) signals, extract the call sign, and
the lower frequency bands will disappear and those bands — most importantly for the SEQP — measure the signal-to-
will “open.” At the end of the eclipse, the reverse happens, noise ratio (SNR).
and aside from some very confused electrons, things will Other decoders can do the same for WSPR and
be back to whatever normal conditions were before the PSK signals. Decoders will be deployed at dozens of
eclipse. sites around the world on all of the active amateur
bands, listening especially hard at 50 MHz and below —
frequencies expected to be most strongly affected by the
How Long Will It Last? eclipse.
Everybody in the United States will get some view of the
The decoders will then relay their observations to
eclipse, depending on cloud cover. If you are fortunate enough mapping and reporting services such as the Reverse
to be “on the line” of totality, you’ll get the maximum length Beacon Net (reversebeacon.net), PSKReporter
experience: almost three hours from the time at which the (pskreporter.info), and WSPRNet (wsprnet.org) which will
lunar disc first begins to cover the Sun, until it is clear of the store each and every observation. Hams will exchange a
Sun again. Totality will last two minutes and 40 seconds at short message indicating received signal strength and exact
maximum, near Carbondale, IL. location as a six-character Maidenhead grid location, such
For some idea of how long the eclipse will last at your as EM48ss (the author’s home locator). (You can learn
location, try the web page at www.space.com/36388- more about the grid system at en.wikipedia.org/wiki/
total-solar-eclipse-2017-duration.html. Maidenhead_Locator_System.) Hams will keep their own
“log” as well, with a list of all the contacts they’ve made.
Take a look at Figure 3.
What are the Hams Doing?
As you might imagine, this level of change coupled
with a major solar event has the ham radio community
HamSCI
pretty excited. Hams already can hear the world turning Then what? That’s where the professional researchers
as the daily ebb and flow of UV opens and closes different come in! There is no way even teams of pros could
bands and different paths. It’s a relatively slow process, duplicate the many thousands of amateur stations, so
taking minutes to hours. The opportunity to experience they’ve decided to use the ham-generated data themselves.
changes occurring so quickly you can hear them is another All of the decoder readings and all of the logs will be
thing entirely. collected by a group of Virginia Tech faculty and staff led
So, what are we doing about it? We’re throwing by Bob McGwier N4HY. They will turn all that data into a
a party! Actually, it’s going to be a “QSO Party” database that geophysics researchers can use.
(pronounced “kyew-so” which means “contact”) in What do the hams get out of it? First, hams like
which hams make short contacts as quickly as possible making a lot of contacts and this will be a lot of fun. At the
on as many bands as possible throughout the event. The peak, individual stations may make several quick contacts
bands will come to life in the morning and fill with signals every minute. Over the eight hours of the SEQP (see the
throughout the day. The Solar Eclipse QSO Party (SEQP) sidebar), some stations will log more than 1,000 QSOs
will be one of the premier ham radio events of the year! (contacts).
Not only will hams be making contacts, but they will Second, hams really enjoy helping science along.
be collecting data at the same time. We’ll be making use Science is what led to ham radio in the first place, and
of two recent ham radio innovations: automated receiving hams have worked with the scientific community since
decoders and data logging networks. The decoders — the early days of wireless. In fact, the SEQP is reminiscent
popularly referred to as “skimmers” after the CW Skimmer of the “Listening Tests” conducted in the early 1920s that
confirmed the presence of a reflecting mechanism
Solar Eclipse QSO Party Basics in the atmosphere now called the ionosphere.
• See the HamSCI SEQP web page for complete rules and FAQ. (You can read more about amateur participation in
• Time and Date: Monday, 21 Aug 2017 from 1400-2200 UTC. scientific and technological advances in History of
QST: Volume 1 — Amateur Radio Technology, 1915-
• Bands: 160, 80, 40, 20, 15, 10, and 6 meter bands (1.8 through 50 MHz).
2013; available from the ARRL at www.arrl.org.)
• Modes: CW, PSK31, RTTY will be decoded and logged.
In recent years, researchers using the HAARP
• Categories: Single-operator or multi-operator team.
facility in Alaska and elsewhere have discovered
• Exchange: Send the call sign of sending and receiving stations, signal hams as an enthusiastic knowledgeable community
report, and six-character grid locator (e.g., EM48ss). willing and able to help conduct worldwide
52 July 2017

Silver - Hams Wireless Workbench - Jul 17.indd 52 5/29/2017 2:08:58 PM


n FIGURE 3. The WPSRNet website shows WSPR reception reports from around the world. WSPR is a very low power
mode, so the long distance reception is quite impressive. WSPR is an invention of Joe Taylor K1JT, a retired astrophysicist
from Princeton who applied his Nobel Prize winning signal processing skills to amateur radio (physics.princeton.edu/
pulsar/K1JT). WPSR is part of Joe’s WSJT-X package of software for amateur radio moonbounce, meteor scatter, and
other experimental communications. (Map generated by Google.)

experiments. listening to the effects of the eclipse. You can do any of the
The early “Listening Tests” were coordinated by the following experiments while watching the eclipse without
Naval Research Lab (the DARPA of its day). Today’s SEQP leaving your backyard:
is being coordinated by HamSCI (hamsci.org): an informal
team of faculty, graduate, and undergraduate researchers 1. Absorption on the AM Broadcast Band
at a variety of academic institutions. HamSCI stands for Remember how solar UV causes the ionosphere to
Ham Radio Science Citizen Investigation. Its mission is to absorb low frequency signals during the day but reflect
coordinate and promote a variety of scientific projects them at night? That is exactly what happens to AM
involving ham radio. broadcast signals, and it’s the reason you can receive
The initial focus was on the eclipse — what could hams distant AM stations after sunset that you can’t hear at all
do to promote the science associated with it? Once the through the day. Your experiment will be to see if you can
SEQP had been devised, it became apparent that there receive distant stations during the eclipse and for how long.
were many other opportunities. A number of organizations Start by determining the direction towards the
were all working on their own projects, too. So, the idea path of totality from your location: NE, SW, or maybe
of a platform to connect all these people and projects was you are in the path, so E-W. Determine the frequencies
born. Check out the various projects on the website. You’ll of clear-channel AM stations in that direction. If you
be impressed. live in, say, Texas, you might listen for KOA-Denver,
KMOX-St Louis, WLS-Chicago, WHO-Des Moines, and
How Can You Participate? WCCO-Minneapolis. (There is a list of these stations at
en.wikipedia.org/wiki/Clear-channel_station.)
Assuming you’re not (yet) a ham, what can you do to Before the eclipse begins, listen for these stations at
observe the eclipse from the standpoint of radio? First, you night on a good quality radio — preferably with a piece
might check with local ham clubs and see if any of them or of wire attached to the antenna terminal. Find a few you
their members are planning to operate during the eclipse can hear well and write down their frequencies. These are
— either as part of the SEQP or in some other way. You your beacons. During the eclipse, tune from one station
would probably be welcome as an observer. What a great to another and note whether you can hear them and how
way to get a look at ham radio in a new and interesting strong they are at different times. What you’re looking for
way! are stations that approach their nighttime signal during the
If you are not licensed, you can still have a great time eclipse and then fade again as it passes.
July 2017 53

Silver - Hams Wireless Workbench - Jul 17.indd 53 5/29/2017 2:08:58 PM


2. Monitor WWV
If you have a “world band” radio
— meaning that it can tune to the
shortwave bands — you can do the
same experiment with the National
www.poscope.com Institute of Standards time-and-
frequency station WWV (en.wikipedia.
org/wiki/WWV(radio_station)). WWV
is in Fort Collins, CO and transmits on
2.5, 5, 10, 15, and 20 MHz. (You may
also hear WWVH on 5, 10, and 15
MHz — it is located in Hawaii on the
island of Kauai and beams its signal
primarily west into the Pacific.) A
world band radio may also have an “S
meter” which gives a reading of signal
strength. You can log those readings as
the signal is received. Refer to Figure 4.
Find the highest frequency signal n FIGURE 4. The 2 and 2.5 MHz
from WWV you can receive at about antennas at WWVH on Kauai.
- USB - PWM
the same time — midday or later in WWV and WWVH are the time and
- Ethernet - Encoders the afternoon. Note its signal strength. frequency standard stations operated
- Web server - LCD
- Modbus - Analog inputs
Monitor that frequency during the by the National Institute of Standards
- CNC (Mach3/4) - Compact PLC eclipse and see if you can observe and Technology. WWV is located
- IO
the opposite effect from the AM north of Denver in Fort Collins, CO.
stations. WWV should fade as the (Photo courtesy of NIST.)
path between it and your location is
darkened and the ionosphere grows weaker. If you are within a couple hundred
miles of WWV, you are probably too close for “skip” reception. Try receiving the
Canadian standard station CHU on 3330 kHz, 7850 kHz, or 14670 kHz.

3. Measure the MUF using Shortwave Broadcasts or Amateur Radio


- up to 256 Finally, you can try to measure the Maximum Useable Frequency (or MUF)
- up to 32
microsteps microsteps from your location by listening to shortwave broadcast stations at different
- 50 V / 6 A - 30 V / 2.5 A
- USB configuration
frequencies. The best reference for finding frequencies is the World Radio TV
- Isolated Handbook (www.wrth.com). Copies are available online, but get a recent
edition since broadcasters may change frequencies and schedules.
PoScope Mega1+ The national stations are usually the strongest. Find a couple that you can
PoScope Mega50 receive well on non-eclipse days at the same time of the eclipse. Don’t forget
the hams will be busy operating, too. If your radio can receive “SSB,” then it can
also receive CW and RTTY signals. Monitor signal strength as the shadow passes
by, and tune to higher and higher frequencies until the signals fade — that’s just
above the MUF between your location and that of the sending station.

After the Eclipse, Then What?


If this turns out to be fun, what happens after the eclipse? There’s another
one in 2024 that will also be visible from the US (southern Illinois is particularly
-up to 50MS/s lucky!), but why wait that long? There are quite a few “citizen science” projects
-resolution up to 12bit and programs, some of which are listed on the HamSCI website in the Citizen
-Lowest power consumption
-Smallest and lightest Science listing at hamsci.org/resources. You might check out the activities of
-7 in 1: Oscilloscope, FFT, X/Y, Recorder, the Society of Amateur Radio Astronomers (SARA — radio-astronomy.org), try
Logic Analyzer, Protocol decoder, Signal
generator your own Radio Jove installation (radiojove.gsfc.nasa.gov), or help launch a
high altitude balloon (www.arhab.org). You won’t regret “doing a little science”
during one of nature’s great events. NV
54 July 2017

Silver - Hams Wireless Workbench - Jul 17.indd 54 5/29/2017 2:08:59 PM


Eady - Design Cycle - Jul 17_Design Cycle - Sep 15.qxd 5/31/2017 11:03 AM Page 55

THE DESIGN CYCLE ■ BY FRED EADY


ADVANCED TECHNIQUES FOR DESIGN ENGINEERS

Put on a PiFace
The Raspberry Pi is a very popular computing platform. Its claims to fame are
inexpensive hardware and open source programming. Browse the Internet and you will
find that many have purchased a Pi with the thoughts of easily applying Python to the
hardware. As you claw through the thousands of hits, you’ll find a bunch of those
potential Pi users crying in their beer. Seems there’s a learning curve that goes along
with Python coding that’s coupled with little gotchas that come with the Raspberry Pi
itself. I’ve suffered with the Pi gotchas, but I didn’t lose any hair learning Python. In this
installment of the Design Cycle, we will use a free RAD (Rapid Application Development)
tool called B4J to twiddle the I/O pins of a PiFace that is hosted by a Raspberry Pi.

Preparing the Pi
You should use the RaspPi website
(www.raspberrypi.org) as a reference to avoid
frustration when working with the Pi.
Documentation for the PiFace is at best weak.
However, dig hard and you will find what you need.
You will discover that the PiFace is a very simple
device.
We will be running the latest version of
Raspbian on our RaspPi. Everything we need to
interface to the B4J program and PiFace is already
included in the Raspbian kernel. SSH is disabled by
default in Raspbian, so be sure to create an empty
file called ssh on the Pi’s bootable micro SD card.
The PiFace you see in Photo 1 is based on the ■ PHOTO 1. The PiFace is an I/O expansion board that falls under
Microchip MCP23S17 16-bit I/O expander. The the control of a Raspberry Pi’s SPI portal. Standard PiFace
features include an octet of LEDs sitting on high current outputs
RaspPi interfaces to the PiFace via the MCP23S17’s and a quad of pushbutton switches positioned on an octet of
SPI portal. I/O instructions from the Pi’s SPI portal digital inputs.
are processed by the MCP23S17, which drives a
ULN2803A Darlington transistor array.
The ULN2803 is designed to drive inductive loads.
To that end, the PiFace is equipped with a pair of relays
that are driven by the ULN2803A. The MCP23S17 pins
out to eight digital inputs and eight digital outputs. The
ULN2803A buffers the MCP23S17’s output pins, and
drives an octet of onboard LEDs in addition to the pair
of onboard relays. There is also a quad of pushbutton
switches tied to the MCP23S17’s input pins.
If you consult the Raspberry Pi website, you will
find that the Pi’s SPI portal is disabled by default. So,
our first task will be to enable it. We do this by editing
the /boot/config.txt file. As you can see in Screenshot 1,
we enable the RaspPi’s SPI portal by simply removing
the comment character standing in front of
dtparam=spi=on. ■ SCREENSHOT 1. I find it funny that the Raspberry Pi fathers
To a programmer, B4J is very much like Visual Basic listed the SPI and I2C portals as “optional.”
July 2017 55
Eady - Design Cycle - Jul 17_Design Cycle - Sep 15.qxd 5/30/2017 6:33 AM Page 56

To post comments on this article and find any associated files and/or downloads,
go to www.nutsvolts.com/magazine/issue/2017/07.

sudo java -jar b4j-bridge.jar

Screenshot 3 is the result of a successful execution


of the b4j-bridge.jar file. As you can see, the Pi spits up
its IP address and port numbers for the FTP transfers.
Now that we have the Pi’s IP address, we can plug it
into B4J and attempt to connect.
Things are good in Screenshot 4. At this point, we
can generate PiFace code and upload it to the RaspbPi.
Once the Pi has the code, we can use the B4J Bridge to
remotely debug it.
■ SCREENSHOT 2. This command sequence downloads the
b4j-bridge.jar file into the current Raspberry Pi directory. Let’s Write Some Code
B4J can be used to create UI and non-UI
applications. We will create non-UI applications for the
PiFace. Console and server applications fall in the non-
UI category. Thus, the PiFace applications will have no
fancy user interface. We must be sure to select Non-UI
(Console) as our application type when creating a new
PiFace application to avoid a Java runtime error
condition.
■ SCREENSHOT 3. We need the Pi’s IP address to hook up the
“bridge.” The FTP ports are nice to have, but we don’t use Here is the non-UI code skeleton that B4J
them or care about them. generates for us:
‘Non-UI application (console / server
application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region

Sub Process_Globals
End Sub

Sub AppStart (Args() As String)


■ SCREENSHOT 4. We can now upload code to the Raspberry End Sub
Pi and debug it remotely under the control of B4J.
‘Return true to allow the default exceptions
6. So, if you’re familiar with VB6, you are a rung up on the handler to handle the uncaught exception.
Sub Application_Error (Error As Exception,
learning curve ladder. B4J runs on a PC and generates the StackTrace As String) As Boolean
PiFace code that we will be loading onto our Pi. To get Return True
code down to the Pi and enable remote debugging, we End Sub
need to run a program on the Pi that “bridges” B4J to the
Pi. That program is aptly called B4J Bridge. It’s up to us to fill in the meat of the various B4J
To get the Pi portion of B4J Bridge, we must subroutines. So, let’s start with the Process_Globals
download the B4J jar file to our RaspPi. Here’s the Pi subroutine.
command that accomplishes that: Process_Global variables can be declared as public or
private. Public variables are accessible by the entire
wget www.b4x.com/b4j/files/b4j-bridge.jar project. Private variables are limited to access only within
their module. The same thought holds true for variables
Following the entry of the wget command, the Pi spits and subroutines. Private variables can only be accessed
out the text you see in Screenshot 2 and the b4j-bridge.jar within the subroutine, while public variables can be
file is placed into the Pi’s current directory. At this point, accessed by any subroutine.
we can fire up B4J on the PC and attempt to “bridge” the All global variables must be declared within the
Pi and B4J. Process_Globals subroutine. To allow the variables to be
Before we attempt the connection, we must also kick accessed from everywhere in the project, declare the
off the Pi portion of the bridge. Again, we resort to our variables as public. Otherwise, declare them as private.
RaspPi terminal session and enter the following: The public variables will live as long as the process lives.
56 July 2017
Eady - Design Cycle - Jul 17_Design Cycle - Sep 15.qxd 5/30/2017 6:33 AM Page 57

application)
#Region Project Attributes
Let’s declare a private PiFace object: #CommandLineArgs:
#MergeLibraries: True
‘Non-UI application (console / server #End Region
application)
#Region Project Attributes Sub Process_Globals
#CommandLineArgs: Private pf As PiFace
#MergeLibraries: True Private Timer1 As Timer
#End Region End Sub
Sub Process_Globals Sub AppStart (Args() As String)
Private pf As PiFace pf.Initialize(0x40,0)
End Sub Timer1.Initialize(“Timer1”,1000)
Timer1.Enabled = True
Sub AppStart (Args() As String) End Sub
End Sub
Sub Timer1_Tick
‘Return true to allow the default exceptions End Sub
handler to handle the uncaught exception.
‘Return true to allow the default exceptions
Sub Application_Error (Error As Exception, handler to handle the uncaught exception.
StackTrace As String) As Boolean Sub Application_Error (Error As Exception,
Return True StackTrace As String) As Boolean
End Sub Return True
End Sub
This code template will compile and can be executed.
However, nothing will happen and the process will end. As you can see in the B4J code, we declared a Timer1
We still need to do some things in the AppStart object in the Process_Globals subroutine. We then
subroutine. Like the Process_Globals subroutine, the initialized and enabled our Timer1 object in the AppStart
AppStart subroutine is called only once at the beginning subroutine. This code will behave exactly like the
of the process. unmodified code we previously laid down. It will compile,
The purpose of the AppStart subroutine is to initialize execute, and do nothing that we can see.
our desired variables and objects. We know that our Let’s do something proactive and blink the PiFace’s
MCP23S17 must be initially configured via the SPI portal, LED2:
so we’ll add some MCP23S17/PiFace startup code in our ‘Non-UI application (console / server
AppStart subroutine: application)
#Region Project Attributes
‘Non-UI application (console / server #CommandLineArgs:
application) #MergeLibraries: True
#Region Project Attributes #End Region
#CommandLineArgs:
#MergeLibraries: True Sub Process_Globals
#End Region Private pf As PiFace
Private Timer1 As Timer
Sub Process_Globals End Sub
Private pf As PiFace
End Sub Sub AppStart (Args() As String)
pf.Initialize(0x40,0)
Sub AppStart (Args() As String) Timer1.Initialize(“Timer1”,1000)
pf.Initialize(0x40,0) Timer1.Enabled = True
End Sub StartMessageLoop
End Sub
‘Return true to allow the default exceptions
handler to handle the uncaught exception. Sub Timer1_Tick
Sub Application_Error (Error As Exception, pf.GetLED(2).State =
StackTrace As String) As Boolean Not(pf.GetLED(2).State)
Return True End Sub
End Subj
‘Return true to allow the default exceptions
handler to handle the uncaught exception.
Our new PiFace code will also compile, execute, and Sub Application_Error (Error As Exception,
stop. We must assume that the MCP23S17 got the StackTrace As String) As Boolean
message. To know for sure, we need to beef up our Return True
End Sub
application and force some kind of visual indication that
things are indeed working as designed. Let’s begin by Since this is a non-UI application, we must call
adding a one second timer and an associated tick handler StartMessageLoop to force the thread to take charge of the
subroutine: message queue. This effectively allows the program to
keep running. Our Timer1 will trigger a tick event every
‘Non-UI application (console / server second. So, we’ll code a subroutine to handle the tick
July 2017 57
Eady - Design Cycle - Jul 17_Design Cycle - Sep 15.qxd 5/30/2017 6:52 AM Page 58

event. In our case, we’ll toggle the PiFace’s LED2 every Next
StartMessageLoop
second. End Sub
Now that we’ve conquered the PiFace LED interface,
let’s turn our attention to the pushbuttons. To read the Sub Timer1_Tick
pf.GetLED(2).State =
state of the PiFace’s pushbuttons, we must code in some Not(pf.GetLED(2).State)
button handlers called event listeners. End Sub
Event listeners are nothing more than subroutines that Sub Pushbutton0_StateChange(State As Boolean)
handle the change in button state. For this to work, we Select State
must declare each of the PiFace’s pushbuttons as a B4J Case True
pf.GetLED(3).State = True
Switch object. Doing this adds the Switch object’s events Case False
and members to each pushbutton. For instance, after the pf.GetLED(3).State = False
declaration, each pushbutton is associated with an event End Select
End Sub
called StateChange which returns the Boolean state of the
pushbutton (true or false). The state of the pushbutton Sub Pushbutton1_StateChange(State As Boolean)
Select State
(true or false) is also defined within the Switch object as a Case True
member. pf.GetLED(4).State = True
Another Switch object member is called AddListener, Case False
pf.GetLED(4).State = False
which adds an event listener. Here is what our pushbutton End Select
event listener initialization code looks like: End Sub

Sub AppStart (Args() As String) Sub Pushbutton2_StateChange(State As Boolean)


pf.Initialize(0x40,0) Select State
Timer1.Initialize(“Timer1”,1000) Case True
Timer1.Enabled = True pf.GetLED(5).State = True
For i = 0 To 3 Case False
Dim sw As Switch = pf.GetSwitch(i) pf.GetLED(5).State = False
sw.AddListener(“pushbutton” & i) End Select
Next End Sub
StartMessageLoop
End Sub Sub Pushbutton3_StateChange(State As Boolean)
Select State
Case True
The PiFace hosts four pushbuttons (0-3) which are pf.GetLED(6).State = True
referenced by pf.GetSwitch(i). Each of the PiFace’s Case False
pf.GetLED(6).State = False
pushbuttons is declared as a Switch object, which entitles End Select
each pushbutton to the Switch object’s events and End Sub
‘Return true to allow the default exceptions
members. handler to handle the uncaught exception.
Each of the PiFace’s four pushbuttons is assigned an Sub Application_Error (Error As Exception,
event listener that is associated by name (pushbutton0, StackTrace As String) As Boolean
Return True
pushbutton1, etc.). When a pushbutton event occurs End Sub
(StateChange), the associated event listener subroutine is
called. We do our thing within that particular subroutine. The B4J code we just generated is pretty much self-
Note that our Timer1 is still ticking away and blinking commenting. The PiFace relays share I/O positions 0 and
LED2 on the PiFace. Let’s add the event listener code: 1 with LED0 and LED1. So, we could control the relays
like this:
‘Non-UI application (console / server
application) Sub Pushbutton0_StateChange(State As Boolean)
#Region Project Attributes Select State
#CommandLineArgs: Case True
#MergeLibraries: True pf.GetLED(0).State = True
#End Region Case False
pf.GetLED(0).State = False
Sub Process_Globals End Select
Private pf As PiFace End Sub
Private Timer1 As Timer
End Sub Sub Pushbutton1_StateChange(State As Boolean)
Select State
Sub AppStart (Args() As String) Case True
pf.Initialize(0x40,0) pf.GetLED(1).State = True
Timer1.Initialize(“Timer1”,1000) Case False
Timer1.Enabled = True pf.GetLED(1).State = False
For i = 0 To 3 End Select
Dim sw As Switch = pf.GetSwitch(i) End Sub
sw.AddListener(“pushbutton” & i)

58 July 2017
Eady - Design Cycle - Jul 17_Design Cycle - Sep 15.qxd 5/30/2017 6:36 AM Page 59

Or, we could control the PiFace relays in a more ‘Non-UI application (console / server
politically correct manner: application)
#Region Project Attributes
Sub Pushbutton0_StateChange(State As Boolean) #CommandLineArgs:
Select State #MergeLibraries: True
Case True #End Region
pf.GetRelay(0).State = True
Case False Sub Process_Globals
pf.GetRelay(0).State = Private piController As GpioController
False Private piPinOut As GpioPinDigitalOutput
End Select Private piPinIn As GpioPinDigitalInput
End Sub Private Timer1 As Timer
End Sub
Sub Pushbutton1_StateChange(State As Boolean)
Select State Sub AppStart (Args() As String)
Case True piController.Initialize
pf.GetRelay(1).State = True piPinOut.Initialize(27,True)
Case False piPinIn.Initialize(“pInput”,25)
pf.GetRelay(1).State = Timer1.Initialize(“Timer1”,1000)
False Timer1.Enabled = False
End Select StartMessageLoop
End Sub End Sub

Sub Timer1_Tick
piPinOut.Blink(500)
Twiddling the Pi I/O End Sub

Sub PInput_StateChange(State As Boolean)


Not only can we use B4J to drive the PiFace, we can piPinOut.Pulse(1000)
also use the same B4J code to drive the Pi’s I/O stack. End Sub
Let’s remove our PiFace and blink an LED using the Pi’s
‘Return true to allow the default exceptions
GPIO pin 27: handler to handle the uncaught exception.
Sub Application_Error (Error As Exception,
‘Non-UI application (console / server StackTrace As String) As Boolean
application) Return True
#Region Project Attributes End Sub
#CommandLineArgs:
#MergeLibraries: True
#End Region
Note that we never enabled Timer1. So, our LED
Sub Process_Globals won’t blink as Timer1_Tick will never be called. Instead,
Private piController As GpioController
Private piPinOut As GpioPinDigitalOutput we added an input pin (Pi I/O pin 25) and an associated
Private Timer1 As Timer StateChange subroutine handler. We really don’t care
End Sub
about the state of the input pin; we just want to know if
Sub AppStart (Args() As String) the state changed. Every time the state on pin 25
piController.Initialize transitions, we pulse on the LED hanging on the Pi’s GPIO
piPinOut.Initialize(27,True)
Timer1.Initialize(“Timer1”,1000) 27 pin for one second.
Timer1.Enabled = True

End Sub
StartMessageLoop
Guess What?
Sub Timer1_Tick Now that you have been exposed to the ways of B4J,
piPinOut.Blink(500)
End Sub you can also program using B4A (Basic for Android), B4R
(Basic for Arduino), and B4i (Basic for iOS). You’ll have to
‘Return true to allow the default exceptions purchase B4A and B4i, but you can download B4J and
handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, B4R for free.
StackTrace As String) As Boolean Once you’ve actually
Return True programmed using one of PiFace
End Sub
the B4x products, you’ll www.amazon.com
By declaring piPinOut as a GpioPinDigitalOutput wonder why you never
object, we can blink and pulse the Pi’s GPIO pin 27 with thought to put it into your
simple commands. Design Cycle before. NV B4J
The code for reading the Raspberry Pi’s digital inputs
is very similar to the code we wrote to read the PiFace Anywhere Software
inputs: www.b4x.com

July 2017 59
NV Webstore - Jul 17 working_NV Webstore June 2016 working.qxd 5/30/2017 6:40 AM Page 60

For comple t e pr oduct de t ails, visi t us online!!


The Nuts & Volts WEBSTORE
GREAT FOR DIYers!
Cool Tools Electronics Workshop 20 Makey Makey Projects
by Kevin Kelly Companion for Hobbyists for The Evil Genius
Cool Tools is a highly by Stan Gibilisco by Aaron Graves,
curated selection of In this practical Colleen Graves
the best tools guide, electronics This hands-on guide is
available for expert Stan filled with DIY projects
individuals and small Gibilisco shows you, that show readers step-
groups. Tools include step by step, how to by-step how to start
hand tools, maps, set up a home creating and making
how-to books, workshop so you cool inventions with the
vehicles, software, can invent, design, Makey Makey invention
specialized devices, build, test, and kit. Each project
gizmos, websites — repair electronic features easy-to-follow
and anything useful. circuits and gadgets. fully-illustrated
Tools are selected Electronics Workshop instructions and detailed photographs of
and presented in the book if they are the Companion for Hobbyists the finished gadget. Readers will see how
best of kind, the cheapest, or the only thing provides tips for constructing your to apply these skills and start building their
available that will do the job. This is an workbench and stocking it with the tools, own Makey Makey projects.
oversized book which reviews over 1,500 components, and test equipment you’ll • No prior programming or technical
different tools, explaining why each one is need. Clear illustrations and interesting experience is required
great, and what its benefits are. do-it-yourself experiments are included • Basic enough for beginners, but
throughout this hands-on resource. challenging enough for advanced makers
$39.95 Sale Price $24.95 $25.00 $25.00

Make Your Own Programming the Raspberry Pi,


PCBs with EAGLE Second Edition: Getting Started
by Eric Kleinert with Python Beginner's Guide to Reading
Featuring detailed by Simon Monk Schematics, 3E
illustrations and by Stan Gibilisco
step-by-step An updated guide
instructions, Make to programming
your own RaspPi Navigate the roadmaps
Your Own PCBs with of simple electronic
EAGLE leads you projects circuits and complex
through the process systems with help from
of designing a Learn to create inventive
programs and fun games an experienced
schematic and engineer. With all-new
transforming it into on your powerful
Raspberry Pi with no art and demo circuits
a PCB layout. You’ll you can build, this
then move on to programming experience
required. This practical hands-on, illustrated
fabrication via the generation of standard guide explains how to
Gerber files for submission to a PCB book has been revised to fully cover the
new Raspberry Pi 2, including upgrades to understand and create high-precision
manufacturing service. This practical guide electronics diagrams. Find out how to
offers an accessible, logical way to learn the Raspbian operating system. DIY
projects include a hangman game, RGB identify parts and connections, decipher
EAGLE and start producing PCBs as element ratings, and apply diagram-based
quickly as possible. LED controller, digital clock, and
RasPiRobot with an ultrasonic rangefinder. information in your own projects.
$30.00 Reg $15.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
A Fully Revised how to program by Simon Monk
Guide to microcontrollers, then
you've found the right In this practical guide,
Electronics book! Microchip PIC electronics guru Simon
Repair all kinds of microcontrollers are Monk takes you under
electrical products, being designed into the hood of Arduino
from modern digital electronics throughout and reveals professional
gadgets to analog the world and none is programming secrets.
antiques, with help more popular than the Also shows you how
from this updated eight-pin version. Now to use interrupts,
book. The Second the home hobbyist can manage memory,
Edition offers expert create projects with these little program for the
insights, case studies, and step-by-step microcontrollers using a low cost Internet, maximize
instruction from a lifelong electronics guru. development tool called the CHIPAXE
system and the Basic software serial communications,
Discover how to assemble your workbench, perform digital signal
use the latest test equipment, zero in on and language.Chuck Hellebuyck introduces
how to use this development setup to processing, and much more. All of the 75+
replace dead components, and handle example sketches featured in the book are
build useful projects with an eight-pin
reassembly. $24.95 PIC12F683 microcontroller. $14.95 available for download. $20.00

60 July 2017
NV Webstore - Jul 17 working_NV Webstore June 2016 working.qxd 5/30/2017 6:40 AM Page 61

Order online @ store.nutsvolts.com


Or CALL 1-800-783-4624 today!
EDUCATIONAL CD-ROM SPECIAL

July 2017 61
TECHFORUM READER - TO - READER

>>> QUESTIONS >>> ANSWERS watch?v=Tw0P2DtB8Yo.


In addition to the car count,
Ransomware Scare [#2175 - Febuary 2017] the laser detectors that I used also
There has been quite a bit Vehicle Detector allowed me to acquire direction and
of news lately about so-called Does anyone have suggestions for speed. I saved the data to a SQL
“ransomware.” Can someone explain buying or building a vehicle detector server and rendered the data on a
how it works and is there a fool-proof which can be used with the Arduino? webpage using highcharts (details
way to keep my machines (and those I wish to sense and count passing in the video). This required a PC to
of my family) protected? vehicles. be running all of the time (about
#7171 Jerry Turner 90 watts). I have now replaced the
Joliet, IL #1 This has been done before by PC with a Beaglebone Black and
several folks using a tube counter use a MQTT listening service called
Battery Killer approach. The drawback is that mosquitto to acquire Arduino data
I have an older model Hunter you need to lay a tube across the and pass it to the MySQL database.
SRC sprinkler controller that came roadway, but if this is okay for your Programming and rendering
with my house. Recently, the unit has project, this is the way to go. It’s the is being done with Node-Red. I
been “resetting” to 12:00 am rather same way that professional traffic hope to develop a video with that
than keeping time. The unit has a nine counts are often done. Two links on configuration soon.
volt battery that was reading 2.7V, so projects are https://hackaday.io/ Jeremy Lang
I replaced the battery. Within a week, project/4567-traffic-counter-road- Madison, WI
the problem was back and the new tube and www.tomorrow-lab.com/
battery was also dead (3.1V). lab16.php. [#3171 - March 2017]
Any ideas what could be killing Ultrasonic sensors might work if Getting Started With High Voltage
the batteries? I can’t find a schematic you can put the sensor very close to I would like to experiment with
for this unit. the lane in question (e.g., if you just high voltage projects, but all my
#7172 Norris Shaw need to detect traffic on the nearest experience in building power supplies
Santa Ana, CA lane). Otherwise, range becomes is for low voltage (typically 5 or 12
an issue and cost increases for volts). I’d love a schematic for a high
Laser Eye Protection longer range sensors. This site has a voltage power supply that could
With high powered laser prices project that did just that: www.chris- produce between 0 and 250 volts
dropping like crazy, I decided to pick sheppard.com/?page_id=40. safely. Also, any safety pointers for
up a 3W blue laser from eBay for $50 Radar rangefinders are the getting started would be appreciated.
to experiment with. next step up for range if you can’t
I’m concerned about eye damage use a tube; one example would #1 You didn’t indicate how
and would like some advice on eye be something like the LIDAR-Lite much current you are expecting from
protection. What makes a pair of laser 3 Laser Rangefinder, but you’re the supply. Searching the Internet, I
goggles good and what should I stay now using a >$100 sensor. There’s found the referenced schematic for
away from? three pages of discussion on this a 300 VDC variable voltage supply
#7173 Gary Byrum topic on the Arduino forum at that will deliver up to 100 ma. The
Milwaukee, WI https://forum.arduino.cc/index. circuit is for 220 VAC mains, but we
php?topic=298000.30. can substitute a step-up transformer
Salt Sensor Mike McGurrin for operating with a 120 VAC mains.
I have a water softener that needs Vienna,VA I have included a Parts List reference
pellet salt added to a brine tank. from Digi-Key that should do the trick.
I’m trying to figure out a circuit to #2 A couple of years ago, I Due to the high voltage involved,
detect when I need to add salt as the wanted to know how many cars you should put the components
tank is opaque and salt usage varies were driving past my house each inside an enclosure, such as a Bud
depending on use. The simpler the day, so I built a counter for about Industries' box and bring the output
circuit, the better! $140. Here is the link to the 12 up to a couple of banana type jacks
#7174 Marc Judd minute YouTube video describing or terminal block. You can also mount
Greensboro, NC how I did this: www.youtube.com/ the pot on the outside of the box and
62 July 2017

Tech Forum - Jun 17.indd 62 5/30/2017 5:44:14 AM


>>>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

add a knob to it. The transformer is not so stable because the voltage knowing what voltage in and voltage
the most expensive component and drops as the charge is depleted. If out you have, it’s hard to say, but
can be sourced from other suppliers if you have a full time battery charger the LM317 will scrub off the excess
you need to reduce costs. Hope this attached, the stability problem goes voltage as heat. However, there are
helps! away. The zener diode has a rather boost/buck converters available
Schematic: www.eleccircuit. high impedance; up to 100 ohms for not much money (I bought four
com/the-variable-high-voltage-power- for those under six volts and lowest little boards based on the LM2587
supply-0-300v at 6.8 volts. If you have a 6.8 volt for about $7.50 each off eBay, for
Parts List: www.digikey.com/ zener running at 20 mA with an instance) that will conserve the
short/327wpp impedance of 25 ohms and the load current (minimal heat, minimal waste,
Doug Foreman varies 10 mA, then the voltage will minimal extra battery usage) and keep
Warren, MI vary: delta V = Ro * delta I = 25 * .01 the voltage even more accurate.
= 0.25V. The LM317, on the other For perfect usage, team one of
#2 You want to be extremely hand, has an output impedance in those up with a zener secondary
cautious experimenting with high the order of .05 ohms and you can regulator, so that you have a
voltages as they are lethal and can be set the voltage as accurate as you minimum of wasted current through
fatal. Rather than trying to construct need using the schematic in Figure 5 the resistor feeding the zener and
a high voltage supply — which could of the datasheet. The voltage should your circuit; that way, you have both
be dangerous — you might consider stay within 1% over time, but you can worlds working for you.
a variable transformer such as the reset it periodically if you want. You Ralph Phillips
Volteq #1KVA_110V/250V (www. should have a minimum load of 10 Shreveport, LA
volteq.com) which costs about $70. mA on the LM317 for good stability.
This transformer plugs into a Don’t run at max current if you want #4 The LM317 appears to be about
standard 120 VAC outlet and provides good reliability. 5% in accuracy (you also need to
an adjustable output from 0 to 250 Russell Kincaid add the error from the resistors used
VAC; it also provides isolation from Milford, NH for the adjustment, but you could
the AC power grid. If you want DC get some 0.1% resistors to manage
voltage, you can construct a simple #2 Three-terminal voltage that). A quick look on Digi-Key shows
bridge rectifier circuit. However, there regulators such as the LM317 are plenty of 1% zeners, so that path may
are many more interesting projects very accurate, and are suitable for offer more accuracy.
that use 5-12 volts. I suggest you most applications. You might want to If your load is fairly constant, your
pursue some of them instead. consider a fixed voltage output, low zener circuit can be tuned so the
Bob Stewart drop-out type, three-terminal regulator zener will just barely turn on with the
Mancos, CO such as the 78L00 series, made by expected load. If the load goes down,
several different manufacturers. The the zener will eat power to keep you
[#3172 - March 2017] low drop-out minimizes power loss — regulated. There are some other parts
Reliable Voltage Source for example, you can obtain five volts out there that offer better accuracy.
I am designing a battery powered out from six volts in (4x AA batteries). Check out the LT1460: 0.125% (but
circuit that requires a very reliable However, the purpose of any voltage only ensures 20 mA output).
voltage source. I was considering using regulator is to create a stable fixed Kevin Cutts
a zener diode in series with a resistor output from a variable input. Thus, the Lake Zurich, IL
across the power source and then regulator must dissipate power, and
tapping it at the diode/resistor for the you must observe the power rating of [#5172 - May 2017]
power point, but it seems this would the regulator or it will overheat and FCC Search
be very wasteful for the battery. Would self-destruct. Has anyone had any success
I be better off with a linear regulator Bob Stewart using the FCC ID search feature? I’ve
like an LM317 and if so, would it Mancos, CO searched about 15 ID numbers and
create as accurate a voltage? have yet to get any useful info!
#3 The LM317 would create a
#1 Are you looking for stability or more accurate voltage; however, that So, let’s say you are motoring
reliability? The battery is reliable but may not be the best way to go. Not about the countryside one fine day
July 2017 63

Tech Forum - Jun 17.indd 63 5/30/2017 5:44:14 AM


>>>YOUR ELECTRONICS QUESTIONS ANSWERED HERE BY N&V READERS

and you spot an interesting tower tower height in meters (307 meters station of interest and type it in there.
structure. Look around the entrance or a little over 1,000 feet). By the Example: WLW and hit the Submit
area and you should see a sign with way, you can also get here by going Station Search button. A new window
the FCC Tower Identification Number to www.fccinfo.com where the good opens with the results, which are fairly
on it. Let’s use number 1027514 as folks at Cavell, Mertz, and Associates skimpy at this point. However, on the
an example. Go onto www.fcc.gov have an easy-to-use database front- far right of the Results is a link labeled
and: end and a nifty Google Earth plug-in Click for Details. Another Results
1. Click the Licensing and that will give you the callsign for a window opens with more links to
Databases tab. You’ll be presented station associated with a broadcast more information. Now, we can get
with a list of about 25 databases listed tower. Note: broadcast, not cell, two- into the good stuff.
by their acronyms. Some of them are way, or other utility tower. On the Bureaus & Offices/Media
intuitive. Others, not so much. 5. On the ASR Results page, click home page, select Electronic Filing
2. In this case, click on ASR (for on the Registration Number. A new and Databases along the left side. The
Antenna Structure Registration). window opens, chock full of good new page that opens offers another
Partway down the page, you’ll information. list of choices — one of which is AM
find Search with a choice of either Another way to go about this Query, among others. Hit that one
Registrations or Applications. is on the FCC home page; click on and a new query search opens. On
3. Click on Registrations and a ‘browse by Bureaus & Offices,’ then the first line, enter WLW. Further
new window opens. In the upper on the Media sub-tab. The Media down, just above the Results buttons,
left corner is a field you enter the home page will appear. Now, along you choose how much information
registration number. While you’re the left side you will be presented you want. Choose the AM Query
here, you can check out the other with a list of choices. You want CDBS (detailed output + CDBS Links) menu
possible searches such as lat/lon, by Search. You’ll then be presented item and hit either the Results To
state, etc. with another list of choices which This Page/Tab or the Results To Next
4. Enter the registration number should be fairly self-explanatory. Page/Tab buttons, depending on your
and hit Submit. Note that this takes a As an example, choose the first preference. You’ll get everything you
whole lot longer to describe than to selection which is Search for Station ever wanted and more. If you’ve got
actually do. A new window opens, Information (as of the date I’m doing the time, you can easily spend hours
with the results — typically one line, this). The new window is a whole looking up all kinds of arcane things.
but a fact-filled line. We now know bunch of search fields, but to keep it Jerry McCarty
the FCC File Number, the owner (in simple the first line is Call Sign. In that Jackson, MI
this case, WLAJ-TV), lat/lon, city, and field, enter the call letters. Pick your

64 July 2017

Tech Forum - Jun 17.indd 64 5/30/2017 5:44:14 AM


ElectroNet - Class Ads - Index - Jul 17_Mar15 -NV - NewProducts.qxd 5/30/2017 6:57 AM Page 65

ELECTRONET
www.nutsvolts.com and click Electro-Net USB
For the ElectroNet online, go to Add USB to your next project--
It's easier than you might think!
USB-FIFO USB-UART USB/Microcontroller Boards
RFID Readers Design/Manufacturing Services Available
Absolutely NO driver software development required!

CLASSIFIEDS www.dlpdesign.com

LIGHTING HARDWARE
WANTED
DEC and VME LED Lighting for Everything
Equipment WANTED!
Digital Equipment Corp
and
Motorola VME Systems
and Parts
Buy - Sell - Trade

Subscribe today! CALL KEYWAYS 937-847-2300


or email buyer@keyways.com

ADvertiser INDEX
■L O O K F O R ■S E A R C H F O R ■F I N D Find your favorite advertisers here! Accutrace ..............................67

All Electronics Corp. .............49

BATTERIES/CHARGERS Anaren .......................Back Cover ROBOTICS Anaren ...................Back Cover


Hitec ..............................................2 Technologic Systems ................10
Hitec ..............................................2
AP Circuits ............................15
IR Robot Control .........................49
BUYING ELECTRONIC EDUCATION
Command Productions ..................7 Pololu ..........................................41 Command Productions ...........7
SURPLUS
All Electronics Corp. .................49 PoLabs ........................................54 EarthLCD ..............................17
TEST EQUIPMENT
CIRCUIT BOARDS EMBEDDED SYSTEMS Electronix Express ................16
Electronix Express ......................16
Accutrace ....................................67 Saelig Co. Inc. ..........................66
Technologic Systems ................10 Pico Technology ..........................35 ExpressPCB .........................22
AP Circuits ...................................15
ExpressPCB .............................22 PoLabs ........................................54
Front Panel Express .............15
PCB Fab Express ........................34 ENCLOSURES Saelig Co., Inc. .........................66
Saelig Co., Inc. .........................66 Front Panel Express ....................15 Hammond Manufacturing .....11
Hammond Manufacturing ............11
TOOLS Hitec .......................................2
COMPONENTS
All Electronics Corp. .................49 LCDs/DISPLAYS PanaVise ..................................34
IR Robot Control ...................49
Electronix Express ......................16 EarthLCD .....................................17 PoLabs ........................................54
Pololu ..........................................41 Saelig Co., Inc. .........................66 Lemos International ..............17
Saelig Co., Inc. .........................66
MICROCONTROLLERS TRANSFORMERS PanaVise ..............................34
CNC / I/O BOARDS Hammond Manufacturing ............11
PCB Fab Express .................34
Routakit .........................................3 Technologic Systems ................10
WIRE, CABLE AND Pico Technology ...................35
DESIGN/ENGINEERING MISC./SURPLUS
All Electronics Corp. .................49 CONNECTORS PoLabs .................................54
/REPAIR SERVICES
Accutrace ....................................67 All Electronics Corp. .................49
Pololu ....................................41
AP Circuits ...................................15 MOTORS / MOTOR
ExpressPCB .............................22 CONTROL Routakit ..................................3
WIRELESS PRODUCTS
Front Panel Express ....................15 Electronix Express ......................16 Anaren .......................Back Cover Saelig Co., Inc. .....................66
Hitec ..............................................2
DEVELOPMENT IR Robot Control .........................49 Lemos International .....................17
Pololu ..........................................41 Technologic Systems ................10 Technologic Systems ............10
PLATFORMS/TOOLS
July 2017 65
Full Page.indd 66 5/31/2017 1:38:56 PM
ea ea ea

Our Full Service Capabilities:

(408)748-9600
ITAR I SO 9001:2008 UL Approved

Full Page.indd 67 1/30/2017 4:53:42 PM


NutsNVolts Jet ad 022117.qxp_Layout 1 2/21/17 1:22 PM Page 1

Full Page.indd 68 2/27/2017 7:18:42 PM

S-ar putea să vă placă și