Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
37 views76 pages

May24 Int

The May 2024 issue of Practical Electronics features various projects including a GPS-Disciplined Oscillator, a Dual RF Amplifier, and a UV Sensor, along with a beginner's project called Songbird. It also includes articles on digital signal processing, electric cars, and a new Teach-In series focused on the ESP32 microcontroller. The magazine offers insights into electronics and computing, with a focus on practical applications and projects for enthusiasts.

Uploaded by

navaltronica
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views76 pages

May24 Int

The May 2024 issue of Practical Electronics features various projects including a GPS-Disciplined Oscillator, a Dual RF Amplifier, and a UV Sensor, along with a beginner's project called Songbird. It also includes articles on digital signal processing, electric cars, and a new Teach-In series focused on the ESP32 microcontroller. The magazine offers insights into electronics and computing, with a focus on practical applications and projects for enthusiasts.

Uploaded by

navaltronica
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 76

Practical

Electronics
The UK’s premier electronics and computing maker magazine
Circuit Surgery Teach-In 2024 Audio Out
Topics in digital signal Analogue input and output with Designing
processing – sampling the ESP32 SoC microcontroller discrete buffers

Dual RF Amplifier
GPS-Disciplined
Oscillator
Mastering
the UVM-30A
UV Sensor

Teach-In 2024
Learn to use
the ESP32 Songbird: an ideal
beginner’s project
PLUS!
Techno Talk – One step closer to a dystopian abyss? May 2024 £5.99
05
Cool Beans – Arduino: 7-segment display delights
Net Work – Electric cars, Moon-shot missions and more 9 772632 573030

www.electronpublishing.com @practicalelec practicalelectronics


Sysblocks
Sysblocks
FLOWCODE
Flowcode A4 Advert EPE 25 01 24 WIP.pdf 1 31/01/2024 13:15:30

Sysblocks

Create highly functional electronic systems using PIC32 technology to


manipulate
Create analogue signals
highly functional using
electronic Flowcode
systems 10.1
using and technology
PIC32 Sysblocks. to
Fantasticsignals
manipulate analogue for digital audio
using applications.
Flowcode 10.1 and Sysblocks.
Create highly functional electronic systems using low cost hardware,
Fantastic for digital audio applications.
like ESP32 and Rpi, to create fantastic Human Machine Interfaces for
Flowcode Pro, PIC32 pack with Sysblocks board, cables and accessories bundle £610 + VAT
your projects and mobile phones.
Flowcode
Create with
highly
Flowcode PIC32 pack with Sysblocks
functional
Pro, PIC32 pack with Sysblocks board,
electronic cables and
systems
board, cables and accessories
using bundle
PIC32bundle
accessories £330 ++ VAT
technology
£610 VAT
to
manipulate
Flowcode with 10%analogue
PIC32Flowcode
packfor
off signals
withPE hobby
Sysblocks
readersusing
board,
usingFlowcode
forcables
ESP32 10.1
FREE andbundle
isPESYS10
and accessories
code: Sysblocks.
£330 + VAT
Fantastic for digital audio applications.
Flowcode Pro with ESP32 pack £340 +VAT
10% off for PE readers using code: PESYS10
Flowcode 10.1 with more than 20 microcontroller targets including
Flowcode 10%pack
Pro,Uno,
PIC32 offwith
for Sysblocks
PE readers using
board, code:
cablesis
and WEB10
accessories bundle £610 + VAT
Arduino PIC18877, RPI2B, and ESP32
Flowcode 10.1 with more than 20 microcontroller targetsnow free for hobbyists.
including
Flowcode with PIC32 pack with Sysblocks board, cables and accessories bundle £330 + VAT
Arduino Uno, PIC18877, RPI2B, and ESP32 is now free for hobbyists.
Flowcode 10.1 with more than 20 microcontroller targets including
+44 (0) 10% off 252
for PE readers using code: PESYS10
[email protected]
Arduino Uno,1422
PIC18877, 380RPI2B, and ESP32 is now free for hobbyists.
+44 (0) 1422 252 380 [email protected]
www.flowcode.co.uk
Flowcode 10.1 with more than 20 microcontroller targets including
+44 (0) 1422www.flowcode.co.uk
252 380 [email protected]
Arduino Uno, PIC18877, RPI2B, and ESP32 is now free for hobbyists.
www.flowcode.co.uk
+44 (0) 1422 252 380 [email protected]

www.flowcode.co.uk
Practical
Volume 53. No. 5
May 2024
ISSN 2632 573X

Electronics Contents
Projects and Circuits
GPS-Disciplined Oscillator by Alan Cashin 16
This GPS-Disciplined Oscillator is mostly built in software, so it only requires a PIC,
an oven-conditioned crystal oscillator and a few other supporting parts. It provides an
extremely accurate 10MHz signal with an error in the parts per billion range.
Dual RF Amplifier by Charles Kosina 26
This small RF amplifier has two outputs with individually selectable gains. This makes
it suitable to add to a signal generator to provide a higher output level, or for better
drive strength, or ‘fanning it out’ to multiple other pieces of equipment and more.
UVM-30A Module Ultraviolet Light Sensor by Jim Rowe 29
This UV light-sensing ‘breakout’ module detects the intensity of UV solar radiation and
hence the degree of protection you may need to prevent skin damage. If you connect it
to an Arduino or other microcontroller, it can even indicate the current ‘UV Index’.
Songbird by Andrew Woodfield 33
Here’s a decades-old design brought up to date in a new package and made to appeal
to beginners as well as experienced builders. It’s quick and easy to build and a great
project if you’re new to electronics.

Series, Features and Columns


Techno Talk by Max The Magnificent 8
One step closer to a dystopian abyss?
Net Work by Alan Winstanley 9
Reports on an environment monitor and Tapo smart sensors; news of forthcoming
(expensive!) electric cars from Lotus; plus a roundup of current Moon-shot missions.
The Fox Report by Barry Fox 14
Cloning drives the easy way, plus more news on scams
NEW SERIES!
Teach-In 2024 – Learn electronics with the ESP32 by Mike Tooley 40
Part 3 – Analogue input and output
Max’s Cool Beans by Max The Magnificent 50
Arduino Bootcamp – Part 17
Audio Out by Jake Rothman 58
Back to the buffers – Part 4
Circuit Surgery by Ian Bell 63
Topics in digital signal processing – sampling

Regulars and Services


Wireless for the Warrior 2
Subscribe to Practical Electronics and save money 4
NEW! Practical Electronics back issues DOWNLOADS – 2022 now available! 6
Reader services – Editorial and Advertising Departments 7
Editorial 7
Welcome to May!... Topics in Digital Signal Processing
Teach-In bundle – what a bargain! 25
PE Teach-In 9 32
PE Teach-In 8 56
Made in the UK. PCBs for Practical Electronics projects
Written in Britain, Australia, Practical Electronics PCB Service 68
the US and Ireland. Classified ads and Advertiser index 71
Read everywhere. Next month! – highlights of our next issue of Practical Electronics 72
© Electron Publishing Limited 2024
Copyright in all drawings, photographs, articles,
technical designs, software and intellectual property
published in Practical Electronics is fully protected,
and reproduction or imitation in whole or in part are
expressly forbidden.
The June 2024 issue of Practical Electronics will be
published on Thursday, 2 May 2024 – see page 72.

Practical Electronics | May | 2024 1


WIRELESS FOR
THE WARRIOR
by LOUIS MEULSTEE
THE DEFINITIVE TECHNICAL HISTORY OF RADIO
COMMUNICATION EQUIPMENT IN THE BRITISH ARMY

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.

ORDER YOURS TODAY!


JUST CALL 01202 880299 OR VISIT www.electronpublishing.com
All prices include 20% VAT. Free UK mainland delivery on orders over £60.
Quasar Electronics Limited Postage & Packing Options (Up to 1Kg gross weight): UK Standard 2-5 Day
PO Box 6935, Bishops Stortford Delivery - £4.95 : UK Mainland Next Day Delivery - £9.95 : Please order online
CM23 4WP, United Kingdom if you reside outside the UK (our website will calculate postage for you).
Payment: We accept all major credit/debit cards. Make UK cheques/PO’s
payable to Quasar Electronics Limited and include P&P detailed above.
Tel: 01279 467799 !! Order online for reduced price postage and fast despatch !!
E-mail: [email protected] Please visit our online shop now for full details of over 1000 electronic kits,
Web: quasarelectronics.co.uk projects, modules and publications. Discounts for bulk quantities.

Solutions for Home, Education & Industry Since 1993

NEW! Mr Robot Kit Digitally Controlled FM Radio Kit


