You are on page 1of 116

£9.95 | €10.95 | $12.

95

514 JULY & AUGUST 2022


ELEKTORMAGAZINE.COM
S

*
1

*
IN
CE 196

AUDIO TESTER
AN AFFORDABLE SOLUTION
Using PC-Based Software
and a USB Audio Interface

p. 06

FOCUS ON

Test &
Measurement
p. 14 AC Grid Frequency Meter
Monitor Mains Frequency and Voltage

p. 30
Get Started With
p. 18
Modest Inductance Meter Your Oscilloscope
A DIY Instrument for Your Find Your Way Through the Knobs
Workbench and Buttons

R2
C2
4k64

C1

R1

+5V
C3
8 1 D2
DRAIN U1 BP
7 2 AMS1117-3.3
DRAIN GND
6 3
F1 D1 1mH DRAIN FB
L1
5 4
L1 DRAIN C/S 2 U2 +3V3
L2
10 / 0W5 R19 R21
HP-01 2
R20

C8 C9 D3 C15 C7 C4 C5
MOV1

4µ7 4µ7 470µ


U 400V 400V 16V

220170-016

Disruption in Test and CO2 Traffic Light with Sigfox Smart Plug Teardown
Measurement Equipment No Wi-Fi Network Needed! p. 74 Which Ones Are Hacker- p. 90
p. 48
Alternatives to the Typical Friendly?
Benchtop Devices
e-zine
Your dose of electronics

Every week that you don’t subscribe to Elektor’s e-zine


is a week with great electronics-related articles and
projects that you miss!

So, why wait any longer? Subscribe today at


www.elektor.com/ezine and also receive free
Raspberry Pi project book!

What can you expect?


Editorial Promotional Partner mailing
Every Friday, you’ll receive the best Don’t miss our shop promotions, You want to stay informed about
articles and projects of the week. every Tuesday and Thursday we the ongoing activities within the
We cover MCU-based projects, IoT, have a special promotion for you. industry? Then this e-mail will give
programming, AI, and more! you the best insights. Non-regular
but always Wednesdays.
colophon editorial

Elektor Magazine,
English edition
Jens Nickel
Edition 5/2022 International Editor-in-Chief, Elektor Magazine
Volume 48, No. 514
July & August 2022

ISSN 1757-0875 (UK / US / ROW distribution)

www.elektor.com
www.elektormagazine.com Measuring Does Not Have to be Expensive
If you measure, you measure crap: Every student of a technical or scientific discipline experi-
Elektor Magazine, English edition ences this at the latest during his or her first relevant internship — and that’s how it should
is published 8 times a year by be. The experience of the user and sound background knowledge cannot be replaced by any
Elektor International Media instrument.
 
Head Office:
Elektor International Media b.v. That’s why we’re once again offering the typical mixture of practice and theory on this import-
PO Box 11 ant topic. My colleague Clemens Valens introduces beginners to the use of oscilloscopes. In
6114 JG Susteren his article “Inexpensive Audio Measurement Station,” Alfred Rosenkränzer combines his
The Netherlands professional specialization in measurement technology with his passion for audio. A good
Phone: (+31) 46 4389444
USB audio interface, a PC and inexpensive measurement software are enough to get a more
Memberships:
than usable solution for measurements on hi-fi systems, (do-it-yourself) speakers and other
E-mail: service@elektor.com equipment. The engineer, who also proves his good judgement with various measurements,
www.elektor.com/memberships only wishes for a notch filter in front of the input of the interface. This will be added in one
of the next issues!
Advertising & Sponsoring:
 
Raoul Morreau
Phone: +31 (0)6 4403 9907
Beyond that there are of course again a lot of projects with practical use. In this issue you will
E-mail: raoul.morreau@elektor.com find a measuring device for the mains frequency as well as one for the series resistance of
capacitors. Plus, an inductance meter that’s easy on the wallet, and much more!
www.elektor.com/advertising
Advertising rates and terms available on request.

Kurt, We Will Miss You!


Copyright Notice It came as a shock to all of us that our long-time colleague
The circuits described in this magazine are for Kurt Diedrich passed away unexpectedly in April. Kurt was an
domestic and educational use only. All draw- editor at Elektor in the eighties; since then, he has remained
ings, photographs, printed circuit board layouts,
programmed integrated circuits, disks, CD-
loyal to us as a contributor for all these decades. A geology
ROMs, DVDs, software carriers, and article texts graduate, he wrote books and articles, translated entire issues
published in our books and magazines (other (most recently our sister magazine MagPi), and brought
than third-party advertisements) are copyright
schematics and other drawings into the famous Elektor style.
Elektor International Media b.v. and may not be
reproduced or transmitted in any form or by any In his spare time, the music lover built analog synthesizers and
means, including photocopying, scanning and picked up the guitar. Kurt, we will miss you!
recording, in whole or in part without prior writ-
ten permission from the Publisher. Such written
permission must also be obtained before any
part of this publication is stored in a retrieval
system of any nature. Patent protection may
exist in respect of circuits, devices, components
The Team
etc. described in this magazine. The Publisher
International Editor-in-Chief: Jens Nickel
does not accept responsibility for failing to
identify such patent(s) or other protection. The Content Director: C. J. Abate
Publisher disclaims any responsibility for the International Editorial Staff: Eric Bogers, Jan Buiting, Stuart Cording, Rolf Gerstendorf,
safe and proper function of reader-assembled Alina Neacsu, Dr Thomas Scherer
projects based upon or from schematics,
Laboratory Staff: Mathias Claussen, Ton Giesberts, Luc Lemmens, Clemens Valens
descriptions or information published in or in
Graphic Design & Prepress: Giel Dols, Harmen Heida
relation with Elektor magazine.
Publisher: Erik Jansen

© Elektor International Media b.v. 2022


Printed in the Netherlands Elektor is a member of FIPP, an organization that has “grown over almost 100 years to
include media owners and content creators from across the world.”

Elektor is a member of VDZ (Association of German Magazine Publishers), which


“represents the common interests of 500 German Consumer and B2B publishers.”

lektor July & August 2022 3


THIS EDITION
Volume 48, No. 514
July & August 2022

Low-Cost Audio Tester


Using PC-Based Software and
a USB Audio Interface

Regulars FOCUS
3 Colophon
86 Low-Budget Tablet Oscilloscope ADS1013D
25 Starting Out in Electronics Good Value for the Money?
Rectifiers
100 Skin Impedance and Skin Capacitance
28 electronica fast forward 2022 Small Experiments

68 Peculiar Parts FOCUS


Reed Relays 106 Pokit Meter Review
A Swiss Army Knife of Test Gear
84 Ethics
Women in Tech

Industry
104 From Life’s Experience
No Local Business
114 Hexadoku
FOCUS
The Original Elektorized Sudoku
48 Disruption in Test and Measurement Equipment
Innovation from the Smaller Players

Features
FOCUS
54 Infographics
Facts and Figures About Test & Measurement
22 Acoustic Wave Hovering 56 Inspiration, That’s What It’s All About
A Look at the Makerfabs Acoustic Levitation Kit Interview with Entrepreneur Walter Arkesteijn
of InnoFaith Beauty Sciences
FOCUS
30 Get Started With Your Oscilloscope 58 Minimizing EMC Interference from Storage Chokes
Find Your Way Through the Knobs and Buttons

FOCUS
42 Moisture Sensors for Watering Systems Low-Budget Tablet
Automatic Watering
Oscilloscope
61 GUIs with Python (Part 5) ADS1013D
Tic-Tac-Toe

86
4 July & August 2022
Get Started With
R2
C2

4k64
C1

Your Oscilloscope
R1

Find Your Way Through the Knobs and Buttons 8


DRAIN U1 BP
1
C3
D2
7 2 AMS
DRAIN GND
6 3
F1 D1 1mH DRAIN FB
L1
5 4
L1 DRAIN C/S 2
L2
10 / 0W5 R19 R21
HP-01 2

Smart Plug
R20

C8 C9 D3 C15 C7 C4
MOV1

Teardown
30 90
4µ7 4µ7 470µ
U 400V 400V 16V

N Which Ones Are Hacker-Friendly?

Projects Next Edition


FOCUS Elektor Magazine Summer Circuits 2022 Edition
6 Low-Cost Audio Tester (August & September​2022)
Using PC-Based Software and a USB Audio Interface In the tradition of the Summer Circuits Guide, next edition will be
extra thick, filled with more than 50 DIY-projects, background articles
FOCUS
about PCB design, tips and tricks and much more!
14 AC Grid Frequency Meter
Monitor Mains Frequency and Voltage
From the contents:
18
FOCUS
A Modest Inductance Meter
> Battery-Free Radiator Sensor
An Affordable Solution for Your Workbench
> Current Source for LEDs
> Tiny Frequency Reference
34 Raspberry Pi Pico Makes an MSF-SDR > Sound Activated Switch
Decode a Time Signal with a Raspberry Pi Pico SDR > Low Noise ADC Calibrator
FOCUS
> Power Semiconductor Tester
70 Simple Analog ESR Meter
> DC/DC Boost Converter
With Moving-Coil Meter Precision
> Digital 220-V AC Dimmer with Arduino
And much more!
74 Sigfox CO2 Traffic Light
No Wi-Fi Network Needed!
Elektor Magazine Summer Circuits 2022 edition will be published
90 Smart Plug Teardown around August 4, 2022. Arrival of printed copies with Elektor Gold
Which Ones Are Hacker-Friendly? Members is subject to transport. Contents and article titles subject
to change.

Acoustic
FOCUS ON
Wave
Hovering
Test &
22 Measurement
lektor July & August 2022
analog

Low-Cost Audio Tester


Using PC-Based Software and a USB Audio Interface
By Alfred Rosenkränzer (Germany)

Professional-grade equipment for characterizing and developing audio equipment is usually


beyond the means of a hobbyist lab. However, it is possible to obtain measurement software
and a high-quality audio interface for relatively little cash, and in conjunction with a PC
this can create a more than adequate solution for measurements on Hi-Fi devices and other
audio hardware. This article looks at how that works out in practice.

Figure 1: Spectrum of a 1 kHz sinewave at 1 VRMS (0 dbV), generated Figure 2: Compare with Figure 1: spectrum of a 1 kHz sinewave at
and measured using the Audio Precision APx555. 1 VRMS using the Steinberg UR22.

 
The inspiration for this project began after Considerations Most professional test equipment of the early
I had spent over 20 years working in a A search on eBay for second-hand profession- third millennium more or less takes the form
high-tech design company surrounded by al-level test equipment quickly revealed the bad of a black box, with no user controls. The
top-notch test equipment, including for audio news. Even units more than ten years old, long unit is controlled and its results processed
measurements. Suddenly this period came to out of manufacturer’s support, were going for using software running on a PC. Why should
an end and my options for making a quick test over a €1,000. New equipment with the specifi- things be any different in the hobby world? So
or measurement became severely limited. I cations I was looking for started at a little under I started off by looking for suitable software
was rudely separated from the professional €10,000, which seemed totally out of propor- for making audio measurements.
equipment that I had been used to, not just by tion to what I was trying to achieve with them. I  
the distance between home and workplace therefore had to try to come up with a different, My requirements for the software were that
but also by the effects of the coronavirus. and above all more affordable, solution. it should work with both internal hardware

6 July & August 2022 www.elektormagazine.com


 
Next, I started to look for a higher-quality
external audio interface with a USB connec-
tion. I wanted a device with XLR connec-
tors for differential signals (‘balanced’) and
Figure 3: Front panel of the Steinberg UR22C.
phono or jack sockets for signals referenced
to ground (‘unbalanced’). The BNC connec-
tors typically found on instrumentation are
rather rare on this kind of interface. That is
not an obstacle, however, as suitable adapt-
ers are available. A headphone output makes
it easy to verify the audio signal. Input and
output levels must be controllable either on
the interface itself or at a minimum using the
accompanying software.
 
Here we at once see what is perhaps the
biggest disadvantage of this type of solution
compared to its professional counterparts,
whose input and output levels are calibrated
in V or dBV. If we set a given level in the
software then that is the level that comes out
of the sockets of the generator. The software
controls the device to generate the desired
level at the best possible quality. The input can
Figure 4: Compare with Figures 1 and 2: spectrum of a 1 kHz sinewave be configured either automatically or accord-
at 1 VRMS using the Steinberg UR22C.
ing to the expected input level.

Levels
and with external hardware connected over manual, available in both English and German. The AudioTester software allows the output
USB. I wanted it to be able to measure total The free trial version offers all the features of level to be set in dBFS (dB full scale) — that
harmonic distortion (THD) and signal-to-noise the software for one month, the only limitation is, in decibels relative to the maximum output
ratio (SNR) as well as frequency response. being that the program automatically termi- level of the DAC. The actual level at the output
Furthermore, the signal generator part of nates a measurement after ten minutes. To of the interface must then be set either directly
the system should at a minimum be able continue, the software must be restarted. Since on the interface itself or using its accompany-
to produce sine, square and noise signals. it remembers its most recent settings, you can ing software. That requires a way to measure
It must be possible to sweep the sine wave carry on immediately from where you left off. the level externally (for example, with an
output in frequency. Other waveforms such   oscilloscope). Unfortunately, the AudioTester
as triangle and pulse were not a sine qua non, A licence costs a reasonable €39. After experi- software cannot set the output gain of the
but nevertheless nice to have. These options menting for a couple of days, I bought a licence interface directly.
are straightforward to implement in software from the developer and received a key file to  
and so add little to its complexity or cost. unlock the software. At this point my search for This difficulty also affects the input. Towards
  a suitable software solution was over. Perhaps the top of the window, there is a kind of drive
The software must be able to acquire a signal you will find other useful programs? If so, feel level indicator for the ADC. By adjusting the
from the audio input and display it. The avail- free to get in touch with me via e-mail. gains on the interface or in its software, we
able frequency range must cover at least the can make sure that the ADC is adequately
audio band from 20 Hz to 20 kHz, and a wider Hardware driven, but not overdriven.
bandwidth is desirable. Digitization should be For my first tests, I used my PC’s internal
possible at sample rates of 44.1 kHz, 48 kHz audio hardware in loopback: I connected a Signal Generators
and their multiples up to at least 192 kHz. mini-jack cable directly from the audio output I first measured the output of the internal
to the line input (not the microphone input). sound card using a professional instrument
Software Since this was using the audio circuitry built (an Audio Precision APx555). Figure 1 shows
During my search, the software package into the PC’s motherboard, my expectations the output from the APx555 in purple: there
AudioTester V3.0 caught my eye. It runs under were not exactly high. The results, however, are no harmonics to be seen and the noise
Windows XP and later versions, and can be were not too bad, although not good enough floor is at around –150 dBV. The blue plot
downloaded for free at [1] along with its for my purposes. shows the output of the sound card. The

lektor July & August 2022 7


strongest harmonic is at 3 kHz with an ampli-
tude of –98 dBV. The noise floor is some 20 dB
above that of the APx555. These results are
remarkably good for an internal sound card.
 
That statement is particularly true in compar-
ison to the Steinberg UR22 external interface.
As Figure 2 shows, the 3 kHz harmonic from
this device has a higher amplitude at –87 dBV.
Figure 5: RME Babyface Pro
 
(Photo: RME).
I borrowed the newer version of this interface,
the UR22C, for a further comparison. Figure 3
shows its front panel and the results of the
measurement can be admired in Figure 4. The
pattern of harmonics observed depends on
the sample rate chosen for the ADC. Further
tests, including on a Zoom R16 interface,
resulted in similar spectra which need not
be displayed here.
 
The main conclusion from this is that the
results from external interfaces are not exactly
convincing. I therefore consulted some techni-
cally-inclined friends, and the RME Babyface
Pro FS [2] was recommended to me. The
Steinberg device costs around €150; the
RME interface is much more expensive, at
€709. Figure 5 shows the appearance of this
interface; further information can be found,
for example, on Thomann’s website [3].
Figure 6 shows what you get for your money: Figure 6: Compare with Figures 1, 2 and 3: spectrum of a 1 kHz
the second harmonic is at –120 dBV! At a sinewave at 1 VRMS using the RME Baby Face Pro.
reduced output level of 0.25 VRMS it disap-
pears into the noise.

Audio Inputs
The second step was to connect the
high-quality output signals of the APx555 to
the audio inputs of the RME interface, display-
ing the result using AudioTester (Figure 7).

Figure 7: 1 kHz sinewave at 1 VRMS generated by


the APx555 and measured using the input of
the RME interface and the AudioTester software.
Towards the top of the window is the drive level
indicator for the ADC.

8 July & August 2022 www.elektormagazine.com


The spectra obtained using the same test on
the internal sound card and on the Steinberg
interface are poorer and not shown here.
 
Next, some loopback measurements were
taken between the inputs and outputs of the
same interface. Figure 8 shows the behaviour
of the RME interface and Figure 9 that of the
Steinberg UR22. In the interest of fairness,
we should remark that the spectra change
depending on the sample rate and drive level
Figure 8: Loopback on the RME Babyface Pro at a sample rate of 192 kHz. of the ADC, but one thing remains constant:
the RME interface performs better under all
settings.
 
To test the frequency response, we can
generate a white noise signal and examine
the resulting spectrum, or we can use a
sinewave frequency sweep. Figures 10,
11 and 12 show the frequency response of
the RME interface at sample rates of 48, 96
and 192 kHz, all measured using white noise.
From Figure 12, we can see that the response
is flat out to approximately 90 kHz, which tells
us that measurements well beyond the normal
audio range are possible.

Operation
The RME interface can be controlled to some
Figure 9: Loopback on the Steinberg UR22 at a sample rate of 48 kHz. extent using its buttons and control knob.
Unfortunately, it is not possible to enable the
48 V phantom power supply or the attenuator
pad on the inputs in this way.
 
For full control of the interface, it is neces-
sary to install the ‘RME TotalMix’ software.
This software will automatically be launched
when the interface is connected to the PC.
This software allows us to set not just levels,
but also includes a parametric equalizer and
more besides. It is essential to read the
manual, and on YouTube there is a number
of videos explaining the fine points of the
interface.
 
Figure 13 shows the user interface of the RME
software. The dialogue box shown in Figure 14
lets you configure the basic settings such as
choice of input, sample rate and so on. This
latter value must agree with the sample rate
Figure 10: Frequency response of the RME Babyface Pro at a sample rate of 48 kHz. configured in the AudioTester software, or else
errors or possibly unwanted tones will appear
in the spectrum.

lektor July & August 2022 9


channel count for input and output. The Setup
button just to the right of Sound on can be
used to select the waveform, the DAC drive
level, the frequency and in some cases other
parameters. Sound on enables the output.
The output level can now be checked using
an oscilloscope and the level settings on the
interface adjusted as desired.
 
The Start button begins a measurement.
Figure 11: Frequency response of the RME Babyface Pro at a sample rate of 96 kHz. The adjacent Setup button allows a choice
of various window functions and FFT lengths.
Increasing Averages reduces noise at the
expense of increased measurement time.
 
In the Analyze Dialog under Analyze, you
can configure automatic measurements. For
example, you can define how many harmon-
ics are taken into account in the computation
of THD. The results of the measurement are
displayed under the graph.
 
We will not look into the 3D FFT Waterfall Plots
menu item. The third button enables Sweep
Measurements (for example for frequency
response measurements), with parameters
being configured under Setup. Right-clicking
on the graph will change the display.
Figure 12: Frequency response of the RME Babyface Pro at a sample rate of 192 kHz.  
A practical application is shown in Figure 15.
Here we are determining the frequency
response of two Butterworth filters (a 1.2 kHz
  lowpass and a 2 kHz highpass). Figure 16
The RME interface can be powered over USB select 2D FFT in the upper selection box shows the hardware setup. The single-ended
or using an external 12 V power adapter. Since and the screen should resemble Figure 8. connections on the right-hand side of the
the current draw over USB is around 500 mA, The Options menu item can now be used to RME interface are used.
the use of an external supply is recommended select the interface that will be used for input  
when using a laptop to reduce the load on and output. If the internal sound card of the The fourth menu item, Impedance Magnitude,
the USB connection. If an external switching PC is not shown, then try plugging cables into lets you display impedance as a function of
supply is used its switching frequency should the relevant sockets. If several interfaces are frequency, for example of a loudspeaker with
be above the audio range. available, different ones can be chosen for or without a crossover circuit. Resonances
input and output. are shown very clearly. For such a measure-
Using the Measurement   ment a power amplifier is of course required
Software Finally, under Options, you can configure to drive the loudspeaker and the two inputs
After installing and launching the software, parameters such as the sample rate and must be connected, along with a power

WEB LINKS
[1] Software AudioTester: http://www.audiotester.de
[2] Audio interface: https://www.rme-audio.de/babyface-pro-fs.html
[3] Information on the RME interface: https://www.thomann.de/gb/rme_babyface_pro_fs.htm

10 July & August 2022 www.elektormagazine.com


resistor, according to the diagram in the
documentation.
 
The Thiele Small Parameter Measurement
menu item will not be discussed here. The
next item, Distortion Measurement vs.
Frequency can be used to see how distor-
tion varies as a function of frequency.
 
The next menu item is dedicated to measur-
ing distortion as a function of amplitude. Here
we need to take note that the AudioTester
software can only control the DAC drive level;
it does not have access to the level control
of the audio interface. At low levels, there-
fore, the digital resolution will be reduced,
which increases distortion. Before making
measurements on a circuit you should test
the behaviour of the system using loopback.
Alternatively, you can adjust the level manually
in the interface and keep the digital drive level
of the DAC constant.
 
As well as lacking well-defined absolute
output levels, the audio interface also omits
an important element that practically all
professional audio instrumentation includes:
an adjustable notch filter. This can be used
Figure 13: Screenshot of the user interface of the RME Babyface Pro software. to attenuate the fundamental of a signal and
thereby analyze the other parts of the signal

Figure 14: Basic settings of the Figure 15: Frequency responses of a 1.2 kHz lowpass filter and a 2 kHz highpass filter
RME Babyface Pro. (both Butterworth), logarithmic frequency axis.

lektor July & August 2022 11


Figure 16: Test setup using the
RME interface with external 12 V
supply and the two filter boards.

(harmonics, non-harmonic tones and noise) quality of its signals and of the measurements
to greater accuracy. It also helps to reduce I made with it is convincing. About the Author
the harmonics introduced by the ADC itself 200604-01
when driven at a high level. An external notch Alfred Rosenkränzer worked for many
filter could be added if these advantages are years as a design engineer, originally in
important in your application. the field of professional television technol-
  Questions or Comments? ogy. Since the end of the 1990s he has
Within the confines of this article it is of If you have technical questions feel free been developing high-speed digital and
course impossible to do more than scratch the to e-mail the author at analogue circuity for IC testers. Audio
surface of the capabilities of the AudioTester alfred_rosenkraenzer@gmx.de technology is his private passion.
software. To find out more you can experi- or the Elektor editorial team at
ment or you can delve into the documenta- editor@elektor.com.
tion. And you can try out everything you need
in advance, and the licence is in any case
reasonably priced, so you have nothing to lose.
 

Measurement Features RELATED


The AudioTester V3.0 software offers all the PRODUCTS
measurement features that I need, and a
few more besides. It seems stable and there
appear to be few bugs. Everything can be > The Complete Linear Audio Library
(USB Stick) (SKU 19672)
tried out before purchasing a licence, which www.elektor.com/19672
at €39 is very good value. It is compatible with
both internal sound cards and all the external > Designing Audio Power Amplifiers
USB audio interfaces that I was able to try. (2nd Edition) (SKU 19150)
The RME Babyface Pro is indeed considerably www.elektor.com/19150
more costly than the other interfaces, but the

12 July & August 2022 www.elektormagazine.com


Join the
Elektor C mmunity
Take out a G O LD
membership
membership!

The Elektor web archive from 1974! An online Elektor LABs account, with
6x Elektor magazine (Print) access to more than 1000 Gerber files
9x Digital (PDF) including and a direct line of communication with
Elektor Industry (EN) magazine our experts!
A 10% discount in our web shop and Bring a project to publication or even sell
exclusive offers it in our shop
Elektor’s annual DVD-ROM

Also available Access to Elektor’s web archive


10% discount in our web shop
The Digital G R E E N membership
6x Elektor magazine (PDF)
Exclusive offers
membership! Access to more than 1000 Gerber files

www.elektor.com/member
project

AC Grid Frequency Meter


Monitor Mains Frequency and Voltage

r- L a b s . c o
to
m

Figure 1: Dieter
k
Ele

Laues’s design
with its
OF grid frequency
BEST
LED bar displa
y.
m
co

le s.
E

kto
r- L a b

 
By Mark Stevenson (United Kingdom)
The National Grid is compelled in the UK troller instead of the AVR in Dieter’s project.
The frequency of the mains to maintain the frequency of the supply to The LED bar from the old design is replaced
±1% of the nominal frequency of 50 Hz, with an LCD, and my meter also displays the
voltage is a good indicator these limits being 49.5 Hz and 50.5 Hz. mains voltage. It should be noted however
of the grid’s load. This grid However, it aims to keep this to within that this device shows trends of the power
frequency meter not only ±0.2 Hz normally (49.8 Hz ... 50.2 Hz). A grid values. It should not be regarded as a
very large power cut across parts of the UK highly accurate device measuring mains
monitors this important was caused by these limits being exceeded. voltage and frequency.
parameter of our AC line Two large generating plants failed almost
supply, but also the mains simultaneously and the sudden loss of Hardware
supply caused the remaining power plants The schematic diagram of the grid
voltage. to become excessively loaded, lowering frequency meter is shown in Figure 2. An
  the frequency. To keep within the operat- AC plug-in power pack of 9 V ... 12 V RMS
A few years ago, I saw an article in Elektor ing limits, large parts of the country were AC is connected to K1. C1 filters any high
by Dieter Laues which showed how you essentially unplugged to allow the remain- frequency noise. D2 half wave rectifies
can determine the load on the National ing plants to continue to work. Reserve the supply to 5 V regulator IC1, two 470 µF
Grid electricity supply by measuring the power was brought online and power was capacitors smooth the supply. C5 (and C2, C3)
frequency of the supply [1]. In short: the eventually returned. supply the processor for long enough in the
greater the load, the more it slows down the   event of a power failure to record the loss of
generators and so the lower the frequency I built the original meter (Figure 1) when voltage in EEPROM. R5, R8 and R9 pull up
of the supply; the lighter the load, the the project was just published. Some years the NO momentary calibrate switch and the
faster the generators and the higher the later, I decided to make my own version 120 V/220 V solder links to 5 V. If neither of
frequency. with a Microchip Technology PIC microcon- the links are soldered, the voltage scaling

14 July & August www.elektormagazine.com


defaults to 240 V. So the output voltage of when viewed close up. If this becomes Software
the AC power pack is used as a measure irritating, C8 could be increased. R2 and A new design needed new software. After
for the mains voltage; not a highly precise R4 should be adjusted to provide the correct some thought, I found a way to measure
measurement, but safe and accurate enough current limiting for the LCD fitted. the period of a pulse using a PIC device on
to monitor AC grid voltage variations.   the Great Cow BASIC forum [3]. I used the
  The microcontroller (IC2) is a PIC16F1825 Open Source compiler for 8-bit PICs, AVRs
Both the voltage and frequency inputs are running at 32 MHz. The LCD is connected in and LGTs Great Cow BASIC to write the code
fed from their own half wave rectifiers, D3 4-bit mode, with R/W tied to ground perma- [4]. The source code and the HEX-file for
and D4. D3 is connected to the AC input nently (write only mode). R13 is a trimmer programming the PIC16F1825 are available
through R1, which in conjunction with for contrast adjustment of the LCD. for download on this project’s Elektor Labs
D5 and R10 limits the maximum voltage page [2].
applied to the Volt_In (Pin 3) pin of the Construction  
microcontroller. Ten-turn trimmer R11 The circuit design is simplicity itself and it The period of the time that the frequency
allows the voltage to be adjusted across contains standard, through-hole compo- input pin is on for is added to the period
a reasonable range, R10 provides some nents only. It should not be difficult to build of time that it is measured to be off for.
additional attenuation when the trimmer is on prototype board or breadboard if you The reason for this is that the transistor
at its highest value. D4 connects to the base don’t want to have a PCB made. Several PCB that is used to shape the half cycle derived
of the pulse shaping transistor through R3. layouts were made for this project, most from the AC power supply gives a slightly
C4 filters any noise on the AC supply, this photos in this article and on Elektor Labs asymmetrical on pulse. By measuring the
does cause some sloping of the pulse, but show a version with an extra large LCD that (equally asymmetrical) off pulse and adding
this is compensated for within the software I took out of a discarded device; the bottom them together corrects for this. A timeout
by measuring both the on and off periods (copper) side of the board is used as front is provided so that, should the incoming
of the pulse. panel for the grid frequency meter. There supply fail due to a power cut, the meter
  are Eagle design files and gerbers available does not lock up waiting for the next on
D1, R2, R4 and C8 provide a supply for the for download on Elektor Labs [2] for either or off pulse to be counted. The frequency
LCD backlight. This half wave rectified standard 16 x 2 LCDs or the larger LCM1602 is averaged for 20 counts. This makes the
voltage can cause the backlight to flicker version. displayed frequency far more stable. The

+5V Vin

DIS1 LCD 16x2


D1
Vin +5V
R13
10k
CONTR

1N4007
LED+
LED–
GND
VCC

R/W

+5V
RS

D0
D1
D2
D3
D4
D5
D6
D7

R2
E

D5
R1 R6 R8 R9 R5
47

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
3k3

10k

10k

10k
1k5

C7
100n
R4
1N4148
D3 D4 +5V
47

1 14
VDD GND
2 13
1N4148 1N4148 RA5 RA0
3 12
RA4 IC2 RA1 C8
4 11
C6 RA3 RA2
R11 5 10
RC5 RC0 470µ
10k 6 9 25V
100n RC4 RC1
7 8
RC3 RC2

T1
+5V Vin
120V 220V S1 PIC16F825 D2
R12 R3 R7 R10 7805DT 1N4007
47k

2k2
1k5

10k

IC1
C4 K1
BC547 CALIBRATE C5 C3 C2 C1
100n 9...12V AC
470µ 470µ 470µ100n
25V 25V 25V

200312-008

Figure 2: This project’s schematic diagram.

lektor July & August 2022 15


Figure 4: Undervoltage event display.

Figure 3: The measurement display under normal conditions.

software is designed to automatically detect right of centre block changes to vertically sor. If the supply dips or drops for more than
a nominal 60 Hz supply frequency and extended “+” character, pointing upwards 500 ms, this event should be captured and
calibrate the bar graph display to centre or downwards in frequency as required. recorded. If the power cuts out totally, the
around 60 Hz. As I have no accurate means   event should be recorded, when the power is
of generating 60 Hz, it remains untested. The centre two characters of the top line returned this will be shown, with the timing
  are used for “Event” reporting. If the supply starting from the time that power returned.
Once the frequency has been measured, the voltage or frequency exceeds a limit (±5%
supply voltage is tested. The voltage applied for the voltage, ±0.6% for frequency) an Calibration
to pin 3 is a raw half wave, un-filtered AC event flag is shown, along with an indica- The processor used has its own internal
waveform. This is sampled 50 times at tor to show the reason for the event. For resonator. This is reasonably accurate, but
1 ms intervals with the peak reading used. example, a downwards arrow is shown for when trying to measure frequencies down
The peak reading taken is then scaled low supply voltage, an upwards arrow for to millihertz levels of accuracy, different
up by a factor to show the approximated excessive supply voltage. devices can show some variation. Calibra-
RMS supply voltage. The scaling factor for   tion is achieved by adding a small amount
this can be selected by soldering a pair of When an event has occurred, once a minute of correction to the timing obtained by
jumpers as noted on the circuit diagram. or so the approximate time elapsed since measuring the on and off times of the pulses
This allows for a nominal supply of 120 V, the event happened is displayed in the derived from the AC input voltage. The
220 V or 240 V to be catered for. A 10-turn unused portion of the bar graph display correction factor is stored in EEPROM and
trimmer resistor allows for the use of an AC area. This is shown as hours and minutes for needs to be be adjusted only once. Calibra-
power supply of 9 V ... 12 V RMS to be used. the initial 24-hours, then days and hours. tion is done by pressing and holding the
With the correct jumpers soldered, a peak For example, the display in Figure 4 shows Reset/Calibrate switch S1 down. The initial
voltage of 4 V applied to pin 3 should show an undervoltage event flag, a symbol that calibration value is shown for a few millisec-
the correct supply. The voltage is averaged mimics a plug being removed from its onds, then the value starts to step upwards.
for eight counts to stabilise it and give some socket, followed by downwards arrow. The The range of adjustment is from -99 through
degree of noise immunity. second line shows the event occurred one to +99. After the calibration is increased
minute ago while the grid frequency was beyond +99 it wraps back to -99. A single
What the Display Shows above nominal value: the time indication step of adjustment adds or subtracts a value
Using the most common 16 x 2 LCD, under is on the left and the bar graph occupies equivalent to ±250 µHz (microhertz!) the
normal conditions, the left side of the top the right side of the line. Had the frequency full range of adjustment being just under
line shows the grid voltage, the frequency is been below the nominal, the event time ±250 mHz (millihertz). If you have access to
displayed across the six rightmost charac- would be positioned in the right hand side a stable signal generator capable of resolu-
ters, as in Figure 3. The bottom line of of the bar graph area. tion (and accuracy) down into the low milli-
the LCD displays a bar graph which shows   hertz, you could use that, with D4 removed
segments lit progressively from the centre. The voltage events are automatically and the signal fed directly to pin 5 of IC2.
Segments lit from the centre towards the cleared after seven days, frequency events More practical is to wait until the early hours
right show that the frequency is above the are cleared after ten minutes. Events can be of the morning (2 AM to 3 AM) and assume
nominal value, from the centre towards manually cleared by pressing the Calibrate that the frequency and load on the grid is
the left show that the frequency is lower button briefly. The software will attempt balanced and then set the meter to read
than the nominal value. Each segment to store the most recent event in EEPROM. the nominal grid frequency, either 50 Hz
represents a 25  mHz step. With eight This is most likely to be a low voltage event. or 60 Hz. This is my favoured approach
segments in each direction this allows a When power is removed, the electrolytic and least likely to end in frustration! If set
display of ±200 mHz. When the frequency capacitors on either side of the 5 V regula- in this fashion, I would suggest keeping an
is very close to the nominal value the centre tor should maintain a supply to the proces- eye on the frequency noting whether it is
two elements each show a large square sor for at least a few milliseconds longer predominantly above or below the nominal
block character, as the frequency moves than that provided to the frequency or frequency, making slow, small adjustments
away from the nominal value, the left or voltage measurement pins of the proces- until it is.

16 July & August www.elektormagazine.com


Mains Grid Frequency Online COMPONENT LIST
If you are want to see or even follow the
Resistors
  mains frequency without buying or building
R1,R12 = 1k5
The voltage reading can be calibrated your own meter, there are some websites R2,R4 = 47 Ω
using any reasonably accurate multime- that show interesting information about the R3 = 2k2
ter, with cautions noted regarding the grid. In the UK there used to be a number R5,R8,R9,R10 = 10 k
safety requirements of measuring lethal of online resources that showed the current R6 = 3k3
voltages. If you are not confident in measur- frequency; however, often looking at these R7 = 47 k
ing high voltage, you could wait until the would show that some would lag behind R11 = 10 k trimmer, multiturn
early hours of the morning again then set the other and there was almost never a R13 = 10 k trimmer
the trimmer until the voltage displayed time when they would agree. Worse, most  
shows the nominal voltage. now seem to either have been taken down Capacitors
  or rely on outdated Adobe Flash technol- C1,C4,C6,C7 = 100 nF
There are a few comments on Elektor Labs ogy that won’t load in a modern browser. C2,C3,C5,C8 = 470 µF, 25 V radial
regarding the accuracy or relevance of using When researching this article, one site was
a processor with an internal resonator as found that seemed to be accurate in the Semiconductors
opposed to an external crystal. I have found UK [5], but it doesn’t seem to automati- D1,D2 = 1N4007
the design to be validated in usage, I have cally refresh, so the page needs constant D3,D4,D5 = 1N4148
recently been able to build my own version updating to get the current value. T1 = BC547
of Dieter Laues’ design which uses a crystal IC1 = 7805
IC2 = PIC16F1825
and ran both “mine” and “his” next to one
 
