Jul24 Int
Jul24 Int
Electronics
The UK’s premier electronics and computing maker magazine
Circuit Surgery Teach-In 2024 Audio Out
Topics in digital signal processing Sensing the environment with Mechanical
– sample and hold the ESP32 SoC microcontroller switches in audio
Make your
own Dynamic
RFID tags
Reciprocal
Frequency Counter
Teach-In 2024
Learn to use
the ESP32
Pi Pico-based
Thermal Camera
PLUS!
Techno Talk – Who saw that coming? Jul 2024 £5.99
07
Cool Beans – Arduino: 7-segment display decoders
Net Work – Practical advice on electronics repairs 9 772632 573030
Sysblocks
www.flowcode.co.uk
Practical
Volume 53. No. 7
July 2024
ISSN 2632 573X
Electronics Contents
Projects and Circuits
Pi Pico-based Thermal Camera by Kenneth Horton 17
A thermal infrared camera measures hot or cold spots compared to the surrounding
area – useful for diagnosing hot spots in electronic circuits, which may indicate a failing
component. They can be pricey, but not this one, a DIY version that’s easy to build.
Dynamic NFC Tag by Tim Blythman 22
The availability of dynamic NFC tags means you can now easily create your own
custom NFC/RFID Tags. This article explains how to program NFC chips that can be
used as smart business cards and more.
Reciprocal Frequency Counter by Charles Kosina 30
A traditional frequency counter samples over a long period to get an accurate result.
This one instead measures the average period and calculates the inverse, so it only
needs to monitor a few pulses to get a precise reading. It’s useful up to about 10MHz.
The Wireless for the Warrior books are a the introduction of VHF FM and
source of reference for the history and hermetically sealed equipment.
development of radio communication
equipment used by the British Army Volume 3 covers army receivers from
from the very early days of wireless up 1932 to the late 1960s. The book not
to the 1960s. only describes receivers specifically
designed for the British Army, but also
The books are very detailed and include the Royal Navy and RAF. Also covered:
circuit diagrams, technical specifications special receivers, direction finding
and alignment data, technical receivers, Canadian and Australian
development history, complete station Army receivers, commercial receivers
lists and vehicle fitting instructions. adopted by the Army, and Army Welfare
broadcast receivers.
Volume 1 and Volume 2 cover
transmitters and transceivers used Volume 4 covers clandestine, agent or ‘spy’
between 1932-1948. An era that starts radio equipment, sets which were used by
with positive steps taken to formulate special forces, partisans, resistance, ‘stay
and develop a new series of wireless sets behind’ organisations, Australian Coast
that offered great improvements over Watchers and the diplomatic service. Plus,
obsolete World War I pattern equipment. selected associated power sources, RDF and
The other end of this timeframe saw intercept receivers, bugs and radar beacons.
01202 087631
Circuit Surgery Teach-In 2024 Audio Out Circuit Surgery Teach-In 2024 Audio Out Circuit Surgery Teach-In 2024 Audio Out Circuit Surgery Teach-In 2024 Audio Out Circuit Surgery Teach-In 2024 Audio Out
LTspice 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 Topics in digital signal Using LED displays with the ESP32 Mechanical Topics in digital signal processing Sensing the environment with Mechanical
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 processing – ADCs SoC microcontroller switches in audio – sample and hold the ESP32 SoC microcontroller switches in audio
Digital
Volume Control WIN!
Microchip
Potentiometer Curiosity HPC
Development
Board Loudspeaker Make your
WIN!
WIN! Test Jig own Dynamic
Microchip
PIC32MK MCJ RFID tags
Curiosity Pro
Development
‘Swiss Army Knife’ Dual RF Amplifier
Building the Active Board GPS-Disciplined Heart Rate
Basic RF Automated Test Bench Oscillator Reciprocal
Mains Soft Starter Sensor Module
Signal Mastering Frequency Counter
Generator WIN!
the UVM-30A
Teach-In 2024 Microchip
Explorer 8 Wi-Fi Time Source
Learn to use the ESP32
Development
Kit
UV Sensor for GPS Clocks
WIN!
Teach-In 2024
Teach-In 2024 Learn to use
Teach-In 2024 Teach-In 2024 the ESP32
Advanced SMD Learn to use Silicon Chirp Learn to use Learn to use
Test Tweeze the ESP32 Build your own the ESP32 Songbird: an ideal the ESP32
rs Pi Pico-based
pet cricket beginner’s project
Thermal Camera
PLUS! PLUS! PLUS! PLUS! PLUS!
Mar 2024 £5.99 Techno Talk – Wait! What? Really? Apr 2024 £5.99 May 2024 £5.99 Jun 2024 £5.99 Jul 2024 £5.99
Techno Talk – The Wibbly-Wobbly World of Quantum 03 04 Techno Talk – One step closer to a dystopian abyss? 05
Techno Talk – Program that! 06
Techno Talk – Who saw that coming? 07
Cool Beans – Arduino: expanding breadboard designs Cool Beans – Arduino: expanding the 7-segment display Cool Beans – Arduino: 7-segment display delights Cool Beans – Arduino: 7-segment display delights Cool Beans – Arduino: 7-segment display decoders
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
Net Work – GaN USB chargers, solid-state EV battery 9 772632 573030
Net Work – Practical advice on electronics repairs 9 772632 573030
www.electronpublishing.com @practicalelec practicalelectronics www.electronpublishing.com @practicalelec practicalelectronics www.electronpublishing.com @practicalelec practicalelectronics www.electronpublishing.com @practicalelec practicalelectronics www.electronpublishing.com @practicalelec practicalelectronics
Take out a one-year subscription and save more than £10 over the year.
Even better – save over £1 per issue if you subscribe for two years – a total saving of £26.
Electronics
Rest of the World £46.99 (Airmail)
1 Year: UK £59.99, Europe £69.99 (Airmail),
Rest of the World £84.99 (Airmail)
Subscriptions start with the next available issue. We accept Card Ex. Date ......................................
MasterCard or Visa.
Name ............................................................................................
(For past issues see the Back Issues page.)
Address ........................................................................................
9 771030 266001
$1150* NZ $1290
05
INC GST
INC GST
Australia’s
International Airsho
All the newest tech
in Avalon Airpor
w
t
• Combined subscriptions include both the printed magazine and online access.
Wideband
• Prices are in Australian dollars (AUD) unless otherwise specified. Fuel Mixture Display;
• Prices listed are for everywhere in the world except Australia and New Zealand. April to June 2023
View siliconchip.com.au/Shop/SubRates for a full list of current prices.
• Price estimates are just that and should only be used as a guide, we primarily
take payment in the form of Australian dollars.
Silicon Chirp;
April 2023
Try our Online Subscription – now with PDF downloads!
An online issue is perfect for those who don’t want too much Advanced SMD
clutter around the house and is the same price worldwide. Test Tweezers;
Issues can be viewed online, or downloaded as a PDF. February & March 2023
Electronics Editorial
Editorial offices
Practical Electronics Tel 01273 777619 We’ve come a long way
Electron Publishing Limited Mob 07973 518682 Hobby electronics has come a long way since the days when,
1 Buckingham Road Fax 01202 843233
Brighton Email [email protected] nearly a century ago, constructors grappled with newly emerging
East Sussex BN1 3RA Web www.electronpublishing.com vacuum tube technology to produce home-brew radio receivers of
Advertisement offices
surprising sophistication and complexity. That was in an era when
Practical Electronics Adverts Tel 01273 777619 ‘wireless’ was one of the few practical hobbies available to budding
1 Buckingham Road Mob 07973 518682 ‘makers’. (Woodworking was another.) Interest in radio intensified
Brighton Email [email protected]
East Sussex BN1 3RA exponentially during the 1930s and magazine titles such as Hobbies
and Practical Wireless appeared weekly to meet an insatiable
Editor Matt Pulzer
General Manager Louisa Pulzer
demand for projects to challenge the hobbyist’s practical skills.
Digital subscriptions Stewart Kearn Tel 01202 880299
Online Editor Alan Winstanley
Web Systems Kris Thain
Practical Wireless would become a standalone title aimed at
Publisher Matt Pulzer the flourishing hobby radio sector while its sister magazine,
Practical Electronics, followed in the early 1960s to exploit new
Print subscriptions
Practical Electronics Subscriptions
semiconductor devices in a wider range of applications. The
PO Box 6337 wannabe electronics constructor has been kept busy ever since!
Bournemouth BH1 9EH Tel 01202 087631
United Kingdom Email [email protected]
Our hobby has of necessity mirrored global technological trends,
Technical enquiries and today’s constructors embrace a wholly different set of skills
We regret technical enquiries cannot be answered over the
telephone. We are unable to offer any advice on the use, purchase,
compared with their forebears. Wikipedia reminds us that the
repair or modification of commercial equipment or the incorporation first electric soldering iron dates back to 1889: appropriate for
or modification of designs published in the magazine. We cannot radio sets of yesteryear, perhaps, but some modern construction
provide data or answer queries on articles or projects that are
more than five years old. projects regularly use ready-made modules and tiny surface-
mounted devices that are much smaller than a match head – a fact
Questions about articles or projects should be sent to the editor
by email: [email protected]
of life dictated to us by the electronics industry. Starting 25 years
ago, boards full of discrete components were swept aside by the
Projects and circuits microcontroller, which demanded programming and coding know-
All reasonable precautions are taken to ensure that the advice and
data given to readers is reliable. We cannot, however, guarantee how, aided by the use of software design tools. Thanks to our design
it and we cannot accept legal responsibility for it. partners at Silicon Chip, the class-leading projects found inside
A number of projects and circuits published in Practical Electronics
every issue take advantage of these modern components along with
employ voltages that can be lethal. You should not build, test, high-quality printed circuit boards that help ensure constructors can
modify or renovate any item of mains-powered equipment unless accomplish their latest project successfully. One thing that hasn’t
you fully understand the safety aspects involved and you use an
RCD (GFCI) adaptor. changed over the years, though, is the inspiration and variety that
we at Practical Electronics strive to bring our readers every month,
Component supplies offering constructors interesting and absorbing challenges to keep
We do not supply electronic components or kits for building the
projects featured, these can be supplied by advertisers. We you just as busy as ever!
advise readers to check that all parts are still available before
commencing any project in a back-dated issue.
What will the future bring?
Advertisements From circuits using glass vacuum tubes housed in wooden
Although the proprietors and staff of Practical Electronics take cabinets to the latest designs based on devices with a billion or
reasonable precautions to protect the interests of readers by
ensuring as far as practicable that advertisements are bona fide, more transistors in 3D-printed enclosures, electronics has changed
the magazine and its publishers cannot give any undertakings beyond recognition. In fact, when it comes to electronics, change is
in respect of statements or claims made by advertisers, whether
these advertisements are printed as part of the magazine, or in the one constant you can rely on. So, what will the coming decades
inserts. The Publishers regret that under no circumstances will bring? AI, smarter sensors and faster devices seem certain, but I’m
the magazine accept liability for non-receipt of goods ordered, or
for late delivery, or for faults in manufacture.
sure there will be surprises too. And that’s all part of the fun!
Cast your mind back to the year 2000. How many of the devices and technologies that surround
us today did you see coming? Did you predict the advent of smartphones? Did you envisage tablet
computers? Did you forecast the widespread deployment of AI?
W
e live in an age of wonders. or take), this mass occupies a volume Alif Semiconductor (www.alifsemi.com)
Many of us don’t appreciate comparable to the Earth (give or take). recently announced a family of small,
just how lucky we are. For We know the white dwarf is suck- affordable, low-power microcontrollers
most of human existence, apart from ing hydrogen away from the red giant, (MCUs) capable of performing artificial
the top 0.1%, people lived in abject resulting in it having a ‘sea’ of hydro- intelligence (AI) tasks like voice process-
squalor. They were cold, hungry, dirty, gen a few meters deep. At some stage, ing and image recognition.
infested… and those were the lucky the hydrogen will undergo a runaway They also have something they call a
ones. Now our homes boast hot and thermonuclear reaction that will blow Vision AppKit, which is a small circuit
cold running water, electric lights and off the surface layer of the white dwarf. board the size of a large postage stamp
heating (and cooling where I live). We Known as a nova (as opposed to a su- carrying one of their processors and a
issue spoken commands to artificial pernova), we can predict (with a high camera. They are sending one of these
intelligences, our humongous high- degree of confidence) that this event bodacious beauties to me. It will be pre-
resolution colour televisions show us occurred around 3,000 years ago, with programmed to recognise human faces
what’s happening around the world in the light reaching us sometime between looking toward the camera. I’m going to
real-time, and… I could go on and on. the time of this writing and the end of mount this on my Countdown Timer.
September 2024, resulting in a magni- When someone is looking toward the
Knowledge is power tude +2 star that will be visible to the timer, the VFDs will shine in all their
There are two quotes that often spring naked eye for a couple of weeks. glory. If no one is looking, the timer will
into (what I laughingly refer to as) I don’t know about you, but the carry on counting but the displays will
my mind. The first is the expression, fact we know any of this stuff blows be powered down. Brilliant!
ipsa scientia potestas est (‘knowl- my mind.
edge itself is power’), which occurs in Who knew?
Francis Bacon’s Meditationes Sacrae I can see you! How good do you think you are with
(1597). And then there’s, ‘The simplest A few years ago, I started work on a respect to predicting the future? We
schoolboy is now familiar with facts hobby project I called my Countdown can base this on how good you were
for which Archimedes would have Timer. Its role in life was to count down in the past. As we celebrated the year
sacrificed his life,’ which comes from the years, months, days, hours, minutes, Y2K and the start of the current millen-
Ernest Renan’s Souvenirs D’enfance et and seconds to the commencement of my nium, for example, did you predict the
de Jeunesse (1887). 100th birthday celebrations, which will advent of smart phones that could take
I love to learn new things. I’m in- kick off at 11:45 a.m. British Summer pictures and videos, act as MP3 play-
credibly fortunate in that I get to chat Time (BST) on 29 May 2057 (mark your ers, and provide GPS functionality? Did
with all sorts of people who know calendar and stockpile the fireworks). you envisage tablet computers like the
things with which to boggle my mind. I put this on the back burner for a iPad? Did you forecast the widespread
Just the other day, for example, I was while (so many things to do, so little deployment of AI and the commercial
chatting with Dr Gerard Van Belle, who time to do them). Actually, I put it on availability of virtual reality (VR) and
is Director of Science at the Lowell a shelf in the closet. Unfortunately, mixed-reality (MR) headsets?
Observatory in Flagstaff, Arizona. He the shelf collapsed, crushing all the Let’s get a little closer to home –
was telling me about all the telescopes display elements. ‘Oh dear,’ I said (or say a year ago. Were you expecting a
and other technologies we now have words to that effect). little AI-enabled MCU like the one I
at our disposal to vastly increase the I’m recreating this little beauty us- described earlier to be available now?
sum of human knowledge about all ing vacuum fluorescent display (VFD) Me neither. So, who was good at pre-
sorts of things. tubes – try to visualise a steampunk dicting the future?
For example, we know that there’s a incarnation of 7-segment displays Well, I recently read A Story of the
star system that’s located about 3,000 implemented using a mix of vacuum Days to Come by HG Wells. Published in
light years from Earth. Our name for tube and cathode ray tube (CRT) tech- 1899, this tale is set in a dystopian future
this system is T Coronae Borealis, or nologies. The problem is that it’s about London of the 22nd century. People live
T CrB. This system is to be found in 33 years (290,000 hours) to the great in enclosed cities and travel around on
that portion of the night sky we call event, but VFDs have a life expectan- moving walkways. Mega-corporations
the constellation Coronae Borealis. We cy of only 10 years (87,000 hours). rule the world. The rich live in skyscrap-
know this is a binary system compris- I’m going to feel rather silly if I don’t ers while the lower classes are relegated
ing a huge red giant and a white dwarf know when it’s time to start blowing to subterranean dwellings. There are
orbiting each other. We know the white my own (party) trumpet. intelligent loudspeakers suspiciously
dwarf is composed of electron-degen- Fortunately, as I mentioned at the start the Amazon Alexa… Hmmm, maybe
erate matter, which means that, while of this column, we live in an age of won- Wells’ Time Machine was functional
having the same mass as our sun (give ders. For example, a company called rather than fictional!
TEACH-IN 3 TEACH-IN 5
£7.99
huge range of subjects that will interest everyone involved 15 design and build circuit projects for newcomers or JUMP START
CIRCUIT SURGERY
in electronics – from newcomers to the hobby and i The how and why of circuit design those following courses in school and colleges. 15 design and build circuit projects
dedicated to newcomers or those
PRACTICALLY SPEAKING
students to experienced constructors and professionals.
following courses in schools and
PIC ‘N MIx
Surgery, EPE/PE’s regular clinic dealing with readers’ Powered Charger n Versatile Theft Alarm n Spooky
i Over 40 different circuit ideas
Starting out with PIC microcontrollers
t
W
1
TWO TEACH-INs FOR
Elec
©
TWO TEACH-INs FOR
THE PRICE OF ONE! THE PRICE OF ONE !
The second section – Practically Speaking – i The free CD-ROM provides
a broad-based introduction
to electronics
n Egg Timer n Signal Injector Probe n Simple Radio Provides
a practi
cal
to PIC
introduction llers
Plus:
MikroElektro
Microchip pe
L-Tek PoSco
nika,
The free CD-ROM provides a
practical introduction to PIC
8 Inter
active ledge
and logo, Techno
ip name of Microchip
Technol
Microch
ip
.09 software
PLUS
The Microch arks s. © 2013
Your Know
016-02
ed tradem countrie 1. MCCD1
register and other d. Issue
in the USAAll rights reserve
d 1
In 2 - JUL13.ind
A BROAD-BASED INTRODUCTION TO CD
ELECTRONICS
TEACH-IN 4
FROM THE PUBLISHERS OF
Electronics Manual, worth £29.95. The Manual i Over 800 PDF pages
What a Bargain!!
if not, open double-click
and
Explorer f
index.pd
MAN.co.u
Downloa be.com
www.ado
BA SE .epe mag
k
© Wimbor
Audio Out – an
£8.99 £8.99
D CD
DV
and Circuit Surgery
The Teach-In 6 CD-
TEACH-IN 6 analogue expert’s take
TEACH-IN 7 by Ian Bell – ‘State TEACH-IN 8
FROM THE PUBLISHERS OF FROM THE PUBLISHERS OF
FREE
CD-ROM
ROM also contains all on specialist circuits
SOFTWARE
FOR
the techniques of
• Pi ClASS – SPECifiC lEARninG AimS • Learn with ‘TINA’ – modern CAD software • Microcontrollers – understand control operations
• PYthon QuiCkStARt – SPECifiC PRoGRAmminG toPiCS • Five projects to build: Pre-amp, Headphone Amp,
readers and circuit the files for:
• Communications – connect to PCs and other Arduinos
• Pi woRld – ACCESSoRiES, BookS EtC Tone Control, VU-meter, High Performance Audio Power Amp
project building.
• homE BAkinG – follow-uP ACtivitiES
nM
icrochip MPLAB
RE FOR
SERIES SOFTWA 7
CH-IN
THE TEA
Smartscope software.
building PIC-based projects
Teach In 6 Cover.indd 1 02/03/2015 14:59:08 Teach In 7 Cover VERSION 3 FINAL.indd 1 07/04/2016 08:25 Teach In 8 Cover.indd 1 04/04/2017 12:24
T
his year’s DTG Summit – Freeview until 2034. How this commit- Freely
organised by the Digital Televi- ment will bind any future government The UK’s public service broadcasters, BBC,
sion Group, which standardises and minister is unclear. ITV, Channel 4 and Five, are banking on
the tech needed to watch digital TV in a recently announced new service called
the UK – coincided with news that the Careful how you change Freely, which was being demonstrated
government and communications regula- Although no-one was blunt enough to in exhibition space at the DTG Summit.
tor Ofcom are looking at a timetable for mention it (or perhaps hadn’t yet seen Jonathan Thompson, Chief Executive of
switching TV viewing from traditional it with their own eyes) the Summit also Everyone TV, the new company behind
over-the-air linear broadcasts to Internet- coincided with a dramatic example of the Freely, describes himself as ‘a former di-
based IP streaming delivery. perils of transitioning from broadcast to rector of strategy for Ofcom and Channel
In October 2023, Ofcom launched a broadband delivery. 4’ with ‘extensive experience of working
‘Call for Evidence’ on how changing The struggling TV station TalkTV had in broadcasting and the regulatory envi-
audience habits, in particular, the in- just ceased normal broadcasting and ronment’. He read a speech which said
crease in Internet-based viewing, will switched to stream delivery. Anyone tun- very little about how Freely works, just
affect the future of TV distribution. ing an ordinary TV to TalkTV’s Freeview a lot about how Freely is ‘a foundation
Over 75s are four times more likely to channel 237 got a dark screen; anyone for the future’ which bundles ‘everything
rely on digital broadcasting than Gen with a smart TV is – in theory – automati- from the public service broadcasters
Z youngsters who have been brought cally redirected to Channel 294, which is – Freeview terrestrial and Freesat satel-
up with streaming. Over 50% of 16- a Freeview channel that automatically lite, along with the catchup services like
24 year-olds don’t watch TV. They logs into an IP stream. In practice, and iPlayer, in one place, for free’.
stream YouTube or Tik Tok, instead. even with fibre broadband, the viewer ‘All you need is Wi-Fi,’ Thompson said
Yih-Choung Teh, Ofcom’s Director of waits what may be minutes to see a dark (as long as the broadband speed is at least
Strategy and Research, compares the screen, then an invitation to press the 10 Mbps). ‘Freely provides multiple entry
switch to IP streaming as ‘comparable remote control’s Red Button (which ap- points. We continue to support Freeview
to Digital Switchover’ when the UK pears unnecessary), then sees a message and Freesat and Freeview Play. Freely
very successfully ditched analogue TV. that connection may take 30 seconds and just adds to the mix. We are at the start
‘The tipping point will be when it finally, after what may be minutes, gets to of a journey’.
is no longer viable for broadcasters to watch the programme. The delay probably Freely’s demonstrators outside in the
deliver digital television,’ he says. This depends on the quality of the smart TV. exhibition space were able to add a
will come when not enough people are I’ve also encountered problems with little more hard fact detail. So far, the
receiving broadcasts to justify the cost lost lip sync and stream freezing, with only way to receive via Freely is to buy
of transmitters. gaps so long that by the time the pictures a new Hisense TV set with the Freely
But he assured that Ofcom is commit- and sound are up and running again, the system built in. This takes in Freeview
ted to ‘not leaving people behind’ and topic being discussed has changed. And Digital Terrestrial broadcasts through a
Minister for Digital Infrastructure Julia for some unexplained reason the news conventional aerial socket and broadband
Lopez added the assurance that although breaks contain no news. streams by Wi-Fi (and presumably also
99% of TVs sold next year will be ‘smart’ It’s a confusing mess and unless there Ethernet). Freely numbers its channels
and Internet-enabled, the government will are major advances, mixing IP and DTV differently from Freeview and Freesat.
not pull the plug on Digital Terrestrial effectively kills channel hopping. So Sky News is on channel 303 instead
TalkTV has provided a masterclass in how not to transition from broadcast TV to IP streaming.
NEW!
assumption and opinion are generally (POSTRS), run by the even more impres-
worthless. So, for the sake of complete- sively titled CEDR (Centre for Effective
ness, I’ll briefly put on record a couple Dispute Resolution), had handled my com-
of fresh hard facts relevant to the pieces plaint about the way Royal Mail’s impres-
I’ve written about self-protection when sive multi-tier internal complaints system
buying on line. Also, some fresh self- had brushed aside diligently collated evi-
protection tips for the Internet Wild West.
Just for the heck of it and with zero
dence showing delivery fraud inside Royal
Mail. I complained that POSTRS/CEDR
5-year
expectations I filed a complaint with
the Advertising Standards Authority
gave no reasons for complaint rejection.
POSTRS/CEDR excused itself thus, ‘The
collection
about the convoluted way in which eBay
promises protection under the Finan-
CEDR Complaints Procedure does not
allow any investigation to be carried out
2017-2021
cial Ombudsman Services if things go into a decision made by an adjudicator
wrong with eBay’s Moneyback Guarantee or the decision process adopted by that All 60 issues from Jan 2017
scheme. In a memo nutshell, eBay in the adjudicator or the evidence they choose to Dec 2021 for just £44.95
UK comprises two quite different and to consider or give weight to.’
separate entities: 1) eBay Marketplace, You have to hand it to them all. They
PDF files ready for
which is eBay (UK) Limited, accessed are being paid good money to ensure no immediate download
via the eBay.co.uk website and 2) eBay sane person would ever bother complain-
Commerce UK Limited. ing about anything relating to Royal Mail. See page 6 for further
eBay Commerce UK Limited (ECUK) More broadly it is now a sad fact of
provides payment services for sellers on modern on-line life that most avenues
details and other great
the eBay platform and is regulated by the of official complaint now lead to a brick back-issue offers.
Financial Conduct Authority (FCA). The wall of illusory concern for consumer
Financial Ombudsman Service (FOS) well-being, with buck-passing middle Purchase and download at:
can investigate complaints for seller managers hiding behind No-Reply email www.electronpublishing.com
payment services. addresses. Just as the postmasters were
I
n last month’s column I showcased certain powerbanks and mains chargers
some USB-powered products that can intelligently communicate with a
typically use a 5V USB source to device using a USB-C lead, raising the
recharge their internal batteries. Whether charging voltage to 9, 12, 15 or even 20V
it’s a camping light, earbuds, Bluetooth to deliver more power and cut charging
speaker or a powerbank, it seems that times dramatically. Last month, I suggested
almost every Chinese-made gadget or some USB add-on monitors that show
rechargeable device now arrives with a what’s actually happening when USB-
USB-C lead included for use with your powered devices are being charged. Tiny
own charger. Some USB leads might only digital meters are readily available that
cost a few pence to make and are often plug onto the end of a USB-C cable to
The KOWSi KWS-065C is a thumb-size
included just to add ‘perceived value’ to display the power being delivered, and a
inline USB-C monitor showing voltage,
the product – I have a dozen scattered ‘PD’ icon confirms when Power Delivery current, wattage, capacity and elapsed
around, ready for the recycling bin. A is operating. These gadgets are very handy time, and is rated up to 6.5A.
‘hanked’ lead is one formed by coiling it for use with an existing USB charger cable.
between two spindles or around a bar to Since last month, several more USB Another KOWSi USB-C monitor, the
produce a tidy coil, usually with a wire leads and monitors have arrived from KWS-2301C, has a 0.77-inch HD mono
tie twisted round the middle or retained China which I’ve been testing over the OLED readout that really impressed
with a fancy sleeve. Apple addressed the past few weeks. Basic monitors that use me: although more compact in size, its
thorny problem of producing hanked USB an A-type port such as the KOWSi USB comprehensive display shows five lines
leads many years ago, by shaping them Detector shown on p.11 last month display of data including time, maximum values,
around two mandrels as shown in Apple’s voltage and current, but I’ve now sourced CPU temperature and direction of flow.
patent, downloadable from the US Patent a more versatile USB-C monitor that has It’s rated up to 12A and the display
Office at: https://bit.ly/pe-jul24-pat an uncluttered multicolour display. The is crystal clear, but having the eyesight
Silicone cable ties and clips (pictured KOWSi KWS-065C is a useful thumb-size of a sparrowhawk might help! KOWSi
below) are available cheaply from Temu, inline device showing voltage, current, is a brand of Yuyao Lianke Electronics,
and are quite handy for keeping USB wattage, capacity and elapsed time. It and the products mentioned cost just
leads manageable. (While I was at it, with memorises readings until reset and the a few pounds from AliExpress, though
online security in mind, I spotted some white segments can be cycled to show remember that AliExpress doesn’t include
stick-on privacy covers for my laptop’s power, watt-hours and capacity. It supports sales tax in their on-screen prices.
webcam that work perfectly.) the major charging protocols and is rated
The latest ‘rounded-rectangle’ USB-C 4-30V at up to 6.5A. I like this general- Untangled cables
connector is now commonplace and, as purpose USB-C monitor – it’s both clear to Higher-power USB charging cables are
I showed last month, things get more read and easy to use. The similar KOWSi available that have a digital display
interesting when ‘Power Delivery’ (PD) is KWS-066C crams more data on a colour built into a USB-C plug for convenience,
involved: a PD-compatible source such as display and shows temperature as well. and I managed to source a braided
(left) A ‘hanked’ computer lead is factory-made using a wire tie, but you can buy silicone straps or rubber clips from Temu to manage
cables. (right) a stick-on privacy shutter for laptop webcams from AliExpress or Temu.
Behind B-7000
I’d never heard of ‘B-7000’ until now,
and a 15ml tube of this mystery glue
duly arrived via eBay. It turned out to
A 10,000mAh powerbank by INIU offers a digital display and PD. It is designed with be a clear, self-levelling acrylic adhesive,
portability in mind. dispensed via a needle-point nozzle
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
Pi Pico-based
Thermal
Camera by Kenneth Horton
I
R thermal cameras have many If the raw output of the Array Sen- this case, their advantages are minor;
uses beyond those listed above, sor is displayed directly on an LCD bilinear gets us most of the improve-
such as checking for overheating screen, it appears very ‘blocky’. Still, ment compared to no filtering with
mechanical bearings or identifying it can easily be upscaled using a tech- very little processing.
areas of heat loss in a building. nique called bilinear interpolation to
Panasonic produces the AMG8833 give the appearance of many more Object emissivity
Infrared Array Sensor (‘Grid-EYE’) data points. The PicoMite Thermal The ‘fly in the ointment’ for a ther-
that detects IR emissions on a Camera can upscale by factors of two, mal camera is that objects vary in
64-pixel 8 × 8 array. It uses the I2C four or nine. These factors were cho- emissivity. An ideal IR emitter is
serial protocol, so it can easily inter- sen as they make the best use of the called a ‘black body’ with 100% elec-
face with a Raspberry Pi Pico run- screen width. tromagnetic emission/absorption.
ning the PicoMite operating system. Below the thermal image display Shiny objects like mirrors have
Objects emit infrared energy in is a text read-out showing the maxi- an emissivity closer to 0%. If you
proportion to their temperature; the mum, minimum and average tempera- point an IR thermometer or camera
higher the temperature, the more IR tures and the current operating mode. at them, you will measure the tem-
energy is emitted and the higher its fre- As mentioned above, the Array Sen- perature of an object that the mirror
quency. For really hot objects, the fre- sor can sample at 10 FPS (frames per is reflecting, not the mirror itself.
quency extends into the visible wave- second) or 1 FPS. The former is most Luckily for us, many electronic
lengths, which is why hot objects are suited to fast-changing subjects, while components are dark colours and will
seen to glow. By measuring this energy, the latter better smooths out random have an emissivity of at least 90%, so
we can get a pretty good idea of the noise in the sensor, giving a more sta- a thermal camera will measure their
temperature. However, there are some ble and accurate output. temperature accurately. Human skin
pitfalls, which we will mention later. has an emissivity of 97-99.9%, so IR
With the Grid-EYE sensor, each Bilinear interpolation thermometers also work well for mea-
pixel has a viewing angle of approxi- This involves drawing an imagi- suring our temperature.
mately 7.5°, so the overall sensor has nary straight line between two data This isn’t a fatal flaw but be aware
a viewing angle of 60° (7.5° × 8). Each points, then generating new data that the temperature measurements
pixel has a tolerance of ±2.5°C when points in between that lie on that of metallic objects using this IR cam-
operated within specification. We line. It’s a simple technique that era could be inaccurate. It isn’t just
can minimise this error by calibrat- produces a much smoother-looking well-polished metal surfaces either;
ing the sensor, as described below. result than the more basic ‘nearest even rough, oxidised aluminium
Also, there can be random operat- neighbour’ technique that gives a only has an emissivity of about 20%,
ing ‘noise’ of up to ±2.5°C per pixel. blocky image. with polished metal surfaces usually
To reduce this, the sensor is used in More complicated interpolation below 5%.
moving-average mode, which aver- schemes like trilinear, bicubic, A known work-around to measur-
ages two readings when the sensor Lanczos or anisotropic interpola- ing the temperature of shiny surfaces
is set up for a 10Hz frame rate or 20 tion involve considerably more pro- (eg stainless steel pipes) is to apply
readings when for a 1Hz frame rate. cessing (arithmetic) than bilinear. In some matte painters tape, which has
a better emissivity. For more infor- find the display on the same sites. 2 Restore the calibration data and last
mation, see: https://w.wiki/6R6E There are some suggested links in pushbutton settings
the parts list. 3 Load the colour spectrum from the
Circuit details The prototype was powered via the table
Refer now to Fig.1, which shows that USB port on the Pi Pico, but there are 4 Enter the main loop
the hardware for the project is rel- also pads on the PCB for an external 5V a. Read 64 pixels from the sensor and
atively straightforward. It consists power supply. This way, the Thermal adjust with the calibration data
of just three modules: the Infrared Camera can be powered by a battery. b. Calculate the maximum, minimum
Array Sensor, a Raspberry Pi Pico The pushbutton is connected so and average temperatures
running the PicoMite operating sys- that it pulls the GP18 pin to GND c. Convert the absolute temperatures
tem (MMBasic) and a 1.8-inch SPI when it is pressed. The Pico has an to points on the colour spectrum
TFT LCD screen with a display res- internal pull-up current enabled on d. Interpolate the intermediate colour
olution of 128 × 160 pixels and an that pin, so its voltage is high when values for each row using bilinear
ST7735 controller. the button is not pressed and goes interpolation
The sensor array is connected to low when it’s pressed, allowing the e. Interpolate the intermediate colour
the Pico via an I2C interface, while digital input to sense the change. values for each column using bilin-
communications with the LCD ear interpolation
screen are over an SPI interface. The Software operation f. Update the display
only passive components are a push- The basic flow of the program is: g. Check the pushbutton state
button to change modes and a 39W 1 Initialise the PicoMite, LCD screen h. Delay if necessary
resistor to set the current at which and IR sensor array Repeat items a-h above indefinitely
the display backlight operates. The
following Pico GPIO pins are used:
GP08 LCD data/control (D/C) The rear of the enclosure (86 × 33.4
GP09 LCD chip select (CS) × 57.3mm) has a cutout for the
GP10 LCD SPI clock (SCK) AMG8833 IR sensor; you can
GP11 LCD SPI data (MOSI) also see a small cutout
for the Pi Pico’s USB
GP15 LCD reset (RST) connector on the
GP18 pushbutton sensing lip.
GP20 AMG8833 I2C data (SDA)
GP21 AMG8833 I2C clock (SCL)
LATES HE
T CO
OF OU PY Electron Publishing TEACH-IN 9
FROM THE PUBLISHERS OF
RIES
techniques, plus eight projects to build FOR THE PRICE
OF ONE
AVAILA
PRICE £8.99
• Multimeters and a multimeter checker
• Oscilloscopes plus a scope calibrator
BL
• 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
PIC n’ Mix
Including Practical Digital Signal Processing
PLUS...
Teach-In 9
Get Testing
This series of articles provides a broad-based introduction to choosing and using a wide range
Files for:
PIC n’ Mix
Three Microchip
PICkit 4 Debugger PLUS
Guides Teach-In 2 -Using
of test gear, how to get the best out of each item and the pitfalls to avoid. It provides hints and
PIC Microcontrollers.
In PDF format
tips on using, and – just as importantly – interpreting the results that you get. The series deals
www.epemag.com
with familiar test gear as well as equipment designed for more specialised applications. Teach In 9 Cover.indd 1 01/08/2018 19:56
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.
D
− Thin credit card/business card
size tag (86 × 54mm)
− Arduino sketch and jig
allows custom tags to be
easily created
− Tags can also be written
from apps
Supported Chips
− ST25DV04K
F
N
G
− ST25DV04KC
− ST25DV16K
C A
− ST25DV16KC
T
− ST25DV64K
− ST25DV64KC
Y
ou likely have several NFC Writing custom data to tags using a briefly explained the history and tech-
tags in your possession. Most Raspberry Pi Pico microcontroller and nology behind NFC.
bank cards and stored credit the Arduino IDE is quite easy. Such Despite being based on NFC tech-
public transport cards use NFC technol- tags can also be read back using the nology, the shield from the 2019 arti-
ogy. You might also hear them referred microcontroller too. cle (which uses a PN532 NFC control-
to as RFID or contactless cards. These custom tags can contain, for ler IC) will not work with these tags
NFC protocols allow communi- example, a vCard file. That format as they use different versions of the
cation over distances up to around encapsulates the sort of information NFC standard. The PN532 can work
5cm using antennas transmitting typically found on a business card. A with tags that comply with ISO14443A
and receiving at 13.56MHz. The NFC programmed tag thus behaves like a (type 2, 3 or 4 tags), while the tags
Forum is responsible for standardising virtual business card and can be ‘taken’ we are using comply with ISO15693
NFC technology. by simply reading it with an appro- (type 5 tags).
RFID is a broader term technol- priate NFC reader, such as a mobile One of the great advantages of NFC
ogy that includes NFC, also having phone. The phone can import those is that the tag does not need its own
systems that operate at 125kHz and contact details into an address book. power source. The reader creates an
around 900MHz. URIs (uniform resource identifi- RF field at 13.56MHz that is picked
It’s now possible to create your own ers) such as web addresses can also up by the tag; it harvests energy from
‘dynamic’ NFC tags using a handful of be written to a tag (a URI is a more that to power its internal circuitry.
components. ‘Dynamic’ means the tag’s general form of a URL, also known Since the tag does not need a battery,
contents can be easily reprogrammed. as a link). Customers can be directed it can be tiny. Tags the size of coins
While you might be familiar with to a website by tapping their mobile are commonplace, and smaller tags
how easily NFC allows money to phone instead of manually entering a are possible.
leave your bank account, NFC tags web address, similar to how QR codes As shown in Fig.1, the coils in the
can also allow small amounts of data are often used. reader and tag effectively form an air-
to be stored and transferred. With cored transformer, which limits the
many mobile smartphones having NFC NFC technology practical communications range.
chips, we’ll look at some apps that can Jim Rowe covered an Arduino shield Data is transferred when either the
work with NFC tags, including read- that uses NFC technology in an arti- reader or the tag modulates the RF
ing and writing. cle from September 2019. That article field. The reader can do this easily,
Terminology
A reader is a device that generates an
RF field and can use this to commu-
nicate. You might also hear the term
emitter used, since this device emits more NDEF records. An NDEF record The specific chips we are using are
the RF field. is roughly analogous to the contents of the ST25DV04K, and they have 512
‘Tags’ are simply devices that can a single file, although the NDEF mes- bytes of EEPROM space (with maybe
communicate with an NFC reader. sage doesn’t have a file system as such. a dozen bytes taken up by the NDEF
They are typically implemented by While NDEF does allow multiple headers). Data such as that found in
combining a tag-capable chip (which messages and records on a tag, for brief text files is an excellent candidate
contains some non-volatile memory) simplicity, our software only writes for being passed around, including the
with an appropriate antenna and per- one message containing one record vCards mentioned earlier.
haps a few passive components. at a time, although it can read mul- Similar chips from the same family
The antenna is often little more than tiple records. can hold up to 8kB, which will also
a printed foil loop, similar to a PCB work with all the software we will dis-
trace antenna, but on a thinner sub- The ST25DV IC cuss, but we haven’t concentrated on
strate. We tried a few variations on cus- Dynamic tags are those tags that them mainly because of how long it
tom antennas that we’ll describe later. can be easily reprogrammed. In this takes to transfer that much data over
Some tags have an internal EEPROM, project, we will use members of the an NFC link.
including the chips we are using, in ST25DV family from ST Microelec-
which case the reader might be able to tronics. These parts include the RF Possible uses
write to the tag and change its contents. interface needed to implement NFC, Some people will find it convenient to
Portable tags are commonly found in an EEPROM and an I2C interface that program tags once and then use them
the form of a card or a keyfob that can allows their internal EEPROM to be as smart business cards or to pass other
be easily carried around. You might modified and thus present changing information around.
also see fixed tags, often in a more data to an NFC reader. For example, you might provide a
robust enclosure to prevent damage. Many tags, including those from the tag to allow guests to connect to your
The NDEF (NFC Data Exchange For- ST25DV family, can also be written Wi-Fi network when they visit. You
mat) specifies headers and other data over the RF interface, provided that could attach a tag to an object contain-
that indicate what sort of data the tag the ‘reader’ also has write capabilities, ing text information about that object.
carries; these are the sort of tags this as many do. One of the apps we tried You might have heard of ‘smart post-
project allows. NDEF tags are only a (from ST Microelectronics) can write ers’ being used in advertising. These
subset of NFC, and other types of NFC to these chips. are nothing more than printed posters
tags exist. You don’t necessarily need to use accompanied by a tag that provides
The software we have written the I2C interface to work with these information beyond what is printed
allows you to explore NDEF data at a chips, but it is an easy way to do so. on the poster.
low level. Briefly, there is a Capabil- In fact, many readers (especially One use we have seen ‘in the wild’ is
ity Container (CC), which indicates those on mobile phones) can also a tag at a bus stop. The tag is enclosed
that the tag contains NDEF data and emulate tags; this is the basis of how in a sturdy plastic shell and attached to
the amount of available storage space. ‘pay by phone’ technology works. The the post that holds up a printed time-
This, in turn, points to an NDEF phone emulates a virtual contactless table (see photo). This is a simple but
message, which can contain one or credit card. practical application.
This tag contains a URI NDEF mes-
sage that points to a web page provid-
ing live bus departure times for that
specific stop, supplementing the fixed
information on the printed timetable.
Screen 1 shows a scan of this tag by
one of the apps we will discuss later.
It also uses a chip from ST Microelec-
tronics (but a different one).
We have written an Arduino pro-
gram that can add several types of
records to these cards. As well as the
Fig.1: with NFC, an unpowered device (the tag) is powered by the received RF vCards and URIs mentioned earlier, it
field and can transmit data back to a reader or emitter by modulating that field. can also create simple text file records
nominal 4.7μH inductance, as well as Tack one lead of each component should be initially secured by one
the wirewound inductor seen in the and ensure the remaining leads are lead. Use tweezers to locate the part
previous photo. We also tried a tiny within their respective pads. Then before tacking, after which the remain-
(M2012/0805) SMD inductor, shown solder the remaining leads and ing leads can be soldered.
in the upper right corner, but the reader refresh the first leads. Check for sol- You might need to build up a small
did not pick it up. der bridges and use solder-wicking fillet of solder to ensure a mechanically
This correlation between size and braid to remove them. sound connection. Inspect the joints
sensitivity also extended to the larger The larger PCB (coded 06101232) is and use flux and solder-wicking braid
tags, with the larger PCB design designed to have the components sit as necessary to tweak the location and
being the most sensitive. We judged inside slots so that they are no thicker amount of solder.
this simply on the distance from than the PCB itself. We used a sili- For IC1, first tack the leads along
which the tag could be detected by cone soldering mat to align the com- one edge. Then flip the PCB over and
the reader, being nearly 5cm for the ponents vertically within the slots. gently bend out the IC leads along
larger PCB design. Rather than resting on surface pads, the other edge to be closer to the PCB
Another reason the smaller SMD the parts are soldered to exposed edges pads. Solder these leads to their cor-
inductor didn’t work, besides its size, of the plated-through holes. The pho- responding pads.
might be that it has a shielded con- tos above show the final result. We found that the best results came
struction. Larger shielded inductors IC1 is very close to the same thick- from using a generous amount of sol-
are also available; avoid using them, ness as the PCB (1.6mm), while the der and flux. We then applied solder
as they will not work well as antennas. passives are much thinner. This is an braid to the PCB pads only to draw off
If you build a Tag without the I2C experimental technique, so it is best excess solder, relying on surface ten-
interface, you won’t be able to use the suited to constructors with some SMD sion to keep a suitable amount of sol-
Arduino Programming Rig that we soldering experience. der connecting the lead.
will describe later. You will only be Before soldering the components, If you like, a pin header can be sol-
able to program the Tags using apps check the pads for copper swarf or dered to CON1 on either PCB, but if
installed on a mobile phone or a sim- burrs, as some may be left from the you only intend to program the tag
ilar reader. milling process during PCB manufac- once, simply holding the header in
ture. We found it wasn’t necessary to place should be sufficient. We’ve off-
PCB designs remove any burrs unless they could set the holes slightly to give a firm
The two Tag PCBs are shown in Fig.3 cause a short circuit or interfere with friction fit.
and Fig.4 and the photos overleaf. The component placement. If you wish to add some polish to
smaller PCB is coded 06101231 and The technique is similar to regular your Tag PCBs, you could glue paper
measures 22 × 31mm, while the larger SMD work in that each component or cardboard (such as your own paper
PCB is coded 06101232 and measures
85.5 × 54mm – both are available from
the PE PCB Service.
The usual SMD tools and supplies
will be adequate for building the PCB-
based tags. This includes solder, flux
paste, tweezers, good lighting and a
fine-tipped iron. Fume extraction is
recommended when working with
flux paste due to the amount of smoke
it generates.
For the smaller PCB (06101231),
assembly is straightforward. Apply
flux to the pads of the four SMD com-
ponents and rest each in place. IC1 is
the only polarised part, so check that
the chamfer along one edge (best seen Fig.3 and Fig.4: assembling the smaller PCB is pretty straightforward. The larger
from the end of the chip) aligns with PCB is a little trickier as the components are nestled into cutouts. Still, if you’ve
the marking on the PCB. done any SMD soldering, you should be able to use similar techniques to do that.
business card) to the front and back of If you want to program tags beyond Fig.5 shows the connections needed.
the PCB. You could even get custom what our sketch can do or tweak the The simplest way to achieve this is to
stickers of the right size made. sketch, you will need the SparkFun solder a four-way pin header to the
ST25DV64KC library in addition to Pico, allowing the Tag to be friction
The programming jig the Arduino IDE. This will also work fitted. However, you could use a bread-
Our programming jig is simple and just with other chips, including the -04K, board or even solder wires if you like.
requires a Raspberry Pi Pico (or Pico -16K, -64K, -04KC and -16KC variants. The RF and I2C interfaces can coex-
W) with four connections to CON1 on We’ve included a copy of the version ist, but note that communication can-
the Tag PCB. We used the Arduino IDE we used in the software download. not occur on both simultaneously.
to write the program, as a good Ardu- It can also be found by searching for So you can leave the Tag connected
ino library is available to work with ‘st25dv’ in the Arduino Library Man- to the programming jig while testing
these chips. ager. As well as the SparkFun library, the Tag with a reader, as long as you
If you want to modify or work with this will show a library from ST Micro- don’t attempt to read or write at the
our code and don’t have the Arduino electronics, but that one appears to be same time.
IDE installed, download and install designed to work with Arduino boards To control the programming jig
it from: www.arduino.cc/en/software based on their (STM) microcontrollers from your computer, you will also
Still, you don’t need the Arduino IDE and not the Pico. need a serial terminal program, such
to try our sketch out. Simply hold down We’ve designed the interface to as TeraTerm on Windows or minicom
the white BOOTSEL button on the Rasp- use four adjacent pins on the Pico. on Linux. The Arduino IDE’s serial
berry Pi Pico while plugging it into a com- These correspond to the four I2C pins monitor has limited functionality and
puter. Then copy the 0610123A.UF2 file on CON1 of either PCB. Pin GP28 is will work for some commands, but
to the drive that appears; it’s typically driven high as an output to provide not all. Verify that your serial termi-
named ‘RPI-RP2’. The file is available 3.3V. Next to it is a ground pin fol- nal program uses CR or CR/LF as the
from the July 2024 page of the PE website: lowed by pins GP27 and GP26 to pro- line ending. The program checks for
https://bit.ly/pe-downloads vide I2C SDA and SCL, respectively. CR and ignores LF.
Conclusion
NFC tags are common
these days, and we think
many readers will relish
the opportunity to create
their own smart business
cards and custom Tags.
We are investigating
other ways to use these Screen 6: the ST25 NFC Tap app can
Tags. One idea is to use create various NDEF record types, as
them to configure proj- shown here. There is also a tab allowing
ects wirelessly without the EEPROM to be directly edited.
needing screens, displays In such a project, the Tag circuit
or buttons to be built into described here becomes part of the proj-
the project. That could ect, with IC1 accessed over an I2C bus.
save quite a bit of time The project can read (or write) its con-
and money. figuration to a text NDEF record on the
Tag, which a suitably equipped smart-
phone or tablet can then view or edit.
There are undoubtedly other excel-
lent applications for these Dynamic
Tags, and we look forward to thinking of
new ways to use them in future projects.
Screen 7: the NXP TagInfo app can read tags and
also decode NDEF messages and records. There is Reproduced by arrangement with
also an NXP TagWriter app that we have not tried. It SILICON CHIP magazine 2024.
could possibly be used to customise Tags too. www.siliconchip.com.au
Reciprocal
Frequency Counter
I
bought a frequency counter over precisely one cycle. Also, as the sig- accurately and quickly using a micro-
30 years ago, but its accuracy is very nal frequency increases, the resolution phone amplifier and this device.
poor by today’s standards, being and accuracy decrease.
out by as much as 50Hz at 10MHz. I One good thing about this scheme Functional description
replaced its not-very- accurate clock is that the exact measurement time is Refer to the timing diagram, Fig.1,
module with a 10MHz TCXO, and I not critical, as the frequency calcula- which is not to scale. The input signal
can now rely on it to be within 1Hz tion is ratiometric. This means that we is fed into the clock input of a D-type
at 10MHz. By adjusting the TCXO fre- should get reasonably accurate results flip flop (74HC74). While the D input
quency to match that of my GPS-dis- as long as we have a clock source with (GATE TIME) remains low, the Q out-
ciplined 10MHz frequency standard, I an accurate frequency and synchronise put remains low, and the counters
can be assured of such accuracy. the measurement period to the rising are inhibited. We start the counting
But what happens when I want to edges of the input signal pulse train. period by applying a logic one (high
measure low frequencies? For exam- What do we need to measure with level) to the D input. On the next ris-
ple, a 50Hz signal. With a gate time of such precision? Mains frequency was ing edge of the input signal, the Q out-
one second, it will most likely show a the first thing I tried. I connected the put (COUNTEN) will go high after the
reading of 50, even if it is not exactly output of a 6V AC mains transformer short propagation delay.
that. It might flip to 49 or 51, but the to an RC network to reduce the volt- Two NAND gates are turned on as
resolution is only 1Hz. age and filter out noise. a result. The reference clock (REF
To improve that, we could have a The frequency did vary slightly COUNT) is then applied to 32-bit
gate time of 10 seconds and a reso- from reading to reading, and the larg- counter IC5, and the input signal,
lution of 0.1Hz. For a 10mHz resolu- est variation was about 30mHz. This is INPUT COUNT, is applied to the other
tion, a 100-second gate time would be within the required Australian Energy 32-bit counter, IC8.
required, which is quite ridiculous. Market Operator (AEMO) specification After one second, the D input of the
A better way to measure low fre- of 49.85-50.15Hz. The frequency vari- 74HC74 is taken low. The Q output
quencies is to measure the period. ation is caused by constantly changing remains high until the next positive
With the same example of 50Hz, using load conditions on the network. edge of the input signal, when it will
a 10MHz clock, it would accumulate Also, musical instruments need to go low. This stops the accumulation
200,000 pulses in one 20ms period. If be tuned to very precise frequencies. In of counts in both the 32-bit counters.
the number of pulses measured were the equal-tempered scale, C4 (middle Importantly, we have an exact input
actually 199,900, that would mean that C) should be 261.63Hz. Concert pitch count as the period is synchronised
the frequency is 10,000,000 ÷ 199,900 A4 must be 440.00Hz. All other notes with the rising edges of the input signal.
= 50.025Hz. require the same precision, to two The reference counter is not syn-
That’s a great improvement in res- decimal places, and a trained ear can chronised the same way, so the count
olution, but highly dependent on the pick the slightest differences in pitch. could be out by one. With a 10MHz
accuracy of the hardware in measuring Such frequencies could be measured reference oscillator, this results in an
error of one part in 107. But, with a
30MHz reference, it reduces to 0.33
Features and Specifications parts in 107, which is insignificant.
We now have three parameters. The
► Operating frequency range: 10mHz-10MHz (maximum ~13.5MHz)
reference clock is a TCXO and so it is
► Input sensitivity: 100mV peak-to-peak (~35mV RMS for a sinewave) very accurate. IC5 will contain a num-
► Accuracy: typical error <0.001Hz up to 9.999MHz after calibration ber accumulated over the (approxi-
► Sampling time: 0.1s, 1s or 5s mate) one-second period, and this
► Reference oscillator: temperature-compensated crystal oscillator (TCXO) is the Reference Count, which will
► Power: three AA cells for about 24 hours of battery life be near the Reference Oscillator fre-
quency. The other counter, IC8, has
Accuracy
The primary factor that affects accu-
racy is how close the TCXO is to its
stated frequency. The second factor is
the precision of the mathematical cal-
culations, but with the use of 64-bit
floating point arithmetic, any errors
are minimal.
I used my 10MHz GPS-disciplined
oscillator as an input to a 14-bit
counter (74HC4060) and fed ten dif-
ferent divided frequencies into the
Reciprocal Frequency Counter. Table
1 shows the results with the 30MHz
TCXO straight out of the box with
no adjustment.
I then tuned the 25MHz TCXO to
within less than 1Hz, and the errors
were 1mHz or less for all of the fre-
quencies shown in Table 1.
The TCXOs I bought from Ali
Express suppliers have been very close
to the stated frequency, but it is possi-
ble to adjust them by peeling the label
off the TCXO, which gives access to a
trim capacitor. However, this is not for
the faint-hearted, as it is an extremely
fine adjustment, and unless you have
the equipment and patience, I don’t
recommend it.
You need a dual-trace oscilloscope
with one channel connected and
locked to a GPS-disciplined 10MHz
oscillator and the other to the TCXO
output. The latter will drift left or right,
and the trimmer should be adjusted
for minimum drift. If it takes five sec-
onds to drift one cycle, that’s an error
of 0.2Hz (1Hz ÷ 5).
Frequency limits
The maximum frequency of this
counter is partially limited by the op
amp used in the input amplifier. The
Fig.2: the entire Frequency Counter circuit. Signal conditioning is at ADA4891 has a gain bandwidth (GBW)
upper left; the counters are left of centre, the power supply is at lower left of 220MHz and a slew rate of 170V/µs
and the microcontroller and display are on the right. The micro decides (it was also chosen for its high input
when to start and stop counting and when to reset the counters. It is impedance and GBW). This limits the
responsible for reading the counter values, computing the frequency and maximum usable frequency to about
displaying it on the OLED screen. 15MHz; however, readings above
10MHz tend to become rather erratic.
Fig.3: most parts are SMDs that mount on the top side of the board, but there are a handful of through-hole parts plus
a few components on the back, notably the TCXO and Arduino Nano module. L1 can be either a through-hole type on
the front or a 4 × 4mm SMD inductor on the back. Watch the polarity of all the ICs, the regulator and the diodes.
Teach-In 8 CD-ROM EE
FR -ROM
CD
ELECTRONICS
£8.99
SERIES
FOR
THE TEACH-IN
8
This CD-ROM version of the exciting and popular Teach-In 8 series INTRODUCING THE ARDUINO
• Hardware – learn about components and circuits
has been designed for electronics enthusiasts who want to get to • Programming – powerful integrated development system
• Microcontrollers – understand control operations
SOFTWARE
The CD-ROM contains the software for both the Teach-In 8 and PICkit 3 series.
W
e are looking at various signal is commonly captured at
Sampling
topics related to digital signal the required sample times by a switch
processing (DSP). DSP covers sample-and-hold circuit (as shown Vin A1 A2 Vout
a wide range of electronics applications in Fig.1). The basic principle here Sampling
CS
where signals are manipulated, anal- is that for an ADC to perform a capacitor
Sampling CS
capacitor
Sampling and holding simulation Fig.6 shows a zoom in from Fig.5 on the first hold to
Fig.4 shows an LTspice circuit based on Fig.3. The sampling track transition. This shows that the output voltage does
capacitor is C1 and the input series resistance is R1. The not immediately equal the input voltage when the circuit
leakage current is modelled with the I1 current source, which enters track mode. The sampling capacitor has to charge (or
is configured for the ideal case (zero current) in Fig.4. The discharge) from the previous hold voltage to the current input
switch is close to ideal (on resistances much smaller than R1, voltage. The time taken depends on the RC time constant
off resistance very large at 10MΩ). The switch is controlled and the amount of voltage change, and is referred to as the
by the 1V SamplePulse waveform from V3 (the switch sample-and-hold’s ‘acquisition time’. After acquisition the
threshold is 0.5V). This is simply a square wave which will output will follow the input unless the input changes too
put the circuit alternately into track and hold modes. The fast for the voltage on the capacitor to follow (again related
circuit values, signals and timing in the circuit in Fig.4 are to the time constant).
to illustrate the principle of operation and are not related to Fig.7 shows the effect of leakage current. This uses the
any particular ADC or sampling system. circuit in Fig.4 with the leakage current source I1 set to
The results from the simulation in Fig.4 are shown in Fig.5. 1µA. Leakage current can flow via the sampling switch (non-
The sampling waveform (cyan trace) has been scaled and infinite off resistance), into the next circuit stage (A2 in Fig.3)
shifted with a formula for convenience of showing alongside or via the capacitor’s imperfect dielectric insulation. Leakage
the signals and labelled with the track and hold conditions. results in a progressive change (droop) in the held voltage,
The input waveform (green trace) is the sum of the two as can be seen by comparing the waveforms in Fig.5 and
sinewaves from V1 and V2. The output waveform (red trace) Fig.7. Droop rate is the rate at which voltage on the sample
can be seen to follow the input when the circuity is in track capacitor changes during the hold interval. It is determined
mode. The output is constant during the hold periods, with by IL/CS where IL is the leakage current, and CS is the sampling
a value equal to the input at the start of the hold period. In capacitance. Note that a constant leakage current results in a
a DSP system the ADC would perform conversions on the linear voltage change on the capacitor unlike the nonlinear
held signal. change when charging through a resistor.
Fig.5.
Waveforms
from the
LTspice
circuit in
Fig.4 (I1 is
zero).
Fig.7.
Waveforms
from the 𝑉𝑉&'()* 𝑑𝑑𝑉𝑉'( 𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟
𝑡𝑡 = 𝑅𝑅𝑅𝑅 ln * , 𝑡𝑡 <
LTspice 𝑉𝑉'('+')* 𝑑𝑑𝑑𝑑 - 2%
circuit in
Fig.4 (I1 is
1µA).
𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟 2𝐴𝐴
𝐿𝐿𝐿𝐿𝐿𝐿 = 2𝐴𝐴𝐴𝐴𝐴𝐴𝑡𝑡- <
2% 2%
𝑑𝑑𝑣𝑣'( 1
𝑡𝑡, ≤ 𝐿𝐿𝐿𝐿𝐿𝐿 𝑡𝑡- <
𝑑𝑑𝑑𝑑 2% 𝜋𝜋𝜋𝜋
𝑑𝑑𝑣𝑣
Practical
'( Electronics | July | 2024 39
= 2𝜋𝜋𝜋𝜋𝜋𝜋 𝑐𝑐𝑐𝑐𝑐𝑐( 2𝜋𝜋𝜋𝜋𝜋𝜋)
𝑑𝑑𝑑𝑑
ADC input ADC input
voltage voltage
ΔV ΔV
Δt Δt
V2 V2
Sample
held Input level
reacquired
V1 V1
tC tC
Conversion Conversion
time time
𝑑𝑑𝑉𝑉'( 𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟
𝑡𝑡 <
𝑑𝑑𝑑𝑑 - 2%
2𝐴𝐴
2𝐴𝐴𝐴𝐴𝐴𝐴𝑡𝑡- <
2%
Fig.14.
Results
from circuit
in Fig.12
with R1
changed to
10kΩ.
OUT
L R
By Jake Rothman
Switching in audio equipment – Part 2
T
his month, we carry on from The Rotary Club Phono socket
where we left off in June and finish Rotary switches, sometimes
our look at the many varied types called wafer switches (Fig.21), Aux
of mechanical audio switches. are the most versatile, but
often require a lot of costly
hand-wiring; although this is FM tuner
not really a problem for home
constructors and prototypes.
The old Paxolin wafer types
have an open construction CD player
Volume
which means they easily get
dirty but are also very easy 10kΩ Left
output
to clean. It is even possible Cassette deck log
to power
0V amplifier
to buy kits, such as the RS
Maka-Switch to assemble
your own specialised multi-
wafer switches. (These
Fig.21. Rotary wafer switches have been are popular among older
around since the swinging 1920s. They engineers who played with
have very long life, are easy to service Meccano as kids!) 0V
to a quiet radio signal (say, classical a high frequency, say 20kHz, and can T Giesberts Mini-preamplifier (Elektor,
music on BBC Radio 3), and having be in the order of −70dB, improving to February 1994).
inadvertently left the CD player going, −120dB in the best cases. To prevent crosstalk there are several
one can hear a faint frequency from By screening the cables and using other effective techniques. Rotary
the CD player in the background. (Hi buffers with a low output impedance switches sometimes include a metal
hat cymbals seem to bleed through the crosstalk can be greatly reduced, as screen between the two sections, as
especially well.) This inadvertent shown in Fig.26. Another popular dodge shown in Fig.28. On PCBs it is always
coupling is due to the capacitance is to put a rotary switch on the back panel worth putting earthed guard tracks
between the contacts and cables. It gets next to the input sockets. This switch is between the input lines going to the
worse if the source impedance of the then mechanically coupled to the knob at switch, along with a ground plane to
selected source is high – in the case of the front using an extension spindle and mimic screened cables. Another trick is
some FM tuners and valve pre-amps brackets – see Fig. 27. This approach also to ground the unused sources. Care has to
this may be up to 10kΩ. The capacitance minimises hum and noise and is popular be taken to ensure this does not cause any
effectively makes a high-pass filter in expensive integrated (combined damage to the source though. Normally
with this resistance, so if it is high pre- and power) amplifiers. It requires a series resistor of around 600Ω prevents
the coupling frequency is lower hence care with mounting to the front panel excessive current. However, there
the hi hat being especially noticeable. bushing to prevent play and a floppy can still be the problem of preventing
Crosstalk is specified in the same way as feel. I use a viscous damping grease such current going to ground which can
signal-to-noise ratio, in decibels (−dB) as Kilopoise and a felt washer under the cause resistive crosstalk. This can be
below the signal. This figure is given at knob. Shaft extensions were used in alleviated by connecting the ground to a
low impedance point, such as the power
Zero output
impedance amplifier
supply. In the days of the Maka-Switch
Input 2 one could buy a ‘rotating open-circuit’
*Reduces distortion wafer, as shown in Fig.29. By linking
from output capacitors across to an adjacent normal wafer, all
10kΩ* 0V
the unused sources were automatically
grounded. It’s also possible to do the
220kΩ
Input 3
+
NE5534 Parasitic
220nF 0V capacitance
2x back-to-back 3.3kΩ
220kΩ tantalum capacitors
creates a bipolar device
Zero output
impedance amplifier
Input 4
Screened cable
shield connected
Fig.28. An earthed metal screening
0V at only one end plate can be placed between two switch
sections to reduce coupling. Useful for
Fig.26. Feeding switches from low impedance sources, such as zero-output preventing crosstalk between left and
impedance buffers, reduces crosstalk between switching elements and cables. right channels.
same thing with interlocking push Post Office/BBC switches medium-scale production I outsource
buttons, as in Douglas Self’s preamplifier I mention these because they often the front panels and then the rectangular
(Wireless World, September 1996). turn up in old BBC equipment, and switches just clip in. (Getting them out
are sometimes called ‘lever switches’. again for replacement/maintenance
Multiple push buttons They are very reliable, achieving a though is another matter!)
An alternative to the rotary switch is million operations. They have an open
an interlocking push button, where construction with easy-to-clean multi- Soldering meltdown
only one button can be on (in) while contacts, as shown in Fig.33. They Some cheap switches use thermoplastic
the others are always off (sticking also make no mechanical noise, but on cases rather than the old Bakelite
out) as illustrated in Fig.30. These the downside they are expensive, and thermosetting material. Take care with
are often easier to operate and offer mounting them is awkward. They need these when soldering. If the wire is
the possibility of clearer labelling. a rectangular hole and two screw holes pulled while it is still hot, the tag/contact
They were popularised by German with precise relative dimensions.
industrial designers such as Dieter
Rams of Braun with his 1959 SK4 Funny shapes, odd holes
radiogram. Indeed, they are replicated For small-scale constructors, switches
on computers screens today in graphical that are fastened with a nut in a round
user interface (GUI) software as ‘radio hole are the most convenient, such
buttons’. Mechanical interlocking has a as toggle and rotary types. They also
sliding bar interlinking all the switches allow the front panel to be completely
(see Fig.31). Such assemblies are prone sealed, unlike rows of interlocking
to go wrong and it’s often impossible push buttons. In general, I try to avoid
to get a replacement. There was one switches that require rectangular holes
design of button that incorporated a which either need an expensive cut-
black ‘eyelid’ which opened to reveal out punch or fiddly, time-consuming
a florescent orange disc when pressed – sawing and filing. This precludes a lot
see Fig.32. Most designers today would of rocker and some push switches – the
go for an electronic interlocking system kind shown in Fig.34. I have even had Fig.34. These lovely LED illuminated
with LEDs which, unlike the ‘eyelid’, 3D-printed adaptor plates made for some Japanese push buttons require a difficult-
requires power. push buttons – see Fig.35. Of course, for to-cut hole.
Fig.32. An interesting push button by Fig.33. Old-fashioned Post Office Fig.35. A square switch in a round hole.
Schadow that uses internal ‘eyelids’ to switches used by the BBC were very An adaptor plate for the switch type
reveal a fluorescent ‘on’ indicator when reliable and you could get them in almost shown in Fig.34. A 3D print designed by
the actuator is pressed. any combination. my friend, Jeremy Paine.
Fig.46. I had to drill another hole at the back (switch sixth from Fig.47. The Allan Bradley (now Clarostat/Honeywell) Mod
left) to access the Veropin to push it down after inserting the Pot series enabled complex potentiometer and switch
slider into the switch casing. No way was I going to unsolder 78 combinations to be made up for custom designs. (These are
pins to get this switch assembly out. the black square devices).
Next month
My overview of audio mechanical
switches went on longer than expected,
but next month we really will move on
to the topic of audio electronic switching.
Practical
Electronics BACK ISSUES
Practical Practical Practical Practical Practical Practical Practical
Electronics Electronics Electronics Electronics Electronics Electronics Electronics
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
The UK’s premier electronics and computing maker magazine
The UK’s premier electronics and computing maker magazine
Circuit Surgery Audio Out Make it with Micromite
Circuit Surgery Audio Out KickStart Make it with Micromite
Circuit Surgery Audio Out Cool Beans Make it with Micromite
Circuit Surgery Audio Out Wind turbine Electronic Building Blocks
Circuit Surgery Audio Out Make it with Micromite
Circuit Surgery Audio Out Make it with Micromite
Circuit Surgery KickStart Make it with Micromite
Exploring op amp PE Analogue Vocoder: Using and interfacing the
Exploring op amp Vocoder: Driver Using the Using and interfacing
Exploring
the the Vocoder: Mastering switch Build an iButton-based
Exploring the Vocoder final Small-scale Building a budget Distortion and Designing a practical Code for an iButton-based
Simulating distortion Using transformers in Installing MMBASIC on
Using
a distortion and Exploring DACs and MMBASIC + RPi Pico + display
exponential amplifiers Driver Amplifier design versatile iButton input offsets Amplifier build I2C bus versatile iButton LM35 temp sensor Audio PSU debounce Electronic Door Lock
Royer oscillator assembly garden set-up electronic stethoscope
distortion circuits de-thump circuit Electronic Door Lockand distortion circuits audio electronics Raspberry Pi Pico distortion circuits microcontrollers = PicoMite Backpack!
Electronic WLR089
Battery Balancer WIN! Unit Development Kit High-current
Curiosity Ultra
Digital Radio Receiver Controlling a
Unit
Development
Flowcode
{ if (intcon & 4)
Xplained Pro
power supply
{
Assembly
Board
Wind Chimes Microchip
clear_bit(intcon, 2);
MPLAB ICD 4
Digital Clock
bsf STATUS, RP0
WIN! WIN!
bcf STATUS, RP1
movwf _adcon1
Hex
In-Circuit
Flowcode
movlw D′192′ :040000008A01122837
movwf _option_reg :08000800F000F00S030
Debugger
Design
EF10000 Flowcode
:10001000040EF2000A0
Simple
EF300BA110A122928352
WIN
Programming
86C Flowcode
:2000200D928FE28073 Flowcode C
void interrupt(void)
Learn
FCM_INTERRUPT_TMR movlw D′7′ { if (intcon & 4)
void interrupt(void) o(); {
bsf STATUS, RP0 Assembly
Music
{ if (intcon & 4)
192kHz, 24-bit
clear_bit(intcon, 2);
Assembly movwf _adcon1 FCM_INTERRUPT_TMR movlw D′7′
movlw D′192′ o(); bsf STATUS, RP0
FCM_INTERRUPT_TMR :040000008A01122837
Flowcode
movlw D′7′ movwf _option_reg bcf STATUS, RP1
o(); bsf STATUS, RP0
:08000800F000F00S030
movwf _adcon1
Hex
EF10000
Keyboard
bcf STATUS, RP1
Learn
EF300BA110A122928352 :08000800F000F00S030
movlw D′192′ :040000008A01122837 86C EF10000
Vintage Battery
movwf _option_reg
Programming:
:08000800F000F00S030 :2000200D928FE28073 :10001000040EF2000A0
EF10000 EF300BA110A122928352
SuperCodec:
:10001000040EF2000A0
Flowcode
86C
Radio Li-ion
:2000200D928FE28073
Balanced Input PIC, Arduino and 16x2 LCD Speed Controller lights and bell! Advanced GPS Computer:
Power Supply Programming
and Attenuator Battery Monitor Logger Advanced GPS Computer construction and use
PLUS! PLUS! PLUS! PLUS! PLUS! PLUS!
Jan 2022 £5.49 Feb 2022 £5.49 Apr 2022 £5.49 May 2022 £5.49 Jun 2022 £5.49 Jul 2022 £5.49 Aug 2022 £5.49
Techno Talk – Communing with nature PLUS!
01
Techno Talk – Go eco, get ethical!
02 Techno
04 Talk – From nano to bio Techno
05 Talk – Positivity follows gloom Techno
06 Talk – Mixed Menu Techno
07 Talk – Time for a total rethink? 08
Fox Report – Power as free as the wind Techno Talk – Should we be worried? Fox Report – Another fine mess: moving to Windows 11 Cool Beans – Simple filtering with software Cool Beans – Amazing Analogue AI and a handy PSU Cool Beans – Choosing servos and a little competition Cool Beans – Touch-sensitive robots and using servos
Net Work –EVs, upgrading to Windows 11 and space tech 9 772632 573023
Net Work – Electricity generation and streaming radio Net Work – Scanners, eVTOLs and the latest from space
9 772632 573023
Net Work – UK gigafactories, Rolls-Royce electric planes
9 772632 573023
Net Work – Google Lens plus energy and space news
9 772632 573023
Net Work – NFC and the rise of mobile payments
9 772632 573023
Net Work – The irresistible rise of automotive electronics
9 772632 573023 9 772632 573023
D
o you know what you were
doing at 5:16:20 pm on Satur-
day, 23 November 1963? I do. (a) Flat cut (b) Bevel cut
I was six years old, and I was stand-
Fig.2. A cut above the rest.
ing bravely (cowering) behind the sofa
with my teddy bear captivated by the As I’ve mentioned before, whenever I
(a) Without insulating tape
sound of the electronic opening music return to England to visit my dear old mom,
accompanying the very first episode of on the Friday before I return to America,
the British science fiction television a gaggle of my techno-geek friends flock
series, Doctor Who. I’ve been a devoted from across the country. We all meet at the
fan ever since. Why did this just pop house of my brother, Andrew, where we
into (what I laughingly refer to as) my spend a happy day and evening showing
(b) With insulating tape
mind? Well… off our latest and greatest creations and
telling tall tales of derring-do. Why do I
Fig.3. The old insulating tape trick.
A gaggle of techno-geeks mention this here? Well…
There is no official collective noun for because (a) they slide in more easily and
a group of engineers, but two terms I Electronic component art (b) square ends have the potential to
favour are ‘a sprocket of engineers’ and One of the guys who attends our geeky damage the breadboard’s sockets. I tell
‘a rube of engineers,’ where the latter gatherings is Paul Parry, who is the you; I learn something new every day!
derives from the American cartoonist, founder and owner of Bad Dog Designs
sculptor, author, engineer and inventor, (https://bit.ly/3QsB8kw). Over the Seeing red
Reuben Garrett Lucius Goldberg (a.k.a. past decade, Paul has captivated and Joe also taught me another tidbit of
Rube Goldberg). Rube is best known for cultivated a worldwide following for trivia. He says he usually covers the
his cartoon depictions of complicated his Nixie-tube-based timepieces. front of his red light-emitting diode
gadgets performing simple tasks in More recently, Paul has started a new (LED) 7-segment displays with a piece
indirect and convoluted ways. line in electronic component-based of red insulating tape.
artworks (https://bit.ly/4dryK7t). I love I must admit to being surprised. ‘I’m
all these creations, but the one that really surprised,’ I said (so it must be true).
caught my eye was that of Doctor Who’s I told Joe I’d assumed insulating tape
TARDIS (Fig.1). I have one on order for was opaque. He replied that although
when I visit the UK this summer. the tape does dim the displays a little,
Meanwhile, back in America, I meet it also makes the active segments ‘pop.’
up with a group of friends on Tuesday I just tried this myself and I see what Joe
evenings. We have a light supper and means. I’ve tried to replicate this effect in
then watch two episodes of Doctor Who Fig.3 (only partially successfully, I fear).
(we started with the 2005 reboot starring The situation without insulating tape is
Christopher Eccleston). These guys are shown in Fig.3a. In this case, the active
going to be blown away when I flaunt segments are a little brighter, but the
my new acquisition. inactive segments still manage to stand
out. By comparison, when the insulating
A handy-dandy tip tape is applied as depicted in Fig.3b,
In my previous column (PE, June even though the active segments are a tad
2024), I remarked on how my friend dimmer, the inactive segments become
Joe Farr has a vast amount of practical almost invisible, thereby making their
knowledge. I also commented on the kits active counterparts more prominent. Once
of pre-stripped, pre-formed, solid core again, I learn something new every day!
jumper wires you can find on Amazon
(https://bit.ly/3vDs2KK). Resistance is futile!
While we were chatting about ‘this Toward the end of my previous column, I
and that,’ Joe dropped a little nugget showed a picture of my own breadboard
of knowledge into the conversation. He setup with four multiplexed 7-segment
noted that he always cuts his solid core displays presenting the hours and
Fig.1. Electronic component artwork for the jumper wires at a 45° angle if he’s using minutes in HH:MM format. At that time,
Doctor Who TARDIS (Source: Paul Parry). them with breadboards (Fig.2). This is I directed your attention to a rinky-dinky
13 12 11 10 9 8 7 6 5 4 3 2 Turn All Segments Off → Set 2:4 Inputs to 00 → Set New Segment Value → Wait 2ms
Turn All Segments Off → Set 2:4 Inputs to 01 → Set New Segment Value → Wait 2ms
(e)
Arduino pin numbers Turn All Segments Off → Set 2:4 Inputs to 10 → Set New Segment Value → Wait 2ms
Turn All Segments Off → Set 2:4 Inputs to 11 → Set New Segment Value → Wait 2ms
:
Fig.7. Current circuit with four 7-segment displays. Fig.9. Alternative control scenarios.
mentioned in this column are available In a crunchy nutshell, the question code in that only one of the four outputs
from the July 2024 page of the PE website: posed by James the inquisitor can be is ‘hot’ (active) at any time.
https://bit.ly/pe-downloads summarised as follows: ‘Why don’t we Based on the functional specification
use a 2:4 decoder to drive the transistors, we just established for our 2:4 decoder,
Why don’t we… thereby freeing up two of the Arduino’s we can create a truth table (Fig.8a),
I received an interesting email from digital I/Os?’ a symbol (Fig.8b), and a gate-level
a reader we will call James (because That’s a good question. Remembering implementation (Fig.8c), where s stands
that’s his name). James had a question that I’m only ever an email away, I’m for ‘select’ and y stands for ‘output.’
regarding our current circuit (Fig.7). As surprised you haven’t presented this In this case, we are using two NOT
you will recall, in the present incarnation poser yourself. Using a 2:4 decoder (we (inverter) gates and four 2-input AND
of our clock, we are using eight of our read this as ‘two-to-four decoder’) is gates. You can find a quick refresher
Arduino’s digital input/output (I/O) pins certainly a possibility, although there are on the truth tables and functioning of
to drive the display segments, with all some considerations to… well, consider. NOT, AND, NAND and XOR gates in my
four displays connected in parallel (side- On the off chance this function is new to Cool Beans Blog on the C/C++ bitwise
by-side). Also, we are using four digital you, let’s start by considering what we operators (https://bit.ly/3UqT9B6). A
I/O pins to control the transistors we use mean by a 2:4 decoder in the first place. more in-depth discussion is provided in
to activate the displays. This means we The idea is to create a logic function my book Bebop to the Boolean Boogie
are using 12 digital I/Os in all. that has two inputs and four outputs. (https://bit.ly/4a6wDDm).
As we’ve previously noted, the The inputs, which we will drive using So, in the case of our current four-
Arduino Uno has only 14 digital I/O pins our Arduino, have 2 2 = 4 possible display clock, we now have a choice
(remember that we aren’t considering combinations: 00, 01, 10, and 11. between not using a 2:4 decoder and
the 6 analogue pins, which can also We want to use each of these input having no free digital I/Os or using a 2:4
be used as digital I/Os, because we combinations to select one of our four decoder and having two free digital I/Os.
are holding them in reserve for a later possible outputs, which we will use to As a slight aside, if we ever decide
date). Also, we aren’t using digital I/Os control the transistors that control our we want to drive anywhere from five to
0 and 1 because these are reserved for displays. Furthermore, in the case of our eight displays, the way we are currently
communications between the Arduino current circuit, we require ‘active high’ implementing things would leave us with
and the host computer. outputs, which means their active state no choice but to use a 3:8 decoder (three
So, the situation we find ourselves in is 1 and their inactive state is 0. This is inputs and eight outputs), which would
is (a) the Arduino Uno has 12 digital I/Os due to the way we have things wired, still leave us with one free digital I/O.
available to us and (b) we are using all whereby a 1 will turn the corresponding
of them to drive our four displays. This transistor on. Remember, we want only Seeing ghosts
means we don’t have any digital I/Os one transistor (and thus one display) to Remember that we are just spitballing
free to implement other functions, like be active at a time. ideas here. We aren’t really going to
driving our piezoelectric buzzer, for It may (or may not) be worth noting deploy a 2:4 decoder, but it’s well worth
example (we introduced this component that our hypothetical 2:4 decoder can be taking the time to cogitate and ruminate
in PE, December 2023). thought of as implementing a ‘one hot’ over the implications if we were to do so.
Your knee-jerk reaction might be that
using a 2:4 decoder as discussed above
s1 s0 y3 y2 y1 y0 s1
& y3 would be easy peasy lemon squeezy.
y3 s1
0 0 0 0 0 1
& y2 Hold hard! Not so fast! Remember
0 1 0 0 1 0 F rom s1 y2
that I said there were considerations
2:1 T o transistors s0
Arduino s0 y1 & y1
1 0 0 1 0 0
s0 to consider. Take a moment to think
y0
1 1 1 0 0 0 & y0 about (a) our gate-level implementation
(a) Truth table (b) Symbol (c) G ate-level implementation and (b) how we might use the Arduino
to drive the inputs to the decoder. Can
Fig.8. 2:4 decoder with active-high outputs (driving 4 displays). you envisage any potential problems?
3 3 3 3
(+5V ) (+5V ) (+5V ) (+5V )
C C C C
V CC V6ACC 6A
6Y 6Y
5A 5A
5Y 5Y
4A 4A
4Y 4Y V CC V4BCC 4B
4A 4A
4Y 4Y
3B 3B
3A 3A
3Y 3Y
B B B B
14 14
13 13
12 12
11 11
10 10
9 98 8 14 14
13 13
12 12
11 11
10 10
9 98 8
E E E E
y3 y2 y1 y0
& & & &
2:1
s1 s0
F ree 1 12 23 34 45 56 67 7 1 12 23 34 45 56 67 7
1A 1A
1Y 1Y
2A 2A
2Y 2Y
3A 3A
3Y G3Y
ND G ND 1A 1A
1B 1B
1Y 1Y
2A 2A
2B 2B
2Y G2Y
ND G ND
13 12 11 10 9 8 7 6 5 4 3 2
(0V ) (0V ) (0V ) (0V )
Arduino pin numbers
(a) SN7404
(a) SN7404 (b) SN7408
(b) SN7408
D3 D2 D1 D0 To displays
7408 7404
Listing 3a. Modifications to use 2:4 decoder. Fig.15. Wiring up the chips on the breadboard.
Fig.14, you wonder as to the rationale the outputs on our unused gates aren’t In some situations, we may be using
behind the way in which the designer connected to anything via wires, such a gate or a more complex function, but
selected which gates in which chips oscillations may result in noise in the not employing all its inputs. In such
were to be connected to which wires. form of electromagnetic interference cases (unless stated otherwise in the
Why did I use U2.3, U2.4, U2.1, and (EMI) that can affect other signals nearby. data sheet), it’s imperative that we apply
U2.2 to drive signals y0, y1, y2, and Happily, the chances of this being appropriate resistors to place these pins
y3, respectively, for example? a problem are extremely slight in our in appropriate states. If we are using
Oftentimes, the answer is more case, not least because of the SN74LSxx only two inputs to a 3-input AND gate,
pragmatic than you might expect – it technology we are using. On the other for example, we would use a pull-up
facilitates the physical layout in some hand, I’m trying to teach you good resistor on the unused input (a pull-
way. In this case, I wanted to be able practices, and it’s a good idea to get down would force the AND’s output to
to draw the wires associated with our into the habit of tying off unconnected
chips in such a way that they didn’t inputs, so that’s what we are going to do.
cross over, which would have made In a scenario where gates are totally
things harder for you to comprehend. unused, as in our example, it’s often up to
the designer to decide between attaching (+5V )
iDisp Binary This starts by using the >> bitwise shift right operator to shift
0 ≡ 00000000 the value from iDisp one bit to the right (again, this doesn’t
1 ≡ 00000001 modify the value stored in iDisp because we aren’t assigning
2 ≡ 00000010 anything to iDisp). The original least-significant bit ‘falls
3 ≡ 00000011 off the end’ and a 0 is shifted into the new most-significant
bit. What this means is that, following the >> operation, we
The math symbol ≡ means ‘equivalent to’ or ‘identical to.’ have the following intermediate value to play with:
We discussed how to use the bitwise operators as masks in a
previous Cool Beans (PE, March 2021). These are the techniques iDisp Binary after >> 1
we are using here. Consider the following portion of Line 95: 0 ≡ 00000000
1 ≡ 00000000
iDisp & B0000001 2 ≡ 00000001
3 ≡ 00000001
Since we are using a bitwise & (AND) operator, any 0s in our
Bxxxxxxxx value will return 0s in the corresponding positions When we subsequently perform the bitwise & (AND) operation,
in the result. By comparison, any 1s in our Bxxxxxxxx value we will see 00000000 (0) when iDisp is 0 or 1, and 00000001 (1)
will return whatever 0 or 1 value
is in the corresponding bit of Cool bean Max Maxfield (Hawaiian shirt, on the right) is emperor of all he
iDisp (note that this doesn’t surveys at CliveMaxfield.com – the go-to site for the latest and greatest
modify the contents of iDisp in technological geekdom.
because we aren’t assigning
Comments or questions? Email Max at: [email protected]
anything to iDisp).
STEWART OF READING
17A King Street, Mortimer, near Reading, RG7 3RS
Telephone: 0118 933 1111 Fax: 0118 933 2375
USED ELECTRONIC TEST EQUIPMENT
Check website www.stewart-of-reading.co.uk
Fluke/Philips PM3092 Oscilloscope HP 54600B Oscilloscope
(ALL PRICES PLUS CARRIAGE & VAT)
2+2 Channel 200MHz Delay TB, Analogue/Digital Dual Trace 100MHz
Autoset etc – £250 Please check availability before ordering or calling in
Only £75, with accessories £125
LAMBDA GENESYS PSU GEN100-15 100V 15A Boxed As New £400 Marconi 2305 Modulation Meter £250
LAMBDA GENESYS PSU GEN50-30 50V 30A £400 Marconi 2440 Counter 20GHz £295
IFR 2025 Signal Generator 9kHz – 2.51GHz Opt 04/11 £900 Marconi 2945/A/B Communications Test Set Various Options POA
IFR 2948B Communication Service Monitor Opts 03/25 Avionics POA Marconi 2955 Radio Communications Test Set £595
IFR 6843 Microwave Systems Analyser 10MHz – 20GHz POA Marconi 2955A Radio Communications Test Set £725
R&S APN62 Syn Function Generator 1Hz – 260kHz £295 Marconi 2955B Radio Communications Test Set £800
Agilent 8712ET RF Network Analyser 300kHz – 1300MHz POA Marconi 6200 Microwave Test Set £1,500
HP8903A/B Audio Analyser £750 – £950 Marconi 6200A Microwave Test Set 10MHz – 20GHz £1,950
HP8757D Scaler Network Analyser POA Marconi 6200B Microwave Test Set £2,300
HP3325A Synthesised Function Generator £195 Marconi 6960B Power Meter with 6910 sensor £295
HP3561A Dynamic Signal Analyser £650 Tektronix TDS3052B Oscilloscope 500MHz 2.5GS/s £1,250
HP6032A PSU 0-60V 0-50A 1000W £750 Tektronix TDS3032 Oscilloscope 300MHz 2.5GS/s £995
HP6622A PSU 0-20V 4A Twice or 0-50V 2A Twice £350 Tektronix TDS3012 Oscilloscope 2 Channel 100MHz 1.25GS/s £450
HP6624A PSU 4 Outputs £400 Tektronix 2430A Oscilloscope Dual Trace 150MHz 100MS/s £350
HP6632B PSU 0-20V 0-5A £195 Tektronix 2465B Oscilloscope 4 Channel 400MHz £600
HP6644A PSU 0-60V 3.5A £400 Farnell AP60/50 PSU 0-60V 0-50A 1kW Switch Mode £300
HP6654A PSU 0-60V 0-9A £500 Farnell XA35/2T PSU 0-35V 0-2A Twice Digital £75
HP8341A Synthesised Sweep Generator 10MHz – 20GHz £2,000 Farnell AP100-90 Power Supply 100V 90A £900
HP83630A Synthesised Sweeper 10MHz – 26.5 GHz POA Farnell LF1 Sine/Sq Oscillator 10Hz – 1MHz £45
HP83624A Synthesised Sweeper 2 – 20GHz POA Racal 1991 Counter/Timer 160MHz 9 Digit £150
HP8484A Power Sensor 0.01-18GHz 3nW-10µW £75 Racal 2101 Counter 20GHz LED £295
HP8560E Spectrum Analyser Synthesised 30Hz – 2.9GHz £1,750 Racal 9300 True RMS Millivoltmeter 5Hz – 20MHz etc £45
HP8563A Spectrum Analyser Synthesised 9kHz – 22GHz £2,250 Racal 9300B As 9300 £75
HP8566B Spectrum Analsyer 100Hz – 22GHz £1,200 Solartron 7150/PLUS 6½ Digit DMM True RMS IEEE £65/£75
HP8662A RF Generator 10kHz – 1280MHz £750 Solatron 1253 Gain Phase Analyser 1mHz – 20kHz £600
Marconi 2022E Synthesised AM/FM Signal Generator 10kHz – 1.01GHz £325 Solartron SI 1255 HF Frequency Response Analyser POA
Marconi 2024 Synthesised Signal Generator 9kHz – 2.4GHz £800 Tasakago TM035-2 PSU 0-35V 0-2A 2 Meters £30
Marconi 2030 Synthesised Signal Generator 10kHz – 1.35GHz £750 Thurlby PL320QMD PSU 0-30V 0-2A Twice £160 – £200
Marconi 2023A Signal Generator 9kHz – 1.2GHz £700 Thurlby TG210 Function Generator 0.002-2MHz TTL etc Kenwood Badged £65
I
n the previous part of our Teach-In series, we
introduced seven-segment and matrix LED displays. We About Teach-In
also introduced the SPI interface as a means of interfacing a Our latest Teach-In series is about using the popular ESP32
wide variety of peripheral devices. Coding Workshop showed module as a basis for learning electronics and coding. We
you how to generate and use random numbers and our Teach- will be making no assumptions about your coding ability
in Project featured the design, construction and coding of a or your previous experience of electronics. If you know one
but not the other, you have come to the right place. On
simple dice roller using a low-cost motion sensor as a trigger.
the other hand, if you happen to be a complete newbie
This month, we will introduce two more interface standards there’s no need to worry because the series will take a
that simplify communication between the ESP32 and external progressive hands-on approach. There will be plenty of
hardware. We begin by introducing a range of low-cost temperature time to build up your knowledge and plenty of opportunity
and humidity sensors that can be used in projects that need to sense to test things out along the way.
conditions in the surrounding environment. Coding Workshop We’ve not included too much basic theory because this
looks at maths operators and functions and our Practical Project can be easily found elsewhere, including several of our
shows how easy it is to add an LCD display to your designs. previous Teach-In series, see:
The learning objectives for the fifth part of our series are https://bit.ly/pe-ti
know how to use: https://bit.ly/pe-ti-bundle
n 1-wire and I2C interfaces to connect external hardware Earch month, there’ll be projects and challenges to help you
n Temperature, humidity and other environmental sensors check and develop your understanding of the topics covered.
n Low-cost I2C LCD displays.
Unmounted DHT22 (and DHT11) sensors) are supplied
The DHT22 temperature and humidity sensor in a 4-pin package. They are also available as small,
A variety of temperature and humidity sensors have become printed circuit modules with a few additional components
available for use in a wide range of situations where there is a that enable them to be used in stand-alone applications
need to sense, monitor and control the environment. Typical where only three connections are required to a host
applications include heating, ventilation and air-conditioning microcontroller: positive supply, data and ground (negative
(HVAC), dehumidifiers and humidity regulators, weather supply).
stations and data loggers, and vehicle environmental control. The DHT devices use the 1-wire bus for communication
We will start this part of Teach-In by introducing some between the sensor and a microcontroller. Sensed values
popular temperature and humidity sensors, namely: the DHT11 of temperature and humidity are sent as serial data using
(RHT01) and DHT22 (RHT02 or AM2302). the single wire connection. The sensor remains in a
standby (low-power) mode until the
host controller generates a start signal
comprising a logic 0 (LOW) for at least
0.5ms, followed by a logic 1 (HIGH).
When this signal is received, the sensor
enters operational mode and responds
with a serial stream comprising five
bytes (40 bits) of data. This data
consists of two bytes of RH data (high
byte followed by low byte), two bytes of
temperature data (high byte followed
by low byte), and a checksum used to
verify the data. A typical example of
the serial data for a DHT22 sensor is
Fig.5.1. A wide variety of low-cost sensors are available for use with the ESP32. They shown in Table 5.1.
include sensors for temperature, humidity, barometric pressure, and UV as well as the The checksum is found by adding
popular DHT11 and DHT22 types (centre). the preceding four bytes of data. So, in
Gotcha!
Take care when RH measurements
are made in environments where Fig.5.4. Breadboard wiring for the DHT22.
airborne contaminants and gases
are present. Table 5.3 DHT11 and DHT22 specifications
Fig.5.8. Wiring for the thermostatic controller based on a Fig.5.9. A representative I2C bus with two bus masters and
popular ESP32 expansion board. three slaves present.
direction of the data transfer. The address is transferred with from the I2C scanner.) Note that I2C applications require
the most-significant bit first (see Fig.5.11). Table 5.4 lists just a the Wire.h (or equivalent) library and so we’ve included
small selection of currently available devices that support I2C. it (using #include) at the start of the code.
#include <Wire.h>
void setup() {
Serial.begin (115200);
Serial.println (); Fig.5.11. I2C bus transaction showing how first an address and
Serial.println (“Performing I2C scan ...”); then data is placed on the bus.
byte count = 0;
Wire.begin();
for (byte i = 8; i < 120; i++)
{
Wire.beginTransmission (i);
if (Wire.endTransmission () == 0)
{
Serial.print (“I2C device found at: “);
Serial.print (“ 0x”); Fig.5.12. Typical Serial Monitor output when using the I2C
Serial.println (i, HEX); scanner in Listing 5.3.
count++;
} The circuit arrangement for the LCD and DHT22
} application is shown in Fig.5.13. This arrangement is based
// Scan complete so print total found
on a low-cost 16 × 2 LCD panel fitted with an I2C interface
Serial.print (“Scan completed. Found “);
Serial.print (count, DEC); (see Fig.5.14). Note that the interface is mounted on the
Serial.println (“ device(s).”); back of the LCD panel and has four connections: GND,
} VCC, SDA and SCL. SDA is used for data and SCL is used
for the clock signal.
void loop() { With the code in Listing 5.4 running, the breadboard
// Main code (if any) goes here wiring for the LCD and DHT22 application is shown in
} Fig.5.15. If required, the display backlight can be adjusted
using the small preset resistor (the square blue component
shown in Fig.5.14).
Listing 5.4 Sample code for the LCD temperature and You should notice that we’ve included two libraries at
humidity monitor the beginning of the code in Listing 5.4 using these lines:
* ESP32 with DHT22 and 16 x 2 LCD
#include <dhtnew.h> // To use the DHTxx sensor
to display temperature and humidity */
#include <LiquidCrystal_I2C.h> // To use the LCD
// Include the library files
#include <dhtnew.h>
#include <LiquidCrystal_I2C.h>
// Define the LCD parameters
int lcdColumns = 16;
int lcdRows = 2;
// Setup the LCD
LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows);
DHTNEW mySensor(16); // UART RXD input
void setup() {
Serial.begin(115200);
// Initialize LCD
lcd.init();
// Turn the backlight ‘on’
lcd.backlight();
}
Fig.5.13. Circuit arrangement for the LCD and DHT22 application.
void loop() {
// First read the sensor
mySensor.read();
// Now display on the LCD
lcd.setCursor(0, 0); // First row
lcd.print(“Temp: “);
lcd.print(mySensor.getTemperature(), 1);
lcd.print(“ deg.C”);
lcd.setCursor(0, 1); // Second row
lcd.print(“Humidity: “);
lcd.print(mySensor.getHumidity(), 1);
lcd.print(“%”);
delay(5000); // Wait for 5 seconds
lcd.clear();
}
Fig.5.14. I2C interface mounted on back of a 16 × 2 LCD display.
Coding Workshop
It’s time to do some maths! You’ve
already made use of some of the
operators that the C++ language
Fig.5.15. Breadboard wiring for the DHT22 and 16 × 2 LCD display. provides. They are + (addition), –
(subtraction), * (multiplication), and
/ (division). You will doubtless already be familiar with
Listing 5.5 Testing the math operators them – but if not, Listing 5.5 shows some code that might
act as a reminder.
// Checking math operators +, -, *, and / The Serial Monitor output of Listing 5.5 is shown in
Fig.5.16. The code in the main loop executes only once
void setup() {
and halts at while(1) (where it waits forever). Since we
// Start the Serial Monitor
Serial.begin(9600); don’t actually need a loop that’s repeated we could have
} simply placed all of the code in setup() which is only
ever executed once. In this case we would simply have
void loop() { an empty main loop. Notice also that we’ve used the tab
float x = 12.3; character (\t) to neatly space the Serial Monitor’s output.
float y = 45.6; As an example of using maths operators let’s consider
Serial.println(“Maths operators!”); temperature conversion from Celsius to Fahrenheit. This
Serial.print(“Added: \t\t”); can be easily achieved using these lines of code:
Serial.println(x + y);
Serial.print(“Subtracted: \t”);
degF = (degC * 1.8) + 32; // Convert deg.C to deg.F
Serial.println(x - y);
Serial.print(“Mulitiplied: \t”); degC = (degF - 32) / 1.8; // Convert deg.F to deg.C
Serial.println(x * y);
Serial.print(“Divided: \t”); The variables (degF and degC) are both declared as floats,
Serial.println(x / y); using these lines:
while(1); // Wait forever
} float degC; // Temperature in deg.C
float degF; // Temperature in deg.C
Where P is the power in the load (in watts), V is the peak // Setup the LCD
voltage developed across the load (in volts), and R is the value LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows);
of load resistance (in ohms). We will use floating point variable
(floats) for the three variables using the following declarations: void setup() {
Serial.begin(115200);
Wire.begin(); // Use the I2C bus
float loadR, peakV, loadP; // Declare the variables bmp280.begin();
We can then use the next line of code to perform the calculation: //Check if the AHT20 will acknowledge
if (aht20.begin() == false) {
loadP = (0.5 * sq(peakV)) / loadR; // Calculate the power Serial.println(“AHT20 not present!”);
while (1)
If, on the other hand, we just want to print the value returned ;
via the Serial Monitor then we could use this line: }
Serial.println(“AHT20 detected!”);
// Initialize LCD
Serial.println((0.5 * sq(peakV)) / loadR); // Print
lcd.init();
the power // Turn the backlight ‘on’
lcd.backlight();
}
void loop() {
Teach-In challenge
This month’s Teach-In challenge involves developing a device
that monitors temperature, humidity and barometric pressure,
and displays the current values on a 20 × 4 LCD display
Gotcha!
When performing calculations the order in which maths
operators are applied is vitally important. It’s always
worth checking carefully or splitting your calculations
into smaller chunks spread over several lines of code. Fig.5.19. Modified AHT20/BMP280 module cable (a 4-pin
header replaces one of the two connectors).
Teach-In 2017
The books listed here
have been selected by
the Practical Electronics
editorial staff as being
of special interest to
everyone involved
BBC micro:bit
direct to your door.
FOR A FULL DESCRIPTION
OF THESE BOOKS AND
CD-ROMS SEE THE SHOP ON
OUR WEBSITE
PYTHON CODING ON THE BBC MICRO:BIT
Jim Gatenby www.electronpublishing.com
Python is the leading programming language, easy to learn and widely used by
professional programmers. This book uses MicroPython, a version of Python adapted
for the BBC Micro:bit. All prices include
Among the many topics covered are: main features of the BBC micro:bit including a
simulation in a web browser screen; various levels of programming languages; Mu Editor
UK postage
for writing, saving and retrieving programs, with sample programs and practice exercises;
REPL, an interactive program for quickly testing lines of code; scrolling messages, creating
and animating images on the micro:bit’s LEDs; playing and creating music, sounds
and synthesized speech; using the on-board accelerometer to detect movement of the
micro:bit on three axes; glossary of computing terms. MICROPROCESSORS
This book is written using plain English, avoids technical jargon wherever possible and
covers many of the coding instructions and methods which are common to most program-
INTERFACING PIC MICROCONTROLLERS – 2nd Ed
ming languages. It should be helpful to beginners of any age, whether planning a career in
Martin Bates
computing or writing code as an enjoyable hobby.
298 pages Order code NE48 £34.99
118 Pages Order code PYTH MBIT £7.99
PROGRAMMING 16-BIT PIC MICROCONTROLLERS IN
GETTING STARTED WITH THE BBC MICRO:BIT C – LEARNING TO FLY THE PIC24
Lucio Di Jasio (Application Segments Manager,
Mike Tooley Microchip, USA)
Not just an educational resource for teaching youngsters coding, the BBC micro:bit is a tiny 496 pages + CD-ROM Order code NE45 £38.00
low cost, low-profile ARM-based single-board computer. The board measures 43mm × 52mm
but despite its diminutive footprint it has all the features of a fully fledged microcontroller to-
INTRODUCTION TO MICROPROCESSORS AND
gether with a simple LED matrix display, two buttons, an accelerometer and a magnetometer.
MICROCONTROLLERS – 2nd Ed
Mike Tooley’s book will show you how the micro:bit can be used in a wide range of applications John Crisp
from simple domestic gadgets to more complex control systems such as those used for light- 222 pages Order code NE31 £29.99
ing, central heating and security applications. Using Microsoft Code Blocks, the book provides
a progressive introduction to coding as well as interfacing with sensors and transducers. THE PIC MICROCONTROLLER YOUR PERSONAL
INTRODUCTORY COURSE – 3rd Ed
Each chapter concludes with a simple practical project that puts into practice what the reader John Morton
has learned. The featured projects include an electronic direction finder, frost alarm, reaction
tester, battery checker, thermostatic controller and a passive infrared (PIR) security alarm. 270 pages Order code NE36 £25.00
No previous coding experience is assumed, making this book ideal for complete beginners
PIC IN PRACTICE – 2nd Ed
as well as those with some previous knowledge. Self-test questions are provided at the
David W. Smith
end of each chapter, together with answers at the end of the
book. So whatever your starting point, this book will take 308 pages Order code NE39 £24.99
THEORY AND you further along the road to developing and coding your
own real-world applications.
MICROCONTROLLER COOKBOOK
REFERENCE 108 Pages Order code BBC MBIT £7.99
Mike James
240 pages Order code NE26 £36.99
UNDERSTANDING ELECTRONIC CONTROL SYSTEMS Order from our online shop at: www.electronpublishing.com
Owen Bishop
228 pages Order code NE35 £36.99
JULY 2023
Multimeter Checker/Calibrator..................................................04107221 10.95
MIDI Spectral Sound Synthesiser (full kit – see p.25)..............N/A N/A
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.
MARCH 2022
PE/EPE PCB SERVICE
Mini Isolated Serial Link..................................................... 24102211 £5.95 Order Code Project Quantity Price
Busy Loo Indicator.............................................................. 16112201 £5.95
Analogue Vocoder – Band-pass filter board....................... AO1-MAR22 9.95 .........................................................
Analogue Vocoder – HP/LP filter board.............................. AO2-MAR22 9.95
.........................................................
FEBRUARY 2022
Arduino-based Power Supply............................................. 18106201 9.95 .........................................................
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
Name. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DECEMBER 2021
AM/FM/SW Digital Receiver............................................... CSE200902A 13.95 .........................................................
Balanced Input and Attenuator for USB CODEC............... 01106202 11.95
Tel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
NOVEMBER 2021 Email . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Dual Battery Lifesaver........................................................ 11111202 £6.95
I enclose payment of £ . . . . . . . . . . . . . . (cheque/PO in £ sterling only)
OCTOBER 2021
Mini Wi-Fi LCD BackPack.................................................. 24106201 £8.95 payable to: Practical Electronics
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
If you want your advertisements to be seen by the largest readership
at the most economical price then our classified page offers excellent Practical Electronics
value. The rate for semi-display space is £10 (+VAT) per centimetre reaches more UK
high, with a minimum height of 2·5cm. All semi-display adverts have a readers than any other
width of 5.5cm. The prepaid rate for classified adverts is 40p (+VAT) per UK monthly hobby
word (minimum 12 words).
electronics magazine.
Cheques are made payable to ‘Practical Electronics’. VAT must be
Our sales figures prove it.
added. Advertisements with remittance should be sent to: Practical
Electronics, 113 Lynwood Drive, Wimborne, Dorset, BH21 1UU. We have been the leading
Tel 07973518682 Email: [email protected] monthly magazine in
BOWOOD ELECTRONICS LTD
For ratesofand
Suppliers further
Electronic information on display and classified advertising
Components this market for the last
please contact our Advertisement
www.bowood-electronics.co.uk Manager, Matt Pulzer – see below. twenty-seven years.
Unit 10, Boythorpe Business Park, Dock Walk, Chesterfield,
Derbyshire S40 2QR. Sales: 01246 200 222
Send large letter stamp for Catalogue
ADVERTISING INDEX
CRICKLEWOOD ELECTRONICS . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Advertisement offices
ESR ELECTRONIC COMPONENTS . . . . . . . . . . . . . . . . . . . . . . . 16 Matt Pulzer
HAMMOND ELECTRONICS Ltd . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
JPG ELECTRONICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Electron Publishing Ltd
FLOWCODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Cover (ii)
1 Buckingham Road
PEAK ELECTRONIC DESIGN . . . . . . . . . . . . . . . . . . . . . . Cover (iv)
Brighton
POLABS D.O.O. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 East Sussex BN1 3RA
QUASAR ELECTRONICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Tel 07973 518682
SILICON CHIP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Email [email protected]
STEWART OF READING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
TAG-CONNECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Web www.electronpublishing.com
TERRINGTON COMPONENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
For editorial contact details see page 7.
WebMite
The PicoMite is a Raspberry Pi Pico programmed in the MMBasic
language – a very capable microcontroller. Our new WebMite
is a PicoMite with firmware support for the wireless capability of
the Pico W (a Pico with the addition of a Wi-Fi module) and the
protocols (802.11n, DHCP, WPA-PSK, TCP, IP, TLS, HTML) that are
necessary to access the internet.
PLUS!
All your favourite regular columns from Cool Beans
and Circuit Surgery, to Audio Out, Teach-In, Techno
Talk and Net Work. On sale 4 July 2024
Content may be subject to change
JPG Electronics
Britannia Maison Mes Amis
Bournemouth BH1 9EH, United Kingdom
Inn
Old Road Remember, we print the date of the last issue
of your current subscription in a box on the
ad
d
Roa
address sheet that comes with your copy.
Old H
orth
tsw
Cha
Morrisons
Sparks
Digital subscribers, please call 01202 880299
Retail & Trade Welcome • Free Parking • Google St View Tour: S40 2RB or visit: www.electronpublishing.com
Published on approximately the first Thursday of each month by Electron Publishing Limited, 1 Buckingham Road, Brighton, East Sussex BN1 3RA. Printed in England by Acorn Web Offset Ltd., Normanton WF6
1TW. Distributed by Seymour, 86 Newman St., London W1T 3EX. Subscriptions UK: £33.99 (6 months); £59.99 (12 months); £114.99 (2 years). EUROPE: airmail service, £38.99 (6 months); £69.99 (12 months);
£129.99 (2 years). REST OF THE WORLD: airmail service, £46.99 (6 months); £84.99 (12 months); £164.99 (2 years). Payments payable to ‘Practical Electronics’, Practical Electronics Subscriptions, PO Box
6337, Bournemouth BH1 9EH, United Kingdom. Email: [email protected]. PRACTICAL ELECTRONICS is sold subject to the following conditions, namely that it shall not, without the written consent of the
Publishers first having been given, be lent, resold, hired out or otherwise disposed of by way of Trade at more than the recommended selling price shown on the cover, and that it shall not be lent, resold,
hired out or otherwise disposed of in a mutilated condition or in any unauthorised cover by way of Trade or affixed to or as part of any publication or advertising, literary or pictorial matter whatsoever.
nics
The UK
Circuit Surgery Teach-In 2024 ’s pAudio
remieOut
r electr
Topics in digital signal processing Sensing the environment
Circuit with Mechanical o
in audio nics and
– sample and hold Topics Surgerswitches
the ESP32 SoC microcontroller
y compu
proce
in digit
ssing – al signal Teach ting ma
-In 20 ker ma
ADCs Using
SoC m
LED dis 24
plays w
gazine
ic rocontr it h the E
oller SP32 Audio
O
Mecha ut
n
switch ical
Make your WIN!
es in a
udio
own Dynamic Micro
Curios chip
Develoity HPC
RFID tags pm
Board ent
WIN! Louds
p
Test Ji eaker
Heart
Reciprocal g
Senso RCounter
Frequency ate
r Modu
le
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