A fun, wearable electronic Build your
gadget that you can pin to your own mod-
clothes. Easy to solder begin- ern, high
ners kit. Two flashing bicolour quality FM
LEDs resemble the eyes. 65 x receiver
40 x 15 mm. CR2032 battery project with
powered (not included). excellent
Order Code: WSL108 - 6.68 sensitivity
powered
LED Electronic Dice Kit by a simple
Still popular! A must-build 9V PP3
soldering kit for all beginners. battery (not included. Auto-seeking button. 4
Dice slowly rolls to stop on a station presets. Volume control. Excellent
Great Brands - Official Main Dealer random number when the learning project for schools and colleges.
push button is released. 9V Order Code: WSAH194 - £20.39
battery (not included). Ideal
Electronic Kits & Modules for educational courses. Wide Audio Analyser Display Kit
We have a massive selection of self- selection of component types.
assembly electronic kits and pre- Order Code: MK109 - £7.08
assembled modules. Please see the full
range on our website or call for details. 3 Channel RGB LED Light Organ Kit

LED Buddy / LED Tester Kit


Hold any
type of
LED to Small, compact LCD display, ideal for panel
the con- mounting. Give your homemade audio gear
tact pads 3 outputs react to different sound frequen- a high-tech look. Upgrade existing equip-
to see it's cies. On-board microphone picks up sur- ment. Provides Peak Power, RMS Power,
polarity, rounding sound or music and drives the low, Mean dB, Peak dB, Linear Audio Spectrum
forward voltage & the recommended series mid & high frequency outputs. Connect 12- And 1/3 Octave Audio Spectrum. Auto /
resistor value. Adjustable target current & 24Vdc RGB or separate colour LED strips or Manual range selection. Peak-hold function.
forward voltage. Great design aid. LEDs (not included). Master & separate Speaker impedance selection.
Order Code: WSMI198 - £16.66 channel sensitivity adjustment. 1.25 A max. Order Code: K8098 - £38.39
per channel. Panel mountable facia 127 x
12-in-1 Solar Hydraulic Construction Kit 44mm. Terminal block or jack power supply Electronic Component Tester Kit
Solar & hydraulic connection. Control knobs included. Build your
powered robot Order Code: WSL209 - £14.10 own versa-
can be trans- tile compo-
formed into twelve Signal Generator Kit nent test-
different animals Sine wave, triangle, square er. Shows
and mechanical wave and integrator value and
robots (monkey, (selectable through jumper) pin layout
T-Rex, scorpion, with 0 - 100Vrms adjustable infor-
excavator, etc). Moves easily. Provides great output level. 1kHz (approx.) mation for
interaction with kids. Teaches the benefit of fixed signal frequency. 9V resistors
alternative energy. Aged 14+. battery (not included). (0.1 Ohm
Order Code: KSR17 - £29.95. Order Code: resolution,
WSAH105 - £6.12 max. 50M Ohm), coils (0.01mH - 20H), ca-
Stereo Ultrasonic Bat Detector Kit pacitors (28p - 100mF), diodes, BJT, JFET,
Bidirectional DC Motor Speed Controller E-IGBT, D-IGBT, E-MOS & D-MOS.
Control the Order Code: WSMI8115 - £44.15
speed of most
common DC LCD Oscilloscope Educational Kit
motors (rated Build your own
up to LCD oscillo-
28Vdc/5A) scope with this
from fully OFF exciting new
to fully ON in kit. Learn how
both direc- to read signals.
Educational & fun kit converts high frequen- tions. Single potentiometer controls speed & See the elec-
cy sounds (20 - 90kHz) normally impercepti- direction. Screw terminal block connectors. tronic signals
ble to humans like bat signals into audible PCB: 90x42mm. Not suitable for use with you learn about
noise. Can also help detect failures in ma- lead acid batteries! displayed on your own LCD oscilloscope.
chines, engines, etc. Stereo feature adds the Kit Order Code: 3166KT - £19.96 Despite the low cost, this oscilloscope kit
possibility to pinpoint the source. Frequency Assembled Order Code: AS3166 - £29.95 has a lot of features found on expensive
range 20-90kHz. 3.5mm jack output. units like signal markers, frequency, dB, true
129x60x40mm. Requires 3x AA batteries RMS readouts and more. A powerful auto-
and stereo headphones (not included). Card Sales setup function will get you going in a flash!
Order Code: WSAK8118 - £20.39 & Enquiries Order Code: WSEDU08 - £48.54
Practical
Electronics
UK readers SAVE £1 on every issue

SUBSCRIBE NOW! Practical


Electronics
The UK’s premier electronics and computing maker magazine
Practical
Electronics
The UK’s premier electronics and computing maker magazine
Practical
Electronics
The UK’s premier electronics and computing maker magazine
Practical
Electronics
The UK’s premier electronics and computing maker magazine
Practical
Electronics
The UK’s premier electronics and computing maker magazine

01202 087631
Circuit Surgery MitchElectronics Audio Out Circuit Surgery MitchElectronics Audio Out Circuit Surgery Teach-In 2024 Audio Out Circuit Surgery Teach-In 2024 Audio Out Circuit Surgery Teach-In 2024 Audio Out
Mixing and tuning in the Our new series on electronics Discrete op amp Demodulation in the Our new series on electronics Designing LTspice 17.1 and Frequency A new series on learning electronics Designing LTspice 24 update and Digital input and output with Designing Topics in digital signal Analogue input and output with Designing
superheterodyne receiver basics for beginners: using the 555 update superheterodyne receiver basics for beginners: op amps discrete buffers Response Analysis with the ESP32 SoC microcontroller discrete buffers Frequency Response Analysis the ESP32 SoC microcontroller discrete buffers processing – sampling the ESP32 SoC microcontroller discrete buffers

Raspberry Pi Pico Digital


W BackPack WIN! Tame the Volume Control
Microchip
PIC-IoT WG current surge! Potentiometer
Development
Board Active Mains
WIN!
Soft Starter WIN!
Microchip
PIC32MK MCJ
Curiosity Pro
Development
‘Swiss Army Knife’ Dual RF Amplifier
Advanc Building the Active Board GPS-Disciplined
WIN! ed SM Basic RF Automated Test Bench Oscillator
Microchip D Test Mains Soft Starter
Check quality factor PIC-IoT WA
Superb Active Tweeze Signal
Development rs Mastering
with our Q Meter
Board
WIN! Subwoofer Generator WIN!
the UVM-30A
Teach-In 2024 Microchip
Explorer 8

Learn to use the ESP32


Development UV Sensor
MitchElectronics Superb Active Kit
WIN!
New learning series! Subwoofer MitchElectronics
555/4017 circuits New learning series! Teach-In 2024 Teach-In 2024
Op amps Advanced SMD Learn to use Silicon Chirp Learn to use
and sensors Test Tweeze the ESP32 Build your own the ESP32 Songbird: an ideal
rs
pet cricket beginner’s project
PLUS! PLUS! PLUS! PLUS! PLUS!
Jan 2024 £5.99 Feb 2024 £5.99 Mar 2024 £5.99 Techno Talk – Wait! What? Really? Apr 2024 £5.99 May 2024 £5.99
Techno Talk – Oscillating onions, Batman!? 01
Techno Talk – Cheeky chiplets 02
Techno Talk – The Wibbly-Wobbly World of Quantum 03 04 Techno Talk – One step closer to a dystopian abyss? 05
Cool Beans – Arduino: switching with transistors Cool Beans – Arduino: ultrasound adventures Cool Beans – Arduino: expanding breadboard designs Cool Beans – Arduino: expanding the 7-segment display Cool Beans – Arduino: 7-segment display delights
Net Work – Celebrating the magnificent UK mains plug! 9 772632 573030
Net Work – Cheap and cheerful workshop tools 9 772632 573030
Net Work – Cookies, privacy and online advertising 9 772632 573030 Net Work – Label printers, smart home devices and SMRs 9 772632 573030
Net Work – Electric cars, Moon-shot missions and more 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.

Overseas rates represent exceptional value


You also: • Avoid any cover price increase for the duration of your subscription
• Get your magazine delivered to your door each month
• Guarantee a copy, even if your local newsagent sells out
Order by: • Phone or post with a cheque, postal order or credit card
• Or order online at: www.electronpublishing.com

Practical SUBSCRIPTION ORDER FORM


 6 Months:.UK £33.99, Europe £38.99 (Airmail),

Electronics
Rest of the World £46.99 (Airmail)
 1 Year: UK £59.99, Europe £69.99 (Airmail),
Rest of the World £84.99 (Airmail)

SUBSCRIPTION PRICES  2 Years: UK £114.99, Europe £129.99 (Airmail),


Rest of the World £164.99 (Airmail)
Subscriptions for delivery direct to any address in: To: Practical Electronics Subscriptions
PO Box 6337
UK: 6-months £33.99, 12-months £59.99, 24-months £114.99 Bournemouth BH1 9EH
Europe Airmail: 6-months £38.99, 12-months £69.99, United Kingdom
24-months £129.99 Tel: 01202 087631
Email: [email protected]
Rest Of The World Airmail: 6-months £46.99, 12-months
£84.99, 24-months £164.99 I enclose payment of £ ..............
(cheque/PO in £ sterling only)
Cheques (in £ sterling only) payable to Practical Electronics payable to Practical Electronics
and sent to: Practical Electronics Subscriptions, PO Box 6337,
 Please charge my Visa/Mastercard
Bournemouth BH1 9EH, United Kingdom
My card number is: .......................................................................
Tel: 01202 087631 Please print clearly, and check that you have the number correct
Email: [email protected]
Card Security Code .................. Valid From Date........................
Also via our online shop at: www.electronpublishing.com (The last 3 digits on or just under the signature strip)

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

Post code .................................. Tel. ...........................................


DIGITAL SUBSCRIPTIONS
Electronic subscriptions are available from £29.99 for 12 months, Email ............................................................................................
more details at: www.electronpublishing.com Subscriptions start with the next available issue.

4 Practical Electronics | May | 2024


Subscribe to The VERY BEST DIY
Projects!
MAY 2023
ISSN 1030-2662

9 771030 266001
$1150* NZ $1290
05

INC GST
INC GST

Melbourne Exhibition Centre,


May 10-11

Australia’s
International Airsho
All the newest tech
in Avalon Airpor
w
t

Australia’s top electronics magazine


Silicon Chip is one of the best DIY electronics magazines in the Published in
world. Each month is filled with a variety of projects that you can build Silicon Chip
yourself, along with features on a wide range of topics from in-depth
electronics articles to general tech overviews.

Print Combined Online


$100 $110 $50
The History of Computer
6 months ≈₤53 ≈₤59 ≈₤27 Memory; Jan-Feb 2023
≈€62 ≈€68 ≈€31
$195 $215 $95
1 year ≈₤105 ≈₤115 ≈₤51
≈€120 ≈€132 ≈€58
Raspberry Pi Pico W
$380 $415 $185 BackPack; January 2023
2 years ≈₤205 ≈₤223 ≈₤100
≈€234 ≈€255 ≈€114

• 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

To start your subscription go to


siliconchip.com.au/Shop/Subscribe
DOWNLOAD YOUR PE/EPE BACK ISSUES
COMPLETE-YEAR collections – all 12 issues for each year!
From just £5.95 each
VOL 28 – January to December 1999 – £5.95 VOL 40 – January to December 2011 – £12.95
VOL 29 – January to December 2000 – £6.95 VOL 41 – January to December 2012 – £14.95
VOL 30 – January to December 2001 – £7.95 VOL 42 – January to December 2013 – £15.95
VOL 31 – January to December 2002 – £7.95 VOL 43 – January to December 2014 – £16.95
VOL 32 – January to December 2003 – £7.95 VOL 44 – January to December 2015 – £17.95
VOL 33 – January to December 2004 – £7.95 VOL 45 – January to December 2016 – £19.95
VOL 34 – January to December 2005 – £8.95 VOL 46 – January to December 2017 – £22.95
VOL 35 – January to December 2006 – £8.95 VOL 47 – January to December 2018 – £27.95
VOL 36 – January to December 2007 – £8.95 VOL 48 – January to December 2019 – £27.95
VOL 37 – January to December 2008 – £8.95 VOL 49 – January to December 2020 – £29.95
VOL 38 – January to December 2009 – £10.95 VOL 50 – January to December 2021 – £32.95
VOL 39 – January to December 2010 – £11.95 VOL 51 – January to December 2022 – £34.95 – NEW!

FIVE-YEAR collections – 60 issues!


From just £14.95 each
PE2832: Jan 99 to Dec 03 – £14.95 PE3842: Jan 09 to Dec 13 – £33.95
PE2933: Jan 00 to Dec 04 – £14.95 PE3943: Jan 10 to Dec 14 – £33.95
PE3034: Jan 01 to Dec 05 – £14.95 PE4044: Jan 11 to Dec 15 – £33.95
PE3135: Jan 02 to Dec 06 – £14.95 PE4145: Jan 12 to Dec 16 – £35.95
PE3236: Jan 03 to Dec 07 – £14.95 PE4246: Jan 13 to Dec 17 – £37.95
PE3337: Jan 04 to Dec 08 – £14.95 PE4347: Jan 14 to Dec 18 – £38.95
PE3438: Jan 05 to Dec 09 – £19.95 PE4448: Jan 15 to Dec 19 – £39.95
PE3539: Jan 06 to Dec 10 – £25.95 PE4549: Jan 16 to Dec 20 – £42.95
PE3640: Jan 07 to Dec 11 – £25.95 PE4650: Jan 17 to Dec 21 – £44.95 – NEW!
PE3741: Jan 08 to Dec 12 – £25.95

20 YEARS OF PE! PE2832: Jan 99 to Dec 03


PLUS!
AMAZING BUNDLE OFFER PE3337: Jan 04 to Dec 08
Every issue from 1999 – 2018 PLUS!

240 magazines for just


PE3842: Jan 09 to Dec 13
PLUS!
£59.95 PE3447: Jan 14 to Dec 18

Do you have the 15-year bundle?


Upgrade to the new 20-year bundle for just £14.95 with: PE15to20

Download your collections at: www.electronpublishing.com


Practical
Volume 53. No. 5
May 2024
ISSN 2632 573X

Electronics Editorial
Editorial offices
Practical Electronics Tel 01273 777619 Welcome to May!
Electron Publishing Limited Mob 07973 518682 ‘Spring is sprung,’ well nearly, and what better way to welcome
1 Buckingham Road Fax 01202 843233
Brighton Email [email protected] in the new season than with a little inspiration from a Songbird
East Sussex BN1 3RA Web www.electronpublishing.com – in this case an electronic one. This month’s avian project is just
Advertisement offices
one of four to keep you busy with a soldering iron. Our silicon-
Practical Electronics Adverts Tel 01273 777619 based warbler is an ideal beginner’s circuit. It contains no SMDs
1 Buckingham Road Mob 07973 518682 or tricky construction techniques, and a very pleasing result can
Brighton Email [email protected]
East Sussex BN1 3RA be obtained in just a few hours of productive work. It would be
ideal for a youngster who wants to build their first electronic
Editor Matt Pulzer
General Manager Louisa Pulzer
project, ideally under supervision from someone with experience
Digital subscriptions Stewart Kearn Tel 01202 880299 of using the necessary tools.
Online Editor Alan Winstanley
Web Systems Kris Thain
Publisher Matt Pulzer For those of you with more experience, the Dual RF Amplifier
and GPS-Disciplined Oscillator (GPSDO) provide very useful
Print subscriptions
Practical Electronics Subscriptions
testbench circuits that you will likely use again and again.
PO Box 6337
Bournemouth BH1 9EH Tel 01202 087631 Last, but not least, we welcome the return of Jim Rowe’s excellent
United Kingdom Email [email protected]
overviews of cheap sensors and modules. This month, he
Technical enquiries provides a handy explanation of a low-cost UV sensor module.
We regret technical enquiries cannot be answered over the
telephone. We are unable to offer any advice on the use, purchase,
Jim is based in famously sunny Australia, so perhaps the more
repair or modification of commercial equipment or the incorporation cynical among you may well wonder why we should worry about
or modification of designs published in the magazine. We cannot UV in the famously less sunny (cloudy) UK. Well, I checked with
provide data or answer queries on articles or projects that are
more than five years old. the UK’s Met Office and UV can certainly be a problem in Britain,
especially for those with fairer skins, so I think it is well worth
Questions about articles or projects should be sent to the editor
by email: [email protected]
learning to use this module – wherever you are based!

Projects and circuits Topics in Digital Signal Processing


All reasonable precautions are taken to ensure that the advice and
data given to readers is reliable. We cannot, however, guarantee All of this month’s columns are excellent, but perhaps the one
it and we cannot accept legal responsibility for it. I am most excited about is the start of a new series by Ian Bell
A number of projects and circuits published in Practical Electronics
in Circuit Surgery. Ian will be examining topics in a notoriously
employ voltages that can be lethal. You should not build, test, tricky (mathematically heavy) subject – digital signal processing,
modify or renovate any item of mains-powered equipment unless or DSP for short. We work hard at PE to avoid mathematics in
you fully understand the safety aspects involved and you use an
RCD (GFCI) adaptor. our coverage of electronics and Ian will do the same with DSP.
There may be a little ‘toe dipping’ into mathematics, but by and
Component supplies large his explanations will give insight into a very important
We do not supply electronic components or kits for building the
projects featured, these can be supplied by advertisers. We electronics subject without the intimidating algebra. Who knows,
advise readers to check that all parts are still available before perhaps his column will inspire you to go off and do your own
commencing any project in a back-dated issue.
research, adding as much mathematics as you are comfortable
Advertisements with. I know that will certainly be my approach.
Although the proprietors and staff of Practical Electronics take
reasonable precautions to protect the interests of readers by
ensuring as far as practicable that advertisements are bona fide, Matt Pulzer
the magazine and its publishers cannot give any undertakings Publisher
in respect of statements or claims made by advertisers, whether
these advertisements are printed as part of the magazine, or in
inserts. The Publishers regret that under no circumstances will
the magazine accept liability for non-receipt of goods ordered, or
for late delivery, or for faults in manufacture.

Transmitters/bugs/telephone equipment
We advise readers that certain items of radio transmitting and
telephone equipment which may be advertised in our pages
cannot be legally used in the UK. Readers should check the law
before buying any transmitting or telephone equipment, as a fine,
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.

Practical Electronics | May | 2024 7


One step closer to a Techno Talk
dystopian abyss? Max the Magnificent

As always, we live in exciting times. Indeed, times are getting more exciting by the minute.
Can you imagine being able to simply look at something, ask a question, and receive a spoken
answer from an AI? I just saw such a system in action!

I
n my previous column (PE, April This comprised only 34 lines of code, I am confident it won’t be long before
2024), we talked about the concept 20 of which were items like { and }. we are all sporting some form of MR
of mixed reality (MR), which en- Out of the 14 lines containing more ‘something or other.’ Personally, I think
compasses augmented reality (AR), meaty statements, 11 of them (that’s one of the MR interfaces intended for
diminished reality (DR), virtual reality close to 80%) had bugs, and this was daily usage that will arrive on the scene
(VR) and augmented virtuality (AV). one of my better days! sooner rather than later will look a bit
Mixed reality is exciting, but the real Prior to the introduction of LLM- like a pair of ski goggles, but I’m pre-
game-changer will come when we com- based assistants called copilots, pared to be surprised by something else.
bine it with artificial intelligence (AI), embedded software developers typi- When people tell me that they would
all boosted by the awesome data band- cally spent 20% of their time thinking have little use for an AI+MR solution, I
widths promised by mmWave 5G and 6G about the code they were poised to think back to the early 2000s when the
cellular communications. The question write, 30% of their time writing the same folks told me they had no use for
is, whether this will be a game-changer code they’d just thought about, and phones that could take pictures (‘All
for good… or the other sort. 50% of their time debugging the code I want to do with my phone is make
they’d just written. By comparison, calls’). All I can say is, ‘Look at you now!’
Where are we? 60% of today’s embedded code is auto- One of the examples I often present
A large language model (LLM) is an AI matically generated by GitHub Copilot. is being able to ask my AI+MR combo
model notable for its ability to achieve This would offer a tremendous per- a question like, ‘What was that book
general-purpose language understand- formance boost if not for the fact that I was reading a few months ago that
ing and generation. The first LLM to – since Copilot was trained on open- talked about AI and Ada Lovelace?’ I
impinge on the general public’s col- source sources – 40% of the code it can envisage the AI responding with
lective consciousness was ChatGPT. generates has bugs or security vulner- the name of the book, while the MR
Created by OpenAI, ChatGPT began to abilities. Fortunately, we have Metabob highlights its location on my bookshelf.
roam wild and free in November 2022, from Metabob (don’t ask), which is a There are several required ‘build-
which is only around 18 months ago form of copilot that identifies and ad- ing blocks’ that are starting to fall into
as I pen these words. dresses any problems introduced by place. For example, a company called
This form of Generative AI (GenAI) is humans and other AIs. Prophesee makes a teeny tiny event-
now all around us. There are AI-based based vision sensor that’s only 3mm x
writing tools (give them a few text Where are we heading? 4mm in size and consumes only 3mW
prompts and they will write your mar- There’s a famous quote: ‘It is difficult of power. Another company called
keting slogans, product descriptions, to make predictions, especially about Zinn Labs has mounted these sensors
brochures… and so on); AI-based pre- the future.’ This quote is so famous in a pair of glasses frames that are also
sentation-generation tools (give them a that no one knows who said it. It’s been equipped with an eight-megapixel for-
few text prompts and they will generate attributed to all sorts of people, from ward-looking camera, microphones,
your PowerPoint presentation for you); Mark Twain to Niels Bohr to Yogi Berra. loudspeakers, and a cellular connec-
AI-based speech-to-text transcribers Whoever did say this knew what they tion to a cloud-based AI. The camera
(give them an audio or video file and were talking about. I would never have captures the scene while the sensors
they will return the written transcript); predicted many of the technologies we track what your eyes are looking at.
AI-based content summarisers (give enjoy today. Contrariwise, some of the I’ve seen a demo where the user looks
them an audio or video file – or the out- technologies I was looking forward to at something like a plant and simply
put from a transcriber – and they will seeing have failed to materialise (in asks a question like, ‘Can I grow this
return a summary along with a list of more ways than one). plant indoors?’ The AI immediately
action items); text-to-image generators One of the questions I often ask tech- responds, ‘Yes, but it requires bright
(I’m currently having a lot of fun with nologists when I’m interviewing them light, so you’ll need to place it near a
Stable Fusion), and – most recently is, ‘Will we have technology XYZ next south-facing window.’
– a company called DeepMotion an- year?’ (where XYZ is whatever futur-
nounced a text-to-3D-animation tool istic technology forms the topic of our Horns and swords
called SayMotion. conversation). Of course, they always I feel like we are sitting on the horns of
In my case, I’m particularly interested answer ‘No.’ My next question is, ‘Will a dilemma with a Sword of Damocles
in how AI might help with hardware we have this technology in 100 years’ hanging over our heads (I never meta-
design and software development. As a time?’ To this, they always respond phor I didn’t like). I hope we’re heading
case in point, shortly before I started to ‘Yes.’ Then I say: ‘So, now we have the toward an age of wonder; I fear we’re
write this column, I whipped up a tiny endpoints, all we need to do is narrow one step closer to a dystopian abyss.
test program to run on an Arduino Uno. things down a little.’ Pass me my dried frog pills.

8 Practical Electronics | May | 2024


Net Work
Alan Winstanley
Our monthly column of trends and news tries out an environment monitor and more Tapo smart
sensors; there’s news of forthcoming (expensive!) electric cars from Lotus; a roundup of current
Moon-shot missions and more besides.

L
ast month, the author tried out the and cheerful, of the sort that domestic
Chinese online vendor Temu for the mail order distributors would drop into
first time, after finally succumbing a polybag along with a display header
to an introductory offer of a heavily card and then quadruple the selling
discounted Bluetooth thermal label price. Apart from handy little doo-
printer. Initial impressions of the service dads and knick-knacks, it wasn’t long
were encouraging, and it wasn’t too long before I found enough of interest to fill
before more Temu orders were on the way. a couple more orders. This included
It must be said that Temu’s website a 6-in-1 environment monitor that is
impresses in many respects, and clearly widely advertised online, which displays
Temu has gone to some lengths to reassure Formaldehyde (HCHO), PM2.5 and
consumers and remove any nagging PM10 (2.5- and 10-micron particulate
doubts and uncertainty that potential matter), TVOC (total volatile organic
buyers might have about sourcing compounds) as well as CO and CO2 levels.
goods directly from China. A myriad The unit is self-contained, powered by a
of merchandise is on sale and website rechargeable battery and data is displayed
users will see a slick shopping cart and on a colour LED. Although I didn’t have
seamless integration with credit card high expectations of it, and a minority of
processing, highlighting an emphasis on reviews had been unfavourable, I decided
PCI DSS (Payment Card Industry Data it was worth a try at the offer price of £21
Security Standard) compliance –Western- (£35-40 elsewhere) and one duly arrived
This 6-in-1 environmental monitor is
standard data protection conditions that on my doorstep a week or so later.
designed for domestic users and offers
vendors must follow when handling If nothing else, it’s interesting to try a digital readout of six factors. Readings
credit and debit card details. Options sampling the air for pollutants in domestic shown when located in a busy kitchen.
to cancel orders, or add to existing ones situations, and when testing the monitor
before despatch, are also offered provided I did sometimes notice large changes in, environment. Obviously, the monitor
you’re quick enough. Everyone hates say, the kitchen when various cooking is designed for domestic use and is for
buying something only to see the price appliances were in full swing. I also noted guidance only; there’s no way of checking
drop soon afterwards, so Temu’s ‘Price PM2.5 and PM10 readings that were calibration or its accuracy, but it is what
Adjustment’ policy promises to refund the broadly within the targets for particulate it is and, given the low price, I didn’t
difference within 30 days. In Britain, the matter published by the UK Government: mind giving it a go.
Evri courier network is used by Temu for https://bit.ly/pe-may24-pm Overall, first impressions of Temu
the last mile in home deliveries, and my Perhaps my rural location helps have been surprisingly encouraging,
first orders arrived flawlessly in a matter with air quality, and city dwellers may and there have been no quality issues
of days; a credit is offered if deliveries measure entirely different levels in their either, though I could do without those
don’t arrive by the promised date.
It’s been hard to fault the service offered
so far, and naturally the Temu app on
a smartphone makes shopping more
effortless than ever. One downside is
the blizzard of emails that are sent by
Temu and Evri giving order updates,
tracking and delivery details, and
customers can expect to see regular
pop-up notifications with enticing offers
and discounts tempting them to buy even
more. The Temu website exhibits many
‘dark pattern’ behaviours (see Net Work,
June 2023) that track your browsing or
shopping patterns and nag you to buy
now, before it’s too late.

Chinese whispers
Much of the Chinese-made merchandise The Tapo Smart Button S200 is an entry-level gadget to switch or dim compatible
offered by Temu I would class as cheap smart devices. The author had mixed success (see text).

Practical Electronics | May | 2024 9


The button can be configured to control when caring for the elderly, but other
other compatible devices, or perform dedicated options are available that are
an action like sounding a chime on the probably better suited to this purpose.
plug-in hub. After a false start or two, Integration with an Alexa skill I found
I managed to switch a couple of Tapo seamless but, annoyingly, Alexa isn’t
smart lights on or off using a single button always totally responsive.
press. In theory, the colour or brilliance To round off my feature on the Tapo
of a multicoloured LED smart lamp could range, I also tried the ‘Smart Water Leak
be changed by spinning the button, but Sensor’ (T300), which is another low-cost
this concept didn’t work very well on my device that requires the Tapo H100 hub.
own network, as the hesitant and ‘stuttery’ It felt a bit more substantial and could
response often caused it to either lag or be used near water tanks, a washing
‘overshoot’. I soon abandoned that idea machine or underneath a sink or shower
as a non-starter. tray. The underside carries two pairs of
Tapo’s Smart Water Leak Sensor (T300) A non-slip pad (supplied) can be stuck detector studs but, unlike many water leak
detects water leaks and drips, is rated underneath, presumably to stop it moving alarms, the top is slightly dished and it
IP67 and also has a built-in switchable around when the button is operated. On has two more studs that can sense drips
90dB piezo sounder.
a clean glass tabletop the button was too from above. After one or two attempts
nagging pop-ups appearing on my phone. light (40g) and the non-skid base didn’t at adding the device in the Tapo app, I
You can visit temu.com or download the hold it securely, making it impossible configured it to sound an alarm on the
app through your usual app store. The to turn the knob in a standalone mode. hub, and the sensor also has its own built-
rule of caveat emptor applies, but you Due to the button’s wobbly micro- in switchable 90dB alarm; you can also
might still find those introductory one- travel operation I found it too easy to link it to other smart actions. The T300
off offers irresistible! accidentally nudge it on the tabletop water leak sensor uses two AAA cells in a
and activate a smart action. However, gasket-sealed compartment and a battery
Testing Tapo its built-in magnet allows attachment life of three years or more is claimed.
As regular readers will recall, I’ve been to a metallic surface, where it is held Overall, the budget Tapo range is
testing out some entry-level smart devices securely, and I found the button could aimed at domestic entry-level users,
marketed by TP-Link under the Tapo be pressed or rotated without a problem. and the app is very user-friendly but
brand. In April’s issue I outlined the TP-Link includes a hefty metal disc and set-up was sometimes a case of ‘getting
Tapo H100 Smart Hub with Chime, a hardware that can be screwed or stuck there in the end’. These smart sensors are
plug-in unit that resides in a mains outlet on to a non-metallic surface – this was available from the usual online sources,
and connects through its own 868MHz a much more secure option. Battery remembering that a smart hub H100 or
(UK) wireless network to a range of replacement is a bit fiddly, using the H200 is also required.
smart devices such as contact sensors, tiny mystery plastic shim supplied to
a temperature/humidity detector and undo the coin cell hatch. Expect a one- Lotus blossoms
a PIR sensor. The Tapo app controls year battery life or longer. Looking at the year-to-date sales figures
events and so-called ‘smart actions’ can Last month, I mentioned a 3D-printed provided by Britain’s Society of Motor
be triggered when activated by a sensor. holder made by an eBay seller to use the Manufacturers and Traders (SMMT), we
Since writing last month’s column Smart Button as a doorbell in a sheltered see that battery electric vehicles (BEVs)
I’ve tried a Tapo Smart Button (S200B) location, advising that the button is not accounted for just 15% of the market,
which enables manual control of Tapo weatherproof and it could also be removed meaning the remaining 85% of vehicles
smart devices, either by a single or double by anyone else ‘in the know’. A wall- sold so far this year still have petrol
tap, or by turning the button instead. mounting version (S200D) is designed as or diesel engines in them. Petrol cars
The wobbly plastic button is just over a smart remote dimmer switch, but based still took nearly 60% of the market and
40mm diameter and contains a 3V coin on my own trials I personally wouldn’t hybrids of all types have accounted for
cell. Set-up is handled by following invest in it. Apart from offering a basic about 21% so far this year.
the instruction in the app, which was on-off control, the Smart Button may also Depending on who you ask, a hybrid
straightforward enough. find a use as a nurse-call chime, perhaps car might offer 50 or 60 miles on electric

1551W IP68 miniature enclosures


Learn more: hammondmfg.com/1551w

[email protected]
01256 812812

10 Practical Electronics | May | 2024


drive, which is handy for buzzing
around town, but a whole new driving
technique is needed to get the best out
of these petrol-electric hybrid vehicles.
The development of EVs in China is so
intense that it’s becoming impossible
to keep up with trends. Waiting in the
wings are yet more Chinese-made cars
carrying British brands, including MG
and Lotus. The latter was famed for
its British-made sports cars: remember
Tesla’s first Roadster electric car was
based on a Lotus Elise way back in 2006,
and Elon Musk launched ‘Starman’ into
space in 2018, where the car is still
flying through space at 8,000 mph, see: The new Chinese-backed Lotus Eletre EV is a snip at £90,000 to £150,000!
www.whereisroadster.com
Now owned by China’s Geely, Lotus dominated by a touchscreen. Apart from slight tremor in my hand which makes
is preparing to unleash an entirely new anything else, manufacturers can update touch screens difficult to use, but the
range of electric vehicles in the UK and controls or debug them just by flashing worse thing is that they don’t work at
Europe. From the outside, the new Lotus new software upgrades, but opinions all with a gloved hand. Long live the
Eletre ‘hyper SUV’ (£90,000-£150,000) about the usability and safety of electric mechanical switch!’
looks indistinguishable from many other vehicle touch panels are very mixed. Not I mentioned in December 2023’s Net
Chinese electric or hybrid cars – it seems everyone is enamoured with the idea of Work how, by chance, I rediscovered my
to me – while the new Emeya is a four- tapping away at a touchscreen to control family’s 1976 Opel Ascona saloon, a car
door GT sportscar that claims to be one their vehicle, and there are increasing bought brand new at a time when your
of the fastest electric GTs in the world, concerns about the problems of drivers’ scribe trundled along to attend evening
achieving 0-62mph in under 2.8 seconds. attention being distracted by the need to classes as a teenager. The car is now an
Happily, British sportscar manufacturing navigate through a touchscreen menu exhibition showpiece and I was thrilled
will continue with the very attractive rather than simply reaching out to press to sit in it once again. The Opel’s controls
new Lotus Emira mid-engine sportscar a button or turn a knob. were dead easy: for example, the heater
(£60k+) due soon. The Lotus website is A spin in a Honda e:Ny1 electric car had up/down and hot/cold, and a simple
enough to make anyone dizzy, but you (see March 2024, Net Work) told me knob controlled the fan speed. Pulling the
can see more of their new electric and all I wanted to know: I found it hard knob out turned on the heated rear screen.
petrol cars at: lotuscars.com enough as a passenger just to switch The mains point is that all this could be
Geely has also partnered with Mercedes- off the heated seats, and as we bumped done by ‘feel’ while I paid attention to
Benz to produce premium EVs under the along some country lanes I struggled to my driving and pondered my homework.
‘Smart’ brand. Distinctive little petrol- register a fingertip with a little icon on
powered ‘Smart’ cars have carved their the impressively large screen, not helped Touchy feely...
own niche on Britain’s roads, and a new by the lack of any haptic feedback. Nowadays it seems that EV manufacturers
electric ‘Smart #1’ compact SUV has now Net Work reader Stephen Horsman are at last getting the message about the
launched as a premium vehicle costing sympathises. Steve writes: ‘I’ve not long way touchscreens are becoming too
£36,000 on the road. Like every other ago had a new VW Tiago with a touch distracting and unsafe for drivers. The
electric vehicle, the Smart #1 dashboard is screen infotainment centre. I have a Euro New Car Assessment Programme

The Smart #1car’s interior has a flat control panel dominating The Smart brand is best known for its quirky little petrol cars and
the dashboard. the new Smart #1 is a compact SUV for the EV market.

Practical Electronics | May | 2024 11


(Euro NCAP) is the test body that awards
new cars a safety star rating, and makers
clamour to receive a coveted 5-star award.
Euro NCAP has finally recognised that
confusing and complicated touchscreens
can cause drivers to take their eyes off
the road for too long so, if car makers
want to earn a 5-star rating, then from
2026 some key functions will have to be
controlled by classic switches and knobs
instead. Interestingly, Mazda Cars eschews
altogether the use of large touchscreens
and retains ordinary knobs and switches
instead, an idea that may appeal to many
motorists seeking to upgrade without
tussling with touch controls.
EV drivers currently face plenty more
SLIM pickings: image of the Lunar surface taken and transmitted by LEV-2 (Image ©
practical problems, including punitive
JAXA/TOMY/Sony Group Corporation/Doshisha University.)
insurance costs and difficulties waiting
for spares or costly repairs while Chinese
EV brands get to grips with selling into transported courtesy of Elysium Space kg, communicated directly with Earth
the UK market. An excellent piece in Auto (qv) and other plaques and mementoes from the Moon, and is considered to be
Express highlights these problems, with from around the world, destined for the world’s smallest and lightest example
a BYD Seal proving almost uninsurable, commemoration on the Moon. Russia had of direct data transmission from a distance
they found, while GWM Ora was heavily tried to land its Luna-25 at the Moon’s of some 380,000km. LEV-2 managed to
criticised for a lack of spares. Major South Pole the previous August, but the take a snapshot of the stricken vehicle.
repairs that are cheaply done in China vehicle was lost during final approach. Undeterred by recent setbacks, another
are unaffordable in Britain due to UK India then accomplished a spectacular Moon-bound mission by a joint venture
labour costs (as I know myself – I was and historical South Pole landing with its between NASA and Intuitive Machines
charged £220 ($285) to fit four spark Chandrayaan-3 (Lunar Vehicle 3) lander (IM) launched in February on board a
plugs!), and EV makers apparently don’t that same month. SpaceX Falcon 9, carrying IM’s Nova-C
understand that crash repairs must Japan’s ‘Moon Sniper’ mission carrying lander named ‘Odysseus’. This time, the
restore the car back to the manufacturer’s SLIM (Smart Lander for Investigating craft did land successfully on the Moon’s
standard – the kind of information that Moon) has been designed for landing surface, but then it had the misfortune of
simply doesn’t yet exist. The picture is accurately within 100m of the target toppling over. Despite this, it was the first
one of Chinese EV makers desperately on the Moon’s surface. This mission commercial vehicle to successfully land
scrambling to ramp up after-sales service unfortunately nosedived in January – on the Moon. Odysseus closed down a
and support; the article is worth a read at: a suspected engine failure caused the few days later on the 29 February – one
https://bit.ly/pe-may24-aexp craft to land literally face down on the giant leap year for mankind.
Moon, nonetheless within 55 metres of Last, in my space news roundup,
Hard cheese its intended target. Unfortunately, this the plucky Ingenuity helicopter that
In March’s column I wrote about crippled its ability to generate power NASA’s Perseverance rover launched
independently funded endeavours to from its solar arrays, but even so, two tiny on Mars (reported three years back in
land a small craft – the Peregrine Lander robots – Lunar Excursion Vehicle (LEV-1) Net Work, May 2021), has finally run its
– on the Moon. Due to a propellant and Transformable Lunar Robot (LEV-2) course. The hovering vehicle managed
leak, the craft failed to reach orbit and – were successfully released just prior to an astonishing 72 flights on the dusty red
was forced to burn up in the Earth’s touchdown and successfully conducted planet, far more than was ever intended.
atmosphere, taking its payloads with it. some trials on the Moon’s surface. Japan’s A broken rotor blade was later spotted
As if to symbolise the frailty of our efforts, Aerospace Exploration Agency JAXA by an imaging camera on board the
the payloads included human ashes points out that LEV-1, weighing just 2.1 Perseverance. NASA’s superb website

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

www.terrington-components.co.uk | [email protected] | Tel: 01553 636999

12 Practical Electronics | May | 2024


the website you’re visiting at that time. to cash in on the book, with sophisticated
This is actually seriously affecting news generative text containing stolen keywords
media websites and the wider industry, being used to hijack ‘my’ search traffic. To
because it’s cookies that give them the be certain, I ordered copies of each one,
ability to target their advertisers’ messages totalling £150 worth.
at ‘interested’ website visitors. Adverts that Copyright infringement is a very
are irrelevant to their viewers are obviously expensive and time-consuming problem
worthless, and advertisers won’t pay if to police. As the perpetrator of this scam
wasted traffic is squandering their budgets could be located anywhere in the world,
needlessly. Consequently, the news site’s the only practical step is to alert Amazon
advertising clients will walk away, taking using the ‘Report an issue with this
their advertising revenue with them. To product’ link found on each item page,
compensate for the drop in advertising and fill in an online claim. This drudgery
income, visitors will increasingly see pay took up a whole day but, to be fair, once
walls adopted, or they’ll either pay to see a notified Amazon removed the stolen books
site or be forced to accept adverts instead. within 30 minutes.
Odysseus, a NASA/Intuitive Machines I agree that those cookie opt-in pop-ups Then I noticed similar shenanigans
craft captured this image approximately are now a major nuisance. Quite often I with certain other book titles that used
35 seconds after pitching over during can’t be bothered working through all the the same style of book covers, with false
its approach to the Moon landing site.
options given so I move on elsewhere. names. Searching for a particular title on
(Image: Intuitive Machines)
I mostly use Firefox too, and previously coding and programming threw up more
contains a wealth of resources related I’ve tried the Ghostery extension to flag up than a dozen near-identical candidates,
to their Mars missions – be sure to take trackers and block ads, but I had problems all selling at around £12 each and pirated
a look at: https://mars.nasa.gov with my browser being slowed down. I from another (as yet unknown) work.
noted more than 100+ running on some The free preview sample reveals similar
Rejected scripts web pages. You can install NoScript, as opening paragraphs. The best a third party
My thanks to regular reader David Hicklin David suggested, from https://noscript. can do is report it as counterfeit, but it’s
who writes: ‘Having just read Net Work, net and Ghostery is still available from infinitely more effective if the original
March issue and especially the bit ‘Bad https://www.ghostery.com work can be cited as evidence.
news days’, have you ever seen how many Such is the quality and scale of the scam
scripts run on a news site that come from Amazon Warrior that I suspect AI is being used to re-write
third-party websites? I use Firefox and one Amazon remains a key go-to site to book descriptions and re-submit them
of my best friends is the add-on ‘NoScript’ purchase pretty much anything under for publication using Amazon’s print-on-
and it has an absolute fit at the number of the sun, but one emerging issue is the demand service or KDP (Kindle Direct
third-party scripts that run on these sites. problem of book piracy, as I recently Publishing). So next time you’re searching
I’m attaching a sample from a local news discovered. It appears that some niche Amazon for books, watch out for similar-
site which is a typical example. I think reference books, including my own Basic looking niche titles or book covers on
these are a far bigger issue than cookies, Soldering Guide, were stolen in their Amazon – these are scammers trying to
and let’s not start about websites that give entirety and re-published using entirely cash in by stealing legitimate work. By
you the options to set the cookie settings, bogus pseudonyms. In my case, more than a the way, readers can buy the (real) Basic
maybe 75+ of them, one setting for each dozen books on soldering suddenly popped Soldering Guide handbook direct from our
external partner!’ up on sale, all the same size, style and own bookshop at an advantageous price.
Thanks for the tip-off, David. In March’s contents (mine) but with different cover That’s all for this Net Work roundup
column I explained how third-party images and authors’ names. Fortunately – see you next month!
cookies are gradually being blocked by for me, I was alerted by one book review
web browsers in favour of only allowing which included photos of me holding my The author can be reached at:
first-party ones; ie, those that originate from own soldering iron! It was a concerted effort
[email protected]

An insight produced by NoScript showing some of the All 15 of these pirated Basic Soldering Guide books were
scripts running behind the scenes on a busy news website. spotted on Amazon by the author before being removed from
(courtesy, David Hicklin.) sale. The same ruse is currently affecting other book titles.

Practical Electronics | May | 2024 13


The Fox Report
Barry Fox’s technology column

Cloning drives the easy way, plus more news on scams

D
anish electronics company Anders Partida Petersen, Brand Di- Scammer update
Sandberg (slogan ‘IT is for eve- rector at Sandberg, is realistic when he We have already warned that scammers
rybody’) makes clever and well- admits the new tool ‘may well seem like have moved on from selling fake capac-
designed gadgets with a real purpose. I something for nerds’. But I guess that ity USB memory devices that store far
recently tried Sandberg’s ‘Unusual hard term covers many of our readers! I’m fewer megabytes than claimed to SSD
drive tool’ because it makes a nice fit pretty sure computer service centres drives that store far fewer gigabytes
with our recent articles on making PCs will love it too. than claimed. Fortunately, there are
perform much better by replacing an I’ve tried it and certainly love it. I just easy-to-use free apps that test capacity.
‘old-fashioned’ spinner Hard Disk Drive wish I hadn’t previously wasted my So far, the tests have been lengthy, but
with a new SSD (Solid-State Disk). money on a multi-bay HDD dock that a newish free app plays clever tricks
To make the HDD-to-SSD replacement looks good but has corrupted some of my to shorten the test time. It randomly
you first need to clone (not simply copy) HDDs, and also on two-bay HDD docks tries to read and write data at widely
the existing operating system on the exist- which are far less use than the much spaced sections of the memory map.
ing HDD to a new and empty SSD. This neater Sandberg tool. So, it quickly fails if real capacity is
can be tricky and risky because making The USB 3.2 cloner and dock costs lower than it should be. The drive is
a mistake in the cloning process can eas- £59.99, and in addition to SATA supports then red flagged for junking or more
ily result in wipeout, with the old HDD SSD fitting types M.2, NVMe and M Key, detailed testing. For further details,
and new SSD both empty. Sandberg’s in sizes 2230 / 2240 / 2260 / 2280. see: https://bit.ly/pe-may24-drv
‘unusual’ tool makes cloning as safe and
easy as it can be; near risk-free in fact.
The same tool also makes it much easier
to work with ‘bare’ HDDs and SSDs, stor-
ing and reading data to and from discs
of both types.

Smart connector
The Sandberg tool is really just a very
smart connector strip, powered with a
separate 12V supply. The strip has SATA
and NVMe sockets for plug-in connection
to standard 2.5-inch and 3.5-inch SATA
spinner drives and SSDs of the type that
slot straight into modern computers and
peripherals. Connection of the tool to
a PC or mobile is by standard USB-A
or USB-C cable. No screwdrivers are
needed. Rather fiddly rubber plugs do
the job of screws.
Two drives, HDD and SSD, can be
connected to a computer simultaneously
or separately, with reading and writing
possible to both. But the tool also has on-
board software that lets it clone directly
from one drive to the other, without the
need to connect to a computer. A physical
switch controls the direction of cloning,
HDD to SSD or vice versa. This is what
makes wipeout mistakes far less likely.
Sandberg says that because the tool
supports USB 3.2 it’s theoretically pos-
sible to achieve transfer speeds right up
to 10 Gbps. But this will of course depend Fox tested and approved – Sandberg’s ‘Unusual hard drive tool’ makes cloning drives
on the drive specs. straightforward, easy and safe.

14 Practical Electronics | May | 2024


It now emerges that scammers are also I have already found several hubs, gift cards, for food and services like music
selling fake USB hubs. Devices that are bought online, that have blue lips but and movie streaming, from supermarket
labelled USB 3.0 or simply equipped USB 2 speeds. USB Device Tree Viewer checkout racks. They then secretly copy
with the blue lip sockets that are sup- also provides useful information on every the card validation code and put the card
posed to guarantee USB/3.0 SuperSpeed USB device that is hard-wired or plugged back in the rack. When another customer
performance, are actually USB 2.0 or 2.1. in – see: https://bit.ly/pe-may24-usb innocently buys the card and loads it with
Again, fortunately, there is a simple free credit, the crim can use the previously
test, called ‘USB Device Tree Viewer’. Card scam - not what you think! stolen code to steal the credit.
Just install the app on your computer Meanwhile, news is now breaking of a So, from now on I shall buy my cards
and plug and unplug hubs, one by one. new high street scam for which there is no only from stores that keep them securely
The app then displays which devices useful IT app cure – so self-protection is ‘behind the counter’ and thus unavailable
are 2.0, 2.1 or 3.0. the key. It seems the crims are ‘borrowing’ for ‘borrowing’.

tekkiepix pic of the month became a thing of the past, just as thread-
ing audio tape was no long necessary

U-matic video cassette recorder once Philips had launched the audio
cassette in the 1960s, and Americans
slapped 8-track cartridges in car players.
All the the proud owner of a U-matic
player had to do was ‘post’ a sealed cas-
sette into a letter-box slot, and a clever
mechanism hidden inside the player
automatically laced it round the drum.
JVC marketed U-matic recorders as
U-VCRs that plugged into a ‘regular TV’
and recorded ‘off-the-air TV programs’
under ‘full remote control’. Meanwhile,
however, JVC was working secretly on
the less expensive VHS system.
For many years, U-matic was a stan-
dard convenience tool for broadcasters,
programme makers, business teachers
and TV advert producers. Early video
U-Matics were not pretty, they just did the Early CD discs were often edited and
job, and loaded faster than open reel. mastered on U-matic systems. cinemas used U-matic tapes, and se-
curity services used them for secret

H
ere’s a good ‘pub quiz’ by professionals rather home users training videos – as one UK journalist
question for PE readers of a because of high cost and the lack of an found out to his cost when he bought
certain vintage: ‘When did the easy connection. Neverthless, U-matic some cassettes from a tech jumble
first video cassette recorders go on became a must-have trophy gadget for sale and thought the contents looked
sale, and what was the name of the well-heeled homeowners, and record- suspicious. Soon after he wrote about
manufacturer?’ Betamax, from Sony, ers were soon available with built-in them in a specialist video magazine,
in 1975? Wrong. VHS from JVC, in connectors for home TVs. promptly followed by a knock on his
1976? Wrong, again. So perhaps it was U-matic cassettes held ¾-inch tape, home door and a bunch of big men with
a bit of a trick question? rather than the 1-inch tape used for security IDs confiscated the cassettes.
Panasonic was ahead of VHS with a open-reel recorders and ½-inch tape In the early 1980s U-matic cassettes
VCR called the Quasar VX ‘The Great used by Beta, VHS and the Philips and were used to store digital audio and
Time Machine’, born 1975, but it died ‘nerve gas’ systems. But most people became the de facto standard tool
soon after – and not just because the neither knew nor cared what kind of for mastering Compact Discs (CD).
marketing team hadn’t realised that just tape was in the cassette. The cassette tape stored digital audio
about everyone associated the label ‘VX’ Until then, home video wannabees packed inside a video signal. As far as
with nerve gas. So, was that one first? had had to struggle with open spools of the U-matic recorder was concerned
Sorry, wrong again; and even though very expensive video tape that needed it was just another signal.
Dutch Philips had stolen a march on careful threading round a spinning More consumer-friendly (smaller,
the Japanese with the N1500 VCR in head drum. Touching the tape could lighter and cheaper) VHS and Beta
1972, that’s still not the right answer. spoil a recording – and anything less decks could do the same job, but U-
The first working video cassette re- than precision threading could wreck matic recorders and tapes were far
corder was the U-matic, developed by the delicate video heads. more rugged.
Sony, with Panasonic and JVC joining U-matic cassettes only ran for an hour,
in for a joint launch in 1971. but so did the Philips cassettes and the Practical Electronics is delighted to be
able to help promote Barry Fox’s project
It’s true that the first U-matic record- first Sony Betamax tapes. Sony’s boss to preserve the visual history of pre-In-
ers needed a bolt-on tuner and output Akio Morita initially saw no problem ternet electronics.
circuitry to feed into the aerial socket with this because back then most Japa- Visit www.tekkiepix.com for fascinating
of a home TV. It’s also true that the nese TV programmes only ran for an stories and a chance to support this
U-matic system was initially adopted hour anyway. Threading video tape unique online collection.

Practical Electronics | May | 2024 15


By Alan Cashin

GPS-Disciplined Oscillator
The GPS-Disciplined Oscillator
(GPSDO) is built almost entirely
in software, so it only requires
a PIC, an oven-conditioned crystal
oscillator and a few other supporting parts. It
provides an extremely accurate 10MHz signal with an
error in the parts per billion range.

T
here are a few situations This project describes a GPS-Disci- The aim of this was to create a use-
where having a very accurate fre- plined Oscillator (GPSDO) that uses ful and inexpensive GPSDO that could
quency is essential. Many pieces the 1PPS signal to adjust (discipline) deliver 10MHz into 50W with a maxi-
of test equipment, such as oscilloscopes the frequency of a 10MHz oven-condi- mum error of 0.01Hz.
and spectrum analysers, have an inter- tioned crystal oscillator (OCXO). The It is based on a cheap CTI OSC5A2B02
nal 10MHz reference that’s accurate to output is accurate to a few parts per oscillator, a PIC16F1455 microcontrol-
within a few Hz (around one part per billion (ppb) at worst, and normally ler and a 74HC04 hex CMOS inverter
million). They usually have an input 1ppb or better. running from a 5V supply.
socket for a more precise external sig- The GPS module I used was the
nal source for operating with much GNSS and GPS cheapest available, the u-blox NEO-6
higher precision. GPS refers to the constellation of nav- (possibly a clone), using an active
As people explore high and higher igation satellites launched by the US antenna with a 3m lead. There was no
operating frequencies, reference accu- government but is sometimes used to need for any display; anyone with a
racy becomes more critical. An error describe any positioning system that smartphone can see their position and
of 1 part per million (ppm) at 7MHz uses satellite data for navigation. get accurate time, so such a display is
is only 7Hz, hardly noticeable in a Last century, the only useful con- redundant. The operational status is
single-­sided band (SSB) signal). But at stellation was the GPS constellation. indicated with a single LED.
5GHz, the same error is 5kHz, enough More recently, many nations have This prototype system performed
for the signal to not be received at the launched their own satellite constel- well enough to justify creating a PCB,
expected frequency. lations, such as GLONASS (Russia), and several were built. However, it
Global Navigation Satellite System BeiDou (China) and Galileo (Europe). was overly sensitive when connected
(GNSS) satellites have accurate atomic The term ‘global navigation satel- to other equipment.
clocks onboard that are adjusted by sig- lite systems’ (GNSS) refers to all the Another problem was that I had not
nals from ground-based master clocks. available constellations. Many ‘GPS’ designed the PCB with any enclosure
The satellites broadcast signals with receivers are actually GNSS receivers in mind, so it needed a larger enclosure
precise timing that allow a GPS receiver and can use data from several constel- than necessary. And people may prefer
to determine the receiver’s location and lations. This means the receiver is more a 12V supply rather than a 5V supply.
the time. Many GPS receiver modules likely to pick up usable signals since Consequently, I designed the
generate an accurately timed one pulse many more satellites are available to it. revised PCB that is presented in this
per second (1PPS). However, there are differences article. The oscillator is substantially
between constellations, and the independent of the rest of the circuitry.
receiver may be less accurate if it The PCB fits a UB3 Jiffy box and runs
switches between constellations. from 12V DC.

Designing a GPSDO How it works


I first became interested in GPSDOs The GPSDO is designed to use a 1PPS
after reading the GPS-Based Frequency signal and NMEA (National Marine
Reference by Jim Rowe (see PE (EPE) Electronics Association) serial mes-
April-May 2009). sages delivered at 9600 baud. Many
In theory, a microcontroller could GPS receivers have these capabili-
replace most of the discrete compo- ties in a wide range of prices and fea-
nents. To test this, I designed a GPSDO ture sets.
that used a PIC16F628A. It worked, but The GPSDO counts the cycles of the
was too elaborate. local oscillator between successive
You will need a GPS module with I decided to improve my old design 1PPS signals. Any deviation from ten
an SMA socket and 5-pin header, after seeing Tim Blythman’s Program- million causes a change in the control
such as the Neo-7M shown above. mable GPS-synched Frequency Refer- voltage to ensure there are ten mil-
Make sure the header is wired as
per Fig.2.
ence (October and November 2019), lion cycles per 1PPS. The oscillator
which has an accuracy of ±100ppb. is locked to the 1PPS signal, and so

16 Practical Electronics | May | 2024


it can be used to accurately time long time, so it can determine if the pulse This GPSDO solves the problem in
periods, as well as provide an accu- arrived early or late compared to the software by dithering the pulse width
rate frequency. local oscillator. From this, we can on every pulse. Selected pulses are
In the long term (days or weeks), a deduce whether the oscillator is run- made 25ns longer. The base number
GPS receiver provides a very accurate ning slow or fast. for this is a 24-bit number, allowing the
time signal. But in the short term (sec- 25ns is a sufficiently short inter- control voltage to be varied in incre-
ond to second), there can be variations val for timing when using a low-cost ments of less than 1µV. This is far finer
due to receiver design, signal recep- GPS module. The 1PPS is generated than required, but as it is generated in
tion and other factors. Many GPSDO from the GPS module’s internal clock, software, it is effectively free.
implementations use specialised GPS which is not necessarily a multiple The unique pulse stream repeats
receivers designed to minimise these of 10MHz. Consequently, the pulse more than twice a second, so the
variations and allow for relatively will not arrive precisely on time, but heavy filtering is adequate to remove
straightforward control strategies. will appear to jitter around the cor- any artefacts created by the dithering.
This GPSDO was designed to use rect value.
low-cost GPS modules that deliver The jitter effectively randomises More capabilities
a time signal with significant short- the arrival time so that accumulating All a GPSDO has to do is time the
term variations. To overcome this, the the arrival times over a period gives arrival of the 1Hz pulses and adjust
processor uses the average of many a statistically more accurate average the control voltage to correct any devi-
1PPS signals to produce a more accu- arrival time. Also, the 1PPS pulse tim- ation of the oscillator from 10MHz, as
rate result. The oscillator control is ing is affected by atmospheric condi- described above. However, it is desir-
then varied at intervals of many min- tions, the transition between GNSS able to be able to determine if the GPS
utes rather than continuously. The constellations and other effects, so unit is generating valid pulses, mea-
default is 512 seconds, but this can measuring to better than 25ns yields sure the GPSDO’s performance, and
be changed through the user interface little improvement. indicate to users that it is functioning
(UI). This approach offers both bene- The oscillator frequency can be correctly (or not).
fits and shortcomings. varied by a few hertz on either side The GPS module generates NMEA
One benefit is that the GPSDO can of 10MHz, based on a control volt- messages as 9600 baud serial data (the
evaluate its own performance. Because age applied to the oscillator. The micro can be programmed to handle
the control is varied by a known OSC5A2B02 has a nominal control the less common 4800 baud). The
amount after a known interval, a max- voltage of 2V±2V and a sensitivity of GPSDO decodes the messages, look-
imum error can be attributed to the around 0.1V/Hz. The PWM periph- ing specifically for $xxRMC messages
oscillator output before the correction eral generates the required voltage, (xx because some modules output
is applied. with its output going through a filter $GPRMC [GPS], some use $GNRMC
The drawback is that the local oscil- with a time constant of over a second [multi-constellation] and so on).
lator’s phase (the amount of lag or lead) to eliminate all traces of the pulses. RMC is the recommended minimum
can be greater than it would be with a The output pulses of the PWM unit message, so almost all GPS modules
PLL (phase-locked loop) design. But are at 40kHz, with the pulse width will deliver it. One field in the message
like a PLL design, the local oscilla- variable from 0 to 25µs in 25ns incre- indicates if the GPS has a valid loca-
tor is locked to the 1PPS signal in the ments. If the pulse width is only tion fix. The GPSDO ignores the 1PPS
long term. changed when a change of control pulses if the fix is not valid. Although
voltage is required, there would be not necessary for GPSDO operation,
In more detail 1000 voltage steps between 0V and 5V, other messages are decoded to obtain
I chose a PIC16F1455 for the microcon- which would change the frequency in data useful for logging such as the date
troller as it has several useful peripher- increments of 5ppb. This is too coarse and time.
als. Its clock signal is the 10MHz out- to be helpful. The GPSDO uses a single LED to
put of the reference oscillator, which The traditional way to tackle the indicate its status. The LED has pat-
allows the micro to count the 1PPS problem is to add more hardware. Typ- terns for error conditions, startup
pulses directly. The processor has a ical solutions are to use PWM over a stages and operational status. When
PLL to multiply this by 4, giving an smaller range and have a potentiome- the OCXO is locked to the GPS 1PPS
internal 40MHz clock. Some of the ter to make a coarse adjustment; com- signal, the LED repeats a pattern once
inbuilt peripherals can use this clock; bine the output of two PWMs, one for per second. A single 50ms flash indi-
in this case, they are the 16-bit timer coarse control and one for fine con- cates the OCXO should be within 1ppb
Timer1 and the 10-bit PWM (Pulse trol; or use an external DAC (digital- of 10MHz. Otherwise, there are two
Width Modulator) generator. to-­analogue converter) with 16 bits (or closely-spaced 50ms flashes indicat-
Timer1 is used to measure the arrival more) of resolution. ing the accuracy is uncertain.
time of the 1PPS signal. The 1PPS sig-
nal is one input to a comparator, with Photo 1: the
the other set to 1.9V from an internal preferred
voltage reference. The 1PPS signal position for
swings from 0V to 3.3V, so the com- mounting the
parator can easily detect it. The com- PCB on a UB3
parator is set up to gate (pause) Timer1 enclosure.
when the signal arrives.
Another timer (Timer2) is used to
count 10 million cycles, then start
Timer1 at a known point. Since Timer1
is clocked at 40MHz, the interval until
it is stopped is known to within 25ns.
This is compared to a target arrival

Practical Electronics | May | 2024 17


Fig.1: the GPSDO is built around oven-controlled crystal oscillator OCXO,
GPS module MOD1 and microcontroller IC4. IC4’s clock is derived from
the oscillator’s 10MHz output, and it analyses the 1Hz pulses from the GPS
module to determine if the control voltage needs to change. That voltage is
produced by error-diffused PWM buffered by MOSFETs Q1/Q2 and filtered by
a three-stage LPF.

