This is only a preview of the December 2021 issue of Practical Electronics. You can view 0 of the 72 pages in the full issue. Articles in this series:
|
Max’s Cool Beans
By Max the Magnificent
Flashing LEDs and drooling engineers – Part 22
J
ust a couple of days ago – as
I pen these words – I received an
email from a new subscriber to
this illustrious magazine. The gentleman in question was querying the
‘Drooling Engineers’ portion of the
title to our current series of Cool Beans
columns. I replied that it originated
from the fact that I’m prone to proclaim,
‘Show me a flashing LED, and I’ll show
you a man drooling.’ I can only assume
that the fact I’ve heard nothing since
that time is because he’s still rolling
on the floor laughing.
Sew a button on your head
You know how you sometimes start
a sentence by saying ‘So...’ and then
pause to gather your thoughts before
proceeding. Well, many moons ago, I
had a friend of the female persuasion
who abhorred a conversational vacuum,
and who would fill it by saying, ‘Sew
a button on your head.’ I had no idea
what this meant, and I used to find it
extremely annoying, so... it’s ironic that
I now tend to find myself doing the same
thing to other people.
The reason I mention this here is that
I’m eager to embark on a new endeavor.
Do you recall my Pedagogical and Phantasmagorical Inamorata Prognostication
Engine project? It was instrumental in
kicking off this Flashing LEDs series of
columns in the first place (PE, March
Fig.1. My ginormous variable capacitor –
do you have bigger one?!
42
2020). The raison d’etre of this bodacious beauty, which currently resides
in my office, is to predict the mood of
my wife (Gina the Gorgeous) and inform
me as to which way the wind is blowing before I set off home in the evening.
Paradoxically, should Gina ever come to
discover the beast’s true purpose, I won’t
need it to predict her mood.
Everyone who encounters the groundbreaking Prognostication Engine is enthralled. Many of my friends have told
me that they could do with one themselves. In fact, I am often asked to bring
it to events like local hamfests to adorn
the booth of a technical company or
radio society. The problem is that it’s a
tad large – it stands taller than me – and
is more than a little delicate, so I prefer
to leave it where it is.
My new machine, which we will call
the Sewing Engine, will be much more
mobile. It’s going to be housed in an antique sewing machine table with a cast
iron base, much like the one that appears
on the Olde Good Things website (https://
bit.ly/3n56Ogz). Mine is almost identical, except that I certainly didn’t pay the
$250 the folks at Olde Good Things were
asking for theirs because – knowing what
I was looking for – my chum Carpenter
Bob acquired one for a song at an auction
out in the country somewhere.
I’m still mulling things over in my head
as to the actual implementation. One thing
I do know is that I’m going to finally get
to use the ginormous variable capacitor
that was gifted to me a couple of years ago
by my chum Paul Parry of Bad Dog Designs (https://bit.ly/3v5NMtS). This little
scamp (the capacitor, not Paul) is about
30 × 30 × 30 cm (Fig.1). I’ll be removing
its current wooden box base and repurposing that for something else, but – for
the moment – observe the drive belt on
the left. Paul removed the end stops that
limited the motion of the moving part of
the capacitor. This means it’s now free
to continuously rotate around, which is
going to look mega-impressive. I don’t
like to boast (I take enormous pride in
my humility), but I bet my variable capacitor is bigger than yours!
Another thing I know is that the Sewing
Engine is going to flaunt five humongous
vacuum tubes, like those perched on
top of the Prognostication Engine (the
tallest of which is 13-inches from tip
to tail). I acquired these tubes, which
are no longer functional, for a pittance
several years ago from a local electronics store that was going out of business,
and I’ve been waiting for an occasion to
use them ever since.
In the case of the Prognostication
Engine, there is a metal band around
the base of each tube (for the Sewing
Engine, I’ll be using cunning 3D printed
bands that were designed by my chum
Steve Manley). Inside each band is a
strip of 30-or-so WS2812 tricolor LEDs.
Way back in the mists of time, I started
by lighting these LEDs with static values,
but the resulting display turned out to be
almost impossible to perceive in regular
ambient lighting conditions. Next, I experimented with dynamic effects, such
as having lit pixels chasing each other
around the bands (Fig.2).
The human eye is incredibly sensitive to motion, so the effect is quite startling, to the extent that the structures
inside the tubes sometimes appear to
be rotating in the opposite direction.
To let you see what I’m waffling about,
I just took a quick video in my office:
https://bit.ly/3ax6EZu
In addition to displaying various
random sequences, I may also decide
to make these LEDs respond to sound,
Fig.2. Using LEDs to give old vacuum
tubes a new lease of life.
Practical Electronics | December | 2021
Fig.3. A cheap-and-cheerful 3-phase 12V motor controller.
but that will be a story for another day
and a future column.
Motoring along
Returning to my variable capacitor, one
end of the drive belt is attached to a
sprocket on a shaft that drives the capacitor, while the other end is affixed to
a sprocket on a shaft driven by a motor
that’s lurking in the wooden base.
I vaguely remembered Paul telling me
that this was a 12V motor, but that was
about it, so you can only imagine my
surprise when I looked inside the base
to find a small gear and motor combo
about 1.5 inches in diameter and 4 inches
long. Actually, that wasn’t the surprise.
The surprise was the fact that there were
three wires coming out of the motor. ‘Ah
Ha!’ I thought, ‘What we have here is a
3-phase brushless motor.’
The advantage of brushless motors is
that they are extremely quiet, both physically (audibly) and electrically (in the form
of electromagnetic noise). The downside
is that they are a right #$%$#$ to control
if you wish to build your own controller
from the ground up. Fortunately, you can
purchase a cheap-and-cheerful controller from eBay (https://bit.ly/2YLSLUi), so
that’s what I did (Fig.3).
I remembered that Paul used four of
these motors to drive the drums on the
front of his legendary Bombe clock (https://
bit.ly/3p0tH76), which is a replica of Alan
Turing’s ‘Bombe’ that helped British Intelligence officers decipher messages coded
by the German Enigma Machine during
WWII. I once saw this marvelous machine
in action, and you couldn’t hear a whisper from the motors.
Is there a doctor in the house?
One of the problems with the control board
for the 3-phase motor is that it doesn’t
appear to be geared up (no pun intended)
to be controlled from a microcontroller.
The jumper to the right of the far side of
the board can be used to control the rotational direction of the motor, while the potentiometer on the lower left-hand side can
be used to control its speed. If I wanted to
Practical Electronics | December | 2021
Fig.4. The Dr.Duino Explorer (Image source: Guido Bonelli).
control this using an Arduino Uno, for example, I’m wondering if I can use a regular
digital input/output signal to replace the
jumper and a resistor-capacitor-smoothed
pulse-width modulated (PWM) output to
replace the potentiometer.
One of my ‘go-to’ boards when I’m
prototyping something like this is the
Dr.Duino Explorer (https://bit.ly/2YSrIat),
which was created by my chum Guido
Bonelli. This is an interesting board in
that it can act as a shield that you plug on
top of an Arduino Uno, or you can skip
the Uno and plug an Arduino Nano into
the Explorer, as shown in Fig.4.
Instead of using a regular breadboard
and fighting your way through a rat’s nest
of wires, the Explorer provides most of
what you need to prototype a bunch of
projects, like my attempt to control my
motor controller board, for example.
The Explorer provides four pushbutton
switches, three potentiometers, a lightdependent resistor (LDR), four red LEDs,
and a bunch of current-limiting resistors.
The shield also features a piezo buzzer
and a stick of eight NeoPixels. Furthermore, there’s an organic LED (OLED)
display in the upper right-hand corner
of the board; a very handy area where
you can add discrete components and
integrated circuits in the bottom righthand corner; and a rather meaty voltage
regulator just below the OLED display.
But wait, there’s more, because in addition to a small breadboard, there are
pins into which you can plug a variety
of I2C-based sensors and actuators (an
ultrasonic ranging sensor, not shown
here, is also included).
One thing I should perhaps point out is
that Dr.Duino Explorer is a kit that you assemble following the step-by-step online
instructions that are accompanied by gorgeous high-resolution photos. These are
the most comprehensive, intuitive and
user-friendly instructions I’ve ever seen,
and I don’t say that lightly.
of unnecessary investigation or experimentation. The later addition of, ‘but
satisfaction brought it back’ indicates
that the risk would lead to resurrection
because of the satisfaction felt after finding out. But none of this is what I wanted
to talk about.
I’ve said it before, and I’ll say it again
– it’s strange how disparate ideas from
different sources sometimes seem to
come together at the same time. A couple
of weeks ago, for example, I received a
rather enigmatic image of a curious cat
construct from my chum Alvin in the UK
(Fig.5). Alvin and I co-authored a couple
of books together, including How Computers Do Math (https://amzn.to/3iYNAYH)
and we like to keep each other abreast
of our current projects, but this one was
new to me, so I asked him to expound,
explicate and elucidate.
Alvin responded with a video, which
is when I first realised that the eyes
appear to move (https://bit.ly/3DHiMDM).
Alvin went on to explain that he used
the OLED displays from an Adafruit
Monster Mask (https://bit.ly/3ayvLen)
to implement the cat’s eyes, and that
he’d augmented these displays with
40mm convex plastic lenses (https://bit.
ly/3azM7mP). Alvin tells me that the
displays come with software accompanied by a configuration file that allows
you to customise them to look like cat,
snake, or human eyes. He also picked up
Feeling satisfied?
The old idiom-proverb ‘Curiosity killed
the cat’ is used to warn of the dangers
Fig.5. An enigmatic cat (Image source:
Alvin Brown).
43
P in io n
R a c k
Fig.6. A rack and pinion gear assembly.
a blank cardboard cat mask from Hobbycraft (https://bit.ly/3AHPJOf), which he
then painted himself. He says the result
is approximately 6 × 6 inches in size.
Seeing Alvin’s cat’s eyes move made
me think of the SMAD (Steve and Max’s
Awesome Display) eyes on my pseudo
robot heads. As I mentioned in my previous column (PE, November 2021), Steve
and I have been planning on making the
SMADs appear to look to the left, right,
up and down by activating different
groups of pixels.
I was happily cogitating and ruminating on this when Alvin sent me one final
email saying that he’s thinking about
future enhancements, including adding
a sensor to detect motion and a servo to
turn the head towards the detected object.
I’d no sooner started to mull over this
new piece of intelligence when, much
to my surprise...
Robots rising
...I received a call from our illustrious
publisher here at PE. Yes, the person
on the other end of the phone was none
other than the man, the myth, the legend
(in his own extended lunchtime), Matt
Pulzer (cue fanfare of sarrusophones).
I’m not sure if he’d been reading (what
I laughingly call) my mind, but Matt said
he’d been thinking (I manfully managed
to choke back a response) that it would
be cool to add some form of motion to my
robot heads. In addition to being able to
look left, right, up, and down, Matt even
suggested the possibility of using some
form of linear actuator such as a solenoid
or rack-and-pinion assembly to give the
SMAD eyes the ability to ‘pop out’ (move
forward and backward).
Just to refresh our minds, a solenoidbased linear actuator involves a wire
wrapped around a ferromagnetic core. If
current is passed through the wire, the
core will act like a magnet with north
and south poles. The clever part is if the
core is only partially inserted into the
coil, in which case activating the current
will cause the core (officially called the
‘plunger,’ in this case) to be pulled into
the coil. This motion can be used to pull
or push a load, like our SMAD eyes, for
example. When the current is removed
from the wire, a spring can be used to
return the actuator to its initial position.
By comparison, a rack and pinion assembly can be used to convert the rotary
motion of a motor into a corresponding
linear action. The way this typically
works is that the high-speed, low-torque
rotation of the motor is first converted
into a lower-speed, higher-torque rotation by means of a gear train. A special
gear wheel called the ‘pinion’ is attached
to the shaft coming out of the gear train,
and the teeth on the pinion engage with
teeth on the rack (Fig.6).
Now, I’m certainly not going to tell Matt
that we aren’t going to do this (that is,
having the eyes move forward and backward). Just to be clear, we aren’t going to
do this, it’s just that I’m not going to tell
Matt – it’s just our little secret. However,
we are going to give our SMAD eyes the
ability to move left, right, up, and down.
Pan-and-tilt and curved orbs
There are several parts to this puzzle.
For example, in order to perform some
short-term cheap-and-cheerful experiments, I just purchased two pan-and-tilt
mechanisms from Adafruit (https://bit.
Fig.7. Pan-and-tilt mechanism (Image source: Adafruit).
44
ly/3lIjQB1). Each of these little beauties
comes fully assembled and equipped with
two SG-90 or SG-92 micro servos that
allow the assembly to pan approximately 180° from side-to-side and tilt around
150° forwards and backwards (Fig.7).
We’ll discuss the differences between
things like servos (analogue and digital) and stepper motors in next month’s
column. Also, at that time, we will be
considering some rather cool 4-axis joysticks that we can use to control our panand-tilt mechanisms.
Returning to my existing pseudo robot
heads, you may remember that the SMADs
are used in conjunction with 3D-printed
shells. These shells, which are 10mm
thick, divide the displays into segments
(we use 29-segment and 45-segment shells
depending on the effect we’re trying to
achieve). In front of each shell, we have a
thin layer of diffuser material (we’re using
the white plastic divider sheets you find
in file folders). In front of the diffuser,
we have a 1mm-thick facia (face plate).
I talked about all of this with my SMAD
collaborator Steve Manley. The first thing
Steve thought of was that we should
create new curved facias for our SMADs
to make them look a little more eye-like
(Fig.8). From left to right this image shows
the back shell, front shell, diffuser and
curved facia. The only reason for splitting
the main shell into two 5mm slices is to
make it easier to use a spray to paint the
inside faces of the segments white (this
dramatically increases the brightness of
the ensuing display).
Although the curve of the facia is quite
subtle (only 5 mm at the center), the result
is rather startling. Apart from anything
else, the fact that the diffuser is located
behind the facia gives the segments a 3D
effect all of their own (Fig.9).
Don’t forget that, should you wish to
join in the fun and frivolity, then SMADs
are available for purchase from the PE
PCB Service (https://bit.ly/3wVUgLq)
for the remarkably low price of only
Fig.8. Exploded view of a 45-segment shell with curved facia
(Image source: Steve Manley).
Practical Electronics | December | 2021
companies will be bringing out VL53L5CX-based breakout boards (BOBs) in the
not-so-distant future. These BOBs will, of
course, be accompanied by training materials and example sketches (programs).
-.-- .- -.-- / ... -- .- -.. -.-.--
Fig.9. The new curved facias give the segments an interesting ‘depth’ (Image source:
Steve Manley).
£11.95 each, which includes shipping
in the UK (shipping outside the UK will
be quoted separately).
Also, as usual, Steve has very kindly
made the 3D print files for this new version of the shells available for anyone
who wants to print their own: download file CB-Dec21-01.zip from the December 2021 page of the PE website at:
https://bit.ly/3oouhbl
A pain in the neck!
Unfortunately, I fear I’ve unleashed a monster – Steve has leapt into this project with
gusto and abandon. In addition to having
eyes that can move from side-to-side and
up-and-down, Steve wants to extend these
capabilities to the entire robot head.
Steve’s already started work on his
eyes. I have to say that the solution he has
come up with is something I’ve never seen
before and that I would not have thought
of myself in a million years. Suffice it to
say that Steve’s solution puts my simple
pan-and-tilt mechanisms to shame.
Every time we chat on FaceTime, Steve’s
3D printer is churning away in the background as he keeps on refining his design.
I cannot wait to share all of this with you
in future columns.
Sense something strange?
Earlier, I mentioned that one of the ways
in which we can control the motion of our
SMAD eyes and robot heads is by means
of some rather cool 4-axis joysticks that
we’ll be discussing in my next column.
Another possibility will be to equip
our robot heads with some way to sense
what’s going on around them and to
respond accordingly. Well, by some
strange quirk of fate, I was just playing
with a brand new VL53L5CX Time-ofFlight 8×8 Multizone Ranging Sensor
from STMicroelectronics.
This little beauty is only 6.4 × 3.0 × 1.5
mm, which makes it significantly smaller than the size of a Jellybean (Fig.10).
The smaller aperture on the left houses
a 940nm invisible light vertical cavity
surface emitting laser (VCSEL) and integrated analogue driver. By means of an
integrated lens, the laser light spreads out
in a three-dimensional 45-degree cone.
The larger aperture on the right holds
an 8×8 receiving array of single photon
avalanche diodes (SPADs) that detect the
laser light reflected from objects up to
4m away. The ‘washboard’ structure in
the middle is used to mitigate any laser
light that’s reflected if you add a glass or
plastic cover on top of the device. Also
in the package is a low-power microcontroller that processes all of the data and
presents it on demand to a host processor via an I2C bus.
I had a lot of fun playing with this in
my office. In fact, I even took a video
(https://bit.ly/3mGOSIA). The reason
I mention this here is that I can easily
envisage using one of these sensors to
detect the presence of people, monitor
their movements, and cause our robot
heads and eyes to track them as they move
around the room. Of particular interest is
that the folks at STMicroelectronics tell
me that they are working with Adafruit
and SparkFun, and that both of these
A
K
B
C
D
G
Fig.10. VL53L5CX Time-of-Flight 8×8
Multizone Ranging Sensor (Image source:
STMicroelectronics).
Practical Electronics | December | 2021
E
M
N
O
F
Q
H
J
I
L
R
S
T
Of course there’s a reason
The reason I mention all of this here is
that I recently received an email from a
member of the PE community who we will
call Simon (because that’s his name). In
his message, Simon spake thus: ‘Hi Max,
your column in October’s PE couldn’t
have been timed better. I had in mind
a little Arduino project to implement a
Morse code trainer and I spent some time
1
U
2
V
3
W
4
X
Y
P
In 1837, the British physicist and inventor
Sir Charles Wheatstone and the British
electrical engineer Sir William Fothergill
Cooke invented the first British electric
telegraph. This instrument made use of
five wires, each of which was used to
drive a pointer at the receiver to indicate different letters.
Sir Charles was a busy man. For example, among many other things, he
took the time to invent the concertina in
1829. I sometimes wonder if Sir Charles
invented the concertina because he didn’t
have many friends, or if he ended up
with few friends because he invented
the concertina.
Also, in 1837, the American inventor Samuel Finley Breese Morse developed the first American telegraph. This
was based on simple patterns of ‘dots’
and ‘dashes’ (or ‘dits and ‘dahs’), which
we now call Morse code (Fig.11), being
transmitted over a single wire.
Morse’s system was eventually adopted as the standard technique because it
was easier to construct and more reliable
than its British counterpart.
Different people can key Morse code at
different numbers of words per minute
(WPM). However, we can standardise
things, because if we say that the length
of a dot is one unit of time, then a dash
is three units, the space between two
parts of the same letter is one unit, the
space between letters is three units, and
the space between words is seven units.
You can experiment with a translator
here: https://morsecode.world
5
6
Z
7
?
,
8
!
.
9
0
Fig.11. International Morse code.
45
pondering how I should format the data
in an array. I had come to the conclusion
that it would be better to start the data
array just as you did with the SMAD: declaring the length of data in each row first
(see below). I felt somewhat vindicated
and relieved that I was on the same track
(as it were) when I read your column, so
a *big thumbs up* to you!’
Simon went on to say that he had used
two #define statements as follows,
noting that ‘the reason for these values is
because a ‘dah’ is three times the length
of time of a ‘dit’ and I use them as the
timing structure’:
#define dit 1
#define dah 3
Based on this, Simon defined his Morse
code trainer array as follows:
uint8_t MorseAlphabet [26][5] =
{
{2, dit, dah},
// a
{4, dah, dit, dit, dit}, // b
{4, dah, dit, dah, dit,}, // c
{4, dah, dit, dit,},
// d
{1, dit},
// e
etc....
we just discussed), but I took a different
tack, as is my wont. For example, my
program commences with two definitions as follows:
#define WPM
15
#define UNIT_DELAY 1200
My unit delay is for one time unit in milliseconds assuming a transmission rate
of 1 WPM. All of the other delay values
are calculated as a function of this and
the WPM value. Thus, assuming a transmission rate of 15 words per minute, we
end up with one unit (a dot) being 1,200
/ 15 = 80 milliseconds. I also defined my
Morse code dots-and-dashes data array
in a different way to Simon, as follows:
char *DnD[] =
{
".-",
//
"-...", //
"-.-.", //
"-..",
//
".",
//
etc.
This is something we haven’t discussed
before. In this context, the asterisk * character declares our DnD variable to be a
Well, I simply couldn’t help myself. I decided to create a little program to make
my two existing pseudo robot heads have
a conversation in Morse code.
I’m not sure how Simon implemented his program (apart from the snippets
GET T
LATES HE
T CO
OF OU PY
R
TEACH
-IN SE
RIES
AVAIL
AB
NOW! LE
0 = A
1 = B
2 = C
3 = D
4 = E
pointer. Further, since DnD is an array
of type char, this means that *DnD is a
pointer to an array of strings.
To be honest, explaining the way
this works would take longer than we
have time for here. The thing is, pointers allow us to do a whole host of cool
things. If you want to know more about
these little rascals, then there’s a wonderful book called Understanding and
Using C Pointers by Richard Reese, see:
https://amzn.to/3ASgYWI
In the meantime, you can peruse and
ponder my program by downloading the
code (file CB-Dec21-02.txt) from the December 2021 page of the PE website at:
https://bit.ly/3oouhbl
Finally, for your delectation and delight,
I just took a video of all this taking place
– see: https://youtu.be/FmQf1q8dlFQ
Next time
In my next column we will look at some
more SMAD display effects. We will also
create some simple programs that allow
us to use our 4-axis joysticks to control
the servos on the pan-and-tit mechanisms,
thereby causing our SMAD eyes to move
around in interesting ways. Until then,
as always, I welcome your comments,
questions and suggestions.
Cool bean Max Maxfield (Hawaiian shirt, on the right) is emperor
of all he surveys at CliveMaxfield.com – the go-to site for the
latest and greatest in technological geekdom.
Comments or questions? Email Max at: max<at>CliveMaxfield.com
Order direct from
Electron Publishing
PRICE £8.99
(includes P&P to UK if ordered direct from us)
EE
FR -ROM
CD
ELECTRONICS
TEACH-IN 9
£8.99
FROM THE PUBLISHERS OF
GET TESTING!
Electronic test equipment and measuring
techniques, plus eight projects to build
FREE
CD-ROM
TWO TEACH
-INs
FOR THE PRICE
OF ONE
• Multimeters and a multimeter checker
• Oscilloscopes plus a scope calibrator
• AC Millivoltmeters with a range extender
• Digital measurements plus a logic probe
• Frequency measurements and a signal generator
• Component measurements plus a semiconductor
junction tester
PIC n’ Mix
Including Practical Digital Signal Processing
PLUS...
YOUR GUIDE TO THE BBC MICROBIT
Teach-In 9
Teach-In 9 – Get Testing!
A LOW-COST ARM-BASED SINGLE-BOARD
COMPUTER
Get Testing
Three Microchip
PICkit 4 Debugger
Guides
Files for:
PIC n’ Mix
PLUS
Teach-In 2 -Using
PIC Microcontrollers.
In PDF format
This series of articles provides a broad-based introduction to choosing and using a wide range
of test gear, how to get the best out of each item and the pitfalls to avoid. It provides hints
and tips on using, and – just as importantly – interpreting the results that you get. The series
deals with familiar test gear as well as equipment designed for more specialised applications.
The articles have been designed to have the broadest possible appeal and are applicable to all branches of electronics. The
series crosses the boundaries of analogue and digital electronics with applications that span the full range of electronics – from
a single-stage transistor amplifier to the most sophisticated microcontroller system. There really is something for everyone!
Each part includes a simple but useful practical test gear project that will build into a handy gadget that will either
extend the features, ranges and usability of an existing item of test equipment or that will serve as a stand-alone
instrument. We’ve kept the cost of these projects as low as possible, and most of them can be built for less than £10
(including components, enclosure and circuit board).
© 2018 Wimborne Publishing Ltd.
www.epemag.com
Teach In 9 Cover.indd 1
01/08/2018 19:56
PLUS! You will receive the software for the PIC n’ Mix series of articles and the full Teach-In 2 book – Using PIC Microcontrollers – A practical introduction – in PDF format. Also included are Microchip’s MPLAB ICD 4 In-Circuit Debugger User’s Guide; MPLAB PICkit 4 In-Circuit Debugger Quick Start Guide; and MPLAB PICkit4 Debugger User’s Guide.
ORDER YOUR COPY TODAY: www.electronpublishing.com
46
Practical Electronics | December | 2021
|