Aug24 Int
Aug24 Int
Electronics
The UK’s premier electronics and computing maker magazine
Circuit Surgery Teach-In 2024 Audio Out
Topics in digital signal processing Create a Wi-Fi Access Point with Mechanical
– the frequency domain the ESP32 SoC microcontroller switches in audio
WebMite
Watering
System
Controller
WIN!
Microchip
PolarFire SoC
Discovery Kit
WIN!
PLUS!
Techno Talk – That makes so much sense! Aug 2024 £5.99
08
Cool Beans – DIY logic probes
Net Work – Passkeys and online security 9 772632 573030
The PIC32CK SG MCU family combines the security of a fully isolated Hardware Security Module with
Arm’s TrustZone® secure partitioning. This provides defense in depth against cyber-attacks for the most
demanding applications.
Designed as a mid-range MCU, the PIC32CK SG MCU integrates advanced hardware security subsystems to
surpass regulatory requirements effortlessly. With a high level of cyber protection integrated, designers can
ensure their products meet and exceed cybersecurity mandates without sacrificing efficiency or speed.
Key Features
• Based on Cortex-M33 at 120 MHz
• 2 MB Dual Panel Flash/512 KB RAM for complex system
• 10/100 Ethernet, USB, CAN-FD, I2S, I2C
• Advanced key management
• Certificate authority
• Secure boot
Electronics Contents
Projects and Circuits
LC and ESR Meter by Steve Matthysen 16
This enhancement to our Wide-Range Digital LC Meter (June 2019) adds capacitor
ESR measurement – useful for diagnosing faulty equipment because increasing ESR
over time is one of the most common ways electrolytic capacitors fail.
WebMite by Geoff Graham with firmware by Peter Mather 28
What happens when the PicoMite meets the web? Find out with this powerful project
that combines a Raspberry Pi Pico with MMBasic, Wi-Fi and Internet connectivity.
We put it to good use in this month’s Watering System Controller
WebMite-based Watering System Controller by Geoff Graham 34
This advanced Watering System Controller does it all. It can change the watering
schedule depending on the seasons, check the weather forecast before watering and
alert you to a burst pipe or blocked sprinkler. Best of all, it’s easy to set up and use.
The Wireless for the Warrior books are a the introduction of VHF FM and
source of reference for the history and hermetically sealed equipment.
development of radio communication
equipment used by the British Army Volume 3 covers army receivers from
from the very early days of wireless up 1932 to the late 1960s. The book not
to the 1960s. only describes receivers specifically
designed for the British Army, but also
The books are very detailed and include the Royal Navy and RAF. Also covered:
circuit diagrams, technical specifications special receivers, direction finding
and alignment data, technical receivers, Canadian and Australian
development history, complete station Army receivers, commercial receivers
lists and vehicle fitting instructions. adopted by the Army, and Army Welfare
broadcast receivers.
Volume 1 and Volume 2 cover
transmitters and transceivers used Volume 4 covers clandestine, agent or ‘spy’
between 1932-1948. An era that starts radio equipment, sets which were used by
with positive steps taken to formulate special forces, partisans, resistance, ‘stay
and develop a new series of wireless sets behind’ organisations, Australian Coast
that offered great improvements over Watchers and the diplomatic service. Plus,
obsolete World War I pattern equipment. selected associated power sources, RDF and
The other end of this timeframe saw intercept receivers, bugs and radar beacons.
01202 087631
Circuit Surgery Teach-In 2024 Audio Out Circuit Surgery Teach-In 2024 Audio Out Circuit Surgery Teach-In 2024 Audio Out Circuit Surgery Teach-In 2024 Audio Out Circuit Surgery Teach-In 2024 Audio Out
LTspice 24 update and Digital input and output with Designing Topics in digital signal Analogue input and output with Designing Topics in digital signal Using LED displays with the ESP32 Mechanical Topics in digital signal processing Sensing the environment with Mechanical Topics in digital signal processing Create a Wi-Fi Access Point with Mechanical
Frequency Response Analysis the ESP32 SoC microcontroller discrete buffers processing – sampling the ESP32 SoC microcontroller discrete buffers processing – ADCs SoC microcontroller switches in audio – sample and hold the ESP32 SoC microcontroller switches in audio – the frequency domain the ESP32 SoC microcontroller switches in audio
WebMite
WIN!
Microchip Watering
Curiosity HPC
Development
Loudspeaker System
Board Make your Controller
WIN! Test Jig own Dynamic
RFID tags WIN!
‘Swiss Army Knife’ Dual RF Amplifier Microchip
GPS-Disciplined Heart Rate PolarFire SoC
Basic RF Automated Test Bench Oscillator Reciprocal
Discovery Kit
Sensor Module WIN!
Signal Mastering Frequency Counter
Generator WIN!
the UVM-30A
Microchip
Explorer 8 Wi-Fi Time Source Teach-In 2024
Development UV Sensor for GPS Clocks Arduino-based
Kit
WIN! Learn to use L/C+ESR Meter
Teach-In 2024 the ESP32
Teach-In 2024 Learn to use
Teach-In 2024 Teach-In 2024 the ESP32
Learn to use Silicon Chirp Learn to use Learn to use WebMite: PicoMite
the ESP32 Build your own the ESP32 the ESP32 meets the Web
Songbird: an ideal
pet cricket beginner’s project Pi Pico-based
Thermal Camera
PLUS! PLUS! PLUS! PLUS! PLUS!
Techno Talk – Wait! What? Really? Apr 2024 £5.99 May 2024 £5.99 Jun 2024 £5.99 Jul 2024 £5.99 Aug 2024 £5.99
04 Techno Talk – One step closer to a dystopian abyss? 05
Techno Talk – Program that! 06
Techno Talk – Who saw that coming? 07
Techno Talk – That makes so much sense! 08
Cool Beans – Arduino: expanding the 7-segment display Cool Beans – Arduino: 7-segment display delights Cool Beans – Arduino: 7-segment display delights Cool Beans – Arduino: 7-segment display decoders Cool Beans – DIY logic probes
Net Work – Label printers, smart home devices and SMRs 9 772632 573030
Net Work – Electric cars, Moon-shot missions and more 9 772632 573030
Net Work – GaN USB chargers, solid-state EV battery 9 772632 573030
Net Work – Practical advice on electronics repairs 9 772632 573030
Net Work – Passkeys and online security 9 772632 573030
www.electronpublishing.com @practicalelec practicalelectronics www.electronpublishing.com @practicalelec practicalelectronics www.electronpublishing.com @practicalelec practicalelectronics www.electronpublishing.com @practicalelec practicalelectronics www.electronpublishing.com @practicalelec practicalelectronics
Take out a one-year subscription and save more than £10 over the year.
Even better – save over £1 per issue if you subscribe for two years – a total saving of £26.
Electronics
Rest of the World £46.99 (Airmail)
1 Year: UK £59.99, Europe £69.99 (Airmail),
Rest of the World £84.99 (Airmail)
Subscriptions start with the next available issue. We accept Card Ex. Date ......................................
MasterCard or Visa.
Name ............................................................................................
(For past issues see the Back Issues page.)
Address ........................................................................................
9 771030 266001
$1150* NZ $1290
05
INC GST
INC GST
Australia’s
International Airsho
All the newest tech
in Avalon Airpor
w
t
• Combined subscriptions include both the printed magazine and online access.
Wideband
• Prices are in Australian dollars (AUD) unless otherwise specified. Fuel Mixture Display;
• Prices listed are for everywhere in the world except Australia and New Zealand. April to June 2023
View siliconchip.com.au/Shop/SubRates for a full list of current prices.
• Price estimates are just that and should only be used as a guide, we primarily
take payment in the form of Australian dollars.
Silicon Chirp;
April 2023
Try our Online Subscription – now with PDF downloads!
An online issue is perfect for those who don’t want too much Advanced SMD
clutter around the house and is the same price worldwide. Test Tweezers;
Issues can be viewed online, or downloaded as a PDF. February & March 2023
Electronics Editorial
Editorial offices
Practical Electronics Tel 01273 777619 Exciting News!
Electron Publishing Limited Mob 07973 518682 Change is in the air. Practical Electronics is the world’s longest-
1 Buckingham Road Fax 01202 843233
Brighton Email [email protected] running hobby electronics magazine. Our first issue came out in
East Sussex BN1 3RA Web www.electronpublishing.com November 1964 when commercial transistors had been available
Advertisement offices
for less than a decade and ICs were only just beginning to appear
Practical Electronics Adverts Tel 01273 777619 – at eye-watering prices that only NASA could afford. Many fine
1 Buckingham Road Mob 07973 518682 magazines have appeared (and sadly disappeared) in the last 60
Brighton Email [email protected]
East Sussex BN1 3RA years, but PE has endured and thrived. I’m sure that one of the
main reasons PE has survived is the quality of its content – thanks
Editor Matt Pulzer
General Manager Louisa Pulzer
to the very hard work of all who write and work for the magazine.
Digital subscriptions Stewart Kearn Tel 01202 880299 But there is another reason – we’ve never been afraid to change,
Online Editor Alan Winstanley
Web Systems Kris Thain
and now it’s time for a new chapter in PE’s long-running story. We
Publisher Matt Pulzer are joining the Silicon Chip publishing stable.
Print subscriptions
Practical Electronics Subscriptions
What does this mean for Practical Electronics?
PO Box 6337 Silicon Chip is an Australian magazine with which we have
Bournemouth BH1 9EH Tel 01202 087631 shared content since the beginning of 2008. They have provided
United Kingdom Email [email protected]
sophisticated projects of the highest quality and it’s been a
Technical enquiries very successful relationship. So successful in fact, that when
We regret technical enquiries cannot be answered over the
telephone. We are unable to offer any advice on the use, purchase,
I mentioned to its editor/publisher Nicholas Vinen that I was
repair or modification of commercial equipment or the incorporation thinking of retiring we decided to work out a way to ensure PE
or modification of designs published in the magazine. We cannot wouldn’t retire with me.
provide data or answer queries on articles or projects that are
more than five years old.
So, the big question is where does PE go from here? The short
Questions about articles or projects should be sent to the editor
by email: [email protected]
answer is most things will stay exactly as they are. All of PE’s
authors will continue to contribute exactly as they do now. Nicholas
Projects and circuits is absolutely clear that PE must not become a ‘Silicon Chip light’,
All reasonable precautions are taken to ensure that the advice and
data given to readers is reliable. We cannot, however, guarantee that would be pointless. If anything, the magazine will get better –
it and we cannot accept legal responsibility for it. Nicholas intends to up the pagination which means more pages and
A number of projects and circuits published in Practical Electronics
more content, all of which will benefit you the reader.
employ voltages that can be lethal. You should not build, test,
modify or renovate any item of mains-powered equipment unless Thank you
you fully understand the safety aspects involved and you use an
RCD (GFCI) adaptor. I first started working on PE nearly 30 years ago with a small job
producing its circuit diagrams. In 2008 Mike Kenward, the editor/
Component supplies publisher asked me if I’d consider becoming PE’s editor. I jumped
We do not supply electronic components or kits for building the
projects featured, these can be supplied by advertisers. We at the opportunity, and it’s been an exciting and rewarding role.
advise readers to check that all parts are still available before Then, at the start of 2019 I became publisher, just in time to catch
commencing any project in a back-dated issue.
the full brunt of the pandemic, but we survived!
Advertisements
Although the proprietors and staff of Practical Electronics take Throughout my time with PE I have had fantastic support from
reasonable precautions to protect the interests of readers by
ensuring as far as practicable that advertisements are bona fide, our many talented contributors – PE is nothing without its creative
the magazine and its publishers cannot give any undertakings scribes – thank you one and all; in no particular order: Alan
in respect of statements or claims made by advertisers, whether
these advertisements are printed as part of the magazine, or in Winstanley, Jake Rothman, Ian Bell, Clive ‘Max’ Maxfield, Mike
inserts. The Publishers regret that under no circumstances will Tooley, Julian Edgar, Mike Hibbett, Phil Boyce, Mark Nelson,
the magazine accept liability for non-receipt of goods ordered, or
for late delivery, or for faults in manufacture.
Barry Fox, Stewart Kearn, Kris Thain, the late John Becker, Mike
Kenward… and to anyone I’ve left off this list, apologies! Last, but
Transmitters/bugs/telephone equipment by no means least, thank you to all our many loyal readers and
We advise readers that certain items of radio transmitting and
telephone equipment which may be advertised in our pages
subscribers. You’ve kept us going and I’m sure your continued
cannot be legally used in the UK. Readers should check the law support will enable Nicholas to carry on bringing you the very best
before buying any transmitting or telephone equipment, as a fine,
in electronics publishing over the coming years.
confiscation of equipment and/or imprisonment can result from
illegal use or ownership. The laws vary from country to country;
readers should check local laws. Matt Pulzer
Publisher
I’m always amazed by the cunning creations of the pioneers of yesteryear, especially when I consider
the rudimentary sensors they had at their disposal. I often wonder what their reactions would be to
see the sophisticated sensors we have available to us today.
A
s usual, my poor old noggin a series of 20-minute movies, and later modulated continuous wave (FMCW)
is full of random thoughts bounc- shown in the 1950s and 1960s on TV. approach that can provide distance and
ing around like super balls on Buck sported a ray gun in the form velocity data on a pixel-by-pixel basis,
steroids. The topic that has currently of a ‘U-235 Atomic Pistol’. The reason I allowing them to perceive and identify
captured my attention is that of sensors. mention all this is that the first practical objects more than a kilometer away.
What pops into your mind when you photoelectric cells were invented in the Meanwhile, companies like Owl
hear (or see) the word ‘sensor’? Living 1880s. In 1955, Zenith introduced the Autonomous Imaging are creating long-
in an age of wonders as we do, you may world’s first wireless television remote wave infrared (LWIR) thermal focal plane
be thinking of highfalutin’ devices like control called the Flash-Matic. Looking arrays (thermal imagers). The signals
lidar (laser detection and ranging) or like something Buck Rogers would not from these images can be employed by
radar (radio detecting and ranging) . be ashamed to be seen carrying, this glo- AI to perform object detection, classifi-
When we boil things down, however, a rified torch (flashlight) employed a beam cation and ranging. As the folks at Owl
sensor is any device that detects some of light to activate four photocells locat- told me, ‘Within five years, all new cars
physical phenomenon and produces a ed at the corners of the screen, thereby will be able to see at night!’
corresponding output signal. allowing the user to control the volume
For our purposes here, we will as- and channel selection. That’s deep!
sume electrical output signals in terms Have you ever thought about our amaz-
of voltage or current being used to feed Mobile sensor platforms ing ability to perceive the world around
electrical or electronic systems, but this Do you remember the artificial intelli- us in three dimensions? Powered by our
isn’t cast in stone. gence (AI) called KITT (Knight Industries optical sensors (eyes) and associated com-
Two Thousand) powering the highly ad- puters (brains), we call this ability ‘depth
Victorian fax machines vanced, very mobile, robotic automobile perception.’ There are many aspects to
Can you imagine the Victorians sending in the Knight Rider TV series of the 1980s? this, but we start with the fact that each
faxes to each other? This may seem far- Today’s cars are getting close to (some- of our eyes sees a slightly different im-
fetched, but in 1842, a Scottish engineer times they surpass) KITT’s capabilities. age due to their separation in our heads.
and inventor called Alexander Bain came My own 2019 Subaru Crosstrek is The resulting disparities are processed
up with a cunning idea. He created an equipped with binocular vision that can in the visual cortex of our brains to yield
image to be transmitted by cutting it out be used to detect and correct any drifting depth information.
of a thin sheet of tin. He placed this metal out of lane, vary the speed of the cruise Even with one eye closed, we can still
image on a movable insulated base and control if we get too close to a car in front, do things like track and catch a ball head-
connected it to one side of a battery. The and slam on the breaks if it feels we are ing our way. In this case, our brains make
base was slowly passed under a swing- in danger of imminent collision. All of use of visual cues, including knowing
ing pendulum formed from a conducting this is made even more exciting by my how big we expect objects to be, and our
wire with a weighted point on the end. wife screaming in my ear. understanding that if an object appears
Whenever this point connected with the In fact, today’s autonomous cars and to be growing bigger, then this may be a
metal image, it completed the electrical robots are essentially mobile sensor and good time to duck.
circuit, thereby converting the dark and computing platforms. A very common In the case of machine vision, one of
light areas of the image – which were scenario is to have multiple cameras the components of depth perception
represented by the presence or absence equipped with CMOS sensor arrays that is the ability to create a 3D depth map
of tin – into an electrical signal. are sensitive to light in the visible part (point cloud) of the scene. We can do
This cunning creator used this electri- of the spectrum. These feed advanced this using two CMOS sensors to pro-
cal signal to activate a relay attached to processors running AI algorithms that vide binocular vision, but that increases
the end of another pendulum that was can perform tasks like object detection the cost. We can employ a single CMOS
swinging back and forth over a second and recognition. sensor in conjunction with an AI, us-
moving bed. The activated relay caused These cameras can be augmented by ing its understanding of the scene to
an attached pencil to encounter a piece of lidar and radar sensors. The original li- determine where and how big things
paper laying on the moving bed, thereby dars were big, bulky, and expensive, are in 3D space, but this requires a lot
reproducing the original image in metal but new versions are coming online in of computation.
as a drawing in pencil. which almost everything is implemented The folks at a company called AIRY3D
in semiconductor form. As opposed to have come up with a way to use a single
Ray guns and TV controllers a simple time-of-flight (TOF) approach CMOS sensor to generate both a regu-
Did you ever see the original Buck Rogers which involves generating powerful puls- lar 2D image and a 3D point cloud on a
science fiction serial from 1939 starring es of light and measuring the round-trip pixel-by-pixel basis with very little com-
Buster Crabbe? Filmed in glorious black- time of any reflections, companies like putation. I don’t know about you, but
and-white, this was originally released as SiLC Technologies are using a frequency I certainly didn’t see this one coming!
The PolarFire SoC Discovery Kit features a quad- The board includes support for Microchip’s Mi-V
core, RISC-V application-class processor that
supports Linux and real-time applications, a Worth ecosystem, a MikroBUS expansion header
for Click Boards and a 40-pin Raspberry Pi
rich set of peripherals and 95K of low-power,
high-performance FPGA logic elements. This
$132.00 connector, as well as a MIPI video connector.
The expansion boards can be controlled
fully featured, yet low-cost kit allows the rapid (approx £104.50) using protocols like I2C and SPI. One
testing of application concepts, development
of firmware applications, programming and
each GB of DDR4 memory is available, as well
as a microSD card slot for booting Linux.
debugging of user code. Communication interfaces include one Gigabit
Ethernet connector and three UART connections
The Discovery Kit is built around the PolarFire via the USB type C connector. An on-board FlashPro5
MPFS095T SoC FPGA that features an embedded programmer is available to program and debug the PolarFIre
microprocessor subsystem consisting of a quad-core, 64-bit FPGA through a USB-to-JTAG channel.
Free-to-enter competition
Microchip Microchip
Win a Microchip MPFS-DISCO-KIT
PolarFire SoC
Discovery Kit
E
very web user will recognise liable to forget where you last left your Common Captcha screens ask ‘how many
the annoying requirement to password book, they’re not a good idea. traffic lights’ or ‘what is four times two’, or
log into any website that retains A limited choice of online password they may ask users to drag a jigsaw puzzle
a user’s personal details. Even trivial managers is available that automates the piece into position, but advanced hacking
online transactions usually involve task of logging in or filling in online forms. can nevertheless still defeat some of them.
inputting our name, address, mobile In the author’s case, having accumulated Admittedly, even I struggle to make sense
number and email address. Some even over 400 different logins over time, online of some Captcha screens, but, sadly, the
impertinently ask for our date of birth, security has been managed for 15 years ones who struggle most with this hurdle
or they might offer to remember debit with Roboform password management are those with vision problems who rely
and credit card numbers as well, an software. Roboform has been established on screen reader software to surf the web.
offer I never accept! 25 years and is something of an unsung Web page screens that say ‘I am not a
Much has been written about the need hero in my opinion, as without it, life at a robot’ might seem deceptively simple or
to use a mix of special characters that busy desk would soon grind to a halt; it’s pointless, but they’re designed to be screen-
makes passwords harder to guess. The one of the very few online services that reader friendly, and Google’s reCAPTCHA
old idea of substituting alpha characters I’m happy to invest time and money in, v3 doesn’t need a challenge at all.
with numbers (called ‘leetspeak’) such and it also works across mobile devices. Another log-in annoyance is the
as p455w0rd has fallen out of fashion, It’s a powerful programme with many cookie opt-out screen, necessitated
and probably the best practical advice features and a few quirks, and you soon by the European GDPR and ePrivacy
is to use a ‘passphrase’ of several words wonder how you managed without it. Directive. Cookie screens have spread
and maybe a special character at the end, Another popular password manager is like a rash across the web, and seem
such as: bread-coffee-7281#. A longer LastPass, a product that has suffered at intended to punish website visitors
string of random words makes passphrases least two security breaches in the recent seeking to safeguard their own privacy.
even harder to guess, for example: past. The Tech Republic website doesn’t Standardised cookie modules are often
tulip.sugar.lawn.yoyo. recommend LastPass for that
To help users to memorise their reason alone, and tech website
passwords, I’ve noticed how special The Verge reckons LastPass
notebooks are sold, helpfully labelled may ‘have a lot of work to do
‘Password Book’ or similar, which would if it wants people to trust it
undoubtedly be goldmines in the wrong again’. LastPass is striving hard
hands. Recording logins and PINs openly to restore credibility and has
in clear print this way would also breach now implemented a minimum
the terms and conditions of banks and standard of 12-character
credit card providers, rendering the passwords. Others to try
account holder entirely liable for any include highly-rated NordPass
losses caused by fraud. If you can’t (https://nordpass.com) and
remember logins, and you’re maybe 1Password (https://1password.
com). Obviously, you must also
safeguard access to your PC and
any password manager software
as well, so explore those security
options carefully.
Crumbling cookies
During the log-in process,
users are often interrupted by a
‘Captcha’ screen, which aims to
prevent automated scanning or
hacking of a website by ‘bots. A
Captcha (Completely Automated
P u b l i c Tu r i n g t e s t t o t e l l
Computers and Humans Apart)
‘challenge-response’ causes a
user to physically respond to a
This Captcha screen uses a sliding jigsaw question, supposedly proving Some cookie opt-out screens make it onerous for users
puzzle piece to confirm you’re really human. that a real human is logging in. wanting to opt out of receiving unwanted cookies.
new
sizes!
1554/1554F
Polycarbonate IP68
Learn more:
www.hammondmfg.com/1554
[email protected] • 01256 812812
or ‘tokens’ such as the USB security – One-Time Passwords (OTPs) – sent by old phone, after which the process of
keys produced by Sweden’s Yubico. financial institutions or service providers. copying contacts, mail, apps and media
These are used by all Google’s staff and Just to reiterate a vital point: OTPs that – including all those photos and videos –
contractors for secure computer and you receive should never be given out started automatically. This can be handled
server logins, Yubico says. I covered to anyone else, as they may well be over Wi-Fi or via USB. Note that iOS as
Yubico’s secure keys in the June 2020 fraudsters looking to steal from you. If well as Android are supported. Happily,
issue of Net Work and more details of you unexpectedly receive an OTP, it may
these hardware devices are online at: be a sign of fraudulent activity taking
www.yubico.com place, so be on your guard and investigate
The author’s Facebook account is if necessary. An authenticator app on a
secured with a Yubico USB security smartphone can also be used to generate
key which, as an ID confirmation check, a code number as part of the 2FA process
needs a simple touch-tap to prove that – both Google and Microsoft offer them.
I’m physically present when logging in. In the past few weeks, I finally upgraded
Other higher-security types have a proper my Huawei P20 smartphone as it was
biometric fingerprint reader built in, but showing its age and was starting to buckle
they become pricey – around €95, exc. tax. under the workload. It must be said that
Yubico keys are available in USB-A and the Huawei has proved faultless, and it
USB-C styles, and a tiny ‘Nano’ version was generally a pleasure to use, but US
is designed to reside in the port. sanctions against the brand effectively
The buzzword here is ‘FIDO killed off the UK market, and so the next
authentication’ which is a powerful task was to transfer its contents to a new
encryption protocol at the heart of Yubico Samsung Galaxy 5G. I’ll summarise my
secure keys. You can learn more about experience of upgrading a phone, with
FIDO at: https://bit.ly/pe-aug24-fido and hints and tips that I hope will help readers
a catalogue of products and services that to prepare for the same eventuality.
are ‘Yubico-aware’ is at: https://bit.ly/ Although I rather dreaded the task, in
pe-aug24-yub reality, the job of moving everything over
Over time, I expect to see more acceptance to a new phone went exceptionally well.
of hardware tokens like these as online For good measure, a cloud backup of my
security becomes ever more challenging. thousands of photos and video files is
offered by Huawei and is still available
Time to swap phones for as long as I pay the negligible annual
Like many people, the writer has come running cost. Huawei has kept its side of
to rely on a smartphone for helping with the bargain, and the cloud backup works
many everyday tasks or keeping track of efficiently, so I downloaded the cloud
communications. In some applications backup onto my PC as an extra measure.
they are virtually indispensable: I wish
it wasn’t always the case, but services Switch it up
including routine banking, shopping On powering up the new phone, a setup
or even buying a parking ticket now routine asks whether you want to transfer
The Samsung Switch app worked
use apps and, at the very minimum, data to it from another device, and flawlessly when transferring data and
consumers are often expected to have a Samsung’s Switch app is duly installed. apps from an old mobile phone to a new
mobile phone to receive security codes The same app is also needed on the Samsung smartphone.
Terrington
Components
• Project boxes designed and manufactured in the UK.
• Many of our enclosures used on former Maplin projects.
• Unique designs and sizes, including square, long and deep
variaaons of our screwed lid enclosures.
• Sub-miniature sizes down to 23mm x 16mm, ideal for
IoT devices.
MADE IN BRITAIN
Sysblocks
www.flowcode.co.uk
T
im Blythman presented an
Steve Matthysen’s Arduino-Based LC Meter with excellent per-
formance, range and accuracy
Revised design
In this design we feed signals into
an Arduino Uno driving an LCD. The
benefit of doing this is that the ESR
front end can be built on a relatively
small circuit board and integrated
with the LC meter presented in the
June 2019 issue. That makes it a great
general-purpose instrument that can
Circuit details
Fig.2 shows the circuit diagram of
the original LC meter (on the left)
with the ESR add-on on the right.
However, note that some extra com-
Fig.1: S1 repeatedly discharges and then briefly applies current to the DUT. ponents are shown on the left, such
The pulses are too short to charge the capacitor, so the resulting voltage is as mode switch S1 and ESR input
proportional to the ESR. The pulse amplifier then feeds an amplified version
protection diodes D5 & D6.
to the comparator, along with a linear ramp, and by counting the number of
output pulses, we can accurately determine the ESR. While only one connection is
shown passing between them – the
500mV, so D1 and D4 have minimal the 270nF capacitor discharged in Integration with the LC meter
effect on the pulse voltage. the absence of a pulse. The LC meter used the Arduino’s ana-
log comparator inputs (D6 and D7)
Pulse amplifier Voltage ramp generator as digital outputs to drive the coils
The pulse voltage developed across PNP transistors Q7 and Q9 operate of relays RLY1 and RLY2. It was nec-
the capacitor being tested is fed to as a current mirror circuit to charge essary to move those functions to D3
the pulse amplifier via a 33nF capac- the 470nF ramp capacitor at a con- and D4 (by modifying the LC Meter
itor and a 1kW series capacitor. The stant rate. When the Arduino pulls code) to allow the ESR function to use
pulse is amplified by a two-stage pin 4 of CON6 low, Q9 switches on, the comparator. The larger, combined
transistor amplifier formed by Q5 causing about 9.4µA to flow through PCB design includes this rerouting.
and Q6. The ratio of the 6.8kW feed- the 470kW resistor. At the same time, At the same time, D3 and D4 are
back capacitor to the 150W fixed Q8 switches off, allowing the ramp shared with the ESR meter as digi-
resistor and VR1 (adjusted for about capacitor to charge. Q7 mirrors the tal I/Os via the selector switch, S1,
200W) sets the gain to 20 (1 + 6.8kW current through Q9, so the capacitor that chooses between the LC and ESR
÷ [150W + 200W]). begins to charge from 0V at 9.4µA. modes. This was necessary since
Diodes D2 and D3 protect Q5 if a The rising voltage across the there were insufficient spare I/Os
charged capacitor is connected to 470nF capacitor is connected to the available on the Uno. As the origi-
the test leads. Arduino Uno’s internal comparator nal LC Meter shield lacks CON5, the
The amplified pulse voltage goes (inverting input) via pin 1 of CON6. wires from CON6 go to the Arduino/
to the non-inverting input of the The Arduino Uno disables the ramp switch pins on my prototype.
Arduino Uno’s comparator via a generator by setting pin 4 of CON6
270nF capacitor, which blocks the high, turning off the charging via C9 Additional input protection
DC voltage across the 680W resistor while switching on Q8 to discharge If the ESR meter were accidentally
at Q6’s collector. This resistor keeps the ramp capacitor. connected to a charged capacitor,
range changes made during a mea- Combined LC / ESR Meter which mode has been selected to the
surement. Note that the accumu- When the LC Meter and ESR Meter Uno via its digital input D2. With D2
lated count includes the effects of are combined, a contact on the LC/ low, it is in ESR mode. Switching
test lead resistances. ESR selector switch, S1, signals from one mode to the other happens
What is a normal ESR value? sheet for the RubyCon YXF series generalised expected readings, so
Electrolytic capacitors include reac- for similar capacitance and voltage manufacturer data sheets should
tive elements, so the ESR value will ranges lists the maximum expected be used as a reference. However,
change depending on the frequency ESR values to be between 0.025W it should be apparent that a capac-
of the applied voltage (there is also an and 1.3W. itor is faulty if the measured ESR
equivalent series inductance or ESL). Table 1 below shows tabulated value exceeds tens or even hun-
Temperature changes also affect the typical ESR values. These are dreds of ohms!
reading, as do different manufactur-
ing processes. Manufacturer data Table 1: typical ESR readings for good capacitors A version
sheets typically give the expected of Table 1
ESR values at 20°C and 100Hz, 120Hz 10V 16V 25V 35V 63V 160V 250V that can be
or 100kHz, although many do not 1μF downloaded
5 4 6 10 20
include such information (or give it as a PDF.
differently, eg as a dissipation factor). 2.2μF 2.5 3 4 9 14
Thus, providing definitive expected 4.7μF 6 3 2 6 5
ESR values for all electrolytic capac-
itors is impossible. Still, we do not 10μF 1.6 1.5 1.7 2 3 6
expect to see the values exceeding
22μF 3 0.8 2 1 0.8 1.6 3
several ohms, and higher-value capac-
itors should generally have lower ESR 47μF 1 2 1 1 0.6 1 2
values. Capacitors designed for
use in switch-mode supplies (often 100μF 0.6 0.9 0.5 0.5 0.3 0.5 1
labelled “Low ESR”) should have val- 220μF
ues of a fraction of an ohm or less. 0.3 0.4 0.4 0.2 0.15 0.25 0.5
For example, the data sheet for the 470μF 0.15 0.2 0.25 0.1 0.1 0.2 0.3
Panasonic FM-A series of aluminium
capacitors gives values from 0.012W 1000μF 0.1 0.1 0.1 0.04 0.04 0.15
to 0.34W ohms varying with the volt- 4700μF 0.06 0.05 0.05 0.05 0.05
age rating (6.3V to 50V) and capac-
itance (22μF to 6800μF). The data 10mF 0.04 0.03 0.03 0.03
Case selection
The case used for the prototype is
available from Mouser Electron-
ics (563-HH-3421) or Digi-Key
(HH-3421-ND), although stocks are
limited. An optional tilt stand is
available separately from Digi-Key
(377-1171-ND).
Because the combined board is
considerably narrower than the ESR-
only board, it should fit in that case.
With an internal depth of 37mm
(excluding things like mounting
bushes, which could be removed),
the Arduino and control board stack
should fit, as should mode switch
S1, but it will be a bit of a squeeze.
Alternatively, you could use just
about any rectangular case. It would
need to be at least 175mm tall inter-
nally for a 20×4 LCD module to fit at
the top with the combined control
PCB and Arduino below it. The LCD
will be around 87mm wide, defining
the minimum internal width, while
a depth of at least 30mm is required
to fit the Arduino Uno, the shield on
top of it, and the body of switch S1.
Fig.3: this is the wiring needed to add the ESR feature to the existing LC
Meter design by simply adding another small board (at the bottom). We think The Altronics H0401 sloped case
most constructors will prefer the much easier method of building the single specified in the parts list should
combined PCB! have plenty of room. Because of the
Construction
First, you need to decide if you will
build the original LC Meter design
and wiring in the add-on ESR mod-
ule or the combined PCB. We reckon
the latter is a lot simpler.
Fig.3 shows the wiring required Fig.4: the combined PCB
with separate boards, while Fig.4 is basically the LC Meter
shows the combined PCB. For the shield (top section) with
combined version, the only part you the ESR circuitry added
need to add externally to Fig.4 is the below. Toggle switch
S1 selects between the
LCD screen, via CON4. two functions. Some
If you want to build the add-on extra mounting holes
board, it is shown in Fig.5, while the have been added to
LC Meter board, without the sockets increase mounting
(as we’re using off-board sockets), is flexibility, although they
shown in Fig.6. We’ll describe the unfortunately are not in a
assembly process for the combined rectangle.
board; the two smaller boards are
similar, you just need to skip the
parts that are not onboard.
The combined PCB measures 64.5
× 115.5mm, is coded 04106182 and
is available from the PE PCB Service.
It’s essentially a larger-than-normal by trimpot VR1 (ideally a multi-turn be printed on them, possibly as codes
Arduino shield. type, although universal pads are like 102 = 1nF, 104 = 100nF etc) and
Fit the resistors first, checking provided) and pushbutton switch S2. then the electrolytics. The latter are
their values with a multimeter as Follow with the transistors. There polarised, so insert the longer posi-
you install each one. Follow with the are nine, of four different types, so tive leads into the pads marked + (the
smaller diodes (1N4148 & 1N4004), make sure to get the right types in striped side is negative). Remember
taking care to check their orienta- each position and orientate them as that the 47µF non-polarised type
tions; face the cathode stripes as shown. Bend their leads with small goes at lower left. If you’re unsure
shown in Fig.4. pliers if necessary to fit the pads. about the values, check each com-
Next, mount IC1 (which can be The next job is to install the capac- ponent with a multimeter.
soldered to the board or socketed, itors, starting with the non-polarised Now is a good time to fit the bulk-
but watch its orientation), followed MKTs/ceramics (the values should ier components like the reed relays
Figs.5 & 6: if you want to build the separate ESR board (left), either to use it as a standalone ESR meter or to add to
an existing LC Meter (right), here is where all the components go. Besides the 10-way ribbon cable from CON6 (which
could be left off & the ribbon cable soldered to the PCB), you also need to wire up the COM− and ESR+ test terminals.
Testing
Make a final inspection of the sol-
dering to ensure there are no solder
bridges between tracks and that all
the components are in their correct
position and correctly orientated.
If you have built the separate
ESR board, you can do some test-
ing before you wire it up. Connect
pin 5 of CON6 to a +5V supply with
pin 8 at 0V.
Measure the current draw, which
should be about 1mA. If the cur-
rent is significantly higher (or zero),
disconnect the supply and look for
assembly errors.
When plugging the shield into
the Arduino, we recommend that
you use 12mm tapped spacers and
short machine screws to hold the
two boards together due to the fact
the headers won’t plug fully into
the sockets. Attach the four spac-
ers to the mounting holes on the
Arduno, but only one needs to be
screwed in through the shield to
hold it down. The rest just set it at
the correct height.
If there is a solder joint touch-
ing the top of the USB socket that
prevents you from tightening the
screws, you should trim it flush to
the extent possible.
Wiring
If you are building the combined
PCB, there isn’t much to the wiring.
You just need to make up a 4-way
When the Meter is switched to ESR mode, a splash screen is briefly displayed cable to go from CON4 to the I2C LCD
showing the ‘Zero value’, which is effectively the offset due to the resistance of header. Make sure the connections
the leads and anything else that might be in the measuring circuit. are made per the labelling on the two
LCD adjustment
If the LCD backlight is not lit, check
that the backlight jumper is fitted on Fig.7: while not recommended for the combined PCB, here is how the separate
PCBs were mounted on an acrylic baseplate for the prototype.
the I2C adapter board. If the back-
light is working, but there is no text, Zeroing the test leads has been saved in the EEPROM; if
adjust the contrast pot on the back The program first checks to see not, you will be prompted to per-
of the I2C adapter board. if the resistance of the test leads form the Zero process. Follow the
EE
LATES HE
T COP
TEACH-IN 9
FROM THE PUBLISHERS OF
Y
OF
TEACH OUR
-IN SE
Electron Publishing GET TESTING!
Electronic test equipment and measuring
FREE
CD-ROM
TWO TEACH
-INs
RIES
techniques, plus eight projects to build FOR THE PRICE
OF ONE
AVAILA
• Multimeters and a multimeter checker
• Oscilloscopes plus a scope calibrator
BL PRICE £8.99
• AC Millivoltmeters with a range extender
NOW! E
• Digital measurements plus a logic probe
• Frequency measurements and a signal generator
• Component measurements plus a semiconductor
junction tester
PLUS...
YOUR GUIDE TO THE BBC MICROBIT
A LOW-COST ARM-BASED SINGLE-BOARD
COMPUTER
Teach-In 9
Get Testing
PLUS
Teach-In 2 -Using
PIC Microcontrollers.
In PDF format
This series of articles provides a broad-based introduction to choosing and using a wide range © 2018 Wimborne Publishing Ltd.
www.epemag.com
of test gear, how to get the best out of each item and the pitfalls to avoid. It provides hints
and tips on using, and – just as importantly – interpreting the results that you get. The series
Teach In 9 Cover.indd 1 01/08/2018 19:56
deals with familiar test gear as well as equipment designed for more specialised applications.
The articles have been designed to have the broadest possible appeal and are applicable to all branches of electronics.
The series crosses the boundaries of analogue and digital electronics with applications that span the full range of
electronics – from a single-stage transistor amplifier to the most sophisticated microcontroller system. There really is
something for everyone!
Each part includes a simple but useful practical test gear project that will build into a handy gadget that will either
extend the features, ranges and usability of an existing item of test equipment or that will serve as a stand-alone
instrument. We’ve kept the cost of these projects as low as possible, and most of them can be built for less than £10
(including components, enclosure and circuit board).
PLUS! You will receive the software for the PIC n’ Mix series of articles and the full Teach-In 2 book – Using PIC
Microcontrollers – A practical introduction – in PDF format. Also included are Microchip’s MPLAB ICD 4 In-Circuit Debug-
ger User’s Guide; MPLAB PICkit 4 In-Circuit Debugger Quick Start Guide; and MPLAB PICkit4 Debugger User’s Guide.
The WebMite
a Raspberry Pi Pico with MMBasic, WiFi and Internet Connectivity
| Article and MMBasic by Geoff Graham | WebMite firmware by Peter Mather |
M
ost readers will be familiar ; Remotely edit BASIC programs. Loading the WebMite firmware on
with the PicoMite, which we ; Transfer files to and from the Pico the Raspberry Pi Pico W is the same
introduced in the July 2022 over WiFi using TFTP. as with the original Raspberry Pi Pico
Make it with Micromite column. It is These features have been imple and is described in the user manual.
a Raspberry Pi Pico programmed in mented using an easy-to-use program Essentially, you plug your Pico W into
the MMBasic language and is a very ming framework with the flexibil a USB port on your computer while
capable microcontroller at a low price. ity to handle the unusual aspects of holding down the button on the top of
Following that, the Raspberry Pi accessing internet resources. Later in the module. The Pico will then create
Foundation released the Raspberry Pi this article, we will present an exam a pseudo USB drive on your computer,
Pico W, which is very similar to the ple of a simple web server that uses and you just drag and drop the Web
original Pico but with the addition of just 12 lines of BASIC code – that is Mite firmware into that.
a WiFi module. all it takes to serve up a web page for When the transfer has been com
In theory, you could take any Pico your projects. pleted, the Pico will restart running the
project and then add an internet con The MMBasic language is an easy- WebMite firmware and create a serial
nection… but it is not quite that easy. to-use programming environment. connection via its USB port.
The internet and its protocols are com With the WebMite, you can easily add Once it has done that, you can use
plicated, with many protocol layers. internet features to complex gadgets a terminal emulator like Tera Term
That means it takes an experienced with touch-sensitive LCD panels, SD (http://tera-term.en.lo4d.com) to access
programmer to accomplish even the card support for storing files, connec the WebMite’s console. If you then hit
simplest task. tion to various sensors and so on. the Enter key on your keyboard, you
That is where our new WebMite will see the MMBasic prompt, which
comes in. We have added to the Pico Loading the firmware is just a greater-than character (>). You
Mite firmware support for the wireless As the hardware is already built for can configure the WebMite, test com
capability of the Pico W and the proto you (the Raspberry Pi Pico W, avail mands, edit programs, and run them at
cols (802.11n, DHCP, WPA-PSK, TCP, able for under $10), all you have to this command prompt.
IP, TLS, HTML etc) that are necessary do to create the WebMite is load the
to access the internet. With the Web appropriate firmware onto that mod Internal file system
Mite, you can easily: ule. Luckily, that is easy. Before we get into the internet capa
; Connect to a WiFi network with The WebMite firmware can be bilities of the WebMite, we need to
a specified SSID and password. downloaded for free from from the introduce the internal file system. It
; Implement a web server with August 2024 page of the PE website: looks like an SD card to the program
advanced features. https://bit.ly/pe-downloads or the mer, but files are actually stored in the
; Query websites for data. author’s website at http://geoffg.net/ flash memory chip of the Raspberry
; Get the current time/date. webmite.html Pi Pico W.
; Check the weather. It comes with a comprehensive 178- You can open files for reading and
; Send emails. page user manual that includes a tuto writing, create and navigate directo
; Publish/retrieve data from MQTT rial on BASIC programming for pro ries and do all the things you can do
broker services (for IoT messaging). gramming beginners. with a physically attached SD card.
That includes using the normal BASIC
file commands such as OPEN, CLOSE,
FILES etc. If you connect a removable
SD card to the WebMite, it is accessed
as drive “B:” while the internal file
system is drive “A:”.
This internal file system has a capac
ity of about 600kB, and it is automat
ically created by the firmware when
MMBasic is loaded onto the Rasp
berry Pi Pico (W). This is especially
useful on the WebMite because, to set
up a web server, you need somewhere
to store the web pages and images to
All that you need serve. The internal file system is per
for the WebMite is an fect for the job.
affordable Raspberry Pi Pico W. This feature was introduced in the
last release of the PicoMite firmware,
Connecting to WiFi
The WebMite can connect to any WiFi
network running 802.11n (2.4GHz)
with WPA-PSK security. The encryp
tion must be either TKIP or AES (or
both) and DHCP must be enabled
on your router. These are standard
requirements for most WiFi-enabled
gadgets, so most routers are set up like
this by default.
To log into your network, use the
command OPTION WIFI at the Web
Mite’s command prompt. For exam
ple, if your network is called MyNet
work and the password is secret, you Screen 1: You can connect to the WebMite using Telnet over WiFi via Tera Term.
would use this command at the com This lets you do everything that you can do via a USB cable, including editing
mand prompt (the quote characters and running programs.
are required):
You can also use PuTTY in Win are slower and clunkier (which is why
OPTION WIFI “MyNetwork”, “secret”
dows or the telnet command in Linux they are only used when required).
This will be remembered and will or macOS (it is no longer part of the To allocate RAM for holding a long
be automatically reapplied on every macOS by default, but you can install string, you need to declare an array of
reboot. It will also cause the WebMite it via Homebrew). integers with a size (in bytes) that will
to restart and drop the USB connec fit the longest string expected. While
tion, so you will have to reconnect to File transfers declared as integers, the string rou
access the command prompt again. Another handy feature is the ability to tines do not store numbers in these;
You can check the IP address that transfer files to and from the WebMite they are just used as memory blocks.
your router gave to the WebMite with over WiFi. This is done using TFTP For example:
the command: (Trivial File Transfer Protocol) from
DIM INTEGER StrA(512),StrB(512)
a Windows, Mac or Linux computer.
PRINT MM.INFO(IP ADDRESS)
In Windows, this is built into the Each array is 512 integers, and an
Most routers will allocate the same operating system; however, you must integer is eight bytes, so each array
address to the WebMite on every enable it first by going to the Control occupies 4KB of RAM (512B × 8). A
reboot. However, if you want to ensure Panel, selecting “Programs and Fea character is one byte, so each can store
the address will not change, go into tures”, then “Turn Windows features strings of up to 4,096 characters. These
your router’s configuration and allo on or off”. Finally, scroll down the list arrays are passed to the long string rou
cate a static IP address to the WebMite. and tick TFTP Client. tines using empty brackets. For exam
Incidentally, you can have many Web You can then send a file to the Web ple, to copy StrB to StrA, you can use
Mites on your network with different Mite’s internal file system (drive A:) the command:
IP addresses and they will not conflict. using the following command in a
LONG STRING COPY StrA(), StrB()
Command or Power Shell window:
Remote connection via Telnet Long strings are documented in the
TFTP -i ipaddress PUT filename
The WebMite could be installed in user manual. It is worthwhile to famil
some inaccessible place, so the firm This protocol can also be used to iarise yourself with them as they are
ware allows you to use Telnet over retrieve files from the WebMite, eg: invaluable when dealing with the large
your WiFi network to access the amount of data sent over the internet.
TFTP -i ipaddress GET filename
MMBasic console. This feature is
enabled with the command: Web server functions
Long string support Assuming that you have connected
OPTION TELNET CONSOLE ON
Another new feature of the WebMite the WebMite to your WiFi network
As before, this command will that needs explaining is long strings. as described above, the next step in
be remembered and automatically Regular string (text) variables in implementing a web server is to tell the
applied on every reboot. It will also MMBasic can store a maximum of 255 firmware to start a TCP server. This is
cause the processor to restart, so you characters. However, most data trans done with another OPTION command
will have to reconnect to regain the ferred between an internet client and as follows (it must be entered at the
command prompt. server is much longer than that. The command prompt):
The recommended terminal emula WebMite has a series of routines called
OPTION TCP SERVER PORT 80
tor, Tera Term, supports Telnet, so all long strings to address this need.
you need do is select that in the new These work with strings of any Port 80 is the standard HTTP port,
connection dialog box and enter the length, limited only by the available normally used for serving web pages.
WebMite’s IP address, as shown in RAM. Using them, you can pull long As with the other OPTION com
Screen 1. You can do everything you strings apart, search for specified text, mands, this only needs to be entered
can via a physical USB connection copy parts of the text and so on. They once and will be remembered. It will
using Telnet, including editing and mimic what the standard string func also cause the WebMite to restart.
running programs... all over the WiFi! tions do in MMBasic, although they In your program, you tell the server
Screen 2: a web request from a remote browser will look like this. The Fig.1: here’s how to connect the
important part is the text between the keywords GET and HTTP. In this case, the DHT22 temperature/humidity sensor
browser is requesting a web page called “page.html”, but it could be an image for the sample web server program in
file or some text indicating that the user has clicked a control on the web page. Program 1.
SUB WebInterrupt
LOCAL INTEGER a, p, t, b(512)
FOR a = 1 To MM.INFO(MAX CONNECTIONS) <H3>Greenhouse Monitor</H3>
WEB TCP READ a, b() The temperature is {CurrentTemp}°C <BR />
p = LINSTR(b(), “GET”) The humidity is {CurrentHumid}%
t = LINSTR(b(), “HTTP”)
If (p > 0) And (t > p) Then Program 2: this is the web page HTML source for the program
WEB TRANSMIT PAGE a, “index.html” shown in Program 1. The first line defines a heading and
ENDIF the next two specify the text in the page. When the page is
NEXT a
END SUB
transmitted, the firmware will substitute the text {CurrentTemp}
and {CurrentHumid} with the current values of those variables.
it working immediately. To make it with associated buttons and switches if you wanted to get the default web
easy, the WebMite firmware download (or a touchscreen) can be converted to page from a website called example.
includes both these files and a ‘readme’ a web interface with the same func- com, you could do it this way:
file with detailed instructions. Give it tions and more.
DIM INTEGER b(512)
a go and be prepared to be amazed at An excellent example is the Water-
WEB OPEN TCP CLIENT
what the WebMite can do. ing System Controller starting on page
“example.com”, 80
36 of this issue. It uses the WebMite
WEB TCP CLIENT REQUEST
Advanced server features and there are no controls on the phys-
“GET / HTTP”, b()
Web infrastructure is a rich environ- ical box. All the controller’s functions
WEB CLOSE TCP CLIENT
ment, so you can add many more fea- are configured and controlled exclu-
tures to your web pages. These include sively via web pages in a browser. Editor’s note: the WEB OPEN and
images, textured backgrounds, multi- WEB TCP commands should all be
ple pages and more. TCP client on a single line; the commands are
For example, you might want to dis- As well as acting as a web server, the shown split here due to limited col-
play a graph of past temperatures and WebMite can act as a client and get umn width.
humidity for your hypothetical green- data from web servers on the inter- The web page would be saved in the
house. That can be done by defining net. Three commands will do this for long string buffer b() and you could
a virtual LCD panel in the WebMite. you: WEB OPEN TCP CLIENT, WEB pick it apart to get the data you wanted
This does not have an attached phys- TCP CLIENT REQUEST and WEB using the long string routines.
ical display, but regardless, you can CLOSE TCP CLIENT. For example, There are many services available
draw your historical data on it using
the graphical drawing commands built Screen 3: how
into MMBasic: line, pixel, text etc. the simple
You can save this image as a BMP file web server
to the internal file system in the Web- appears to
Mite. Then, when a remote browser a user on a
requests the web page with this embed- phone, tablet
or computer.
ded image, the browser will also ask
for this file, and the user will see an
image representing the graph of past
temperatures and humidity that your
program recorded. Screen 4 illustrates Screen 4: with
what it could look like. a little more
Even more useful is the ability to programming
define HTML forms in the web page, effort, you
including embedded controls such as can extend
buttons, checkboxes, radio buttons, the simple
input text fields and much more. Using web server
these, the user can, via the web page, to display a
send commands to the BASIC program graph of past
temperatures
running on the WebMite to do things and humidity
like turn devices off/on, set parame- readings
ters and so on. Screen 5 provides some for your
examples of these. greenhouse.
A wide range of controls is available
but be warned that the HTML code
can get complicated. The web page at
www.w3schools.com/howto/default.
asp lists these controls and their fea-
tures, and has plenty of examples that
you can copy into your web pages.
This ability means that many proj-
ects that generally need an LCD screen
TEACH-IN 3 TEACH-IN 5
£7.99
huge range of subjects that will interest everyone involved 15 design and build circuit projects for newcomers or JUMP START
CIRCUIT SURGERY
in electronics – from newcomers to the hobby and i The how and why of circuit design those following courses in school and colleges. 15 design and build circuit projects
dedicated to newcomers or those
PRACTICALLY SPEAKING
students to experienced constructors and professionals.
following courses in schools and
PIC ‘N MIx
Surgery, EPE/PE’s regular clinic dealing with readers’ Powered Charger n Versatile Theft Alarm n Spooky
i Over 40 different circuit ideas
Starting out with PIC microcontrollers
t
W
1
TWO TEACH-INs FOR
Elec
©
TWO TEACH-INs FOR
THE PRICE OF ONE! THE PRICE OF ONE !
The second section – Practically Speaking – i The free CD-ROM provides
a broad-based introduction
to electronics
n Egg Timer n Signal Injector Probe n Simple Radio Provides
a practi
cal
to PIC
introduction llers
Plus:
MikroElektro
Microchip pe
L-Tek PoSco
nika,
The free CD-ROM provides a
practical introduction to PIC
8 Inter
active ledge
and logo, Techno
ip name of Microchip
Technol
Microch
ip
.09 software
PLUS
The Microch arks s. © 2013
Your Know
016-02
ed tradem countrie 1. MCCD1
register and other d. Issue
in the USAAll rights reserve
d 1
In 2 - JUL13.ind
A BROAD-BASED INTRODUCTION TO CD
ELECTRONICS
TEACH-IN 4
FROM THE PUBLISHERS OF
Electronics Manual, worth £29.95. The Manual i Over 800 PDF pages
What a Bargain!!
if not, open double-click
and
Explorer f
index.pd
MAN.co.u
Downloa be.com
www.ado
BA SE .epe mag
k
© Wimbor
Audio Out – an
£8.99 £8.99
D CD
DV
and Circuit Surgery
The Teach-In 6 CD-
TEACH-IN 6 analogue expert’s take
TEACH-IN 7 by Ian Bell – ‘State TEACH-IN 8
FROM THE PUBLISHERS OF FROM THE PUBLISHERS OF
FREE
CD-ROM
ROM also contains all on specialist circuits
SOFTWARE
FOR
the techniques of
• Pi ClASS – SPECifiC lEARninG AimS • Learn with ‘TINA’ – modern CAD software • Microcontrollers – understand control operations
• PYthon QuiCkStARt – SPECifiC PRoGRAmminG toPiCS • Five projects to build: Pre-amp, Headphone Amp,
readers and circuit the files for:
• Communications – connect to PCs and other Arduinos
• Pi woRld – ACCESSoRiES, BookS EtC Tone Control, VU-meter, High Performance Audio Power Amp
project building.
• homE BAkinG – follow-uP ACtivitiES
nM
icrochip MPLAB
RE FOR
SERIES SOFTWA 7
CH-IN
THE TEA
Smartscope software.
building PIC-based projects
Teach In 6 Cover.indd 1 02/03/2015 14:59:08 Teach In 7 Cover VERSION 3 FINAL.indd 1 07/04/2016 08:25 Teach In 8 Cover.indd 1 04/04/2017 12:24
W
ateringsystemcontrollers, read it and edit it if you have any damage caused by the permanent-
often known as reticulation special requirements. ly-open valve.
or irrigation controllers, This project was partly developed Some systems have a pump as
are notoriously difficult to program. to demonstrate what you can do with the water supply; in that case, the
They generally have a small LCD the WebMite. Even if you do not want Watering System Controller would
screen and an array of tiny buttons to build a Watering System Control- switch that on and off instead of a
or switches to configure the water- ler, this project can be helpful by pro- master valve.
ing schedule. viding the code and techniques you Either way, the Controller will
Our Watering System Controller can use in other projects. switch it on half a second before
has no LCD or buttons; it is entirely The Watering System Control- the first sprinkler valve is opened
set up and controlled via a web ler program will even run on a bare and switch it off half a second after
browser on your smartphone, tablet Raspberry Pi Pico W. That means you the last has been closed. That is to
or computer. The web pages are easy can explore the program and try it ensure that the water pipes lead-
to understand and provide every- yourself without building anything; ing to the sprinkler valves are kept
thing you need to set it up. you just need the Pico W module. full of water, avoiding the situation
The key component is the WebMite, where a sprinkler valve closes after
a Raspberry Pi Pico W microcontroller Watering system layout the master valve, letting water out
running the MMBasic programming Fig.1 shows a typical reticulation lay- of the pipes.
language, starting on page 28 in this out. The water supply is connected Otherwise, when the master
issue. Here it delivers the web pages, via a master valve to a series of valves valve next opens, the water rushing
gets the time, date and weather from that control individual sprinklers (or through the empty pipes could act
the internet and follows the watering sets of sprinklers). The Controller as a hammer and damage the joints
schedule you have configured. opens the master valve, then steps in the pipe and the valve.
The only other significant com- through each sprinkler valve in turn, The flow sensor is an optional but
ponents in this design are a small opening them for the specified time. worthwhile addition. It is usually fit-
power supply and the solid-state The master valve is important as ted at the outlet of the pump or mas-
relays (SSRs) that drive the solenoid it provides a backup if one of the ter valve and tells the Controller the
watering valves. sprinkler valves is stuck open (it amount of water flowing through the
The program running on the Web- happens). The master valve will still system. The Controller records this
Mite is written in BASIC, so you can cut off the water supply, limiting the and, over time, builds up an average
flow rate for each valve.
The Controller can then easily
The finished controller detect an abnormal flow rate when it
in a weatherproof opens a valve, either over or under
enclosure mounted the average. This is invaluable as
on an exterior wall. an excessive flow indicates that a
We decided to mount pipe has burst and it might be dig-
the status LED on ging a hole in your garden. A low-
the lid along with a er-than-normal flow rate means a
waterproof power sprinkler or valve is blocked; if left
switch.
unfixed, that could cause your plants
to die.
When an excessively high flow is
found, the Controller immediately
shuts off that valve to stop any dam-
age. In the case of underflow, it will
continue with the watering time in
the hope that some water is getting
through, but it will also inform you Typical Watering System Control- The first field on the configuration
of the problem. lers require you to change the water- page allows you to enter a meaning-
The rain sensor is also optional. ing characteristics at the start of each ful title to be displayed on the main
The Watering System Controller season, and that can quickly become page. You can also enable or dis-
can check the weather forecast for tedious, something that our design able the schedule with a checkbox.
you and skip watering if rain is pre- cleverly eliminates. The next four fields let you set the
dicted, but connecting a rain sensor That page includes buttons to con- start and stop dates in the year for
provides a backup specific to your figure each schedule. After clicking the schedule. Schedules can over-
garden. The Controller will check one, you will be presented with a lap and, if you want the same water-
the sensor before it starts a watering web page similar to that shown in ing scheme for the whole year, you
run, and if it indicates that it is cur- Screen 2, which provides all the can set the start to 1/1 and the end
rently raining, the schedule will be schedule details. to 31/12.
skipped for that day.
electrician if the Watering System existing controller, it might already has space for a small toroidal trans-
Controller is to be permanently wired be available. former at the top, such as Jaycar Cat
to a power circuit. We mounted the prototype Water- MT2112 or Vigortronix VTX-146-
Before you decide on the place- ing System Controller next to the 030-212.
ment of the Controller, check that the house fusebox, which had a mains The Controller does not have facil-
WebMite can reach your WiFi net- GPO socket inside, then used a 24V ities for terminating and fusing the
work at that location. As described AC plug pack to power the Controller. transformer primary as that would
later, you can do this by loading the This is the best and most economi- be done by the electrician.
firmware onto the WebMite and pow- cal solution; suitable plug packs are
ering it with a 5V USB power bank inexpensive and easy to find. Typi- Construction
or portable computer. If you can call cal examples are Jaycar MP3032 and The Controller is built on a 132 ×
up its web page from that location, Altronics M9379A. 152mm double-sided PCB coded
you are good to go. If you want to power the Control- 15110231, with the components
ler from the mains, you will need a mounted as shown in Fig.3. It is
24V AC power source qualified electrician to run the cables available from the PE PCB Service
24V AC is the standard power supply and connect them to a power circuit. Before you start, you need to
for domestic watering system con- This is expensive, so we do not rec- decide what options you will include
trollers and if you are replacing an ommend it, but if you must, the PCB or exclude. The first is the number of
Teach-In 8 CD-ROM EE
FR -ROM
CD
ELECTRONICS
£8.99
SERIES
FOR
THE TEACH-IN
8
This CD-ROM version of the exciting and popular Teach-In 8 series INTRODUCING THE ARDUINO
• Hardware – learn about components and circuits
has been designed for electronics enthusiasts who want to get to • Programming – powerful integrated development system
• Microcontrollers – understand control operations
SOFTWARE
The CD-ROM contains the software for both the Teach-In 8 and PICkit 3 series.
W
e are looking at various effect circuits or signal processing will
Amplitude
topics related to digital signal have on a signal and helps us understand
processing (DSP). DSP covers design requirements. The frequency axis
a wide range of electronics applications of signal spectra and response plots may
where signals are manipulated, anal- be linear or logarithmic, with logarithmic
ysed, generated, stored or displayed as axes often used when a very wide range
digital data, but originate from, and/or of frequencies is considered.
are output as, real-world signals for in- Signal strength on spectra may be 0 1 2 3 4 5 6 7 8
teraction with humans or other parts of plotted with various parameters such as Frequency/kHz
the physical world. Fig.1 shows the key voltage, current, power or power density.
Fig.2. Spectrum of a 1kHz sinewave.
elements of a generic DSP system with a Although theoretical spectra can be
signal path from an analogue input via continuous functions, the practicalities Amplitude
digital processing to an analogue output. of measurement and simulation usually
This does not necessarily represent every result in a spectrum that is effectively a
DSP system (not all have all the parts histogram comprising frequency ranges
shown) but it serves are as reference for or ‘bins’ for which the signal strength
the various subsystems we will look at. is plotted. It follows that if we change
In our discussion of sampling signals, the width of the bins the signal level in
0 1 2 3 4 5 6 7 8
so far we have mainly considered the each bin may also change. Using spectral Frequency/kHz
signals in time domain (waveforms of density avoids this problem, however,
voltage against time) but in DSP is it also when spectra are drawn simply to show Fig.3. Spectrum of a 1kHz square wave.
important to understand the frequency the general shape of the signals at different
content of signals (the frequency domain). frequencies, rather than provide specific Amplitude
than the equations. We will use one key at some frequencies than others, and a
formula and do some calculations that potentially complex variation of signal
involve just multiplying and adding. strength with frequency.
Often when discussing signal
Spectra processing we want to depict the spectrum
To depict the frequency domain, we use of a generic non-periodic signal, such as 0 1 2 3 4 5 6 7 8
graphs of signal strength versus frequency speech or music. Fig.4 shows a spectrum Frequency/kHz
– the signal’s spectrum. We also plot of such a signal which has content from
parameters such as the gain of a circuit DC to 2kHz. Fig.5 shows a spectrum of Fig.5. Spectrum of a generic non-period
against frequency as a frequency-response a signal with no DC (zero amplitude at waveform with no DC.
graph. Looking at frequency responses zero frequency) but also with content in such as these are commonly used when
and signal spectra together shows us the the range up to 2kHz. Spectral shapes discussing signal processing in the
frequency domain. The spectra in
Analogue Digital Analogue such figures are often drawn on linear
Antialiasing Sample and Digital Reconstruction
axes which can go down to zero (DC)
In ADC DAC Out
filter hold processing filter – log frequency axes cannot show
zero frequency (minus infinity on a
Fig.1. Generic DSP system structure. log scale).
waveform with DC with negative frequencies in the February 2024 Circuit Surgery.
shown (same signal as shown in Fig.4). Fig.8. Visualising a continuous time impulse.
Impulses
The mathematics behind the idea that An impulse is an idealised pulse. We
a signal can be represented as a sum mentioned impulses in the May 2024
of sinewaves (this is effectively what Circuit Surgery, and it is worth discussing 1
a spectrum shows) was first proposed them in more detail because they are
n
by the French mathematician Joseph important in signal processing. For –3 –2 –1 0 1 2 3
Fourier (1768 – 1830). The set of peaks example, digital filters are categorised in
in a periodic waveform is called its terms of their response to impulse inputs. Fig.9. Unit sample (discrete time impulse).
Fourier series, and the more general We can consider sampling as multiplying
mathematical process for converting from the continuous time signal by an impulse an area of 1 – this is an impulse. The shape
a time domain to a frequency domain train (a waveform comprising a set of is not necessarily rectangular, but this
representation of a signal is called the evenly spaced impulses). In continuous representation makes it easier to show the
Fourier Transform (and the reverse or time an impulse (also called a ‘Dirac delta’) constant area in this discussion.
inverse Fourier Transform goes the other is a pulse which is of zero duration but Fig.10 shows a continuous time
way). For the sampled signals used in DSP with ‘an area under the curve’ of one. For waveform, the unit impulse train used
the basic Fourier Transform is replaced discrete (sampled) signals an impulse is for sampling and the sampled signal.
by the Discrete Fourier Transform (DFT). a single sample with a value of 1 at one The spectrum of a unit impulse train is
There are several methods of calculating sample point and a value of 0 for all other interesting in that it has the same shape
the DFT from the signal sample data, but samples. This is called a unit sample and in the frequency domain – it is also a set
one method, the Fast Fourier Transform is related to another mathematic concept of evenly spaced impulses. If the time
(FFT), as its name suggests, is much more called the ‘Kronecker delta’. domain impulse train has amplitude 1
computationally effective than the others, Fig.8 shows a way of visualising a (unit impulse) and a period (time between
so FFT is the usual approach. To see the continuous time impulse, and a sampled impulses) of T (the sampling period)
spectrum of a waveform in LTspice you signal impulse is shown in Fig.9. The top then the spectrum is an impulse train of
use View > FFT from the right-click menu waveform (a) in Fig.8 shows a pulse that amplitude 1/T spaced by f = 1/T, where f
on the waveform. starts at time –2T and ends at +2T, so it is the sampling frequency. The spectrum
A consequence of the Fourier Transform has a duration to 4 (in arbitrary time units). of the sampling impulse train from Fig.10
is that the spectrum of a signal contains It is zero at all other times. Its amplitude is shown in Fig.11. The arrowheads seen
negative frequencies. This concept may is ¼ (this could be volts, but again the on the waveforms and spectrum in Fig.10
be hard grasp intuitively – it is a result units are arbitrary in this discussion). and Fig.11 are commonly used to indicate
of the mathematical representation of The area under the pulse is simple to impulses. The sampling impulse train and
the spectrum rather than being part of calculate because of its rectangular shape impulse train in the spectrum are often
our direct perception of the world. It is – it is 4 × ¼ = 1. The middle waveform considered to extend from minus infinity
related to the need to represent signals (b) shows a pulse half the duration and to plus infinity (in time and frequency)
and circuit responses using ‘complex twice the amplitude of waveform (a). Its for theoretical work, but of course this
numbers’. Amplitude alone is not area is also 1 (2 × ½). Similarly, the bottom does not happen for real signals.
sufficient to fully define a sinusoidal waveform is again half the duration and
signal of a given frequency – we also twice the amplitude, so the area is still 1 Convolution
need to know phase (offset in time). (1 × 1). We can repeat this process many We know the spectrum of the sinewave in
Phase and amplitude are not the most times with the pulse getting shorter and Fig.10 (a single frequency peak, like the
convenient way of representing the signal greater in amplitude. Eventually the pulse spectrum in Fig.2) and we have just seen
for mathematical analysis. An alternative, duration will tend towards zero and the the spectrum of the impulse train from
also with two values, is to represent the amplitude towards infinity, but still with Fig.10 (Fig.11). We also know that the
Equation
Convolution can be applied to
t
T
both continuous and discrete
(sample-based) functions. For
continuous functions its
Sampled signal xs(t) definition involves integration Fig.12. Tetrahedral dice.
(calculus), but for the discrete
case we replace integration with up everything in the sequence of values
t summation, which is easier to defined by the expression to the right of
understand if you have not the sigma symbol (f(m)*g(n-m) in this
studied calculus. The case) and the summation range definition
convolution
Digital Signal Processing Topics – Frequency of the two discrete
Domain is below and above the symbol’. Here the
functions f(n) and g(n) is range is for variable m from -∞ to ∞. The
Fig.10. Time domain (waveform) view of the
defined by the following value below the sigma symbol defines
sampling process.
equation: the start value for m via the expression
! m = -∞ and the final value of m in the
sampled signal in Fig.10 (xs(t)) is related 𝑓𝑓(𝑛𝑛) ∗ 𝑔𝑔(𝑛𝑛) = ( 𝑓𝑓(𝑚𝑚) 𝑔𝑔(𝑛𝑛 − 𝑚𝑚) sequence is written above the sigma
to the continuous (xc(t)) and sampling "#$!
symbol. The value of n is fixed for a given
(s(t)) signal by multiplication: xs(t) = summation in the convolution equation,
xc(t)s(t). The question arises as to how We will look at the various parts of this but to find the complete result of the
this relationship maps to the frequency equation to explain what they mean. convolution (eg, a new spectrum) we
domain, and hence what the spectrum of The convolution operator symbol is ‘*’, need to calculate a separate summation
the sampled signal is. This leads us to an so f(n)*g(n) means the convolution of for all values of n from -∞ to ∞. However,
important mathematical operation called functions f and g. (The fact that the symbol as noted previously we can restrict our
‘convolution’ and an important theorem * is commonly used for multiplication calculations to much smaller ranges of n
which states that the multiplication of two in coding languages is a possible source and m for practical applications.
functions in time domain is equivalent of confusion.)
to the convolution of their spectra in A function is a mathematical operation Convolving dice
the frequency domain. Similarly, the performed on one or more variables (the We will illustrate a convolution
convolution of two functions in time variables are n and m in the above). calculation in a simple context before
domain is equivalent to the multiplication Functions are often named using a single looking at the calculation for a spectrum
of their spectra in frequency domain. letter (f and g in the above). For example, example. Consider throwing two dice
Unless you have studied mathematics we could define a function called q on and working out what the probability
at a fairly advanced level you may not variable x as meaning ‘x squared’, then that you get a specific total value. This
have heard of convolution, however it is we would write q(x) = x 2. However, is easy enough to solve by writing down
very important in a variety of areas – DSP functions in this context can also refer all the combinations, but it can also be
of course – but also probability theory, to things such as waveforms and spectra solved by a convolution, so it is a useful
image processing, artificial intelligence for which there is not a very simple example to show how the summation
and various other areas of mathematics, expression such as x2, but for which we sequences work. We will consider two
physics and engineering. A reasonably know or can find the value of, say, f(n) tetrahedral dice (see Fig.12) as they have
simple example, that people might not for any value of n. just four possible values rather than the
be aware is a type of convolution, is the As noted, the above equation is the standard six – this simply reduces the
moving average in statistics, which is also discrete version of convolution, which amount of calculation.
related to the basics of digital filtering. means the functions are of discrete For the first dice [‘die’ if you prefer] the
Convolution is an operation performed variables – that is, n and m are integer function f(n) is the probability of rolling
on two mathematical functions; it (whole number) values. As mentioned value n, which is ¼ or 0.25 for n = 1,2,3,4.
combines them to produce a new function. above, we typically assume that waveform Given that n can be any integer we note
In our case (spectra related to the signals and spectrum data ranges from minus to that for all other values of n, f(n) is zero.
plus infinity, so n and m would start at The function g(n) is the probability of
s(f) -∞, go through zero, that is … -1, -2, 0, rolling value n for the second dice, which
1, 2, 3 … and then on up to ∞. For real has the same values as f(n). The values
1/T
waveforms and spectra, we obviously are shown in Table 1.
have to use a more limited range and so The convolution f(n)*g(n) is equal to
–4f –3f –2f –f 0 f 2f 3f 4f typically assume all values of the function the probability that the total value of the
Frequency outside the range of interest are zero. two dice will be n. Given the minimum
The symbol S (Greek capital sigma) total is 2 (rolling two 1s) and maximum is
Fig.11. Spectrum of the sampling impulse in the convolution equation is the 8 (two 4s) we expect f(n)*g(n) to be zero
train from Fig.10, where f = 1/T. summation operator, which means, ‘add for all values except n = 2 to 8. We will
Fig.14. Spectrum of the sampling impulse (arbitrary units, but could be kHz) and multiples of fs to ±∞, but of course it is
train with sample frequency f = 5. sampling rate of 5 (could be 5kHz). limited in range in real systems. In the
The sinewave spectrum is xc(f), which discussion on modulation in December
corresponds to f() in the convolution 2023 we saw that multiplying waveforms
look at one example calculation in detail equation and is shown in Fig.13. Its value is together produced sum and difference
– getting a total of 6. There are 16 possible zero for all cases except xc(-1) and xc(1). The frequencies, and this is also what is
outcomes from rolling the two dice of sampling signal spectrum s(f) corresponds happening here with sum and difference
which 3 combinations add up to 6, these to g() in the convolution equation and is occurring at each multiple of the sampling
are 2+4, 3+3 and 4+2, so the probability shown in Fig.14. Its value is zero for all frequency. A further illustration in Fig.16
(calculated without convolution) of the cases except s(0) and s(n) where n is a shows the spectrum of a sampled version
total being 6 is 3/16 = 0.1875. multiple of 5. In general, the amplitude of of a signal similar to that in Fig.7 where
The convolution calculation f(6)*g(6) s(f) is the amplitude of the pulse divided the original spectrum extends from DC
is shown below in Table 2. This shows by T (sampling period); however, we will to f = 2 and sampling frequency is again
the summation (from the equation above) just assume it is 1 for simplicity. fs = 5. Again, we see the replication of
for a range of values of m around the We can quickly calculate xc(n)*s(n) to the spectrum at each multiple of the
points at which the results are non-zero. find the sampled waveform spectrum sampling frequency. Next month, we
For all other values of m we know that the by just considering the summation of will look at the implications of sampled
result will be zero so we do not need to x c(m)s(n-m) for the two cases where signal spectra for system design.
calculate these. The convolution delivers xc(m) is 1 (at m = -1 and 1) as
the result f(6)*g(6) = 0.0625 + 0.0625 all other cases contribute zero. Table 3. Convolution to calculate sampled signal
spectrum (non-zero values highlighted in blue).
+ 0.0625 = 0.1875, the same as above. This is shown in Table 3 for a
Convolution can be described as the small example range of n and m = -1 m=1
product of two functions where one is the resulting spectra is shown
n n-m xc(m)s(n-m) n-m xc(m)s(n-m) S
reflected in the y-axis (reversed) and in Fig.15.
shifted. We see in the above that in From Table 3 and Fig.15 -2 -1 0 -3 0 0
the calculation of f(n)*g(n) the terms we see that spectrum of the -1 0 1 -2 0 1
in f() and g() use different values sampled waveform contains the
of the variable (eg, f(1)g(5) and f(2) original spectrum (at f = -1 and 0 1 0 -1 0 0
g(4)) – this is the ‘shifting’. Also, the 1) plus copies of the spectrum 1 2 0 0 1 1
variable for g() goes down in value as shifted from its original position
2 3 0 1 0 0
the summation progresses (g(5), g(4), centred on 0 to being centred
g(3) and so on) – this the ‘reversal’ or on multiples of the sampling 3 4 0 2 0 0
‘reflection’. If you search online you can frequency. For example, the 4 5 1 3 0 1
find various animations which illustrate original spectrum is replicated
convolution calculations graphically to centred around f s to gives 5 6 0 4 0 0
help emphasise this point – for example, peaks at f = 4 and 6 (+1 and 6 7 0 5 1 1
https://youtu.be/KuXjwB4LzSA -1 relative to 5). Theoretically
7 8 0 6 0 0
this replication occurs for all
Table 2. Convolution calculation.
m … 0 1 2 3 4 5 6 …
f(6)*g(6) = …+ f(0)g(6-0) + f(1)g(6-1) + f(2)g(6-2) + f(3)g(6-3) + f(4)g(6-4) + f(5)g(6-5) + f(6)g(6-6) +…
f(6)*g(6) = …+ f(0)g(6) + f(1)g(5) + f(2)g(4) + f(3)g(3) + f(4)g(2) + f(5)g(0) + f(6)g(0) +…
f(6)*g(6) = …+ 0×0 + 0.25×0 + 0.25×0.25 + 0.25×0.25 + 0.25×0.25 + 0×0.25 + 0×0 +…
f(6)*g(6) = …+ 0 + 0 + 0.0625 + 0.0625 + 0.0625 + 0 + 0 +…
OUT
L R
By Jake Rothman
Switching in audio equipment – Part 3
I
finished off last month promising to move on to
+
electronic switching in this month’s Audio Out, and we L input 100µF 620Ω
+
will make a small start, but first there are a few odds and –
L output
+
R output
bypassing in systems where the input is driven from a low –
impedance. However, it does not work well for self-contained
100kΩ
units such as guitar pedals where the high-impedance guitar
signal is loaded by the input stage at all times, pulling the
0V
impedance down. A typical place where this is used is in
Hi-Fi preamplifiers to bypass the tone control – see Fig.52.
Fig.53. Traditional mono switch circuit.
Mono switch it cancels out across the left and right channels. In more
This is an essential test switch for music producers to sophisticated units, a little bit of gain is introduced via
listen for phase problems in stereo mixes, accomplished a proper summing amplifier (Fig.54) to counteract the
by mixing the left and right channels. This must be done attenuation. A typical ‘fudge value’ being +4.5dB.
using resistors, since it can be dangerous if the left and
right channels are simply joined together. Imagine if there ‘Juggler’ switch
were two out-of-phase 10Vrms signals from two op amps It is sometimes necessary to switch the order of two processing
(not impossible in audio) and their outputs were joined. blocks. A common dilemma facing music engineers is ‘do we
The ‘electronic smell of death’ from burning epoxy would have the EQ followed by the compression or the other way
soon fill the air. The simple resistive summing circuit round?’ It sounds very different depending on which way you
shown in Fig.53 leads to a halving of the voltage
level (−6dB) if only one channel has a signal on L input
it. It remains the same if it’s the same signal on + 100µF 47Ω Stereo
+
100kΩ
old record collections also like a mono button –
Out +
100µF
Output 22kΩ
EQ 0V Mono
Input from low- In Out S1b
impedance drive +
In 100µF R output
47Ω
+
R input
– Stereo
22kΩ
Bass Treble
0V
do it. One option is quite a convoluted ended up bypassing the whole selector
circuit called a ‘juggler’ using three section, reducing it to a single-input
Input 1
ganged change-over switches (3PDT) computer amplifier. RL1a
as shown in Fig.55. A real benefit of electronic
Input 2 RL2a
switching can be had by removing
Electronic switching easily corrupted small-signal wiring Input 3
RL1b
That’s i t f or me c h a n i c a l a u d io connected to mechanical switches at
switching; now we can move on to the front panel and confining it to the Input 4
the important topic of electronic audio PCB at the rear. The DC control signals
1 2
switching, which offers the possibility can then go anywhere around the front
V+ coil
of remote control that has become panel for the most ergonomic layout. voltage
an essential marketing tool today. I This means there is no need to worry 0V 0V
don’t rate it that highly as I’m always about hum when placing a switch next
NC
losing ‘remotes’ and I don’t think a to the mains switch. 1
sedentary lifestyle is so wonderful. If The simplest and highest quality 2
3
I’m going to select a new source, I see way of implementing DC control is Input
select 4
no problem in getting up to operate a to use relays, but it is debatable if
switch. A modern amplifier following this is truly ‘electronic’ – more like
this tradition is the Arcam 65 Plus ‘electromechanical’. On the other
shown in Fig.56. This design uses a hand, I tend to view relay control as
rotary encoder and a microcontroller electronic because it involves electrical Fig.57. Four input selector switch using
to control the electronic switching. control signals. Again, the relays can DPDT relays. Duplicate for stereo use.
Unfortunately, the micro died in mine be located at the back and only the Suitable relay is Relpol R8M822N,
and could not be replaced thanks to DC control wires need to go to the Rapid 61-6018.
proprietary programming/silicon. I front panel switch. Relays are most
commonly available with
V+
dual change-over contacts
and have to be used in the S1
0V
D Q Output
R S
CD4001b
Fig.60. Op amp latching circuit. Avoids the use
100kΩ 100kΩ 100kΩ
of unreliable CMOS chips and give higher output
voltage as well.
latch with an op amp using a circuit that appeared
4.7kΩ in Elektor Summer Circuits (July 1983) as illustrated
in Fig.60. I have found this arrangement useful since
Low-current
LED, on when it can use a standard op amp power supply. It is
S1 pushed also a good use for old spare op amps that are too
0V
noisy for audio, such as 741s. A drawback is the
problem of an uncertain state upon switch-on. One
Fig.59. CMOS switch debouncer and flip-flop. Ideal for controlling 4066 way round this is to have some kind of capacitive
chips. Shown using single-rail supply, but could use a dual-rail supply. delay on one side of the bi-stable. Fig.61 shows a
discrete bi-stable used in Boss effects pedals.
test gear. My Audio Precision analyser takes the number of
relays to extremes, and many can be heard clicking away as Next month
it runs through various test routines. This mechanical noise That was a very brief start to electronic audio switching.
is annoying and strangely reassuring at the same time. Relay Next month, we will dive properly into this important and
coils consume relatively high levels of power at 100mW or fascinating topic.
more, and can generate high back voltages when turned off.
It is vital to use clamping diodes, an independent power rail
and an independent earth to avoid clicks and bangs.
ESR Electronic Components Ltd
Control logic
One of the great advantages of using electronic control is that
latching/maintained switches can be replaced by cheaper
momentary types. Gold-plated contacts are not needed All of our stock is RoHS compliant and CE
either since we are dealing with switching DC rather than approved. Visit our well stocked shop for
low-level signal currents, sometimes called ‘dry switching’. all of your requirements or order on-line.
However, we need to generate a latching action to hold the
selected position. It is possible to use a spare contact on a We can help and advise with your enquiry,
relay to do this job (Fig.58), but it is more convenient to use from design to construction.
a latching logic element, such as a flip-flop/bi-stable to do
this. This can be done with standard logic ICs such as the
4013 dual D-type flip-flop. A common problem affecting
counting logic when controlled by mechanical switches is 3D Printing • Cable • CCTV • Connectors • Components •
Enclosures • Fans • Fuses • Hardware • Lamps • LED’s •
switch bounce. This can cause erratic operation, such as
Leads • Loudspeakers • Panel Meters • PCB Production •
jumping a few steps randomly. A monostable made with a Power Supplies • Relays • Resistors • Semiconductors •
couple of NOR gates makes a good de-bouncer to feed the Soldering Irons • Switches • Test Equipment • Transformers
flip-flop, as shown in Fig.59. It’s also possible to make a and so much more…
Monday to Friday 08:30 - 17.00, Saturday 08:30 - 15:30
+9V
470pF 470pF
1MΩ 56kΩ 56kΩ
Output Output
100kΩ 100kΩ
BC549B
1kΩ
470pF BC549B
Foot switch 10nF 56kΩ 56kΩ Station Road
push to 470pF Cullercoats
make
0V North Shields
Tyne & Wear
NE30 4PQ
Tel: 0191 2514363 [email protected] www.esr.co.uk
Fig.61. Good old discrete flip-flop; still used in Boss guitar pedals.
J
ust for giggles and grins, There are many different
let’s start this column with what families of these components. Top view
they call a ‘pop quiz’ in the US I suggested the LS (‘Low-
16v100uF
(this means an unexpected test; it’s Power Schottky’) family Side
views To other
nothing to do with pop music, thank because they are cheap and rails and
goodness). The way we currently have cheerful and do the job. My breadboard
As I said deep in the mists of time is naught but ‘click bait.’ Silicone is an up to 2V, the 20V setting will measure
when we started Part 1 of this Arduino electrical insulator, but anti-static mats voltages up to 20V, and so on. Now
Bootcamp series (PE, January 2023): must be able to conduct static build-up suppose we wish to measure a signal
‘To prevent any such unfortunate away to ground. A giveaway clue is that that we know can vary only between 0V
occurrence, may I make so bold as to there is no way to connect these mats and 5V, like the signals generated by our
suggest you invest in an anti-static to ground! Arduino Uno, for example. In this case,
mat (https://amzn.to/3g1YH4A) and an we would select the 20V range because
anti-static wrist strap (https://amzn. Testing times this is the closest to the values we want
to/3WYZ9Bu). Both typically come If you don’t already own a digital to measure while still being higher
with crocodile clips (a.k.a. alligator multimeter, now would be a really good than the values we want to measure. If
clips in the US), which you can pull time to invest in one. You have two main we were to select the 200V range, this
off to reveal banana plugs. My preferred options in the form of hand-ranging or would still measure our signal, but with
modus operandi is to plug these banana auto-ranging products. There are more less precision.
plugs into an anti-static grounding plug pros and cons to this decision than you By comparison, in the case of an auto-
(https://amzn.to/3hDIcML), which is – might suppose, but the accuracy will be ranging multimeter, the setup is faster
in turn – plugged into a wall socket or the same in both cases. because all we need to do is select the
a power strip.’ For the purposes of this column, we DC voltage option. However, this type of
With respect to the anti-static mat, will simply note that a hand-ranging multimeter will take longer to make the
get the largest one you can that fits multimeter takes a little longer to set reading because it first needs to decide
your workspace (and your budget). up because you first need to select the on the most appropriate range.
Also, and this bit is very important, if desired range. This can be a little tricky For what we are doing here, which will
you are working with static-sensitive for beginners to wrap their brains around. include verifying our power connections
components (diodes, transistors, ICs…), Suppose our hand-ranging multimeter and monitoring the states on our logic
then do not waste your money on a indicates support for the 2V, 20V and signals, I would suggest buying a cheap-
blue or grey ‘Heat-Resistant Silicone 200V DC voltage ranges, for example (I and-cheerful hand-ranging device, such as
Work Mat’ (like this one: https://bit. can no longer remember why multimeter the ULTRICS Digital Multimeter, which is
ly/4bMwYfw). I know the description manufacturers use these arcane values). available for only £9.99 from Amazon at
includes the words ‘anti-static,’ but this The 2V setting will measure voltages the time of writing: https://bit.ly/4dMDu7V
J I H G F
now has the full 5V across it (and one 680Ω resistor). Removing
1 5 10 15 20 25 30
this LED’s 2V voltage drop gives 5V – 2V = 3V. Since all the
current is now flowing through a single resistor, this current
will be 3V / 680Ω = ~4.4mA, which means the red LED will
glow with a respectable brightness without hurting our eyes.
Similarly, if we connect the flying end of our logic probe
to +0V (this could be the ground rail or an output from one
of our digital ICs that’s currently driving a logic 0 value, our
P1 P2 P3 P4 P5 P6
red LED will be disabled and our yellow LED (which we are
pretending is green) will glow like a champion.
As I previously mentioned, we could implement our
Fig.6. Six logic probes. logic probe on an unused portion of one of our existing
To Displays
D3 D2 D1 D0
y3 y2 y1 y0
From 2:4 Decoder
(eventually)
Fig.8. Disable the displays. Listing 2a. Simple test of 2:4 decoder.
Time
reading is substantially lower than this – and 14 of the 7408 is the same ~5V.
say 4.5V, for example – then you have a
problem, possibly even a bad breadboard, Testing, testing
which is what happened to me. This is where things get interesting. All
If you get a negative reading like we are going to do is repeatedly write the
(a) Order of display –5V, then this probably means you’ve values 0, 1, 2 and 3 to the displays D0,
applied your probes the wrong way D1, D2 and D3, respectively. Remember
round. Your red probe should be on that we can have only one display active
the power rail and your black probe at a time. Also, since we want to be able
(b) All off should be on the ground rail. If the to see what’s happening, we’ll set things
reading continues to show negative, up so each value will be on for one second
then check the probe connections at the and off for three seconds.
Fig.10. Test values.
multimeter end. The black wire should Let’s start by creating a simple test
displays active simultaneously because be plugged into the ‘COM’ (common) program (file CB-Aug24-02.txt). I’ve based
we know that’s a bad idea. So, connect port and the red wire should be plugged this on the latest and greatest program from
the ends of the y0, y1, y2 and y3 wires into the ‘VΩmA’ port. the previous issue, but I’ve stripped out
into the lower ground rail (the blue 0V Now, power everything down again, anything extraneous to what we’re trying
rail) as illustrated in Fig.8. These are the add the 7404 and 7408 ICs to the to do here. As an example, our loop()
wires connected to the resistors that drive breadboard, and connect their power function is now as shown in Listing 2a.
the bases of our transistors. Connecting and ground pins as shown in Fig.9. With respect to the f o r ( ) loop
them to 0V will turn the transistors off, Remember that the ‘dimple’ at one end established on Line 63, the iDisp control
thereby disabling the displays. of the package is used to determine variable repeatedly counts from 0 to 3.
Next, power everything up and verify which end is which. In this case, both of We start by turning all our display
that the green and blue LEDs straddling our chips use pin 14 for power and pin segments off (Line 63). Then we set the
the power and ground rails at the top of 7 for ground, but every IC is different, values on our s0 and s1 signals (Lines
the breadboard light up. so you should always consult the data 66 and 67). We derive these signals from
Now, set your multimeter to the 20V DC sheets for any chips you are using. While the current value of iDisp (we discussed
range, and then use its probes to check we’re at it, let’s also add the two 0.1µF this last month). Next, we activate the
the voltage across the power and ground ceramic capacitors we discussed earlier. segments associated with the current
rails. As a ‘rule-of-thumb,’ I typically We’ll mount these as close to each IC’s digit we wish to display (Line 68).
apply the black probe first. Start with the power pin as possible. Once again, we use the current value of
STEWART OF READING
17A King Street, Mortimer, near Reading, RG7 3RS
Telephone: 0118 933 1111 Fax: 0118 933 2375
USED ELECTRONIC TEST EQUIPMENT
Check website www.stewart-of-reading.co.uk
Fluke/Philips PM3092 Oscilloscope HP 54600B Oscilloscope
(ALL PRICES PLUS CARRIAGE & VAT)
2+2 Channel 200MHz Delay TB, Analogue/Digital Dual Trace 100MHz
Autoset etc – £250 Please check availability before ordering or calling in
Only £75, with accessories £125
LAMBDA GENESYS PSU GEN100-15 100V 15A Boxed As New £400 Marconi 2305 Modulation Meter £250
LAMBDA GENESYS PSU GEN50-30 50V 30A £400 Marconi 2440 Counter 20GHz £295
IFR 2025 Signal Generator 9kHz – 2.51GHz Opt 04/11 £900 Marconi 2945/A/B Communications Test Set Various Options POA
IFR 2948B Communication Service Monitor Opts 03/25 Avionics POA Marconi 2955 Radio Communications Test Set £595
IFR 6843 Microwave Systems Analyser 10MHz – 20GHz POA Marconi 2955A Radio Communications Test Set £725
R&S APN62 Syn Function Generator 1Hz – 260kHz £295 Marconi 2955B Radio Communications Test Set £800
Agilent 8712ET RF Network Analyser 300kHz – 1300MHz POA Marconi 6200 Microwave Test Set £1,500
HP8903A/B Audio Analyser £750 – £950 Marconi 6200A Microwave Test Set 10MHz – 20GHz £1,950
HP8757D Scaler Network Analyser POA Marconi 6200B Microwave Test Set £2,300
HP3325A Synthesised Function Generator £195 Marconi 6960B Power Meter with 6910 sensor £295
HP3561A Dynamic Signal Analyser £650 Tektronix TDS3052B Oscilloscope 500MHz 2.5GS/s £1,250
HP6032A PSU 0-60V 0-50A 1000W £750 Tektronix TDS3032 Oscilloscope 300MHz 2.5GS/s £995
HP6622A PSU 0-20V 4A Twice or 0-50V 2A Twice £350 Tektronix TDS3012 Oscilloscope 2 Channel 100MHz 1.25GS/s £450
HP6624A PSU 4 Outputs £400 Tektronix 2430A Oscilloscope Dual Trace 150MHz 100MS/s £350
HP6632B PSU 0-20V 0-5A £195 Tektronix 2465B Oscilloscope 4 Channel 400MHz £600
HP6644A PSU 0-60V 3.5A £400 Farnell AP60/50 PSU 0-60V 0-50A 1kW Switch Mode £300
HP6654A PSU 0-60V 0-9A £500 Farnell XA35/2T PSU 0-35V 0-2A Twice Digital £75
HP8341A Synthesised Sweep Generator 10MHz – 20GHz £2,000 Farnell AP100-90 Power Supply 100V 90A £900
HP83630A Synthesised Sweeper 10MHz – 26.5 GHz POA Farnell LF1 Sine/Sq Oscillator 10Hz – 1MHz £45
HP83624A Synthesised Sweeper 2 – 20GHz POA Racal 1991 Counter/Timer 160MHz 9 Digit £150
HP8484A Power Sensor 0.01-18GHz 3nW-10µW £75 Racal 2101 Counter 20GHz LED £295
HP8560E Spectrum Analyser Synthesised 30Hz – 2.9GHz £1,750 Racal 9300 True RMS Millivoltmeter 5Hz – 20MHz etc £45
HP8563A Spectrum Analyser Synthesised 9kHz – 22GHz £2,250 Racal 9300B As 9300 £75
HP8566B Spectrum Analsyer 100Hz – 22GHz £1,200 Solartron 7150/PLUS 6½ Digit DMM True RMS IEEE £65/£75
HP8662A RF Generator 10kHz – 1280MHz £750 Solatron 1253 Gain Phase Analyser 1mHz – 20kHz £600
Marconi 2022E Synthesised AM/FM Signal Generator 10kHz – 1.01GHz £325 Solartron SI 1255 HF Frequency Response Analyser POA
Marconi 2024 Synthesised Signal Generator 9kHz – 2.4GHz £800 Tasakago TM035-2 PSU 0-35V 0-2A 2 Meters £30
Marconi 2030 Synthesised Signal Generator 10kHz – 1.35GHz £750 Thurlby PL320QMD PSU 0-30V 0-2A Twice £160 – £200
Marconi 2023A Signal Generator 9kHz – 1.2GHz £700 Thurlby TG210 Function Generator 0.002-2MHz TTL etc Kenwood Badged £65
I
n the previous part of our Teach-In series, we
introduced the 1-wire and I2C bus interface standards and About Teach-In
showed how you can easily add a low-cost LCD display to Our latest Teach-In series is about using the popular ESP32
your ESP32 projects. Coding Workshop introduced maths opera- module as a basis for learning electronics and coding. We
tions and functions and our Teach-In Project featured the design, will be making no assumptions about your coding ability
construction and coding of a simple environmental monitor or your previous experience of electronics. If you know one
but not the other, you have come to the right place. On
displaying temperature, barometric pressure and humidity.
the other hand, if you happen to be a complete newbie
This month, we begin to explore some of the ESP32’s inbuilt there’s no need to worry because the series will take a
features that help make wireless communication a reality. progressive hands-on approach. There will be plenty of
We begin by introducing some of the basic concepts and time to build up your knowledge and plenty of opportunity
terminology associated with Wi-Fi technology and how the to test things out along the way.
ESP32 can scan for available networks to which it can connect. We’ve not included too much basic theory because this
Our Practical Project shows how the ESP32 can be configured can be easily found elsewhere, including several of our
for use as a Wi-Fi Access Point, making environmental data previous Teach-In series, see:
from a low-cost sensor available for remote display on a https://bit.ly/pe-ti
smartphone, tablet, laptop or desktop PC. https://bit.ly/pe-ti-bundle
Earch month, there’ll be projects and challenges to help you
The learning objectives for the sixth part of our series are, know: check and develop your understanding of the topics covered.
n How to set up and use ESP32 Wi-Fi
The difference between Station (STA) mode and Access
n IP addresses
Point (AP) mode For reasons that will be obvious, every device connected to a
n How to run a scan for nearby wireless networks network needs to have its own unique address. This address
n How to configure the ESP32 Wi-Fi in AP mode is simply a 32-bit (IPv4) or 128-bit (IPv6) number. These are
How to apply simple Arduino C++ string handling techniques
n usually expressed as a sequence of bytes with the decimal
n That HTML is used to display AP data in a web browser. values quoted for each. Here’s an example of a four-byte local
IP address: 192.168.1.1. Note that devices connected to your
Getting to grips with Wi-Fi own router are all members of the same network and can
Since this is the first time that we’ve used Wi-Fi in this Teach-
In series it’s worth starting by explaining a few of the concepts
that underpin the technology. By enabling connectivity
without the need for cabling, Wi-Fi is now commonly used
in modern homes and businesses. All ‘smart’ devices make
use of Wi-Fi and even a humble item such as a doorbell now
employs this technology. We will start by explaining some
key terms before moving on to explain the two modes of
connection that the ESP32 uses.
Wi-Fi bands
Wi-Fi communication operates in two discrete frequency bands.
The original 2.4GHz band and the more recently available
5GHz band. Each of these bands is further subdivided into
several channels, each with an allocated number. Most existing Fig.6.4. Typical output from Listing 6.1.
Encryption Outline
Wired Equivalent Outdated but still widely used. Available in 64, 128 and 256-bit versions. Officially retired by the Wi-Fi
Privacy (WEP) Alliance in 2004.
Formally adopted in 2003, the most-common WPA configuration is WPA-PSK (Pre-Shared Key). The
Wi-Fi Protected keys used by WPA are 256-bit, a significant increase over the 64-bit and 128-bit keys used in the WEP
Access (WPA) system. WPA originally employed Temporal Key Integrity Protocol (TKIP) but this was later superseded
by the Advanced Encryption Standard (AES).
Officially superseded WPA in 2006. It uses AES algorithms and CCMP (Counter Cipher Mode with Block
Wi-Fi Protected
Chaining Message Authentication Code Protocol) as a replacement for TKIP which is still available in
Access II (WPA2)
WPA2 (as a fallback) and to ensure interoperability with WPA.
First announced in 2018 and offering significant improvements over WPA2. It uses Protected
Management Frames (PMF) to enable encryption of the data used for network management (in
Wi-Fi Protected
addition to that used for the data itself). Also incorporates other security enhancements and
Access III (WPA3)
protection against brute force and offline attacks. WPA3 192-bit Enterprise Mode currently offers the
most advanced Wi-Fi encryption.
WiFi.scanDelete(); // Tidy up
and free some memory
Practical project
We mentioned earlier that in AP mode
the ESP32 can create its own Wi-Fi
network to which other smart devices
can be connected. This allows you to
monitor and view data remotely without
the need for a wireless router or host Fig.6.8. Typical Wi-Fi configuration screen on a desktop PC.
computer. To show how useful this is
we’ve created an application based on we need to include three libraries at the might already have them. If not, just go to
the DHT22 temperature and humidity beginning of the code. This is done with the IDE’s Library Manager (as described
sensor that we met last. month. the following lines: in earlier parts of this Teach-In series).
The complete code for our Practical In Listing 6.2 we have included several
Project is shown in Listing 6.2. Note that #include <WiFi.h> // To use lines of code that are needed to configure
ESP32 Wi-Fi the IP address used by the ESP32. Note
that we’ve set the local IP address to
Gotcha! #include <WebServer.h> // To 192.168.1.1. This is the address that you
You might have noticed that we’ve
used ‘\t’ in several of the Serial. use the ESP32 as a web server will need to enter into your browser’s
println statements of Listing address bar to access the hypertext
6.1. The \t simply inserts a non- #include <DHT22.h> // To use transfer language (HTML) data served
printing tab character in the string the DHT22 sensor by the ESP32.
to be printed and this can be used to Rather than just display plain text,
ensure that the text is aligned neatly. It may not be necessary to download and we’ve included some HTML tags to
install all of these library files as you improve the appearance of the data.
void loop() {
Serial.println(“String handling examples ...”);
char firstString[] = “Practical Electronics”;
int n = strlen(firstString);
Serial.print(“First string length = “);
Serial.println(n);
// Print the first string
Serial.println(firstString);
// Print the first character
Serial.print(“First character = “);
Serial.println(firstString[0]);
// Print the last character
Serial.print(“Last character = “);
Serial.println(firstString[n - 1]);
String secondString = “ ESP32 “;
// Print the second string
Serial.print(“Second string = “);
Serial.println(secondString);
// Trim leading and trailing spaces
secondString.trim();
// Print the trimmed string
Serial.print(“Trimmed string = “);
Serial.println(secondString);
// Shorten a string
String thirdString = “OUTPUT DATA”;
// Print the third string
Serial.print(“Third string = “);
Serial.println(thirdString);
String subString = thirdString.substring(0, 3);
Serial.print(“First three characters = “);
Serial.println(subString);
while (1) // Suspend execution
;
}
Check Point
Now that we’ve reached the half-way point in our Teach-In series
Check Point replaces our usual Teach-In Challenge. This is a great
opportunity to test your knowledge of the ESP32. Just select one
answer to each of these questions. When you’ve finished you can
check your answers at the bottom of page 16. Good luck!
7. In the first byte of an I2C transfer, how many bits are used
to convey the address?
(a) Four bits
(b) Seven bits
Fig.6.15. Output from Listing 6.3. (c) All eight bits.
character array. For example, to extract and print the eleventh 8. When an LED is conducting, its:
character we could use: (a) Anode is positive with respect to its cathode
(b) Cathode is positive with respect to its anode
Serial.println(titleString[10]); (c) Cathode is at the same potential as its anode.
You’ve hopefully concluded that this would output ‘E’ (the 9. To set the state of a digital I/O pin you would use:
eleventh item in the array) on the Serial Monitor. (a) outputSet();
The sample code shown in Listing 6.3 shows ways in (b) digitalWrite();
which strings can be accessed and also modified using the (c) outputWrite();.
trim() function (to remove leading and trailing spaces)
and the substring() function (to create a substring from 10. The I2C interface standard allows for a maximum of:
consecutive characters within the original string). It’s worth (a) 15 devices
(b) 63 devices
(c) 127 devices.
Gotcha!
When entering your code remember that character strings 11. The speed at which serial data is transferred is often
to be printed need to start and end with matching opening quoted in:
and closing quotation marks. An error will occur if you (a) Baud
don’t do this and the compiler will reject your code. (b) Hertz
(c) Mbyte.
Practical
Electronics
If you want your advertisements to be seen by the largest readership
at the most economical price then our classified page offers excellent Practical Electronics
value. The rate for semi-display space is £10 (+VAT) per centimetre reaches more UK
high, with a minimum height of 2·5cm. All semi-display adverts have a readers than any other
width of 5.5cm. The prepaid rate for classified adverts is 40p (+VAT) per UK monthly hobby
word (minimum 12 words).
electronics magazine.
Cheques are made payable to ‘Practical Electronics’. VAT must be
Our sales figures prove it.
added. Advertisements with remittance should be sent to: Practical
Electronics, 113 Lynwood Drive, Wimborne, Dorset, BH21 1UU. We have been the leading
Tel 07973518682 Email: [email protected] monthly magazine in
BOWOOD ELECTRONICS LTD
For ratesofand
Suppliers further
Electronic information on display and classified advertising
Components this market for the last
please contact our Advertisement
www.bowood-electronics.co.uk Manager, Matt Pulzer – see below. twenty-seven years.
Unit 10, Boythorpe Business Park, Dock Walk, Chesterfield,
Derbyshire S40 2QR. Sales: 01246 200 222
Send large letter stamp for Catalogue
ADVERTISING INDEX
CRICKLEWOOD ELECTRONICS . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Advertisement offices
ESR ELECTRONIC COMPONENTS . . . . . . . . . . . . . . . . . . . . . . . 50 Matt Pulzer
HAMMOND ELECTRONICS Ltd . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
JPG ELECTRONICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Electron Publishing Ltd
FLOWCODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1 Buckingham Road
MICROCHIP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Cover (ii)
Brighton
PEAK ELECTRONIC DESIGN . . . . . . . . . . . . . . . . . . . . . . Cover (iv) East Sussex BN1 3RA
POLABS D.O.O. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Tel 07973 518682
QUASAR ELECTRONICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Email [email protected]
SILICON CHIP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
STEWART OF READING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Web www.electronpublishing.com
TAG-CONNECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
TERRINGTON COMPONENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 For editorial contact details see page 7.
PCBs for most recent PE/EPE constructional projects are available. From the July 2013 issue onwards, PCBs with eight-digit codes
have silk screen overlays and, where applicable, are double-sided, have plated-through holes, and solder mask. They are similar to
photos in the project articles. Earlier PCBs are likely to be more basic and may not include silk screen overlay, be single-sided, lack
plated-through holes and solder mask.
Always check price and availability in the latest issue or online. A large number of older boards are listed for ordering on our website.
In most cases we do not supply kits or components for our projects. For older projects it is important to check the availability
of all components before purchasing PCBs.
Back issues of articles are available – see Back Issues page for details.
You can also order PCBs by phone, email or via the shop
on our website: www.electronpublishing.com
All prices include VAT and UK p&p. Add £4 per project for post to Europe; £5 per project outside Europe.
Orders and payment should be sent to:
Practical Electronics, Electron Publishing Ltd
113 Lynwood Drive, Merley, Wimborne, Dorset BH21 1UU
Tel 01202 880299 Email: [email protected]
On-line Shop: www.epemag.com
Cheques should be made payable to ‘Practical Electronics’ (Payment in £ sterling only).
NOTE: Most boards are in stock and sent within seven days of receipt of order, please allow up to 28 days delivery if we need to restock.
Teach-In
Next month, we will introduce Network Time Protocol (NTP),
and create an accurate clock that displays network time on a
16 × 2 character LCD.
PLUS!
All your favourite regular columns from Cool Beans
and Circuit Surgery, to Audio Out, Fox Report,
Techno Talk and Net Work. On sale 1 August 2024
Content may be subject to change
JPG Electronics
Britannia Maison Mes Amis
Bournemouth BH1 9EH, United Kingdom
Inn
Old Road Remember, we print the date of the last issue
of your current subscription in a box on the
ad
d
Roa
address sheet that comes with your copy.
Old H
orth
tsw
Cha
Morrisons
Sparks
Digital subscribers, please call 01202 880299
Retail & Trade Welcome • Free Parking • Google St View Tour: S40 2RB or visit: www.electronpublishing.com
Published on approximately the first Thursday of each month by Electron Publishing Limited, 1 Buckingham Road, Brighton, East Sussex BN1 3RA. Printed in England by Acorn Web Offset Ltd., Normanton WF6
1TW. Distributed by Seymour, 86 Newman St., London W1T 3EX. Subscriptions UK: £33.99 (6 months); £59.99 (12 months); £114.99 (2 years). EUROPE: airmail service, £38.99 (6 months); £69.99 (12 months);
£129.99 (2 years). REST OF THE WORLD: airmail service, £46.99 (6 months); £84.99 (12 months); £164.99 (2 years). Payments payable to ‘Practical Electronics’, Practical Electronics Subscriptions, PO Box
6337, Bournemouth BH1 9EH, United Kingdom. Email: [email protected]. PRACTICAL ELECTRONICS is sold subject to the following conditions, namely that it shall not, without the written consent of the
Publishers first having been given, be lent, resold, hired out or otherwise disposed of by way of Trade at more than the recommended selling price shown on the cover, and that it shall not be lent, resold,
hired out or otherwise disposed of in a mutilated condition or in any unauthorised cover by way of Trade or affixed to or as part of any publication or advertising, literary or pictorial matter whatsoever.
nics
The UK
Circuit Surgery Teach-In 2024 ’s pAudio
remieOut
r electr
Topics in digital signal processing Create a Wi-Fi Access
CircPoint
uit
with Mechanical
o
in audio nics and
– the frequency domain Topics Surgerswitches
the ESP32 SoC microcontroller
y compu
– sam
in digit
a
ple an l signal proc
ting ma
T each- ker ma
WebMite d hold essing
Sensin In 2024
g the e
gazine
Watering th
e ESP3 virn
2 SoC onment wit Audio
O
microc h Mecha ut
System ontrolle
r n
switch ical
es in a
Controller udio
Make
y
own D our
WIN! y
RFID t namic
Microchip
PolarFire SoC ags
Discovery Kit
WIN!
PLUS!
P
LUsense!
S! Pi
Aug 2024P ico
£5.99
Therm08 -based
Techno Talk – That makes so much
Techn
Cool Beans – DIY logic probes
Cool B
o Talk
– Who al Cam
eans –
Net Work – Passkeys and online security
Net W Arduin
saw th 9 772632 573030
at com era
ork – P o: 7-seg in g?
www.electronpublishing.com ractica
@practicalelec ment d
www.e l adpracticalelectronics
vice on isplay Jul 20
lectro electro decod 24 £5
npubli nics re ers .99
shing pair
.com s 07
@prac 9 772
ticale
632 5
73030
lec
practi
calele
ctronic
s
You read that right! We now sell the current issue of your favourite electronics
magazine for exactly the same price as in the High Street, but we deliver it
straight to your door – and for UK addresses we pay the postage. No need to
journey into town to queue outside the newsagent. Just go to our website, set
up an account in 30 seconds, order your magazine and we’ll do the rest.
www.electronpublishing.com