A UI is provided to obtain more sta- by IC4 emanates from pin 7 and is fed from the general 5V supply. The 5V
tus information, and some limited con- to the gates of P-channel and N-chan- rail from the standard linear regulator
trol over the GPSDO, via the microcon- nel MOSFETs Q1 and Q2, which oper- that powers the OCXO is stable enough
troller UART. By default, the NMEA ate as an inverter. When the PWM sig- that the MAX6350 IC is not required.
data stream from the GPS module is nal is low, Q1 switches on, pulling the Therefore, constructors should omit
passed through to the UART. Programs output up via a 10kW resistor, whereas REF5 and instead solder a wire from
are available to decode the information when the PWM signal is high, Q2 the output of REG6 to REF5’s pad 6
and display items such as the num- switches on, pulling the output low (the dashed line in Fig.1). Regardless
ber of satellites in view, their signal via another 10kW resistor. of the source of the reference voltage,
strength, position in the sky and the The resulting signal is fed through it is fed through an LC low-pass filter
location data’s reliability. This can be three RC low-pass filters connected (1mH/47μF) before being applied to
useful to diagnose performance issues. in series to the control terminal (pin the source of MOSFET Q1 to remove
The UI can also be accessed by a 1) of the 10MHz crystal oscillator any digital noise.
terminal program such as TeraTerm. (OCXO). The time constant of this fil- The output signal from the OCXO
The user can change the output from ter is around one second. at pin 3 is fed through an inverter
the NMEA stream to a log of what the The main reason for inverting the (IC7a) and 22pF AC-coupling capac-
GPSDO is doing. There are some con- PWM signal with two MOSFETs was itor to the clock input pin (pin 2) of
trol functions to change some defaults, so the input to the PWM filter can have microcontroller IC4, which has an
reboot or update the software without its amplitude determined by a very internal DC bias. It’s also fed to the
removing power. precise reference voltage for stability remaining five inverters in IC7 con-
in the resulting control signal, gener- nected in parallel, with series resis-
Circuit details ated by a MAX6350 voltage reference tors on the outputs to prevent them
The entire circuit is shown in Fig.1. IC. However, testing showed that it was from ‘fighting’ each other if they don’t
The controlling PWM signal produced sufficient to isolate the PWM supply switch simultaneously.

18 Practical Electronics | May | 2024


Budget GPS-disciplined Oscillator

The output of this set of inverters REG3 powers microcontroller IC4, The remote end requires a buck
is AC-coupled to output connectors hex inverter IC7, the GPS module converter, a line driver and the GPS
CON7 and CON9 with a 1kW resistor and some other bits and pieces, while receiver. This setup has been tested
to provide 0V DC bias. REG6 powers the crystal oscillator and over a 12m cable, and worked over
An opto-isolated serial interface PWM control signal inverter, as men- 20m. However, I did not design a PCB
is provided at CON5, which can be tioned earlier. Both regulators will for this.
plugged straight into a USB/serial remove any remaining switching noise If you wish to implement this, fit
converter module. By isolating it, we from the buck regulator that passes the line receiver IC using a socket. For
prevent electrical noise from being through the LC filter. remote use, install the line receiver. For
fed back from a connected computer. The GPS module is wired to CON6. local use, remove the line receiver and
Isolation is via two opto-couplers, one The 1PPS signal is fed to pin 8 of IC4 plug the GPS receiver into CON6. Oth-
for each direction (in/out) – OPTO1 while the serial stream goes to pin 12. erwise, IC3, CON8 and the two asso-
and OPTO2. The PCB has provision for data ciated 100W resistors can be left off.
Turning now to the circuit’s power to be fed in from a GPS receiver via
supply, the incoming 12V is filtered dual-differential receiver IC3. This Preparing the enclosure
by a 100μF capacitor and then fed is an experimental interface to allow Before mounting any parts on the PCB,
into a buck converter module (REG1) remote location of the GPS receiver use it as a drilling template for the
that efficiently drops it to 6.5-7.5V. Its for situations where a local GPS mounting holes on the Jiffy box lid,
output is filtered by a 220μF capac- antenna cannot pick up adequate GPS which will become the base. Refer to
itor, then an LC low-pass filter to signals. The connection to the remote Photo 1, which shows the preferred
remove most of the switching noise receiver utilises a standard Ethernet position for a UB3 enclosure, with the
(100μH/470μF) before being applied UTP cable, with two pairs for the two power connector close to the back and
to two 5V low-dropout linear regula- signals and the remaining pairs for plenty of space for mounting the buck
tors, REG3 and REG6. 12V power. converter module.

Practical Electronics | May | 2024 19


We recommend you use this type of any updates can be made via the UI
USB/serial module, as it makes the on the serial port.
overall wiring much easier. Next, install the linear regulators
Note the non-standard (REG3 and REG6) plus the buck reg-
orientation of Q1; see the ulator module (REG1), making sure
panel on p68. they are oriented as shown in Fig.2.
For REG1, various types can be used,
and it isn’t always obvious which
way around they should go. Check
the module and verify that the input
and output pins match the ‘IN’ and
‘OUT’ labels shown in Fig.2.
After that, fit the OCXO, which can
only be inserted into its pads in the
correct orientation.
We don’t recommend you fit IC3,
Buck converter a proper joint. When it remelts, feed CON8 or the two resistors next to
We have specified a low-cost 7.5V 1A in some extra solder until you have IC3. Similarly, REF5 should be miss-
buck converter that should be a direct nice shiny fillets. ing, although you will have already
fit on the PCB, similar to a standard With that in place, move on to the soldered a wire link to its pad 6. You
linear regulator. through-hole parts, starting with the can now fit the DC socket to complete
The 7.5V option provides plenty resistors. All but one are mounted the board.
of headroom but will increase dissi- vertically to save space. While doing LED1 can be mounted on the PCB,
pation in the case (ie, reducing effi- that, use one of the lead off-cuts to fit but it is more convenient to fit a two-
ciency), although with the small flag the wire link shown in red in Fig.2, pin polarised socket in its place and
heatsinks specified, that should not bypassing the unused REF5. Follow wire up the LED to a matching plug
bother the regulators. with the two TO-92 MOSFETs, being using a length of light-duty figure-8
The prototype used an LM2596- careful not to get the different types cable (eg, two wires stripped from rib-
based buck converter module with mixed up, then the ceramic capaci- bon cable). That will let you mount
an adjustable output, set to 7.0V (6.5- tors, which are not polarised. it in a hole in the case later, so it’s
7.0V is the ideal range). As it has suit- Next, install the electrolytic capac- externally visible.
able onboard capacitors, the 100μF itors, which need to have the longer Similarly, the 10MHz output socket
and 220μF supply capacitors on the positive leads inserted into the pads is chassis-mounted and connected via
main PCB can be omitted. It was marked with a + symbol. The striped a two-pin header, CON7. It isn’t crit-
attached edge-on using a few pieces side of the can indicates the oppo- ical that this is a polarised/locking
of solid copper wire scavenged from site (negative) lead. Then solder the type header; you could use a standard
an earth conductor; no additional opto-couplers (OPTO1 and OPTO2) header and DuPont plugs or just sol-
support was necessary (see the photo plus hex inverter IC7. These compo- der the wires to the output socket to
below). With a UB3 Jiffy box, this nents can all be soldered to the board the pads, although that does make dis-
converter just fits between the posts without a socket, but make sure pin assembly/testing a bit more difficult.
in the lid. 1 is in the right location in each case Fit a standard six-pin header for the
You can do something similar, but before soldering. isolated USB/serial interface at CON5.
using the specified regulator is neater Now fit microcontroller IC4, you The specified USB/serial module has a
and easier, and you don’t have to be can solder it directly to the board as socket that will plug into this header
so concerned with the exact mounting there is provision for in-circuit pro- later. The direct serial interface header,
position of the PCB on the lid. gramming/reprogramming (ICSP) via CON4, should not be needed.
CON3, but you might prefer to use a
Construction socket to make it easier to replace. Programming the micro
The project’s control PCB is coded If IC4 is programmed before instal- Next, yo need to program your
04103231, measures 100 × 55mm and lation, CON3 is not needed because microcontroller. The procedure is
is available frmo the PE PCB Service.
Refer to the overlay diagram, Fig.2, The LM2596 module is inexpensive
during construction. and adjustable, but mounting it can
Begin the PCB assembly by fitting be messy.
the only SMD component, inductor
L1. It’s reasonably large and easy to
handle but requires quite a bit of heat
to flow the joints. Turning the iron up
will help. First, spread a thin layer of
flux paste on the pads and add some
solder to one.
Place L1 over its pads and use
something to clamp it in place while
adding solder to the sides of the two
pads, one at a time. Once the solder
contacts the inductor, it will solid-
ify, and you will have to hold the
iron there, continuing to apply heat
until it melts again and flows to form

20 Practical Electronics | May | 2024


straightforward, just fit CON3 and of 2-3V, most likely close to 2.5V. If GPS module wiring
then program it using an in-circuit that’s wrong, it could be due to a prob- You can now solder the wires from
serial programmer like a PICkit 3/4 lem with MOSFETs Q1 and/or Q2 or your GPS module to the pads for
or a Snap. a faulty oscillator module. CON6. Fig.2 shows the wire colours
The PICkit 3 or 4 can supply power
to the board during programming.
For the Snap, arrange for your own
5V supply or temporarily connect a
12V supply to the board to program
the chip.
Once the chip has been pro-
grammed, you don’t need to open the
box to access CON3 to reprogram it.
This can be done over the serial port
using the XMODEM protocol.

Testing
Before applying power, check your
soldering for unwanted shorts, espe-
cially around the MOSFETs. Also
check to ensure the fillets are all shiny
and well-formed, all components are
in the correct locations and have the
right orientations.
If you decided to use an adjustable
buck converter, verify that you’ve set
it for approximately 7V output before
connecting it to the main PCB. This is
not critical as it can be adjusted later,
during testing.
The converters used on the pro-
totypes are adjusted by rotating
the onboard potentiometer screw
anti-clockwise. Nothing happens for
much of the rotation, then the voltage
reduces over very little travel. Once the PCB has been assembled, it needs to be wired
Connect the LED to its header, to the output socket, GPS module, USB socket and LED1. Note the omitted
apply power and check that it lights optional parts.
up or flashes. Check the output volt-
age from the buck module at either
end of inductor L1 relative to 0V (eg,
one of the two larger plated holes on
either side of unused socket CON8).
Verify it’s close to the expected volt-
age (6.5-7.5V). Also measure the out-
puts of the two 5V regulators at their
tabs and verify that they are both
close to 5V.
If the LED is not flashing, probe pin
3 of the PIC. It should be switching
between 5V and 0V. If it is, you might
have the LED connected the wrong
way around.
If the LED flashes at 2Hz, the 10MHz
signal is not reaching the PIC at its pin
2. Check for a 10MHz signal between
the two pins of CON7. It should also
be present at pin 1 of IC7 (directly con-
nected to the output of the oscillator).
If all is well, the LED should flash
at 1Hz with about 800ms on and
200ms off. This indicates that the PIC
is working and using the 10MHz from
the oscillator as its clock.
You can check the control voltage Fig.2: fit the components as shown here, taking care with the orientation of
the electrolytic capacitors, ICs, opto-couplers, regulators and LED1. Several
at the control pin of the OCXO, which
parts are not needed and are shown left off, while CON8 and the two 100W
is connected to the right-hand end of resistors below it are depicted but not required. Don’t forget the short wire
the resistor immediately between it link near the middle of the board, shown in red, which bypasses REF5.
and REF5. It should be in the range

Practical Electronics | May | 2024 21


be obtained indoors near openings
such as a window.
If using a different module, consult
its data sheet to determine the con-
nections. Most TTL modules should
be suitable.
The specified module has a stan-
dard 5-pin header, so a short 5-way
ribbon cable with DuPont connec-
tors at either end will suffice to con-
nect it to the CON6. In contrast,
the VK2828U7G5LF module has an
onboard miniature connector and
comes with a matching cable with
bare ends, so you could solder its
wires directly to the board. It also
The finished PCB; note the wire has an enable (EN) wire that needs
soldered to pin 6 of REF5 to to connect to the 5V pad.
bypass it (on the underside). The system is now ready to be
powered up with the GPS module
attached. There’s a power light on
for the suggested Neo-7M module. It is best to use an active antenna on most GPS units; if present, it should
However, you might decide to use a lead as the signal quality indoors is light up. If the system LED is now
a module with an onboard antenna usually too marginal. The antenna is making a double flash at three-sec-
if you have good signal strength in ideally placed outdoors with a good ond intervals, all is well. That indi-
your lab. view of the sky. Adequate signal may cates that data is received from the

BS250 Pinout
Be aware that there are
versions of the BS250
MOSFETs with non-
standard pinouts (the
standard pinout is DGS
left-to-right looking at
the flat ‘label’ side; see
Fig.1). If you end up with
those, you might need to
rotate it or bend the pins.
Usually the non-standard
versions have their pinout
printed on the face.

Fig.3: this shows where to


drill holes in the lid/base, for
mounting the PCB, and in the
sides of the case, for the various
chassis-mounting connectors.
As noted in the text, you
should ideally use the PCB as a
template to mark the four holes
in the lid/base, although you
can use this diagram if you’ve
already populated it.

Note: the DC socket and GPS


antenna socket locations are
only guides, and the actual size
and location can vary when it is
mounted. So it’s best to check
them before drilling.

22 Practical Electronics | May | 2024


module but it is not detecting any Parts List – GPS-Disciplined Oscillator
satellites yet.
Next, plug the USB/serial module 1 double-sided PCB coded 04103231, 100 × 55mm
into CON5; make sure it’s the right 1 12V DC 500mA+ supply with barrel plug
way around, with its DTR pin to pin 1 UB3 Jiffy box (optional)
1 on the left and its GND pin on the 1 PCB-mount DC socket (CON2; 2.1mm or 2.5mm ID, to suit plugpack)
right. Connect it to your computer, 1 5V GPS module with 1PPS output and SMA antenna socket
open a serial terminal on the COM [eg, NEO-6M, NEO-7M or NEO-8M; SC6737] (MOD1)
port that appears, power up the board, 1 GPS antenna with wired SMA connector [SC6738]
and you should see one line of text 1 CTI OSC5A2B02 oven-conditioned crystal oscillator module (X1)
when it detects that it is running with [eBay www.ebay.com.au/itm/332389156868]
the 10MHz clock. 1 12V input, 7.5V 1A output three-pin buck converter module (REG1) (A good, inexpensive
With the GPS module attached, it variable voltage output device is www.aliexpress.com/item/1005002168374063.html)
should pass through the NMEA data 1 WeMos style CH340G-based USB/serial module with header socket for serial and
to the serial output (this is the default micro-USB socket (MOD3) [SC6736; AliExpress siliconchip.au/link/abjn]
when first powered up, but you can 1 10cm panel-mount micro-USB socket to micro-USB plug (for MOD3) [SC6736]
change it later). 1 10×10mm 100μH 1A+ SMD inductor (L1) [ASPI-8040S-101M-T or NR10050T101M]
Place the GPS antenna where it 1 1mH axial RF inductor (L2)
will receive a good signal from the 1 5-pin header (CON3; optional, for programming IC4 in circuit)
satellites. Turn the system on, and 1 4-pin header (CON4; optional, for non-isolated serial)
the double flash at three-second inter- 1 6-pin header (CON5; for isolated serial)
vals should resume. It could take up 2 2-pin polarised headers and matching plugs (CON7, CON8)
to 30 minutes or possibly a little lon- 1 panel-mount BNC socket (CON9)
ger for the GPS module to pick up all 1 100mm 5-way female-to-female DuPont cable (CON6; NEO GPS module)
the satellites after a ‘cold start’. When 2 flag heatsinks for TO-220 devices [eBay 182609295159]
that happens, the LED flash pattern 6 M3 × 8-10mm panhead machine screws
should change. 4 M3 x 5mm tapped Nylon spacers
The LED reports the number of sat- 2 M3 shakeproof washers
ellites seen (in binary) until a fix is 6 M3 hex nuts
obtained. This may take some time, 2 M2 × 10mm panhead machine screws and hex nuts (to mount USB socket)
sometimes as long as 15 minutes. If 1 200mm length of twin-core light-duty figure-8 cable (eg, stripped from ribbon cable)
the system stays in the double-flash Semiconductors
state, the antenna may not be in a good 2 4N25 or 4N35 opto-isolators (OPTO1, OPTO2)
position, or it isn’t working. 1 UA9639CP dual differential receiver IC (IC3; optional)
1 PIC16F1455-I/P 8-bit microcontroller programmed with 0410323A.HEX, DIP-14 (IC4)
Final testing 1 74HC04 hex inverter IC, DIP-14 (IC7)
If the GPS module is locating satel- 2 LM1085-5.0 low-dropout 5V linear regulators (REG3, REG6)
lites, the system should transition 1 BS250 P-channel MOSFET, TO-92 (Q1)
after some time to a flash pattern 1 2N7000 N-channel MOSFET, TO-92 (Q2)
every four seconds. It starts as five 1 3mm LED (any colour)
flashes, a single followed by four
Capacitors
doubles, and counts down. If there is
1 470μF 10V radial electrolytic
no flashing, it is most likely that the
1 220μF 10V radial electrolytic
GPS module has reported a good fix,
2 100μF 16V radial electrolytic
but the 1PPS signal is not getting to
3 47μF 50V radial electrolytic
the PIC processor.
3 10μF 50V radial electrolytic
Do not allow the system to run for
4 100nF 50V MKT or multi-layer ceramic
more than an hour after this transi-
1 22pF 50V NP0/C0G ceramic
tion. Turn it off, detach the GPS mod-
ule, and run the system without the Resistors (all ¼W 1% axial metal film)
GPS for a few hours or overnight. The 3 10kW 2 5.6kW 5 1kW 5 270W 3 100W
reason for this is that most crystal – two of the 100W resistors are optional (used only when IC3 is installed)
oscillators need some time to settle
down after unknown handling before
being installed.

Calibration
The GPSDO is self-calibrating. The
purpose of the calibration is twofold;
it determines the actual sensitivity of
Fig.4: we’re recommending a USB/serial module with a micro-USB socket
the crystal oscillator (the control volt-
that plugs directly into CON5 (it has an onboard header socket). However,
age vs frequency relationship) and you can use most USB/serial adaptor you want, including the very common
a reasonable control voltage to use type shown here, wired to a 6-way female header to match CON5.
when the system is started.
After the oscillator has been run- This will take more than an hour, A single flash per second indicates
ning for a few hours, turn off the sys- and if the GPS signal is marginal, it the GPSDO has completed calibration
tem and reattach the GPS module with may be longer (or not achieved – in and has reached 10MHz within 1ppb.
its antenna. Let the system run until which case you will need to relocate A double-flash suggests it may not be
it delivers one flash every second. the antenna). within specification.

Practical Electronics | May | 2024 23


It is normal to see an occasional or high, you can adjust either the list also specifies a chassis-mount
period of double flashing, for a few hole’s location or the size of the spacer micro-USB socket with a short cable
minutes every few hours. This is due between the PCB and the lid. Make that plugs right into that socket.
to the GPS switching satellites and the other required holes, too; if your That just leaves the output con-
not having a good fix immediately. A arrangements differ from what we’ve nector. If you haven’t crimped and
well-positioned antenna will reduce suggested, you might need to adjust soldered the output connector wire
or eliminate these deviations. some of the hole positions and sizes. with the polarised plug at one end and
After the GPSDO has been switched If your GPS module has an onboard BNC socket at the other, do that now,
off, it will take some time to settle antenna, you can attach it to the then mount it on the side of the case
down the next time it is turned on. inside of the case using double-sided where it won’t interfere with the PCB.
Usually, it is unusable for up to five tape. Otherwise, drill the hole for the Plug it into CON7 and check that the
minutes and reliable after 15 minutes. antenna connector and mount the GPS connector shell has continuity to the
For best results, the system should module to that hole. You will probably PCB ground.
be allowed to run continuously. It need to use neutral-cure silicone seal- Finally, check that everything is
improves noticeably for the first week ant to glue it inside the case as the SMA working before ‘buttoning up’ the
of running. If the antenna is well-­ socket does not have a retaining nut; GPSDO in its case – verify that the
positioned, the system should then the threads are only for the SMA plug. LED flashes when power is applied,
single-flash (indicating a precision Various approaches can be used for a ~10MHz signal appears at CON9,
better than 1ppb) and rarely, if ever, the USB interface. On the prototypes, and you can establish USB commu-
double-flash. we wired up a low-cost USB/serial nications via the chassis socket. Make
adaptor, as shown in Fig.4, then wired sure the GPS antenna is plugged in
Completion it up to a chassis-mounting ‘exten- and it is ready to use.
Once you’ve verified that it’s working, sion cable’ style USB socket. How- The HEX file, source code and docu-
all that’s left is to finish mounting it in ever, we think we’ve come up with mentation for the GPSDO can be down-
the case. Mount it on the base by insert- an easier and neater solution for the loaded from from the May 2024 page of the
ing 8-10mm-long machine screws from final version. PE website: https://bit.ly/pe-downloads
the outside, into 5mm spacers. Drop The USB/serial adaptor specified or from the author’s GitHub:
the PCB on the screw shafts, then use in the parts list plugs directly onto https://github.com/ajcashin/budget-gpsdo
a set of nuts to hold it in place. header CON5 (watch the orienta-
Check that the DC socket will line tion). You will then have a micro- Reproduced by arrangement with
up with the location of the hole shown USB socket facing up from the PCB SILICON CHIP magazine 2024.
in Fig.3, then make it. If it’s too low (as shown in the photos). The parts www.siliconchip.com.au

Your best bet since MAPLIN


Chock-a-Block with Stock
Visit: www.cricklewoodelectronics.com
Or phone our friendly knowledgeable staff on 020 8452 0161
Components • Audio • Video • Connectors • Cables
Arduino • Test Equipment etc, etc
JTAG Connector Plugs Directly into PCB!!
No Header! No Brainer!

Our patented range of Plug-of-Nails™ spring-pin cables plug directly


into a tiny footprint of pads and locating holes in your PCB, eliminating
the need for a mating header. Save Cost & Space on Every PCB!!
Solutions for: PIC . dsPIC . ARM . MSP430 . Atmel . Generic JTAG . Altera
Xilinx . BDM . C2000 . SPY-BI-WIRE . SPI / IIC . Altium Mini-HDMI . & More
Visit our Shop, Call or Buy online at:
www.cricklewoodelectronics.com
Visit our shop at:
www.PlugOfNails.com
020 8452 0161 40-42 Cricklewood Broadway
London NW2 3ET
Tag-Connector footprints as small as 0.02 sq. inch (0.13 sq cm)

24 Practical Electronics | May | 2024


ETI BUNDLE (1) Teach-In 3, 4 and 5 – all on CD-ROM – only £18.95
ELECTRONICS TEACH-IN 3 – CD-ROM ELECTRONICS TEACH-IN 5 – CD-ROM
ELECTRONICS ELECTRONICS
EE M EE M
FR -RO FR -RO £8.99

Mike & Richard Tooley CD


JUMP START CD

TEACH-IN 3 TEACH-IN 5
£7.99

Mike & Richard Tooley


The three sections of the Teach-In 3 CD-ROM cover a
FROM THE PUBLISHERS OF

FROM THE PUBLISHERS OF

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

The projects are: n Moisture Detector n Quiz


colleges
i The techniques of electronic
project construction PRACTICALLY SPEAKING
The first section (80 pages) is dedicated to Circuit INGENUITY UNLIMITED Machine n Battery Voltage Checker n Solar- The techniques of project construction

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

queries on circuit design problems – from voltage nics


Teach-
In FREE Circuits n Frost Alarm n Mini Christmas Lights n FREE M
ro TEACH-IN 1 CD-ROM bo
rne
Pu blishing Ltd 20
10 CD-RO
TEACH-IN 2
regulation to using SPICE circuit simulation software. iPod Speaker n Logic Probe n DC Motor Controller
im

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

Receiver n Temperature Alarm.


microcontro software

covers hands-on aspects of electronics construction.


ws
for Windo

n Program i A complete stand-alone


CD ROM
This CD
should
start
y, if not
microcontrollers
Simulatio automaticallindex.html
Circuit d version) tutorial in 11 parts plus free
8 TINA (Limite ramming double-click
In 2 Plus MikroElektronika,
CODE V3
PIC Prog n)
software nicsorne Teach-

Again, a whole range of subjects, from soldering to


8 FLOW d versio
Ele©ctro Publishing
Ltd
dsPIC are Microchip and L-Tek PoScope
Software Quizzes to Test
(Limite PIC and rated
2013 Wimb MPLAB, logy Incorpo ogy

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

avoiding problems with static electricity and identifying


Inc.
3 09:59:25
29/07/201

d 1
In 2 - JUL13.ind

components is covered. Finally, our collection of


Teach
Teach In 5 Cover.indd 1 29/07/2013 10:00:29
Teach In 3 Cover.indd 1 06/05/2010 16:22:29

PIC’n’ Mix – starting out with the popular range of PIC


Ingenuity Unlimited circuits provides over 40 circuit designs submitted by readers. microcontrollers and Practically Speaking – tips and techniques for project construction.
The CD-ROM also contains the complete Electronics Teach-In 1 book, which
provides a broad-based introduction to electronics in PDF form, plus interactive 29/04/20
10 13:21:42
The CD-ROM also contains:
quizzes to test your knowledge and TINA circuit simulation software (a limited n Complete Teach-In 2 book, a practical introduction to PIC microprocessors
n MikroElektronika, Microchip and L-Tek PoScope software.
dd 1

version – plus a specially written TINA Tutorial).


CD Cover.in

The Teach-In 1 series covers everything from electric current through to


microprocessors and microcontrollers, and each part includes demonstration circuits
to build on breadboards or to simulate on your PC.

ELECTRONICS TEACH-IN 4 – CD-ROM Three Teach-ins for the great price of


ELECTRONICS £18.95
EE M
FR -RO £8.99

A BROAD-BASED INTRODUCTION TO CD

ELECTRONICS
TEACH-IN 4
FROM THE PUBLISHERS OF

Mike & Richard Tooley FREE

PLUS you also get the contents of the


CD-RO
M
A BROAD-BASED WORT

The Teach-In 4 CD-ROM covers three of the most


H
£29.9
INTRODuCTION TO ELECTRONICS 5

important electronics units that are currently studied in


free CD-ROM from each issue...
i An eleven part tutorial
i uses inexpensive circuit

many schools and colleges. These include, Edexcel


simulation software

BTEC level 2 awards and the electronics units of the


... so that’s another TWO Teach-Ins and
FREE M
CD-RO

Diploma in Engineering, Level 2. THE MODERN ELECTRONICS MANuAL


The essential reference
The CD-ROM also contains the full Modern
The Full Modern Electronics Manual!
work for everyone
studying electronics

Electronics Manual, worth £29.95. The Manual i Over 800 PDF pages

contains over 800 pages of electronics theory,


i In-depth theory
i Extensive data tables
autorun,
should
This software in Windows

What a Bargain!!
if not, open double-click
and
Explorer f
index.pd

projects, data, assembly instructions and web links.


This CD-ROM
requires
and web links
UAL
Reader™
Adobe® from
dable Free

MAN.co.u
Downloa be.com
www.ado

BA SE .epe mag
k

A package of exceptional value that will appeal


www ne Publishi
ng Ltd.
2011

© Wimbor

to anyone interested in learning about electronics – Teach In 4 Cover.indd 1 14/11/2011 20:33:21

hobbyists, students or professionals.

ETI BUNDLE (2) Teach-In 6, 7 and 8 – all on CD-ROM – only £18.95


ELECTRONICS TEACH-IN 6 – CD-ROM ELECTRONICS TEACH-IN 7 – CD-ROM ELECTRONICS TEACH-IN 8 – CD-ROM
A COMPREHENSIVE GUIDE TO RASPBERRY Pi DISCRETE LINEAR CIRCUIT DESIGN INTRODUCING THE ARDUINO
Mike & Richard Tooley Mike & Richard Tooley Mike & Richard Tooley
Teach-In 6 contains an exciting series of articles that Teach-In 7 is a complete introduction to the design of Hardware: learn about components and circuits
provides a complete introduction to the Raspberry analogue electronic circuits. It is ideal for everyone Programming: powerful integrated development system
Pi, the low cost computer that has taken the educa- interested in electronics as a hobby and for those Microcontrollers: understand control operations
tion and computing world by storm. studying technology at schools and colleges. The Communications: connect to PCs and other Arduinos.
This latest book in our Teach-In series will appeal CD-ROM also contains all the circuit software for Teach-In 8 is an exciting series designed for
to electronics enthusiasts and computer buffs who the course, plus demo CAD software for use with the electronics enthusiasts who want to get to grips with
want to get to grips with the Raspberry Pi. Teach-In series. the inexpensive, popular Arduino microcontroller, as
n Discrete Linear Circuit Design well as coding enthusiasts who want to explore
Teach-In 6 is for anyone searching for ideas to use n Understand linear circuit design
their Pi, or who has an idea for a project but doesn’t hardware and interfacing. It will provide a one-stop
n Learn with ‘TINA’ – modern CAD software source of ideas and practical information.
know how to turn it into reality. This book will prove n Design simple, but elegant circuits
invaluable for anyone fascinated by the revolutionary nF  ive projects to build: The Arduino offers a truly effective platform for
Pi. It covers: i) Pre-amp developing a huge variety of projects; from operating
n Pi programming ii) Headphone Amp a set of Christmas tree lights to remotely controlling a
n Pi hardware iii) Tone Control robotic vehicle through wireless or the Internet.
n Pi communications iv) VU-meter Teach-In 8 is based around a series of practical
n Pi Projects v) High Performance Audio Power Amp. projects with plenty of information for customisation.
n Pi Class
n Python Quickstart This book also includes PIC n’ Mix: ‘PICs and the
PLUS PICkit 3 – A Beginners
n Pi World E
guide’ by Mike O’Keefe FCRDE-ROM
EE M

n ...and much more!


ELECTRONICS ELECTRONICS ELECTRONICS
EE OM
FR -R FR -RO £8.99

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

Machines part 1 and 2’.


THE TEACH-
IN 8
FROM THE PUBLISHERS OF SERIES

the necessary software RASPBERRY Pi ®


DISCRETE LINEAR CIRCUIT DESIGN
A ComPREhEnSivE GuidE to RASPBERRY Pi
Practically Speaking – • Understand linear circuit design
The CD-ROM includes
INTRODUCING THE ARDUINO
for the series, so that
• Hardware – learn about components and circuits
• Pi PRojECt – SomEthinG to Build • Design simple, but elegant circuits • Programming – powerful integrated development system

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

designers can get FREE


DVD-R
ALL THE
OM
SOFTWA
RE
FREE M
-RO
n Teach-In 8
started quickly and
N6
TEACH-I
FOR THE RRY Pi CD CIRCUIT
RASPBE ALL THE

nM
 icrochip MPLAB
RE FOR
SERIES SOFTWA 7
CH-IN
THE TEA

easily with the projects


SERIES

IDE XC8 8-bit compiler


and ideas covered. PluS
Pi B+ uPdAtE
intERfACE – a series of
ten Pi related features
PLUS...
AUDIO OUT
An analogue expert’s take
n PICkit 3 User Guide PLUS...
n Lab-Nation
on specialist circuits
REviEwS – optically PIC n’MIX
isolated AdC and i/o PRACTICALLY SPEAKING PICs and the PICkit 3 - A beginners
The techniques of project guide. The why and how to build
interface boards

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

ORDER YOUR BUNDLE TODAY!


JUST CALL 01202 880299 – OR VISIT www.electronpublishing.com
Dual RF Amplifier
for Signal generators
This small RF amplifier has two outputs with
individually selectable gains. This makes it
suitable to add to a signal generator to provide
a higher output level, or for better drive strength,
or ‘fanning it out’ to multiple other pieces of
equipment and more.
by Charles Kosina