another for a number of months. At no
Miscellaneous
time did I feel that I needed to consider
S1 = pushbutton NO
redesigning mine to use a crystal derived
DIS1 = alphanumeric LCD 2 x 16
oscillator.
characters
200312-01

Questions or Comments? RELATED


If you have technical questions or For Europe, one was found that works well PRODUCTS
comments on this article, feel free to and looks to be constantly updated but we
e-mail the Elektor editorial team at can’t vouch for its accuracy [6].
editor@elektor.com. > SmartPi 3.0 Smart Meter for
Raspberry Pi (Bundle) (SKU 19953)
www.elektor.com/19953  

> PeakTech 2715 Digital Loop / PSC


Tester (SKU 19078)
www.elektor.com/19078  

> PeakTech 3445 True RMS Digital


Multimeter with Bluetooth
(SKU 18774)
www.elektor.com/18774

WEB LINKS
[1] Dieter Laues, “Grid Frequency Monitor,” Elektor Magazine 01/2012:
https://www.elektormagazine.com/magazine/elektor-201201/19793
[2] This project’s page on Elektor Labs: https://www.elektormagazine.com/labs/electricity-grid-frequency-meter-v2
[3] W. Roth, “Measuring Pulse Width To Sub-Microsecond Resolution with PIC Capture & Compare,” Great Cow BASIC, 2015:
https://bit.ly/measuring-pulse-width
[4] Great Cow BASIC compiler: http://gcbasic.sourceforge.net/Typesetter/index.php/Home
[5] Mains frequency UK online: http://mainsfrequency.uk/fm-last10m
[6] Mains frequency EU online: https://www.gridwatch.templar.co.uk

lektor July & August 2022 17


project

A Modest
Inductance Meter
An Affordable Solution for Your Workbench le
kto
r- L a b
s.

co
E

m
BEST
OF

Ele
to

m
r- L a b s .c o

k
Vcc
By Philippe Le Guen (France)

Need an instrument for testing R1


L1+Lx
and measuring inductors? This
do-it-yourself inductance meter
is an affordable alternative to Q1
C6

many of the expensive solutions


on the market. 
R2 R3
C2 C7

A good instrument to test and measure inductors has been on my


lab-equipment wish list for many years now, but the cost of such a 200592-30

device has been prohibitive. I therefore decided to build something


myself. The little instrument presented here cannot compete with the
Figure 1: An LC tank circuit determines the
complex all-singing, all-dancing instruments on the market; it is only frequency of the Colpitts oscillator.
a modest inductance meter that enables me to obtain the value of
an unknown inductance. There are many of such devices available
online, sometimes based on Arduino.
  program retrieves the value of the inductor under test over USB and
Some years ago, I discovered F. Kudelsko’s website [1], which describes displays it. Even though I found this approach quite interesting, I was
a small DIY inductance meter capable of measuring inductances from looking instead for a stand-alone device. Yet I would like to thank the
a few tens of nanohenries to approximately 10 mH. A small Windows author here for sharing his work on which I based my design.

18 July & August www.elektormagazine.com


+5V +5V

K1 LCD1
C4 R11 1 1
P1 VSS
2 2
10k

10
VDD
100n 3 3
VO
4 4
RS
+5V 20 5 5
R/W

LC DISPLAY 2x16 SIL


6 6

Principle of Operation
E
1 21 7 7
MCLR RB0 DB0
The operating principle of the inductance
22 8 8
IC2 RB1 DB1
2 23 9 9
meter is quite simple. The unknown 3
RA0/AN0
RA1/AN1
RB2
RB3
24 10 10
DB2
DB3
inductance is used to create an LC 4
RA2/AN2 RB4
25 11 11
DB4
5 26 12 12
oscillator. By measuring the oscillator’s 6
RA3/AN3 RB5
27 13 13
DB5

frequency, the value of the unknown


RA4/T0CKI RB6 DB6
7 28 14 14
RA5/AN4 RB7 DB7
inductance can be determined. 15 15
PIC18F252-I/SP 16
A
11 18 16
  12
RC0 RC7/RX
17
+5V
C
RC1 RC6/TX
There are many ways to build an LC 13
RC2 RC5/SDO
16
R18
LCD

oscillator. Here a Colpitts oscillator is


14 15
RC3/SCL RC4/SDA

220
used (see Figure 1). The circuit uses a OSC1 OSC2
+5V
common-base transistor amplifier (Q1)
8 9 10 19
X1 S1
R5 R13 R12
with the input on the emitter and the Measure

output on the collector. Without going


1k

1k

1k
C3 8MHz C1
R17
into details on how this oscillator works, LED1 LED3 LED2

10k
its output frequency is given by the
22p 22p

Zero Error Power


formula of Thomson (a.k.a. Lord Kelvin):
 
f = 1 / (2π √(LC))
  +5V +5V +5V +5V

After reworking it, we obtain: R6


16 R10
  L1
TP2
10k
VDD
C9

5k6
9
L = 1 / (4π² f²C) R1 47µH 0
C5 CTR12 7 100n
1
 
10k

11 6
CT=0 2
Here C is the value of the two capacitors
3n3 REL1 D1 5 Q3
5% 3 R8
Lx IC1 3
C6 and C7 in series: HE722 1N4148 HEF4040B
4
5
2
10k

  CT 6
4 BC547B

C = C6 × C7 / (C6 + C7) C6 13
7
TP1 10 12
+
 
8
Q1 Q2 14
100n R4 9
With the value of these capacitors being
5% 15
220k 10
1
known — I measured them with my BC547B C2 BC547B GND
11

capacitance meter for more precision in C2


R2 R3
C7 1n
R7 8

the calculations — we only have to plug


820

100
12k

C into the reworked formula (together


10µ 220n
50V 5%

with the measured frequency) to find the 200592-028

value of L. It is recommended to use 5%


MKT-types. Figure 2: A prescaler (IC1) divides the oscilator frequency set by Lx down to something the
MCU (IC2) can digest.
Schematic Diagram
The circuit of the inductance meter
is shown in Figure 2. I replaced the  
PIC18F2550 microcontroller in the origi-
nal schematic [1] with a PIC18F252, as I didn’t need a USB interface, With my component values (and Lx short-circuited by the relay,
and I added a 2 × 16 alphanumerical LCD. Some component values see below), the theoretical operating frequency of the oscillator is
were determined by what I had available. 83.821 kHz (86.488 kHz with ideal components). Measuring it with an
  oscilloscope showed a frequency of 88.652 kHz, a difference of 5.4%.
Note C5: This part was inherited from the original design [1] and has  
a slight influence on the oscillator frequency. With C5 the C to use in All the calculations are done by the microcontroller. It measures the
the calculations is given by: frequency of the oscillator via its port RC0. For this it is essential
  to divide the frequency down to values acceptable for the MCU. A
C = C5 + C6 × C7 / (C6 + C7) 4040-type binary counter (IC1) takes care of this. The division ratio
  used here is 1/32. I used an HEF4040B for IC1 because that was
C5 should be of the same precision and quality as C6 and C7. what I had in stock, but a 74HCT4040 will work too.

lektor July & August 2022 19


R14

0 22
0W5
6 7 8
D2 D4 VCC IS DC +5V
J1
1
SWC L2
2
4x 1N4007 SWE
220µH R15
IC3
7...23V AC MC34063AP

3k
D3 D5 5 3
9...32V DC FB TC
1%
GND D6 R1
C10 C11 C12
4

1k
330µ 220p SB120 330µ
25V 25V 1%

200592-29

Figure 3: The switched-mode power supply allows for a wide input voltage range.

 
L1 and the Relay The LCD shows what is going on. During Step 1 the yellow LED (LED1,
To ensure the fast starting of the oscillator irrespective of the value of Zero) lights up. If the inductance to be measured is disconnected, then
the unknown inductance Lx, another inductor L1 is placed in series the message “no coil detected” is shown and the red LED (LED3, Error)
with it. When taking a measurement, the frequency of the oscillator will be lit. If this happens check that the coil is correctly connected
is determined by these two inductances. However, we only want to and restart the measurement sequence by pressing the push button.
know the value of Lx. Therefore, the software first takes a measurement  
with Lx short-circuited. This value, the zero reference, is memorized The use of the system is simple and comfortable as it is fully automatic.
and used later to calculate the value of Lx. The only thing to do is to press briefly (approx. 0.5 s) the push button
connected to RC5 to restart the procedure if needed. The display
The Power Supply shows an arrow to indicate a new measurement.
The power supply is based on an MC34063 (IC3), a switching voltage
buck regulator that delivers a nice supply voltage of +5 V (Figure 3). The Building Process
The power source applied to the input of the circuit is first rectified Once the prototype was validated, I designed a double-sided printed
and then filtered by capacitor C10 before entering IC3. The reason circuit board for it [2]. It is intended to fit into a Multicomp MCRH3135
for the rectifier D2..D5 is to allow both AC and DC power supplies case (Figure 5). Your trained eye may have noticed the small size of
without having to worry about their polarity. This way the device the pads. Most of them have a diameter of 1.4 mm for a 0.8 mm hole. I
accepts 7 VAC to 23 VAC or 9 VDC to 32 VDC at its input. Its working therefore highly recommend using a good soldering iron for mounting
frequency is about 30 kHz. The power consumption of the complete the components or reroute your board differently.
circuit is only 35 mA, not a problem for this power supply that can  
deliver a maximum current of 1.2 A. The power supply connector’s Even though I did my best to come up with a good PCB design, it
center pin is 2 mm in diameter, which allows for the use of many ended up having two issues that I did not fix:
standard power adapters.
> I forgot to check the dimensions and the shape of the pads of
Firmware power connector J1. If you use the same model as I did, you will
I developed a small program in mikroC [2] that, like the original design, have to rework the PCB a bit with a Dremel-like tool (Figure 6).
allows for the measurement of any inductance, and displays its value As the connector is no longer correctly maintained by its
(in nH, µH or mH) on the LCD. The measurement range selection is soldered connections, I glued it to the board (after soldering).
automatic. Measuring the value of Lx is done in two steps: > There is no ICSP connector for in-circuit programming of the
  MCU, which is rather impractical. It is, however, possible to
1. System calibration sequence (relay closed, Figure 4). program the MCU by removing it from the board and placing it
2. Measurement sequence with display of the calculated value. on a breadboard or prototyping board.
   
The MCU’s Timer1 is configured to start counting on the first rising The LCD is mounted on a single-row, 16-way connector, and it is firmly
edge on RC0; it will count for one second (controlled by Timer0). After fixed to the PCB with four M3 × 10 mm nylon spacers and suitable
one second, the value of Timer1 represents the frequency of the signal bolts and nuts.
present at its input. Now the processor can perform all the calculations  
necessary to determine the value of either L1 (Step 1) or Lx (Step 2). The ICs are mounted on sockets which are, of course, not absolutely

20 July & August www.elektormagazine.com


Figure 4: To ensure the best accuracy every measurement is done in two Figure 5: The circuit board for the inductance meter fits snuggly inside the
steps. Shown here is Step 1, the system calibration sequence. enclosure.

necessary (unless you want to reprogram the microcontroller...). The


relay is soldered directly on the PCB, mainly to avoid unwanted parasitic
capacitances and inductances. The three LEDs are soldered almost flush
with the PCB, I used light guides (optical fiber) to improve their visibility.
The binary file produced by the compiler must be programmed in the
microcontroller’s flash memory with a programmer such as the PICkit3.
 
After designing the front panel using the free Front Panel Designer
tool [2][3], I printed it on a self-adhesive aluminum foil (3M) with my
laser printer. The result is clean, but cutting the front panel properly
and sticking it at the correct position is a bit tricky.

Details and Finishing Touches


Figure 6: Errare humanum est, and so the PCB required some rework to
It is recommended to keep connections between the device and the
make the barrel jack fit on its incorrect footprint.
inductance-under-test Lx as short as possible because they can intro-
duce errors due to parasitic capacities and inductances. My test leads
are 12-cm 0.2-mm² multi-stranded wires with hooks on one end. As for
any measuring instrument, switch the device on for a few minutes to
stabilize its operating temperature before taking any measurements.
200592-01

Questions or Comments?
Do you have technical questions or comments about his article? RELATED PRODUCTS
Email the author at pleguen@gmail.com or contact Elektor at
editor@elektor.com.
> Elektor 2 MHz LCR Meter Kit (SKU 19883)
www.elektor.com/19883  

> Miniware DT71 Mini Digital Tweezers (SKU 19422)


www.elektor.com/19422  

> T. Hanna, Microcontroller Basics with PIC (Elektor, 2020,


SKU 19188)

WEB LINKS
[1] DIY inductance meter (in French): http://kudelsko.free.fr/inductance_usb/sommaire.htm
[2] This project with downloads at Elektor Labs: https://www.elektormagazine.com/labs/autonomous-inductance-meter
[3] Front Panel Designer: https://www.frontpanelexpress.com/

lektor July & August 2022 21


review

Acoustic Wave
HH
H oovveerriinngg
Hovering
A Look at the Makerfabs Acoustic Levitation Kit

By Luc Lemmens (Elektor)

With the TinyLev project,


you can experiment with
ultrasonic standing waves
to make objects hover. The
Makerfabs kit contains all
the components needed to
make your own acoustic
levitator. But is it really that
simple to build?

In recent editions of Elektor, we have


presented three small, simple circuits for
magnetic levitation. It was noted that there
are other methods for levitating objects,
such as using acoustic waves [1]. Instructa-
bles.com describes a DIY project designed
at the University of Bristol that uses sound
waves from off-the-shelf ultrasonic transduc-
ers to achieve this apparent weightlessness
of small objects [2]. The Makerfabs Acoustic
Levitator DIY Kit, available from the Elektor
Store, contains all the parts needed to build
this so-called TinyLev project, thus saving
you the trouble of searching for the compo-
nents yourself, including the 3D printed frame  
needed to build the complete contraption. On this web page you can also find (links to) geometry of the base with the reflectors and
  background information and theory on acous- the positioning of the transducers are essen-
The kit comes without documentation, but the tic levitation; it provides good reading if you tial for the levitation effect. On the Instructa-
web link in the Elektor online store guides us want to do more than just building and playing bles site, there are two 3D designs available
to the aforementioned Instructables project with the TinyLev as a gadget. In short: the for downloading and printing the base for
page [2]. It is loaded with instructions in text, levitation relies on the standing wave pattern TinyLev. The Makerfabs Acoustic Levitator
photos and even videos, and the step-by-step of (in this case: two) arrays of ultrasonic trans- kit contains a printed specimen of version
approach will guide you through the construc- ducers, each array arranged in a curved, V1 plus the leg that must be glued the base,
tion of the kit. ball-shaped ‘reflector’. The correct shape and ready for use.

22 July & August 2022 www.elektormagazine.com


 
Start Building, but First Things The next step, Step 8 in the instructions, is to Other Hardware and Software
First wire the transducers. The kit contains a piece In the following steps the other connections
After checking the contents of the kit of thick, stranded wire with the isolation cut need to be made: between the Arduino Nano
(Figure 1), the first thing to do is to deter- open (Figure 2), every single wire from this and the driver board, the power wiring, and
mine the correct polarity of every single ultra- can be used to interconnect legs of the trans- between the driver board and the base with
sonic transducer (Step 4 … 6). Apparently, ducers in concentric circles. The longer red the transducers. The Arduino needs to be
polarity markings on ultrasonic transduc- and black wires from the kit finish the wiring of programmed of course. Download the Nano_
ers in general are not to be trusted, it is not the base, with the transducers arranged in two TinyLev.ino sketch from the Instructables site,
that the MakerFabs kits contains question- arrays of 36; the shorter wires are kept aside compile and upload it in the Arduino IDE.
able components! With 72 sounders in total, for the power supply wiring of the electronics  
this is quite a time-consuming task. In the in Step 15 and 16. Figure 3 shows what the The driver is a standard L298N dual motor
instructions, two methods how to do this are wiring of one of the reflectors will look like. driver board, in this case it provides the 40 kHz
presented, including using the Arduino Nano
board - that is also included in the Maker-
fabs kit - as a minimalistic ‘oscilloscope’.
Testing with a standard digital multimeter
is probably the easiest and fastest way to do
the job: simply mark the polarity based on
the initial potential on the transducer’s pins
when the probes are connected. However,
my auto ranging DMMs appeared not to be
usable here, you need to have a meter that
can be manually switched to the most sensi-
tive voltage range and immediately reacts
when the meter’s probes are connected to
the transducer. Eventually, I used the Arduino
Nano method. Take your time to do this, one
mistake can spoil or even completely ruin the
levitation effect. It is of the utmost impor-
tance that all transducers have the correct
phase of the sound signal.

The Transducer Arrays


Figure 1: Contents of the kit.
With all the transducers marked, it’s time to
glue them all to the 3D printed frame. The
manual on Instructables recommends the
use of hot glue; for me that doesn’t work
with relatively small parts, like these trans-
ducers. If you want me to make a mess of
my workbench, give me a hot glue gun…
I used a tube of hobby adhesive for hard
plastics. Whatever you use, make sure
that all markings you made on these parts
point to the same direction: either all to
the center or all to the outer edge of the
reflector. They should fit flush into the round
recesses/sockets in the base. I ended up
with some spare parts, four transducers were
not needed to completely fill the frame (i.e.
Figure 2: Wires
there are 76 in the kit!). Two of them may be for connecting the
needed for troubleshooting, and can be used transducers.
as sensors (microphones) to check the phase
of the sound from all transducers individually
(if things don’t work…). Figure 3: The wiring of one of both arrays.

lektor July & August 2022 23


sound signals for the two transducer arrays.
The procedure to make these interconnec-
tions will not be difficult for the experienced
tinkerer, just follow the text and photos on
Instructables which - admittedly - could have
been a bit clearer at some points. The base
board used for fixing the PCBs and power
circuit is not included in the kit, but a 10 x
10 cm or larger piece of plywood will do.

Check, Check, Double-Check…


It is advisable to do the tests described in
the instructions before the transducers are
connected, especially to check for short
circuits in the arrays, which would proba-
bly damage the driver board. Also, check
the output signals of the driver board with Figure 4: A tiny polystyrene ball hovering in the TinyLev.
an oscilloscope. Then, if you have enough
confidence in your own work, that is if you
are - as good as - sure that all transducers
are correctly connected and working, you may essential parts are included and with all
save time and skip checking (the phase of ) the information that can be found on the
all sounders individually. You can always do Instructables website and other Internet Good to hear!
that afterwards; if the levitation does not work sources, it will be relatively easy to start The frequency of ultrasound is above the
properly, there is a good chance that the fault experimenting with acoustic levitation. Do human hearing limit, hence the name. In
lies in the arrays. I had a lot of confidence in not expect to finish the construction within this case, we are talking about 40 kHz,
my work and that turned out to be justified: an hour or so. I spent quite some time only about a factor of two higher than the
it worked straight away! to check and mark the transducers and to highest tone we can perceive. At best,
solder the arrays. And with the rest, I even we will hear a click or short crackle
And Experiment… skipped some steps that were not absolutely when switching on the TinyLev, but other
And then, it’s time to start experimenting with necessary to get the levitation working on my creatures, like your pets, can hear it and
all kind of ‘things’ that can be levitated with workbench. Don’t rush things, though: one may react strongly to it. The author’s cats
the TinyLev. I didn’t spend too much on this mistake — especially in the transducer arrays don’t seem to mind, but they only react to
though, I tried some rolled-up tiny pieces of — may cost a lot of time to troubleshoot and food-related sounds anyway.
paper, small plastic beads and polystyrene fix! If you have done it right, the hard work
balls, and these were pretty easy to levitate will be rewarded with a huge ‘wow’-feeling
between the transducer arrays (see Figure 4). when you see the first object hovering on
The Instructables page also describes hover- the TinyLev’s acoustic waves!
ing of small (dead) insects and drops of liquid. 220062-01
Searching for ‘TinyLev’ on the internet, you’ll
find lots of other experiments with this project
that may be nice to try for yourself (or maybe Questions or Comments?
they can trigger new ideas). Do you have any technical questions or RELATED
comments about this article? Contact
PRODUCTS
Hovering on Acoustic Waves the author at Luc.Lemmens@elektor.
> Makerfabs Acoustic Levitator DIY Kit
Building the TinyLev is easy to do with this com or contact the Elektor team at www.elektor.com/19984  
MakerFab Acoustic Levitator DIY Kit. All editor@elektor.com.  

WEB LINKS
[1] Eric Bogers, “Powerful tractor beam suspends people,” Elektormagazine.com: https://bit.ly/3IzO7uu
[2] Acoustic Levitator on Instructables: www.instructables.com/Acoustic-Levitator/

24 July & August 2022 www.elektormagazine.com


basic course

Starting Out in Electronics


Rectifiers
By Eric Bogers (Elektor)

In the May/June issue of Elektor, we welcomed the diode


as the first representative of the semiconductor family,
and you can’t think about today’s electronics without it.
Now we’re going to calculate with rectifiers. After all, we
can’t just solder parts together and hope it works.

For our convenience, we subtract 0.7 V from that peak voltage


(which is the forward voltage of the silicon diode used as a
rectifier):

U peak  15 V  2  0.7 V  20.5 V

Figure 1: The half-wave rectifier. As for the perfectionists among you, we have rounded the result
to one decimal — that is accurate enough in this case. Since the
IC needs an input voltage of at least 18 V (we can find this minimum
Let us first have a look at our half-wave rectifier (Figure 1). The input voltage in the datasheet of the IC), the voltage is allowed to
larger the capacitance of the electrolytic capacitor, the less the drop by a maximum of 2.5 V during one period. We rewrite the
voltage will drop during the negative half-periods of the AC voltage; formula for the voltage across the capacitor and add the current,
and also, as the resistance gets smaller (and thus the current drawn voltage and frequency values:
by the load gets larger), the voltage will drop more during the
negative half-periods (‘collapse’, says the electronics engineer). I I
U
 C

We can put this into a formula: f C f  U

Q Q I  T I 1A
U  U   C  8000 μF
C C C f C 50 Hz  2.5 V

We have assumed that the current is constant. Now suppose we The next larger standard value would be 10,000 µF, and for a current
have a 15 V transformer, a half-wave rectifier and a load with a of only 1 A, that is quite a ‘bulky’ capacitor. In principle, there are
current draw of 1 A. The voltage provided by the rectifier must be two methods of achieving a lower value (and thus a smaller and
stabilized by a regulator IC that requires a minimum input voltage cheaper electrolytic capacitor):
of 18 V to provide a stable output voltage of 15 V. (We’ll come back  
to that IC in a future issue.) In that case, how large should the > We apply full-wave rectification, which means that the capaci-
capacitor be? tor is charged twice as often.
  > We increase the transformer voltage and thus the permissible
First, we have to calculate the peak value of the AC voltage; in a voltage difference.
previous article in this series, we saw that for the peak value applies:  
This full-wave rectification will be discussed later; below we will
first deal with ’increasing the transformer voltage’. If we use an
 U eff  2
U peak
18 V transformer instead of the 15 V version in the example, we
will measure a peak voltage of about 24.7 V at the diode, and that

lektor July & August 2022 25


is including the losses in the diode and the voltage regulator) does
not really matter, unless it forces us to use a transformer that is a
bit bigger in size.

The Full-wave Rectifier


We have shown the full-wave rectifier schematically in Figure 3.
Thanks to the ingenious circuit with four diodes (also called the
Figure 2: Half-wave rectifier with stabiliser IC. bridge rectifier or Graetz circuit), both half-periods of the sinusoi-
dal AC voltage at the input are now used. During the positive half
period, the charging current for the electrolytic capacitor flows
means a maximum permissible voltage difference of 6.7 V. The through the diodes in the upper right and lower left, and during
selection of the capacitor can therefore be correspondingly smaller; the negative half period through the diodes in the lower right and
the calculated value is about 3000 µF and the next larger standard upper left. The advantage is that the electrolytic capacitor is charged
value is either 3300 µF or 4700 µF. twice as often and therefore (roughly estimated) only needs to be
  about half as ‘thick’. This results in the Figure 4 voltage curves:
As a famous Dutch football philosopher (Johan Cruijff) once said, above the input voltage, in the middle the voltage across the load
every advantage has its disadvantage: this solution involves higher without the capacitor, and below the voltage across the capacitor.
power consumption and also a higher heat dissipation in the voltage  
regulator. For this, we will have a look at Figure 2. For the voltage variation across the buffer capacitor of the full-wave
  rectifier, the following applies:
The component with the part number 7815 is a fixed voltage regula-
tor. For the time being, we are not interested in how this thing I
works. What matters here is that this IC turns a (within certain U 
2 f C
limits) varying DC input voltage into an (almost) constant DC
output voltage.
 
The following applies to the output power in both cases (the
example with the 15 V transformer and the example with the 18 V
transformer):

Pout  15 V 1A  15 W

The dissipation in the IC (the power converted into heat in the IC)
is equal to the difference between input and output voltage times
the current (in many cases — and also here — we can neglect the
IC’s own power consumption). Figure 3: The full-wave rectifier.

 U in(min)  U in (max) 
Ploss U in  U out   
I   U out   I
 2  U(t)

 18 V  20.7 V 
Ploss (15 V) 
 15 V  1A 4.35 W
 t
 2 
U(t)

 18 V  24.7 V 
Ploss (18V) 
 15 V  1A 6.35 W

 2  t

To be sure, the input voltage of the IC is not constant; in this case,


U(t)
we use the arithmetic mean of the minimum and maximum input
voltage (which is accurate enough for our purposes).
 
t

As a result, the power loss in the voltage regulator increases around