M
any signal generators do at the op amp output and 2.5V peak-to- 100nF × 470W]) so they will not attenu-
not provide a high enough out- peak at the 50W load, or 884mV RMS ate signals within the specified operating
put level for certain uses. This (13.9dBm/24mW). The maximum out- frequency range, from 100kHz to 75MHz.
small PCB uses an OPA2677 high-speed put with a 12V supply is about 25dBm, The signals are coupled to the non-in-
dual op-amp to boost signals of 100kHz- as shown in the specifications panel. verting input pins, so the amplifiers do
75MHz at around 0dBm (1mW, 225mV/- The RF Amplifier is useful from not invert the signal phase. The outputs
13dBV into 50W) to around 18dBm 100kHz to 75MHz, although once past of the op amps (pins 1 and 7) are fed
(63mW, 1.78V/5dBV into 50W). 50MHz, the maximum output level back to the inverting inputs (pins 2 and
The OPA2677 has impressive specifi- starts to drop off. Table 1 shows spot 6) via 470W resistors, which form volt-
cations. It can operate on voltages from measurements at several frequencies age dividers with trimpots VR1/VR2 and
3.3V to 12V, has rail-to-rail outputs, a using my signal generator as an input. their series 68W resistors.
high drive capability and a gain band- The output variability somewhat The 100nF capacitors in the feedback
width (GBW) of 200MHz. But what depends on the signal generator varia- network reduce the DC gain of these
makes it stand out is a slew rate of 1800V/ tion in output level. amplifiers to 1x so that the input offset
µs, which means it can provide a large The OPA2677 is not cheap, about £5 voltages (up to 5.3mV) are not ampli-
output swing for high-­frequency signals. from Digi-Key, Mouser or element14, fied. The corner frequency of the high-
Since it is a dual op amp, my design but I bought five from AliExpress for pass filter formed is similar to that of the
provides two outputs for the one input £8. Still, even if you pay £5 (each), the input networks as the component values
signal. Individual feedback resistors overall cost of building this RF Ampli- are the same.
and a potentiometer set the gain for fier is modest. As mentioned earlier, the op amps
each output. have very high gain bandwidths (GBW)
The maximum gain is 1 + (470W ÷ Circuit description and slew rates, so they are effective up to
68W) = 7.9 times with the 1kW single-­turn The whole circuit is shown in Fig.1. The high frequencies. Because the gain band-
trimpot set to minimum. The lowest gain signal fed in via SMA connector CON1 width is fixed, the maximum signal fre-
is 1 + (470W ÷ 1068W) = 1.44 times with is AC-coupled to both halves of dual op quency drops as you increase the gain.
the trimpot set to maximum. The out- amp IC1 via 100nF capacitors. These For example, with the GBW of 200MHz,
put impedance is 50W and it will safely signals are biased to half the VCC rail a gain of four times is possible at 50MHz
drive a 50W load. (eg, 2.5V for a 5V supply or 6V for a 12V or about three times at 70MHz.
The power supply voltage should supply) using 470W resistors. The outputs of the two op amps are
ideally be in the range of 9-12V. You Those coupling capacitors and bias coupled to SMA connectors via 100nF
could use 5V DC, but the amplified sig- resistors form high-pass filters with a capacitors to eliminate the VCC/2 DC
nals will be limited to 5V peak-to-peak corner frequency of 3.4kHz (1 ÷ [2π × bias and fed through 51W resistors for
impedance matching. You could change
them to 75W if you need to feed into a
Features and Specifications 75W device.
∎ Operating frequency range: 100kHz to 75MHz The VCC/2 rail is formed by a
1.2kW/1.2kW voltage divider with a
∎ Number of inputs: 1
100nF capacitor from the junction to
∎ Number of outputs: 2, individually gain adjustable ground to eliminate supply ripple and
∎ Gain range: 1.44 times (3dB) to 7.9 times (18dB) keep the source impedance low at higher
∎ Maximum output level: frequencies. Op amp IC1 also has a
25.6dBm @ 30MHz (360mW into 50Ω, 12.5dBV, 4.25V RMS) 100nF supply bypass capacitor.
23.2dBm @ 50MHz (207mW into 50Ω, 10dBV, 3.2V RMS) Note that there is no termination resis-
13.5dBm @ 70MHz (22mW into 50Ω, 0.51dBV, 1.06V RMS) tor for input CON1. You could add an
∎ Power supply: 9-12V DC @ 20-25mA (or 5V DC with reduced maximum M2012/0805 size resistor (51W or 75W)
output levels) across the terminals of the SMA socket
if you need one.

26 Practical Electronics | May | 2024


Table 1 – frequency vs maximum output level @ 12V DC
Frequency Output (p-p) Output (RMS) Output (dBm) Output (dBV)
1MHz 9.5V 3.36V 23.5 10.5
10MHz 8.4V 2.97V 22.5 9.5
20MHz 10.0V 3.54V 24.0 11.0
30MHz 12.0V 4.24V 25.6 12.5
40MHz 9.6V 3.39V 23.6 10.6
50MHz 9.1V 3.22V 23.2 10.2
Compared to the lead image, which
60MHz 5.6V 1.98V 18.9 5.9 is enlarged, here is the finished Dual
70MHz 3.0V 1.06V 13.5 0.51 RF Amplifier shown at life size.

Construction solder joints to ensure they are all good. convenient. Its exact orientation doesn’t
Construction is straightforward as there Next, fit the passives (none are polar- matter as long as you observe the ‘+’ and
are only a couple dozen components. ised), using a similar technique of tack- ‘–’ markings when wiring it up.
The Dual RF Amplifier is built on a dou- ing one side, then adjusting the align-
ble-sided PCB coded CSE220602A that ment and after a brief delay to allow the Housing it
measures 38 × 38mm, which is available solder to solidify, solder the other side. This board is small, so it can fit into most
from the PE PCB Service. Refer to the The resistors will be marked with cases. A metal case is preferred for RF
PCB overlay diagrams, Fig.2 and Fig.3, codes indicating their values (eg, 122 shielding. See the parts list for sugges-
to guide you during assembly. or 1201 for 1.2kW), while the capacitors tions and note that the 51 × 51mm die-
Start by fitting the SMDs to the com- will not be marked, but they are all the cast cases sold by Jaycar and Altronics
ponent side, with IC1 first. Determine its same value (100nF). When all the SMDs are too small to fit the PCB.
pin 1 location – look for a dot or divot in are mounted on that side, flip the board Fig.4 shows the hole positions to drill
one corner, or failing that, a chamfered over and solder the lone capacitor on in the lid or base, and the board can
edge on the pin 1 side. Locate it with pin the other side. then be mounted using the SMA con-
1 towards the upper right with the PCB That just leaves the six through-hole nector nuts.
oriented as shown in Fig.2. components: two trimpots, the power Drill a hole in the side of the case to fit
Add flux paste to its pads, then tack header and the three SMA sockets. It’s a chassis-mount barrel socket and wire it
one pin with solder and check the align- best to fit the SMA sockets next, so you up to CON4. Double-check that the pos-
ment of the other pins. If they are good, have good access to their pins. Push itive wire (usually the tip of the barrel
solder the diagonally opposite pin. Oth- them down fully and solder all five pins, socket) goes to the + side of CON4, as the
erwise, heat the original solder joint and keeping in mind that you may need some board has no reverse polarity protection.
gently nudge the part until it is in place. extra heat or flux to solder the four outer There isn’t a great need for a power
Then solder the remaining pins, pins due to their thermal mass. switch as you can simply unplug the
refresh the first one and clean up any Finally, mount the two trimpots and plugpack from the wall when you
solder bridges which might have formed the power header. Use single-turn trim- aren’t using it. Still, if you want to add
between pins with another dab of flux pots as multi-turn types likely have too a power switch, all you have to do is
paste and some solder wick. much inductance. You could solder drill a hole in a convenient location,
Clean flux residue off the board with some figure-8 wire directly to the board
alcohol or a flux cleaner and inspect the for power, but a polarised header is more

Dual RF
Amplifier

Figs.2 and 3: most components are


Fig.1: the Dual RF Amplifier is a straightforward implementation of the SMDs that mount on the rear, while
OPA2677 dual high-bandwidth op amp. Signals are AC-coupled at the inputs one capacitor and the three SMA
and outputs so they can be DC-biased to a half supply rail formed by two connectors are on the front. The RF
resistors and a capacitor. Trimpots VR1 and VR2 adjust the feedback ratio and connector side of the board is covered
thus the gain of each individual amplifier. with a ground plane.

Practical Electronics | May | 2024 27


Parts List – Dual RF Amplifier
1 double-sided PCB coded CSE220602A, 38 × 38mm from the PE PCB Service
1 diecast aluminium case, large enough to fit the PCB
[eg, Jaycar HB5062, 111 × 60 × 30mm]
1 9-12V DC 50mA+ plugpack or other DC supply
1 OPA2677IDDA dual high-bandwidth op amp, SOIC-8
[element14, Mouser, Digi-Key]
2 1kW single-turn 3362P-style top adjust trimpots (VR1, VR2)
www.poscope.com/epe 8 100nF 50V X7R SMD ceramic capacitors, M2012/0805 size
3 vertical SMA female sockets (CON1-CON3)
1 2-pin polarised header with matching plug and pins (CON4)
1 chassis-mount DC socket to suit plugpack plug
1 short length of light-duty figure-8 cable
1 chassis-mounting SPDT switch (optional; power switch)
1 1N5819 schottky diode (optional; see text)
Resistors
2 1.2kW 4 470W 2 68W 2 51W

mount the power switch and wire it in your power supply to the barrel socket
series with the positive conductor from and use a DMM to check that the power
the barrel socket to CON4. polarity at the plug is correct. Then
If you want to add reverse polarity plug it in and connect a signal to the
protection, solder a 1N5819 diode to input socket.
the barrel socket with its anode to the Verify that an amplified version of
positive tab of the socket, then run the the signals appears at the outputs using
supply wire to the board or switch from a scope, signal level meter or frequency
its cathode. That will drop the supply counter, depending on what you have
- USB - PWM voltage slightly, by around 0.3V, so it on hand.
- Ethernet - Encoders may have a small impact on the maxi-
- Web server
- Modbus
- LCD mum output signal level. Using it
- Analog inputs
- CNC (Mach3/4) - Compact PLC
Finally, you might want to drill a cou- There isn’t much to it – just power it
- IO ple of small holes in the face of the case up, feed in your signal, adjust the level
opposite the board so that you can slot using trimpot VR1 or VR2 if necessary,
in a thin adjustment tool to adjust trim- and take the output from the correspond-
pots VR1 and VR2 with the case closed. ing socket. The CON2 signal level/gain
That depends on your application; is adjusted using VR1, and the CON3
you could just set a different fixed gain signal level/gain is adjusted using VR2.
for both trimpots and then use which- Keep in mind that VR1 and VR2 are
ever output suits your needs at the time. wired such that anti-clockwise rotation
Before screwing on the lid, unplug increases the gain and clockwise rota-
the CON4 plug from the board, connect tion decreases it.
- up to 256 - up to 32
microsteps microsteps
- 50 V / 6 A Reproduced by arrangement with This article is in memory of Rod
- 30 V / 2.5 A
- USB configuration SILICON CHIP magazine 2024. Graham, VK3BQJ, who passed away
- Isolated www.siliconchip.com.au on 4 November 2022.

PoScope Mega1+
PoScope Mega50

- up to 50MS/s
- resolution up to 12bit
- Lowest power consumption Fig.4: just about any metal case would be suitable but this one is relatively
- Smallest and lightest
- 7 in 1: Oscilloscope, FFT, X/Y,
compact. The lid is larger than the base, so if using this as a template, cut it to
Recorder, Logic Analyzer, Protocol the appropriate outline. The central area could be cut out and transferred to
decoder, Signal generator just about any other case. The hole in the side for the power socket is not shown
here; it could go just about anywhere.

28 Practical Electronics | May | 2024


Using Electronic Modules with Jim Rowe

UVM-30A Module
Ultraviolet Light Sensor
This ultraviolet (UV) light-sensing ‘breakout’ module detects the intensity
of UV solar radiation and hence the degree of protection you may
need to prevent skin damage. If you connect it to an Arduino or other
microcontroller, it can even indicate the current ‘UV Index’.

P
rotection is critical if you curve, with the peak at the middle of better sensitivity over slightly more
spend a lot of time outdoors the day or soon thereafter. So it can than half of the UV-A range, from
in the summer sunshine (sun- be worthwhile to keep tabs on the UV 315nm to 365nm.
screen and hat) to avoid sunburn and radiation level if you are going to be The vertical units in Fig.1 are micro-
to lower your chances of developing outdoors, even in the early morning amps per milliwatt of UV radiation.
skin cancer. or late afternoon. The Genicom data sheet for the GUVA-
The UVM-30A analogue UV light At the heart of the UVM-30A mod- S12SD lists the typical peak response
sensing module is ideal for detect- ule is a miniature UV sensor called of the device as 0.14A/W at 350nm,
ing harmful UV rays and can be used the GUVA-S12SD. This is in an SMD equivalent to the peak of the curve
to build your own UV sensor. It eas- package measuring 3.5 × 2.8 × 1.8mm in Fig.1.
ily connects to an Arduino or other and is made by Genicom Co Ltd in
microcontroller unit (MCU) and with South Korea. Inside the module
the right firmware, it will indicate the Genicom describes their device as As shown in the circuit diagram (Fig.2)
current UV Index or ‘UVI’. If you’re a schottky-­type gallium-nitride pho- there’s very little in the UVM-30A
unsure what this is, please see the ‘UV todiode designed to respond to UV module apart from the GUVA-S12SD
Radiation and UV Index’ panel. radiation with wavelengths between sensor (PD1), and a small SGM8521 op
Sunburn and skin damage are 240 and 370nm (nanometres). It is amp (IC1) used to convert its output
caused by the UV wavelengths in solar also described as being ‘blind’ to vis- current into a voltage.
radiation, which can still be quite ible light. The conversion performed by op
strong even when the sky is overcast. The response curve of the GUVA- amp IC1 conforms to the expression
So checking the UV radiation level is S12SD sensor is shown in Fig.1. Its Vo = 4.3 × 106 × Ipd, where Ipd is the
still important. sensitivity is very low at wavelengths current passed by PD1 in amps. So a
UV radiation varies in strength below 240nm, rising steadily to a peak PD1 current of 280nA should result in
during the day, just like visible light at 350nm before dropping sharply an output of 1.2V.
and infrared (IR) heat radiation. As between 360nm and around 375nm. So Most of the circuitry in Fig.2 is
with these other wavelengths, its it has good sensitivity over the UV-B inside a pale yellow rectangle with
intensity tends to follow a bell-shaped range from 280nm to 315nm and even a dashed red border because that

The UVM-
30A module
comprises a
larger PCB
(28 × 12.5mm)
and a smaller
PCB (3.5 ×
2.8mm). The
smaller PCB
hosts the
GUVA-S12SD
UV sensor in
a white SMD
package.

This image is
shown at 250%
actual size.
Fig.1: the sensitivity of the GUVA-S12SD sensor to light within the UV spectrum.
The x-axis is the light wavelength in nanometres, while the y-axis shows the
microamps conducted per milliwatt of incident radiation at that wavelength.
This indicates that it’s most sensitive to UV-A but will also pick up much of the
UV-B spectrum and some UV-C, at reduced sensitivity.

Practical Electronics | May | 2024 29


part of the module is on a small sub- PCB is 28 × 12.5mm. The only com- Connecting it to an MCU
PCB mounted on the larger PCB. The ponents on the larger PCB are a 10μF Since the module has an analogue
smaller PCB measures only 3.5 × supply bypass capacitor and a 3-pin voltage output and operates from a DC
2.7mm square, while the larger module SIL header. supply voltage of 3.3V to 5V, it is quite
easy to connect to a microcontroller
such as an Arduino Uno or Nano. You
just need to connect the + and − power
pins to the +5V and GND pins on the
MCU board, while the ‘OUT’ pin goes
to an analogue input on the MCU, such
as the A0 analogue input, as shown in
Fig.3 and Fig.4.
Once set up, all that’s needed is suit-
able firmware for your Arduino/MCU.
After searching the Internet, I found
a website with a graph showing the
output voltage of the UVM30A mod-
ule plotted against the equivalent UV
Index (see https://bit.ly/pe-may24-uv).
I’ve redrawn this as Fig.5.
On the same website, I also found
Fig.2: the circuit of the UV sensor module is pretty straightforward. A bias an Arduino sketch for a UVI sensor,
voltage is applied to the photodiode from the op amp output via a resistor, although this sketch was designed to
converting the current into a voltage that’s fed to the OUT pin. The yellow display the calculated UVI level using
box surrounds the components on the sub-PCB; the main PCB just adds a a Nokia 5110 LCD module.
bypass capacitor and the 3-pin SIL header with two power pins (+ and −) I adapted this sketch into one that
and the analogue output. displays both the module’s output
voltage and the equivalent UVI figure
on a low-cost 16×2 LCD module with
an I2C serial interface.
Fig.6 shows how an Arduino Uno
can be connected to both the UVM30A
module and the LCD with the I2C inter-
face attached.
The resulting sketch file is called
Arduino_UVI_meter_sketch.ino and is
available from the May 2024 page of the
PE website: https://bit.ly/pe-downloads
When you upload it to the Arduino,
it first gives you this opening display:
Silicon Chip
UVI Meter
Then, after pausing for two seconds,
it starts measuring the output voltage
from the UVM30A module. It con-
Fig.3: wiring up the module to an Arduino Uno couldn’t be much simpler.
verts the reading into the equivalent
Just connect the module’s + supply pin to its +5V, the module’s – supply pin
to its GND and the module’s output to one of its analogue inputs (in this UV Index and displays both, like this:
case, A0, to suit our example sketch). UV Index = 2
Vout = 350mV
It repeats this every 1.5 seconds.
The sketch also sends this data back
to your computer via the Serial Mon-
itor (if you have it connected).
So it is easy to hook the UVM30A
Fig.4: connecting the UV sensor UV sensing module up to an MCU
module to an Arduino Nano like the Arduino and make yourself
isn’t much different than the a handy UVI meter. The sketch could
Uno shown in Fig.3. Once also be adapted to MMBasic code for
again, the module is supplied use on a Micromite or Maximite; any
with 5V from the Nano’s
microcontroller with an analogue
+5V and GND pins while the
module’s analogue output input should do.
signal goes to the Nano’s A0 One morning in late October, I took
analogue input. this arrangement outdoors and got UVI
readings of 1-2 when the Sun was only
about 30° above the horizon.
The readings steadily rose as the
morning wore on (although they

30 Practical Electronics | May | 2024


Shown above, right is the Adafruit
version of the UV sensor. It uses the
same GUVA-S12SD sensor IC as the
Altronics version.

Fig.5: the mapping of the output of the UV sensor to the UV index is primarily linear, except below a UV index of one.
Therefore, the formula to convert its output voltage to the UV index is pretty simple. The sketch source code (available for
download) shows exactly how it’s down.

UV Radiation and UV Index


Ultraviolet or UV radiation is electromagnetic radiation with Most of the UV-B radiation from the Sun suffers the same
wavelengths between 10nm (nanometres) and 400nm – fate, especially when there is heavy cloud cover.
shorter wavelengths than light that is visible to humans, When there is cloud cover, more than 95% of the solar
but longer than the wavelength of X-rays. UV radiation reaching the surface of the Earth consists
UV radiation constitutes about 10% of the total radi- of the longer UV-A wavelength. And these wavelengths
ation from our Sun. Still, this radiation is the primary are of concern when it comes to protecting our skin. So
cause of suntan, sunburn and skin damage resulting in clouds tend to reduce the amount of UV reaching the sur-
skin cancers. face but do not eliminate it; you can still get sunburn on
The section of the solar UV radiation spectrum primarily a cloudy day.
of interest regarding human skin safety is between 100nm The UV Index is an international measurement scale used
and 400nm. This is subdivided into three main divisions: to indicate the intensity of UV radiation in easily understood
UV-A (315nm to 400nm; ‘long wave UV’), UV-B (280nm to terms for the ‘general public’. It uses a scale of 11 or more
315nm; ‘medium wave UV’) and UV-C (100nm to 280nm; steps, with each step corresponding to an increase of UV
‘short wave UV’). radiation intensity of 25mW/m2 (milliwatts per square
Although photons of UV-C radiation carry more energy metre). A UVI of one indicates a UV intensity of 25mW/m2,
than those of UV-B or UV-A and are therefore more capa- two indicates an intensity of 50mW/m2 and so on.
ble of skin damage, the good news is that virtually none Fig.7 shows the UV Index on the right and the correspond-
of the Sun’s UV-C radiation ever reaches the surface of the ing UV radiation intensity on the left. The coloured bands
Earth. These photons are absorbed by oxygen and ozone indicate the five categories into which the UVI levels are
in our upper atmosphere. grouped in terms of their ‘risk of harm’ to our skin.

Fig.7: this shows


the five ranges of
UV index values
that provide some
guidance as to
the danger of skin
exposure under
those conditions.
It will depend
somewhat on your
skin pigmentation,
but it’s still a good
idea to ‘cover up’
at the upper end of
the risk spectrum.

Practical Electronics | May | 2024 31


dropped back when clouds obscured reading of the immediate conditions Adafruit has a smaller version (ID
the Sun). When the Sun was directly that you are experiencing. 1918) available for US$6.50 plus ship-
overhead and the clouds were not ping. It’s also available from Digi-Key
obscuring it, the UVI readings reached Cost and availability in the US for around the same price.
a level of 8 or 9. I obtained the module shown in the There is yet another smaller version
So it appears to be doing its job and photos from Altronics (catalog code available from various suppliers on Ali-
should be helpful for those who spend Z6397) for around $40. If you want to Express. This one measures 19.8 × 10 ×
a lot of time outdoors. By the way, source this in the UK then Amazon 2mm and is available for a few pounds
the Australian Bureau of Meteorology and eBay offer it for around £18, but with free shipping. So you have quite
also publishes UV Index predictions at the time of writing fluxworkshop. a good range to choose from, all with
in their forecasts. For the UK, the Met com offer it for just over £14. the same UV sensor and its surround-
Office includes UVI in its forecasts: This version has the same circuit, ing circuit, in various sizes and prices.
www.metoffice.gov.uk but everything is mounted on a single
Of course, they can only give a PCB measuring only 19 × 10 × 2mm Reproduced by arrangement with
rough idea of what to expect, whereas and seems to originate from the US SILICON CHIP magazine 2024.
this module provides an actual firm Adafruit: www.adafruit.com www.siliconchip.com.au

Fig.6: to make a
practical device,
I added a serial
(I2C) 16×2 LCD
module to the basic
circuit, wired as
shown here. That
allows the Arduino
to display both
the raw UV sensor
output voltage and
the equivalent UV
index in a handy
portable package
if the Arduino is
battery-powered.

EE

Order direct from ELECTRONICS


FR -ROM
GET T CD
£8.99

LATES HE
T CO
OF OU PY TEACH-IN 9
FROM THE PUBLISHERS OF

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

(includes P&P to UK if ordered direct from us) PIC n’ Mix


Including Practical Digital Signal Processing

PLUS...
YOUR GUIDE TO THE BBC MICROBIT
A LOW-COST ARM-BASED SINGLE-BOARD
COMPUTER

Teach-In 9
Get Testing

Teach-In 9 – Get Testing! Three Microchip


PICkit 4 Debugger
Guides
Files for:
PIC n’ Mix

PLUS
Teach-In 2 -Using
PIC Microcontrollers.
In PDF format

This series of articles provides a broad-based introduction to choosing and using a wide range © 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.

ORDER YOUR COPY TODAY: www.electronpublishing.com

32 Practical Electronics | May | 2024


Songbird
By Andrew Woodfield
Here’s a decades-old design brought up to date in a new package and
made to appeal to beginners as well as experienced builders. It’s quick
and easy to build and a great project if you’re new to electronics.

W
hen the festive season or box with a mostly bare aluminium also makes it much easier to build than
birthdays approach, those front panel. I felt it lacked the visual the original design.
interested in electronics appeal to capture the imagination of I removed the original large and
often look for a small, easy-to-build today’s younger audience. costly 8W speaker and its driver tran-
project to give as a gift. Something with This revision was my solution. sistor in favour of a modern, inexpen-
flashing lights or a variety of sounds Along with migrating the circuit to sive piezo speaker. Mounted on the rear
has universal appeal, especially for the 74HC-series CMOS logic family, of the PCB, it produces a bright sound
our (grand)children. Helping a begin- I also redesigned the printed circuit without driving parents to utter despair.
ner to build one of these is the perfect board (PCB) into a more compact and The original used a somewhat
way to spark an interest in the hobby. attractive bird shape – something expensive 9V battery, while a pair of
The problem is identifying a suitable between an overfed festive budgie inexpensive AAA cells power my new
design. During a recent search, I came and a kookaburra! version. The new 3V supply also sig-
across an ‘electronic canary’ designed Modern PCB manufacturing pro- nificantly reduces the current draw to
by Ron de Jong, published in Electron- vides a choice of PCB solder mask under 2mA.
ics Australia way back in May 1981. colours. I chose purple, but you could
Unfortunately, the 74C-series CMOS also go with something like green, yel- What makes it sing?
chip used in the original design is low or red (after all, it was initially a The Songbird consists of two almost
not as widely available as 74HC-se- ‘canary’). Contrasting with the colour- identical sets of three coupled oscil-
ries devices. Also, the original design coded bands of the resistors on the lators, ie, circuits that produce a con-
used a large square PCB mounted in PCB, the overall effect is bright and tinually changing voltage level. Each
a very large plain rectangular plastic cheerful. The double-sided PCB design oscillator uses one of the six CMOS
schmitt-trigger inverters inside the
The ‘inspiration’ for the 74HC14 integrated circuit (IC). Fig.1
Songbird project came shows the basic oscillator circuit used
from the May 1981 edition in each case.
of Electronics Australia. The The inverter (triangle) produces a
image shown is the lead low output voltage when its input volt-
photo used for that article.
age is high and vice versa. Connected
to it are a resistor, ‘R’, and a capaci-
tor, ‘C’. The values of C and R vary in
each oscillator.
When power is switched on, capac-
itor C is discharged, and the inverter
input is at ‘ground’ potential (0V,
or logic ‘low’ level). As a result, the

Practical Electronics | May | 2024 33


Fig.1 (above): the Songbird circuit
uses six oscillators, all based on
this simple RC (resistor-capacitor)
oscillator configuration.

Fig.2 (right): these three


waveforms are created by each
set of three schmitt-trigger
inverter-based oscillators.

output of the inverter is near +3V (a The full Songbird circuit is shown in 3V. It is connected to the circuit via
logic ‘high’ level). The voltage across Fig.3. In each oscillator, a series diode/ switch S1, which acts as a power on/
capacitor C begins to rise as current resistor combination placed in paral- off switch. A 100μF capacitor stabi-
from the high level at the inverter out- lel with resistor R results in an asym- lises the battery voltage so that it does
put flows via resistor R. metric square-wave shape by changing not vary in the short term as the oscil-
When the voltage across C rises the resistance depending on whether lators draw varying currents.
above the schmitt-trigger low-to-high the capacitor is being charged or dis-
transition voltage (about 1.5V in this charged. Different capacitor and resis- Building the Songbird
case), the inverter input recognises tor values in each set of three timing-­ Remember that this is designed to
that the input has gone from a logic chirp-note oscillators produce two be an ideal beginners’ project, so the
‘low’ to a logic ‘high’. It immediately slightly different bird sounds. following description is primarily
changes the inverter’s output to a logic These signals are combined by written for those with limited expe-
‘low’ voltage, almost at ‘ground’ poten- using each output to drive one side of rience. Children from around nine
tial or 0V. the relatively high-impedance piezo or ten years of age can build it (with
The voltage across capacitor C starts speaker, which produces the final help). However, it’s equally suitable
to fall as current flows from the capac- desired bird sounds. for those interested in building a lit-
itor back to the low-level output via The circuit is powered by a battery, tle project that is just a bit different.
resistor R. When the input voltage falls shown at upper-right in Fig.3, compris- Simply put, you can never be too old
below the schmitt-trigger high-to-low ing two 1.5V cells in series to produce to build the Songbird!
transition voltage (about 0.7V), the
inverter input voltage is detected as The basic version of the
a low, and output suddenly switches Songbird uses a simple
to high. The whole cycle then repeats. unetched PCB as the base.
Over many such cycles, the result
is a sawtooth voltage at the input pin If using the battery box
varying from 0.7 to 1.5V, and a square with an integral switch,
wave at the output ranging from almost the base will need to be
slightly wider (63mm) as
0 to 3V. The frequencies of these wave-
the box is longer than the
forms are identical and proportional to holder shown here. Still,
the product of the values of resistor R it does save you from
and capacitor C (the ‘time constant’). having to mount and wire
The basic bird sound is made from up the switch.
two pairs of three of these oscillators
coupled together. In each tri-­oscillator
group, one sets the basic timing, the
second creates the chirp, while the
third makes the tone of the bird sound.
Other components around each oscil-
lator modify and combine these three
to produce the final sound. The result-
ing waveforms are shown in Fig.2.
At the top of Fig.2 is shown the
timing oscillator, in the middle is the
chirp oscillator and at the bottom is
the note oscillator.

34 Practical Electronics | May | 2024


Silicon Songbird
Fig.3: the full circuit of the Songbird replicates the oscillator configuration shown in Fig.1 six times. This is convenient
as IC1 contains six inverters, so only one chip is needed. Each triplet of oscillators uses a different set of feedback
components to produce different frequencies. They are ganged up via resistors and capacitors, ultimately feeding the
piezo speaker together via connector CON2.

Children and beginners will need 5 A soldering iron holder – it helps resistor using its coloured bands
help from a more experienced builder, you to avoid accidental contact before fitting (or even better, verify
given the inherent risks of a hot solder- with the iron’s hot tip! A good sol- the value with a DMM set to mea-
ing iron and other possibly dangerous dering station will come with one. sure ohms) because different resis-
tools like side-­cutters. 6 A ‘solder sucker’ desoldering tool tors have very similar bands (eg, 1kW,
The instructions assume it will and/or solder wicking braid – these 10kW and 100kW).
be built in four stages, each taking help you to remove solder if you get Your parts supplier may only have
between 20 and 45 minutes. You might it in the wrong place or incorrectly (smaller) 1/8W resistors or (more pre-
prefer to make it in several shorter place a part and need to remove it cise) 1% tolerance resistors, which
10-to-15-minute bursts to better match (that can happen to anyone). will work just as well. 1% resistors
a younger child’s concentration. For 7 A multimeter – you might find this have five bands rather than four. See
the more experienced, you can prob- helpful for checking resistor val- the table in the parts list, which shows
ably build the whole thing in about ues, checking battery voltages and how they vary.
1½ to 2 hours. testing for shorts and open circuits. You will need to bend the leads of
Still, there’s no rush. The Songbird They start under £5 (eg, Jaycar Cat the resistors into a U-shape so you
will happily wait to burst into song QM1500, Altronics Cat Q1053B)! can insert them into the pads on the
until you’re finished. You will likely PCB, as shown in Fig.5(a). You can do
make fewer mistakes if you take your Find a clear space to build the Song- this with your fingers or pliers, but it’s
time. Check each part before solder- bird, such as a kitchen table, with more precise to use a lead-bending
ing and enjoy the relaxed pace of the plenty of light. Also, ensure you have jig (available at low cost from stores
construction process. good ventilation because soldering like Jaycar and Altronics), as it will
will create some fumes. Place a cloth form the bends precisely the right dis-
Some tools you’ll need include: or a layer of newspaper (or similar flat tance apart. Then, insert the resistor
1 A 15-25W soldering iron with a fine disposable material) over your work- as shown in Fig.5(b).
to medium tip. Keep this clean by ing area to avoid marking the tabletop Solder the leads, making sure to
carefully wiping the tip periodi- with your tools, the PCB or molten sol- form a shiny fillet like in Fig.5(c), then
cally on a damp rag or sponge. der during assembly. trim the excess leads using side-cutters
2 0.5-1.0mm fine rosin-cored solder. A helpful way to handle the parts at the height indicated by the dashed
If this is your only project, a 15g during construction is to place them line. Protect your eyes when doing
‘hobby tube’ will be enough in a small plastic tray, say 300mm × this, as the cut leads can be sharp
3 Sharp pair of small side cutters. 200mm, on one side of your workspace. and will fly off if you don’t hold them
while cutting.
Other useful tools include: Construction step #1 (resistors) Note that there are two ways to
4 Fine needle-nosed pliers or a com- The location for each resistor is insert each resistor but the circuit
ponent bending jig (Jaycar Cat shown in Fig.4. It’s usually easiest will work either way. Still, it’s neater
TH1810 or Altronics Cat T1495); to install the resistors in groups. to place them all in the same orienta-
these bend the component leads. Double-­c heck the value of each tions, as in Fig.4.

Practical Electronics | May | 2024 35


Fig.4: this shows the
shape of the Songbird
PCB and where each
resistor is soldered. The
colour bands are shown
for four-band (5%)
resistors; see the parts
list for the equivalent
five-band codes. It’s still
a good idea to check
them all using a DMM
set to measure ohms,
as some colours can be
easily confused (eg, red
and orange).

Construction step #2 capacitors are polarised, meaning you white PCB overlay. One end of the IC
(diodes and capacitors) must orient them correctly. The nega- is marked by a notch in its body (some
Next, fit the six diodes as shown in tive lead is marked by a stripe on the ICs have a divot or dot in the nearby
Fig.6. These are all the same type, but capacitor body, while the overlay dia- corner instead). This end goes clos-
your diodes may have a slightly differ- gram indicates where the longer posi- est to the Songbird’s eye, as shown
ent body colour to those shown here. tive lead is inserted. in Fig.8.
Their size is exaggerated for clarity in Once they are in the right places and Before trying to fit the IC, it’s help-
Fig.6; the important thing is that, in have the correct orientations, solder ful to slightly bend each row of IC
each case, the black stripe on the end each capacitor and trim the leads. The pins until they are close to parallel.
of the glass body must face down or two larger electrolytic capacitors go on Gently roll each side of the IC towards
to the right as shown. the rear side, allowing the Songbird’s the ends of the pins on a hard flat sur-
Bend each diode’s leads as you did eye to be more clearly seen. Mount face, as shown in Fig.7, so that the IC
for the resistor. When you insert it, them last. pins lie parallel (or close to it). You
make sure to align the diode’s black can also buy a tool to do this (again,
band with the band printed on the PCB Construction step #3 check Jaycar and Altronics), which
overlay. Solder and trim the leads in (the integrated circuit) is easier to use, but the flat surface
the same way as for the resistors. You must fit the 74HC14 CMOS IC method does work well provided you
Next, fit the four ceramic capacitors, to match the pattern shown on the are careful.
shown in yellow in Fig.6. Two have the
same value. Take care to place the cor-
rect part in the right location, although
they are non-polarised, so it doesn’t
matter in which of the two possible
orientations you fit them. The PCB
silkscreen overlay shows the value of
each capacitor to help you.
Ceramic disc capacitors may be
marked in various ways. The most
common markings are shown in Fig.6.
After fitting each component, solder
and trim the leads similarly to before.
Next, fit the three smaller axial
electrolytic capacitors, which are
mounted on the top side of the PCB.
They come in metal cans with a plastic
covering except at the top. Electrolytic

Fig.6: this diagram will help you to fit the diodes and the capacitors on the
Fig.5: each resistor should be (a) bent Songbird’s PCB. The ceramic capacitors are not polarised and can go in either
to shape, (b) placed down on the PCB, way around. However, the electrolytic capacitors must have their longer
soldered, and then trimmed with side leads inserted in the pads marked with a + (the stripe on the can indicates the
cutters (dotted line height) to produce opposite, negative lead). Similarly, the diodes must be fitted with the cathode
the result at (c). stripes facing as shown.

36 Practical Electronics | May | 2024


Parts List – Songbird
1 double-sided purple, green, yellow or red PCB coded 08103231, 61 × 75mm
1 2×AAA switched battery box with flying leads (BAT1+S1) OR
1 2×AAA battery holder and toggle or slide switch (BAT1/S1)
1 27mm diameter piezo loudspeaker (SPK1)
1 52 × 45mm (63 × 45mm if using battery box) unetched copper-clad PCB
(optional; stand for basic version)
Semiconductors Resistor Colour Codes
1 74HC14 hex schmitt-trigger inverter, DIP-14 (IC1)
6 1N4148 75V 200mA diodes, DO-35 (D1-D6)
Capacitors
1 220μF 16V radial electrolytic
2 100μF 16V radial electrolytic
2 10μF 16V radial electrolytic
2 1nF 50V ceramic
1 680pF 50V ceramic
1 470pF 50V ceramic
The ‘basic’ version of the Songbird.
The main PCB is soldered along its Resistors (all 1/4W axial, 5% or better)
base to a single-sided unetched PCB. 2 1MW 2 680kW 1 470kW 3 330kW 2 100kW
The battery holder and slide switch 2 68kW 2 47kW 2 39kW 2 10kW 2 1kW
are also mounted to the unetched PCB.

Now fit the IC into the PCB as along the lower edge of the Songbird battery box. Just make sure you can
illustrated in Fig.8 and solder all the PCB. The result is surprisingly robust. still open it to replace the cells!
pins. You don’t need to trim the pins The double AAA-cell battery holder The piezo speaker can be mounted
after soldering, as they should only and slide switch are then mounted on the rear of the main PCB using
just project through the other side of directly to this blank PCB, the former a 3D-printed speaker mount (see
the PCB. with a couple of drops of epoxy glue Fig.9) and a couple of dabs of hot
and the latter by soldering three of the glue. You could print this yourself
Construction step #4 unused lower tags of the slide switch if you have a 3D printer – STL files
(speaker and battery) to the blank PCB base. for all the 3D-printed items used in
There are two ways to complete the Note that kits will include a battery this project are available from the
Songbird. You can use a simple square box with an integral switch, simpli- May 2024 page of the PE website:
PCB for the base. This version is quick fying construction somewhat. The kit https://bit.ly/pe-downloads
and easy to build. Alternatively, you will also have a double-sided tape pad The two piezo speaker wires may
can create a more elaborate birdcage that you can use to stick that box to be connected either way around to the
and base. That will take more time, the base very easily and quickly. Since PCB at the two points marked ‘Piezo’
but it gives a more attractive finish to the battery box is a bit longer than a on the overlay, as shown in Fig.10.
the project. simple battery holder, it would be best You can trim the wires slightly if they
to use a 63 × 45mm unetched PCB for are too long before soldering them in
Option 1 – simple PCB base the stand in this case (not included place. These wires may be almost any
The photo at upper left shows the in the kit). colour, and some can be pretty deli-
basic version with the PCB mounted Alternatively, you could use hot cate, so a little care is required.
to a single-­sided, unetched 52 × 45mm melt glue or silicone sealant to attach Finally, add the battery and switch
PCB base by soldering a few spots the Songbird PCB to the side of the wiring; the switch is not required for
the battery box included in the kit, as
it is already integrated into the box.
In that case, you just need to connect
the two wires from the box to the PCB
but watch the polarity; the red wire
must go to the terminal marked + on
the PCB.

Fig.7 (above): bend the IC pins Option 2 – bird cage


carefully to be approximately parallel I designed a 3D-printed base for the
before inserting them into the PCB. prototype. Those with a lathe may
It’s better to use a lead straightening prefer to create a more elegant base
tool, but easy enough to do it with a from suitable timber. Alternately, a
flat surface as long as you don’t apply
careful hunt around the supermar-
more force than needed.
ket shelves may locate a suitable
15mm-tall, 70mm diameter screw-on
plastic jar lid.
Fig.8 (right): the 74HC14 hex inverter The battery holder and switch can
IC must be fitted with its notch (pin then be mounted in this base. I used
1 marking) matching the pattern a toggle switch for this, rather than
printed on the PCB, as shown here. a slide switch, because it’s easier

Practical Electronics | May | 2024 37


The 3D-printed piezo speaker mount
The piezo speaker recommended is a low-cost 27mm diameter part commonly
used in greeting cards and small toys. They are readily available from a vari-
ety of suppliers. Slightly more expensive piezo speakers are made complete
with a thin pressed metal enclosure to form a resonating chamber, but they
are harder to mount to the Songbird.
The 3D-printed holder used here has three benefits. It simplifies mounting
(just use glue!), the sound is significantly improved, and it’s all quite cheap and
easy to do. It’s surprising the difference this simple piezo mount makes to the
overall sound volume. The piezo sits on the circular lip of the mount facing
outwards. A tiny drop of super glue holds the piezo to the mount.
It’s also possible to make a 5-10mm-high 27mm -diameter tube speaker
mount using rolled-up paper. Produce a wall thickness
of about 1mm, gluing the paper with PVA or similar
glue to give it a little rigidity. Glue the circumfer-
ence of the piezo speaker to the top surface of
this tube with a drop of super glue, then hot glue
the assembly into place on the rear of the PCB.
The ‘bird cage’ version of the
Fig.9: this simple 3D-printed speaker Songbird uses a 3D-printed base and
mount improves the sound quality and some wires to act as a ‘cage’. The
simplifies construction. speaker is attached to the rear of the
PCB using the mount from Fig.9.

to mount on a curved surface. The If you prefer that the speaker is out
Songbird is then mounted on the base of sight, there is enough space in the
using two small PCB off-cuts mea- base for it to be glued there using the
suring about 3 × 6mm. These are sol- 3D-printed speaker holder. However,
dered on the lower edge on the rear the bird sounds will be less audible.
of the main PCB, separated by a gap The birdcage is made from 18-gauge
of about 10mm. (1.2mm diameter) galvanised wire and
This method allows the Songbird to a 20mm diameter piece of tinplate.
be mounted into the slot in the base You can obtain the galvanised wire
and then adjusted from side-to-side in from most garden centres or hardware
the slot to centre the Songbird in its stores. I cut the circular piece of tin-
cage. The gap in the slot is used for plate from a discarded tin can.
the wiring to the switch and battery. It’s easiest to begin by unrolling
The wiring details inside the base are about a metre of wire from the wire
shown in Fig.11. roll. Get this as straight as possible by
The piezo speaker is mounted in holding one end of the wire in a vise
the same way as the basic version and pulling on the other end with a
(Option 1). The battery and speaker pair of heavy-duty pliers. Modest force
wiring to the PCB is the same as shown is sufficient. Then cut eight 105mm
in Fig.10. lengths from this straight piece.

Fig.10: the battery and piezo speaker


wiring are shown here. This diagram
also shows the overlay markings for
these connections to help you identify
them. If your battery holder has an
integral switch, you don’t need the
external switch; just run the red wire
from the battery holder straight to the
Fig.11: if building the birdcage version, glue the battery holder into the base pad marked + on the PCB, parallel to
before installing the switch and completing the wiring. the negative (black) wire.

38 Practical Electronics | May | 2024


Using a piece of waste timber or Adding signs
plywood, place these wires radially You can add the optional ‘Please Do
around the circular tinplate as evenly Not Feed The Bird’ sign. This, and
as possible. Tape them in place tem- the equally optional extra sign for the
porarily using short pieces of paint- other side, can be glued to the front
er’s masking tape. Once everything is and back of a piece of card or onto a
nicely aligned – the tape really helps 3D-printed frame (the latter is also
with this – solder the wires to the cir- available as a download). This can
cular tinplate. The timber insulates be glued to a suitable location on the
the soldered wire and plate and pro- Songbird’s cage.
tects your work surface.
Bend each wire into the final bird- Operation
cage shape by hand. The wire is very Turn on the Songbird’s switch and
easy to bend yet holds its shape the Songbird will burst into song
well. You can then ease the ends almost instantly. The prototypes I
into the eight holes in the base of the made were joined by several addi-
3D-printed base or your timber base. tional copies as budding builders
To ensure a good fit, you may need added their own efforts. The cho-
to drill out each of the eight holes in rus of the Songbird birds produced
Fig.12: the optional signs for the
the 3D-printed base. This depends a fantastic sound. Parents will be birdcage version of the Songbird. You
on the accuracy of the 3D printer. ‘delighted’ to learn that battery life can download the sign artwork and 3D
These 1.2mm diameter holes are is at least six months of regular use! printer (STL) files from the PE website.
evenly spaced on a 65mm diameter If you want to adjust the Songbird’s
circle centred on the 70mm diame- sound, changing the value of the
ter base for those making up their 330kW and 470kW resistors in series
own base from other materials. Add with the 1nF capacitors will have the
a small drop of epoxy or hot glue most significant impact.
inside the base to hold each of the
wires in place.
It all sounds complicated, but in
practice, it takes surprisingly little Reproduced by arrangement with
time and effort and gives a pleasing SILICON CHIP magazine 2024. Fig.13: The 3D-printed sign frame (28
visual finish to the project. www.siliconchip.com.au × 18mm) for holding the Fig.12 signs.

ESR Electronic Components Ltd BACK ISSUES


All of our stock is RoHS compliant and CE Practical
approved. Visit our well stocked shop for Electronics
all of your requirements or order on-line.

We can help and advise with your enquiry, BACK ISSUES – ONLY £5.95
from design to construction. Practical Practical Practical Practical Practical
D NA –
D NA –

IG E
IG E

PE

!
PE

ES M
N
ES M
N

N NEW E
N NEW E

Electronics Electronics Electronics


Electronics

Electronics
EW
EW

The UK’s premier electronics and computing maker magazine The UK’s premier electronics and computing maker magazine The UK’s premier electronics and computing maker magazine The UK’s premier electronics and computing maker magazine The UK’s premier electronics and computing maker magazine
Circuit Surgery Make it with Micromite Audio Out Circuit Surgery Make it with Micromite Audio Out Circuit Surgery Make it with Micromite Audio Out Flowerpot speakers! PIC n’ Mix Circuit Surgery Make it with Micromite Audio Out Circuit Surgery
Timing and metastability Build an RGB display project Construct a Timing and metastability Fun display project How to make a Transformers Accessing Internet data Superb microphone A low-cost route to Software tools for Understanding Analogue inputs and Constructing the PE Micro-Cap 12
in synchronous circuits using a Micromite Plus transistor radio in synchronous circuits using a Micromite Plus transistor radio and LTspice with your MKC preamplifier high-quality Hi-Fi the PIC18F Differential amplifiers using servomotors Theremin amplifier simulator review

Frequency Reference Mastering Nutube Guitar WIN! Touchscreen WIN! Ultrabrite LED WIN! Don’t miss Random WIN!
WIN!
Signal Distributor RFID tags for Microchip Overdrive and Superb PE PIC Microchip Wide-range Microchip bike light Microchip
Explorer 16/32 our Super Number Microchip
MPLAB Starter Kit

your projects
Curiosity HPC
Development Distortion Pedal Development PIC24F LCD and
USB Curiosity
RCL Box
MCP19114 Flyback
Standalone
Development
Kit Summer Sale! Generator for Serial Memory
Products
Board
WIN!
Board Development
Board
Evaluation
Board WIN! WIN!

Clever Controller
Meet the for dumb chargers
Meet the Cricket: Mastering stepper Micromite
making IoT designs motor drivers Explore-28 Hi-Fi amp on
super easy! the cheap!
Programmable Robot Buggy

3D Printing • Cable • CCTV • Connectors • Components •


Thermal Programmable Ultrasound Completing the
Thermal Roadies’ Test sensing! High-power 45V/8A
Regulator Signal Generator
Regulator Variable Linear Supply
Make your own PCBs Tunable HF Making a Fun LED
with our precision Preamplifier Building the splash with Christmas
Fabulous low-cost Low-noise

Enclosures • Fans • Fuses • Hardware • Lamps • LED’s •


Solder Reflow Oven NeoPixels! Tree offer!
Concrete speakers! theremin PSU
PLUS! PLUS! PLUS! PLUS! PLUS!
Techno Talk – Tin whiskers scourge Apr 2021 £4.99 Techno Talk – No blame, no shame? Mar 2021 £4.99 Techno Talk – Bad science and good Jun 2021 £4.99 Sep 2020 £4.99 Techno Talk – Triumph or travesty? Dec 2020 £4.99
04 03 06 Cool Beans – Even cooler ping-pong ball lights! 09 12
Cool Beans – Bouncing around the Maxiverse Cool Beans – Round-up of NeoPixel effects Cool Beans – Smoothing LED colour transitions Net Work – IP security cameras Cool Beans – Mastering NeoPixel programming
Net Work – Hydrogen: a viable alternative to batteries? 9 772632 573016
Net Work – Videoconference cameras 9 772632 573016
Net Work – Lockdown technology and how we now work 9 772632 573016
Techno Talk – The perils of an enquiring mind... 9 772632 573016 Net Work – The (electric) car’s the star! 9 772632 573016

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

Leads • Loudspeakers • Panel Meters • PCB Production •


Power Supplies • Relays • Resistors • Semiconductors • We can supply back issues of PE/EPE by post.
Soldering Irons • Switches • Test Equipment • Transformers We stock magazines back to 2006, except for the following:
and so much more…
2006 Jan, Feb, Mar, Apr, May, Jul
Monday to Friday 08:30 - 17.00, Saturday 08:30 - 15:30 2007 Jun, Jul, Aug
2008 Aug, Nov, Dec
2009 Jan, Mar, Apr
2010 May, Jun, Jul, Aug, Oct, Nov
2011 Jan
2014 Jan
2018 Jan, Nov, Dec
2019 Jan, Feb, Apr, May, Jun
Issues from Jan 1999 are available on CD-ROM / DVD-ROM
Station Road If we do not have a a paper version of a particular
Cullercoats issue, then a PDF can be supplied – your email address
North Shields must be included on your order.
Tyne & Wear
NE30 4PQ Please make sure all components are still available before
commencing any project from a back-dated issue.
Tel: 0191 2514363 [email protected] www.esr.co.uk

Practical Electronics | May | 2024 39


Teach-In 2024
Learn electronics with
the ESP32 by Mike Tooley
Part 3 – Analogue input and output

I
n the last month’s part of our Teach-In series, we
introduced digital I/O and showed you how to interface About Teach-In
buttons and switches, and how to drive loads such as Our latest Teach-In series is about using the popular ESP32
LED, relays and sounders. We also showed you how to use module as a basis for learning electronics and coding. We
the Serial Monitor to test and debug your code. In this third will be making no assumptions about your coding ability
or your previous experience of electronics. If you know one
part we will be introducing the ESP32’s analogue-to-digital
but not the other, you have come to the right place. On
converter (ADC) and moving into the analogue world. Our the other hand, if you happen to be a complete newbie
Teach-In Practical Project is a tester for 1.5V alkaline batteries. there’s no need to worry because the series will take a
The learning objectives for this third part of our series are progressive hands-on approach. There will be plenty of
to know how to: time to build up your knowledge and plenty of opportunity
n Configure and use simple analogue I/O to test things out along the way.
n Interface analogue sensors We’ve not included too much basic theory because this
n Use binary, octal, hexadecimal and ASCII. can be easily found elsewhere, including several of our
previous Teach-In series, see:
ESP32 analogue input https://bit.ly/pe-ti
The ESP32 has two 12-bit analogue-to-digital converters https://bit.ly/pe-ti-bundle
(ADC). Each of these supports up to 18 analogue channels, Earch month, there’ll be projects and challenges to help you
but not all may be available in a particular development check and develop your understanding of the topics covered.
board implementation. For example, the 30-pin board that
we’re using for most of our practical projects has just six the DAC) to an analogue value perceived by the comparator
ADC1 channels and nine ADC2 channels available. A further as being the same as the analogue input.
limitation is that ADC2 is unavailable when Wi-Fi is being
used. Obviously, this isn’t an issue if Wi-Fi isn’t required, but Reading analogue inputs
it might be a problem if you need many analogue channels. Last month, we used digitalRead() to sense the state
Fig.3.1 shows the ADC pins available on the most common of the ESP32’s GPIO pins, the result being either HIGH or
30- and 36-pin ESP32 boards. LOW. The corresponding function for analogue inputs is
The ESP32 ADC uses a technique known as ‘successive analogRead().
approximation’. This uses a comparator
that compares an analogue input with the
output of a digital-to-analogue converter
(DAC), as shown in Fig.3.2. The digital
input to the DAC (a 12-bit value) is held
in a dedicated successive-approximation
register (SAR). This holds a series of
values that rapidly approximate to
an SAR value that’s equivalent to the
analogue input. The process stops when
the data held in the SAR is converted (by

Gotcha!
The ESP32 supports 18 different
analogue channels but not all of
them may be present on a particular
development board.
Fig.3.1. Analogue pins on two common ESP32 development boards (30-pin left/36-pin right).

40 Practical Electronics | May | 2024


Fig.3.3.
Using a
potentiometer
to test the
ADC.

Gotcha!
ADC2 can’t be used if your application is using Wi-
Fi. So, if you do need Wi-Fi it’s important to use
ADC1 instead.
Fig.3.2. An ADC based on successive approximation.

As you might expect, analogRead() requires a GPIO pin as There are two things to note from this. First, we need to
an argument. Note that we would normally want to assign the use a float because we are no longer dealing with integer
pin before the main body of code using a statement like this: values for voltage.
Second, a scaling factor (3.3/4095) is needed to convert
int analogPin = 15; // Sensor voltage on pin-15 our raw reading from the ADC into a corresponding voltage.
It’s worth checking this out by connecting an ordinary
Here, GPIO15 (often marked ‘D15’ on development boards) potentiometer (10kΩ to 20kΩ would be ideal) across the
corresponds to ADC2 Channel 3. Later in the code we will 3.3V supply with the slider taken to the pin in question, as
need a variable in which to store the returned analogue value shown in Fig.3.3. A suggested wiring arrangement is shown
from pin-15. We can do this using: in Fig.3.4.
Enter or download the code shown in Listing 3.1 – all this
int rawReading = analogRead(analogPin); // month’s code is available for download from the May 2024
Sensor value page of the PE website: https://bit.ly/pe-downloads
When you execute the code and start the Serial Monitor
The result stored in rawReading will be a 12-bit value you will see the voltage present at pin-15 updated every
from the ADC. This can range from 0 to 4095 (where 4095 second. If you rotate the shaft of the potentiometer over its
corresponds to the 3.3V DAC reference voltage). full range, you will see the voltage changing smoothly from
In some applications you might need to convert the 12-bit 0V at one extreme to 3.3V at the other. Typical analogue
value from the ADC into a corresponding voltage value. To readings are shown in Fig.3.5.
do this, you will need to convert the value returned by the
ADC and store it in a float variable, as in:

Float volts = rawReading * (3.3/4095); //


Convert to voltage

Fig.3.4. Wiring arrangement for the circuit shown in Fig.3.3. Fig.3.5. Typical analogue readings obtained from the Serial Monitor.

Practical Electronics | May | 2024 41


Gotcha! Listing 3.1 Testing the ADC with a potentiometer
The ESP32’s ADC are non-linear at both
extremes. It’s important to be aware that input /* Analogue input using a potentiometer */
voltages below 0.1V will be read as 0V, while
inputs above 3.2V will be read as 3.2V. If you int analogPin = 15; // Analogue input via ADC2 Channel 3
can live with these restrictions, then it’s worth
noting that the device is reasonably linear void setup() {
from 0.5V to 2.5V. Serial.begin(9600);
}

void loop() {
Gotcha! int rawReading = analogRead(analogPin);
Voltages outside the range 0 to 3.3V must // The raw reading from the potentiometer needs to be
never be applied to the ESP32’s analogue // converted to volts and stored as floating point
input pins. If you need to measure larger float volts = rawReading * (3.3/4095);
voltages it will be necessary to use a potential // Send the value and print it using the serial monitor
divider at the input. Furthermore, in some Serial.println(volts);
applications it’s important to avoid reverse delay(1000); // Delay for 1s before repeating the loop
polarity at the input. }

Listing 3.2 Using the serial plotter

// Using the serial plotter


void setup() {
// Start serial communication at 9600 bps
Serial.begin(9600);
}

void loop() {
// Select ADC2 Channel 3 (GPIO pin-15)
int gpioPin = 15;
// Read the voltage at D15
int analogVolts = analogReadMilliVolts(gpioPin);
// Display the current voltage in mV
Fig.3.6. The ESP32’s ADC step size. Serial.printf(“ADC input = %d mV\n”,analogVolts);
// Wait for a while
delay(1000);
ESP32 ADC performance }
Before we move on to some practical ESP32
ADC applications it’s worth explaining some
of the specifications and potential limitations size is illustrated in Fig.3.6. If ESP32’s ADC is that it does exhibit
of the device. you don’t need the full default some non-linearity, as shown in Fig.3.7.
12-bit resolution you can
Resolution select a different value using Range
The resolution of an ADC is defined by its step size. analogReadResolution(). The ESP32’s analogue input range extends
In the ESP32, a 3.3V supply reference is used with a For example, 10-bit resolution from 0V to 3.3V. The voltage applied must
12-bit ADC. This achieves a comfortably small step (210 = 1024 different values) not be allowed to fall outside this range.
size of approximately 0.8mV (3.3/4096). This step can be selected using
analogReadResolution(10). Introducing the Serial Plotter
Thus far in our series we’ve made
Accuracy extensive use of the IDE’s Serial Monitor,
The accuracy of an
ADC depends on
the accuracy of its
reference voltage
source. The reference
voltage for the ESP32
is derived from the
3.3V supply and there’s
no provision for an
external (and more
accurate) reference
voltage source.

Linearity
Ideally, an ADC
should be perfectly
linear. Unfortunately,
Fig.3.7. ESP32 ADC non-linearity (the range from a n u n c o m f o r t a b l e Fig.3.8. Circuit to demonstrate the use of the
1V to 2.75V can be considered reasonably linear). p e c u l i a r i t y o f t h e Serial Plotter.

42 Practical Electronics | May | 2024


Listing 3.3 LDR test code

/* Simple LDR analogue interface */


int analogPin = 15; // Use ADC2 Channel 3

void setup() {
Serial.begin(9600);
}

void loop() {
// Get the current input from the LDR
int ldrValue = analogRead(analogPin);
Serial.println(ldrValue);
delay(1000);
// Repeat forever
}

but there’s another useful tool that’s worth knowing about.


This is the Serial Plotter, which will provide you with a neat Fig.3.11. Simple LDR interface.
way of visualising data that changes over time. We’ll now use
the Serial Plotter to show how the voltage across a capacitor electronics, as we will see a little later when we need to average
increases as it charges. The code is shown in Listing 3.2, the a voltage over a period of time.
circuit in Fig.3.8, and a suggested wiring diagram is illustrated
in Fig.3.9. When running Listing 3.2 you will need to start Interfacing analogue sensors
execution with the shorting link in place see Fig.3.8.) The ESP32’s analogue inputs provide you with a means of
After the code in Listing 3.2 has been compiled and uploaded, interfacing a variety of simple, low-cost analogue sensors.
select Tools from the IDE’s menu bar and then Serial Plotter. As an example, we will show you how to sense ambient light
Next, remove the shorting link so that the capacitor begins to level using a light-dependent resistor (LDR).
charge. You should observe a Serial Plotter display like that Interfacing analogue sensors with the ESP32 is usually
shown in Fig.3.10. After the capacitor has fully charged (ie, very straightforward, as we will now show using an LDR.
when the voltage at D15 has reached and flattened off at 3.3V) Most LDRs exhibit resistances of several megohms in total
replace the link and repeat the measurement with different darkness falling progressively to a few hundred ohms in
values for C1 and R1 (try 10µF, 47µF and 220µF). Note how bright sunlight. Since the ESP32 can’t sense resistance
this affects the charging rate. C-R circuits are widely used in directly, this resistance change needs to be converted to
a corresponding change in voltage. This is easily done by
connecting a series resistor to supply current to the LDR.
The voltage dropped across the LDR will then be inversely
proportional to incident light. This voltage can then be
passed to an analogue input for sensing.
A simple arrangement for light sensing is shown in Fig.3.11
with R1 and LDR1 forming a potential divider across the 3.3V
supply. The level of ambient light can be displayed using
the Serial Monitor using the code shown in Listing 3.3. Once
again, we’ve used ADC2 Channel 3 and GPIO pin D15. A
suggested wiring diagram is shown in Fig.3.12.
If you execute the code shown in Listing 3.3 you will
be rewarded with values that decrease as the intensity of
incident light increases. Our readings varied from as low
as 200 in strong sunlight to 4095 in full darkness. Average
room lighting produced a value of around 2200.

Fig.3.9. Suggested wiring layout for Fig.3.8.

Fig.3.10. Serial Plotter display for Listing 3.2. Fig.3.12. Suggested wiring diagram for Fig.3.11.

Practical Electronics | May | 2024 43


interface (see last month). This relay
Listing 3.4 Code for the automatic light controller is activated by a LOW state output
from D4. A suggested wiring diagram
/* Simple analogue LDR lighting controller using a relay.
is shown in Fig.3.14. Note that the
NB: The relay interface is active ‘low’ so a LOW output will
turn the load ‘on’ while a HIGH output will turn it ‘off’. relay derives it positive supply from
*/ the development board’s +5V/VIN
pin rather than from the +3.3V pin.
int ldrPin = 15; // Analogue input via ADC2 Channel 3 The code for the automatic light
int relayPin = 4; // Digital output via GPIO 4 controller is shown in Listing 3.4.
int thresholdValue = 2000; // Set darkness threshold This has been liberally commented
and should be reasonably self-
void setup() { explanatory. Note that we have set
pinMode(relayPin, OUTPUT); // Set the relay as an output the switching threshold to 2000.
digitalWrite(relayPin, HIGH); // Start with light ‘off’
This is an arbitrary value and can be
}
changed to suit your own situation.
void loop() {
// Get the current analogue input from the LDR ESP32 analogue output
int ldrValue = analogRead(ldrPin); Having dealt with analogue input,
if (ldrValue < thresholdValue) it’s now time to introduce analogue
digitalWrite(relayPin, HIGH); // Enough light so switch ‘off’ output. Unfortunately, the ESP32
else does not incorporate a true digital-to-
digitalWrite(relayPin, LOW); // Not enough light so switch ‘on’ analogue converter (DAC) so analogue
delay(1000); // 1s delay output is based on a technique known
// Repeat forever
as pulse-width modulation (PWM).
}
Because the ESP32 uses PWM the
analogWrite() function produces
a rectangular pulse waveform rather
than a continuous analogue voltage.
This can be a tricky concept to grasp,
so we will take some time to explain
how it works.
Fig.3.15 shows three different
pulse waveforms. At any time,
the voltage described by these
waveforms can only be either HIGH
or LOW. The waveform in Fig.3.15(a)
is a perfect square wave and is HIGH
for 50% of the time and low for the
other 50%. This is equivalent to a
mark-space ratio (HIGH-LOW ratio)
of 1:1 or a duty cycle of 50%.

Fig.3.13. Circuit of the automatic light controller.

Fig.3.15.
PWM
principle.

Fig.3.14. A suggested wiring layout for Fig.3.13.

Check it out!
Having demonstrated how easy it is to sense light level using
a low-cost LDR it is worth showing how this inexpensive
component can form the basis of a simple automatic lighting
controller. Fig.3.13 shows the circuit of our automatic light
controller. The output of our ESP32 at D4 is fed to a relay

44 Practical Electronics | May | 2024


analogWrite(outPin, 200); // Output 2.64V

Fig.3.16 shows the output waveform produced when this


function is executed. Note that the pulsed output is not
constant (as with a true analogue signal).
You can also define a custom range of duty cycle values.
If we need 10-bit instead of 8-bit resolution we can use:

analogWrite(outPin, 511, 1023); // Output 1.65V

The default PWM frequency for the analogue channels is 5kHz


but this can be changed if required. To set the frequency to
10kHz you could use:

analogWriteFrequency(10000); //

Generating waveforms
Let’s now move on to generating a waveform rather than a
steady average. This is a little bit trickier because we will
Fig.3.16. PWM output waveform. need to code the waveform into a repetitive loop in which
successive values of duty cycle are output via the DAC. Listing
3.5 shows an example of generating a stepped waveform:
If you enter and execute the code in Listing 3.5 and connect
a DC voltmeter between pin-15 and ground you should be
rewarded with series of voltage values that steadily increment
from zero to about 2.9V in increments of about 0.32V. This
is a simple low-speed stepped waveform. You might now be
wondering if it’s possible to generate a sinewave so let’s examine

Listing 3.5 Code for generating a stepped output voltage

/* Simple application to produce a stepped output


Using the default ult PWM setting (5kHz) */
Fig.3.17. Improving the output waveform using a low-pass filter.
int outPin = 15; // Use GPIO D15

The waveform in Fig.3.15(b) is HIGH for 25% of the time void setup() {
and low for the remaining 75%. It has a mark-space-ratio of }
1:3. The HIGH time is one quarter of the total time for the
cycle and so the duty cycle is 25%. void loop() {
for (int step = 0; step < 10; step++) {
The waveform in Fig.3.15(c) is HIGH for 75% of the time
analogWrite(outPin, step * 25);
and low for the remaining 25%. It has a mark-space-ratio of delay(2000); // 2 sec. delay between levels
3:1. The HIGH time is three quarters of the total time for the }
cycle and so the duty cycle is thus 75%. }
Now look again at the three waveforms in Fig.3.15 and note
how the average value of voltage differs according to the duty
cycle. In Fig.3.15(a) the average value is 0.5V where V is the Listing 3.6 Code for sinewave generation using a look-up table
maximum value. The corresponding averages for Figs.3.15(b)
and 3.15(c) are 0.25V and 0.75V. Thus, as we change the duty /* Low frequency sine wave generator.
cycle of the wave we also change its average value. This code uses the default PWM settings. */
The first of the two parameters used in the analogWrite()
function is the GPIO pin number, while the second relates to int outPin = 15; // Use GPIO D15
the duty cycle of the waveform. By default, this parameter // This is the sinewave lookup table:
const uint8_t sineLUT[] = {
can range from 0 to 255, corresponding to duty cycles from
128, 152, 176, 198, 218, 234, 245, 253,
zero to 100%. So, for example, to generate a 50% duty cycle 255, 253, 245, 234, 218, 198, 176, 152,
waveform at D15 we could use lines of the form: 128, 103, 79, 57, 37, 21, 10, 2,
0, 2, 10, 21, 37, 57, 79, 103
int outPin = 15; // PWM output pin };

and void setup() {


}
analogWrite(outPin, 128); // Output 1.65V
void loop() {
for (int step = 0; step < 32; step++) {
Note that 1.65V is 50% of the 3.3V reference voltage. As a
analogWrite(outPin, sineLUT[step]);
further example, let’s assume that we need to produce an delay(3); // Delay sets frequency
output of 2.64V. We can determine the value to use for the }
duty cycle parameter from (2.64/3.3) × 255 = 200 so the code }
required is:

Practical Electronics | May | 2024 45


+

Fig.3.18. Sinewave output produced by Listing 3.6. Fig.3.19. Sinewave output produced by Listing 3.7.

two ways of doing this; first, using a look-up table (LUT) and
second, by calculating values using the maths library. Gotcha!
The code in Listing 3.6 produces a sinewave of about When using the noTone() function to turn off your tone
2Vpk-pk with a frequency of 10Hz. The output waveform you must ensure that the ‘T’ is in upper case, notone()
just won’t work!
benefits from the addition of the simple C-R low-pass filter
(R1 and C1) shown in Fig.3.17. This helps to smooth the
output waveform and improve its shape. The frequency can There’s another way of generating a sinewave that uses the
be changed by altering delay(). Varying the delay parameter built-in maths library. Here we repeatedly calculate values as
from 1 to 20 will change the frequency from 31Hz to 1.6Hz we need them rather than extract them from a look-up table.
respectively. Fig.3.18 shows the waveform produced. Listing 3.7 shows how this is done. Once again, the delay
parameter sets the frequency of the sinewave output.
Fig.3.19 shows the waveform produced.

Using tone() and noTone()


The ESP32 can generate a simple square wave using
the tone() function. This is simple and expedient in
many applications. For example, the code in Listing
3.8 generates an alarm signal consisting of repeated
one-second bursts of 1kHz tone. All that you need is an
audible transducer connected between pin-15 and ground.

Generating TTL levels


You may sometimes find that you need to generate a good-
quality square wave at TTL (5V logic) levels. This can be
easily done by adding an external transistor buffer stage,
as shown in Fig.3.20. The TTL-compatible square wave
generated by Listing 3.9 is shown in Fig.3.21.
Fig.3.20. Using an external transistor buffer to provide a 5Vpk-pk
TTL-compatible output. LED brightness control
Another important application of PWM is controlling the
brightness of an LED display. This can be easily done by
Listing 3.7 Code for generating a sinewave using maths library
varying the duty cycle of the pulses supplied to an LED,
/* Low frequency sine wave generator.
This code uses the math library. */ Listing 3.8 Testing tone() and noTone() functions
int outPin = 15; // Use GPIO D15 /* Tone test */
int level;
int outPin = 15; // Use GPIO D15
void setup() {
} void setup() {
}
void loop() {
for (int step = 0; step < 36; step++) { void loop() {
level = 128 + (127 * sin(step * 10 * (6.28 / 360))); tone(outPin, 1000);
analogWrite(outPin, level); delay(1000);
delay(5); // Delay sets frequency noTone(1000);
} delay(1000);
} }

46 Practical Electronics | May | 2024


is the ones digit, the next
digit to the left is the eights
digit, next is the 64s digit,
and so on. The valid digits
are 0 to 7. For example, the
value of the digits present
in the octal number 127
can be calculated from:

1278 = (1 × 64) + (2 × 8) +
(7 × 1) = 64 + 16 + 7 = 8710

Hexadecim al (base 16)


number system
Although microcontrollers
are quite comfortable working
with binary numbers of 8,
16, or even 32 binary digits,
Fig.3.22. Denary, binary, octal
humans find it inconvenient
Fig.3.21. A TTL-compatible square wave generated by Listing and hexadecimal numbers.
to work with so many digits
3.8 using the transistor buffer shown in Fig.3.20.
at a time. The hexadecimal (base 16) numbering system
offers a practical compromise. One hexadecimal digit
and the ESP32 provides several functions for doing this, including can exactly represent four binary digits so an 8-bit binary
ledcSetup(), ledcAttachPin(), and ledcWrite(). Listing number can be expressed using just two hexadecimal
3.9 shows how this is done. digits. Hexadecimal notation is thus much more compact
than binary notation and often easier to work with than
Coding Workshop decimal notation.
In this month’s Coding Workshop we introduce ways of In the hexadecimal (base 16) number system, the
representing numbers and characters in our code. This can be weight of each digit is sixteen times as great as the
particularly useful when we need to send or receive data to/ digit immediately to its right. The rightmost digit of a
from external devices. We will start with the base 10 (denary or hexadecimal integer is the ones digit, the next digit to
decimal) number system that we’re all familiar with and move the left is the sixteens digit, next is the 256 digit and so
on to binary (base 2), octal (base 8) and hexadecimal (base 16) on. The valid digits are 0 to F. Note that, because we have
number systems. run out of numerical characters beyond 9, we introduce
the letters A to F to represent numbers from 10 to 15.
Denary (base 10) number system Fig.3.22 shows the equivalence between the first sixteen
The denary (or decimal) system of numbers is something decimal, binary, and hexadecimal numbers.
that we are all familiar with because we use it every day of As an example of hexadecimal notation, the value
our lives. The valid digits in a decimal number are 0 to 9 of the digits present in the hexadecimal number 7F
and the weight of each digit is 10-times greater than the digit can be accumulated from the following weightings:
immediately to its right. The rightmost digit of a denary integer 7F16 = (7 × 16) + (15 × 1) = 112 + 15 = 12710.
(ie, a whole number with no fractional part) is the units place,
the digit to its left is the tens digit, the next is the 100s digit, Conversion from binary to hexadecimal (and vice
and so on. For example, the value of the digits present in the versa) is very easily performed by simply arranging the
denary number 123 can be accumulated from the following: binary number into groups of four digits from right to

12310 = (1 × 100) + (2 × 10) + (3 × 1)


Listing 3.9 Using PWM to control LED brightness
Note that we have used the suffix subscript 10 to
indicate the number base. This can help avoid /* Simple PWM application to slowly increase the brightness
confusion, particularly when different number bases of an LED indicator */
are being used concurrently.
int ledPin = 15; // Use GPIO D15
int ledChan = 0; // LED channel
Binary (base 2) number system int freq = 1000; // PWM frequency
In the binary system (base 2), the weight of each digit int bits = 8; // 8-bit resolution
is twice as great as the digit immediately to its right. int delayTime = 50; // Delay between levels
The rightmost digit of the binary integer is the ones
digit, the next digit to the left is the twos digit, next void setup() {
is the fours digit, then the eights digit, and so on. The ledcSetup(ledChan, freq, bits); // Configure the PWM
only valid digits in the binary system are 0 and 1. For ledcAttachPin(ledPin, ledChan); // and attach the LED
example, the value of the digits present in the binary ledcWrite(ledChan, 0); // Start with LED off
number 1011 can be accumulated from the following: }

void loop() {
10112 = (1 × 8) + (0 × 4) + (1 × 2) + (1 × 1) = 8 + 2 + 1 = 1110. for (int dutyCycle = 0; dutyCycle <= 255; dutyCycle++) {
ledcWrite(ledChan, dutyCycle); // Output to the LED
Octal (base 8) number system delay(delayTime);
In the octal (base 8) number system, the weight of each }
digit is eight times as great as the digit immediately }
to its right. The rightmost digit of an octal integer

Practical Electronics | May | 2024 47


Listing 3.10 Decimal, binary, octal, and hexadecimal table

/*
Decimal, binary, octal, and hexadecimal table
*/

void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // Wait for the serial port
}
delay(1000);
// Print the table heading and
// use tabs to separate columns
Serial.println(“”);
Serial.print(“Dec.”);
Serial.print(“\t”); Fig.3.23. Conversion of binary to hexadecimal (and vice versa).
Serial.print(“Binary”);
Serial.print(“\t”);
Serial.print(“Octal”);
Serial.print(“\t”);
Serial.print(“Hex.”);
Serial.print(“\t”);
Serial.println(“ASCII”);
}

int lineValue = 64; // Start value


int endValue = 127; // End value

void loop() {
delay(200);
Serial.print(lineValue);
Serial.print(“\t”);
Serial.print(lineValue, BIN);
Serial.print(“\t”);
Serial.print(lineValue, OCT);
Serial.print(“\t”);
Serial.print(lineValue, HEX);
Serial.print(“\t”);
Serial.println(char(lineValue));
if (lineValue == endValue) {
while (true) {
continue; // Got to the end!
}
}
lineValue++; // Go round again ...
}

Table 3.1 Number base prefix

Name Base Prefix Valid digits Example


Fig.3.24. Serial Monitor display from Listing 3.10.
Denary 10 none 0 to 9 109
is the default way of showing numbers. Binary, octal and
Binary 2 0b 0 and 1 0b11001000 hexadecimal numbers are denoted by using a prefix, as shown
Octal 8 0 0 to 7 0102 in Table 3.1.
As an example of using hexadecimal values, the following
Hexadecimal 16 0x 0 to F 0x2C code fragment show how our sinewave look-up table (LUT)
appears when coded in hexadecimal rather than in denary:

Gotcha! Fig.3.25. Circuit for the


It’s important to avoid inserting
1.5V battery tester.
an unnecessary 0 before a number
because it will be interpreted as an
octal value. So, only use the zero
prefix if you really do want to use
octal numbers!

left and then converting each digit to


its hexadecimal equivalent, as shown
in Fig.3.23.

Number base prefix


When writing code, denary (base 10)

48 Practical Electronics | May | 2024


Listing 3.11 Code for the 1.5V battery tester

const uint8_t sineLUT[] = { /* Simple ESP32 1.5V battery tester */


0x80, 0x98, 0xb0, 0xc6, 0xda, 0xea, 0xf5, 0xfd,
0xff, 0xfd, 0xf5, 0xea, 0xda, 0xc6, 0xb0, 0x98, // Assign LEDs to digital I/O lines
0x80, 0x67, 0x4f, 0x39, 0x25, 0x15, 0x0a, 0x02, int redLED = 23; // End-of life LED is red
0x00, 0x02, 0x0a, 0x15, 0x25, 0x39, 0x4f, 0x67 int amberLED = 22; // Mid-life LED is amber
}; int greenLED = 21; // Beginning of life LED is green
int analogPin = 15; // Analogue input via ADC2 Channel 3
float end = 1.1; // End-of-life threshold = 1.1V
When sending data via the Serial Monitor you can have float mid = 1.4; // Mid-life threshold = 1.4V
your numerical values printed in decimal (default), float diodeFwd = 0.75;
binary, octal and hexadecimal. You can also print the
corresponding American Standard Code for Information void setup() {
Interchange (ASCII) character. Listing 3.10 shows how // Initialize digital I/O pins outputs
this is done. If you enter and execute the code you pinMode(redLED, OUTPUT);
will be rewarded with a handy reference table like that pinMode(amberLED, OUTPUT);
shown in Fig.3.24. Note, for example, that the ASCII pinMode(greenLED, OUTPUT);
character ‘A’ can be variously represented by 63 (in // We need to adjust the thresholds to take into
// account the forward voltage drop of the diode
decimal), 0b1000001 (in binary), 0101 (in octal), and
end = end - diodeFwd;
0x41 (in hexadecimal). mid = mid - diodeFwd;
}
Practical project
Our Practical Project involves the design, construction, void loop() {
and coding of a simple tester for 1.5V alkaline batteries. // Get the terminal voltage of the battery on-load
The tester is to provide three different indications using int rawReading = analogRead(analogPin);
a ‘traffic light’ display. A green LED will indicate that // Convert the raw reading from the analogue input
a battery is fresh and ready for service. An amber LED // to volts and store it as floating point
will indicate that the battery is partially drained but float volts = rawReading * (3.3 / 4095);
if (volts > mid) {
still serviceable. A red LED will show that the battery
// It’s above the mid threshold, put green on
is exhausted and should be rejected. digitalWrite(greenLED, HIGH);
The circuit of the 1.5V battery tester is shown in digitalWrite(amberLED, LOW);
Fig.3.25. The analogue input of the ESP32 (via D15) is digitalWrite(redLED, LOW);
protected by means of silicon diode D1. This component }
will only conduct when the battery is inserted correctly. if ((volts > end) && (volts < mid)) {
If the battery is fitted incorrectly in its holder then the // It’s between the two thresholds, put amber on
diode will be reverse biased and will not conduct. The digitalWrite(greenLED, LOW);
15Ω resistor (R1) provides a test load for the battery digitalWrite(amberLED, HIGH);
which demands a test current of about 50mA (note that digitalWrite(redLED, LOW);
}
0.7V will be dropped across D1 when it’s conducting).
if (volts < end) {
The three series current-limiting resistors (R2 to R4) are // It’a below the end threshold, put red on
located on the small ‘traffic light’ circuit board (see last digitalWrite(greenLED, LOW);
month for further details). The wiring layout for the 1.5V digitalWrite(amberLED, LOW);
alkaline battery tester is shown in Fig.3.26. digitalWrite(redLED, HIGH);
}
delay(100); // Short delay
}

Fig.3.26. Wiring layout for the Teach-In Challenge


1.5V battery tester. This month’s Teach-In Challenge involves a
modification to the 1.5V alkaline battery tester.
Connect a piezoelectric buzzer between D18
(GPIO18) and ground. Then modify the code so
that the tester beeps continuously whenever a
fresh battery is inserted into the test holder. This
will provide users with an audible indication
of the state of a good battery without having to
refer to the LED display. Here are the lines that
you need to add to the code – but, we will leave
you to decide where to add them!

int outPin = 18; // Tone ouput for buzzer


tone(outPin, 1000); // Output a beep
delay(500);
noTone(1000);

Next month
In Part 4, we will introduce seven-segment LED
and matrix displays. Coding workshop will
deal with random number generation and our
Practical Project will feature a dice roller.

Practical Electronics | May | 2024 49


Max’s Cool Beans
By Max the Magnificent

Arduino Bootcamp – Part 17

A
few moments ago, as I pen
these words, I was conversing
with my son about – let’s say an
occurrence that had just occurred – when
I started to make the comment, ‘If there’s
one good thing to be said for any of
this…’ and he finished my sentence by
saying ‘…it’s not our fault and it’s not
our problem.’ I felt so proud. Despite
his habitual look of disinterest when
I’m discoursing, it turns out he has been
listening to me after all.

That’s interesting
I’m a digital logic designer by trade.
Although we haven’t discussed any of
this thus far in our bootcamp columns,
there are several mathematical tools
available to make the lives of digital logic
designers simpler, including Boolean Fig.2. Dual breadboard setup (Source: Mike Tooley / PE).
algebra, Karnaugh maps, and De Morgan
transformations. Don’t panic. We aren’t columns appeared in Scientific American One of the things that immediately
going to go into any of these tools here. magazine for a quarter of a century. caught my eye was the first picture of
However, if you do plan on taking a One of the topics covered in Martin’s Mike’s breadboard setup, which was
deeper dive into electronics, it would book is Venn diagrams, which typically accompanied by the caption: ‘Two
be a good idea to gain some familiarity involve the use of circles to illustrate (slightly modified) breadboards provide
with these topics. In which case, may I simple set relationships in areas like a convenient space for a 30-pin ESP32
make so bold as to note that they are all probability, logic, statistics and computer development board.’ Look and see for
introduced in excruciating exhilarating science. The reason I mention this here is yourself (Fig.2). Do you spot anything
detail in my book, Bebop to the Boolean that I’m bubbling over with glee because interesting and/or unusual? Jot down
Boogie – see: https://bit.ly/3u9XIWV I just spotted something that (a) relates to a list and then we can compare notes.
I often use Bebop as a reference myself. what we’ve been talking about in recent The first thing I observe is the gaps in
The scary thing is that I regularly read columns and (b) falls neatly into a Venn the middle of the red and blue horizontal
something in there and think, ‘Wow, diagram intersection of ‘that’s interesting’ lines reflecting the power and ground
that’s interesting, I never knew that,’ and ‘it’s not my problem’ (Fig.1). rails, respectively. This indicates that the
before remembering that I wrote it in conducting rails inside the breadboard
the first place. Another book I keep It’s not my problem are themselves split. As we discussed in
for reference is Logic Machines and A couple of columns ago (PE, March my Arduinos and Solderless Breadboards
Diagrams by Martin Gardner (https:// 2024), we migrated to using a dual- blog (https://bit.ly/3PdnqBk), these ‘split-
bit.ly/3v7b8DJ). Martin was one of breadboard setup. At that time, we noted rail’ boards make it easier to work with
my heroes. His Mathematical Games that it is possible to remove one or both circuits that require a mix of power
power and ground rail assemblies from supplies, like 5V and 3.3V, for example.
That’s interesting It’s not my problem the top and bottom of the breadboard. Did If Mike is intending to use only a single
you pause to say to yourself, ‘I wonder supply, then he will add jumpers to link
why anyone would ever want to do such both sides of the power rails and both
a thing?’ Well, as soon as the full March sides of the ground rails.
issue of PE landed on my desk, I read it Now look at the middle of Mike’s dual-
cover-to-cover. One item of particular board setup. The ESP32 is so wide that if
interest to me was Part 1 of Mike Tooley’s we tried plugging it into just one board,
Teach-In 2024 – Learn electronics with there would be no free terminal holes
the ESP32. This is going to be awesome. on one side and only one free hole next
That’s interesting AND it’s not my problem I’ve never found the time to play with an to each of the pins on the other side. As
ESP32, so I’m going to follow this series we see, Mike has removed the upper
Fig.1. Venn diagram. with great interest. power and ground assembly from the

50 Practical Electronics | May | 2024


at each end. Assuming we have the red
From Current-Limiting Resistors
power rail on the top (which is how I
60 55 5 1
prefer to work), then the columns are
numbered from 1 on the right to 63 on
E D C B A

E D C B A
the left.
Personally, I would have preferred

Upper Breadboard
D1 D0
the numbers to start with 1 on the left
H G F

H G F
and increment as we move to the right.
Of course, they do this if we rotate the
I

I
J

J
60 55 5 1

board 180° clockwise (or anticlockwise,


for that matter), but then we would have
(a) My breadboards the ground rail on top, which would cause
me to wear my frowny face.
Now look at Mike’s breadboards (Fig.2 BC377

0 5 55 60
and Fig.3b). In this case, the count starts E3 1C
at 0, which actually makes good sense

Lower Breadboard
E D C B A

2B
I

on several levels. However, for reasons


F G H

unknown (unless it’s to vexeth us greatly),


rather than associating the 0 with the
A B C D E
H G F

leftmost or rightmost column, all the


boards I’ve seen like this have the 0
I
J

60 55 5 0
positioned halfway between the second
and third columns, thereby requiring us
From Arduino 11 10
(b) Mike’s breadboards to count back from column 5 to determine
with which column the 0 is related. Also,
Fig.3. Can you spot the difference? this leads us to the realisation that the Fig.4. Controlling the displays with transistors.
leftmost column is numbered –1. Color
me confused. least, for the moment) is to use eight
lower board before connecting the boards It gets worse. If you look at row A in of the Arduino’s pins (pins 2 to 9) to
together. This allows his ESP32 to span the upper left of one of Mike’s boards drive both displays in parallel (side-
the two boards while still leaving two and follow it horizontally to the right, it by-side). Also, for each display, we’ve
free breadboard terminal holes next to ends up as row J. Similarly, if you look at added a BC377 transistor to control its
each of its pins. column 0 in the upper left of the board ground pin. Arduino pins 10 and 11
Thus far, everything reflects what we’ve and follow it vertically to the bottom, it are used to control displays D0 and D1,
discussed in our earlier columns. I’ve ends up as column 61. respectively (Fig.4).
saved the best (or worst, depending on Other than having rotational symmetry, You can remind yourself of our entire
your point of view) for last. Suppose you which benefits us not at all, this annotation current setup by downloading, perusing,
are playing a remote game of chess. If it’s scheme has nothing whatsoever to and pondering of our latest and greatest
your opponent’s turn and they send you recommend it. For example, if you are incarnation (file CB-May24-01.pdf).
a message saying ‘Qf3,’ then you know using a board as shown in Fig.3a, there As usual, all of the files that are mentioned
they’ve just moved their queen to the is no ambiguity if you are instructed to in this month’s column are available from
square located on file (column) f and row ‘Connect a wire between B3 and G60.’ By the May 2024 page of the PE website:
3. The reason you know this is because comparison, following this instruction is https://bit.ly/pe-downloads
everyone who plays chess has adopted more than problematic if your board is As one final reminder, our BC377
a standard notation for describing and as shown in Fig.3b because there are two transistors are of a type known as NPN.
recording the moves. locations that can be addressed as B3 and The way we are using these transistors
Similarly, there are occasions when two more that can be referenced as G60. in this circuit, we can think of them as
it may be advantageous to be able to Happily, if there’s one good thing to acting like switches. In the case of an
document instructions for populating a be said for any of this… it’s not my fault NPN transistor, applying 0V (LOW) to
breadboard with components and wires and it’s not my problem! its control terminal (the base, B) will
using some form of standard notation turn the transistor off, which means it
along the lines, ‘Connect a 150Ω resistor Preparing to rock and roll will act like an open switch. In turn, this
between locations (x1,y1) and (x2,y2)’ Just to set the scene, let’s remind ourselves means the ground pin on the display can’t
or ‘Connect a wire between locations that we now have two common-cathode activate any of the light-emitting diode
(x3,y3) and (x4,y4).’ But what form of 7-segment displays in play. In addition (LED) segments, even if the Arduino is
notation should we use to identify our to their ground pins (their common trying to light them up.
(x,y) values? cathodes), each display has eight segment By comparison, applying 5V (HIGH)
Suppose you were the inventor of (anode) pins (the decimal point counts to the transistor’s base will turn it on,
the original breadboard. One approach as a segment), so 16 anode pins in all. which means it will act like a closed
might be to use the letters A through As we noted in our previous column switch between its collector (C) and
E and F through J to identify the rows (PE, April 2024), the Arduino Uno has emitter (E) terminals. This will effectively
while also employing numbers to 14 digital I/O pins numbered 0 to 13. connect the display’s ground pin to the
identify the columns. Well, that seems We are reserving pins 0 and 1 for UART breadboard’s ground (0V) rail, which
to be simple enough. I mean, seriously, communications with our host computer, means any of its segments being powered
how complicated could it be? More which leaves 12 pins for us to work with. by the Arduino will light up.
complicated than you might think. The problem is that our dual displays
Let’s start with the breadboards I’ve require 2 x 8 = 16 pins. This is a bit of a Firing up our two displays
been using (Fig.3a). As we see, the letters poser. A conundrum, some might say. This bit is very important. Since our two
A through J are associated with the rows The solution we decided to adopt (at displays are wired in parallel, we must

Practical Electronics | May | 2024 51


we tell our Arduino that the pins we are
using to drive the segments in our displays
are of type OUTPUT. Finally, on Line 49
we call our trusty old DisplaySegs()
function to turn all the segments off.
To be honest, line 49 is superfluous
to requirements because we already
know that the transistors controlling
the displays are turned off, but it never
hurts to make sure.
The interesting part of this program takes
place in the loop() function, as seen in
Listing 2b. We start on Line 56 with a for()
loop that counts from 0 to 9. On line 58
we use our DisplaySegs() function to
apply power to the segments associated
with the current digit on both displays.
The important thing to note here is
that, even though we are applying power
to the segments, nothing will light up
Listing 2a. The setup() function for first test. because the transistors associated with
both displays are currently off.
ensure that only one of them is active at Take a few moments to think about On Lines 61 through 63, we turn display
any time. If both displays are active at how we might implement this. Maybe D1 on, wait one second, and turn it off
the same time, our Arduino will be very you could create your own test program again. On Lines 66 through 68, we turn
unhappy. In a crunchy nutshell, this and then compare your approach to my display D0 on, wait one second, and turn
means we must never drive the Arduino’s solution (file CB-May24-02.txt). it off again. Then we move onto the next
10 and 11 pins HIGH at the same time. As usual, we won’t go through the entire count in our for() loop and do it all
As I’ve noted on many previous program line-by-line here. Instead, we again. Once we’ve displayed all the digits
occasions, it’s almost invariably a good will focus only on the interesting bits. 0 through 9, the for() loop terminates,
idea to take things one step at a time, Note that, from our earlier programs, at which point we proceed to the next
verifying that any new additions to our NUM_SEGS (‘number of segments’) and iteration of the main loop() function.
system work in isolation before bringing NUM_DIGITS (‘number of digits’) are So, there you have it. Easy peasy lemon
everything together. It’s a lot easier to defined as 8 and 10, respectively. Also, squeezy. What could possibly go wrong?
debug things when there are only a ON_OFF_TIME is defined as 1000 (one I’m so glad you asked…
limited number of things that can go thousand milliseconds, or one second).
wrong (as I just found to my cost). Last, but not least, PinTrD0 and PinTrD1 Arrrggghh
Let’s start by creating a little program are integer variables that we’ve associated When I set my program running, it
that commences with both our D1 and D0 with the Arduino pins we’re using to appeared to be functioning 98% (give
displays being turned off. The program drive our two transistors. or take) as planned. How did I come up
will then repeatedly count from 0 to Lert’s start with the setup() function with this particular percentage? Well, as
9, first presenting the value on D1 for as seen in Listing 2a. The first thing we do Homer Simpson famously said, ‘People
one second, then turning D1 off and on Lines 39 through 42 is tell the Arduino can come up with statistics to prove
presenting the same value on D0 for that the two pins driving our transistors anything; 40% of all people know that.’
one second, then turning D0 off and are of type OUTPUT and set them driving The bottom line is that everything
proceeding to the next value. LOW values. Next, on lines 45 through 48 worked as expected except… whenever

Listing 2b. The loop() function for first test. Fig.5. Welcome to the real world (we hope you’ll enjoy your stay).

52 Practical Electronics | May | 2024


I also checked that none of my resistor leads were touching
To Display D1 To Display D0 each other, and I rechecked all my connections and wiring.
Everything appeared to be OK. Eventually I did what I always
do in these circumstances – I set up a Zoom call with my chum,
Joe Farr, in the UK, and we talked our way through things.
It wasn’t long until we decided that there just had to be a
problem with my wiring or – possibly – the internals of the
breadboard. The thing is that the real world (see Fig.5) looks very
different to my artistic interpretation (file CB-May24-01.pdf).
So, I went through everything step-by-step one more time. Do
you recall when I said that my wiring appeared to be correct?
It turned out I hadn’t looked closely enough. I’d plugged one
of my flying leads one hole to the right (Fig.6). Everything
looked great when viewed from every angle, except the angle
From Arduino
I hadn’t viewed things from. Give me strength!
As soon as I repositioned the errant wire, everything started
Fig.6. Ah! There’s the little scamp! to function as expected. I was a happy chappy. The radiance of
my smile once more lightened the world. I was basking in the
display D1 was activated, segment A was on for every digit. belief that I hadn’t made any more mistakes when… Joe inquired
Even more puzzling, it was noticeably dimmer than any of the why I had decided to use two sets of current-limiting resistors.
other segments on either display. ‘Oh dear,’ I said to myself
(or words to that effect). Good grief!
Why am I telling you about this? Well, it’s not uncommon for I replied that each segment in our 7-segment displays requires
things to fail to function as planned, so you’ll probably run into a current-limiting resistor. So… eight segments a display… two
something like this yourself at some stage in your experiments. displays… sixteen resistors. Joe responded that he agreed… in
Hopefully, my problem, and the investigation thereof, will principle. However, he then pointed out that since only one
provide a ‘teachable moment,’ as they say. You’re welcome. of our displays is going to be on at any time, we can therefore
The first thing I did was to swap the two 7-segment displays. make do with only a single set of resistors.
The problem remained with segment A on the new D1 display. O-M-G. I feel like an old fool (but where are we going to
Next, I unplugged the end of the blue wire driving pin 7 find one at this time of the day?). What this means is that we
(segment A) of D1, I unplugged the end of the purple wire can remove one set of resistors and simplify our wiring from
driving pin 7 (segment A) of D0, and I connected them into its current layout (Fig.7a) to a more minimalist interpretation
the other’s display (any references to the colours of wires (Fig.7b). Just to make sure we’re all tap-dancing to the same
relate to my illustration in file CB-May24-01.pdf). Now, the skirl of the bagpipes; I’ve updated our master drawing (file
always-on, low-intensity segment A appeared on D0. ‘Hmm,’ CB-May24-03.pdf).
I thought to myself. Hang on. Maybe I should have mentioned all this at the
I tried swapping out the jumper wire driving the errant beginning of this column before you implemented our original
segment. No change. Next, I swapped out the resistor driving wiring scheme yourself. Oh well, it’s too late now. Once again,
the wire connected to the misbehaving segment (plus I used we can consider this to be a teachable moment. And, once
my multimeter to confirm that the original resistor’s value was again, you’re welcome.
as it should be). No change.
Both displays together
When we eventually get to present the time on our clock,
To Display D1 To Display D0 To Displays D0 & D1
we don’t want to display the most-significant digit (MSD)
on display D1 followed by the least-significant digit (LSD)
on display D0 with only one digit visible at a time. What we
really want is to have both of our displays presenting values
Upper Breadboard

at the same time.


Lower Breadboard

98765432 From Arduino 9 8 7 6 5 4 3 2


(a) Original wiring (b) Simplified wiring

Fig.7. One set of current-limiting resistors will suffice. Listing 4a. The loop() function for second test.

Practical Electronics | May | 2024 53


We know we can’t actually achieve flickering (Fig.8). ‘I love it when a plan appear to be so bright is that we have
this because – with our current setup – comes together,’ as fearless frontrunner nothing to compare them to. I’m sure we
only one of our displays can physically Hannibal Smith of A-Team fame would be able to detect some difference
be active at any time. However, due to famously said. if we compared them to a third display
persistence of vision (the optical illusion ’42?’ I hear you say… well, just take running at full brightness 100% of the
that occurs when the visual perception a look here: https://bit.ly/pe-nov21-42 time, but that’s not an issue here.
of an object does not cease for some The technical term for what we’ve been
time after the rays of light proceeding Blinded by the light doing with our displays is ‘multiplexing,’
from it have ceased to enter the eye), Although the song Blinded by the Light which basically means that not all
if we swap back and forth between the was originally written and recorded by displays are on at the same time. Suppose
displays fast enough, we can make it Bruce Springsteen, my favorite version we wished to add two more displays,
appear that both displays are presenting is the one performed by Manfred Mann’s thereby allowing us to present both hours
values simultaneously. Earth Band, but we digress… and minutes (HH:MM) at the same time.
As a starting point, I’ve forked our As we shall soon see, there are more If we were to extend our multiplexing
earlier test program and made a few factors at play here than at first meet technique, then each display would be
teensy-weensy modifications (file the eye (no pun intended). Depending active for only 1/4 of the time.
CB-May24-04.txt). In fact, the only on who you are talking to, our eyes and At this point, we would probably
changes occur in our loop() function, brains retain a visual impression for become aware that our displays are not
as illustrated in Listing 4a. somewhere between 1/30 and 1/60 of as bright as we would prefer. Also, since
Just for giggles and grins, I’ve decided a second. Let’s say 1/50 second, which each display would now be on for 10ms
to present the number 42, with the 4 equates to 20ms. Known as ‘persistence and off for 30ms (assuming we stick with
and 2 appearing on displays D1 and D0, of vision,’ this explains why we no longer our ON_OFF_TIME definition set to 10)
respectively. As before, our ON_OFF_TIME perceive any flickering in our displays, we may start to see some flickering.
definition is still set to 1000, which each of which is now on for 10ms and One solution to the flickering is to
equates to 1000 milliseconds (ms). off for 10ms. increase the refresh rate, perhaps changing
So, we start by seeing the ‘4’ for one But wait, there’s more, because if we the value associated with ON_OFF_TIME
second, then the ‘2’ for one second, and look at our displays, which are currently to 5ms (1/200 of a second) or even 1ms
then we do it all again. Now, let’s change presenting 42, they appear to be running (1/1000 of a second).
the value associated with ON_OFF_TIME at full brightness to our eyes, even though With respect to the dimming of our
to be 100 (that’s 1/10 of a second) and we know that each display is active only multiplexed displays, one possibility is
reload the program into the Arduino. In half of the time. How can this be? to increase the current being fed to each
this case, we can sort of see both digits at Well, one reason is that the human of the display segments. As a reminder,
the same time, but accompanied by a lot of eye is incredibly sensitive over a wide an Arduino Uno’s pins prefer to sink or
annoying flickering. How about we change dynamic range from starlight to daylight. source up to 20mA. They can handle
the value associated with ON_OFF_TIME Even within a single scene, the eye can up to 40mA, but only for short periods
to be 10 (that’s 1/100 of a second). perceive a dynamic range of up to 100dB, of time. Thus, if we wanted to supply
Wow! Both digits appear to be on at which equates to a brightness ratio of more than 20mA for sustained periods
the same time without any observable 100,000:1. Thus, one reason our displays of time, we would use the Arduino’s

Components from Part 1


LEDs (assorted colours) https://amzn.to/3E7VAQE
Resistors (assorted values) https://amzn.to/3O4RvBt
Solderless breadboard https://amzn.to/3O2L3e8
Multicore jumper wires (male-male) https://amzn.to/3O4hnxk
Components from Part 2
7-segment display(s) https://amzn.to/3Afm8yu
Components from Part 5
Momentary pushbutton switches https://amzn.to/3Tk7Q87
Fig.8. I think we’ve found the answer.
Components from Part 6
Passive piezoelectric buzzer https://amzn.to/3KmxjcX
Online resources
For the purposes of this series, I’m going to assume Components for Part 9
that you are already familiar with fundamental con- SW-18010P vibration switch https://bit.ly/46SfDA4
cepts like voltage, current and resistance. If not, you
Components for Part 10
might want to start by perusing and pondering a short
Breadboard mounting trimpots https://bit.ly/3QAuz04
series of articles I penned on these very topics – see:
https://bit.ly/3EguiJh Components for Part 12
Similarly, I’ll assume you are no stranger to solder- Light-Dependent Resistor https://bit.ly/3S2430m
less breadboards. Having said this, even if you’ve used
Components for Part 13
these little scamps before, there are some aspects to
BC337 NPN Transistor https://bit.ly/40xAgyS
them that can trap the unwary, so may I suggest you
feast your orbs on a column I wrote just for you – see: Components for Part 14
https://bit.ly/3NZ70uF HC-SR04 Ultrasonic Sensor https://bit.ly/49AMBq4
Last, but not least, you will find a treasure trove of
Components for Part 15
resources at the Arduino.cc website, including exam-
Real-Time Clock (RTC) https://bit.ly/3S9OjHl
ple programs and reference documentation.

54 Practical Electronics | May | 2024


pins to control transistors that could a current of 40mA, and we turn this so many modifications to our prototype,
handle higher current values. segment on and off very quickly such I think it’s a good idea to make sure
When it comes to LEDs, the that it’s active only 50% of the time. we haven’t &%**$#$@ anything up
relationship between current and Since the two segments’ average in the process (forgive my use of the
luminous intensity is reasonably linear; currents are identical, will their perceived engineering vernacular).
that is, 2x the current results in 2x the brightnesses also be identical? Let’s say I just loaded one of the programs we
luminous intensity. So, does this mean ‘Yes,’ because it’s almost true, and we created earlier (PE, March 2024). This
that 2x the current results in 2x the really don’t want to wander any further is the one that loops around reading the
brightness? That depends on whether into the weeds. date and time from our real-time clock
we are talking about actual brightness as Is it a good idea to boost the current (RTC) and displaying these values in our
measured by an electronic instrument, in this way? It depends. On the one Serial Monitor (file CB-May24-05.txt).
in which case the answer is ‘Yes,’ or hand, it provides a solution to a problem. It still works! Hurray!
perceived brightness as seen by the On the other hand, using high current
human eye, in which case the answer is pulses ages LEDs and causes them to The time has come!
‘No.’ This is because the eye’s response dim faster, which may or may not be an To be honest, after all we’ve been through,
to signal intensity is non-linear. issue depending on the expected life of the next part may seem somewhat
At this point, I can imagine you saying, the product. anticlimactic… except for the fact that
‘Hang on a minute. We are using 7-segment More problematic is what will happen it works, of course.
LEDs whose data sheets specify a ‘forward if the microcontroller crashes or freezes What we are going to do is fork the
voltage drop’ of 2V and a ‘maximum (locks up) with one or more of the LEDs final program we created in the previous
continuous (sustained) forward current’ of on. This may also occur when the user column (PE, April 2024). This was the
20mA. Also, we are using 150Ω current- performs some action like activating one that looped around reading the time
limiting resistors to provide our 20mA a menu subsystem, which means the from the RTC and then displaying the
maximum. So, how can we increase the programmer must account for all such 2-digit hour and 2-digit minute values
current?’ I’m glad you asked. possibilities. In this case, the LEDs won’t as a series of four digits on our single
If we look more closely at the data last long at all. This is the sort of thing 7-segment display.
sheet, we may also see a ‘maximum professional electronic engineers must We are going to augment this program
pulse current’ specification of 100mA, for consider and design around. with the ability to present pairs of
example (this value will have associated Happily, this technique – boosting the digits on our dual displays using the
qualifiers, like a maximum active duration current – provides one more example technique we developed above. This
and a maximum duty ratio). of ‘that’s interesting’ and ‘it’s not our means we will be able to display the
Let’s perform a thought experiment. problem’ because we aren’t going to use it. two hour digits followed by the two
Suppose we take two segments on one minute digits. The result is available
of our displays. Assume we connect a It’s almost time for your delectation and delight (file
150Ω resistor to one segment, thereby Finally, nearly, it’s almost time for us CB-May24-06.txt).
limiting its current to 20mA, and we set to start displaying the time, but first… All we need to know for the purpose
this segment running 100% of the time. You may feel free to call me an old of these discussions is that, in addition
Also assume we connect a 75Ω resistor fussy-fuddy-duddy if you will but – to ON_OFF_TIME being defined as 10,
to the second segment, thereby allowing before we proceed – since we’ve made we’ve also defined ON_TIME as 360,

Listing 6a. (above) Our new DisplayPair() function.

Listing 6b. (right) Our modified loop() function.

Practical Electronics | May | 2024 55


SML_PAUSE as 180, and BIG_PAUSE as back and forth between displays, with 12-hour format, in which the hours are
720. Also, we’ve added our PinTrD0 and each display being on for ON_OFF_TIME numbered 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
PinTrD1 declarations so we can control (which we’ve set to 10ms, or 1/100 of and 11. Meanwhile, the minutes are
our transistors. a second). This means that a complete numbered from 0 to 59.
The first change we’ve made is to add display cycle (D1 then D0) will take (ON_ On Line 77 we call our new
a new function called DisplayPair() OFF_TIME * 2) = 20ms. DisplayPair() function, passing
as illustrated in Listing 6a. The role of Since the total time we wish to display in two arguments in the form of the
this function is to display a pair of digits this pair of digits is ON_TIME (which most-significant and least-significant
for a specified amount of time (this is we’ve defined to be 360ms), then our hours digits. On Line 78 we pause for
our ON_TIME). It doesn’t take long to numCycles will equate to 360 / 20 = 18. a short delay. On Line 81 we call our
realise that the body of our new function The reason for doing things this way, as DisplayPair() function again, this
is almost identical to the contents of the opposed to simply plonking a value of time passing in the most-significant and
loop() function in our previous test 18 in our for() loop, is that it makes it least-significant minutes digits. Finally,
(Listing 4a). In fact, there are only two easy for us to experiment with different on Line 82 we pause for a longer delay.
significant differences. values. I’m sitting here watching my dual
The first difference is seen in Lines 93 Next, let’s turn our attention to our display presenting the time in the form:
through 103. As opposed to displaying new loop() function, as illustrated
fixed values of 4 and 2 on D1 and D0, in Listing 6b. Lines 63 through 74 are HH… MM… … … HH… MM… … …
respectively, we are instead displaying identical to the program we created in HH… MM… … … and it looks great!
integer variables called msd and lsd, our previous column. This is where we
whose values are passed into the function. read the current date and time from our Next time…
The second difference is that, as RTC and boil things down to the hour We are getting closer and closer to creating
opposed to the original loop() function and minute we wish to display. a 4-digit display device. As the next step
running forever, we are using the for() As you may recall, we are using the along the way, we are going to refresh our
loop that starts on Line 91 and ends on RTC in its default 24-hour mode, in minds as to the concept of binary coded
Line 104 to limit the duration of the which the hours are numbered from 0 decimal (BCD), and then investigate
display to a specific number of cycles, to 23, and then converting this into a various deployments of BCD-to-7-segment
as defined by the integer variable
numCycles.
The value assigned to numCycles Cool bean Max Maxfield (Hawaiian shirt, on the right) is emperor of all he
is calculated on Line 89. From surveys at CliveMaxfield.com – the go-to site for the latest and greatest
our previous experiments, we in technological geekdom.
know we can achieve a flicker-
Comments or questions? Email Max at: [email protected]
free presentation by swapping

Teach-In 8 CD-ROM EE
FR -ROM
CD
ELECTRONICS
£8.99

Exploring the Arduino TEACH-IN 8


FROM THE PUBLISHERS OF
FREE
CD-ROM
SOFTWARE

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

grips with the inexpensive, immensely popular Arduino microcontroller,


• Communications – connect to PCs and other Arduinos

as well as coding enthusiasts who want to explore hardware and


interfacing. Teach-In 8 provides a one-stop source of ideas and
practical information.
The Arduino offers a remarkably effective platform for developing a
huge variety of projects; from operating a set of Christmas tree lights
PLUS...
to remotely controlling a robotic vehicle wirelessly or via the Internet. PIC n’MIX

Teach-In 8 is based around a series of practical projects with plenty of


PICs and the PICkit 3 - A beginners
guide. The why and how to build
PIC-based projects

information for customisation. The projects can be combined together


in many different ways in order to build more complex systems that can Teach In 8 Cover.indd 1 04/04/2017 12:24

be used to solve a wide variety of home automation and environmental


monitoring problems. The series includes topics such as RF technology,
wireless networking and remote web access.
PRICE
£8.99
PLUS: PICs and the PICkit 3 – A beginners guide Includes P&P to UK if
ordered direct from us
The CD-ROM also includes a bonus – an extra 12-part series based around the popular
PIC microcontroller, explaining how to build PIC-based systems.

SOFTWARE
The CD-ROM contains the software for both the Teach-In 8 and PICkit 3 series.

ORDER YOUR COPY TODAY!


JUST CALL 01202 880299 OR VISIT www.epemag.com

56 Practical Electronics | May | 2024


AOShop
The home for specialist audio, analogue and historic
components – provided by Jake Rothman, PE’s
Audio Out columnist. The AOShop is your best bet for
classic analogue ‘NOS’ (new old stock) components,
including all parts for Audio Out projects and designs.

Ge semiconductors 5534H metal-cased op amp £3.00 Radiation resistant Special resistors


LM384, TDA2030A, Siemens cellulose acetate MKL
Small-signal PNP transistors TDA2050V £1.50 2.2/25 £0.80 Bourns wire-wound trimmer
NKT214F, OC57, OC59, TAA435 (Mullard power 5kΩ 3059 JM panel-mount £2.00
2N1377, 2N525 £1.00 Electrolytic – Mullard blue 017 series Thermistor RA53, R13 £4.00
amp driver) £1.20
10/25, 22/25, 100/10 £0.50 A13 £2.00
Low-noise PNP transistors 150/40, 470/40, 1000/40 £1.00
GET106 £2.50 Synthesiser ICs Thermistor CZ1, CZ6 £1.50
Tantalum – axial metal cased Holco H2 2.2MΩ 1W, 1% £1.00
Small power PNP transistors That/dbx 2180 VCA/VCF £6.00 Welwyn 1GΩ 2W £1.00
22/50, 47/35, 68/25, 100/20, 120/10,
AC153, AC153K, AC188, AC188K £1.50 CA3080 VCA/VCF (vocoder) £2.80 5k Bourns 3321H cermet trimmer £0.50
150/16, 220/10, 330/6 £2.00
CA3280 VCA/VCF £4.00
Small power NPN transistors 22/35, 33/35, 47/20, 68/15, 100/10,
LM13600/ LM13700 VCA/VCF £2.00 Potentiometers
AC176, AC176K, AC187K, 150/6 £1.25
CA3086 transistor array £1.00
AC141K £2.00 4.7/50, 6.8/35, 10/25, 10/35, 22/15 £1.00 Bourns 81
PT2399 echo/delay £1.50
High-voltage PNP transistors Axial moulded-case tantalum 25kΩ lin cermet £2.00
OC77, CV7001 £1.50 Dual transistors Kemet axial 6.8/10 £0.30 25kΩ lin, 5kΩ lin conductive
Kemet radial 33/10 £0.40 plastic £3.00
TO3 PNP power transistors 2N2639, 2N2223, 2N2910 (NPN) £4.00 STC radial 100/20 £1.50
OC22, CV7054 (OC23), OC25, Bourns 91
E401 (JFET Moog) £4.00 Tantalum bead 10k dual-gang lin or log £10.00
OC35, OC36, AD143, AD149, 2SK2145-Y dual JFET £0.80
AD161, AD162 £2.00 22/50 £1.00 Plessey moulded-track
2N5564 JFET £8.00 470/3 £2.00
AD140 £3.50 HN3C51F, HN3A51F £1.00 5kΩ log with switch £3.00
AD149, AD161/2 matched pair £5.00 680/6.3 £3.00 50kΩ A/log £3.00
DMMT3904/6, HN1A01F,
RF PNP transistors HN1C01F £0.50 Wet tantalum Mil 250kΩ lin dual £5.00
OC41, OC42, 2SA12, 2SA53,AF124, 220/25 axial £3.20 Alpha
AF178, GET872A £1.50 Loudspeakers Castanet button 140/30, 470/3 £3.20 16mm 4.7kΩ A/log £0.80
Hughes 540/10 £3.20 220kΩ A/log £0.80
NPN transistors PE Mini-Monitor
OC139, OC140, ASY73 £2.00 Volt PE165 6.5-inch woofer (each) £85 Bipolar 10kΩ lin centre-detent dual-gang £1.50
Morel MDT29 tweeter (each) £25 Hermetic bipolar tantalum 16/35 £3.20 Allen Bradley J series/Honeywell
Diodes Kit pair of PE165/MDT29 plus Elcap axial 10/50 £0.50
CV7049 (OA10), CG92 (OA91) £0.50 10kΩ lin 1 million cycles £5.00
Volt crossover parts and PCBs £299 Generic radial 100/16, 470/35, Blore Edwards AB 45 dual 5kΩ
Monacor DT-28N tweeter (each) £35 100/ 63, 22/35, 4.7/35, 220/16 £0.50 A/log with switch £3.50
Si semiconductors Vifa 19mm BC20SC15-04 Philips solid-aluminium (axial) 121/123 Alps RK9 dual-gang 5kΩ RD law £4.00
Diodes tweeter (each) £15 47/16 £1.00 Alps 50k log tapped motorised
ZC5800 RF Schottky £0.20 Volt crossover inductors 330/6.3 £2.00 stereo £5.00
Low-noise silicon transistors 1.2mH, 1.5mH, 2mH, 2.7mH, 0.5mH 100/35 £4.00 BI P260 500kΩ log conductive
BFW16A, 2SC3071, 2SC3068, (tapped at 0.3mH) (each) £5.85 plastic 1 million cycles £2.00
Philips Pearl 122 series (radial)
2SA1016K, 2SC2362K, Colvern wire-wound 100kΩ or
Fully assembled and tested high-quality 10/16 £0.30
2SA970BL £1.50 50kΩ dual-gang 3W £5.00
speaker prototypes – ask for details Silvered mica (radial) Mil Spec hermetic 10Ω £8.00
2SC2204, 2SD655, BC550C £0.50 LS3/5As and other similar speaker
ZTX651 £0.30 1nF/500 1% £1.00
systems (pair) £200-£350 Miscellaneous
ZTX751 £0.50 Trimmer capacitors
Fully tested reclaimed speakers Vishay plastic-film 4-40pF £0.80 Theremin Clearance Sale!
RF transistors (suitable for Theremin) Vifa BC14 5-inch woofer (each) £10
BF199 £0.50 Vishay plastic-film 5.5-45pF £1.00 Elysian Theremin MIDI box £300
Vifa TC26 1-inch tweeter (each) £10 Vishay plastic-film 5-80pF £1.20
Audio power MOSFETs PCBs
Low-price speakers Vishay plastic-film 10-250pF £2.00
Exicon 10N20, 10P20 £6.50 Pocket Theremin (EPE, 1996) £2.00
Philips 4-inch 4070 £2.00 Mica 1-12pF, 2-40pF £1.00
Hitachi 2SJ99, 2SK343 £3.50 Elysian Theremin (EPE, 1996) £6
EMI 10x6-inch, 30Ω Alnico £7 Synth VCF, VCO (EPE, 2017) £3.00
Hitachi 2SJ56, 2SK176 £8.50 64mm 64Ω neodymium £1.20 Audio transformers and 48V PSU (EPE, 2019) £3.00
JFETs 5x3-inch elliptical 50Ω or 80Ω inductors SMT dual transistor adapter £0.40
BFW11, BFW10, TIS73L, J177, Alnico £3.50 Eagle transformers
J113, U1994, U1898, 2SJ176, 1.65x2.75-inch 8Ω £1.50 LT44, LT722 driver, LT700, LT723 Contact
J201 £1.00 500Ω output £2.50 Jake Rothman
J175, J176, J112, J111, 2N3820, LT30 500mW output £3.50 The Old Rectory, Arlais Road,
2N5467, BF244, 2N5460, J230 £0.60 Capacitors 5:1 interstage £1.50 Llandrindod Wells, Powys
Note ‘10/63’ denotes ‘10µF 63V’. LD1 5HE (visit by appointment)
Small power output/driver transistors Repanco
2SB649A, D669A, 2SA1208, Polyester T/T3 splitter transformer £4.00 +44 (0)1597 829102
2SC2910, MJE253G, MJE243G, 3.3/100, 4.7/250, 4.7/63 £1.00 CH2 5mH RFC £2.00 [email protected]
2SA1725, 2SC4511 £1.20 5.6/63, 8.2/63, 10/63 £2.00
BD139,BD140, BD135, BD156, BD435, Balanced output transformer Minimum order £5.00 inc post
Mullard ‘Mustard’ C296 0.22/400 £2.00
BD436, MPSA63, BCV46 £0.50 Vigortronix 600Ω VTX-101-007 £10 Quantity discounts negotiable
Polycarbonate Vigortronix 600Ω VTX-101-3001 £10
MOSFETs Axial 2.2/63 1%, 4.7/160, 6.8/63 £1.00 Vigortronix 600Ω VTX-101-3002 £15
ZVP2106A £0.30 Payment
Gardners 150Ω £10 PayPal, cards (via phone), bank
Dual-gate 3SK45, BFS28 £1.50 Radial
Reclaimed BBC LL74/MPC transfer, cheques (payable to ‘J
6.8/160V, 10/63 £2.00
Metal-cased transistors nickel core 600Ω £12 Rothman’, UK pounds only)
Reclaimed 22/63 £2.00
BC143 £0.35 No VAT payable
2N1711 £0.50 Polystyrene Reclaimed mic input transformer £15
£0.30 Philips 1% 4.7nF/160, 6.2nF/500,
BCY71 Inductors Postage
BC109C £0.60 12nF/63, 22nF/63, 110nF/63,
82µH, 4.7mH, 100µH, 270µH, Small Jiffy bag £2.99
24nF, 2nF £1.00
Amplifiers 10µH, 14µH (low Z) £0.50 Small package £4.99
RIFA 1% 100nF/100, Suflex
LM318 high-speed op amp £0.35 7-inch ferrite rod with MW Big boxes and overseas at cost
90.9nF 0.5% £2.00
µA709 metal-cased op amp £2.00 and LW windings £3.00 – ask for a quote
Suflex 2.5% 10nF/63 (rad. or ax.) £0.50

Practical Electronics | May | 2024 57


AUDIO AUDIO OUT

OUT
L R

By Jake Rothman
Back to the buffers – Part 4

T
his month, we’ll wrap up the strategy is to start by combining circuit subtle low-frequency rise in THD that
series on discrete op amp/buffer blocks you already know work. If it occurs with capacitors, for example.
designs. The complexity of a full doesn’t work, it’s easier to find the fault. To fix the oscillation, I placed a
discrete op amp is not really required for There was a hard offset upon turn-on capacitor (CComp) across the collectors
a buffer and the simple three-transistor because I forgot that the omitted voltage- of the long-tailed pair. I used 470pF out
circuits given (PE, April 2024, Fig.24, amplifier stage was inverting. To get of the ‘mixed cap’ drawer which fixed
Fig.27) are usually sufficient. However, round this, the negative feedback had to the oscillation problem. I then checked
sometimes op amp characteristics, such be applied to the non-inverting terminal for slewing distortion which occurred
as a low output offset are occasionally OA+ on the input stage. Guess what? It at a too low a frequency of 40kHz, so
needed. The high open-loop gain of a still didn’t work. Then I remembered the I then reduced the capacitor to 150pF
full op amp (discrete or monolithic) also current mirror had to be turned round – but then some other unwanted high-
enables a very low output impedance to as well. One side of the mirror is output frequency signal appeared. Fortunately,
be obtained. There are some expensive and the other, the diode-connected this was not an oscillation, but 470kHz
dedicated buffer chips available, such transistor side (TR5 on the original op RF noise emitted from a new Metcal
as the LM302, which employs 18 amp circuit (PE, October 2023, Fig.15)), soldering iron I had recently started
transistors. So, I thought a ‘halfway- is for current sensing. Having done this using. Unfortunately, this new problem
house’ discrete solution based on an necessary ‘flipping’, the circuit worked. also had me going round in circles for
op amp input stage with the voltage Next, I needed to do some optimisation. a couple of days after sudden rises in
amplifier stage (VAS) omitted would be distortion on various amplifiers I was
worthy of some R&D. Oscillation testing. The problem was solved by
As is usual with new circuits with moving the soldering iron away from
Op amp buffer design negative feedback, it oscillated when the test circuit, at which point I was
My resulting design is a two-stage op first turned on. It was barely visible relieved to determine that the 150pF
amp, sometimes called a ‘Schlotzaur on the scope as a
circuit’. It has an open-loop gain of thicker trace, but
around 6000 if constant current loads very apparent on the +25V
19mA
are used. To start, the discrete op amp distortion analyser, R4 R3 R7
200Ω PR1 200Ω 10kΩ
board from the October 2023 article was with a reading of 5kΩ
used with a long-tailed pair (LTP) stage 0.02% THD+N
followed by a class-A emitter follower. a t 1 V rms ( t o t a l DC offset 4.8mA

A possible problem with this topology harmonic distortion TR5 TR4


BC556 BC556 TR3
using 100% negative feedback, is that plus noise). I knew BC546
the operating level of the input stage from before that
*Compensation
is the same as the output. Indeed, this both circuit blocks capacitor R22
47Ω
was a problem, with the distortion level were capable of VIN CComp* VO
150pF
increasing in proportion to the output at least ten-times TR2 TR1
voltage, as shown later. better distortion. R18 BC546 BC546 100%
22kΩ Negative
One reason I pursue R1 R2
feedback
110Ω 110Ω
Development trials vanishingly low 0V
2mA 2mA
and tribulations distortion figures TR7
4mA BC546
Originally, the output stage of the first in my circuits, R6
2.2kΩ
discrete op amp which I used as a buffer even though the TR6
just consisted of an emitter follower improvements may BC546
10mA
(TR3) and current sink running at 10mA be inaudible, is to LED1
R5 1.7V R8
(TR7) – see Fig.35. This was adequate clear the view for 240Ω
Red
100Ω
for high impedance loads, but not for other problems and
–25V
full output into 600Ω. The solution non-linearities that 19mA
was a three-transistor follower and a can hide behind
modulated current source. The first a h i g h g e n e r a l Fig.35. Initial discrete op-amp-style buffer. This is reconfigured
circuit tried was to simply connect the THD floor. These to compensate for the omission of the inverting VAS stage.
three-transistor buffer to the op amp can be low-level Note component numbering refer to the discrete op amp PCB
input stage. A successful circuit design oscillations or the (PE, November, 2023).

58 Practical Electronics | May | 2024


Fig.38. Building the MOSFET op-amp-
based buffer on the discrete op amp
PCB (PE, November, 2023). This is how
prototypes can look. Note that individual
devices can be plugged in to sockets for
Fig.36. The effect of using an output MOSFET for the JFET discrete op-amp-based
changing devices during testing.
buffer circuit was to reduce the distortion compared to a Darlington (TR3) in Fig.37.

capacitor was sufficient to fix the


+25V
oscillation problem.
19mA
R2
PR1
R3 R7 Another cause of ‘raised distortion’
200Ω 200Ω 10kΩ
5kΩ was a bench power supply placed too
R8 close to the Audio Precision audio
2mA 2mA 5mA 180Ω 1.78V
DC offset analyser. I found magnetic coupling
between the power supply’s large,
TR5
TR4/5
laminated transformer and the audio
HN1A01F analyser’s output transformers. About
TR4 + C3 TR6
10µF BS170 D 200mm clearance was required.
*Compensation 50V Since the output stage was enclosed
capacitor
C1* in a negative feedback loop, I found the
D 150pF D R10
TR1/2 S value of the sense resistor (R8, Fig.37)
47Ω
2SK2145 TR1 TR2
VIN
VO was much less critical for minimum
distortion than in the three transistor
R1 100% circuits. I then set it for maximum output
1MΩ S Negative
feedback swing into a 600Ω load.
0V R6 Next, I decided to run the input stage
2.2kΩ TR7
4mA R5 BC546 at double the current (2mA per each
2.2kΩ
TR3 transistor) to increase the slewing, give
BC546
10mA greater drive to the output stage and to
C2
100nF get more transconductance out of JFETs
R4 LED1 R9
240Ω Red 100Ω if these are used for the long-tailed pair.
1.7V
–25V
19mA Component selection
Following on from my experience with
parts for the discrete op amp, I strongly
Fig.37. Final discrete MOSFET op-amp-based buffer circuit with JFET input and MOSFET suspcted dual transistors would give
output. (Note: components renumbered, coupling/decoupling capacitors omitted.) the best results – and they did. Using
JFETs for the long-tailed pair revealed
them to be more sensitive to loading
from the output stage. I tried an MPSA29
Darlington transistor for the emitter
follower (TR3) and the distortion
dropped by 75% compared to a BC546B.

Fig.39. Increasing the output level for


the FET (JFET input, MOSFET output)
op amp buffer in Fig.37 in 1Vrms steps
to 12Vrms into a 600Ω load increases
the distortion as expected. Note the
rapid rise of distortion at 20Hz to 1.3%
at 12V due to the 10µF 50V tantalum
bead modulation capacitor (C3) being
stressed. Changing this device to
a 22µF 50V metal-cased tantalum
reduced it to 0.025%.

Practical Electronics | May | 2024 59


However, some sort of curvature
cancellation magic happened when I
put in a BS170 MOSFET with current-
sink modulation. Using this device the
circuit achieved the excellent figure of
0.001% THD+N, as shown in Fig.36.
My final circuit is shown in Fig.37, and
the messy prototype construction of the
discrete op amp PCB in Fig.38.

Distortion depression
However, this low distortion was only for
an output signal of 1Vrms (2.8Vpk-pk) into
600Ω. I needed to check the distortion
at different output levels all the way up
to clipping. I increased the output level
in 1Vrms steps on the Fig.37 FET op
amp buffer giving the curves shown in
Fig.39. What looked good at 1Vrms didn’t
look so good at higher test levels up to
clipping. There was a rise in distortion
at the low-frequency end at 12Vrms due
Fig.40. Using the original full discrete op amp as a buffer suffers from rising high- to the modulation capacitor C8 getting
frequency distortion. Note that the top curve is for the output just before clipping at stressed.
17Vrms. I then tested the original full discrete
op amp (PE, October 2023, Fig.15) wired
as a buffer with 100% negative feedback
and this gave a large high-frequency
(10kHz) distortion hump of 0.026% at
16Vrms, shown in Fig.40. This is because
a lot of compensation capacitance is
required to make this topology unity-
gain stable. This causes a problem with
slewing when driving the capacitance
and there is little negative feedback at
high frequencies left for output stage
distortion reduction. It did give a large
output of 17Vrms (48Vpk-pk) just beginning
to clip with ±25V rails, 2Vrms more than
the single-ended three transistor circuit
for the same rail voltage.

Back to the three-


transistor buffer
Fig.41. Distortion for three-transistor buffer just before clipping (Fig.24). These curves I then checked the three-transistor buffer
are taken in steps from 1V to 15Vrms into 600Ω. Clipping is just beginning to occur at circuit shown in Fig.24 which gave better
15Vrms, hence the sudden jump in distortion. performance than the op amp version at
the higher test levels (above 1Vrms), as
shown in Fig.41.
I can’t leave things alone and
decided to replace R7 with a more
stable constant-current source using
a 1mA CRD (current-regulator diode).
The distortion dropped by a third to
0.0015% at 8Vrms and the low-frequency
distortion increase vanished. At 1Vrms
the distortion was flat over the whole
band at 0.0005%, a useful upgrade.
Sadly, this was not so effective on the
JFET version which also needed the
sense resistor R8 adjusting to 470Ω. I
was hoping this constant-current mod
would reduce the distortion variation
between different individual JFETs. It
didn’t. If I was a total obsessive, I would
make R8 a preset adjustment tweaked for
Fig.42. Distortion plot for JFET single-ended buffer in Fig.27 at 1Vrms, 4Vrms and each individual JFET. Fig.42 shows the
8Vrms respectively. distortion at different levels produced

60 Practical Electronics | May | 2024


Fig.43. Spectrum of distortion harmonics
produced by the single-ended JFET
buffer in Fig.27 driven at 1kHz 0dB. Note
the relatively large amount of second
harmonic (2kHz) which is 90dB down
relative to 1kHz. The third harmonic is
122dB down. Since it is a simple circuit
with low feedback the higher harmonics
are invisible, buried in noise.

by the JFET single-ended three-transistor


buffer. However, the bulk of distortion
generated is second harmonic, as shown
in the spectrum analysis plot in Fig.43
produced using fast Fourier transform
analysis. FFT is a useful feature of the
Audio Precision analyser, TiePie scopes
and various software packages. This type
of distortion at this level is inaudible, but
at high levels can even sound nice, so
the variation between JFETs is nothing +25V
13.5mA
to worry about. C5 D1 R4
100nF 1N4148 Iq
130Ω
TR3 4.2mA
It’s for real 0V D2
1N4148
BC556B
It is possible to use simulation for this
type of R&D and it is great for checking TR5
R8 ZRX651
whether a circuit will basically work, 4.8mA 4.5mA 100Ω
avoiding the latch-up scenario I had
R3
earlier. However, I dislike simulation 10kΩ
R6*
6.8Ω
for distortion analysis because it tends TR1
C7
BC556B link
to underestimate problems. Also, I’ve al R10
100nF Ib rm 92mV
The 22Ω C4
been doing practical circuits since I C1 R2 47µF
470nF 1kΩ Bipolar
was 12 and I’m now 61, so I stick to VIN + C3

+
*Set Iq 22µF VO
what I’m good at! It takes me longer to 10V
R1 R12
input the schematic into LTSpice than C2 47Ω
100kΩ 100pF Ib Th
erm R11
it does to build it. I can pull out any TR2 al 22Ω
0V BC456B link
component from my vast ‘Cupboard-
R7*
Based Programming Language’ 6.8Ω
(CBPL, shown in Fig.44) quicker than
downloading any component model R9
on-line. When I need a simulation I can 100Ω TR6
ZTX751
always get a friend with the necessary D3 TR4
0V BC456B 4.2mA
10,000-hours practice time to do a 1N4148
R5
skills swap with me. The catch with C6 D4 130Ω
100nF 1N4148
my CBPL method is that the file size 13.5mA
–25V
is 1500 square feet. You need to have
bought a house before 1995 or have had
a big inheritance to install it. Fig.45. ‘Diamond’ buffer. An unusual circuit with two parallel, but opposite polarity input
emitter follower stages. These then drive a complementary class-AB emitter-follower output.

Fig.44. ‘Cupboard based programming language’ for analogue Fig.46. This Avondale Audio active crossover board uses four
circuits. This shelf of passive components comprises 650 diamond buffers with a similar proprietary circuit to Fig.45. The
Farnell plastic drawers alone. (These cost more than the parts transistors are thermally coupled to ensure a stable quiescent
in some cases!) current. Note there are lots of SMT components under the board.

Practical Electronics | May | 2024 61


Diamond buffer C5 C9

LED1
The Diamond buffer is an interesting,
+VE
R5 R6 R12 GND
C7
if poorly named circuit, which I first -VE
came across in an Elektor oscillator C4 C6
R7 R10 ZD1
design (February 1979). It is a class- C3

SGL SUPPLY
AB push-pull mirror-image circuit R3

LINK
I/P

that has curvature cancellation, giving GND C1 R8


TR1
R9
O/P
very low distortion of 0.0018% at 1Vrms GND

into 600Ω with no overall feedback. R1


TR2
R4
TR3
R11
The transistor input bias currents also C10
R2
cancel out, assuming good Hfe matching. C8
Despite its name I can’t see a ‘diamond R13 R14
C2
shape’ in it; rather it has a ‘crossover’
like the classic multi-vibrator. I don’t
Fig.47 Held over from last month, the overlay diagram for the PCB for last month’s
know what the ‘diamond’ refers to, its
three-transistor discrete buffer circuit.
name seems to derive from Burr Brown
blingy marketing. The circuit in Fig.45
needs six transistors, which is rather Software sorrow… and a little serendipity
a lot for a buffer. The Elektor version During the test phase for the discrete buffer I thought I had a fault with my
was simplified down to four transistors AP audio analyser – the output drive level seemed to be fixed at 1Vrms, but
by using bootstrapping for the input I was wrong. Buried in the manual (six A4 ring binders), I found – after
transistors’ collector loads. Note the a year of use – that the analyser was running a fixed test routine (macro)
thermal linking of the transistors to each time I clicked on the little THD icon. If I went to the sweep menu
reduce drift. A practical application and clicked ‘start with append’ I could then change the output drive level
is for the buffers in active filters, such with at least three more entries and clicks. I was amazed to find the unit
as the active speaker crossover shown could actually deliver 26Vrms (36.9Vpk-pk) at 0.0002% THD into a 600Ω
in Fig.46. load. This is very useful for performing component stress tests. I was even
able to produce distortion in resistors! But that’s for another column. I’m
PCB sure there are many other settings I could use better, does anyone out there
A PCB for the discrete buffer is available know how to use an AP SYS-2712 to its full potential?
from the PE PCB Service – layout, Fig.47.

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

HP33120A Function Generator 100 microHz – 15MHz £350


HP53131A Universal Counter 3GHz Boxed unused £600
HP53131A Universal Counter 225MHz £350
Audio Precision SYS2712 Audio Analyser – in original box POA
Datron 4708 Autocal Multifunction Standard POA
Druck DPI 515 Pressure Calibrator/Controller £400
Datron 1081 Autocal Standards Multimeter POA
ENI 325LA RF Power Amplifier 250kHz – 150MHz 25W 50dB POA
HP/Agilent HP 34401A Digital Keithley 228 Voltage/Current Source POA Marconi 2955B Radio
Multimeter 6½ Digit £325 – £375 Time 9818 DC Current & Voltage Calibrator POA Communications Test Set – £800

62 Practical Electronics | May | 2024


Circuit Surgery
Regular clinic by Ian Bell

Topics in digital signal processing – sampling

T
his month, we will start to converter (DAC). The output of the the signal value is captured and stored
look at various topics related to DAC is a ‘stepped’ waveform which for processing at specific points in
digital signal processing (DSP). is converted to a smooth analogue time. Sampling usually occurs with a
DSP covers a wide range of electronics waveform by the reconstruction filter. fixed time interval (called the sample
applications where real-world signals Fig.1 shows key components in a generic period, T) between sample points. A
such as sound, images, temperature, pres- DSP system, but not all DSP systems sampling period of T corresponds with
sure, position and speed are converted will contain all these components. For a sampling frequency (or rate) of 1/T.
to digital data for manipulation, analy- example, digital generation does not Sampling frequency is a key performance
sis, storage and display. The resulting require the input half from Fig.1 and the parameter of DSP systems. In the most
processed digital information, or new system’s output may not require a DAC basic approaches, the sampling frequency
information which has been generated if it is just one or more on/off controls, is the same throughout the system, but it
digitally, can also be converted into real- or a pulse-width-modulated signal. is also possible to use different rates in
world signals for human consumption different parts of a system. For example,
(eg, audio and video) or manipulation Sampling and quantisation initially sampling the analogue signal
of the physical world (eg, mechanical We assume that analogue signals can have at a relatively high rate, but effectively
and thermal). These systems can be rela- an infinite number of possible values resampling (within the digital part) to a
tively complex (for example, streaming between their upper and lower limits lower rate for performing the processing
movies from the internet or control of (peak values). We also assume that their operations (this is called ‘downsampling’
industrial robots) or relatively simple value may be different (by some arbitrary or ‘decimation’).
(for example, a basic microcontroller small amount) after an infinitely small A signal defined at a set of sample
measuring temperature). change in time. This is not strictly true times is referred to as a discrete time
Fig.1 shows the key elements of when you consider that electric current signal, to distinguish it from a continuous
DSP systems, with a signal path from depends on discrete charge carries (eg, time signal. Digital (DSP) circuits process
analogue input via digital processing to electrons) and quantum effects come discrete time signals, but it is also possible
analogue output. The input signal passes in to play when at sufficiently small to build analogue circuits which work with
through an analogue antialiasing filter scales. However, for the majority of sampled signals. These use continuous-
which removes frequencies that would analogue electronic circuit designs it value analogue signals that update to new
otherwise cause errors. A sample-and- is reasonable to assume this property values at each sample point. Switched-
hold circuit captures the filtered input for analogue signals. capacitor circuits are an important example
signal at the points in time at which it is On the other hand, digitised analogue of this technology, and are widely used
to be digitised. The process of sampling, signals can only have a finite number in integrated circuit design.
and the use of antialiasing filters are key of possible values. This is because they
concepts in DSP and will be discussed in are represented by digital code values, Sampled signals
more detail in this article. An analogue- which have a finite number of bits. The top plot in Fig.2 shows a set of
to-digital converter (ADC) produces An ADC/DAC with an N-bit output/ sample points, with sample period T,
digital codes that represents the values of input digital word can handle at most on an analogue waveform. The sampled
the analogue signal at the input sampling 2N different values. When an analogue signal itself, in its most general form, is
instants. The digital processing performs signal is digitised, the process of going just a set of values associated with the
operations on the digitised signal (data); from an effectively infinite number of sample times. It does not have a value
this can be implemented directing in possible values to a finite one is called between these times – this is illustrated
digital hardware or by software running quantisation and is an inherent property in the middle waveform in Fig.2. This
on a processor. of ADCs. We will look at ADCs (and representation fits directly with digital
The result of the digital processing DACs) in more detail in a later article. data – a set of discrete values stored in
of the input signal (or results of direct Digitised (sampled) analogue signals a digital circuit, computer memory or
digital generation) are converted to also only change to a new value after other media.
analogue values at the output sample a finite amount of time – this is the If sampled values are processed in
times using a digital-to-analogue fundamental nature of sampling, where an analogue circuit, then the signal is
often held constant between sample
Analogue Digital Analogue points and waveforms typically have
Antialiasing Sample and Digital Reconstruction
a stepped appearance, like the bottom
In ADC DAC Out
filter hold processing filter plot in Fig.2. This is the waveform
that would be seen at the output
Fig.1. Generic DSP system structure. of both the sample-and-hold and

Practical Electronics | May | 2024 63


‘holds’; for example, Area = p x 1 p
Continuous waveform with sample points a first-order hold
1
T
produces a straight-
line value change
t 0
between sample
–1T 1T 2T 3T
t i m e s . H o w e v e r,
these are relatively Fig.4. Sampling pulse train s(t).
rare/advanced
Samples techniques in DSP systems. contains frequencies relatively close to
If we sample an analogue the sampling frequency.
signal, convert it to digital Moiré aliasing patterns occur when
t with an ADC and then convert a digital camera has trouble imaging
it directly back to an analogue an intricate pattern, the result is
signal with a DAC, the visual artefacts in photos or videos.
resulting zero-hold signal is A well-known example is a finely
Sample and hold
not an accurate reconstruction striped or patterned shirt (eg, on a TV
of the original signal, However, presenter) causing strange waves or
assuming the sampling swirl patterns to appear in a digital
t was performed correctly, image. This happens when the pixel
the original signal can be size is similar to the pattern size and
reconstructed by passing the is less common than it used to be due
DAC output through a low- to the increase in resolution of digial
Fig.2. Sampled waveforms. pass filter – the reconstruction cameras and video presentation.
filter shown in Fig.1. Any sampling process can be
DAC blocks of the generic DSP system affected by potential ambiguities. This
shown in Fig.1. The input waveform Aliasing includes manually making real-world
is sampled at each sample time and The first block in Fig.1 is called the measurements (eg, of temperature).
held at this value until the next sample ‘antialiasing filter’, so an obvious Imagine measuring the temperature in
time. At the ADC input the flat parts of question is, what is aliasing and why a garden once a day in the afternoon
the waveform provide the ADC with do we need a filter for it? Aliasing is a and plotting the results. The shape of
a constant input during the time it problem which can potentially occur the graph is likely to be an inaccurate
takes to perform the conversion. If the in any signal processing system which representation of the temperature
value being converted is not exactly samples the signal. This includes all changes. For example, there is likely to
equal to the signal at the sample time digital audio and video signal processing. be a daily cycle with lower temperatures
then errors will be introduced into the Digital imaging sensors such as cameras at night. An actual near-constant
digitised signal. and scanners can also suffer from aliasing temperature and strong day-night
The stepped waveform (particularly effects. Aliasing is so called because it cycle with similar temperature each
at the DAC output) is a called a zero- causes ambiguities in the sampled data, afternoon will produce the same form of
order hold. It represents the creation, or that is, there could be more than one graph with this measurement schedule.
reconstruction, of a continuous-in-time signal which resulted in the same set Measuring every hour would give a
analogue signal from a discrete set of of sample values – thus one signal is an much more accurate picture of what
samples. This is an interpolation process alias of the other. Aliasing effects can was happening. The choice of sample
– we need to fill in the gaps between the be observed in everyday life; one often- rate requires an understanding of the
sample points to create a waveform that quoted example is the ‘wagon wheel signal being sampled.
is continuous-in-time. This is similar effect’ where the wheels of a vehicle in
to finding the ‘line of best fit’ for data a film or video (perhaps a stagecoach Sampling concepts
points on a graph. in a western, as the name suggests) and nomenclature
The term ‘zero order’ refers to the appear to be turning at the wrong speed, An idealised sampled signal (x s (t)),
mathematical principle of approximating backwards or even stationary. Search which only exists at the sample points,
a function (or set of data points) with a online for ‘wagon wheel effect’ videos can be approximated by multiplying the
polynomial. A polynomial function of if you would like to see some examples. continuous signal (xc(t)) by a train of
x is of the form a0+a1x+a2x2+a3x3… and A video camera samples the scene in short-duration, unit-amplitude pulses
so on, where the an terms are numerical front of it at a certain number of frames (s(t)). This is a conceptual model rather
values. The order of the polynomial is per second. If the wheel of a vehicle than practical implementation and is
the highest power of x used. A zero-order in the shot rotates an exact number of illustrated in Fig.3. The pulse train
polynomial just has a constant value – a whole revolutions in the time between signal is shown in Fig.4. The duration
flat line that does not change with x (or frames it will appear to be in the same of each pulse (p) is ideally zero.
t for time in the case of the waveform). position in each frame. When the film There is a potential problem here in
It is possible to create higher-order is viewed the wheel will appear to be that a unit amplitude pulse of duration
stationary despite the fact that the vehicle zero simply disappears. As p reduces to
s(t) is obviously in motion. However, if the zero the area under the pulse on the graph
wheel was rotating much more slowly, (p × 1 – see shading on Fig.4) becomes
or if the video frame rate was much zero. Fortunately, there is a mathematical
xC(t) xs(t) = s(t)xC(t)
higher, we would get a large number solution – a function called the unit
X
of frames per revolution and playback impulse or Dirac delta (written as d(t))
would look as it should. This leads us which is defined to be zero everywhere
Fig.3. Simple model of sampling a signal to the insight that problems will occur except at time zero, but does ‘exist’ in
with a pulse train. if the input (the scene in this case) the sense that the area under the Dirac

64 Practical Electronics | May | 2024


which is what we generally refer to as
a waveform. The symbol t is taken to
refer to continuous time, and the original
continuous signal (xc(t)) has defined
values for all values of t. However, for the
sampled signal the value is only defined
at integer (n) multiples of T, that is nT,
so we can write xs(t) as x(nT). With the
‘s’ subscript being less necessary as nT
implies sampling.
Since T represents the time difference
between samples it is also sometime
written as DT, the symbol D (upper-case
delta) meaning a difference between
values of a variable. In its most abstract
Fig.5. LTspice schematic to create a sampled waveform. form, a set of samples is just a sequence
of values, and we can refer to these using
an index for the position in the sequence,
that is x(n) rather than x(nT). For example,
we can describe calculations performed
on sampled data, where each step occurs
at the sampling interval, just using x(n)
and other relative samples in the sequence
such as x(n – 1) and x(n + 1) to reference
the values used in the calculation. If you
look at websites and books on DSP you
will often see terms such as x(nT), x(nDT),
x(n) and d(t) and variants of these in the
equations used in these sources.

LTspice sampling pulses


We can create sampled signals based
on the model illustrated in Fig.3 and
Fig.4 using LTspice. This can help us
illustrate sampling concepts such as
aliasing. The LTspice model in Fig.5
creates a 1kHz sinewave using source
V1. A 9kHz sampling pulse train is
created using source V2. The sinewave
and sampling pulses are multiplied by
Fig.6. Results from simulating the LTspice schematic in Fig.5. behavioural source B1 to produce the
samples signal in the manner shown in
delta pulse is not zero, despite its zero The sampling pulses occur at multiples Fig.3. The pulse width of the sampling
duration. The area under the Dirac delta of sampling period T; that is, there is pulses is chosen to be small but easily
is by definition, a value of one. This is a a pulse at time t = 0, t = T, t = 2T, t = visible on the plots because our main
useful mathematical abstraction which 3T and so on. There can also be pulses aim here is to create illustrative graphs.
occurs frequently in the mathematics before the nominal reference time zero The result of the simulation is shown
of sampled signal processing and is (t = 0), at times t = –T, t = –2T and so in Fig.6. The top trace (red) is the 1kHz
widely used in other areas of physics on. In general, mathematical analysis sinewave. The second trace (green)
and engineering. It is worth being aware of signals often assumes they are of shows the sampling pulse train and the
of the impulse concept even if you do infinite duration. third (cyan) the sampled waveform. The
not want to get into all the advanced The term x(t) means the value of bottom trace has the original sinewave
maths that it gets used in. the signal x as a function of time (t), and sampled waveform shown together
to confirm that the sample pulses align
with the original waveform.
Fig.7 shows a couple more sinewave
signals added to the schematic in Fig.5;

Introduction to LTspice
Want to learn the basics of LTspice?
Ian Bell wrote an excellent series of
Circuit Surgery articles to get you up
and running, see PE October 2018
to January 2019, and July/August
2020. All issues are available in
print and PDF from the PE website:
https://bit.ly/pe-backissues
Fig.7. Adding more sinewaves to the schematic in Fig.5.

Practical Electronics | May | 2024 65


Fig.8. Results from simulating the LTspice schematic in Fig.7. All three waveforms will produce the same set of samples and are
therefore indistinguishable after sampling.

these are 8kHz and 17kHz. The simulation


results in Fig.8 show that the sample
pulses from sampling the 1kHz sinewave
at 9kHz exactly line up with the other two
sinewaves. That means that if we sample
a 1kHz, 8kHz or 17kHz sinewave at 9kHz
we get the same set of samples. Thus, once
we only have the sample data (further
through the signal processing system, or
in a digital storage), we cannot tell if the
data was originally due to a 1kHz, 8kHz
or 17kHz sinewave. In fact, there are many
more sinewaves that will also produce the
same sample data with 9kHz sampling.
Another way to look at this is that if we
Fig.9. Sampling at exactly the Nyquist rate.
sampled an 8kHz sinewave at 9kHz then
when the signal was reconstructed (eg,
when playing a digital audio recording)
we may end up with a 1kHz tone instead
of the original 9kHz. The output contains
something that was never there in the
first place – just like the illusionary
stationary or backward-turning wheels
on the ‘wagon’. Real audio signals, such
as voice and music, are generally much
more complex than single sinewaves, but
the same aliasing processes can occur
during sampling. The resulting output
may contain tones which were not in
the input, resulting in a loss of fidelity.

Nyquist rate
Mathematical analysis of the process of
sampling a signal shows that signals with
a frequency of less than half the sampling
frequency are reliably represented in
Fig.10. Waveforms of sampling at exactly the Nyquist rate, example 1. the sampled data. This is known as the

66 Practical Electronics | May | 2024


Simulation files
Most, but not every month, LTSpice
is used to support descriptions and
analysis in Circuit Surgery.
The examples and files are available
for download from the PE website:
https://bit.ly/pe-downloads

rather than 9kHz (that is exactly twice


the 1kHz signal frequency).
Example results are shown in Fig.10
where it can be seen that the samples
exactly align with the peaks in the
sinewave. These samples will produce
a square wave at 1kHz when passed to a
DAC, which will in turn produce a 1kHz
sinewave when passed through a suitable
reconstruction filter – the sampled signal
Fig.11. Waveforms of sampling at exactly the Nyquist rate, example 2. is successfully recovered. However,
Fig.11 shows the same situation except
Nyquist sampling theorem (also known as the sampling theorem, that the sample pulses are shifted in time (the Tdelay parameter
the Nyquist-Shannon theorem and the Whittaker-Nyquist- for the pulse source V2 is changed to 0 instead of 250µs).
Shannon sampling theorem, the names honouring people who The sampling aligns with the zero crossing of the sinewave,
first published significant work on the topic). The theory shows so all the samples are zero and therefore the sampled signal
that if the input does not contain any frequency components cannot be recovered.
at or beyond half the sampling frequency then it is possible to
perfectly reproduce the original signal from the sample data. Antialiasing filters
A sampling frequency of twice the maximum signal frequency If we remove all frequencies at and above half the sampling
is called the Nyquist frequency or Nyquist rate. Sampling at frequency from the input before sampling it, then we will
less than this frequency is called ‘undersampling’ (which does not have any problems with aliasing. This is the job of the
have its uses). Sampling at a rate significantly higher than antialiasing filter. By sampling at just over the Nyquist rate
the Nyquist rate is called oversampling and facilitates low it is theoretically possible to perfectly recover the sampled
-noise, low-distortion signal processing. Sampling at exactly signal, but doing so implies a close-to-ideal antialiasing filter
the Nyquist rate may enable the signal to be recovered but the – we will discuss this in more detail in another article. In
results may be wrong for specific alignment of the samples and cases where there is certainty that the sampled signal does not
waveform. This is show in the simulation in Fig.9 to Fig.11. The contain frequencies at and above half the sampling frequency
schematic (Fig.9) is similar to Fig.5 but with 2kHz sampling an antialiasing filter is not required.
Antialiasing filters are not only required in audio and video
signal processing; the image sensors in digital cameras are

NEW!
spatially sampling the image projected by the lens onto the
sensor. If the image contains small repetitive details aliasing
can occur. To overcome this, an optical filter is used to
provide an amount of blurring which will prevent aliasing.
However, in recent years more digital cameras have become
available without anti-aliasing filters. These provide better

5-year collection image quality in situations where aliasing would not occur.

Fig.12. The

2017-2021 moiré effect in


photography is an
example of aliasing.
All 60 issues from Jan 2017 It creates artifical
to Dec 2021 for just £44.95 stripey patterns
when images are
PDF files ready for captured with
repeating patterns
immediate download that match the
spatial frequency of
the camera’s sensor
See page 6 for further details and pixels.
other great back-issue offers.

Purchase and download at:


www.electronpublishing.com

Practical Electronics | May | 2024 67


Practical Electronics PCB SERVICE
PROJECT CODE PRICE PROJECT CODE PRICE
MAY 2024 MAY 2023
GPS-Disciplined Oscillator........................................................04103231 12.95 Precision AM-FM DDS Signal Generator.................................CSE211002 14.95
Dual RF Amplifier.......................................................................CSE220602A 5.95 Improved SMD Test Tweezers programmed PIC....................0410621PIC 12.95
Songbird ....................................................................................08103231 7.95 AO 2x-dual-to-quad through-hole (pack of five).......................AO1-MAY23 6.95
AO 2x-dual-to-quad SMD (pack of five)...................................AO2-MAY23 6.95
APRIL 2024 AO 2x-single-to-dual through-hole (pack of five)......................AO3-MAY23 6.95
Basic RF Signal Generator.......................................................CSE221001 8.99 AO 2x-single-to-dual SMD (pack of five)..................................AO4-MAY23 6.95
Basic RF Signal Generator (black front panel).........................CSE220902B 9.99
Silicon Chirp Cricket..................................................................08101231 7.99 APRIL 2023
Test Bench ‘Swiss Army Knife’..................................................04110221 9.99 500W Amplifier Module.............................................................see p.22, April 2023
Clipping Indicator (per channel)................................................01112211 7.95
MARCH 2024 CD Welder Power Supply (one needed)..................................29103221 9.95
Digital Volume Control Potentiometer SMD version................01101231 8.95 CD Welder Controller (one needed).........................................29103222 9.95
Digital Volume Control Potentiometer through-hole version....01101232 9.95 CD Welder Energy Storage module (several needed)............29103223 7.95
Advanced SMD Test Tweezers body........................................04106221 6.95 AO Universal Dual Op Amp Board........................................AO1-APR23 9.95
Advanced SMD Test Tweezers legs (pair)...............................04106212 7.95 AO Stereo RIAA precision passives kit for dual op amp.......AO2-APR23 8.95

FEBRUARY 2024 MARCH 2023


Active Mains Soft Starter...........................................................10110221 10.95 Pico BackPack...........................................................................07101221 9.95
Semaphore Signal (controller)..................................................09103221 7.95
JANUARY 2024 Semaphore Signal (blade)........................................................09103222 5.95
Q Meter ....................................................................................CSE220701 8.95
Q Meter (black solder mask).....................................................CSE220704 7.95 FEBRUARY 2023
Raspberry Pi Pico W BackPack................................................07101221 8.95 Tesla Coil driver board...............................................................26102221 9.95
Tesla Coil potentiometer board.................................................26102222 5.95
DECEMBER 2023 Cooling Fan Controller & Loudspeaker Protector....................01102221 8.95
Digital Boost Regulator..............................................................24110224 8.95 Remote Gate Controller............................................................11009121 12.95
Dual-Channel Power Supply for Breadboards.........................04112221 11.95
Display Adaptor for the Breadboard PSU.................................04112222 9.95 JANUARY 2023
Classic LED Metronome – 8-LED.............................................23111211 7.95
NOVEMBER 2023 Classic LED Metronome – 10-LED...........................................23111212 8.95
LC Meter Mk3............................................................................CSE220503C 9.95 Multi-Channel Speaker Protector – 6 channel.........................01101221 9.95
DC Supply Filter for vehicles.....................................................08108221 8.95 Multi-Channel Speaker Protector – 4 channel.........................01101222 7.95
Discrete Audio Op Amp PCB....................................................AO1-JUL23 9.95 Remote Control Range Extender – IR-to-UHF........................15109212 5.95
Discrete Audio Op Amp PCB + essential components............AO2-JUL23 17.95 Remote Control Range Extender – UHF-to-IR........................15109211 7.95
AO Universal Single Op Amp Board......................................AO1-JAN23 7.95
OCTOBER 2023
Buck/Boost Charger Adaptor....................................................14108221 9.95 DECEMBER 2022
PIC Breakout Board for SOIC parts..........................................24110225 5.95 Hummingbird Amplifier..............................................................01111211 9.95
PIC Breakout Board for DIP parts.............................................24110222 5.95 SMD Trainer PCB......................................................................29106211A 8.95
AVR64DD32 Breakout board....................................................24110223 5.95 SMD Trainer PCB + parts.........................................................29106211B 13.95
Automatic Train Controller.........................................................09109221 6.95
Chuff Sound module..................................................................09109222 6.95 NOVEMBER 2022
USB Cable tester – main PCB..................................................04108211 12.95
SEPTEMBER 2023 USB Cable tester – front panel.................................................04108212 5.95
Mini LED Driver..........................................................................16106221 7.95 USB Cable tester – optional panel............................................SC5970 5.95
New GPS-Synchronised Clock.................................................19109221 9.95 Model Railway Carriage Lights – PCB.....................................09109211 6.95
Wide-Range Ohmmeter............................................................04109221 14.95 AO transfmr PCB – standard VTX-A range........................ VTX-101-007 6.95
AO transfmr PCB – dual-outline VTX102-3001/101-3002....VTX-Dual 6.95
AUGUST 2023
110dB RF Attenuator.................................................................CSE211003 9.95 OCTOBER 2022
Universal Battery Charge Controller (2023 update).................14107192 9.95 SMD Test Tweezers – PCB and pair of tweezer arms.............04106211-2 11.95
Wide-Range OhmMeter............................................................04109221 12.95 SMD Test Tweezers – programmed PIC12F1572-I/SN...........0410621A 7.95
Tele-com............................................................................. 12110211 12.95
JULY 2023
Multimeter Checker/Calibrator..................................................04107221 10.95 SEPTEMBER 2022
MIDI Spectral Sound Synthesiser (full kit – see p.25)..............N/A N/A Touchscreen Digital Preamp – main board........................ 01103191 12.95
Touchscreen Digital Preamp – adaptor board pair............. 01103192 5.95
JUNE 2023 20A DC Motor Speed Controller......................................... 11006211 9.95
Arduino Programmable Load....................................................04105221 8.95
Buck-Boost LED Driver.............................................................16103221 8.95 AUGUST 2022
Multi-purpose Battery Manager – I/O Expander module.... 11104212 5.95
Multi-purpose Battery Manager – Switch Module............... 11104211 8.95
Simple MIDI Music Keyboard (for 8 switches).................... 23101213 6.95
Nano Pong......................................................................... 08105212 7.95

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.

68 Practical Electronics | May | 2024


Double-sided | plated-through holes | solder mask

PROJECT CODE PRICE PROJECT CODE PRICE


JULY 2022 JULY 2021
Silicon Labs AM/FM/SW Radio.......................................... CSE210301C 10.95 ATtiny816 Breakout / Dev Board with Capacitive Touch.... 24110181 £9.75
Level Crossing Controller................................................... 09108211 6.95 IR Remote Control Assistant (Jaycar version).................... 15005201 £8.95
IR Remote Control Assistant (Altronics version)................ 15005202 £8.95
JUNE 2022 PIC18F Development Board.............................................. PNM-JUL21 £12.95
Full-wave Motor Speed Controller...................................... 1010221 8.95 Microphone Preamplifier........................................................AO-JUL21 £11.95
PIC Programming Helper for 8-pin PICs only..................... 24106211 7.95
PIC Programming Helper for 8, 14 or 20-pin PICs ............ 24106212 10.95 JUNE 2021
Advanced GPS Computer.................................................. 05102211 9.95 Roadies’ Test Signal Generator (surface-mount version)... 01005201 £8.95
Roadies’ Test Signal Generator (through-hole version)...... 01005202 £9.95
MAY 2022 Touchscreen Wide-range RCL Box (Resistor module)....... 04104201
£18.95
Bus board PCB for Analogue Vocoder............................... AO1-MAY22 10.95 Touchscreen Wide-range RCL Box (Ind/Cap module)....... 04104202
Complete set of 14 PCBs for Analogue Vocoder................ AO2-MAY22 97.95 KickStart Part 3 – Gyrator-based Audio Filter.................... KS3-2021 £7.95
Programmed EEPROM for Digital FX Unit......................... FX1-MAY22 10.95
Programmed PIC for Digital FX Unit using potentiometer.....FX2-MAY22 8.95 MAY 2021
7-Band Equaliser (Mono)................................................... 01104201 £8.95
APRIL 2022 7-Band Equaliser (Stereo).................................................. 01104202 £10.95
64-key MIDI Matrix shield................................................... 23101211 8.95 Car Altimeter....................................................................... 05105201 £7.95
64-key MIDI Matrix switch board........................................ 23101212 11.95
High-current Battery Balancer ........................................... 14102211 10.95 APRIL 2021
Digital FX Unit – using potentiometer................................. 01102211 9.95 Reflow Oven – DSP Active Crossover (CPU)..................... 01106193
Digital FX Unit – using BCD switch.................................... 01102212 9.95 Reflow Oven – DSP Active Crossover (Front panel).......... 01106195 £19.95
Universal Audio PSU.......................................................... AO1-APR22 11.95 Reflow Oven – DSP Active Crossover (LCD)..................... 01106196
Frequency Reference Signal Distributor.................................... CSE200103 £8.95
MARCH 2022
Mini Isolated Serial Link..................................................... 24102211 £5.95 For the many pre-2016 PCBs that we stock please see the
Busy Loo Indicator.............................................................. 16112201 £5.95
Analogue Vocoder – Band-pass filter board....................... AO1-MAR22 9.95
PE website: www.electronpublishing.com
Analogue Vocoder – HP/LP filter board.............................. AO2-MAR22 9.95

FEBRUARY 2022
PE/EPE PCB SERVICE
Arduino-based Power Supply............................................. 18106201 9.95 Order Code Project Quantity Price
Battery Monitor Logger....................................................... 11106201 10.95
Electronic Wind Chimes..................................................... 23011201 10.95 .........................................................
Analogue Vocoder – Driver Amplifier.................................. AO-FEB22 8.95
.........................................................
JANUARY 2022
Vintage battery Radio Li-ion Power Supply........................ 11111201 9.95 .........................................................
MiniHeart: A Miniature Heartbeat Simulator....................... 01109201 8.95
.........................................................
DECEMBER 2021
AM/FM/SW Digital Receiver............................................... CSE200902A 13.95 .........................................................
Balanced Input and Attenuator for USB CODEC............... 01106202 11.95

NOVEMBER 2021 Name. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


Dual Battery Lifesaver........................................................ 11111202 £6.95 Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCTOBER 2021 .........................................................
Mini Wi-Fi LCD BackPack.................................................. 24106201 £8.95
Tel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SEPTEMBER 2021 Email . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
USB SuperCodec PCB....................................................... 01106201 £14.95
Audio DDS Oscillator PCB................................................. 01110201 £5.95 I enclose payment of £ . . . . . . . . . . . . . . (cheque/PO in £ sterling only)
Audio DDS Oscillator rotary encoder................................. 01110201-ENC 6.95
Programming Adaptor Board for Audio DDS Oscillator...... 01110202 £5.95 payable to: Practical Electronics
High-power Ultrasonic Cleaner main PCB......................... 04105201
£14.95
High-power Ultrasonic Cleaner front-panel PCB................ 04105202 Card No . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Night Keeper Lighthouse PCB........................................... 08110201 £5.95
Valid From . . . . . . . . . . . . . . . . . Expiry Date . . . . . . . . . . . . . . .
AUGUST 2021
Ol’ Timer PCB..................................................................... 19104201 £11.95 Card Security No . . . . . . . . . .
Ol’ Timer 8x8 RGB LED module using WS2812B.............. 19104201-88 £8.95
Ol’ Timer set of acrylic case pieces and spacer................. 19104201-ACR £8.75 You can also order PCBs by phone, email or via the shop
Ol’ Timer DS3231 RTC IC wide SOIC-16.................................19104201-RTC £5.95 on our website: www.electronpublishing.com
Wideband Digital RF Power Meter..................................... 04106201 £9.75
Switchmode 78xx regulators (PACK of 5!)........................ 18105201 £7.95 No need to cut your issue – a copy of this form is just as good!
Cool Beans SMAD display................................................. CB-AUG21 £11.95

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.

Practical Electronics | May | 2024 69


Practical Electronics PCB SERVICE
PROJECT CODE PRICE PROJECT CODE PRICE
MARCH 2021 APRIL 2020
Nutube Guitar Effects Pedal............................................... 01102201 £12.95 Flip-dot Display black coil board.................................................. 19111181
Programmable Thermal Regulator (Peltier Interface)......... 21109181 Flip-dot Display black pixels........................................................ 19111182
£18.95 £14.95
Programmable Thermal Regulator (Peltier Driver)............. 21109182 Flip-dot Display black frame........................................................ 19111183
Tunable HF Preamp........................................................... CSE190502 £8.95 Flip-dot Display green driver board............................................. 19111184

FEBRUARY 2021 MARCH 2020


4G Remote Monitoring....................................................... 27111191 £9.95 Diode Curve Plotter............................................................ 04112181 £10.95
Steam Train Whistle / Diesel Horn Sound Generator................ 09106181 £8.50
JANUARY 2021 Universal Passive Crossover (one off)....................................... UPC0320 £12.50
Nutube Valve Preamplifier.................................................. 01112191 £12.95
Arduino DCC Controller...................................................... 09207181 £10.95 FEBRUARY 2020
Motion-Sensing 12V Power Switch.................................... 05102191 £5.95
DECEMBER 2020 USB Keyboard / Mouse Adaptor........................................ 24311181 £8.50
Pseudo-Random Sequence Generator.............................. 16106191 £7.95 DSP Active Crossover (ADC)............................................. 01106191
Clever Charger................................................................... 14107191 £11.95 DSP Active Crossover (DAC) ×2 ....................................... 01106192
PE Theremin Amplifier........................................................ AO-1220-01 £8.95 DSP Active Crossover (CPU)............................................. 01106193 £29.95
DSP Active Crossover (Power/routing)............................... 01106194
NOVEMBER 2020 DSP Active Crossover (Front panel)................................... 01106195
LED Christmas Tree (1 off)................................................. 16107181-1 £6.95 DSP Active Crossover (LCD).............................................. 01106196
LED Christmas Tree (4 off)................................................. 16107181-2 £14.95
LED Christmas Tree (12 off)............................................... 16107181-3 £24.95 JANUARY 2020
LED Christmas Tree (20 off)............................................... 16107181-4 £34.95 Isolated Serial Link............................................................. 24107181 £8.50
USB/SPI Interface Board.................................................... 16107182 £5.95
45V/8A Power Supply PCB plus acrylic spacer.................. 18111181 £14.95 DECEMBER 2019
45V/8A Power Supply front panel five-way display bezel... 18111181-BZ £3.95 Extremely Sensitive Magnetometer.................................... 04101011 £16.75
Five-way LCD Panel Meter/Display.................................... 18111182 £7.95 Four-channel High-current DC Fan and Pump Controller.... 05108181 £8.75
Useless Box........................................................................ 08111181 £11.50
OCTOBER 2020
Digital Audio Millivoltmeter................................................. 04108191 £9.95 NOVEMBER 2019
Precision Signal Amplifier................................................... 04107191 £7.95 Tinnitus & Insomnia Killer (Jaycar case – see text)............ 01110181 £9.95
Tinnitus & Insomnia Killer (Altronics case – see text)......... 01110182 £9.95
SEPTEMBER 2020
PE Theremin PSU.............................................................. AO-0920-01 £5.95 OCTOBER 2019
PE Theremin PSU transformer........................................... AO-0920-02 £7.95 Programmable GPS-synced Frequency Reference........... 04107181 £11.50
Micromite Explore-28......................................................... 07108191 £6.95 Digital Command Control Programmer for Decoders......... 09107181 £9.95
Ultrabrite LED Driver.......................................................... 16109191 £6.95 Opto-isolated Mains Relay (main board)............................ 10107181 £11.50
Opto-isolated Mains Relay (2 × terminal extension board)....10107182
AUGUST 2020
Micromite LCD BackPack V3............................................. 07106191 £9.95 AUGUST 2019
Steering Wheel Audio Button to Infrared Adaptor............... 05105191 £7.95 Brainwave Monitor.............................................................. 25108181 £12.90
Super Digital Sound Effects Module................................... 01107181 £6.95
JULY 2020 Watchdog Alarm................................................................. 03107181 £8.00
AM/FM/CW Scanning HF/VHF RF Signal Generator......... 04106191 £13.95 PE Theremin (three boards: pitch, volume, VCA).............. PETX0819 £19.50
Speech Synthesiser with the Raspberry Pi Zero................ 01106191 £5.95 PE Theremin component pack (see p.56, August 2019).... PETY0819 £15.00
PE Mini-organ PCB............................................................ AO-0720-01 £14.95
PE Mini-organ selected parts............................................. AO-0720-02 £8.95 JULY 2019
High-current Solid-state 12V Battery Isolator – control...... 05106191 £6.95 Full-wave 10A Universal Motor Speed Controller............... 10102181 £12.90
High-current Solid-state 12V Battery Isolator FET (2oz).... 05106192 £9.95 Recurring Event Reminder................................................. 19107181 £8.00
Temperature Switch Mk2.................................................... 05105181 £10.45
JUNE 2020
Arduino breakout board – 3.5-inch LCD Display................ 24111181 £6.95 JUNE 2019
Six-input Audio Selector main board.................................. 01110191 Arduino-based LC Meter.................................................... 04106181 £8.00
£10.95
Six-input Audio Selector switch panel board...................... 01110192 USB Flexitimer.................................................................... 19106181 £10.45

MAY 2020 MAY 2019


Ultra-low-distortion Preamplifier Input Selector.......................... 01111112 2× 12V Battery Balancer.................................................... 14106181 £5.95
£11.25
Ultra-low-distortion Preamplifier pushbutton Input Selector...... 01111113 Deluxe Frequency Switch................................................... 05104181 £10.45
Universal Regulator..................................................................... 18103111 £7.95 USB Port Protector............................................................. 07105181 £5.95
433MHz Wireless Data Repeater............................................... 15004191 £8.50
Bridge-mode Adaptor for Amplifier.............................................. 01105191 £7.95 APRIL 2019
iCEstick VGA Terminal................................................................. 02103191 £5.95 Heater Controller................................................................ 10104181 £14.00
Analogue noise with tilt control.................................................... AO-0520-01 £7.95
Audio Spectrum Analyser............................................................ PM-0520-01 £8.95 MARCH 2019
10-LED Bargraph Main Board............................................ 04101181 £11.25
+Processing Board.............................................. 04101182 £8.60

70 Practical Electronics | May | 2024


CLASSIFIED ADVERTISING

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

BOWOOD ELECTRONICS LTD Electrical Industries Charity (EIC)


Suppliers of Electronic Components We help people working in the
electrical, electronics and energy COAST ELECTRONICS
www.bowood-electronics.co.uk community as well as their family BREAKOUTS-COMPONENTS-
Unit 10, Boythorpe Business Park, Dock Walk, Chesterfield, members and retirees. CONTRACT DESIGN-3D PRINTER PARTS-
Derbyshire S40 2QR. Sales: 01246 200 222 We use workplace programmes that MUSICAL-MICROCONTROLLERS
Send large letter stamp for Catalogue WWW.COASTELECTRONICS.CO.UK
give the industry access to financial
grants and a comprehensive
range of free and
MISCELLANEOUS confidential services. Andrew Kenny – Qualified Patent Agent
EPO UKIPO USPTO
VALVES AND ALLIED COMPONENTS? www.electricalcharity.org
Circuits Electric Machinery Mechatronics
For free stock list and/or advice, please Web: www.akennypatentm.com
contact me: [email protected] COMPONENTS AS JOB LOT
Email: [email protected]
Telephone: 01788 574774 Large stock. Transistors, Diodes,
Tel: 0789 606 9725
Logic, Memory and Analogue parts.
PIC DEVELOPMENT KITS, DTMF kits 1000s of passive items. Catalogued
and modules, CTCSS Encoder and and sorted. ‘New Old Stock’ in racks.
Decoder/Display kits. Email: [email protected]
Visit www.cstech.co.uk

ADVERTISING INDEX
CRICKLEWOOD ELECTRONICS . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Advertisement offices
ESR ELECTRONIC COMPONENTS . . . . . . . . . . . . . . . . . . . . . . . 39 Matt Pulzer
HAMMOND ELECTRONICS Ltd . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
JPG ELECTRONICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Electron Publishing Ltd
FLOWCODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Cover (ii)
1 Buckingham Road
PEAK ELECTRONIC DESIGN . . . . . . . . . . . . . . . . . . . . . . Cover (iv)
Brighton
POLABS D.O.O. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 East Sussex BN1 3RA
QUASAR ELECTRONICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Tel 07973 518682
SILICON CHIP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Email [email protected]
STEWART OF READING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
TAG-CONNECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Web www.electronpublishing.com
TERRINGTON COMPONENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
For editorial contact details see page 7.

Practical Electronics | May | 2024 71


Next Month – in the June issue
Wi-Fi Time Source for GPS Clocks
The Raspberry Pi Pico W can be used as a substitute for GPS modules in
existing time keeping designs, for when you can’t get a reliable GPS signal.
It gets the time from an internet NTP server via Wi-Fi and is accurate to a
fraction of a second.

Loudspeaker Test Jig


Use your computer’s sound card to measure loudspeaker performance,
inductors, capacitors and complex impedances. With this Jig and
appropriate software, measuring and tweaking crossovers, cabinets and
speakers is easy.

Heart Rate Sensor Module


The XC3784 kit features an Analog Devices AD8232 heart rate
monitor front-end IC which forms the ‘heart’ of this module.
It provides a low-cost way to monitor the operation of the
heart via an Arduino MCU or similar. It comes complete with a
matching three-electrode lead; a pack of additional electrode
pads is also available.

PLUS!
All your favourite regular columns from Cool Beans and
Circuit Surgery, to MitchElectronics, Teach-In, Techno Talk
and Net Work. On sale 2 May 2024
Content may be subject to change

Welcome to JPG Electronics NEW subscriptions hotline!


Selling Electronics in Chesterfield for 29 Years
Open Monday to Friday 9am to 5:30pm
And Saturday 9:30am to 5pm Practical
• Aerials, Satellite Dishes & LCD Brackets
• Audio Adaptors, Connectors & Leads
• BT, Broadband, Network & USB Leads
Electronics
• Computer Memory, Hard Drives & Parts We have changed the way we sell and renew
• DJ Equipment, Lighting & Supplies subscriptions. We now use ‘Select Publisher
• Extensive Electronic Components
Services’ for all print subscriptions – to start a
- ICs, Project Boxes, Relays & Resistors
• Raspberry Pi & Arduino Products new subscription or renew an existing one you
• Replacement Laptop Power Supplies have three choices:
• Batteries, Fuses, Glue, Tools & Lots more...
1. Call our NEW print subscription hotline:
01202 087631, or email: [email protected]
T: 01246 211 202
E: [email protected] 2. Visit our shop at: www.electronpublishing.com
JPG Electronics, Shaw’s Row,
Old Road, Chesterfield, S40 2RB
3. Send a cheque (payable to: ‘Practical
W: www.jpgelectronics.com Electronics’) with your details to:
Practical Electronics Subscriptions, PO Box 6337,
Shaw’s Row

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

Rose & Crown


Johnsons
all Ro

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.

72 Practical Electronics | May | 2024


Did you know our online shop
now sells the current issue of
PE for £5.99 inc. p&p?
Practical
Electronics Prac
Electro tical
The UK’s premier electronics and computing maker magazine

nics
The UK
Circuit Surgery Teach-In 2024 ’s pre mierOut
Audio
electro
Topics in digital signal Analogue input and output
Circuitwith Designing
nics an
processing – sampling LTspic Surgerydiscrete buffers
the ESP32 SoC microcontroller d com
e 24 u puting
Freque pd
ncy Re ate and T maker
spons ea ch-In 20 magaz
e Ana
lysis Digita
l input 24 ine
th e ESP3an d
2 SoC output with Audio
microc O
Design ut
ontrolle in
r discrete g
buffers

Dual RF Amplifier
GPS-Disciplined
Oscillator Basic
R
Mastering Signal F ‘Swiss
the UVM-30A Ge A
UV Sensor nerato Automa rmy Knife’
r ted Te
WIN! st Ben
Microc
hip
ch
E xplo
Develo rer 8
Teach-In 2024 pment
Kit
IN! W
Learn to use Teach
the ESP32 -In 20
LeaSongbird:
rn to u 2an
4 ideal
s
thebeginner’s
ESP32 e project
PLUS! Silicon
P
Techno Talk – One step closer to LaUdystopian
S! abyss? May 2024 £5.99 C
Build y hirp
pet cr our own
Techn 05
o Tadelights
Cool Beans – Arduino: 7-segment display lk – W it
Cool B
Net Work – Electric cars, Moon-shot eans – andamore
missions Arduin
! What 9 772632 573030
?R icket
Net W
ork – L o: expa eally?
www.electronpublishing.com abel p
@practicalelec nding
practicalelectronics
rinters t
www.e
lectro
, smart he 7-segmen Apr 20
24 £5
npubli home t displa .99
shing device y
.com s and SM 04
@pr Rs 9 772632
actica
lelec
5 73030

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

You might also like