50% — that’s a lot of excess heat that has to be dissipated. The fact
that the transformer now has to supply 22 W instead of 20 W (that Figure 4: Voltage curves with the full-wave rectifier.

26 July & August 2022 www.elektormagazine.com


(1 A at a peak voltage of approx. 20 V) — but that is for each half
period. In total, the transformer must be able to deliver at least 40 W.
 
That’s it for this time. In the next episode, we will multiply voltages.
220169-01

 
Editor’s Note: the series of articles “Starting out in electronics” is based on the
book, Basic Electronics Course, by Michael Ebner, published by Elektor. 
Figure 5: This is how we create a symmetrical supply voltage.
 

Let us now calculate our earlier example (with the 15 V transformer)
with a full-wave rectifier. Due to the extra voltage drop across the Questions or Comments?
second diode, we now have a peak voltage of: Do you have any technical questions or comments prompted
by this article? Send an email to the author or to the editor of
Elektor via editor@elektor.com.
U peak  15 V  2  1.4 V  19.8 V

This gives us a value for the electrolytic capacitor of:


 
1A
C  5500μF
2  50 Hz 1.8 V

The next larger standard value would be 6800 µF, but it is question- RELATED PRODUCTS
able whether this is (widely) available. If not, we have to use an
electrolytic capacitor of 10,000 µF. At a transformer voltage of 18 V,
we end up with a calculated value of 1700 µF and a standard value
> B. Kainka, Basic Electronics for Beginners,
Elektor 2020. (SKU 19212)
of 2200 µF, which is at least one size smaller. Regarding our initial www.elektor.com/13950  
expectation that the buffer capacitor should be only half the size,
the forward voltage of the rectifier diodes cancels this out. > B. Kainka, Basic Electronics for Beginners (E-Book),
  Elektor 2020. (SKU 19213)
www.elektor.com/18232
It is clear that the current through the load plays a decisive role:
the greater the current, the larger the capacitor. This is the reason
why we often find a large number of big electrolytic capacitors in
the power supply of heavy power amplifiers.

Symmetrical Supply Voltage


For circuits with operational amplifiers (‘op-amps’), we often need
a symmetrical supply voltage — in other words, we need equal
positive and negative voltages with respect to common ground. In
principle, we can achieve this with two transformers, or with a trans-
former with two secondary windings, followed by two rectifiers.
 
It can also be simplified: it is possible to derive a positive and a
negative DC voltage from a single AC voltage, as shown in Figure 5.
In fact, we use two half-wave rectifiers, one utilizing the positive
half-periods of the sinusoidal input AC voltage and the other the
negative half-periods. For the calculation of the electrolytic capac-
itors, the same equations apply as for ‘normal’ half-wave rectifiers.
  WEB LINK
However, the size of the transformer now requires a little more
[1] E. Bogers and M. Ebner, “Starting Out in Electronics:
attention. Suppose we need a symmetrical supply voltage of ±15 V
Welcome to the Diode,” Elektor 5-6/2022:
for a current of 1 A. These voltages are stabilized by voltage regula-
www.elektormagazine.com/220003-01
tors. The transformer must be capable of delivering at least 20 W

lektor July & August 2022 27


E-FFWD
electronica fast forward
Looking Ahead Again
Together with Messe München and the industry as a whole, Elektor is
looking forward to a well-attended electronica 2022 fair in November.
We’ve been hearing from all sides about the need to meet each other
again in person, and perhaps this applies most to the creative innovators
who are pillars of the annual electronica fast forward awards (e-ffwd)!

28 July & August www.elektormagazine.com


www.elektormagazine.com/effwd-2022
With monthly articles/videos online — in the Elektor magazines,
e-zines and on our socials — potential candidates are introduced.
A ballot for the most interesting stories is combined with a jury
review to arrive at the verdict of who is invited to Munich. Thus,
No matter how much we try not to talk directly about COViD now this year’s e-ffwd is “invite only” but weighted. A total prize pool
that we are finally able to do some more, it is, of course, inevita- of €150,000 in marketing exposure and one of the highly desired
ble to consider its impact on the upcoming edition. We are proud invitations to electronica 2024 is available for the winners. This
that we did not have to skip an edition of the fast forward start up way, anyone interested can also see the development with their
awards. But, after a digital version in 2020 and last year’s Produc- own eyes at the next edition of the world’s largest electronics fair.
tronica edition still heavily affected by travel restrictions, it will be
clear that we expect to make a bigger impact this year. University Team
New for 2022 is the plan to also invite a student team from a
It is therefore with great excitement that we look ahead to the technical university. Many universities have amazingly ambitious
2022 edition during the largest electronics trade fair in the world projects entered in global competitions (often also sponsored by
from November 15 onwards in Munich. It promises to be a great our industry). There have been many great developments in recent
event, which will include both the trade fair itself (almost all major years, which to some extents have not yet received the attention
parties have announced their presence) and the electronica fast they deserve. That's why Messe München and Elektor want to
forward, the start-up platform by electronica and Elektor. With a provide them with that platform in this special comeback edition
leading role for innovative start-ups and scale-ups in a booth of that is electronica 2022!
no less than 273 m2, we’ll more than make up for the lack of space
in recent years! Again, our team is looking for a best-in-class guest from the inter-
national educational sector. Of course, we also invite our own
In 2022 there will be much more to discover as we will not only community to think along and nominate. This can be done via
be giving the stage to innovative concepts in their early stages, our special fast forward 2022 website. Of course, teams can also
but also to the players who have already leaped the first hurdles register themselves. Educational institutions fall outside the e-ffwd
in their entrepreneurial journey. awards competition, but there is of course no better place to show
the results of hard work to the entire international industry of which
Best of the Best every student dreams of becoming a member!
This year we intend to really scout out the ‘crème de la crème’
of start-ups and give them a podium. We are focused on inter- Ambition
esting and innovative entrepreneurs with a lot of conviction and Clearly, the electronica fast forward awards 2022 will be bursting
boldness. In order to find them, we are going even further in 2022. with ambition. Especially, of course, due to the ambition of the
In addition to the annual call through the channels of Messe engaged start-up entrepreneurs and students involved. But also
München and Elektor, we are also actively scouting the e-ffwd organization itself has a renewed ambition to make this
internationally through industry collabora- the best edition so far. Messe München has made an impressive
tions, platforms such as Kickstarter, stand available in the middle of Hall B4, right next to the Forum
Indiegogo, and Crowd Supply, where every student team, start-up or scale-up gets the chance to
as well as international present itself. And Elektor will use all its media to give this year's
publications. fast forward awards guests a marketing boost.

We are looking for The organization cordially invites industry partners to be part of
start-ups and scale- this special edition of the fast forward awards. Show your support
ups in different for the future of our industry and become a sponsor for this unique
stages of early entre- event. Please contact the team at fastforward@elektor.com or ask
preneurship. With a few your direct contacts about the possibilities.
up-and-coming talents and
up to three companies that have
already achieved their first business
successes, e-ffwd 2022 promises to be a
combination of inspiration and aspiration. As we
do every year, Elektor invites the most interesting and
inspiring entrepreneurs, people, and products to showcase
themselves and to tell their stories at the e-ffwd booth in front of
the entire industry.

lektor July & August 2022 29


basics

Get Started
With Your Oscilloscope

Find Your Way Through the Knobs and Buttons

By Clemens Valens (Elektor) Of course, you already invested in a multi- can find online (Figure 2). They just do not
meter, which is great, but an oscilloscope offer the comfort and features of a low-cost
can do things you cannot do with a multime- but real bench oscilloscope. They may be
When you have been ter. However, oscilloscopes are also much practical when traveling or when you are
tinkering with electronics more complex instruments than multime- really tight on space, but that’s probably all
for a while and your projects ters, and so it takes some time and practice they are good for. I like my oscilloscope to
to get the most out of them. stay where it is when I pull a test lead, and
are getting more serious, it must have knobs and buttons that I can
chances are that you will What Do You Need? find quickly. To me, an oscilloscope without
need an oscilloscope. Oscilloscopes used to be expensive, but knobs for the horizontal and vertical axes
today prices have dropped so much that is not a real oscilloscope.
An oscilloscope is an almost anyone can afford one. For most
instrument that displays the hobbyist, tinker, and maker applications, Headless Oscilloscopes
evolution of one or more a basic oscilloscope is more than good Of course, there are headless oscilloscopes
enough. If your thing is Arduino- or Raspber- with excellent specifications (Figure 3),
voltages over time. But how ry-Pi-based projects or building and repair- but they require a tablet or computer and
do you choose one? And how ing audio amplifiers or musical instruments a mouse. Such devices are good for doing
do you use one? or guitar effects, there really is no need to remote measurements or for documentation
invest in a four-channel (or more) oscillo- or constant monitoring, for data logging and
scope with hundreds of MHz of bandwidth postprocessing (or for doing very precise
and many gigasamples. A two-channel, things that require a lot of fiddling). In
20-to-50-MHz oscilloscope is just fine my lab setup, the computer is needed to
  project (Figure 1). show the schematic, modify firmware, read
Watch this eo! datasheets, and search the Internet. I don’t
on vid Not Too Small, Please want it to be an oscilloscope as well. And
However, even though it may seem tempt- I don’t want a second computer because
ing, I don’t recommend spending money on it takes up too much bench space. And, of
those cheap small DIY oscilloscope kits you course, because I want real knobs.

30 July & August www.elektormagazine.com


DSO, MSO, Analog? the middle of the screen. Note that I wrote fore important to understand what it does
Today’s oscilloscopes are digital, and they are ‘voltage’, and not ‘current’. An oscilloscope is and how.
called DSOs, which stands for Digital Storage a fancy voltmeter.
Oscilloscope. In the past oscilloscopes were Vertical
analog. Analog oscilloscopes are bulky and Main Control Sections But first let us look at the section Vertical.
limited, and you don’t want one unless you Because it displays signals as graphs, an This section lets you amplify or attenuate the
have very special needs. There have been oscilloscope has controls to adjust the input voltage or signal, meaning that you can
hybrid oscilloscopes that could do both, but horizontal and vertical axes of the graph. adjust its amplitude, and you can move it up
you don’t want one of those either. By the On every modern oscilloscope that I know and down. This can be set independently for
way, do not confuse these with so-called of, these controls are grouped together in every input channel.
mixed-signal oscilloscopes, or MSOs, as these a section labeled Horizontal and a section  
are DSOs with special features for digital labeled Vertical (Figure 4). The horizontal By the way, in oscilloscope language, a signal
signals and communication buses and things. section is also known as the Time Base as is also called a trace. Single-trace means one
the horizontal axis usually represents time. signal or channel, dual-trace means two, etc.
Let’s Try to Use It  
So, now that we know a bit more about oscil- Then there is a third section called Trigger. XY Mode
loscopes, we can move on to learning how This is probably the most important section Another point of confusion can be that input
to use them. If you were smart and bought a as it determines how and when a signal is connectors besides being labeled channel
cheap one, it will not have too many functions, shown. Often it is easy enough to get the 1 and 2 are sometimes also labeled X and
and so it is easy to get going. signal you are measuring to fit on the screen Y (Figure 5). This refers to a special opera-
  by adjusting the horizontal and vertical axes, tion mode of the oscilloscope in which the X
As said at the beginning, an oscilloscope but making the oscilloscope display the part input controls the horizontal axis instead of
displays the evolution of a voltage over time, of the signal you are interested in can be the vertical. This is the mode to create the
a ‘signal’, and it does this in the shape of a much more difficult. The trigger section famous Lissajous figures with that they liked
two-dimensional graph with the center in gives you control over this and it is there- to show in old sci-fi movies. We will not use

Figure 5. The inputs X and Y are used in


Figure 1: In most situations a simple two-channel,
Figure 4: The three main control sections of every XY-mode and let you create, for example,
20-to-50 MHz oscilloscope is all that is needed.
oscilloscope: Vertical, Horizontal and Trigger. Lissajous figures.
 

Figure 2: Even
though they
seem kind of
cool to have,
miniature
oscilloscopes
are not very
practical to use.

Figure 3: A headless oscilloscope saves bench space. Or does it? A


computer or tablet is required for viewing the signals.

lektor July & August 2022 31


Figure 6: Connect the probe’s crocodile clip to GND Figure 7: Always keep in mind that an oscilloscope may be
(ground). The rule is to try to get it as close as possible to connected to earth. If it is, short circuits may arise when the
the signal of interest, but often ‘anywhere’ is just fine. probe’s crocodile clip is connected to something else than ground.

 
XY mode in this article; for us the horizontal A Word About Ground Triggering is what makes an oscilloscope
axis always represents time. Note that ground doesn’t have to be ground, it really useful as it allows you to focus on the
can be any voltage or signal in the circuit, but interesting part of a signal. A trigger is needed
Connecting the Probe it must be the same for every channel. Also to start a trace. If there is no trigger, the trace
Connect a probe to one of the channel note that probe ground is usually connected to will not start, and you will not see anything.
connectors, not to the Ext, Trigger, Aux or oscilloscope ground which can be connected This is why an oscilloscope features several
Z connector. Note that probes often have a to mains ground, so if you connect the probe options for triggering. One might even argue
switch to choose between 1:1 or 10:1. This is ground to something other than ground, short that the more trigger options an oscilloscope
an extra attenuation option that allows large circuits may be created and dangerous situa- has, the better it is.
signals to fit or to improve the precision of tions may arise (Figure 7). Therefore, always  
measurements of sensitive signals. Some connect the crocodile clip to ground unless In my world, every oscilloscope features at
people always use 10:1 attenuation mode you know what you are doing. least automatic and normal triggering, adjust-
and there exist probes that are always in able trigger level, up and down or positive
10:1 mode. (Other ratios like 1,000:1 can be Horizontal or Timebase and negative trigger slopes and an external
had too.) Probes are also referred to as 1x With the knob in the section Horizontal, you trigger input.
and 10x where the ‘x’ means attenuation, not can zoom in and out on the time scale and  
amplification. It is often possible to inform you can move the signal to the left or to the The first thing to do is select the source for the
the oscilloscope about the type of probe right. Usually, the center of the screen is zero. trigger signal. Usually it is one of the signals
you are using, so it can adapt the scales you want to look at, but it can be a signal
accordingly. Triggering generated by another device altogether.
  Up to now, I was supposing that you did see
Before connecting the tip of the probe something on the display of the oscilloscope, Automatic Triggering
to the signal of interest, first connect the but maybe you didn’t? One reason can be Automatic triggering is easiest to use
crocodile clip attached to the probe to the that the trace is not on the screen. Use the (Figure 9). In this mode the oscilloscope
ground reference of the circuit under test. As vertical level control to find it. Another reason decides when to trigger, and the user can
a general rule, connect it as close as possible may be that the brightness is too low. If it is, set the trigger level and choose the slope
to the signal. However, in many cases this is crank it up. A third reason can be a trigger to trigger on. This mode is useful for quickly
not so important as long as it is connected problem. If your oscilloscope has an Auto seeing if something is “going on” on an input
to ground somewhere (Figure 6). It can Setup button or something similar (Figure 8), or to simply measure a DC voltage.
even be convenient to use the crocodile now is a good time to press it. After doing
clip of a second probe just for connecting so you may not see what you expected, but Normal Mode
to ground so you can remove the crocodile you should at least see something. Use the In Normal mode the oscilloscope only triggers
clip from the measuring probe and keep it vertical and horizontal knobs to bring the when the trigger level and slope conditions
out of your way. signal into range. are met or any other trigger condition that

32 July & August www.elektormagazine.com


Figure 8: The Auto Setup button
can help you find your signals,
but the result may always not be
what you hoped for.
Figure 9: Do not confuse Figure 10: The Run, Stop and Single buttons
the Auto trigger button allow capturing infrequent events or freezing
with the Auto Setup the traces for taking measurements without
button. Auto trigger mode the signal disappearing.
is useful to quickly setup
a measurement before
switching to Normal mode.

you may have specified. After a trigger, the window, with delays and what not. As I said
trace will run until it falls off at the right side before, the more trigger options, the better.
of the screen. A new trigger is required to   Questions or Comments?
start it again. If you set the trigger level too We will stop here. Your oscilloscope probably Do you have technical questions or
low or too high, the trace freezes or may not has several other buttons not covered in this comments about this article? Please note
appear as it is never triggered. This mode article. But now that you know how to get a that we are aware that it is incomplete and
is good for infrequent events or to focus on stable signal on its display, you can explore that some shortcuts have been taken. This
special events. these functions more in depth. article is not targeted at experts. Email the
  author at clemens.valens@elektor.com or
Run/Stop & Single Whatever you do, always keep in mind that contact Elektor at editor@elektor.com.
It is quite probable that your oscilloscope before measuring anything, you should have
has a Run/Stop button and a Single button an idea of what to expect so that you can
(Figure 10). The Run/Stop button lets you compare the result to what it is supposed to
freeze the display, which is handy if you want be. If you don’t know what to expect, then you
to study a signal in detail without allowing a can’t tell if it is wrong or if it’s right.
new trigger to change it or make it disappear. 200661-01
Press the button again to leave this mode.
 
The Single button can be used when an event
happens only occasionally, for instance only at RELATED PRODUCTS
power-on or after pressing a button, or when
it is not periodic. After the trigger happens, the
trace will run only once and then the oscil- > Owon SDS1022 2-ch Digital Oscilloscope (20 MHz) (SKU 18898)
loscope enters Stop mode. You must press www.elektor.com/18898  
Run or Single to restart the capture of a single
> LabNation SmartScope USB Oscilloscope (SKU 17169)
event. Press Single or Run again to go back to www.elektor.com/17169  
normal mode (which button to press depends,
of course, on the oscilloscope). > PeakTech 1375 All-in-one 4-ch Oscilloscope (100 MHz, 1 GS/s)
  (SKU 19316)
www.elektor.com/19316   J
Depending on the oscilloscope, there can be
more trigger options. Typical other options go > JYE Tech DSO Coral 112A Oscilloscope (SKU 18319)
from triggering on both slopes, or on a time www.elektor.com/18319
delay between slopes, a pulse so to speak, to
triggering on a sequence, inside or outside a

lektor July & August 2022 33


background

Raspberry Pi Pico
Makes an
MSF-SDR
Decode a Time Signal with a Pi Pico SDR

VLF antenna in Anthorn (Dougsim, https://bit.ly/34HXeuG)

By Martin Ossmann (Germany)

MSF is the UK’s equivalent of the


German DCF77 time signal transmitter.
This SDR project shows how a receiver
and decoder for these (and other) time
signals can be implemented quite
simply and, above all, inexpensively. signal, but this is probably the first time a design for an MSF receiver
For the hardware you really won’t need has been featured. There was, however, an add-on circuit [2] for the
much more than a low-cost good-old 6502 Junior Computer [3] described in the English language
edition of Elektor.
Raspberry Pi Pico to receive, decode,  
and display MSF time signal A lot of water has flowed under the bridge since then, and technology
information. relating to receivers/decoders has progressed in leaps and bounds.
In this article, we will use the latest “up-to-date” concepts to build a
  software-defined radio (SDR) using a small microcontroller board.
In Germany the DCF77 transmitter in Mainflingen transmits an encoded The Raspberry Pi Pico board, which uses an RP2040 CPU clocked
long-wave time signal. Its equivalent based in the UK is the MSF signal at 125 MHz (the in-house controller of the Raspberry Pi Foundation
formerly known as “The Rugby Clock.”[1] It sends out time signals using is equipped with dual 32-bit ARM Cortex M0+ cores), is a suitable,
a 60 kHz long-wave carrier signal. In the early days, it served as a you could say, predestined piece of hardware for this application. Its
frequency standard, and sent out a five-minute pulse train twice a day. analog-to-digital converter can run at 500 ksps. All this processing
The “transmission protocol” of the signal has changed several times power can be purchased for an almost ridiculous €5 (see Related
over the decades, but it was not until 1977 that the encoding included Products below).
time-of-day and date information that could be evaluated by the receiver.  
Here we show how to implement a complete receiver in hardware
The Project and software for the 60 kHz MSF time signal. The entire receiver,
Over the years, there have been many receiver/decoder circuits without a display but with an RS232 output and antenna connection,
described in various Elektor articles that make use of the DCF77 is shown in Figure 1.

34 July & August www.elektormagazine.com


1 USB 40
GP0 VBUS
2 39
GP2 VSYS
3 38
GND LED GND R2
4 37
GP2 3V3_EN

10k
5 36

BOOTSEL
GP3 3V3_OUT active
6
GP4 ADC_VREF
35 C1 antenna
7 34

Hardware
GP5 GP28
8 33
GND GND R1 10µ
9 32
First we will take a look at the hardware necessary to build the SDR. GP6 MOD1 GP27 10V

10k
10 31
GP7 GP26
There are just a few additional items to connect to our pico board. 11
GP8 RUN
30

 
12 29
GP9 GP22
13 28
Antenna Input: We use the analog input pin ADC2 (GPIO28, on the Pico 14
GND
GP10
GND
GP21
27

board pin 34) to receive signals from the antenna. The ADC uses the 15 26

Raspberry
GP11 GP20
16 25
internal 3.3 V as a reference voltage. This pin must therefore be biased

Pi PICO
GP12 GP19
17 24
GP13 GP18
at half the reference voltage. The two resistors in Figure 2 take care of 18
GND GND
23

this. The 10 µF capacitor C1 provides AC coupling for the incoming signal. 19
GP14 GP17
22

SWCLK

SWDIO
20 21
 

GND
GP15 GP16

RS232 Output: In its simplest form (without an LC display), the receiver 220006-004

uses a serial interface (115,200 bit/s) to output the data. The interface is Figure 2: Components required at the A/D signal input.
implemented by the circuit shown in Figure 3. We cannot use the USB
port to output the serial data because it would generate interrupts to
our software in an unpredictable way.
  +5V 1
GP0
USB
VBUS
40

PWM DACs: When no LC display is connected, it is possible to use


2 39
R1 R2 GP2 VSYS
3 38
the DACs with pulse width modulated (PWM) signals to create an easy

2k2

2k2
GND LED GND
4 37
GP2 3V3_EN
aid for debugging. We have set up two PWM DACs with the associ- 5 36

BOOTSEL
GP3 3V3_OUT
6 35
ated low-pass filters as shown in Figure 4. Using GPIO 2 and GPIO 3 D T1
7
GP4 ADC_VREF
34
RS232 GP5 GP28
as PWM outputs, for example, the demodulated signal and Bit-Timer 115200 Bd
G 8
GND GND
33

signals can be displayed on a scope (Figure 5).


9 32
S GP6 MOD1 GP27
BS170 10 31
  11
GP7
GP8
GP26
RUN
30

LCD: The 3.5-inch Arduino 8-bit module ILI9486 (non touch screen 12


GP9 GP22
29
13 28
version SKU MAR3502 [4]) can be used as the LCD. This 3.5-inch Arduino 14
GND GND
27
GP10 GP21
shield has 480x320 coloured pixels and retails for around €10. Its connec- 15 26

Raspberry
GP11 GP20
tion to the Raspberry Pi Pico is shown in Figure 6. 16 25

Pi PICO
GP12 GP19
17 24
  18
GP13 GP18
23
GND GND
The received signal is shown on the LCD together with a waveform 19
GP14 GP17
22
SWCLK

SWDIO

showing bit timing information. The received time information is shown


20 21
GND

GP15 GP16

in plain text above the waveform (Figure 7). If you do not need to display 220006-005

this information you can choose to simply omit the LCD without the Figure 3: The RS232 output from the Pico Board.
need to make any changes to the software.
 
Active Antenna: We have already covered the antenna connection;
the circuit of the active antenna can be seen in Figure 8. It is essen- C1
tially based on the LM6132 dual operational amplifier. This op-amp is
1 USB 40
GP0 VBUS
2 39
particularly suited for this application with an operating voltage of 2.7 100n GP2 VSYS
R1 3 38
GND LED GND
to 24 V, 10 MHz gain bandwidth product, rail-to-rail input and output A 1k 4
GP2 3V3_EN
37
PWM 5 36
signal capability and low current consumption of 360 µA per amplifier.
BOOTSEL

R2 GP3 3V3_OUT
B 1k 6 35
GP4 ADC_VREF
7 34
C2 GP5 GP28
8 33
GND GND
9 32
100n GP6 MOD1 GP27
10 31
GP7 GP26
11 30
GP8 RUN
12 29
cut-off GP9 GP22
13 28
frequency GND GND
approx. 14 27
GP10 GP21
1600Hz 15 26
Raspberry

GP11 GP20
16 25
Pi PICO

GP12 GP19
17 24
GP13 GP18
18 23
GND GND
19 22
GP14 GP17
SWCLK

SWDIO

20 21
GND

GP15 GP16

220006-006

Figure 1: The Raspberry Pi Pico board as a software-defined radio for MSF Figure 4: Two low pass filters for the PWM-DAC debug signals.
reception.

lektor July & August 2022 35


3.5" ILI9486 LC Display

GND
RST

+5V
WR
CS
RS

RD
D7
D6
D5
D4
D3
D2
D1
D0
1 USB 40
GP0 VBUS
2 39
GP2 VSYS
3 38
GND LED GND
4 37 +5V
Figure 5: The PWM test signals. Top trace is the 5
GP2 3V3_EN
36

BOOTSEL
ampl-value, middle trace is the SecondTimer
GP3 3V3_OUT
6 35
GP4 ADC_VREF
showing Sampling trigger pulses and below is the 7
GP5 GP28
34

digital sigValue signal. 8


GND GND
33
9 32
GP6 MOD1 GP27
10 31
GP7 GP26
11 30
GP8 RUN
12 29
GP9 GP22
13 28
GND GND
14 27
GP10 GP21
15 26

Raspberry
GP11 GP20
16 25

Pi PICO
GP12 GP19
17 24
GP13 GP18
18 23
GND GND
19 22
GP14 GP17

SWCLK

SWDIO
20 21

GND
GP15 GP16

220006-008

Figure 7: Receiver information on an LCD. Figure 6: Connections for the 3,5“ LCD.

V1 +5V

R1 R4
8 C7 C5
L2
10k

IC1
1k

10mH
4 100n 10µ
C1
IC1 = LM6132
500p R6

L1
470

3
1 5 ca. 4V5 receiver
IC1A C6
1mA
C9
2 7
C2 IC1B
6
1µ 10µ
R3 R5
10k 10k
R2
C3 C4 C8
10k

10µ 10µ 10µ

220006-010 Figure 8: Active antenna for


L1: 500 turns enamelled copper wire 0.2 mm on 10 mm ferrite rod (length 180 mm) the 60 kHz MSF signal.
C2: as required

Isum Buffer Low pass


filter
Input
active COS
antenna ADC DDS fMix Ndown Fifo Ndown
500k 400k log√I2+Q2 + Decoding
Samples/sec
1250 Samples/sec
4
100 Bit/sec

SIN
0.00475

Qsum Buffer Low pass


filter Z-1 Threshold

0.995

Figure 9: Diagram showing the MSF receiver signal paths in the Raspberry Pi Pico Board. 220006-011

36 July & August www.elektormagazine.com


No doubt other op-amps would also work here but if you intend to
replace the LM6132, check carefully whether it will match the spec.

Programming the Input Mixer Figure 10: The MSF seconds pulse showing Bit A and Bit B coding.
After the hardware, we come to the programming. The analogue paths
of the SDR is structured as shown in Figure 9. The Raspberry Pi Pico
can be programmed using several different languages. For this appli-
cation we chose C using the Microsoft Visual Studio Code develop-
ment environment running on a PC under Windows 10. Let’s look at
how the different parts function.
  Year (BCD coded 0...99) Meaning
The ADC Sample Routine is triggered by the PWM and called 500,000 80 40 20 10 8 4 2 1 BCD
times per second via interrupt. The Offset ADCoffset  = 2048 is weighting
subtracted from the ADC value and the result is then multiplied by 17A 18A 19A 20A 21A 22A 23A 24A Bit
ADCscale = 10 (Listing 1).
  Month (BCD coded 1...12) Meaning
The local oscillator (LO-DDS) phase is updated and the input value is
10 8 4 2 1 BCD
multiplied by the cosine (in-phase or I signal) and the sine (quadra- weighting
ture-phase or Q signal). The products are summed over 1250 samples
25A 26A 27A 28A 19A Bit
(in Isum and Qsum). The values are ​​ then (in Listing 2) passed to a FIFO
for further processing, which then takes place at 500000/s/1250 =
Day of month (BCD coded 1...31) Meaning
400 samples/s. This sample rate is so low that all the further process-
20 10 8 4 2 1 BCD
ing can be carried out using double variable values.
weighting
 
30A 31A 32A 33A 34A 35A Bit
The values ​​are read from the FIFO and passed through a fourth-order
Butterworth low-pass filter with a cut-off frequency of 3 Hz. During
development it was found that this low cut-off frequency was necessary Day of week (BCD coded 0...6) Meaning
because the author’s antenna received strong interference signals directly 4 2 1 BCD
adjacent to the wanted signal. This is followed by another down-sam- weighting
pling, this time by a factor of 4, so that 100 samples/s are then processed. 36A 37A 38A Bit
 
The msfSample() routine in Listing 3 then calculates the carrier ampli- Hour (BCD coded 0...23) Meaning
tude ampl from the I/Q components. The logarithm of ampl is derived 20 10 8 4 2 1 BCD
and in turn stored in ampl which makes it easier to decode the bits. weighting
  39A 40A 41A 42A 43A 44A Bit
The switching level threshold is derived from ampl via a first-order
recursive filter calculation. The signal ampl is then compared with Minute (BCD coded 0...59) Meaning
the switching level threshold to determine its digital receive value 40 20 10 8 4 2 1 BCD
sigValue. Now with the analogue signal processing covered we can weighting
look at how the data is recovered from the received signal and how 45A 46A 47A 48A 49A 50A 51A Bit
this corresponds to the time-of-day information.
Minute marker Meaning
Reading the Bits 52A 53A 54A 55A 56A 57A 58A 59A Bit
The MSF transmitter sends out RF carrier pulses at each second as shown
0 1 1 1 1 1 1 0 Value
in Figure 10. At second 0 of every minute the carrier switches off for 500 ms.
The SDR uses this pulse for synchronization. The pulses emitted at each Parity bits
of the following 59 seconds contain two bits of information: A and B. At
Bit 54B with bit 17A to 24A results in odd number of bits
the start of each of these seconds the carrier is off for 100 ms (correspond-
Bit 55B with bit 25A to 35A results in odd number of bits
ing to 10 samples in our application). If Bit A = 1, the carrier remains off
for a further 100 ms, and if Bit B = 1, the carrier is off for another 100 ms. Bit 56B with bit 36A to 38A results in odd number of bits
  Bit 57B with bit 39A to 51A results in odd number of bits
In SecondTimer, a timer, synchronised to each second, runs from 0 to 99.
Figure 11: MSF time coding scheme. Source: [5].
The software decoding works as follows: In Duration, the pulse length of
the current pulse is measured. If a 0.5 s absence of the carrier is detected,

lektor July & August 2022 37


Listing 1: A/D sampling and local oscillator Operation. Summing and downsampling with a factor of 1250 at 400 Samples/s.
 
int16_t adcv=(uint16_t) adc_hw→result;             //get ADC result
hw_set_bits(&adc_hw->cs, ADC_CS_START_ONCE_BITS);  //start ADC again
pwm_clear_irq(pwm_gpio_to_slice_num(PWM_PIN1));    //interrrupt flag
DDSp += DDSd ;                                      //increment LO-DDS phase
inputVal=ADCscale*(adcv-ADCoffset) ;               //offset and scaling
Isum += LOcosTab[DDSp>>24]*inputVal ;              //I-multiplication
Qsum += LOsinTab[DDSp>>24]*inputVal ;              //Q-multiplication
SampleTime++ ;                                     //refresh this step
if(sampleTime>=1250){                              //downsampling
      FIFO...}                                     //further steps

Listing 2: Filtering the I- and Q- values and downsampling by a factor of 4 at 100 samples/s.
 
Isample=IntFifoI[IntFifoOutPtr] ;                  //get I-signal from FIFO
Qsample=IntFifoQ[IntFifoOutPtr] ;                  //get Q-signal from FIFO
IntFifoOutPtr=(IntFifoOutPtr+1) & IntFifoMask ;    //increment FIFO pointer
IfilOut = tprun(IIfil,Isample) ;                   //lowpass filter I-signal
QfilOut = tprun(QQfil,Qsample) ;                   //lowpass filter Q-signal
kdown++ ;
      if(kdown>=4){                                //downsampling factor 4
            msfSample(IfilOut,QfilOut) ;
            kdown=0 ;
            }

Listing 3: Calculating the amplitude ‘ampl’, the switching threshold, and the pulse duration to recover bits.
 
void msfSample(double ii, double qq){
      ampl=sqrt(ii*ii+qq*qq) ;                     //get carrier amplitude
      ampl=40*log(ampl+1) ;                        //log is better!
      threshold=0.995*threshold+0.005*ampl*0.95 ;  //recursive mean as threshold
      if(ampl>threshold){                          //comparator function
            sigValue=1 ;                           //digital value = 1
            }
      else {
            sigValue=0 ;                           //digital value = 0
            }
      doScope(ampl/2.0+20,threshold/2+20,sigValue*10+10, DAC/2.0+30) ;
      if(sigValue==lastSigValue){
            Duration++ ;                           //pulse goes on
            }
      else {                                       //pulse end reached
            tt=pulseForm(lastSigValue,Duration) ;  //get pulse character
            if(tt==’z’){
                  printf("sync on z") ;            //signalize sync
                  SecondTimer=50-2 ;               //sync SecondTimer
                  }
            printf("%c",tt) ;                      //display pulse character
            Duration=0 ;                           //new pulse length starts
            lastSigValue=sigValue ;                //update lastSigValue
            }

Listing 4: Sampling of bits A and B triggered by SecondTimer.


 
IncSecondTimer() ;                         //SecondTimer runs from 0 to 99
DAC=SecondTimer ;                          //scope sawtooth signal
if (SecondTimer==5+0) { DAC=60 ; }         //scope signal pulse
if (SecondTimer==15+0) {                   //bit A sample time
   DAC=60 ;                                //scope signal pulse
   putMSFbit(Second,0) ;                   //clear bit store
   if (sigValue==0) {                      //if carrier switched off
      addMSFbit(Second,1) ;                //Bit A set true
      } ;
   }
   if (SecondTimer==25+0) {                //bit B sample time
      DAC=60 ;                             //scope signal pulse
      if (sigValue==0) {                   //if carrier switched off
         addMSFbit(Second,2) ;             //Bit B set true
         } ;
      }

38 July & August www.elektormagazine.com


I
Low pass Low pass
filter filter
COS COS
Input ADC 60 kHz 100 Hz Ouput
Down-
250k +
Samples/sec
sampling

SIN SIN

Low pass Low pass


Q filter filter
220006-014

Figure 12: Upconversion to a 100 Hz IF.

SecondTimer is set to the value 50-2=48 so that the SecondTimer timer frequency or IF. The IF signal is then filtered with a relatively narrow
now runs synchronously with the second (Listing 4). At the same time, band filter. The IF signal of the MSF60 receiver can also be viewed
the minute is synchronized by setting the value of the current second to using an oscilloscope. Our receiver mixes the input signal down to IF =
0 in doMinuteSync(). 0 Hz. If you want to observe an AC IF signal, you can upconvert the 0
  IF signal to an AC IF. The circuit block diagram is shown in Figure 12.
With the help of SecondTimer, the received signal is sampled at the mid-bit  
position of Bit A and Bit B (SecondTimer==15 and SecondTimer==25) in The software to perform the necessary upmixing is shown in Listing 8.
order to determine the values of​​ these transmitted bits. We simply output A PWM output is used as the DAC. The 100 Hz AM-modulated IF
the received digital value via GPIO-Pin 4 (Pico-Pin 6): signal is shown in Figure 13.
   
gpio_put(GPIO4, sigValue); // Output sigValue at This completes the design and construction of the MSF receiver. Only
// pico GPIO4=pin 6 one core of the processor is used in this application, leaving plenty
  of computing power for expansion. The bit decoding, for example,
The value of SecondTimer is also output later for debugging purposes could be made more error-tolerant. A DCF77 receiver could be built
via PWM, as are the values ​​of ampl and DAC. This is achieved with the in much the same way, only the bit decoding process would need to
following two statements: be adapted. The MSF signal reception here in Aachen (Germany) is
  much weaker than the DCF77 signal with an equivalent SDR. This often
pwm_set_gpio_level(PWM_PIN1, ampl/5.0 ); // Output results in parity bits indicating errors in the received information but
// amplitude sufficient error-free messages still get through frequently enough to
pwm_set_gpio_level(PWM_PIN2, DAC );       // Output timing allow accurate time of day information to be displayed reliably.

Decoding Time Information Working with an RP2040


Whenever SecondTimer is synchronized by the 0.5 s gap, one minute has We have shown that with very little additional hardware, the
passed and we can evaluate the latest time information. The received data Raspberry Pi Pico board can be turned into a complete MSF SDR.
bits are in the values ​​MSFbits[0 to 59]. The transmitter encodes the
information listed in Figure 11 into these bits. The time and date information
is then simply reconstructed as in Listing 5 to give hours and minutes.
 
We also display the same information that we send out via the serial
interface as text on the LCD. This is done using the instructions given
in Listing 6. A parity check on the received information is evaluated as
in Listing 7. The monitored bits are the A-bits of the transmitted infor-
mation. The four check bits are B-bits of each corresponding seconds
pulse. Four parity checks are carried out, the integrity of up to 12 bits are
protected by one parity bit.

Debug Signals
Classic superhet receiver designs mix the incoming RF signal with a
variable frequency local oscillator signal to produce a lower intermediate Figure 13: 100 Hz amplitude modulated IF Signal.

lektor July & August 2022 39


Listing 5: Decoding and serial BCD output of hours and minutes.
 
void OutBCD2(int v){                           //issue 2 BCD digits
   uartPutc(’0’+(v>>4)) ;                      //via serial interface
   uartPutc(’0’+(v & 0xf)) ;
   }
int GetBCDbits(int StartPos , int Length){     //fetch length bits from MSFbits
   int v,k ;                                   //start at StartPos
   V=0 ;                                       //BCD coding
   for (k=0 ; k<Length ; k++ ){
      v=(v<<1) + ( MSFbits[StartPos++] & 1) ;
      }
   return v ;
   }
hours =GetBCDbits(39,6) ; OutBCD2(hours ) ;     //hours = bits 39 to 44
uartPutc(’:’) ;
minutes=GetBCDbits(45,7) ; OutBCD2(minutes) ;   //minutes = bits 45 to 51
UartBlank()

Listing 6: Output Hours and minutes information to the LCD.


 
LcdPutc(CRcode) ;                  //output carriage return
LcdPutc(LFcode) ;
LcdPutc(’0’+((hours>>4)&0xF)) ;    //MS digit of hours
LcdPutc(’0’+(( hours)&0xF)) ;      //LS digit of hours
LcdPutc(’:’) ;                     //separator
LcdPutc(’0’+((minutes>>4)&0xF)) ;  //MS digit of minutes
LcdPutc(’0’+(( minutes)&0xF)) ;    //LS digit of minutes
LcdPutc(’:’) ;                     //separator

Listing 7: Parity checking.


 
LcdPutc(CRcode) ;                          //output carriage return
int parity(int from , int to) {            //parity over A bits
int parity ;
int k ;
parity=0 ;
   for (k=from ; k<=to ; k++){
      parity ^= MSFbits[k] ;               //XOR with bits
      }
Parity &= 1 ;                              //select A bit
return parity ;
}
void parityCheck(int from , int to , int checkPosition) {
   int p ;
   p=parity(from,to) ;
   if ( (MSFbits[checkPosition] & 2)>0) {  //B bit is parity
      P ^= 1 ;                             //XOR parity bit
      }
   uartPutc(’ ’) ;
   uartPutc(’P’) ;
   uartPutc(’=’) ;
   uartPutc(’0’+p) ;                       //output parity bit
   }
   ParityCheck(17,24,54) ;                 //four parity checks
   parityCheck(25,35,55) ;
   parityCheck(36,38,56) ;
   ParityCheck(39,51,57) ;

Listing 8: Coding for software upmixing.


 
debugDDSp += debugDDSd ;              //100Hz phase update
v=IfilOut*cosTab[debugDDSp>>24]       //add I signal
   +QfilOut*sinTab[debugDDSp>>24] ;   //add Q signal
v=62+v/1024 ;                         //offset and scaling
pwm_set_gpio_level(PWM_PIN2,v );      //PWM output

40 July & August www.elektormagazine.com


RELATED PRODUCTS

> Elektor Raspberry Pi RTL-SDR Kit (Book and


Components) (SKU 19518)
www.elektor.com/19518  
The most complex element of this build is construction of the active
antenna. Given the processing power and low cost of the board this > Elektor SDR Hands-on Kit (Book and SDR-Shield with
application shows what even a hobbyist with few resources can achieve ferrite toroid and cable) (SKU 19041)
nowadays. You often read how easy the Pico board can be programmed www.elektor.com/19041  
in Python, but in this application, it will not be able to cope with the
> Raspberry Pi Pico RP2040 (SKU 19562)
500k sample rate of the input signal. With C, however, the microcon- www.elektor.com/19562
troller hardware can be addressed more directly and programmed
efficiently. We see here that even without the benefit of a floating point
unit (FPU) the RP2040 is still more than capable of implementing a
low-pass digital filter. 
220006-01

r
this Elekto
Questions or Comments? Check out bout the
If you have any technical questions regarding this article you can video a Pi Pico! 
contact the author at ossmann@fh-aachen.de or the Elektor team Raspberry
at editor@elektor.com.

WEB LINKS
[1] “Time from NPL (MSF),” Wikipedia: https://en.wikipedia.org/wiki/Time_from_NPL_(MSF)
[2] “Time receiver for the Rugby MSF,” Elektor 9/1982: www.elektormagazine.com/magazine/elektor-198209/44950
[3] J. Buiting, “Retronics - Elektor Junior Computer,” Elektor 1/2005: www.elektormagazine.com/magazine/elektor-200501/17897
[4] 3.5” Display: www.lcdwiki.com/3.5inch_Arduino_Display-UNO
[5] NPL Time & Frequency Services, “MSF 60 kHz Time and Date Code”
www.npl.co.uk/products-services/time-frequency/msf-radio-time-signal/msf_time_date_code

Advertisement

PERFORMANCE. WE are here for you!


RELIABILITY. Join our free webinars on:
www.we-online.com/webinars
SERVICE.
Optocouplers by Würth Elektronik
With the new optocouplers, Würth Elektronik presents one of the latest additions
Optocouplers by Würth Elektronik to its optoelectronic product portfolio. The innovative design features a coplanar
structure and high-grade silicon for total internal reflection. The coplanar design
ensures the isolation gap stay fixed during the production process and provide
perfect isolation and protection for your application. The total internal reflection
provide stable CTR over the whole temperature range and high CTR even at low
current operation.

Provided in all industry standard packages. Available with all binnings ex stock.
Samples free of charge: www.we-online.com/optocoupler

• Innovative coplanar design • Stable CTR over whole


© eiPal

• High grade silicon encapsulation temperature range


• Copper leadframe for high reliability • High CTR in low current operation

lektor July & August 2022 41


background

Moisture Sens rs for


Watering Systems
Automatic Watering

By Peter Tschulik (Austria) and


 
Christof Hübner (Germany)
Moisture sensors have two tasks in a watering system: they inform the
Before you start working with system about the current watering status, and as a result they help
to make economical use of water as a resource. Quite a few plants
moisture sensors, consider the are equally intolerant to waterlogged or dry soil. Although there are
following tips about sensor selection an enormous number of moisture sensors, it appears that only a few
and sensor integration. Once you really work properly.
 
are familiar with the basics, you can After a brief overview of the operating principles of the most common
begin integrating the sensors using moisture sensors, this article focuses on sensor integration using the
the Arduino IDE for boards such as Arduino IDE for commonly used boards such as Arduino or ESP. If
you are currently using a watering system without sensors or are not
Arduino and ESP. satisfied with your moisture sensors, you’re in the right place here.
 
Measuring Soil Moisture
There are a number of different definitions of soil moisture. The volumet-
For many years, I have been using automatic watering systems to make ric water content, which means the proportion of water in the total
gardening more convenient. My first system consisted of a simple volume of soil, is usually what is wanted. If all air spaces in the soil are
timer clock with inexpensive solenoid valves, like the ones used in filled with water, the maximum volumetric water content in natural soil
washing machines. The next generation featured an Arduino board is approximately 50 to 60%. Higher values are possible in peat and
with a display, and it obtained its information from simple capacitive other organic materials.
moisture sensors, and even maintained a watering log. My current  
watering system is based on an ESP32 and is fully integrated into The gravimetric water content relates to the relative mass of water in
my home automation system. This allows me to manually switch on the soil and can be determined, for example, by weighing a soil sample
the watering system, view the most recent watering times, set these before and after drying. This parameter must be measured in a lab,
times and other parameters, and much more. I hope you can benefit so it is not suitable for the continuous monitoring of soil moisture.
from my experience.  
  Electrical soil moisture sensors are based on a variety of physical
The above description is not entirely complete. For instance, there is also measurement principles. Measuring the electrical conductivity is very
an alarm function that reports things like when a watering session failed, inexpensive, but unfortunately not reliable because the conductivity is
for example due to a broken hose. The system can also be operated from also dependent on the amount of dissolved ions. With the same water
a web browser and the software can be updated over the air. content, measuring the conductivity can lead to completely different
  results depending on the type of soil, salt content and fertilisers. The
The watering system is, however, not the focus of this article because conductivity is also strongly temperature dependent, and compen-
it is very much designed to meet my specific needs (my patio). Instead, sating for this is virtually impossible in practice. However, the biggest
I would like to describe my experience in selecting moisture sensors, problem is corrosion of the sensor electrodes, which often last only
since I have learned a lot about them over the years. a few days or weeks.

42 July & August www.elektormagazine.com


 
Capacitive sensors with electrodes protected by an insulating layer sensor is exposed to strong corrosion in the soil and consequently has
are much better in this regard. The measurement principle is based a short lifetime. This also applies to electrodes with thin gold plating.
on the interaction of water molecules with an electric field, since water In addition, the terminals are usually not protected against water.
molecules are dipoles with positive and negative ends. If a dipole is  
placed between the electrodes of a plate capacitor and a voltage is Advantage: Very economical.
applied to the metallic electrodes, the dipole will align itself to the
electric field (see Figure 1). Low-Frequency Capacitive Sensors
  Measuring principle: The soil moisture is determined by measuring the
This polarisation effect is expressed by the dielectric constant εr. It capacitance. The electronic circuit operates at low frequencies in the
ranges from εr = 1 for air through εr = 3 to 8 for mineral soil particles range of several kilohertz to around 1 MHz. Many different versions can
to εr = 80 for water [1]. The effective dielectric constant of a given soil, be found online, often working with an NE555 timer (see Figure 3).
consisting of a mix of air, water and soil particles, is therefore largely  
determined by the water content. If a soil sample is placed between the Disadvantages: Due to the low operating frequency, moisture measure-
electrodes of a capacitor and the resulting capacitance is measured, ments are more strongly influenced by other factors such as the electri-
the associated dielectric constant can be calculated and from it the cal conductivity and temperature of the soil, so only limited accuracy
water content. In practice, an AC voltage is applied to the electrodes is possible. The electrodes are often only protected by a thin layer
to reduce electrolysis at the capacitor electrodes, disturbances from of solder resist, which does not last long in the soil. The circuit and
surface polarisation, and the influence of soil conductivity. Increasing terminals are often not sealed water-tight.
the frequency of the measurement signal leads to more accurate results  
and increases the immunity to interference. Frequencies above 100 MHz Advantage: Fairly economical.
are ideal, but would make the circuitry significantly more expensive.
VH400 High-Frequency Capacitive Sensor
Conductivity Sensors Measuring principle: The soil moisture is determined by measuring
Measuring principle: The soil moisture is determined by measuring the the capacitance.
electrical conductivity of the soil between two electrodes. The sensor  
is usually supplied with an analog signal processing circuit with an Disadvantages: Medium price range. The influence of the soil type
adjustable threshold value (see Figure 2). on the measurement is still noticeable. The electrodes are very close
  together, so the electrical measurement field barely extends beyond the
Disadvantages: The electrical conductivity of soil depends not only on circuit board and the suitability of the sensor for large-grained soil is
the water content, but also strongly on the salt content, fertilisers and limited (see Figure 4). The measurements are temperature dependent
soil type, and is therefore an unreliable measure of soil moisture. The and change when the connecting cable is touched with the hand [5].

Figure 2: A sensor for


conductivity measurement (YL69
or similar; source: [2]).

Figure 1: Orientation polarisation of dipole water molecules in a


plate capacitor.

Figure 3: Example of a low-frequency Figure 4: VH400


capacitive sensor (source: [3]). sensor (source: [4]).

lektor July & August 2022 43


 
Advantage: Sufficiently accurate moisture measurement in many types
of soil.

CWT-SOIL-H-S
Figure 5: CWT-SOIL-H-S Measuring principle: No information available regarding the measur-
sensor (from AliExpress; ing principle or measuring frequency.
source: [6]).
 
Disadvantage: Medium price range. Frequent failures after a short
time in the soil.
 
Advantages: Holds the promise of additional measurement of electri-
cal conductivity; various versions (see Figure 5).
Figure 6: SMT 50 high-frequency capacitive sensor
(source: [7]). SMT 50 High-Frequency Capacitive Sensor
Measuring principle: The soil moisture is determined using a capacitive
voltage divider. The circuit operates at 16 MHz or above.
 
Disadvantages: Medium price range. The influence of the soil type on
the measurement is still noticeable.
 
Advantages: The measuring frequency is high enough for reliable
moisture measurement in many types of soil. The electrodes are embed-
Figure 7: DAV-6440 ded in a multilayer circuit board, providing good mechanical protec-
sensor (source: [8]). tion and long lifetime in the ground. The circuitry is encapsulated in
epoxy to make it completely waterproof (see Figure 6). The 10 m long
connecting cable with a polyurethane sheath is suitable for under-
ground installation (resistant to microbes and hydrolysis).

DAV-6440 Tensiometer
Measuring principle: This Watermark sensor is an example of a tensi-
ometer, which measures the soil moisture tension (correlated to the
water content of the soil). For this the electrical resistance of a material
in hydraulic contact with the soil is determined (see Figure 7). Other
tensiometric sensors use a non-woven fabric in contact with the soil
and determine its water content by electrical heating while observing
the temperature (e.g. Gardena sensors).
 
Disadvantages: Tensiometers are sluggish and respond slowly to chang-
ing soil moisture. There is a hysteresis effect, resulting in different
measurements with the same soil moisture tension (with rising versus
falling water content). Under very dry conditions the sensor can lose
hydraulic contact with the soil. The stated lifetime of this sensor in the
ground is at least 5 years, which is not especially long.
 
Advantage: The soil moisture tension indicates the soil moisture avail-
able to the plants.
Figure 8: SMT 100 TDT Figure 9: Operating
sensor (source: [9]). principle of a TDT sensor. SMT 100 TDT Sensor
The moisture-dependent Measuring principle: This time domain transmission (TDT) sensor
pulse propagation time consists of conductor loops forming a high-frequency transmission
of the loop conductor is
line that is driven by pulse signals (see Figures 8 and 9). A ring oscil-
converted into a frequency.
lator is implemented by feedback to an amplifier, and its frequency is
measured by a microcontroller. The capacitance between the electrodes
is influenced by the soil moisture. The higher the moisture content,

44 July & August www.elektormagazine.com


Watering Strategy

Integration of Sensors in Watering Systems


As previously mentioned, low-cost sensors have analog interfaces
and only higher-grade sensors have digital interfaces. Simple analog
sensors can be integrated easily in the Arduino IDE without additional
libraries. All you need is an analog input. Pin A0 of an Arduino Uno is
used in the following example program.
 
int SENSOR_PIN = A0;  /* select analog pin */
int SENSOR_VAL = 0;     /* variable storing sensor value */
void setup()
{
  Serial.begin(9600);    /* setup serial connection */
Comparison of time-controlled and sensor-controlled watering. }
  void loop()
Conventional time-controlled watering irrigates in fixed time inter- {
vals, regardless of the actual need for watering. It can therefore lead   /* read value */
to overwatering with harmful waterlogging or to underwatering and   SENSOR_VAL = analogRead(SENSOR_PIN);
dry stress, depending on weather conditions. This can be mitigated   Serial.println(SENSOR_VAL);    /* output value */
by using a rain sensor or online weather information. Sensor-con- }
trolled watering is much better. This not only allows optimal water  
supply to the plants, but also reduces water consumption. The Higher-grade sensors, such as the CWT-SOIL-H-S or SMT 100, provide
differences are shown in the chart. digital interfaces. In my system both sensors are connected through
  a Modbus RS-485 interface. The advantages of this connection are
There are various strategies for setting the threshold levels. An obvious: Long cable runs (up to 100 m from the sensor to the control
experienced gardener can recognise the start of dry stress by unit) are not a problem, and data transmission is immune to inter-
observing the plants (slight wilting, rolling of leaf edges). Exces- ference. In addition, many sensors can be connected over the same
sive watering results in saturation, with no further increase in soil interface.
moisture. If you wait a while (around 24 hours), the excess water  
will drain into the subsoil. As a rule of thumb, you can set the lower The CWT-SOIL-H-S sensor basically works well, but in my system two
threshold to 60% of the saturation level. During the learning phase, sensors simply stopped working after two years or started indicating
observe the plants together with the moisture trend and adjust unrealistic values. In addition, the included user guide is understand-
the threshold levels as necessary to achieve long-term optimal able but the configuration tool described in the user guide is difficult
and economical automatic watering. It is important to position the to find online and is only in Chinese. For this reason, only the integra-
sensor properly in the root area of the plants. To obtain a good soil tion of the SMT 100 sensor is discussed below.
moisture cycle with drip irrigation, the sensor should not be placed  
too far away or too close to the drip location. First some remarks about RS-485 and Modbus. RS-485 is a differ-
ential serial interface with two lines that transmits data in differential
mode, which suppresses common-mode interference and improves
the signal-to-noise ratio compared to RS-232. Robust connections
up to 100 m long can be made with simple unshielded twisted-pair
the longer the pulse propagation time and the lower the frequency cables. Modbus is a client/server communication protocol, developed
of the ring oscillator. in 1979 for communication with programmable logic controllers. This
  open protocol has become an accepted industry standard. All techni-
Disadvantage: Upper price range. cal documents are freely available at [10]. Each node basically has a
  unique address for accessing the node.
Advantages: The measuring frequency is over 150 MHz, enabling high
accuracy with good resolution combined with minimal influence of Configuring Sensors
the soil type on the measurement. Thanks to a multilayer circuit board For initial experiments with the SMT 100, it is advisable to use a USB/
with epoxy encapsulation and a high-grade cable, the sensor achieve RS-485 bridge or a PCIe RS-485 card so that the sensor can commu-
a long lifetime in the soil. A large selection of interfaces is available, nicate directly with a laptop or desktop computer. I use a well-docu-
including analog output, RS-485 (TBUS/ASCII and Modbus), SDI-12 mented USB adapter based on an FTDI IC.
and 4-20 mA current loop.  
  A very convenient Modbus configuration program can be downloaded
The SMT 100 sensor is often used for professional purposes (precision from the website of the sensor manufacturer [11]. After unpacking and
agriculture or scientific applications in hydrology and soil science). installation, proceed as follows to connect the RS-485 version of the

lektor July & August 2022 45


Figure 10: Modbus test program for the SMT 100 sensor. Figure 11: Test setup for connecting an SMT 100 sensor to an ESP32.

Figure 12: Output in the Arduino IDE Serial Monitor window.

 
sensor to the RS-485 interface: The white wire of the sensor cable is Along with the readily available ESP32-DEV-Kit, it consists of a small
ground, the green wire is RS-485 A, and the yellow wire is RS-485 B. A board that converts the RS-485 signal from the sensor into TTL levels
supply voltage in the range of +4 V to +24 V (with respect to ground) suitable for the microcontroller. Terminal DI is an input for serial data
must also be connected to the brown wire. transmission from the ESP32 to the sensor. Terminal RO receives data
  from the ESP32 to be sent to the sensor. Terminals DE and RE are
After launching the Modbus tool, you first have to select the COM connected together here. When these terminals are pulled low, the
port. If you are using a USB adapter and no port is shown, you need to receiver in the MAX485 IC is enabled, and when they are pulled high
install the appropriate driver. If everything is okay, the window shown the MAX485 transmitter is enabled.
in Figure 10 appears.  
  Now let’s look at the test program [12]. The first part (before the setup
Now you can read out the individual parameters or change the Modbus routine) defines the pins and the variables for the sensors. In the setup
address. By default the sensor is accessible at address 253 (Broad- routine the pin for switching the transmitter/receiver is initialised, the
cast). If you want to connect multiple sensors, each sensor must have standard serial interface is defined as the debug interface, the serial
a unique address. In the example program the Modbus address is set interface to the sensor is initialised as ‘Hardware Serial Interface 2’,
to 1 by the instruction Set new MODBUS Address. To be on the safe and a subroutine checks whether the sensor is connected properly.
side, you can check communication via address 1, for which Modbus  
Address on the left must be set to 1. Note that only one sensor at a In the main loop the sensor is polled every three seconds by calling the
time can be connected to the bus when setting the address. subroutine SUB_RECEIVE_HUMIDITY, and the result is output. Querying
the sensor values is handled by three subroutines: SUB_CHECK_HUMID-
A Test Program ITY checks the received sensor address for correctness to verify that
Now let’s see how this sort of sensor can be integrated into a watering a sensor is connected, SUB_RECEIVE_HUMIDITY fetches the sensor
system. The test setup is shown in Figure 11. value, and SUB_CALCULATE_CRC calculates the CRC checksum. The

46 July & August www.elektormagazine.com


complete, extensively commented example code can be downloaded Questions or Comments?
free of charge from [12]. If the output in the Arduino Serial Monitor Do you have any questions or comments about this article? Contact
window is similar to that in Figure 12, everything is working right. the author at peter.tschulik@chello.at or the Elektor editorial team
210684-01 by email at editor@elektor.com.

WEB LINKS
[1] C. Hübner, U. Kaatze, Electromagnetic moisture measurement, Universi-
RELATED PRODUCTS tätsverlag Göttingen: https://doi.org/10.17875/gup2016-958
[2] YL69 conductivity sensor: https://bit.ly/YL69-soil-sensor
[3] Capacitive sensor: https://bit.ly/cap-sensor
> ESP-C3-12F-Kit Development Board with [4] Vegetronix VH400: https://www.vegetronix.com/Products/VH400
Built-In 4 MB Flash (SKU 19855)
www.elektor.com/19855   [5] Sensor comparison (German language): https://bit.ly/SMT50-vs-VH400
[6] CWT-SOIL-H-S sensor:
> MakePython ESP32 Development Kit https://de.aliexpress.com/item/1005001524845572.html
(SKU 20137) [7] SMT 50 sensor: https://www.truebner.de/en/smt50.php
www.elektor.com/20137   [8] DAV-6440 sensor: https://bit.ly/DAVIS6440
> Bundle: Getting Started with ESPHome + [9] SMT 100 sensor: https://www.truebner.de/en/smt100.php
LILYGO TTGO T-Display ESP32 (16 MB) [10] Modbus: https://modbus.org
(SKU 19896) [11] SMT 100 Modbus tool:
www.elektor.com/19896 https://www.truebner.de/download/ModbusTool_Installer_V3.zip
[12] Example code: http://www.elektormagazine.com/210684-01

Advertisement

Development Tools alle


an einem Ort
Tausende Tools von hunderten Wählen Sie Ihr Produkt aus
unserer breiten Palette auf
zuverlässigen Herstellern mouser.de/dev-tools

dev-tools-workbench-185x124mm-5mmbleed-DE.indd 1 17.05.22 12:04

lektor July & August 2022 47


background

Disruption in
Test and
Measurement Equipment
Innovation from the Smaller Players
FOCUS ON

Test &
Measurement
By Stuart Cording (Elektor)

There’s nothing more satisfying than seeing a lab stocked with


test and measurement equipment. It is a sign that things are being
undertaken correctly. However, the cost of traditional tools can be
prohibitive for startups, smaller businesses, and students. So what is
being done to make measurement more accessible to the masses?

Scouring the halls and stands of an electronics exhibition such as development. In such cases, a single tool may be locked into a setup
electronica or embedded world, it is very easy to get excited about for days or weeks, stopping others from using it.
the rows of test and measurement (T&M) equipment emanating  
from the world’s foremost suppliers. Color displays, smooth and For some time now, the traditional T&M suppliers have been under
soft buttons, and knobs that provide a reassuring haptic bump on attack from disruptors. Startups and electronics industry veterans,
rotation exude quality, reliability, and accuracy in measurement. frustrated by the complexity of traditional tools, drab exteriors,
But this all comes at a price. Even entry-level, 50-MHz bandwidth and underperforming user interfaces, have been delivering some
oscilloscopes from the big names, like Rohde & Schwarz or Keysight, competent alternatives that deliver exceptional capability for a
won’t leave you much change out of €1,000. Signal generators fraction of the price of a benchtop alternative. This has changed
and spectrum analyzers start at around €2,000. And, if you want the way engineers equip their laboratories, and it is also changing
to be more mobile, perhaps with a handheld, you’re looking at how students learn.
significantly more.
  Lab in a Box
The strain on budgets quickly becomes apparent when it comes Traditionally, sourcing an oscilloscope, power supply, spectrum
to equipping laboratories. This is exacerbated by the use cases analyzer, waveform generator, and voltmeter required a healthy
of the typical education or research and development environ- budget and a robust table, with each item supplied as an isolated
ment. While a student or engineer may spend all day at the bench, piece of equipment. Over the years, and linked to the growth in
individual items of T&M will see differing amounts of use. Some automated test systems, suppliers such as National Instruments
equipment may be used the entire day, while others are used only have developed modular hardware T&M solutions, such as PXI.
weekly. Oscilloscopes and spectrum analyzers are also cumbersome These consist of a chassis into which a range of measurement cards
items, making them awkward to keep moving around. With the can be inserted, enabling the creation of custom instrumentation
complexity of applications continuously rising, T&M equipment solutions. But what if the hardware could remain the same, with
is also regularly incorporated into test automation systems during just the software defining the measurement capability?

48 July & August 2022 www.elektormagazine.com


ELEKTOR INDUSTRY

Figure 1: The Moku family uses an instrument-on-chip (IoC) approach, Figure 2: The Moku:Go is the entry-level, portable test and measurement
featuring highly capable analog coupled with a reconfigurable FPGA to instrument from Liquid Instruments. (Source: Liquid Instruments)
implement the various supported capabilities. (Source: Liquid Instruments)

 
This is the question raised by the five founders of Liquid generators, logic analyzer, and spectrum analyzer. Beyond this
Instruments, a team based just north of San Diego, California. The are advanced instruments, such as an FIR filter builder, data logger,
group of scientists, who had participated in experimental physics 20 MHz lock-in amplifier, and multi-input/output PID controller [2].
and research into gravitational waves, found the existing T&M This last instrument highlights the capability of such equipment,
offering to be inflexible and lacking in scalability. The availabil- enabling up to two PID controllers to be implemented, configured,
ity of powerful system-on-chip (SoC) field-programmable gate and monitored. The interactive Bode plot offers real-time control
arrays (FPGAs) made them feel there was a basis for developing a and multi-section PID builder configurations for superb insight into
common hardware platform that could be used in many different how it functions for those building or teaching control systems.
ways (Figure 1). Their goal became to enable users to build measure-  
ment solutions that even the team hadn’t thought of. Talking to Michi Yoneda, one of the Liquid Instruments team, he
  explains that the Moku line-up frequently finds a home in university
The result of their efforts is the Moku range of software-defined labs and research institutes. There it is used for everything from
T&M solutions. At the lower end of the price spectrum is the photonics and LiDAR, to spectroscopy and quantum computing.
Moku:Go (Figure 2), an engineering platform designed to fit easily The ability to change instrument on-the-fly and its programmable
in a student’s or engineer’s backpack. Measuring just 24 × 13 cm and interface make it a valuable alternative to costly, traditional T&M
just 3.8 cm high (9.4” × 5.1” × 1.5”), it features two 12-bit, 125-MSa/s equipment. Users can also develop their own instruments even
analog input channels, offers 30-MHz bandwidth, and has an input without access to traditional FPGA development tools. Thanks to
range of ±25 V. On the output side, there are two 12-bit, 125-MSa/s their Cloud Compile [3] platform, those proficient in VHDL can
analog outputs with 20-MHz bandwidth and a ±5-V range, plus 16 create the bitstream required. Currently, this capability is limited
channels of digital I/O. Four power supply outputs that support to the high-end Moku:Pro, but there is a chance that the feature
between 150 mA and 1 A and -5 V and 16 V, model dependent, will be rolled out to the rest of the range.
round off the tool’s features.  
One concern of such tools is their accuracy. For sure, they are
Grab Your Tablet suitable for garnering a general view of signals on a printed circuit
Like similar tools of this kind, it relies on other equipment for the board (PCB), but could I base promises to a customer on the value
graphical user interface (GUI). While laptops and PCs can access measured? Yoneda ensures me that, yes, this is possible, thanks
the GUI through a browser, Moku is optimized for use with the to a third party who offers calibration together with a certificate.
touch screen of an iPad. Wi-Fi provides the Moku:Go M0 and M1’s
connectivity, while the M2 also features an Ethernet port. Thanks From Frustration to Logic Analyzer
to careful consideration for the GUI design, the interface looks Having set up probes on a serial interface and found a suitable
clean and is intuitive. decoder on your logic analyzer, one of the most frustrating things
  is discovering that it requires a paid license. After all, the hardware
Out-of-the-box, the Moku:Go [1] offers 11 different instruments, is already capable of the job, and you’ve paid for the tool. And other
including an oscilloscope, standard and arbitrary waveform times, it is simply a lack of access to affordable test equipment

lektor July & August 2022 49


today it is the Logic 8 (Figure 3) that kicks off their offering [4]. It
provides eight mixed-signal inputs that can record digital, analog,
or both. With a digital sampling rate of 100 MSa/s, and 10 MSa/s
for analog, it covers the majority of use cases found in research
labs and education.

Smooth Moves
What really stands out is their Logic 2 software (Figure 4), the
user interface to the tool that runs on Windows, Linux, and Mac
OSX. The GUI is intuitive, allowing the user to enable and disable
channels, name them, and the color-coding used relates to the
colors used for the unit’s connecting cables. Decoding of standard
serial protocols is also supported, from I2C, SPI, and UART, to
MIDI, Modbus RTU, and even the HD44780 interface used on
Figure 3: The entry-level Logic 8 from Saleae offers eight channels of alphanumeric LCDs. The device is also frequently used for data
mixed-signal capture in a tiny machined aluminum package that is just 5.3 logging, with developers using the Python application program-
cm on a side. (Source: Saleae) ming interface (API).
 
However, compared to a traditional benchtop, the ease with which
signals can be reviewed in the software is what really blows the
which leads to the forming of businesses like Saleae, the devel- user away. Garrison explains that the ease of use of the Google
oper and manufacturer of the popular USB-based logic analyzers. Maps user interface had proven to be an inspiration at the time of
  initial development. The GUI enables consecutive edges in the data
Mark Garrison, Saleae’s Vice President of Engineering, explains stream to be found easily, even when widely spaced. ‘Flicking’ the
that the initial trigger to develop their tools came when his brother data stream left or right scrolls the logic output until it slows to an
worked on an embedded design. Back then, a benchtop logic eventual stop if not held earlier. This is a vast improvement over
analyzer wasn’t financially viable, not even used on eBay, so he’d the knobs and buttons of traditional test equipment.
procured a USB-based device. The only issue was that this tool  
required more debugging than the product he was building. Today, around 80% of sales are into professional engineering teams,
  many of whom value the high-resolution data capture offered in
Over the years, their logic analyzer line-up has developed, but this modest device. The remaining customer base is makers and

Figure 4: Logic 2 provides the user interface for Saleae’s tools. It is exceptionally easy to use, enabling edges to be located quickly and serial interfaces to be
decoded.

50 July & August 2022 www.elektormagazine.com


ELEKTOR INDUSTRY

hobbyists, education, and startups, happy to have access to this


caliber of tool at a more acceptable price point. This is reflected
in their active user forum [5], where the community helps and
supports one another, both with the tools and developer questions.
They also create extensions, a range of Python-based packages, that
can deliver metrics on the data captured, such as signal jitter, or
perform higher-level analysis of decoded data streams.

Lab in Your School Bag


While education establishments have done an excellent job of
building on the wave of interest for all things digital by deliver-
ing embedded programmers and app developers, enthusiasm for
analog amongst students has fallen sharply. This was the experi- Figure 5: The ADALM1000 (MK1) gives electrical engineering students a full
lab experience in their dorm or home. (Source: Analog Devices)
ence of Robin Getz, Director of Systems Engineering at Analog
Devices, in discussion with a professor at MIT one decade ago. At
the time, of 200 engineering students, only around four focused
on analog; the rest concentrated on software and digital. Such
insight spurred the development of a collection of low-cost Active
Learning Module platforms designed to provide easy access to both
analog and RF technology.
 
The range starts with the ADALM1000 [6] (also known as the M1K),
a self-contained tool that enables students to explore the relation-
ship between current, voltage, and impedance (Figure 5). Powered
and configured via USB, it offers two channels for signal generation
and measurement for both voltage and current. Its 16-bit, 100 kSa/s
oscilloscopes and function generators are more than adequate
for even intermediate study of analog concepts. Supporting it is
the simple-to-use, open-source PixelPulse 2 software [7] that runs
under Windows and Mac OSX. Linux users can build the applica-
Figure 6: Now standard equipment for Analog Device’s FAEs, the
tion themselves. A more traditional user interface is provided with ADALM2000 (MK2) includes an oscilloscope, function generator, logic
the software package ALICE [8]. analyzer, and pattern generator. (Source: Analog Devices)
 
Performance is pushed up a notch with the
ADALM2000 [9] (also known as the M2K)
(Figure 6). Two analog inputs (100 MSPS,
25 MHz) and two analog outputs (150 MSPS,
30 MHz) are complemented by two variable
power supplies (0 to ±5 V at 50 mA). There are
also 16 digital I/Os and two digital triggers. This
tool uses Scopy [10], a fully-featured instrument
GUI that runs on Windows, Mac OSX, and Linux
(Figure 7). The software also works on Android,
with the tool connected via an OTG adapter to
a tablet.

Measurement on Laptop and Tablet


Support for Android tablets is intentional, says
Getz. “We notice that students follow our lab
material on their laptops while using the M2K
with their tablet in the US. However, in Asia,
most students only have a tablet.” Students are
provided with a wealth of learning material
at the Engineering University Program [11] Figure 7: The GUI is critical for the success of any headless measurement tool. Scopy provides
website. clear access to its features and settings on all operating systems and Android tablets.

lektor July & August 2022 51


 
Rather than choosing a single learning institute’s curriculum, kitted out with their tools. As long as they work within the tool’s
the team has focused on creating an amalgam of all the course limits, there are a host of design challenges they can tackle when
materials institutes cover when teaching engineering students the supporting customers in the field. And, he notes, a woodworker
basics of electronics and components. In the US, students using doesn’t just own one hammer and one saw, so why should FAEs
the Analog Devices tools typically undertake the lab work at home solely rely upon benchtop test equipment?
rather than in the lab, then discuss the results and any anomalies 220201-01
with staff back at their college or university. They can also make
use of LTspice [12] to compare simulations with practical results.
During the restrictions imposed by Covid, this has ensured that Questions or Comments?
learning can continue. But it also raises the question, when do Do you have technical questions or comments about the
students get to learn about ‘proper’ test equipment? article? Email the author at stuart.cording@elektor.com or
  contact Elektor at editor@elektor.com.
“Benchtop equipment is still needed at some point,” says Getz.
“We see ourselves providing an on-ramp to understand how to
measure and test.”
 
Students are also spending more time studying the material. Those
RELATED PRODUCTS
using the M1K and a supply of components provided by Analog
Devices at the University of Limerick, Ireland, found students
engaged more deeply and spent more time validating the concepts > PicoScope 2204A (10 MHz) (SKU 17303)
covered in the course. Professor Hayes, the head of The Electronic www.elektor.com/17303  
& Computing Engineering Department, said that he sees students
become experts more quickly, just by “learning how to recreate > ScanaQuad SQ200 Logic Analyzer & Signal Generator
their lab environment” through their practical work [13]. (SKU 18103)
www.elektor.com/18103  
Test and Measurement Changed Forever?
Benchtop T&M is not going anywhere soon. Industry needs
standardized, calibrated commercial off-the-shelf (COTS) equip-
ment that integrates easily with common software program-
ming tools like National Instruments LabVIEW or MATLAB from
MathWorks. But, when it comes to education, price, and porta-
bility, the tools offered by these disruptive players offer masses
of quality measurement capability at a fraction of the outlay for
equivalent big-name T&M suppliers. Analog Device’s Getz also
highlights that their Field Applications Engineers (FAE) are all

WEB LINKS
[1] Moku:Go Product Page: https://bit.ly/35tKNmz
[2] “Multiple-Input Multiple-Output PID Controller,” Liquid Instruments: https://bit.ly/3NF3Zin
[3] “Moku Cloud Compile: A Getting Started Guide,” Liquid Instruments, September 2021: https://bit.ly/35tWR7m
[4] Saleae Logic Analyzers Product Page: https://bit.ly/3qWyt62
[5] Saleae User Forum: https://bit.ly/376dAyf
[6] ADALM1000 Product Page: https://bit.ly/3tXoFdE
[7] Pixelpulse Software: https://bit.ly/3NRfdkj
[8] ALICE Active Learning Interface (for) Circuits (and) Electronics Software: https://bit.ly/3tYFi96
[9] ADALM2000 Product Page: https://bit.ly/36G6IaZ
[10] Scopy Software: https://bit.ly/3Jcj2Nr
[11] Analog Devices Engineering University Program: https://bit.ly/3LE3OCt
[12] LTspice Product Page: www.analog.com/en/design-center/design-tools-and-calculators/ltspice-simulator.html
[13] “UL and Analog Devices partner on digital learning tool to recreate lab environment at home,” University of Limeric,
December 2020: https://bit.ly/3uOZVDB

52 July & August 2022 www.elektormagazine.com


November 15–18, 2022

Driving
sustainable
progress.
Discover the future today.
At electronica 2022.

Save the date!


Elektor infographic
By Robert van der Zwan

CTM: Growth Stronger Than TM


(and Staying Strong)
The coming years, the market for Communications
Test and Measurement (CTM) will grow much 11.20 USD Billion
stronger than the market just related to Test and
Measurement (TM). This is nothing new: in 2020, Yearly growth
we reported a 9% growth rate for the CTM market rate 8%
against 4% for ‘just’ TM. However, due to Covid-19,
one can now see a little less optimism for the global
6.53 USD Billion
CTM market during the coming years. Some market
research companies think that an 8% growth rate
would be more realistic, or even want to stick to a
7% estimate. Let us go for 8%, based on various
research carried out for market size and growth rate.

(Sources: Data Bridge Market Research;


MarketsandMarkets; Research and Markets; Vantage
Market Research)
2021 2028

Growth Rate CTM Market (USD Billion)

Sensors: Yes, It Is the Supply Chain


What applies to the global market
Global Sensor Market, 2021-2026 (USD Billion) for Communications Test and
Measurement, also applies to the global
USD Billion sensor market: demand stays high
the coming years, but Covid-19 has
disrupted the supply chain. Knowing
that eventually the supply disruptions
300 249.6 will end, the high demand has the last
word, leading to a growth of about
250 r year
9.8% pe 10% in the period 2021-2026. This
200 high growth rate has to do with the
156.6 fact that there isn’t any sector that
150 is not interested in smart (or not so
smart) sensors. Applications range
100 from reducing maintenance costs to
enhancing safety levels in transport and
50 healthcare.

2023 2024 2025 2026 (Source: Allied Market Research; BCC


2021 2022 Publishing)

54 July & August www.elektormagazine.com


Market Shares Sensors, by Type, 2019-2028

2019 2028

It Is the

en nd

nso n

se and
Radar Sensor

sor

em xim or

rs
se itio
sor

r
nso

nso

nso

nso

nso

n a enso

nso

nso

he
ts a
s
en

en

pos
se

l se

se

se

se

se
en ity

ed er

Ot
es

es

s
Bio

speomet
r

re

el

ity
nd
a
da

uc

ag

v
tic
All Around

ssu

tu

d
Le
ac ro
To

Im
Ra

mi
ra

ler
Op

Pre

spl P

tio

Hu
pe

ce
Mo
m

Ac
Te

di
What is and will be the most promising
measuring device this decade? Or, to
phrase it slightly differently: who would think of autonomous cars? Radar sensors the total global sensor market. This would
have thought that radar technology would can not only detect an object, but can amount to around $70 billion (USD) in 2028.
become so important? Radar technology also determine its shape, its direction of
should no longer be associated with movement and even its speed. Roughly (Sources: Allied Market Research; Fierce
aviation and shipping alone. What to speaking, radar sensors make up 20% of Electronics)

Where Are They Going? Where are all these sensors going? Which
sectors make the most use of all these
sensors? One might think that IT and Telecom
Market Demand Sensors, by Sector, 2019-2028 represent the most significant market for
sensors, given the growth in broadband
2019 2028 communication. Following that line of thought,
another high-growth sector, automotive,
would probably come in second. Yes, IT
and Telecom, as well as automotive, are still
going strong globally. But it is (consumer)
electronics that most definitely takes the
ics

al

ve

nse

rs
ar
co

he
tri

oti
ron

greatest chunk out of the sensor market


fe

hc
le

Ot
us

tom
ct

De
Te

alt
Ind

between now and 2028. From washing


Ele

Au
d

He
an

an

machines to fridges to game consoles, the list


IT

ce

is endless and that is precisely the point.


pa
ros
Ae

Source: Allied Market Research)

Covid-19 is an Impetus
for Growth?! Market Size Software Testing,
2021-2027 (USD Billion)
When compared to two years ago, marketing research firm Global
Market Insights is somewhat more optimistic when it comes to the 2027
global market of software testing. There are at least two reasons for > 60 USD Billion
that. Software applications in the cloud become more popular by
the day. Given the fact that these applications are updated regularly, CAGR 2020
software testing stays at the forefront of anyone’s mind. Another > 40 USD Billion
reason has to do with the pandemic. Covid-19 provides an extra 2021 - 2027
impetus for the growth of cloud applications. That is why Global
>7%
Market Insights thinks the software testing market will grow more
than 7% between 2021-2027 instead of the 6% estimate for 2020-
2026.

(Source: Global Market Insights)

lektor July & August 2022 55


interview

Inspiration,
That’s What It’s All About
Interview with Entrepreneur Walter Arkesteijn,
InnoFaith Beauty Sciences

By Jan Buiting (Elektor)

In electronics, ideas, crude sketches and ‘triggers’ can prove more valuable than turnkey
circuits. Walter Arkesteijn explains how he applies this philosophy within his young
company.

Jan Buiting: In the electronics industry, development and Elektor product, it would be the collection of audio amplifiers
education, we come across many readers having a “Deja-vu” featured in the magazine. What fascinates me is how you can
when they see Elektor (Elektuur) again, often after making a specialize a lot within the same objective: audio amplification.
career. But it’s different with you since you are both “in e-busi- Through technology, there are multiple dimensions to the same
ness” and an active Elektor reader today. product. Here I find the conceptual insights and technical insights
Walter Arkesteijn: That’s right, I’m still an active reader of Elektor. very interesting.
There is a difference with the old days! While I am now a nostalgic  
reader, I used to be a reader of Elektor at a fairly young age. It was the Jan: You started your own company called InnoFaith. Briefly
right place for me to pick up all the knowledge and feed my boyhood describe how that went. What were your main motivations?
dream of creating. I can truly say that Elektor has contributed to the Hopefully not Elektor’s Corrections & Updates section?
person I am today. Through your magazine, I was able to accumu- Walter: I started InnoFaith Beauty Sciences [1] out of entrepre-
late a lot of knowledge and use it to think in terms of solutions and neurial ambition. I felt the personal urge to jump into the “oppor-
options. It still stimulates my creative mind and I enjoy following tunity hole” within the Aesthetic Medicine industry. I found out
the innovations and different projects that are covered. that there was a lot to be gained when I was a teenager accompa-
  nying my mother to a trade show — she is employed within the
Jan: What did you think and feel about the magazine? Be frank! beauty industry. I wanted to create the tool to help the industry
Walter: I found and still find the magazine a source of information. interpret and treat both skin problems and skin aging. This is how
Especially back in the day when I started with my passion for electri- Sylton was formed, the brand under which we sell these devices.
cal engineering and I still had to learn to understand each table. Elektor’s corrections were not an issue here. To me, Elektor really
  is a breeding ground for imagination and knowledge.
Jan: What is your technical background and how has Elektor  
helped or thwarted you? What were your favorite projects or Jan: Elektor as a magazine often propagates that it prefers to
articles and why? inspire rather than instruct. How did you experience that?
Walter: My technical background is from a higher professional What was your personal trigger condition, so to speak, to read
education study in electrical engineering. Elektor magazine helped an article or undertake a project?
me find my passion for e-engineering, which is why I decided to Walter: I experienced Elektor as inspirational and not ped-
follow this program. Reading the magazine whetted my appetite for antic. I still experience it as such. I didn’t do much building from
learning more, especially within the world of electrical engineer- Elektor articles; the fun was quickly gone when it was already
ing. I’ve always been given the scope to discover everything myself thought out by someone else. To me, the main trigger con-
and in this respect, Elektor has helped to inspire me. dition is this: after reading an article, a technological fascination
  grows in me. Seeing different perspectives feeds my creativity;
Here my fascination goes mainly to the process of fantasy becom- it enables me to see opportunities that make me want to think
ing reality with the help of technology. If I had to mention an in new ways.

56 July & August 2022 www.elektormagazine.com Partner Content


 
Jan: How would you outline the industry that InnoFaith is in?
What are the opportunities and challenges?
Walter: InnoFaith Beauty Sciences finds itself in a very interest-
ing industry where the end-user of the product is not a techie. So,
with us, it is very important the product, in addition to striving to
be innovative, should also be easy to handle.
 
I especially see a lot of opportunities within image processing
systems. The sector in which InnoFaith Beauty Sciences is present
is fueled enormously by the availability of new technology. In this,
the challenge is to collect a lot of image data in a short period of
time, combined with the different types of exposures. We want
to be able to capture increasing amounts of information from the
skin in order to properly understand the ratio between perspec-
tive and visual perception. We want to be at the cutting edge of the
perception of beauty and make this visible and understandable
through digital technology.
 
Jan: On the subject of technology availability, to what extent is
InnoFaith suffering from the crisis in the component market,
especially chips?
Walter: We, too, are facing a market with chip shortages, long
delivery times of electronic components, and sharp increases in
component prices, in addition to an overall disruption in the supply
chain. Fortunately, we have been able to minimize the impact of the
shortages by doing small redesigns, ordering on time and in large
quantities, making an accurate production forecast, and sourcing
difficult but critical chips on the open market through chip brokers.
 
Jan: The Netherlands wants to be a manufacturing country
again. What is your view on that?
Walter: I also see this trend, particularly in the production of serial
industrial technical products. In my view, the current labor short-
age is an inhibiting factor in this development. We have therefore
  chosen to carry out the high-tech or critical production/control
Jan: What does InnoFaith look like in terms of the organiza- in-house and to carry out the large, more labor-intensive serial and
tion, and what is your product palette? space-consuming assembly steps in a partnership with a Slovakian
Walter: At this time, InnoFaith Beauty Sciences consists of a team production company.
of 23 employees. We develop the software and hardware ourselves  
within our team. Our main product, the Observ 520x, is sold through Jan: Thanks for the interview and we will be reading and
distributors in different countries around the world. hearing more from you and your company soon, here in Elektor
  Mag and on our YouTube video channel [2].
It is vital to our product that it is easy to operate while technically 220257-01
it is very sophisticated and intricate. Digital technology bridges
the world between our instinctive and analytical abilities to look
at beauty in a way that is visually intelligible and compelling in a
stimulating and inspiring way.
 
Jan: What electronics technologies are key at InnoFaith?
Walter: At InnoFaith Beauty Sciences we work with various items
where signal processing is especially important. But in addition,
WEB LINKS
software development and device design. We are always trying to
develop ourselves further within image processing and imaging. [1] Innofaith Beauty Sciences: https://innofaith.com/
For example, we work with different light modes and developed [2] Elektor TV: www.youtube.com/elektorim
an application required when using the Observ.

Partner Content lektor July & August 2022 57


background

Minimizing EMC Interference


from Storage Chokes
By Ranjith Bramanpalli, Würth Elektronik

Normally, switching regulators cannot function without power inductors. However, if you
want to enhance their influence on EMC behavior, there are several places to start, including
shielding efficiency, winding start and the switching transitions.

DC/DC switching regulators are critical in Effects of Electromagnetic Field


energy management, as they enable the When power inductors operate in DC/DC
implementation of efficient switching converters, they produce undesired side
power supply for example. In this context, effects similar to those of a loop antenna.
storage inductors are critical components AC voltage and current in the inductor
of these switching regulators, even though generate an electric field (E-field) and a
the development process often will only magnetic field (H-field). These two fields
focus on the pure electrical properties, such Figure 1: Typical switched-mode DC/DC propagate from the source at right angles
as RDC, RAC or core losses. On the other hand, converter with switches S1 and S2. in opposite directions.
electromagnetic radiation properties are  
frequently overlooked. Figure 1 depicts The properties of the E and H fields close
a typical switched DC/DC converter with to this loop antenna (source) are dictated
switches S1 and S2. by the source characteristics (switching
frequency, transitions, etc.). However, the
Power Inductors in Switched- further away one moves from the source, it’s
Mode Power Supplies the transition medium that determines the
In switched-mode power supplies, power field attributes. As a result, these distinct
inductors can be designed and assembled yet connected phenomena can be classified
using a variety of different core materials into two domains: the near field and the far
and winding types. Additionally, power field (Figure 2). The near field is defined as
inductors can be classified as unshielded, the area within λ/2π of the source, and the
semi-shielded, or shielded. Each type of far field is defined as the emissions beyond
shielding has distinct advantages and Figure 2: Propagation spectrum in the near and this area.
far field with a transition at λ/2π.
disadvantages that determine its applica-  
tion areas. The fields E and H must be evaluated
  separately in the near field because their
A switching power supply generates an frequency and its harmonic waves in the ratio, denoted as the E / H characteristic
alternating current (AC) voltage in the lower frequency range from 100 kHz to impedance, is not constant. However, in
inductor as a result of the switching 30 MHz is not only dependent on the shiel- the far field, these fields combine to form
processes. Since an inductor can operate ding of the coil, but also on the winding a plane wave. As a result, the electric field
as a loop antenna from a purely practical properties. In contrast, the electromagne- E and the magnetic field H are described
standpoint, electromagnetic radiation is tic radiation’s dependency on frequency in only in terms of the near field. When a
dependent on a number of parameters. the upper range (30 MHz to 1 GHz), where source is operated at a high current and a
These include the core and shielding emissions are caused by harmonics and low voltage, the magnetic field is dominant,
material as well as the start of the winding. their harmonic waves, is more dependent whilst when a source is operated at a low
  on the shielding properties of the core current and a high voltage, the electric field
The electromagnetic radiation emitted material, the switching frequency, and the is dominant.
by a power inductor due to the switching basic design.  

58 July & August 2022 www.elektormagazine.com Partner Content


Figure 3: Test setup for the measurement of the Figure 4: H-field measurement results of unshielded, semi-shielded and shielded coils.
electric field in a DC/DC switching regulator
(DUT).

When a loop antenna is used, the magne-


tic field is very strong in the vicinity of the
source, resulting in a low characteristic
impedance in that region. With increa-
sing distance from the source, the magne-
tic field weakens and simultaneously
generates an electric field perpendicular to
the field H’s propagation direction. When
moving further away from the source,
the magnetic field weakens by a factor of
1 / r3 and the electric field weakens by a
Figure 5: Comparative saturation behavior of a shielded (gray), semi-shielded (black) and unshielded
factor of 1 / r2 (where r = radius denotes
(red) coil.
the distance).
 
The characteristic impedance of a straight  
wire antenna is high due to the strength DC/DC switching regulator (DUT) is depic- Würth Elektronik is one of only a few
of the electric field in the source region. ted in Figure 3. manufacturers to offer semi-shielded
The properties of attenuation are the polar   coils capable of successfully bridging the
opposite of those of a loop antenna. As previously stated, each type of coil offers gap between space requirements, electrical
both advantages and disadvantages. The properties and EMC. These are particularly
Radiation Behavior of Coils primary advantage of a shielded coil is well suited for applications for which the
As previously stated, electromagnetic that its electromagnetic emissions are components adjacent to the coils are not
field radiation from storage inductors relatively weak compared to semi-shielded highly sensitive to radiation.
in DC/DC converters is not negligible. and unshielded coils. Figure 4 illustrates  
This is especially true when the type the basic emission behavior of these three The outstanding saturation properties of
and spacing of adjacent components are fundamental types. the WE-LQS semi-shielded storage induc-
considered along with their susceptibi-   tor, size 8040 (744 040 841 00), are illus-
lity to magnetic coupling. As engineers’ As many electrical engineers know, trated in Figure 5 in comparison with a
awareness of this potential EMC issue has designing a new circuit is always a delicate shielded coil from the WE-PD series, size
grown, component manufacturers have act of balance. Exacerbating a desirable 7345 (744 777 10) and an unshielded coil
responded by expanding their portfolio to quality can frequently result in amplifi- from the WE PD2 series, size 7850 (744 775
include shielded and semi-shielded coils cation of undesirable characteristics, the 10).
in addition to standard unshielded coils. maximum values of which are ultimately
Shielded coils are manufactured in such constrained by project’s overall require- Effect of the Winding Start
a way that the winding is totally encased ments. Inevitably, one of these constraints An critical feature of EMC, which is
in a molded part made entirely of magne- is size. Shielded coils have a lower induc- frequently overlooked, is the orientation of
tic shielding material. In unshielded coils, tance and magnetic saturation, as well as the start of the winding, which is indicated
the coil windings are typically exposed and greater manufacturing costs, as compared by a “dot” on the coil (Figure 6). It is impor-
there is also no magnetic shielding. Due to unshielded examples of comparable tant to connect the coil’s side marked with
to the electromagnetic fields’ unrestricted dimensions. Obviously, designers with this dot as close as possible to the switch
propagation, these are typically the most less experience will be tempted to use an node, as this side has the highest dU/
powerful sources of EMI interference. unshielded coil due to its smaller size, dt value and thus the most interference.
Magnetic materials are frequently applied lower cost, and higher saturation currents. This way, the outer windings shield the AC
to the exposed windings of semi-shielded However, this choice results in a slew of current flow from the switch node during
coils using epoxy resin. The test setup for EMC problems that are difficult to resolve switching. If the unmarked end is connec-
measuring the electromagnetic field in a after the design phase. ted to the switch node, the alternating

Partner Content lektor July & August 2022 59


Figure 6: Coil types WE-XHMI and WE-PD2 Figure 7: E-field of the winding start connected to the switch node, and vice versa.
showing the “dot” that indicates the start of the
winding.

current forward voltages occur at the outer


winding. This can result in unacceptably
strong electrical or capacitive connections.
 
Magnetically shielded coils effectively
shield the dominant H-field radiation,
but are not always capable of shielding
the dominating E-field radiation. The
efficiency of E-field shielding depends
on the material properties and magnetic
permeability of the core material: the stron-
Figure 8: H-field of the winding start connected to the switch node and vice versa.
ger and more magnetically conductive the
core material, the more efficient the coil’s
E-field shielding.
  effect of various materials in the near and
The E-field emissions of a shielded power far fields is provided in the article titled
inductor manufactured by Würth Elektro- “The behavior of electromagnetic radia-
nik were measured as an example. The tion of power inductors in power manage-
switching regulator’s transistor switched at a ment” [1].
frequency of 400 kHz, generating the funda- 220295-01
mental resonance and subsequent harmo-
nics. The spectrum clearly demonstrates that
when dot-marked end of the coil is connec-
ted to the switch node, the E-field emissions About the Author
are significantly reduced (Figure 7). As a Ranjith Bramanpalli graduated from the Univer-
result, the correct orientation of the coil is sity of Massachusetts at Lowell in 2008 with two
applied. By contrast, the orientation of the master’s degrees in electrical engineering and
inductor has virtually no effect on the H-field computer science. He has since worked in the field
emissions (Figure 8). of power electronics, with a particular emphasis on
  research, development and application. He is currently
A detailed examination of the electro- employed with Würth Elektronik eiSos as a Product
magnetic interference signals caused by Application Engineer.
switching transitions and the shielding

WEB LINKS
[1] Würth Elektronik, “The Behavior of Electromagnetic Radiation of Power Inductors in Power Management”:
www.we-online.com/ANP047

60 July & August 2022 www.elektormagazine.com Partner Content


tutorial
Free Download
for all Elektor
members: 60-p
with Parts 1 to age-PDF specia
10 of l
www.elektorma this series. Se
gazine.com/ne e
ws/GUI-PDF-Spe
cial

Create GUIs with Python:


Part 05

Tic-tac-toe
Use your GUI to control a simple game

N
0w that you have learnt how to make a basic
GUI, let’s add some more programming
logic behind the scenes to make your GUI
work as the means of controlling a game of tic-
tac-toe (also known as noughts and crosses).
Create a new file with the following code:

Laura Sach # Imports ---------------


MAKER

from guizero import App


Laura leads the
A Level team at
the Raspberry # Functions -------------
Pi Foundation,
creating resources # Variables -------------
for students
to learn about
Computer Science. # App -------------------
@CodeBoom app = App("Tic tac toe")

app.display()

Figure 1 A typical game of tic-tac-toe


Figure 1
Create the board
Let’s begin by creating the widgets which will make If you run your program at this point, you won’t
up the game board. A traditional tic-tac-toe board see anything on the screen because the Box itself is
looks like the one shown in Figure 1. invisible.
You’ll use buttons to represent each of the Now let’s create the buttons to go inside it.
positions on the board, so that the player can click You will need nine buttons in total, so instead of
Martin on one of the buttons indicating where they would creating them individually, you can use a nested
MAKER

O’Hanlon like to move. To be able to lay out the buttons on a loop to generate them all automatically and give
grid, let’s create a new type of guizero widget called them co-ordinates. First, add PushButton to
Martin works in
a Box. your list of widgets to import and then add this
the learning team
at the Raspberry A Box is a container widget. This means that it code immediately after the code for the board
Pi Foundation, is used for containing other widgets and grouping you just created.
where he creates
them together. Add it to the imports at the top of
online courses,
projects, and your code: for x in range(3):
learning resources. for y in range(3):
@martinohanlon from guizero import App, Box button = PushButton(
board, text="", grid=[x, y],
Set the Box to have a grid layout and add it to your width=3
app – before the app.display() line, as with all )
widgets.
Notice that there are two loop variables: x from 0
board = Box(app, layout="grid") to 2 and y from 0 to 2. As we iterate and generate
buttons, each button will be added to the board,

lektor July & August 2022 61


which is the Box container you created earlier. The
button will be given the grid co-ordinates x,y,
meaning that each button is neatly placed on a
grid at a different position!
Your code should now look like tictactoe1.py.
The result of running it is shown in Figure 2.

Figure 2 Underlying data structure


Figure 2 A grid of nine buttons to play tic-tac-toe You might notice that when you create the buttons
using a loop, you are creating nine buttons
automatically and every single one is called

tictactoe1.py DOWNLOAD button. How will you be able to refer to each of


THE FULL CODE: these buttons in the program?
The answer is that you need an underlying data
> Language: Python 3 magpi.cc/guizerocode structure to hold a reference to each button, and
for this you will use a two-dimensional list.
001. # Imports --------------- Let’s create a function which we can call to clear
002. from guizero import App, Box, PushButton the board. It is a good idea to do this in a function
003.
004. # Functions ------------- so that you can reuse the code once the game has
005. been played to reset the board and allow the player
006. # Variables ------------- to begin a fresh game.
007.
008. # App ------------------- In the functions section, add a new function
009. app = App("Tic tac toe") called clear_board.
010.
011. board = Box(app, layout="grid")
012. for x in range(3): def clear_board():
013. for y in range(3):
014. button = PushButton(
board, text="", grid=[x, y], width=3) Your first job inside this function is to initialise
015. the data structure for the board. Let’s assume at
016. app.display() this point you have not created any buttons, so you
can initialise each position on the board as None
– the element in the list now exists but does not

tictactoe2.py yet have a value. Add the following line, indented,


to your function.

> Language: Python 3 new_board = [[None, None, None], [None,


None, None], [None, None, None]]
001. # Imports ---------------
002. from guizero import App, Box, PushButton Next, move the nested loop code from your app
003. section into the clear_board function. Make sure
004. # Functions -------------
005. def clear_board(): the indentation is correct.
006. new_board = [[None, None, None], [None, None, None], [ Inside the inner (y) loop, add a line of code
None, None, None]] to store a reference to each button at its x,y co-
007. for x in range(3):
008. for y in range(3): ordinate position within the two-dimensional list
009. button = PushButton( so that you can refer to it later.
010. board, text="", grid=[x, y], width=3)
011. new_board[x][y] = button
012. return new_board new_board[x][y] = button
013.
014. # Variables -------------
015. Finally, after the loops end, return the new_board
016. # App ------------------- you have just created. Your function should look like
017. app = App("Tic tac toe") this:
018.
019. board = Box(app, layout="grid")
020. board_squares = clear_board() def clear_board():
021.
new_board = [[None, None, None],
022 app.display()

62 July & August 2022 www.elektormagazine.com


tictactoe3.py Reset the game
> Language: Python 3 At the start, you wrote a function called clear_board.
This may have seemed unnecessary at the time, but
in actual fact it was thinking ahead to when the game
001. # Imports --------------- has ended. Since tic-tac-toe is quite a short game, it is
002. from guizero import App, Box, PushButton, Text
likely that someone might want to play more than one
003.
004. # Functions ------------- game in a row.
005. def clear_board():
006. new_board = [[None, None, None], [None, None, None], [None, Can you add a reset button to your game, which only
None, None]] appears once either someone has won the game,
007. for x in range(3): or the game was a draw? The button should call the
008. for y in range(3):
009. button = PushButton(board, text="", grid=[x, y], clear_board function and reset the turn variable as
width=3, command=choose_square, args=[x,y]) well as the message reporting whose turn it is.
010. new_board[x][y] = button
011. return new_board Hint: You will need to check the guizero documentation
012. to find out how to hide and show widgets, so that your
013. def choose_square(x, y):
button is not visible all of the time during the game.
014. board_squares[x][y].text = turn
015. board_squares[x][y].disable()
016. Hint: Create a new function which takes care of
017. # Variables ------------- everything you need to do to reset the game, and call
018. turn = "X" that function when the reset button is pressed. Don't
019.
forget that in your function you'll need to specify some
020. # App -------------------
021. app = App("Tic tac toe") variables as global.
022.
023. board = Box(app, layout="grid")
024. board_squares = clear_board() and run the program and you should see an identical
025. message = Text(app, text="It is your turn, " + turn)
026. result to the one you had at the end of the last step,
027. app.display() but now you have a hidden two-dimensional list
data structure to let you reference and manipulate
the buttons.
[None, None, None], If you want to see what your 2D list looks like, you
[None, None, None]] could add a print command to print the board_
for x in range(3): squares list: print(board_squares). You should then
for y in range(3): see nine lots of [PushButton] object with text ""
button = PushButton( appear in the shell.
board, text="", grid=[x,
y], width=3 Make the buttons work
) At the moment, your buttons don’t do anything
new_board[x][y] = button when you press them. Let’s make a function to
return new_board attach to the button, so that when it is pressed, the
button displays either X or O depending on which
In the app section, initialise a list called board_ player chose it.
squares and set it to call the new function First, create a variable in the variables section to
you just created. record whose turn it is. You can choose to start with
either player, but we will choose to start with X.
board_squares = clear_board()
turn = "X"
This variable will be assigned the value of the new_
board you created within the function, which should This now means that you need to display on the GUI
be a blank board with nine buttons. Make sure that whose turn it is (Figure 3) so the players don’t get
you create this variable after the code for creating confused. Add Text to your list of widgets to import:
the Box, otherwise you will be trying to add buttons
to a container that does not yet exist. from guizero import App, Box, PushButton,
Your code will now resemble tictactoe2.py. Save Text

lektor July & August 2022 63


tictactoe4.py
> Language: Python 3

001. # Imports ---------------


002. from guizero import App, Box, PushButton, Text
003.
004. # Functions ------------- Move to the functions section and create a new
005. def clear_board():
006. new_board = [[None, None, None], [None, None, None], [None, function called choose_square.
None, None]]
007. for x in range(3):
def choose_square(x, y):
008. for y in range(3):
009. button = PushButton(board, text="", grid=[x, y],
width=3, command=choose_square, args=[x,y]) You will notice that this function takes two
010. new_board[x][y] = button
011. return new_board arguments – x and y. This is so that you know which
012. square on the board has been clicked.
013. def choose_square(x, y): Add the following code (indented) inside the
014. board_squares[x][y].text = turn
015. board_squares[x][y].disable() function to set the text inside the button that was
016. toggle_player() clicked to the symbol of the current player, and then
017.
disable the button so it cannot be clicked on again.
018. def toggle_player():
019. global turn
020. if turn == "X": board_squares[x][y].text = turn
021. turn = "O"
022. else: board_squares[x][y].disable()
023. turn = "X"
024. message.value = "It is your turn, " + turn Finally, connect this function to the button. Find
025.
026. # Variables ------------- this line of code inside your clear_board function:
027. turn = "X"
028.
button = PushButton(board, text="",
029. # App -------------------
030. app = App("Tic tac toe") grid=[x, y], width=3)
031.
032. board = Box(app, layout="grid")
033. board_squares = clear_board() Modify it so that it looks like the line below:
034. message = Text(app, text="It is your turn, " + turn)
035. button = PushButton(board, text="",
036. app.display()
grid=[x, y], width=3, command=choose_square,
args=[x,y])

You have added two things here. Firstly, you


are attaching a command, just as before. When
Then add a new Text widget in the app section to the button is pressed, the function with this name
display the turn. will be called. Secondly, you are also providing
arguments to this function, which are the co-
message = Text(app, text="It is your turn, ordinates x and y of the button which was pressed,
" + turn) so that you can find that button again in the list.
Figure 3 Let your
Your program should now look like
players know tictactoe3.py. Save and run it. You will now be
whose turn it is
able to click on a button and it will change to an
X. Unfortunately, in this version of the game it is
permanently X’s turn!

Alternating between players


Once one player has taken their turn, the turn
variable should toggle to be the other player. Here
is a function which will toggle from X to O and vice
versa.

def toggle_player():
global turn
if turn == "X":
Figure 3 turn = "O"

64 July & August 2022 www.elektormagazine.com


tictactoe5.py
> Language: Python 3

001. # Imports --------------- 041. ) and board_squares[2][2].text in ["X", "O"]:


002. from guizero import App, Box, PushButton, Text 042. winner = board_squares[2][0]
003. 043.
004. # Functions ------------- 044. # Horizontal lines
005. def clear_board(): 045. elif (
006. new_board = [[None, None, None], [None, None, 046. board_squares[0][0].text ==
None], [None, None, None]] board_squares[1][0].text == board_squares[2][0].text
007. for x in range(3): 047. ) and board_squares[2][0].text in ["X", "O"]:
008. for y in range(3): 048. winner = board_squares[0][0]
009. button = PushButton(board, text="", 049. elif (
grid=[x, y], width=3, command=choose_square, 050. board_squares[0][1].text ==
args=[x,y]) board_squares[1][1].text == board_squares[2][1].text
010. new_board[x][y] = button 051. ) and board_squares[2][1].text in ["X", "O"]:
011. return new_board 052. winner = board_squares[0][1]
012. 053. elif (
013. def choose_square(x, y): 054. board_squares[0][2].text ==
014. board_squares[x][y].text = turn board_squares[1][2].text == board_squares[2][2].text
015. board_squares[x][y].disable() 055. ) and board_squares[2][2].text in ["X", "O"]:
016. toggle_player() 056. winner = board_squares[0][2]
017. check_win() 057.
018. 058. # Diagonals
019. def toggle_player(): 059. elif (
020. global turn 060. board_squares[0][0].text ==
021. if turn == "X": board_squares[1][1].text == board_squares[2][2].text
022. turn = "O" 061. ) and board_squares[2][2].text in ["X", "O"]:
023. else: 062. winner = board_squares[0][0]
024. turn = "X" 063. elif (
025. message.value = "It is your turn, " + turn 064. board_squares[2][0].text ==
026. board_squares[1][1].text == board_squares[0][2].text
027. def check_win(): 065. ) and board_squares[0][2].text in ["X", "O"]:
028. winner = None 066. winner = board_squares[0][2]
029. 067.
030. # Vertical lines 068. if winner is not None:
031. if ( 069. message.value = winner.text + " wins!"
032. board_squares[0][0].text == 070.
board_squares[0][1].text == board_squares[0][2].text 071. # Variables -------------
033. ) and board_squares[0][2].text in ["X", "O"]: 072. turn = "X"
034. winner = board_squares[0][0] 073.
035. elif ( 074. # App -------------------
036. board_squares[1][0].text == 075. app = App("Tic tac toe")
board_squares[1][1].text == board_squares[1][2].text 076.
037. ) and board_squares[1][2].text in ["X", "O"]: 077. board = Box(app, layout="grid")
038. winner = board_squares[1][0] 078. board_squares = clear_board()
039. elif ( 079. message = Text(app, text="It is your turn, " + turn)
040. board_squares[2][0].text == 080.
board_squares[2][1].text == board_squares[2][2].text 081. app.display()

else:
turn = "X" Go back to your choose_square function and call the
toggle_player function – with toggle_player() –
Add the code in your functions section. Notice the once you have set the text and disabled the button.
first line in the function: global turn. You need to Your code should now resemble tictactoe4.py. Save
specify this so that you are allowed to modify the and test the program again and you should find
global version of the turn variable, i.e. the one you that you can click squares and they will alternately
already created. If you don’t specify this, Python will be designated either X or O.
create a local variable called turn and modify that
instead, but that change won’t be saved once the Do we have a winner?
function exits. Finally, you need to write a function which will check
You also need to make sure that the Text widget whether there is a row, column, or diagonal of three Xs
accurately reports the current player’s turn. After or Os, and if so will report the winner of the game.
the if/else statement in the toggle_player function, Although it seems very inelegant, by far the easiest
update the message like this: way to check if someone has won is to hard-code the
checks for each vertical, horizontal, and diagonal line
message.value = "It is your turn, " + turn individually.

lektor July & August 2022 65


Global variables
The following code is for one vertical line, one
horizontal line, and one diagonal – can you add the It is arguably a bad idea to use global variables because if you have many
rest? functions in a large program, it can become extremely confusing as to which code
modifies the value of a variable and when. In a small program like this, it is not too
def check_win(): difficult to keep track.
winner = None
Remember that it is possible to read and use the value of a global variable from
inside a function without declaring it global, but in order to modify its value you
# Vertical lines will need to explicitly declare this. The functions in this program (and most GUI
if ( programs in this tutorial series) are actually modifying the values of your widgets
board_squares[0][0].text == board_ as global variables. For example, when someone wins the game, you set the value
squares[0][1].text == board_squares[0][2].text of the message to display who won:
) and board_squares[0][2].text in ["X", "O"]:
message.value = winner.text + " wins!"
winner = board_squares[0][0]
In this example, message is a global variable. So how can we modify its value
# Horizontal lines without declaring it as global? The answer is because we are using a property
elif ( of the message widget, the property called value. Essentially what this code is
board_squares[0][0].text == board_ saying is “Hey Python, you know that widget over there called message? Well,
squares[1][0].text == board_squares[2][0].text could you modify its value property please?” Python will allow modification
through object properties in the global scope, but it won't allow you to directly
) and board_squares[2][0].text in ["X", "O"]:
modify the value of a variable without declaring it global.
winner = board_squares[0][0]

# Diagonals
elif ( game was a draw. You could stop at this point, but if
board_squares[0][0].text == board_ you really want to put the icing on the cake, adding a
squares[1][1].text == board_squares[2][2].text few more little touches could make your game more
) and board_squares[2][2].text in ["X", "O"]: polished.
winner = board_squares[0][0] First, let’s add some code to detect whether the
game is a draw. The game is a draw if all of the
Notice that the function begins by creating a squares contain either an X or an O, and no one has
Boolean variable called winner. If by the time the won. In the functions section, create a new function
long if/elif statement has been executed, the value called moves_taken:
of this variable is True, you know that someone has
won the game. def moves_taken():
After adding the remaining winning line checks,
Create
add some code at the end of the function to change You’re going to use this function to count the number
Graphical
the display message if there has been a winner: of moves which have been made, so let’s start a
User
variable to keep count, initially beginning at 0.
Interfaces
if winner is not None:
with Python
message.value = winner.text + " wins!" def moves_taken():
moves = 0 For further
You now need to make sure that this function tutorials on how
is called each time an X or O is placed, which Now, remember when we created the to make your
corresponds to any time a button is pressed. Add board_squares, we used a nested loop to create all of own GUIs with
guizero, take
a call to check_win at the end of the choose_square the squares on the grid? We’re going to need another
a look at our
function, just in case the square that was chosen nested loop here to check each and every square and book, Create
was the winning square. determine whether it has been filled in with an X or Graphical User
Your program should now look like O, or whether it is blank. Add this code for a nested Interfaces with
tictactoe5.py. Run it and test the game. If you loop to the moves_taken function: Python. Its
wrote the tests in the check_win function correctly, 156 pages are
packed with
you should find that the game detects correctly for row in board_squares:
essential info
when a player has won. for col in row:
and a range
of exciting
Draw game Inside the loop, we need to check whether that projects.
At the moment, the game will allow you to continue particular square is filled in with an X or an O. If it is, magpi.cc/
playing even after it has been won, until all of the add 1 to the moves variable to record that square has pythongui
squares are selected. It will also not tell you if the been counted.

66 July & August 2022 www.elektormagazine.com


Editor’s note: This article originally appeared in MagPi 9-10/2021 (German edition).
Elektor publishes the Dutch, French, and German editions of MagPi.

06-tictactoe.py
> Language: Python 3

001. # Imports ---------------


002. from guizero import App, Box, PushButton, Text board_squares[1][0].text == board_squares[2][0].text
003. 047. ) and board_squares[2][0].text in ["X", "O"]:
004. # Functions ------------- 048. winner = board_squares[0][0]
005. def clear_board(): 049. elif (
006. new_board = [[None, None, None], 050. board_squares[0][1].text ==
[None, None, None], [None, None, None]] board_squares[1][1].text == board_squares[2][1].text
007. for x in range(3): 051. ) and board_squares[2][1].text in ["X", "O"]:
008. for y in range(3): 052. winner = board_squares[0][1]
009. button = PushButton(board, text="", 053. elif (
grid=[x, y], width=3, command=choose_square, 054. board_squares[0][2].text ==
args=[x,y]) board_squares[1][2].text == board_squares[2][2].text
010. new_board[x][y] = button 055. ) and board_squares[2][2].text in ["X", "O"]:
011. return new_board 056. winner = board_squares[0][2]
012. 057.
013. def choose_square(x, y): 058. # Diagonals
014. board_squares[x][y].text = turn 059. elif (
015. board_squares[x][y].disable() 060. board_squares[0][0].text ==
016. toggle_player() board_squares[1][1].text == board_squares[2][2].text
017. check_win() 061. ) and board_squares[2][2].text in ["X", "O"]:
018. 062. winner = board_squares[0][0]
019. def toggle_player(): 063. elif (
020. global turn 064. board_squares[2][0].text ==
021. if turn == "X": board_squares[1][1].text == board_squares[0][2].text
022. turn = "O" 065. ) and board_squares[0][2].text in ["X", "O"]:
023. else: 067. winner = board_squares[0][2]
024. turn = "X" 068.
025. message.value = "It is your turn, " + turn 069. if winner is not None:
026. 070. message.value = winner.text + " wins!"
027. def check_win(): 071. elif moves_taken() == 9:
028. winner = None 072. message.value = "It's a draw"
029. 073.
030. # Vertical lines 074. def moves_taken():
031. if ( 075. moves = 0
032. board_squares[0][0].text == 076. for row in board_squares:
board_squares[0][1].text == board_squares[0][2].text 077. for col in row:
033. ) and board_squares[0][2].text in ["X", "O"]: 078. if col.text == "X" or col.text == "O":
034. winner = board_squares[0][0] 080. moves = moves + 1
035. elif ( 081. return moves
036. board_squares[1][0].text == 082.
board_squares[1][1].text == board_squares[1][2].text 083.
037. ) and board_squares[1][2].text in ["X", "O"]: 084. # Variables -------------
038. winner = board_squares[1][0] 085. turn = "X"
039. elif ( 086.
040. board_squares[2][0].text == 087. # App -------------------
board_squares[2][1].text == board_squares[2][2].text 088. app = App("Tic tac toe")
041. ) and board_squares[2][2].text in ["X", "O"]: 089.
042. winner = board_squares[2][0] 090. board = Box(app, layout="grid")
043. 091. board_squares = clear_board()
044. # Horizontal lines 092. message = Text(app, text="It is your turn, " + turn)
045. elif ( 093.
046. board_squares[0][0].text == 094. app.display()

if col.text == "X" or col.text == "O": if winner is not None:


moves = moves + 1 message.value = winner.text + " wins!"

Finally, once the loops have finished, add a return # Add this code
statement to return the number of moves taken. elif moves_taken() == 9:
message.value = "It's a draw"
return moves
Your code should resemble 06-tictactoe.py. When
Now, call this function inside the check_win run, the game will now check whether nine moves
function, to check for a draw. Add this code after the have been taken; if they have, it will change the
code that checks for a winner: message to report that the game was a draw.

lektor July & August 2022 67


components

Reed Relays Peculiar Parts, the series

By David Ashton (Australia)

While the semiconductor


industry has some great
innovations, sometimes
you can’t beat a real
switch! Here we delve
into the world of reed
relays, devices that were
extensively used in the
telephone exchanges of
yesteryear.

Reed relays are versatile components that Figure 1: At the core of a reed relay is a reed switch that uses a magnetic field to
can be used for applications where the true operate it. (Source: Pickering Electronics)
isolation offered by a physical switch is
demanded. They are based upon a reed
switch, a device consisting of two lengths
of magnetic alloy, commonly 50:50 nickel switch than mechanical relays. Although operation at 10 mA. At such current levels,
iron. The contacts are held in a glass tube their switching is considered bounce free, they can be constructed to be reasonably
(the “reed”) such that they almost touch, under certain conditions they can still sensitive.
and their ends are plated with a contact suffer from contact bounce, especially if  
material. When a magnetic field is the coil is driven from a voltage higher The coil and the reed can also be hermet-
brought close to the reed, the two lengths than specified. ically sealed inside a case, making them
of magnetic material become magne-   remarkably rugged. Some types even have
tized, their ends attract, and, bingo, they The coil of a reed relay is usually imple- metal screening inside the case to ensure
make contact. When the magnetic field mented with a fine wire wrapped that external magnetic fields do not
is removed, they open again (Figure 1). around the reed. A typical reed requires result in the unwanted operation of the
  50 Ampere-turns to operate. So, 50 turns device. Manufacturers also have a couple
Reed relays generate the magnetic field of wire cause it to operate if 1 A is passed of tricks with which reed relays can be
from a coil and are typically faster to through the coil, while 5000 turns cause built as normally-closed or changeover

68 July & August www.elektormagazine.com


devices [1]. Figure 2 shows a variety of for the chosen lamp, such as the brakes, applications, thanks to them being physi-
reeds and reed relays. was modified so that the current passed cally much smaller and capable of sensing
  through a fairly thick wire wrapped around magnetic fields electronically rather
Reed switches remain popular for a range a reed switch to form a home-made reed than mechanically. However, in terms of
of applications thanks to their opera- relay. The switch itself controlled an simplicity and isolation, reed relays win
tional simplicity. Door switches for alarm LED synchronous to the switching of the hands down, which is why they are still
systems attach the reed switch to the door chosen bulb. If one brake light bulb burned in wide use.
frame and the magnet to the door. When out, only half the current flowed, which  
the door is closed, the magnet and switch was insufficient to operate the reed. Like all If this has piqued your curiosity, suppliers
come into close proximity, and the reed the others from Elektor’s 60-year history, such as Pickering Electronics have some
is closed. As the door is opened, the reed this project can be found on the Elektor great tutorials [3] and other resources [1]
opens, and the resultant break in the website [2]. where you can learn more.
circuit triggers the alarm. I also had a car   220179-01
alarm once that used two reeds affixed These days reed relays face some compe-
to the windscreen. It used a magnet in a tition from Hall‑effect sensors in some
keyring fob to enter a basic code to disarm
it. For non-contact applications such as
these, reed switches are very useful.
  WEB LINKS
They have also featured in many an [1] “Reed RelayMate,” Pickering Electronics, April 2011: https://bit.ly/3qhVRKS
Elektor project. One that springs to mind [2] “Car Lights Failure Indicator,” Elektor 3/1978: https://bit.ly/3tisNoq
from years ago monitored the operation [3] “Reed Relay Basics,” Pickering Electronics: https://bit.ly/37AU5hf
of the light bulbs in your car. The cabling

Figure 2: A selection of reed relays. Top left is a changeover type (two contacts on the left-hand end). Bottom right is a bare
reed. The rest show the wide variety of sizes and packages available.

lektor July & August 2022 69


project

Simple Analog
ESR Meter
With Moving-Coil
Meter Precision

By George Lydecker (USA)


First, What Is ESR?
Looking for an analog ESR meter to check ESR stands for the equivalent series resistance of a capacitor. ESR
and find bad capacitors? You can build your is frequency-dependent, temperature-dependent, and changes
as components age. It’s typically important for ‘wet’ aluminum
own. Here is one approach.  electrolytic capacitors used in power supplies to have a low ESR.
 
  The typical method used for measuring ESR is to supply the capac-
I was always envious of my friend’s analog ESR meter that allowed itor with a known AC current (Icap) at some frequency where the
him to check and find bad capacitors while they were still in circuit. capacitive reactance of the capacitor is very low so that the ESR
The particular meter he had is no longer available, which meant dominates. By measuring the resulting AC voltage developed across
doing some research to understand how they worked and to come the capacitor’s terminals (Vcap), the ESR can be determined with
up with my own version. Ohm’s law:
 
ESR = Vcap/Icap
 
Most of the designs I found worked along the same lines as the
block diagram shown in Figure 1. Going from left to right, there
is an oscillator that supplies AC voltage to be applied to the capac-
itor. Next, the AC signal is fed into an impedance converter and
detector. The detected signal is then rectified and buffered so that
it can drive the meter on the right of the diagram.
 
Since the ESR meter is to be battery operated, the power supply
circuit supplies split rails for the operational amplifiers that will
be used in the ESR meter. The oscillator in most of the examples I
looked at operated at 100 kHz to 150 kHz. The driver used to reduce
the impedance of the AC signal could be anything from a transistor
current boost, transformer, or paralleled logic gates. The detector
was usually back-to-back diodes. The detected AC signal is then
Figure 1: Block diagram of the ESR Meter. rectified, amplified and fed into a DC meter.

70 July & August www.elektormagazine.com


A
DUT B
+4V5
IC1B
R2 R7 R15
3 4 14 8 8
1 600 1M IC1 = 74HC14 10k
IC1 IC2 IC3
C2 IC2, IC3 = TL082
IC1C 7 4 4 D3 1N4148
R1 R3 R16
5 6
1k 1 600
D1
470n R11
–4V5
10k
C4 100p
4k7 R13
IC1A IC1D 6
R4 C3 R10 10k R18
D4
1 2 9 8 2 2 7
1 1 600 2 x 1N4001 1k R12 1N4148 IC3B
1 6 1 5
C1 100n IC2A 1k R14 IC3A 50k R19
IC1E 3 7 3
IC2B 1k

10k
R5
11 10 D2 5
10n 1 600 R8 R9 R17
+

10k
10

10
IC1F
R6 M1
13 12 100µA
1 600

OSCILLATOR DRIVER DETECTOR AC AMPLIFIER ABSOLUTE VALUE CIRCUIT 210017-002

Figure 2: The schematic of the ESR Meter is composed of design elements from various DIY examples found on the Internet.

My Circuit circuit because any other silicon junctions will not be forward
In the circuit I decided to build (Figure 2), I used several design biased by the relatively low AC signal. The low-level AC signal is
elements from the DIY examples I found on the Internet. For the DC decoupled with C3 and amplified by two operational amplifi-
oscillator and impedance converter, I used a single 74HC14 that ers, with a voltage gain of 4.7 for the first amplifier and a gain of
provides six inverters with hysteresis. One of the inverters acts as a 10 for the second. This provides an overall gain of 47 to the input
relaxation oscillator and the remaining five inverters operate as the of the absolute value circuit.
impedance converter. This part of the circuit came from Lawrence  
P. Glaister VE7IT. His circuit and article can be found at [1]. The absolute value circuit was taken from the Burr-Brown
  Application Bulletin “Precision Absolute Value Circuits” [2]. The
The detector portion of the ESR meter is the same as the detection absolute value circuit had plenty of drive for the 100 microamp
circuit in the commercial ESR meter built by Creative Electronics. meter I used.
Sadly, these meters are no longer made.  
  This ESR meter operates of a single 9-volt battery. The plus,
Diodes D1 and D2 clip the top and bottom of the 100 kHz AC to minus and ground voltages needed for the operational amplifier
one silicon junction drop. This allows capacitors to be tested in are derived using the opamp voltage follower with current boost
shown in Figure 3.

R22
3k3

R20 T1
R26
10k

10k

TIP41 R24
Bt1
D5

1 +4V5
10

3 7
5 1N4001
9V 6
IC4 R25
2
D6
4
–4V5
10

LF356 1N4001

T2

R21 R23

TIP42
10k

3k3

Figure 4: The oscilloscope shows the output of the oscillator as well


as the output of the ESR meter while testing a 50 µF electrolytic
Figure 3: This circuit turns a 9 V battery into a symmetric capacitor.
double 4.5 V power supply.

lektor July & August 2022 71


Figure 6: The circuit is simple enough to be built on prototyping
board.
Figure 5: This waveform dump from the oscilloscope shows the
difference between a capacitor with a high ESR in blue and a
capacitor with a low ESR in orange.

Test and Operation


To test out the circuit, I built it up on a conventional bread board.
BNC connectors allow for easy monitoring of the various waveforms.
Initially for testing I simply looked at the signals with an oscillo-
scope instead of the 100 µA meter (Figures 4 and 5).
 
The circuit is wired on two prototyping perfboards (Figure 6). The
smaller board on the left is the circuit used to derive the plus, minus
and ground references for the op-amps. The larger perfboard is the
ESR meter circuit and is held in place by the nuts on the meter.
  Figure 7: Even when it still was a breadboarded prototye the
Even before I was able to package the meter into a case I used it to circuit proved useful when checking the motor capacitor of an air
trouble shoot our air conditioner by locating a bad motor capac- conditioner.
itor (Figure 7).
 
The completed ESR meter is sufficiently portable so that it can
be used remotely and away from the work bench. Simple Post-It
Note calibration was accomplished with a handful of 2-Ω resis-
tors (Figure 8).
 
The ESR meter works like an ohm meter. Before measuring a capac-
itor, the leads are shorted together and the knob is adjusted for
a full-scale reading (zero ESR). Rotating the knob fully counter
clockwise turns the meter off with a switch.
210017-01

Questions or Comments?
Do you have technical questions or comments about this article? Figure 8: Calibrating the meter is easily accomplished with a few
Email the author at glydeck@aol.com or contact Elektor at 2-Ω resistors and a scrap of paper.
editor@elektor.com.

RELATED PRODUCTS
WEB LINKS
[1] Circuit by Lawrence P. Glaister (VE7IT): > Elektor 2 MHz LCR Meter Kit (SKU 19883)
http://ve7it.cowlug.org/esrmeter.html www.elektor.com/19883  
[2]Burr Brown application note
> Peak Atlas ESR70 Plus Capacitor Analyser (SKU 17668)
http://glydeck.com/project/content/absolute_value_ www.elektor.com/17668
circuit.pdf

72 July & August www.elektormagazine.com


They trust us,
do you?

We love electronics and projects, and we do


our utmost to fulfil the needs of our customers.
The Elektor Store: ‘Never Expensive, Always Surprising’

Check out more reviewsw.on tor.com/TP


our Trustpilot page: ww elek
Or make up your own mind by
e, ww w.elektor.com
visiting our Elektor Stor
project

Sigfox CO2
Traffic Light
No Wi-Fi Network Needed!

makes the CO2 traffic light system ideal for


By Peter Groppe, Frank Schleking and Bernd vom Berg operation where access to a Wi-Fi network
(Germany) is unavailable.

We have already featured a number of CO2 The Hardware


concentration meters in Elektor. Almost all Building the hardware for the CO2 traffic light
of them feature a Wi-Fi interface so that you is quite easy; nowadays there are a wide range
of very powerful microcontroller boards avail-
can check out the readings from anywhere in able off the shelf from Arduino that can be
the world. This CO2 traffic light is different; it used in this CO2 traffic light design. One such
connects to the IoT using the Sigfox network. board which includes Sigfox communication
function is the Arduino MKR FOX1200 board,
This gives the sensor significantly wider range which we have previously introduced in the
and allows it to operate where there is no Elektor article series “Sigfox and the IoT” [5].
access to a Wi-Fi network.  
Alternatively, if you do not need IoT connectiv-
ity and just want to display the CO2 measure-
ments locally, you could use a standard
Arduino Uno which also plugs onto the
A variety of studies have shown that air quality traffic light display. In the age of the IoT, most motherboard design presented here. Figure 1
decreases in unventilated public spaces; high of these systems also have a Wi-Fi interface gives the circuit diagram showing how either
CO2 concentration correlates with a higher so that measurement data can be transferred IC3 (an Arduino Uno R3) or IC1 (Arduino MKR
viral load in the air we breathe. It’s important to a cloud platform and displayed on a web FOX1200) connect to the motherboard.
to maintain a good airflow to help reduce the page viewable from anywhere in the world.  
risk of passing on airborne viruses. CO2 sensor   The microcontroller board records the
modules are widely available and can be used This CO2 traffic light system described here measured values ​​(CO2 concentration, air
with a controller to continuously monitor the connects to the Internet using the Sigfox radio temperature and humidity) from the SCD30
air we breathe. Warnings and alarm messages network rather than Wi-Fi. Sigfox is particu- CO 2 sensor at regular (adjustable) inter-
can then be issued when the measurement larly well suited to this application because vals and shows these values ​​on a 1.3” OLED
concentration level exceeds a preset threshold. we only need to send small amounts of data, display. The traffic light indicator consists of a
  and the excellent radio coverage achieved by multicolor NeoPixel LED matrix display.
That is the task of a standard CO2 measure- Sigfox gives us maximum flexibility when siting  
ment traffic light system. It provides a visual the sensor. The Sigfox network generally only The CO2 sensor SCD30 sensor [1] uses an I2C
and sometimes acoustic alarm when more requires a handful of base stations to cover bus (SDA, SCL, +5V and GND) and connects
fresh air is required. The concentration of CO2 an entire city and coverage in many countries via the space-saving double-level screw termi-
is indicated via a red, yellow or green LED around the world is already very good. This nal strip X1. If required, 4.7-kΩ pull-up resistors

74 July & August www.elektormagazine.com


+5V JP1 7805 D1 F1
IC2
R1 X6
1N4004 800mA

1k5
C4 C2 C1 C3
VCC
220µ 220µ
GND
D2 100n 100n

+5V

R3 R2

USB

4k7

4k7
IC3 SCL
SCL
SDA
IC1
SDA
ARDUINO UNO R3 RST +5V
AREF
GND AREF 5V
A0
RESERVED 13 DAC0/A0 VIN
A1
IOREF 12 A1 VCC
A2
RESET 11 A2 GND
A3
3.3V 10 A3 RES
+5V

5V 9 A4 14 < TX
POWER

GND 8 A5 13 > RX
GND A6 12 SCL
DIGITAL (PWM)

DIO7 DIO0
VIN 7 0 11 SDA
DIO6 DIO1
6 1 10 MISO
A0 DIO5 DIO2
A0 5 ~2 9 SCK
A1 DIO4 DIO3
ANALOG IN

A1 4 ~3 8 MOSI
A2 ICSP DIO3 DIO4
A2 3 7
RESET

~4
MISO

A3 DIO2 DIO5
SCK

A3 2 ~5 6
SDA DIO1
A4 TX 1
SCL DIO0 MKR FOX1200
A5 RX 0
ANT
GND
MOSI
5V

DIO6
DIO7
DIO2
DIO7
DIO1
DIO0

DIO3
DIO5
DIO6
DIO4

A2
A0
A1
A3
SDA
SCL

SDA
SCL

R4
+5V +5V +5V +5V +5V
470

RESET 1 3 2 4 1 4 2 5 3 6 1 4 2 5 3 6 1 4 2 5 3 6 1 3 2 4

X2 C5 X4 X3 X5 X1
S1

1000µ

OLED DISPLAY LED MATRIX DIO ANALOG SCD30 200650-003

Figure 1: The CO2 traffic light circuit diagram showing both the Arduino Uno and the MKR FOX1200 board wiring.

can be connected to SDA and to SCL. The connections X3, X4 and X5. These connec-
OLED display [2] also connects via the I2C bus tors can be used to provide future additional
at the X2 double-level terminal strip. functionality to the system, for example to
  switch on air conditioning units or actuate
In addition to a power supply connection we ventilation when measured values exceed
only need a single digital port pin to operate thresholds.
the NeoPixel LED matrix display [4]. Port pin  
DIO7 is used here and the display connects Figure 2 shows the assembled circuit board
via the double-level terminal strip X4. NeoPixel onto which either the Arduino MKR FOX1200
displays with different numbers of LEDs can module or the Arduino Uno board is plugged
be driven from this single port pin. (face down) into its corresponding rows of
  connectors. Only one of these boards
Additional sensors/actuators can be should be fitted to the motherboard at any Figure 2: The finished CO2 traffic light
con­nected to the unused digital/analogue time. Do not try to mount both boards, by motherboard PCB.

lektor July & August 2022 75


Figure 3b: The Arduino Uno fitted face
down to the motherboard.

Figure 3a: The Arduino MKR FOX


1200 fitted to the motherboard. Figure 3c: The CO2 sensor module (left) and
various displays.

using extending headers. The board layout, connections to mitigate supply voltage supply can easily be provided via the Arduino
the assembly plan, a parts list and Arduino fluctuations as the LEDs are switched. on-board SMD voltage regulator. In this case,
firmware used can be downloaded from Use an electrolytic capacitor in the jumper JP1 on the motherboard must be
the Elektor project page [3]. The flat Sigfox range from 470 µF to 1,000 µF for smaller removed so that the 7805 will not become
antenna can be fixed in position using double- displays. The value used in this applica- reverse powered.
sided adhesive tape. Figure 3 shows both tion (C5) is 1,000 µF.
versions assembled. > Install a low value resistor in series with Add Some Libraries to the
the display control line to reduce inter- Arduino IDE
The Power Supply ference. The value used here (R4) is The CO2 traffic light software requires some
One important consideration when using 470 Ω. additional libraries to operate external
NeoPixels is their power requirements. In the > An external regulated power source will components like the CO2 SCD30 sensor, 1.3”
worst case when all three of the individual be required with a high-quality voltage OLED display and NeoPixel LED matrix. Two
LEDs in one NeoPixel is set to maximum inten- regulator (possibly even cooled) and additional libraries will also be required for
sity with a value of 255 to produce the bright- with appropriate reservoir capacitors Sigfox operation with the MKR FOX1200 board
est white light, each LED element will draw (here we use a conventional 7805 linear and an optional one for the on-chip RTC of
20 mA so a single NeoPixel requires 60 mA. regulator on the motherboard powered the SAMD21 microcontroller.
A matrix made up of 16 NeoPixels requires from a 9V/1A mains adapter). DC/DC  
16 × 60 mA = 960 mA! That’s more than can switching regulators can also be used The SCD30 CO2 Sensor Library
be supplied by the 5V SMD voltage regula- here they offer better efficiency and are To install the SparkFun driver library for
tor (without a heatsink) fitted to the Arduino not much more expensive. the SCD30 sensor, go to Tools -> Manage
board. Powering it from the Arduino board > Under no circumstances should the Libraries... in the Arduino IDE, then look for
would overload the regulator which may shut uncooled on-board SMD voltage stabi- scd30 in the top right corner. The two most
down or in the worst case, release its inter- lizer of the Arduino boards be used, popular SCD30 libraries will be listed, one from
nal smoke. since failures can quickly occur, partic- Adafruit and one from SparkFun. As shown
  ularly if you are using a cloned board, in Figure 4, we will use the SparkFun library.
Under normal operating conditions, you proba- due to overheating or switching current  
bly will not be driving the NeoPixel so hard, but peaks. After installation, the library is automatically
reckon on an average current consumption of > The NeoPixel LED display matrix should integrated into our program in the IDE via
25 to 30 mA per NeoPixel, depending on the only be as large as absolutely necessary Sketch -> Include Library -> ... SparkFun
overall colour displayed. With a 4×4 LED matrix, and should not be operated at maximum SCD30 Arduino Library. You can get a detailed
you still get 400 to 480 mA, which again will brightness. The brightness of the round description of the library by clicking on More
be too much for an on-board Arduino voltage 7-element NeoPixel display used here is info in the bottom left of Figure 4.
regulator to cope with. controlled by the software using a range  
  of values from 4 to 16 out of 255 possible The 1.3” OLED Display Library
Therefore, the following should be observed levels. The extremely powerful and comprehen-
when using NeoPixel displays:   sive U8g2 library built by Oli Kraus is used to
  If the system is operated without a NeoPixel drive the 128*64 pixel 1.3” OLED display. This
> Install a reservoir electrolytic capacitor display for test or other purposes, and if the complete software package actually consists
directly at the NeoPixel power supply total power consumption is not too high, the of four individual libraries:

76 July & August www.elektormagazine.com


 
> U8g2: Library for graphics-capable Figure 4: Select the SCD30 library from SparkFun.

display applications using large numbers


of graphics functions and display charac-
ter sets.
> U8x8: Library for simple, purely
text-based display applications with a
reduced range of character sets.
> MUIU8g2: Special functions for the reali-
zation of interactive, graphics-capable,
Monochrome User Interfaces (MUI).
> U8log: Functions for emulating a terminal,
similar to the serial monitor feature of the
Arduino IDE. Figure 5: Select the U8g2-library to drive the 1.3” OLED display.
 
The U8g2 driver library for the OLED display
is also installed in the Arduino IDE using Tools
-> Manage Libraries...; then look for u8g2 in
the top right corner (Figure 5).
 
After the installation, the three core libraries
are automatically integrated into our program
using Sketch\Include Library\… U8g2.
 
#include <MUIU8g2.h>         // delete
#include <U8g2lib.h>         // delete
#include <U8x8lib.h>
 
We only need the text-based U8x8lib, so the
#include statements referencing the other
two libraries can be deleted.
 
The advantage of the U8g library pack is,
among other things, the large number of
supported display types which includes: Figure 6: Uncomment the correct one from this large assortment of U8x8 supported display types.
 
> LCD, OLED graphics capable displays
> Various pixel resolutions
> Control via different buses: I2C/SPI in File -> Examples -> U8g2 -> U8x8. Be careful > Display controller: SH1106
hardware or software implementation, to only select examples for the U8x8 library! > Display pixel count: 128*64
parallel buses according to 8080 and   > Display manufacturer: NONAME (we use a
6800 specification In the long list in this HelloWorld sketch, we generic unbranded display)
> Various driver components need to search for the (OLED) display used. > Hardware interface method: I2C
  You enable it by removing the // comment > Name of the created object for reference
While it’s undoubtedly useful to have an delimiter. We just copy the corresponding in the program: u8x8
overabundance of supported displays, make (commented out) line 64 of the appropriate > Expression in brackets: the display reset
sure you choose the correct one, otherwise display constructor to line 119 [3] of our CO2 pin is not used
you will run into problems. In Figure 6 you traffic light sketch:  
can see just a section of the myriad of possi-   You can get a detailed description of the library
ble supported display types commented out. U8X8_SH1106_128X64_NONAME_HW_I2C by clicking on More info in the lower left corner
  u8x8(/* reset=*/ U8X8_PIN_NONE); of Figure 5.
It therefore makes sense to first look at one of    
the finished examples that were installed with which breaks down to: The NeoPixel-LED Library
the library in the Arduino IDE — for example   The NeoPixel LED concept developed by
the HelloWorld example can be found under > Driver Library: U8X8 Adafruit makes it possible to construct large,

lektor July & August 2022 77


coloured LED strips, fields, circles and other
shapes composed of individual RGB LED
elements. All LED elements are daisy-
chained and controlled via a single digital
I/O line. The WS2812 LED controller makes
it possible to control each of the three differ-
ent coloured individual LEDs (red, green, Figure 7: Install the Adafruit NeoPixel library.
blue) with programmable 8-bit intensity, so
that almost any colour combination can be
generated.
 
The advantage of creating software for
NeoPixel applications of any size is that there
is a very convenient Arduino library from
Adafruit to provide control. This library is also
included in the Arduino program package
and is installed using the library manager you Figure 8: Select the RTC library for the SAMD21 microcontroller.
are already familiar with (search for neopixel),
as shown in Figure 7. After installation, the
library is automatically integrated into our
program via Sketch -> Include Library ->
Adafruit NeoPixel. Here, too, you can find a
detailed description of the library under by
clicking on the More info link.
 
The SAMD Microcontroller RTC Library
The SAMD21 microcontroller on the MKR
FOX1200 board has an on-chip RTC that
can be used for system-wide time and date Figure 9: Select the Sigfox-library for the MKR FOX1200 microcontroller board.
applications. This requires a backup battery
for the board so that the RTC does not lose
track of time every time the supply voltage  
is switched off. We chose not to include the Using Sigfox, the measured values of ​​ the CO2 places for debugging purposes (for the serial
backup battery in the CO2 traffic light, but traffic light system are transferred wirelessly monitor in the Arduino IDE). Once you are
a corresponding small circuit can be easily to the Internet where they can be accessed satisfied everything works as it should, these
connected to the MKR FOX1200 board. and displayed anywhere in the world using code sections can be commented out or
  a PC, laptop, tablet or smartphone. deleted.
If you want to use this RTC, there is of course    
a convenient driver library for this, which Here again we can take advantage of all the You can freely assign thresholds for the
can be installed as usual via the library ready-made functions in the Sigfox library measured CO2 concentration levels and the
manager (search for rtc, Figure 8). As usual, available in the Arduino program package. associated traffic light colour. Our suggested
the detailed description of this library can The library is installed via the library manager thresholds are:
be found under More Info. The library is just as we did with the others (search for  
integrated using Sketch -> Include library sigfox, Figure 9). Now use Sketch -> Include > 0 to 1000 ppm:       saturated green
-> RTCZero. Library -> Arduino Sigfox for MKRFox1200 to > 1001 to 2000 ppm:    yellow
install it. Click on More Info to discover more > 2001 to 5000 ppm:    orange
The MKR FOX1200 Sigfox about the available Sigfox functions. > 5001 to 12000 ppm:   saturated red.
Library  
Now we come to the connection of the CO2 Significant snippets of the annotated Operation Using the Sigfox
traffic light to the Internet of Things using Arduino program (for the MKR FOX1200 Network
the Arduino MKR FOX1200 microcontroller board) are given here in Listing 1. The In [5] we have shown in detail how the
board, which talks to the Sigfox network. For complete program in German and English parameterization and operation of the MKR
more information about Sigfox, take a look [3] is documented in detail and still contains FOX1200 module is implemented in the
at the four-part introduction in Elektor [5]. some serial output routines inserted in many Sigfox network. Here we can limit ourselves

78 July & August www.elektormagazine.com


Listing 1. Excerpts from the Arduino sketch.
void loop()
{
  unsigned char i;
  char text[15];
 
  // loop
  while(1)
  {
 
    /* The SCD30 sensor measures automatically every 2 seconds.
       If data is available, then read it out and store it in variables*/
 
    if (AirSensor.dataAvailable())      // Check if new data is available
    {
      // If yes, then read the 3 measured values
      co2 = AirSensor.getCO2();
      temperatur = AirSensor.getTemperature();
      luftfeuchte = AirSensor.getHumidity();
 
      // Increase counter
      mess_zae = mess_zae + 1;
 
      // Print values on the serial monitor
      Serial.print("Measurement-Nr: "); Serial.print(mess_zae); Serial.print("   //   ");
 
      // Print time
      print2digits(rtc.getHours());
      Serial.print(":");
      print2digits(rtc.getMinutes());
      Serial.print(":");
      print2digits(rtc.getSeconds());
      Serial.println();
 
      // print measurements
      Serial.println("CO2:      " + String(co2) + " ppm");
      Serial.println("Temp:     " + String(temperatur-temp_cor) + " °C");
      Serial.println("Hum:  " + String(luftfeuchte) + " %rh");
      Serial.println();
 
      // Processing the CO2 value for the 'LED monitor': NeoPixel display
      switch(co2)
      {
        case 0 ... 1000:  pixels.fill(gruen_satt,0,7);
                          pixels.show();
                          break;
   
        case 1001 ... 2000: pixels.fill(gelb_1,0,7);
                            pixels.show();
                            break;
   
        case 2001 ... 5000: pixels.fill(orange_1,0,7);
                            pixels.show();
                            break;
       
        case 5001 ... 12000: pixels.fill(rot_satt,0,7);
                             pixels.show();
                             break;         
      }
 
      // Output of the measured values on the OLED display 
      // Output: CO2 value
      u8x8.setCursor(6,2);
      sprintf(text,"%5d",co2);   // sprintf only works with integers
      u8x8.print(text);
 
      // delete Phantoms
      u8x8.setCursor(11,2);
      u8x8.print(" ppm");
 

lektor July & August 2022 79


stations (Sigfox Stations) within range. These
base stations transmit all received data via
the Internet or GSM connection to the Sigfox
Cloud, from which the user can retrieve their
data and further evaluate it in their data
processing application (Customer IT).
 
The user account configuration interface
Figure 10: Basic structure of the Sigfox network (Source: Sigfox). is called Sigfox Backend. This is where the
Sigfox Objects (devices) are registered,
groups are assigned and data forwarding
to Customer IT (via Callbacks) are set up.
 
First, the Sigfox device unique identifier ID
and PAC must be read out of the Sigfox
device using a small Arduino sketch [3].
These two parameters are required to regis-
ter the Sigfox device in the Sigfox Cloud
at [6].
 
During operation, worldwide access is
available to the telegrams. You log in to the
Sigfox backend [7] with your e-mail address
and the selected password which brings
Figure 11: The Sigfox portal (Sigfox-Backend).
you to the Sigfox portal start page (Sigfox
backend) in Figure 11. Here you click on the
Device tab so that a list of the active Sigfox
devices appears. If you then click on the Id
field of a device, you get to the information
page for that device. Here you now click on
MESSAGES on the left side and end up in
the window in which all telegrams are listed
that the Sigfox backend has received from
this device (Figure 12).

Creating Callbacks in the


Sigfox Backend
Figure 12: The device message window. This raw data is not particularly meaningful.
As soon as the MKR FOX1200 sends data to
the Sigfox backend, we want it to be automat-
ically forwarded to the thinger.io dashboard
to a brief description of the principle and the can transmit a maximum of 12 bytes of program. The Sigfox backend offers so-called
necessary steps. We begin with an overview measurement, status or other data with Callbacks for this purpose.
of the Sigfox network (Figure 10). each transmission. Since the Sigfox network  
  works in the license-free ISM band, to remain Such a callback is nothing more than an
The Sigfox-Objects, like our CO2 measuring within the legal regulations, each object is automatic forwarding to the desired recipient,
device or other sensor board, send out their only allowed a maximum of 140 transmissions which occurs immediately when the Sigfox
telegrams as a broadcast according to the per day. Our MKR FOX1200 board is therefore backend receives data from a Sigfox device —
“fire-and-forget” principle via the license- allowed to send one telegram every eleven for example, from our MKR FOX1200 module.
free 868 MHz ISM band. In addition to an minutes on average. The creation and configuration of a Callback
identification (sender ID), each telegram   was dealt with in detail in the third part of
contains a user data field with a maximum Depending on the coverage, these transmis- the article series [5], so here we will restrict
size of 12 bytes, called the payload. A user sions are then received by all Sigfox base our description to the essentials.

80 July & August www.elektormagazine.com


      // Output of the temperature value = float number
               oled_float(6,4,temperatur-temp_cor,1);     
 
      // Output of the humidity value = float number
      oled_float(6,6,luftfeuchte,1);     
   
      // Waiting times for measured value acquisition and transmission of the Sigfox telegram
      delay(w_zeit * 60000);            // (w_zeit * 1 Minute) wait between the measurements
      min_zae = min_zae + w_zeit;       // Minutes count until the next Sigfox transmission
      if (min_zae == SF_zyk)            // Now: send Sigfox telegram
      {
        SF_send_data();
        min_zae = 0;                    // Reset counter
} } } }     
 
/*** Send data via Sigfox ***/
 
void SF_send_data(void)
{
  Serial.print("Sigfox - Start ... \n");
 
  // Write measured values to the data structure variable
  SF_Ampel.CO2    = co2; 
  SF_Ampel.Temp   = temperatur;  
  SF_Ampel.Feucht = luftfeuchte;   
 
 
  // If required: Debug outputs
/*  Serial.println();
  Serial.print("CO2:     "); Serial.println(SF_Ampel.CO2);
  Serial.print("Temp:    "); Serial.println(SF_Ampel.Temp);
  Serial.print("Feucht:  "); Serial.println(SF_Ampel.Feucht);
  Serial.println();
*/
 
  // Activate Sigfox modem and query errors
  if (!SigFox.begin())      // Initializing the modem
  {
    Serial.println("Sigfox modem not found! - Continue with RESET!");
    while (1);  // loop
  }
  else
  {
    Serial.println("Sigfox modem initialization OK!");
  }
 
  // Enable debug LED and disable sleep modes
  SigFox.debug();
 
  // Clears all pending interrupts
  SigFox.status();
 
  // Send payload via Sigfox
  SigFox.beginPacket();               // Preparing to send a packet
 
  // Send structure variable to the Sigfox backend
  SigFox.write((char*)&SF_Ampel, sizeof(SF_Ampel));
 
  // Error checking: If endPacket() returns 'true': error
  SF_error = SigFox.endPacket()
  if(SF_error > 0)
  {
    Serial.println("Sigfox-Error !!");
  }
 
  // Sigfox end
  SigFox.end();
 
  Serial.println("Sigfox - End .... !\n"); 
}

lektor July & August 2022 81


types of callbacks for the most common types
of Dashboard-/Cloud-programs (Figure 15).
Here you select Custom Callback.
 
In the window that now appears (Figure 16),
the callback for sending the data from the
Sigfox-Backend to thinger.io is configured.
 
With this callback, the Sigfox backend always
Figure 13: Choose the desired Device Type.
sends the variables Device-ID, Telegr-Nr,
CO2, Temp and Feucht (Humidity) with their
values to
​​ the Dashboard Program immediately
after receiving the telegram from the CO2 traffic
light.

Build a Dashboard with


Thinger.io
Thinger.io is an open-source IoT visualization
platform with which you can quickly and easily
create clear and descriptive representation
of data. For smaller projects, it can be used
free of charge. The values ​​are visualized on a
Figure 14: The Callback window.
dashboard, which can also be made publicly
available to web browsers.
 
Only a few simple steps are necessary
before you are able to develop a customized
Dashboard:
 
> Create a free user Account at thinger.io.
> Create a data container (Data Bucket) at
thinger.io to hold the measured values ​​
sent from the Sigfox cloud.
> Define the access point (Token) for the
Sigfox-cloud and create a receipt authenti-
cation (Access Token) at thinger.io, so that
the Sigfox-cloud receives permission to
transmit data to thinger.io.
> Configure a Callback in the Sigfox-cloud
to transfer the data from the Sigfox-cloud
to the Data Bucket in thinger.io via the
Internet.
> Design a neat dashboard on the thinger.io
site to visualize the data.
Figure 15: The large selection of different Callback types.  
Here, too, we refer to [5], which gives a more
detailed description of the individual steps. After
creating a free account at thinger.io [8], you
log in and get to the main screen, which is the
  case Arduino_DevKit_1 (Figure 13). In the starting point for all further actions (Figure 17).
To create a callback, click on the Device Type overview page of the Device Type, click on  
tab on the main page of the Sigfox Backend Callbacks in the list on the left (Figure 14) and To create a dashboard, click on the Dashboards
and in the list that appears (with only one in this window to the top right click on the small item on the left and then click on the Add
entry) on the name of the Device Type, in our button New. A list appears with all possible Dashboard button in the window that appears.

82 July & August www.elektormagazine.com


A large number of freely configurable widgets
(the user interface components) are available
for the individual design of a dashboard, for
example diagrams showing measurement
values over time, donut diagrams, bar charts,
analogue displays, Google Maps to show
location, images, text displays, LEDs and a
clock.
 
Figure  18 shows an example of a dashboard Figure 16: Callback configuration.
designed with thinger.io for our CO2 traffic light.
The measured values are​​ shown in the form of
a time chart. In addition to this data, the time,
telegram number and other information can be
displayed. Worldwide access to the dashboard
is possible with a few mouse clicks, so that
anyone who receives the link can then read the
dashboard and check on the current values.
200650-01

Figure 17: Account statistics on the console dashboard.

RELATED
PRODUCTS

> Arduino MKR FOX 1200 (SKU 19096)


www.elektor.com/19096  

> Arduino Uno Rev3 (SKU 15877)


www.elektor.com/15877  

> Seeed Studio Grove SCD30 CO2,


Temperature & Humidity Sensor for
Arduino (SKU 20012)
www.elektor.com/20012    

Figure 18: The CO2 traffic light dashboard.

WEB LINKS
[1] CO2-Sensor SCD30: https://bit.ly/34XbL5o
[2] 1.3“ OLED display: https://bit.ly/3fEP7AX
[3] Elektor Project Page: www.elektormagazine.com/200650-01
[4] NeoPixel LED displays Information: https://bit.ly/3qf1Y2k
[5] Frank Schleking, Bernd vom Berg, “Sigfox and the IoT (1),” ElektorMag 11-12/2019 (Parts 2 to 4 follow in the next 3 editions):
www.elektormagazine.com/magazine/elektor-114/56832
[6] Provide your dev kit details: https://buy.sigfox.com/activate/devkit/DE
[7] Sigfox backend login page: https://backend.sigfox.com/auth/login
[8] Build the dashboard using thinger.io: www.thinger.io

lektor July & August 2022 83


ethics

Women
in Tech
“It's All About Merit
Until Merit Has Tits”
Photo by Kelli McClintock on Unsplash

By Priscilla Haring-Kuipers (The Netherlands)

If you are wondering why Women in Tech


would need yet another article, it is because
you — my dear reader — are most likely male.
 
Bias Galore The gender equality gap is slowly getting smaller, but both in the
Societal expectations that are based on gendered roles start early. US and the UK the share of female engineers is only around 13%
Clothes for toddlers come mainly in pink for a girl and astronaut [1]. Should you — against the odds — find yourself working as a
for a boy. Books for girls might focus on long-haired princesses female engineer, you are most likely underpaid, undervalued and
waiting in a tower to be rescued, while books for boys tend to have underutilized compared to your male colleagues. Merit be damned.
main characters like chocolate technicians flying off in elevators. Your work environment might range from unfemale to unsafe, and
Thousands of ‘little things’ are scaffolded into systemic barriers that yet you will likely be told to “lean in” or to “think like a Queen” and
diminish the likelihood of any random human being who happened be above your surroundings. Which is asking an already disadvan-
to be born a woman from becoming an (electrical) engineer. taged person to overcome real-world problems that they did not
  create nor can control by having a better attitude. It is not surpris-
For years now educational policies have tried to increase the low ing that a lot of women leave the field of engineering.
numbers of girls choosing Science, Technology, Engineering, Math
(STEM) subjects in high-school. Such girls-in-STEM interventions Personal Quota
are trying to fight back at biases that have established themselves It is why we need things like quotas for hiring capable female
firmly in our culture. My high school math teacher plainly told engineers. We did not all have a supported start into STEM on equal
the class that he would not be spending his time answering my terms, and we are not judged in engineering on merit alone. Yes,
questions as “girls do not understand.” I dropped math. Twenty there are biological differences between men and women, but they
years later I run statistical data analysis to establish effect research, do not translate into males having math heads or a female procliv-
but the road was not a straight one. ity for baking. Neurologically there is no reason for the low number

84 July & August 2022 www.elektormagazine.com


Female Factory
There are a lot of women involved in building electronics but not as the engineers.
They are the workforce on the factory floor. In the assembly houses we work with in
Shenzhen and the Netherlands, the hands on our boards are mostly female. About 70%
of the people that are carrying boards from machine to machine, doing through-hole
soldering, providing optical inspections and clamping test beds are women. They are
mostly young women and likely migratory workers in China and mostly middle-aged
women in the Netherlands. In a very practical sense women are making our electronics.

Photo by Austrian National Library on Unsplash

of women in tech. The biases that cause this situation are learned. > Flavia Ferreira (Young Padawan): In our house there is a
Which should mean that we can unlearn them. The same is true for group of women known as the ‘soldering ladies’ that roam the
any other underrepresented group of human beings in engineering. world of audio hardware doing fantastic assembly work and
  repairs. Flavia is one of them. If your circuits are built to make
A very powerful part of forming your worldview is ‘normalising’. It sound, then these are the hands you want to work on them.
means that you think that whatever you are exposed to is normal. She also posts soldering tips, Let’s Talk Nerd interviews and
This is why representation and role-models matter so much. So makes music. The force is definitely strong in this one.
try giving yourself a women’s quota wherever you connect to your www.instagram.com/imyoungpadawan
particular field of engineering. Make an effort to get maybe a third  
of your input from female engineers. (You get only half points for Please share with us which Women in Tech you would recommend
this article as I am a ‘woman in tech,’ but I am not an engineer.) to follow.
Try to fill your social media account with more women. And when 220200-01
you find interesting female voices; amplify them. To start you off
on your journey of normalising women in tech, I would like to
introduce you to three of my favourite femmes:
 
> Jeri Ellsworth: All-round inventor. Amazing programmer
and electrical engineer. Ran the R&D team at Valve, and has
recently been busy building Tilt Five. This is an AR board World Ethical Electronics
gaming system where players wear glasses with tiny projec- Forum 2022
tors that make holograms appear on a reflective gaming In November of 2021, Elektor
surface. After four years, the system is currently in production launched the World Ethical Electron-
and is about to explode onto the gaming market. ™ ics Forum (WEEF) in Munich,
www.jeriellsworth.com Germany. The event inspired global
  innovators in electronics with an
> Naomi Wu (Sexy Cyborg): A tech reviewer and DIY maker of open discussion about ethics and sustainable development
all sorts in Shenzhen. Giving you a candid peek into the birth- goals (SDGs). In addition to Elektor engineers and editors,
place of most electronics. Worked on the Creality 3D conveyer the list of speakers and panelists included Dr. Stefan Heine-
belt printing mill and builder of the blinkini. Once made a mann (Professor of Business Ethics at the FOM University of
company uphold their code licencing by simply walking into Applied Sciences), Dr. Paula Palade (PhD, Jaguar Land Rover),
their offices. Called out tech facemasks for not being safe. Margot Cooijmans (Director, Philips Foundation), and several
Advocates and opinionates loudly so that those in the back other thought leaders, including Priscilla Haring-Kuipers. Visit
can hear. The tag line, “It’s all about merit until merit has tits,” the WEEF webpage (www.elektormagazine.com/weef) to stay
is hers. informed about Elektor’s plans for WEEF 2022, which will take
www.youtube.com/c/SexyCyborg place in November of this year.
 

WEB LINK
[1] Wikipedia, “Women in Engineering”: https://en.wikipedia.org/wiki/Women_in_engineering

lektor July & August 2022 85


review

Low-Budget
Tablet Oscilloscope ADS1013D
Good Value for Money?

By Luc Lemmens (Elektor)

The time when a 100-MHz


scope would cost a fortune is
long gone. But for only €150
... too cheap to be true? Most
sellers are advertising
the ADS1013D as “Tablet
oscilloscope, 2-channels,
100 MHz bandwidth and
1Gigasamples/second.” Let’s
see what you get when you
buy one.

If you are used to working with more expen- you do, of course. During testing proto-
sive oscilloscopes from renowned brands, it types and repairing electronic devices, for
is very difficult to look at a device from the example, accuracy and precision aren’t
lower market segment without prejudice. actually that important, a quick glance if
The device I’m going to discuss here looks the signal-under-test has about the correct
good, but — with all due respect — it ‘feels’ level or waveform will do. If that is what
cheap. You know in advance that in terms of you need, this affordable unit
specifications, it can’t compete with devices may be good enough for the
that cost a multiple of the ADS1013D. If you measurements you want to
want to do very accurate measurements, take, so why spend more
you’d better save up and buy something money than necessary?
really good.  
 
But as with so much equipment and tools,
it doesn’t all have to be top of the bill to still
be useful. Let’s be honest: how often do we
really need a high-precision oscilloscope?
It strongly depends on the kind of work Figure 1: The box and its contents.

86 July & August 2022 www.elektormagazine.com


Specifications > Coupling mode: AC/DC
> Analog bandwidth: 100 MHz > Trigger mode: Single, Normal, Auto
> Number of channels: 2 > Trigger edge: rising/falling edge
> Maximum real time sampling rate: 1 GSa/s > External trigger voltage: 0 to 40 V
> Vertical sensitivity: 50 mV/div to 500 V/div > Display: 7” TFT - 800*480
> Horizontal time base range: 50 S/div to 10 nS/div > Operating: capacitive touch screen + gesture
> Maximum test voltage: 40 V (1X probe), 400 V (10X probe) > Extension ports: USB picture export
> Storage depth: 240 Kbit > Power supply: 1 * Lithium battery, 6000 mAh
> Input resistance: 1 M > Item size: 184 * 124 * 50 mm/7.2 * 4.9 * 2.0 in
> ADC precision: 8 bits > Package weight: 700 g/1.5 lb

The original plan for this review was to The box also contains two P6100 1:1/1:10 base setting of 50 s/div will hardly ever be
test a Daniu ADS1013D, but when I was switchable 100 MHz probes — no high-qua- of practical use.
looking to buy one that I could get at an lity stuff, but they will do the job. The hook
acceptable price, at short notice, I came clips could have been a bit smaller, though.  But instead of complaining what this oscil-
across the FNIRSI brand. They sell exactly   loscope does not have, let’s have a look at
the same oscilloscope with even the same And then, of course, the most important what it does have to offer. First of all, a
type number, and apparently it is also part: the oscilloscope. 7” touchscreen, a bright 800 x 480 pixel
being sold as a KKmoon and Yeapook colour LCD with a good viewing angle,
ADS1013D. I wouldn’t be surprised if the The ADS1013D Itself nothing to complain about there. With this
product is available from other brands as As I said earlier, you shouldn’t buy an touchscreen, no knobs, buttons or switches
well. There are many online shops where oscilloscope in this price range if you need are needed to operate this instrument,
you can buy the ADS1013D, and with prices highly accurate measurement equipment, except for the good old-fashioned ON/OFF
ranging from a lower hundred to more and I’m even not going to test or verify switch. The good thing about this switch is
than €300, it certainly pays to search well the specifications of this one (see textbox). that it keeps the scope powered, without
before you actually buy. Most sellers are Other reviews on the Internet (like [2]) any auto power off timer that switches it off
advertising the ADS1013D as “Tablet oscil- show that these specs are — mildly put — during measurements; but of course, if you
loscope, 2-channels, 100 MHz bandwidth very optimistic, for example, by pointing forget to switch it off without the charger
and 1 Giga-samples/second.” Let’s see what out that the 8-bit A/D-converters at the connected, the battery will probably be
you get when you buy one. input of each channel (AD9288) are by no drained the next time you want to use it.
means fast enough for real time 1 GSa/s  
What’s in the Box? sampling. Even more important: the The power switch is recessed in the top side
My FNIRSI ADS1013D is packaged in a 100 MHz bandwidth that is claimed for of the oscilloscope (Figure 2), just like the
sturdy cardboard box with protective both inputs is also unrealistic; in terms two BNC connectors for the probes, a 1 kHz
foam inside, and it contains the oscil- of true bandwidth, 20 MHz seems to be square wave output connection for probe
loscope, a 2 A USB-charger with a 1.5 m a more accurate value [2]. A maximum calibration, a red power indicator LED
long USB-C cable, two 100 MHz probes sensitivity of 50 mV/div for the inputs is plus a green LED to signal that the battery
and a small manual (Figure 1). To start a bit disappointing, and a maximum time is fully charged, and the USB-C connector
with the latter (you know: that booklet
that you never wanted to read anyway), I
can be very short: if you look inside, you
immediately hope that you’ll never need
to read it, with its small print, vague illus-
trations and very compact layout. I would
recommend to use the online documen-
tation instead [1].
 
The charger is a standard 5 V USB type, so
there’s no fast type C USB-charging on this
device. With a fully charged battery, the
oscilloscope works for about four hours,
Figure 2: Power switch, connectors and LEDs.
not bad at all!
 

lektor July & August 2022 87


trouble to find how to manually set the
time base, which appeared to be a matter
of tapping either the left (increase) or
the right (decrease) side of the waveform
display area. Not the most obvious way,
in my opinion, but it works well once you
Figure 3: Input channel 1 know how to do it.
settings menu.  
Most of the controls are self-explanatory,
with familiar names and operation as on
other oscilloscopes. However, there are
two buttons in the bottom right corner of
to connect the charger or data connection (Figure  3), and CTRL in the top right the LCD that were not clear at first: Save Pic
cable to a computer. On the back side of the corner enables control buttons to adjust and Save Wave, respectively. The first button
enclosure is a foldable tilt stand. the channels 1 and 2 input attenuators saves a snapshot (picture) of the complete
(Figure 4). There are no nested menus, screen; the second saves the waveform.
Working With the ADS1013D which makes it easy to quickly see how to Other than a static picture, a waveform
A very good thing about this ADS1013D is operate this oscilloscope, even if you only can be treated as a normal input signal,
that it is very simple to control. At the top use it occasionally. Not completely true: i.e. the time base can still be adjusted, the
and the right side of the screen are (menu) the System settings in the main menu (as attenuator settings altered, measurements
buttons you can tap to open menus, trigger I will call the menu in the top left corner) can be made, etc. after it has been saved.
functions or toggle settings. For example, has a sub-menu, but this doesn’t contain Both Pictures and Waveforms can be retrie-
tapping the yellow CH1 button opens options and functions for normal, common ved on the display by tapping the corres-
the menu for the settings of channel 1 oscilloscope operation. Silly enough, I had ponding items in the main menu, in the
top left corner.
 
There are a few items controlled by swiping
the screen, like the vertical position of the
waveforms, trigger position and measure-
ment cursors. However, it is sometimes
uncertain what exactly will move when you
swipe the display. At the top of the screen,
there is a toggle button marked move slow/
move fast that controls the swiping sensi-
tivity, the latter setting allows for more
precise movement of waveforms and
cursors. It doesn’t work to use two fingers
on the touchscreen to zoom in and out, like
you would do on other touch screen devices
like your tablet or smartphone.
 
The ADS1013D can perform Fast Fourier
Transforms on both channels, but — like
with most other affordable digital oscillos-
copes — the resulting frequency spectra
are not very useful. It can display Lissajous
figures when the X-Y display mode is set;
and that’s about it. There are no mathe-
Figure 4: Attenuators’ adjustments. Figure 5: ADS1013D connected via USB. matical functions that can be performed

88 July & August 2022 www.elektormagazine.com


Inside the ADS1013D

Since it only takes five Phillips


screws to open the case of the
ADS1013D, I could not resist the
temptation to have a look inside
on the input waveforms, not even simple the oscilloscope. Apparently,
operations like sum and/or difference of there was an earlier model of this
the two input signals. oscilloscope that didn’t have any
shielding around the input stages,
Connecting to a Computer and this has been improved for the
Apart from charging the internal battery, version I have. As far as I can tell
the USB-C cable can also be used to hook from photos I saw of the older one,
the device up to a computer. When USB most of the PCB layout looks unchanged.
Connection is selected in the main menu, I can’t tell if the ADCs at the inputs are still the same, the type numbers are removed
the picture shown in Figure 5 appears on from the ICs.
the display and the ADS1013D is presented
as a USB drive on your computer. You can
then access the images stored on the oscil-
loscope from your computer. Unlike other
digital oscilloscopes, this one cannot be
controlled via USB, the interface is for trans- What’s in a Name?
ferring pictures only. I already mentioned that this is called a tablet oscilloscope, and I guess we all know what
a ‘tablet’ is, or we all have some idea what it should be or look like. If that would just be a
To Buy, Or Not to Buy? ‘rectangular device with touch screen operation’, then this is a true tablet scope. On the
That completely depends on what you want cardboard packaging it is called a Table Oscilloscope, and, in my opinion this is a more
and what you expect from a (simple) oscil- appropriate name, but I assume that it is either a typo or a bad translation. To me, a ‘tablet’
loscope. If you need it for accurate measure- sounds like some kind of portable device that can even be used ‘in the field’ by service
ments, you shouldn’t buy this device from technicians or in the workshop. The ADS1013D is relatively small, weighs only about 700
FNIRSI, or any other oscilloscope in this grams and has a rechargeable internal battery; in all these respects it is a portable device,
price range. But in many cases, when only but I would not recommend carrying it around too much. Even though the plastic enclo-
standard functional tests are performed sure looks and feels sturdy, I don’t think the display or device itself will survive if you drop
at lower frequencies and exact, accurate it and there’s no case supplied to protect it during transport. That’s why I would keep it on
measurements are of minor importance, the table, and wouldn’t treat or use it like a tablet.
you don’t need to buy expensive equip-
ment and get good value for money with
this ADS1013D!
  200640-01

RELATED PRODUCTS
Questions or Comments?
Do you have questions or comments
about his article? Email the author at > OWON SDS1102 2-ch Digital Oscilloscope (100 MHz) (SKU 18782)
www.elektor.com/18782  
luc.lemmens@elektor.com.
> Micsig STO1152C Plus 2-ch Oscilloscope (150 MHz) (SKU 19372)
www.elektor.com/19372

WEB LINKS
[1] FNIRSI online documentation: www.fnirsi.cn/productinfo/556152.html
[2] ADS1013D tablet oscilloscope tested: https://bit.ly/3Doz6Kv

lektor July & August 2022 89


project
b•
or la Elekt
kt

Ele

or
lab
ORIGIN
AL

Ele k

ab
rl rl

to
Smart Plug Teardown
• Ele k to
ab

Which Ones Are Hacker-Friendly?


By Mathias Claußen (Elektor)

Smart plugs or Wi-Fi-enabled sockets can be had for less than €15 these days. They
allow lamps and other consumer appliances to be controlled remotely (some units
can even record the appliance’s power consumption). For electronics engineers,
it’s not always that simple. Questions such as “I wonder what hardware they are
using there?” and thoughts like “I might be able to swap out the firmware and use
a different cloud platform to the one specified by the manufacturer” are always in
the back of our mind. To check out the internals of some of these smart sockets
and find out which ones are more hacker-friendly, I turned to my toolbox and took
out screwdrivers, a hacksaw, a camera, and a magnifying glass.
 

 
 

Attention mains voltage! The electronics


discussed here operate at peak DC Figure 1: The Gosund Figure 3: Shelly Smart
mains voltage! Do not attempt to SP211. (Source: Figure 2: Amazon Smart Plug. Plug S. (Source:
operate any electrical appliance outside https://bit.ly/3wAWu6g) (Source: https://bit.ly/3wCtife) https://bit.ly/3D9TJtQ)
its protective enclosure as it could be
lethal. Any improper use will lead to
life-threatening electric shocks.
  sible to work out what their internal hardware ble) the components used. Not only did it
might consist of. To investigate further, I chose become clear which microcontrollers were
There are plenty of smart mains sockets three popular makes of smart plugs to sacri- installed, but also revealed some short cuts
controlled by radio or Wi-Fi available these fice in this teardown investigation. I was in the circuit design that have been made in
days. With regard to their functions and the interested in the following questions: Which order to save costs.
network connection (usually Wi-Fi), the various components are used? How are these wired?
models often only differ in their software and Can the unit measure power consumed and The Smart Plugs
its associated cloud service. Price-wise they mains voltage, and if so, how? Is there any To delve deeper I will take a closer look at
are also pretty evenly matched. What’s inter- overload protection? three sockets from different manufactur-
esting is how the various manufacturers have   ers. Figure 4 shows the EU6S model from
actually designed their products. The most interesting questions are proba- Aoycocr. Figure 5 shows the Tapo P100 type
bly which of these variants can more easily from TP-Link. Figure 6 shows the S26R2 from
You only need to Google “smart plug” to see be hacked and if the manufacturer’s default Sonoff. In addition to these three, I also got the
the wide range of such devices currently avail- firmware could be improved upon. To answer chance to dismantle a TRÅDFRI socket from
able (see examples in Figure 1, Figure 2, and these questions, I drew out the circuits of IKEA (Figure 7 and Figure 8) fairly recently
Figure 3). From the outside it’s almost impos- three units and identified (as far as possi- to use some parts for another project.

90 July & August www.elektormagazine.com


Figure 4: The Aoycocr
EU6S.
Figure 5: The TP-Link Figure 6: The S26R2 Figure 8: The TRÅDFRI
Tapo P100. from Sonoff. Figure 7: Ikea’s TRÅDFRI. internals.

 
Table 1 contains the technical data of the Aoycocr EU6S circuit board, on which all components except
three sockets examined in more detail. The The EU6S housing is held together by four the power contacts are located. This layout
manufacturers specified a maximum load triangular socket head screws (Figure 9), makes reengineering easier.
current of 10 A (2.3 kW at 230 V≈) for the allowing fairly easy access to the internals.  
EU6S and Tapo P100 models. With the S26R2, With the cover off, the PCB is held in place I divided the PCB into three basic functional
Sonoff pushes the limits of what is possible by two screws which screw into and make groups. Figure 13 shows the sections of the
and offers up to 16 A (3.6 kW at 230 V≈), contact with the live and neutral pins of the power supply function (yellow), Wi-Fi/MCU
which is useful for switching larger loads such plug. You will need a suitable tool which can module (orange) and relay including wiring
as kettles or electric heaters. be found in the iFixit kit from the Elektor Shop (magenta). The shunt resistor R7 and IC U3
[1] to access the screw heads. Figure 10 (Figure 14) are used here to provide a means
These items are not intended to be service- shows the two internal threads in the plug of measuring the current drawn by the appli-
able; they rely on the integrity of the casing to pins which are used to fix the PCB (Figure 11). ance switched by the unit. What’s obviously
provide electrical isolation from the user. I was Figure  12 shows the component side of the missing in this configuration is a transformer
only able to open (and reassemble) the EU6S
and S26R2 smart sockets without destroying Table 1: Technical data of three smart plugs
them. Unfortunately, the TP-Link Tapo P100 Name Max load  Wi-Fi BLE  MCU/SoC
uses a sealed housing, while getting inside
Aoycocr EU6S 2.3 kW (10 A @ 230 V≈) 2.4 GHz No ESP8266
is possible, it will be damaged in the process.
Incidentally, the TRÅDFRI socket from IKEA TP-Link Tapo P100 2.3 kW (10 A @ 230 V≈) 2.4 GHz Yes* RTL8720CF
was a job for the hacksaw, it could not be Sonoff S26R2 3.6 kW (16 A @ 230 V≈) 2.4 GHz No ESP8285
reused.
*Only used to configure Wi-Fi

Figure 9: Four screws secure Figure 10: Hard-to-reach Figure 11: Underside of the


the EU6S casing. mounting of the EU6S PCB. EU6S-PCB with fixings.

Figure 12: Component side of Figure 13: Functional areas of the Figure 14: Close up of U3 and shunt
the EU6S PCB. EU6S PCB. resistor.

lektor July & August 2022 91


R2
C2

C1

R1

+5V
C3
8 1 D2
DRAIN U1 BP
7 2 AMS1117-3.3
DRAIN GND
6 3
F1 D1 1mH DRAIN FB
L1
5 4
L1 DRAIN C/S 2 U2 +3V3
L2
10 / 0W5 R19 R21
HP-01 2
R20

C8 C9 D3 C15 C7 C4 C5
MOV1

4µ7 4µ7 470µ


U 400V 400V 16V

+3V3 +3V3

R14 R15 R16 R4 LED1


C11
R6
10k

10k

10k

10k
N 1k

R7 R11 SW R3
1 8 10
0 1

VDD SEL
S1

680
2 7 R12
R5 VIP U3 CF1 10
3 6
N OUT 1k VIN CF2 R13
4 5 10
C12 C11 V2P GND

BL0937 LED

R8 R9
L1 1M2 1M2
R10
C14
1k

SEL
CF1
CF2

+5V

+5V
R17
1k7

Q1 1 14
R18
REL RX 2 13 TX
900
GPIO4 3 12 GPIO5
GPIO0 4 11 GPIO2
L1
GPIO13 5 10 GPIO15
Re1 D4 GPIO14 6 9 GPIO12
EN 7 8 TOUT
5V
F2
L1 OUT U4
10A

220170-015

Figure 15: Circuit of the EU6S smart plug.

that would normally provide galvanic isola- any data sheet for this device. I drew out the mains signal. C8, C9 and L1 are configured
tion in a switched-mode power supply design. circuit showing all the components wired to to form a pi filter to smooth the resulting DC
Let’s take a look at the power supply first. this chip to determine the pin functions. voltage. This voltage is applied to pins 5 to 8
    of U1. The two parallel shunt resistors R19 and
The Power Supply Mains voltage is present on the left and enters R20, diode D3 and coil L2 together with the
In the upper area of Figure 15 you can see via F1, a 10-Ω resistor used here as a fuse with feedback network formed by D2, C1, C2, R1
the circuit of the power supply built around a 0.5 W power rating (Figure 17). The varistor and R2 indicate that U1 is most likely a buck
the IC U1 (HP-01 AL93PH.1, Figure 16). Unfor- MOV1 provides overvoltage protection. Diode switching regulator providing a 5 V DC output
tunately, an Internet search did not bring up D1 provides a cost-effective half-wave rectified smoothed by capacitor C7 from the 325 V DC

92 July & August www.elektormagazine.com


R2
C2

4k64
C1

R1

+5V
C3
8 1 D2
DRAIN U1 BP
7 2 AMS1117-3.3
DRAIN GND
6 3
F1 D1 1mH DRAIN FB
L1
5 4
L1 DRAIN C/S 2 U2 +3V3
L2
10 / 0W5 R19 R21
HP-01 2
R20

C8 C9 D3 C15 C7 C4 C5
MOV1

4µ7 4µ7 470µ


U 400V 400V 16V

220170-016

Figure 16: Markings on the HP-01 AL93PH.1 (U1) are more readable using false colouration.

input on capacitor C9. The circuit requires 5 V microcontroller and Wi-Fi hardware which output voltage. It is reasonable to assume that
for operation of the relay K1 which switches cannot tolerate 5 V. U1 is used here in a similar way. The wiring
power to the appliance.   and layout for an application using the MPS
  I have seen similar power supply configura- MP4050A is similar to how U1 is configured
IC U2 is the familiar AMS1117-3.3 low-drop tions used by standard mains powered LED in the circuit of the UE6S smart plug.
linear regulator that converts 5 V into a stable lamps with an E14 or E27 base. Even though
3.3 V. This voltage level is required by the I couldn’t find a data sheet for this particular  
IC (U1) I can deduce that it provides a similar
function to chips such as MPS MP4050A [2]
(Figure 18) or Power Integration LNK302 [3] Caution! This uses a non-insulated
(Figure 19) often used in LED lamps. Their power supply without galvanic isola-
data sheets give information about pin assign- tion, the ground of the circuit board can
ments and circuit wiring indicating they are have the same potential as the phase,
compatible with the function of U1. Figure 20 depending on the polarity of the socket
shows the block diagram of the internal struc- wiring. Touching the circuit ground and
ture of the MPS MP4050A. Although GND is almost all components and circuit board
the reference for the control signal and the pads is therefore life-threatening!
Figure 17: F1 is a 10-Ω resistor. gate driver, it is not the reference point for the

Figure 18: Example application circuit using the MPS MP4050A. Source: [2].
 

lektor July & August 2022 93


between 80 to 250 V (at 50 and 60 Hz) to
ensure the product is compatible with mains
supply standards around the world.
 
Measuring Power
Figure 19: Basic circuit using the Power Integration LNK302. Source: [3].
This smart plug is able to record current and
thus power and probably also the mains voltage
supplied to the load. The middle left part of the
circuit in Figure 15, containing the chip U3, is
responsible for this function. The markings on
U3 can be seen in Figure 21. It’s possible to
make out “HJL-01” along with other numbers
and letters but sadly there was no sign of a
data sheet on the internet. Further searching
uncovered similar, pin-compatible, chips such
as the BL0937 or the HLW8012. Since U3 is
powered from 3.3 V, it is probably more similar
to the BL0937 chip, the HLW8012 needs a 5 V
supply. The question remains what does U3 do?
 
The BL0937 is a smart meter IC for sockets
and other smart applications that can measure
power in single-phase networks. The pin
assignment and block diagram of the BL0937
can be seen in Figure 22. Pin CF of this chip
outputs continuous 38 µs pulses at a repetition
rate proportional to the active power measure-
ment. Pin CF1 outputs a similar pulse train with
a repetition rate equivalent to the RMS value
Figure 20: Internal Block diagram of the of active current (when the pin SEL input is at
MPS MP4050A. Source: [2].
‘0’) or the RMS value of active voltage (when
the pin SEL input is at ‘1’).
 
When comparing the circuit of U3 in Figure 15
The use of non-isolated DC/DC step-down an undamaged housing there is no danger with the reference circuit of the BL0937 given
converters is a cost effective method of you could accidentally touch any live parts. in the data sheet [4], it is noticeable that the
supplying power to the electronics in All electrical products should carry markings voltage divider resistor values​ for voltage
these smart plugs and many other electri- indicating they conform to current standards measurement do not correspond. The U3 uses
cal products. The PCB and all operating of electrical safety. The switching regulator a divider ratio of 2,400:1 instead of 1,980:1 as in
buttons and LEDs are enclosed in a plastic ICs used in these designs offer a wide-range the BL0937, which should be relevant if alter-
housing, under normal operation and with input and will often work with AC voltages native firmware is contemplated.

Figure 21: An HJL-01 chip is used in the


EU6S. Figure 22: Pin-outs and block diagram of the BL0937. Source: [4].

94 July & August www.elektormagazine.com


Figure 24: The ESP8266 Module. Figure 25: A ZB25VQ80AITG
8-Mb flash chip.

Figure 23: The Aoycocr EU6S


uses a 10 A slow blow fuse F2.

Figure 26: The TP-Link Tapo Figure 27: The pins down the Figure 28: The PCB can be divided into three
P100 forms a compact unit. middle are soldered. main sections.

   
Current is measured by the voltage drop The slow-blow mini-fuse F2 (Figure 23) is rated measure and read out the energy consump-
across a 1-mΩ shunt resistor R7 placed in at 10 A and protects the relay and circuit board tion of the connected device. However,
the neutral (N) path. The voltage across R7 from damage when excessive current is drawn the measurements from U3 should also be
connects to pins 2 and 3 of U3 through R6 by the switched load. The fuse can be easily and calibrated so that the data collected can be
and R5. Together with C11 and C12, they form cheaply replaced to get the unit working again. relied upon.
a low-pass filter for removing mains-borne    
interference. LED1 uses a 680-Ω series resistor (Figure 15, All the programmer interface contacts of the
  bottom middle). This low value of current can MCU are on the underside of the PCB so its
Pins SEL, CF1 and CF use series 10-Ω resis- be supplied directly from the MCU pin LED. necessary to take the PCB out of its enclosure
tors and 10-kΩ pull-up resistors for the signals The push button input uses a 10-kΩ pull-up if you wanted to flash ESPHome or Tasmota to
which then connect directly to the MCU pins. resistor R4. the MCU. The screws are not so easy to reach
The interface is as simple and as low-cost as   — in particular, assembly is more difficult than
possible. The HJL-01 chip is probably cheaper The Wireless Microcontroller disassembly. You can, however, open the case
than a BL0937, which retails for less than ¢60. The MCU used in this unit is an ESP8266, without causing any damage, which is a bonus.
By comparison the HLW8012 alternative is which has built in Wi-Fi compliant to IEEE
about 30% more expensive. 802.11 b/g/n. Together with a few other compo- The TP-Link Tapo P100
  nents it is on its own small PCB (Figure 24), The Tapo P100 socket (Figure 26) from TP-Link
The Relay, LED and Push Button fixed upright to the main PCB. Apart from a is significantly more compact compared to the
Appliances plugged into the socket are RESET, no other test point is labelled on the product from Aoycocr. No screws are visible
switched by relay K1. The type used is the module. Next to the MCU is the ZB25VQ80A- from the outside, because the Tapo P100 model
NHLC 932-5VCD-SL-AH with a maximum ITG 8  Mb capacity flash memory chip has a housing whose parts are held together
load capacity of 10 A at 250 V≈. Relays with (Figure 25). I unsoldered this small board with clamps or latches. Opening the case will
this spec generally cost around ¢50. The control to find which components connect to the leave marks, even if you are careful. With the
can be seen in the bottom left of the circuit in ESP8266. I was then able to determine the pin right tools, you can get to the inner workings
Figure 15. assignments of the module board and allocate quite quickly. Unfortunately, the circuit board
  functions to them. This information is given in cannot be taken out of the housing that easily
The relay coil K1 is connected to 5 V and the circuit of Figure 15. because it is soldered to the contacts of the
switched by transistor Q1. This driver transis-   plug pins (see Figure 27). I desoldered it to
tor switches 0.4 W from 5 V through the coil MCUs like the ESP8266 can easily be provided take a look at the bottom of the board.
from the 3.3 V signal output by the controller. with their own firmware. It is possible, for  
D4 ensures the back-EMF generated when example to operate the MCU with ESPHome The PCB can be roughly divided into the three
switching the inductive relay coil is safely [5] or Tasmota [6]. In addition to simply switch- areas of power supply, relay and MCU based
discharged to the supply rail. ing the load via the relay, it is also possible to on functions, which are marked in Figure 28.

lektor July & August 2022 95


R168
10
1W
L101 +5V
B1 U4
L BP2525X
R150 D15
4 3
3k3 DRAIN VCC
5
N DRAIN
2 C170
SEL
6 1
CS GND
C176 C171
R11 1% L10
2µ2 4µ7 1 3
400V 400V D13
R9 1% C172
1 3
470µ
10V

U1
+5V
RTL8720CF-VA
F2
30 VBAT_IN

D10 A1-1A-F
L SW1 D14
R5
100 23 GPIOA_9
L_OUT

C175 C174
24 GPIOA_10

SW1 = RJ-SS-105DM Q1
R155
500 21 GPIOA_7
R158
10k

R6
10k 31 VD33_OUT

SW3 R7
100 38 GPIOA_17

C6

220170-032

Figure 29: The Tapo P100 circuit diagram.

Figure 31: Realtek
RTL8720CF.

Figure 30: The BP2525 is mounted


underneath the PCB.

Figure 32: The thermal fuse is fitted close to


the relay housing. Figure 33: Disassembled Sonoff S26R2.

96 July & August www.elektormagazine.com


U2
BP2905
4 3
DRAIN VCC
5
DRAIN
2
SEL C5
6 1
R1 CS GND
+5V
L1 39!
D2
AP1117-33

RV1 CE1 L1 1mH R2 L2


STE 10D471k DB1 0!33 U1 +3V3
680µH
47n R3
U 275V

100!
N D1
R5
CE3 CE2 C6 CE4 C2 C1 C3 C4 C7

2k
3µ3 3µ3 470µ
400V 400V 10V

+3V3

LED1

R10
+5V +3V3
brother, the RTL8720DN [9], also offers Wi-Fi
in the 5 GHz band in addition to the usual
1k

+3V3 R12
L1 OUT
Q2
R8
2.4 GHz band.

1k
K1 D3
 
LED2
1k

S1
Push Button, LED, Relay and Fuse
C8
L1
R11
Control of the LED in this circuit (Figure 29)
Q1
R6 looks a bit strange at first glance. Resistor R5
1k

1k

R7 REL LED1 SW1 and a two-colour LED D10 connect directly


between pins GPIOA_9 and GPIOA_10 of the
4k7

microcontroller. By generating PWM signals


GPIO12 GPIO13 GPIO0
from these two pins, it is possible to produce
220170-015
a range of LED colours.
 
Figure 34: Circuit diagram of the Sonoff S26R2.
Transistor Q1 switches the relay and D14
serves as a freewheeling diode. GPIOA_7
controls the base of Q1 via R155. A pull-down
resistor is provided with R158 so that the
transistor remains off while the firmware is
being loaded at startup. F2 is a special feature
A chip to measure current is not available in The wiring is easy to understand from the here (Figure 32). This non-resettable thermal
this design (Figure 29). data sheet and the components are easy to fuse (AUPO A1-1A-F [10]) ruptures in the event
  identify. There is not much difference to the of overheating when the relay is overloaded.
The Power Supply EU6S power supply. There is no 3.3-V supply This interrupts current to the coil so that the
The power supply circuit was easy to work generated in this design. The MCU used here relay drops out and cools down but the fuse
out because the IC labelling was legible and (see below) makes it clear why this is the case. does not reset. Access to the internals to
datasheets could be found. Previous experi-   replace the fuse is quite difficult so any P100
ence with the EU6S previously was helpful: The RTL8720CF with Wi-Fi and BLE unit suffering this fate is most likely to join
Here, too, a 10-Ω resistor (R168) — this time The Tapo P100 does not use the ubiquitous the increasing mountain of electronic waste.
with a 2 W rating — is installed as a fuse and ESP8266 microcontroller but instead uses  
current limiter. the RTL8720CF from Realtek (Figure 31). The The built-in button has a classic circuit with a
  datasheet [8] indicates that it only requires a 10-kΩ pull-up resistor to 3.3 volts, a capacitor
The main chip U4 is a switching regulator 5-V supply because it has an integrated 3.3-V for contact debouncing and a 100 Ω resistor
type BP2525 [7] (Figure 30). Here, too, a regulator. The maximum load on this 3.3-V connecting to GPIOA_17.
non-isolated step-down converter is used; supply is 450 mA.
it generates a selectable 5 V or 3.3 V from   The Sonoff S26R2TPF
up to 500 VDC at the input. A bridge recti- Wi-Fi is supported in the 2.4 GHz band and By the time I got round to dismantling the
fier converts the AC mains voltage into a DC Bluetooth Low Energy 4.2 is also available. The Sonoff, I knew what to expect and was just
voltage which is then smoothed with a Pi filter MCU is based on an ARM Cortex-M33 core curious as to how the various functions
made up of C176, L101 and C171. (called KM4 by Realtek), which can be clocked had been implemented. The Sonoff model
  at up to 100 MHz. The MCU also has 2 MB S26R2TPF (Figure 33) can switch up to 16 A
Chip U4 provides an output voltage (depend- integrated flash memory and 256 KB RAM, at 250 V≈; its circuit diagram can be seen in
ing on the version) up to 500 mA at 5 V. altogether an interesting choice. Its bigger Figure 34.

lektor July & August 2022 97


 
If you are interested in using alternative
firmware on the devices a very helpful
website on this topic can be found at [12]
called Tuya-Convert. A number of these smart
sockets can even be flashed with alterna-
tive firmware without the need to physically
get inside the unit. If your model needs to
be opened most ESP8266 MCUs can be
Figure 36: The ESP8285 module fitted in re-flashed using the Tasmotizer [13]. Appro-
the S26R2. priate settings must be made according to
Figure 35: The BP2905 is compatible the model.
with the BP2525 chip.
 
If you want to use ESPHome, you can install
  this on some sockets without opening the
The Power Supply the switching transistor prevents the relay from case using OTA (Over The Air) programming
The power supply section is built around U2, unintentionally switching during boot. via Wi-Fi [14]. With some models, however,
a switching regulator IC marked as a BP2905   you will need to resort to a screwdriver and
(Figure 35). Unfortunately, I couldn’t find a The Wireless MCU soldering iron.
datasheet for this. It is possible to deduce The ESP8285 MCU (U1) is on its own mini
from the package outline, pins and wiring to circuit board, mounted at right angles to
external components that it is most likely a the main board (Figure 36). Thanks to its
pin-compatible relative of the BP2525 chip. integrated flash memory, this ESP8266 variant  
  does not need any additional flash chip. The
In this circuit again resistor R1 acts as a pin assignment can be found in the circuit Second warning: As this article shows,
fuse. The bridge rectifier DB1 is followed by diagram in Figure 34. all sockets discussed here use non-iso-
a pi filter made up of CE2, L1 and CE3. The lated power supplies. This means parts
BP2905 produces a stable 5 V on the reser- Software to Use a Different of the circuit will be at peak line voltage
voir capacitor CE4. As with the EU6S, a linear Cloud (almost 400 V in Europe). It can be lethal
voltage regulator is used to generate 3.3 V While we have concentrated on the hardware if any part of your body makes contact.
for U1. aspects of smart plugs,there are also consid- The design of these smart plugs relies
  erations when the unit is in use and its on the integrity of their insulated enclo-
Push Button, Relay and LED connectivity to a cloud-based server. The sures to protect the consumer from
The wiring of the button S1 is simple and only manufacturer’s software will usually connect harm. Touching any internal components
requires a 1-kΩ pull-up resistor plus capacitor the socket to the home Wi-Fi and then during operation is life-threatening.
for contact debouncing. It connects directly needs to be configured via an app so that This cannot be overstated: Never work
to the SW1 input of the MCU without any the socket can be used with a smartphone, on live circuits and always follow the
series resistor. Amazon’s Alexa, Google’s Home or Apple’s applicable safety rules. In addition: The
  Homekit. Many smart sockets use the cloud mains-side capacitors used in power
The anode of LED2 connects to the 3.3-V service of a provider who hosts their servers supply units can still carry a high voltage
supply while its cathode is switched via series somewhere in the ether which ultimately also charge of several hundred volts for a
resistor R11 from a GPIO pin of the MCU. has access to the smart device. This config- while after they have been switched off.
  uration then allows loads to be switched Before working on these (unpowered)
LED1 is powered from the 3.3-V supply and remotely via the Internet. Unfortunately, such circuit boards, make sure to discharge
has its own driver transistor Q2 which is a cloud connection is not entirely reliable them to be on the safe side.
switched by the same GPIO signal from the since there is no guarantee that any cloud
MCU which operates the relay. It indicates provider will not simply discontinue its
when the load is switched on. service one day [11].
    ESP8266, ESP8285, RTL8720...
The relay is connected as in previous variants As already mentioned, there are alternatives If you are now thinking of buying a smart
with one terminal of its coil connected to 5 V, for smart plugs based on the ESP8266 by socket with the intention of installing alter-
and the other connection switched to ground installing the open-source firmware TASMOTA native firmware, note that both ESPHome and
via Q1 by a 3.3 V control signal from the MCU. [6] or ESPHome [5]. This replacement of the Tasmota currently only support ESP family
A diode (D3) across the coil again snubs the original firmware then allows the device to chips. While there is ample documentation
coil’s back-EMF. As with the other two sockets, be controlled from your own LAN via MQTT, for the RTL8720CF that does not mean that
a resistance between the base and emitter of WebUI, Alexa or other protocols. alternative firmware support is available.

98 July & August www.elektormagazine.com


 
In addition to the MCUs, we found here you
might find other types such as the Realtek
RELATED PRODUCTS
RTL8710, Beken BK7231T or the XradioTech
XR809 installed in other brands of smart
plug. As ever it makes sense to do as much > Koen Vervloesem, Getting Started with ESPHome (Elektor 2021) (SKU 19738)
background research as possible before www.elektor.com/19738  
purchase. If you’re lucky, another dedicated
developer has already done the hard work > CH340 USB/TTL Converter module CH340G (3.3 V/5.5 V) (SKU 19151)
www.elektor.com/19151  
to analyze and then publish their findings on
the web. Another important aspect is that > OWON OW18B Digital Multimeter with Bluetooth (SKU 18777)
manufacturers products in the same range www.elektor.com/18777
will inevitably undergo optimization over time
so that hardware may change possibly by
installing other MCUs thereby making them
more difficult (or more interesting) to modify.

A Helpful Hack
As we discovered, all three smart plugs are to assess other products and use the circuits
very similar. An un-isolated power supply as inspiration for future projects.
steps down the mains voltage to power an  
MCU with Wi-Fi that controls a relay. There are If you have already tinkered with smart
some variations in the implementation such as sockets, share your experiences (whether
protective measures, the LED control method good or bad) with us. Any unusual findings
or the addition of a smart meter chip. Even and insights into the design of other smart
though IKEA’s TRÅDFRI only made a guest plugs are very welcome and may help
appearance here, I can tell you that there is others. 
nothing out of the ordinary in its design also. 220170-02
 
Hacking into these products was definitely Questions or Comments?
instructive for me. I got a glimpse into some Do you have any technical questions
safety aspects of the design and how “optimi- or comments prompted by this article?
zations” can cut costs, which is a particularly Email the author at mathias.claussen@
important criteria in the design of high volume elektor.com or contact the team at
consumer products. I can use that knowledge editor@elektor.com.

WEB LINKS
[1] iFixit Pro Tech Bit Set: www.elektor.com/ifixit-pro-tech-toolkit
[2] MP4050A: www.monolithicpower.com/en/mp4050a.html
[3] Power Integrations LNK302: www.power.com/products/linkswitch/linkswitch-tn/lnk302dg
[4] BL0937: https://bit.ly/37KY7Uo
[5] ESPHome: https://esphome.io/
[6] Tasmota: https://tasmota.github.io/docs/
[7] MP2565: www.monolithicpower.com/en/mp2565.html
[8] RTL8720CF: https://bit.ly/3DbrJ8Z
[9] RTL872xD: https://bit.ly/3JESUf2
[10] AUPO A1-1A-F: www.tme.eu/en/details/a1-1a-f/thermal-fuses/aupo/
[11] N. Statt, “Nest is permanently disabling the Revolv smart home hub,” The Verge, April 4, 2016: https://bit.ly/3ICGi6O
[12] Tuya Convert: https://tasmota.github.io/docs/Tuya-Convert
[13] Tasmotizer: https://github.com/tasmota/tasmotizer
[14] ESPHome OTA Installation: https://bit.ly/3JIlps9

lektor July & August 2022 99


background

Skin Impedance
and Skin Capacitance
Small Experiments

By Burkhard Kainka (Germany)

What do capacitors have in common with wires in water or fingers


touching metallic surfaces? Quite a lot, as the author discovered
with his own experiments and measurements. Skin impedance
can be used for a variety of interesting applications.

Many years ago, I encountered some strange using an AC signal, or, more precisely, a short becomes very small and the internal imped-
effects involving wires in water and fingers positive pulse followed by an equally short ance is therefore dominant. This means that
touching metallic surfaces. At the time, I negative pulse. The result was astonishingly electric shocks are more dangerous than you
wanted to measure wood moisture content good conductivity values. A normal multi- might think from an ohmmeter reading.
using stainless steel screws in the wood. meter shows a resistance of around 1 MΩ  
Unfortunately, the characteristics of the between the two contact electrodes, but the The other focus of such investigations lies in
contacts changed quickly, resulting in less microcontroller instrument gives values of the medical domain. The aim is to find out
current flow. It was even possible to build up around 10 kΩ.
a charge on the contacts, and I was able to  
measure a voltage for several seconds after If you do an online search on this topic, you
the supply was disconnected. I decided to call will quickly discover that skin impedance
this a ‘wood battery’. Only later did I realise is frequency dependent. The higher the
that this involved a double layer of water frequency, the higher the conductivity. The
molecules forming a double-layer capacitor. impedance also drops with increasing voltage.
Now I have clarified this mystery with further Investigations like this are performed for a
measurements. variety of reasons. At one time it was about
the dangers of electricity. Researchers inves-
Measuring Skin Impedance tigated how much current could flow through
The starting point for the measurements was the human body under various conditions.
the development of a conductivity meter for This revealed that the internal impedance
human skin (Figure 1) using a microcontrol- from hand to hand is only a few thousand
ler, which was ultimately intended to be used ohms, and the skin impedance is dominant.
as a lie detector. I made the measurements With high AC voltages, the contact resistance Figure 1: Measuring skin impedance.

100 July & August 2022 www.elektormagazine.com


how ECG electrodes work or what conclu-
sions can be drawn from the body impedance.
These investigations reveal that the contact
resistance can change over time during the FINGER

investigation and that it can be influenced by 1V


a saline solution. The impression remains that
the skin is a very complex organ. OSC

10k
An Equivalent Circuit for the
Skin 200621-006

What an electronics hobbyist or engineer


actually wants is a usable equivalent circuit
Figure 2: Measuring with AC signals. Figure 3: The voltage drop over the resistor.
for small signals. Up to now this has usually
been assumed to be a resistance on the order
of 100 kΩ to 1 MΩ, but this is apparently only
valid for low DC voltages up to approximately
9 V. The behaviour of the skin is different with
AC voltages. So, I switched on my sinewave
generator and built a voltage divider consist- FINGER

ing of two fingers and a fixed 10 kΩ resistor. 0V/0V2


 
Measurements with low voltages around 1 V 1kHz
OSC
(Figure 2) showed that the current waveform
10k

was an undistorted sinewave (Figure 3). The


strong frequency dependence could also be 200621-008

confirmed. Between 1 kHz and 10 kHz the


impedance dropped by around a factor of
Figure 4: Measuring with square-wave signals. Figure 5: The same signal waveform as with a
10. My hand with the two wire electrodes was high-pass filter.
thus behaving more or less like a capacitor.
Comparisons with different capacitors from
the parts bin showed that a 3.3 nF capacitor
showed very similar behaviour. behaves like a capacitor with a capacitance
  of a few nanofarads. In parallel there is a high
The entire measurement process can be resistance of around 1 MΩ.
simplified by using a square-wave signal
(Figure 4). For this I used the test signal from An Explanation
the oscilloscope, with an amplitude of 0.2 V The large capacitance of a several nanofar-
and a frequency of 1 kHz. This is not an AC ads with the very small contact areas of the
voltage, but instead pulsed DC. The output wires gave me the idea that what is actually
voltage is zero for 0.5 ms and then 0.2 V for formed here is a double-layer capacitor. The
0.5 ms. This signal can be regarded as a DC skin moisture produces a water film on the
voltage of 0.1 V with a superimposed square- metal surface. A double layer of polarised
wave signal having a peak amplitude of 0.1 V. water molecules is then formed on the bound-
  ary surface. This would be exactly the same
The result is the typical pulse waveform of as the operating principle of a supercapaci-
an RC high-pass filter (Figure 5). Since the tor, in which a graphite coating provides an
measuring signal has a DC component, it especially large boundary surface.
is clear that the DC conductivity is insignif-  
icant, as otherwise the output signal would be This sort of capacitor can also be formed with
noticeably offset in the pulse region. This also two copper wires in pure water (Figure 6). The Figure 6: Experimental setup for a double-layer
confirms that skin with two wire electrodes measuring circuit is still the same. To obtain capacitor.

lektor July & August 2022 101


you need more capacitance for some reason,
it’s not a problem.
 
WATER
In summary, the result is clear: the impedance
0V/0V2
of two fingers with wire contacts corresponds
to the equivalent circuit in Figure 9. The exact
1kHz result, however, can vary significantly from
OSC
one person to the next and is, of course, very
10k

strongly dependent on the contact area, the


200621-011
instantaneous skin moisture level and the
contact pressure.
 
Figure 7: The water capacitor with an applied Figure 8: Output signal of the water RC network.
square-wave signal. If we examine this capacitor in more detail,
it turns out to actually be two capacitors.
The dielectric of these capacitors is the thin
water layer between the skin and the metal
electrode. In addition there is naturally the
inner impedance of the body, for example,
10n between one finger and another. All in all, this
FINGER leads to a more extensive equivalent circuit
1M

FINGER
1k
1M

3n3 (Figure 10). The internal impedance is difficult


to determine, and for the sake of simplicity, it
10n

200621-013
is here assumed to be 1 kΩ.
 
200621-014 If you repeatedly increase the frequency,
the impedance of the skin capacitor drops
accordingly. Then the internal impedance
Figure 9: The simplified equivalent circuit. Figure 10: The more extensive equivalent circuit.
becomes more significant. I personally know
this from painful experiences in amateur radio.
If you accidentally touch the output connec-
comparable results, the wires should only be tor of a shortwave transmitter, you don’t get
ATtiny85 immersed about 1 mm into the water. an electric shock but instead a burnt finger.
B3 B4 B1   The burn effect, however, is totally different
The measurements (Figure 7 and Figure 8) from what you get from touching a hot solder-
show that the glass of water with two ing iron. There is no burn blister like you get
electrodes has more capacitance than my from a soldering iron, and it feels completely
hand. The capacitance can be calculated different. The heating clearly occurs beneath
from the waveform, but it can also be deter- the epidermis in the deeper skin tissue with
mined by comparison with other capacitors. higher conductivity, in particular where the
200621-015 The water capacitor has approximately the current density is highest.
same effect as a 47 nF film capacitor, despite
the very small surface area of the electrodes Application: Touch Sensor
Figure  11: An automatic Morse key with touch
sensors. immersed only about 1 mm into the water. If A possible application for the finger capacitor
is an automatic Morse key with touch sensors.
I used an ATtiny85 microcontroller (Figure 11)
together with two touch sensors from an
FM radio (Figure 12). In the radio the sensor
currents were amplified by transistors, which
means that the skin resistance was sensed.
This has the disadvantage that a certain
degree of soiling can lead to malfunctions.
 
An evaluation method in which the micro-
controller measures the charging time of the
Figure 12: The touch contacts. Figure 13: Signal on port B3. capacitor formed by the finger is significantly

102 July & August 2022 www.elektormagazine.com


Listing 1: Morse key.       waitms 1
      next n
'ELbug with touch sensors       waitms 100
     end if
$regfile = "attiny85.dat"    portb.3=0            ' discharge B3
$crystal = 8000000    ddrb.3 = 1
$hwstack = 8  
$swstack = 4    DDRB.4 = 0           ' B4 high impedance
$framesize = 4    Portb.4 = 1            ' pullup
dim n as byte    waitus 10
     if PINB.4 = 0 then   ' still low after 10 µs?
        portb.4 = 0
ddrB = &B00011010       ddrb.4 = 1
Portb = 0       for n = 1 to 150  ' output dash
        PortB.1 = 1
        waitms 1
Do       portb.1 = 0
   DDRB.3 = 0            ' B3 high impedance       waitms 1
   Portb.3 = 1            ' pullup       next n
   waitus 10       waitms 100
   if PINB.3 = 0 then   ' still low after 10 µs?    end if
      portb.3 = 0    portb.4=0            ' discharge B4
      ddrb.3 = 1    ddrb.4 = 1
      for n = 1 to 50    ' output dot    waitus 10
      PortB.1 = 1 Loop
      waitms 1  
      portb.1 = 0 End

more reliable (see Listing 1). For this a port


(B3, B4) is first configured as an output and Questions or Comments?
switched low to discharge the capacitor. Do you have technical questions or
Then the port is put into the high-impedance comments about this article? Email
state and the internal pull-up (approximately the author at b.kainka@t-online.de or
50 kΩ) is enabled. The sensor capacitor then contact Elektor at editor@elektor.com.
starts charging. The critical point is when the
port voltage rises above the threshold level
of around ½ VCC. For the task at hand, it is
sufficient to wait 10 µs and then read the port
state. If a low state is detected at that point,
the key is regarded as being pressed. In this RELATED PRODUCTS
case a square-wave signal as a feedback
tone is generated for the piezo loudspeaker
connected to B0. Figure 13 shows the situa- > B. Kainka, Basic Electronics for Beginners 
(Elektor 2020) (PDF, SKU 19213)
tion with a too-light touch. There the pulses
www.elektor.com/19213
rise to 4 V within 10 µs, so the key is regarded
as not pressed.
 
In the next edition of Elektor (the Summer
Circuits 2022 issue), I will show two other appli-
cation circuits: the finger capacitor and the
two-finger organ. Until then, I hope you have
a lot of fun with your own experiments!
200621-01

lektor July & August 2022 103


developer’s zone
Tips & Tricks, Best Practices and
Other Useful Information

From Life’s
Experience
No Local Business

By Ilse Joostens (Belgium)

When I was a teenager, the main


hobby electronics activity was
rebuilding audio amplifiers, audio
equipment and related disco stuff,
occasionally with the more traditional
DIY lab power and measurement
equipment. Many years later, when I took the
step into self-employment, I decided to leave the
common path and focused more on niche products
Photo: Dim Dimich / Shutterstock.

with vintage components such as nixie tube clocks


that are still immensely popular. At that time, the
product range was still quite limited with only a few
foreign resellers, and I had made up my mind to just
try to influence the entire Belgian market. Unfortunately,
not much later I realised that there seemed to be no market at
all in Belgium for this kind of more technically oriented stuff.
Before we knew it, we had grown into a micro-multinational
with customers all over the world, except in Belgium.

 
You Can Catch More Flies with Honey Than With Somewhere in 2012, when we had established an entire range of
Vinegar products using vintage technology, but we were also among the
I used to love the Piet Pienter and Bert Bibber comics. The fact that first to offer enclosures and expansion boards for the Raspberry Pi
technology plays an important role in this series by Jozef Van Hove, computer. Our website was available in both Dutch and English and
alias Pom, who in real life was a qualified engineer at Blaupunkt in sales were made through our own web shop and eBay. However, the
Germany during the Second World War, obviously contributed to this. orders from Belgium just didn’t come... It was quite a lot of work to
If I remember correctly, one of the personalities once said, “You can keep the website up to date in two languages, and after a while we
catch more flies with honey than with vinegar.” It is the real truth, with decided to stop the Dutch site without much ado.
some elementary politeness, a business-like attitude and honesty one  
can succeed in a foreign country. Since then, we have served countless foreign customers. Our products

104 July & August 2022 www.elektormagazine.com


were sold in more than 25 countries, including far-off locations such thanks to the competition, there is often nothing left than simply pay
as Australia, Hong Kong and Japan. We have gained a number of a part of the shipping costs yourself, which puts a lot of pressure
good friends and collaborations on the profit margins. When shipping
over the years. Belgium, unfortu- outside Europe, there are also
nately, was a different story, and customs formalities like the notori-
all in all, we have sold maybe 20 ous CN23 form and the so-called
times to customers in Belgium, “Commercial Invoice”. Apart from
and even then, mostly to acquain- the fact that the list of TARIC codes
tances and family. And even sometimes causes me a headache,
worse, cooperating with people it is not so bad in terms of complex-
in Belgium seems not possible at ity, but it is a lot of extra adminis-
all. We have been scratching our trative effort and time that I could
heads about this phenomenon, but have spent in a better way. On top
unfortunately, there is no obvious of that, the tax authorities rejected
explanation. Is it due to the fact international phone calls outside
that Belgium lags behind in many office hours, as they do not consider
areas compared to its neighboring them as business calls. My God, have
countries? Do Belgians think that you never heard of the existence of
their own products are less good time zones?
or more expensive than those from  
abroad? Fear of the unknown? If you want to make a profit from
Are they envious? Or is it a your activities without too much
kind of technophobia? Who hassle, some local business is
knows? Apparently, we are a good thing. In Antarctica,
not the only ones because just like in Belgium, there is
a well-known Belgian no local market, and you
chocolatier and supplier have to buy and sell every-
to the Royal Court once thing from abroad. This
mentioned this phenome- is called the South Pole
Photo: Jeremy Walter / Shutterstock.
non in an article in my favor- effect, and forget about the
ite business newspaper [1]. The North Pole, which has been melting
fact is that, since we started working with Elektor, our products have away for a while now, and you won’t survive there anyway. It is not
suddenly found their way from the Netherlands to Belgium. that bad here yet.
  220198-01
The somewhat surprised reaction of one of our few Belgian custom-
ers was also typical. He thought it was fascinating but also hard to
understand that someone here, in particular in Belgium, was develop- Questions or Comments?
ing expansion boards and enclosures for the Raspberry Pi. He didn’t Do you have any technical questions or comments prompted by this
expect this at all, wished us good luck and suggested that if we really article? Send an email to the editor of Elektor via editor@elektor.com.
wanted to move our business forward, we’d better move abroad.

The South Pole Effect


Each customer is valuable and, in principle, it should not make much
difference whether they are located in Timbuktu or just around the
corner. In practice, things are not so prosperous, especially regarding
the local mail services, customs and the tax authorities are sometimes
difficult to deal with. As soon as a national border is crossed, postal
WEB LINK
rates suddenly skyrocket. The absolute distance is less important,
and sending a small parcel a few dozen miles away to a neighboring [1] Proud Mary:
country suddenly costs almost as much as sending it to the United www.tijd.be/cultuur/gastronomie/Proud-Mary/9491697
States. Customers prefer the lowest possible shipping costs and,

lektor July & August 2022 105


review

Pokit Meter Review


A Swiss army knife of test gear

By Dr. Thomas Scherer

The Pokit Meter is a puck-sized device with extendable probes


that can function as a multimeter, oscilloscope, spectrum
analyzer or data logger and hooks up to a smart device via
Bluetooth to provide its GUI. The concept is novel, but what can
it really do and how well?

I have been looking for a fairly basic data probes in red and black are to the left
logging device for some time now. When I and right and at the top right is a tiny
read the spec for the Pokit Meter, it looked spare fuse (Figure 3). This miniscule
as if it might just fit the bill. The design looked SMD component is a spare fuse on a
rather unconventional and interesting. I didn’t tiny PCB. Some versions of the packag-
have to wait long before the small cardboard ing include a pop out section which
box (Figure 1) was sitting on my bench. holds the fuse securely and allows it
Symbols on the outside of the box (Figure 2)
indicate the functions of the device inside.
On the right in Figure 2c, you can see what’s
inside. The 48 mm diameter 18 mm thick puck
shown in Figure 1 is the Pokit meter. Gripper Figure 1: The boxed Pokit Meter.

106 July & August 2022 www.elektormagazine.com


a b c

Figure 2: On one side it says that you can measure with it, anything and anywhere (a). Another
side is bursting with features (b). The opened packaging (c) showing what’s in the box.

to be safely stowed into one of the pockets in neath the battery. A link to the manufacturer
the carry pouch. I took it out completely and or QR code would have been useful here. On
taped it to the instruction sheet to ensure it the homepage [1] of the manufacturer Pokit
doesn’t get lost. Innovations there is hardly any further infor-
mation to be found; but there is a link to a
Let’s Fire It Up forum. At least I know now that this measur-
Figure 4 shows all the items spread out on the ing device was funded through a successful
bench. A zip up carry pouch has space for the crowdfunding campaign and that I have the
Figure 3: Keep it safe. The tiny spare SMD fuse
Pokit meter, spare fuse and gripper probes. black version from a range of four coloured on its mini PCB.
The 8 x 22 cm information sheet lists the basic versions and that there will soon be a Pokit
technical information for the device and lets Pro version and a Smartwatch app.
us know that the corresponding ‘pokitMe-  
ter’ app is available to download for smart The Pokit meter’s retractable leads are termi- supplied. The leads extend (Figure 5) to a
devices running Android or iOS from the play nated in needle point probe tips which can be maximum reach between the gripper probes
or app store. It also gives battery information used directly for probing a circuit or can be of around 56 cm. The button on the bottom of
and indicates that the fuse is situated under- plugged into one of the spring loaded grippers the puck retracts the leads just like the power

Figure 4: The contents set out on the bench. Figure 5: With the two leads extended, Pokit is ready to measure.

lektor July & August 2022 107


replaced we can go to the Play Store or
App store to locate and install the ‘pokit-
Meter’ app (Figure 7) on our smart device.
Curiously the image displayed on the app
page actually shows a sample measurement
reading of ‘3.222 mV’ but the app will in fact
only display a measurement resolved to two
decimal places.
 
From now on there were no more big
a b surprises. With the app running, we can pair
with the Pokit meter and interact with it via
Figure 6: Don’t forget to remove the green waxed paper insulation (a) under the coin cell. And the Bluetooth link. The first thing I noticed
replace the coin cell (b).
was that the display remains consistently in
landscape format, no matter how you turn
the phone. That makes sense for displaying
waveforms, but for the multimeter option at
least, I would prefer portrait format; it’s easier
cord stow feature of some vacuum cleaners. to hold a phone in that orientation with one
Overall, the construction of this unit has been hand, and it’s almost universal for conven-
very well thought-out. tional multimeters.
 
According to the instruction leaflet, we need Flakiness Persists
to fit a CR2032 type lithium coin cell but mine When trying it out for the first time, it was
came with one already installed. It was just noticed that when operated as a multime-
necessary to pop it out and remove the thin ter, in some measuring ranges, neither open
green insulating disc of waxed paper under- nor short-circuited terminals produce a clear
neath the cell (Figure 6). With the battery reading of zero. Figure 8 shows the screen
for measuring alternating current where the
display is showing 60 µA with open termi-
nals. It looks like the zero adjustment is a bit
buggy when the measurement ranges are
Figure 7: The pokitMeter app, in the Apple App switched. The device does however measure
Store. Here the measured values ​​shown have other values correctly.
three decimal places.
 
Regarding the measurement properties for
this device: Pokit can record the ‘real RMS
value’ of alternating voltages and alternating
currents which is very commendable. After
comparative measurements with calibrated
multimeters, I can confirm that claim is in
fact true!
 
A bit of playing around showed that when
switching from ‘continuity test’ to another
mode, the beep tone (when the terminals were
short-circuited) was often not switched off. You
had to select the other mode a second time,
then it was quiet and everything was in perfect
order. So not a major issue, just an annoying
carelessness somewhere in the code.
Figure 8: In firmware version 1.2, the display does not go to zero for alternating current. At the top left
the warning of voltages higher than 60 V. Display error: On the right you can see the bottom edge of
 
all the scale selection labels are truncated. Autoranging is the default setting in multime-

108 July & August 2022 www.elektormagazine.com


ter mode but you can also select the measur-
ing range manually. When in oscilloscope
mode, the GUI occasionally suffers redraw
errors. The view in Figure 9 shows that the
selected time base indicator sometimes can
hardly be read. Unlike a conventional scope,
the Pokit meter oscilloscope behaves like
a single shot DSO triggered by tapping on
the white button to the right of the screen.
The trace does not free run and continuously
overwrite the screen (or scroll horizontally).
This mode of operation would be good as
an option, but it is the only option and thus
limits its usability as a scope. The more expen-
sive Pokit Pro version is still under develop- Figure 9: Display errors occasionally occur when selecting the scope time base.
ment but will be able to operate in conven-
tional scope mode. Incidentally, you can set a
cursor on the displayed waveform by tapping
it (Figure 10) and the measured amplitude is
displayed - interestingly enough, to a resolu-
tion of three decimal places. A second cursor
can also be positioned. Both should be able to
be moved horizontally with the finger on the
waveform, but I could not get that to work...
another bug?
 
At this point, an update request popped up.
Checking out my unit, I found I was using
hardware version 1.6 running firmware version
1.2. The update offered firmware version 1.5
which I accepted. After updating, the redraw
bug disappeared and the cursor could now
be moved as intended. It was reassuring to
Figure 10: Version 1.5 of the firmware allows use of the cursors.
know that software maintenance is ongoing.
The newer version didn’t cure the beeping
problem but the fault now seems to occur
less often when switching between ranges.

Measurement Accuracy and


Inconsistencies
Pokit should be able to measure voltages and
currents to an accuracy of 1% — regardless
of whether they are AC or DC levels. I can
confirm this by making comparative measure-
ments. At 1 V DC and 5 V DC the error was
≤0.2% in both cases and at 12 V DC it was
even less than 0.1%. The currents readings
also stayed at around 0.2% error. I measured
the frequency response to AC signals. In the
range up to 500 Hz, the error was less than
1%. At 5 kHz, on the other hand, it rose to
around 5%. Measurements in the upper range Figure 11: Spectrum of the mains hum picked up from my index finger. Harmonics at integer multiples
of the audio frequency band cannot really be of 50 Hz can be seen. A warning indicates a value has been clipped but where?

lektor July & August 2022 109


technical spec on the website indicates opera-
tion ‘up to 6 months’ which is most likely a
result of the 6 month maximum battery lifes-
pan. It would certainly inspire more confi-
dence if there were more consistency in the
documentation.
 
Also in the Elektor Store [2], we correctly
identify the A/D converter in the Pokit as
12 bit, the page integrated in the app under
‘TECH SPECS’ suggests it’s 14 bit — which
it definetely isn’t. This page also contains a
few other anomalies such as the data logger
sample interval is selectable in the range
Figure 12: The display of a 50 kHz sine wave is acceptable at a sample rate of 1 MS/s. The display is from ‘1 s — 1 day’ and the maximum log
switched to full screen mode so none of the controls are visible.
time is ‘1 year (at 6 hours/sample)’ — none
of which is correct. Anyway the six-month
battery life would certainly put an early halt
to proceedings.
 
The screenshot in Figure 12 shows the
waveform of a 50 kHz sine wave at the fastest
time base setting; you can see that at least
the specified sample rate of 1 MS/s is correct.
This means that the oscilloscope function is
good to display signals in the entire audio
spectrum. As a ‘real oscilloscope’ it would
need to be at least 10 times faster and have
a number of additional trigger capabilities;
with the Pokit you do have at least a mini
storage scope in your pocket and can monitor
changes in voltages or currents in the sub-HF
range far out in the field far away from any
power supply. That’s the environment in which
Figure 13: Data logger plot. Seven minutes in the life of my car battery sampled at 1-s intervals.
it really shines.
 
For the test I wanted to monitor the voltage
level of my Prius directly on the 12 V battery
  every 1 s while the car is in motion. At my
trusted, but this is not a special drawback of As I mentioned, the function of particular first attempt, Pokit was displaying incorrect
Pokit alone. You can only expect more consis- interest to me is the data logger. The hardware values (battery voltage of 7.5 V). The remedy
tant values from more professional measur- technical specification indicates that 8,000 was to cancel and start recording again. The
ing equipment beyond €1000. All in all, I was measurements can be recorded. That doesn’t second attempt was successful. The logged
quite impressed by the Pokit’s measurement sound too generous, but the measurement values are again not shown in real time. Only
accuracy. intervals can be set at: 1/2/3/4/5/10/30 s and at the end of the logging period we can see
  1/5/10 m and 1 h. Crunching the numbers, a waveform made up of the logged values.
I can accept that the device lacks many of this results in a maximum time span ranging This again is less than optimal, a real time
the features of a ‘real oscilloscope’ that could from 8,000 s = 2:13:20 h:m:s (at a one second view would be more useful.
have been implemented in software at no sample rate) up to 8,000 h orjust over 333 d  
extra cost. You can’t really expect more from (i.e., about 11 months). The Pokit paperwork Figure 13 shows car’s battery voltage level
a device in this price range. The function as suggests that the span with a 1-s interval during the seven-minute drive down a country
a spectrum analyzer (Figure 11) is also rather is shorter i.e. 103 m (= 6,180 s) and with a lane. The voltage fluctuates between 11.7 V
rudimentary and an add-on. 1-h interval only 8 months (≈ 5,850 h). The and 14.55 V. When first connecting Pokit, the

110 July & August 2022 www.elektormagazine.com


on-board voltage was exactly 12.23 V. At the For me the data logger function is ideal, and and beginners, its capabilities are so wide
beginning you can see a slight drop to 12.175 V I’m sure, as I use it more and more I will come ranging they may not need to buy any other
when getting into the car, as the hydraulic to appreiciate its other capabilities. A little measuring device at first for low voltage, low
pump kicks in to build up brake pressure; it more storage space would be good, but on frequency measurement applications.
draws up to 15 A for a few seconds when the the whole I am happy with what it can do. I 210615-01
driver’s door is opened. When starting, the don’t necessarily need higher sample rates,
voltage goes briefly below 12 V when all the as these would probably have a heavy impact
electrics are activated and then the battery on battery life. In my opinion, Pokit Innova- Questions or Comments?
receives a charge. When the battery is full, tions has done a lot of things right with the Do you have any technical questions or
charging is terminated and the battery voltage hardware, but I get the impression we are comments prompted by this article? You
drops to around 13.4 V. Even if the end-of- working with a beta version of the firmware. can email the editor at editor@elektor.
charge voltage is a bit high for my taste -   com.
the curve in Figure 13 is quite informative. Am I looking forward to the Pokit Pro version?
The logger is very well suited to reveal such Surprisingly, not so much even though it
insights and is by far accurate enough. promises real-time scope capability and
simultaneous operation of four units on one
A Handy Solution smart device. For me the concept of a discreet
With a few reservations about the GUI, I found key fob that turns your smart device into a
the Pokit Meter to be quite usable and well sophisticated piece of test equipment is very
worth the money — just under €100. Small attractive.
inconsistencies in its operation are annoying,  
but you can live with them. Version 1.5 of the I can see the Pokit Meter will find a place in
GUI is still a little flaky, but the overall concept my growing collection of test gear for use in
is good, and the company is a relatively new the lab and especially in the field. For students
upstart, so we can expect the product to
improve as more updates arrive. I can’t under-
stand why the bug with the beep has not been
resolved, at least with the Apple version of the
app; it should really have been noticed. And RELATED PRODUCTS
why is it not possible to set the oscilloscope
time base down to a minimum of 20 µs/div?
The end is there at 1 ms per screen = 200 µs/ > Pokit Meter – Portable Multimeter, Oscilloscope and Logger (SKU 19854)
www.elektor.com/19854
div. The 20 µs per horizontal division can only
be achieved by zooming out using two-fin-
gers. The hardware has the capability, but it
cannot be configured in the firmware.
 
A lot of thought has gone into the physical
layout of this unit to make it convenient to
use. Its physical size is just about on the limits
of what you would consider unobtrusive and
pocketable when attached as a fob to a set
of keys.
 

WEB LINKS
[1] Pokit Innovations website: http://www.pokitinnovations.com
[2] The Pokit Meter in the Elektor store: http://www.elektor.com/pokit-meter-portable-multimeter-oscilloscope-and-logger

lektor July & August 2022 111


store
www.elektor.com

The Elektor Store


Never expensive, always surprising
The Elektor Store has developed from the we simply want to try out. If you have a nice
community store for Elektor’s own products suggestion, we are here (sale@elektor.com).
like books, magazines, kits and modules, into Our main conditions:
a mature webshop that offers great value for never expensive, always surprising!
surprising electronics. We offer the products
that we ourselves are enthusiastic about or that

Miniware DS213 4-ch Mini Oscilloscope


(15 MHz)

Price: €249.00
Member Price: €224.10

www.elektor.com/20206

PiKVM v3 KVM over IP


for Raspberry Pi 4
(pre-assembled)

Price: €319.00
Member Price: €287.10

www.elektor.com/20199

112 July & August 2022 www.elektormagazine.com


Waveshare PicoGo Mobile Robot Ersa i-CON NANO
for Raspberry Pi Pico Soldering Station (80 W)

Price: €67.95
Member Price: €61.16 Price: €329.00
Member Price: €296.10

www.elektor.com/20196 www.elektor.com/20187

RangePi – LoRa USB Dongle


based on RP2040 (EU868)

Andonstar AD203
Handheld
Digital Microscope
with 4“ LCD Screen

Price: €54.95 Price: €69.95


Member Price: €49.46 Member Price: €62.96
www.elektor.com/20156 www.elektor.com/20146

lektor July & August 2022 113


Hexadoku
Puzzles with an Electronic Touch

Traditionally, the last page of Elektor The Hexadoku puzzle employs numbers in the hexadecimal range 0
through F. In the diagram composed of 16 × 16 boxes, enter numbers
magazine is reserved for our puzzle with an such that all hexadecimal numbers 0 through F (that’s 0-9 and A-F)
electronics slant: welcome to Hexadoku! occur once only in each row, once in each column and in each of the
Find the solution in the gray boxes, submit it 4×4 boxes (marked by the thicker black lines). A number of clues
are given in the puzzle and these determine the start situation.
to us by email, and you automatically enter
the prize draw for one of five Elektor store Correct entries received enter a prize draw. All you need to do is
vouchers. send us the numbers in the gray boxes.

SOLVE HEXADOKU AND WIN! PARTICIPATE!


Correct solutions received from the Ultimately August 15th, 2022,
entire Elektor readership automati- supply your name, street address
cally enter a prize draw for five and the solution (the numbers in
Elektor store vouchers worth €50.00 the gray boxes) by email to:
each, which should encourage all hexadoku@elektor.com
Elektor readers to participate.

PRIZE WINNERS
The solution of Hexadoku in edition 04-05/2022 (May & June) is: 0FC3D.
Solutions submitted to us before June 15th were entered in a prize draw for 5 Elektor Store Vouchers.
The winners are posted at www.elektormagazine.com/hexadoku.
Congratulations everyone!

The competition is not open to employees of Elektor International Media, its subsidiaries, licensees and/or associated publishing houses.

114 July & August 2022 www.elektormagazine.com


PROTEUS
DESIGN SUITE
Design Quality Assurance
Constraint Driven
Design
Flexible and scalable
Zone Inspector
rule system
Full support for design Analyze plane coverage and
rule rooms stitching
Manufacturing Grid view of plane
solder mask rules configurations
Live display of
Edit plane settings and
violation areas
draw order

Dedicated
Reporting
Module
Tables automatically
populate with design
Pre-Production data
Checklist
Compliance status for
diff pairs and length
Set of board tests
matched routes
before Gerber Output
Make custom
Includes placement, reports with data
connectivity and object tables
clearance testing
Generate reports
Completely independant from templates
code for clearance checks

info@labcenter.com
+44 (0)1756 753440
electronica fast
forward is back!

New Logo, New Concept

Do
you
the wa
be nt
st to
wi sta see
thi rt- the
nt up bes
he sa to
ele nd f
ctr sca
on le-
ics up
sce s
ne
th ?
b o o
s a t o
s i t u t t
Vi o g e
.
0 t e m
. 4 4 t h
B4 n ow
k

Save the date: 15th - 18th November 2022


Messe Munich - B4.440

You might also like