Practical Electronics October 2019 Avxhm - Se

Download as pdf or txt
Download as pdf or txt
You are on page 1of 86

D NA –

IG E
!
E
ES M
N
Practical
EW W P
N NE E

Electronics
The UK’s premier electronics and computing maker magazine
Micromite Electronic Circuit Surgery Cool Beans
MMBASIC graphical Building Blocks Transistor theory Designing a
commands Auto gadgets and practice 4-bit computer

WIN!
Microchip
PIC-IoT WG
Development
Board
WIN!

GPS-synced
Frequency Reference
Exciting new series
on stepper motors
DCC Programmer
WIN! for Decoders
$50 of PCB prototyping
from PCBWay

Opto-isolated LS3/5A
Mains Relay Crossover
design

See our Super


Summer Sale!
PLUS!
Net Work – Look back to the start of the Internet Oct 2019 £4.65
10
Techno Talk – Two cheers for 5G
The Fox Report – Finding free 4K content via satellite 9 772632 573009

www.epemag.com @practicalelec practicalelectronics


With Over 250 Million Units in
Stock, We’ve Got You Covered
Delivering You the World’s Largest
Inventory of Microchip Products

www.microchip.com/learn-more

The Microchip name and logo and the Microchip logo are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
All other trademarks are the property of their registered owners.
© 2018 Microchip Technology Inc. All rights reserved. DS00002552A. MEC2226Eng10/18
Practical
Volume 48. No. 10
October 2019
ISSN 2632 573X

Electronics Contents
Projects and Circuits
Programmable GPS-synced Frequency Reference – Part 1 by Tim Blythman 14
For design, servicing, calibration or whenever you need a really accurate and stable
frequency reference, this Micromite BackPack-based project delivers the goods.
Digital Command Control Programmer for Decoders by Tim Blythman 24
DCC is a widely-used method for controlling model railways. This programmer is
simple, cheap and easy to build – and operates from a computer’s USB port.
Opto-isolated Mains Relay by Tim Blythman 32
This project lets you switch the mains from a microcontroller or low-voltage
output, but keeps dangerous voltages safely locked away.

Series, Features and Columns


The Fox Report by Barry Fox 8
Free 4K material via satellite
Techno Talk by Mark Nelson 10
Two cheers for 5G
Net Work by Alan Winstanley 12
A look back 50 years to the very start of the Internet...
Google’s world of Cardboard... Augmented reality... Newsbeat
Using Stepper Motors by Paul Cooper 40
Part 1 – Introduction to stepper motor technology
Circuit Surgery by Ian Bell 44
Understanding bipolar junction transistors – Part 4
Audio Out by Jake Rothman 48
Designing Hi-Fi mini-monitor loudspeakers – Part 2
Make it with Micromite by Phil Boyce 58
Part 9: Introduction to MMBASIC graphical commands
Max’s Cool Beans by Max The Magnificent 66
A little more on metastability, and back to the ‘HRRG’
Electronic Building Blocks by Julian Edgar 76
Automotive gadgetry

Regulars and Services


PE Teach-In 8 3
Subscribe to Practical Electronics and save money 4
PE Summer Sale – a page full of great deals 6
Reader services – Editorial and Advertising Departments 7
Editorial 7
Competitions – please enter them!
Exclusive Microchip reader offer 23
Win a Microchip PIC-IoT WG Development Board
Exclusive PCBWay reader offer 38
Win one of six $50 credits to use with PCBWay’s superb PCB prototyping service
Teach-In bundle – what a bargain! 56
Practical Electronics back issues CD-ROM – great 15-year deal! 57
Practical Electronics CD-ROMS for electronics 70
A superb range of CD-ROMs for hobbyists, students and engineers
Direct Book Service 73
© Electron Publishing Limited 2019 Build your library of carefully chosen technical books
Copyright in all drawings, photographs, articles, Practical Electronics PCB Service 78
technical designs, software and intellectual property PCBs for Practical Electronics projects
published in Practical Electronics is fully protected, Classified ads and Advertiser index 79
and reproduction or imitation in whole or in part are Next month! – highlights of our next issue of Practical Electronics 80
expressly forbidden.
The November 2019 issue of Practical Electronics will be
published on Thursday, 7 October 2019 – see page 80. Stepper motor image on cover and contents page courtesy of Pololu Robotics & Electronics, pololu.com

Practical Electronics | October | 2019 1


All prices INCLUDE 20.0% VAT. Free UK delivery on orders over £48
Quasar Electronics Limited Postage & Packing Options (Up to 0.5Kg gross weight): UK Standard 3-7
PO Box 6935, Bishops Stortford Day Delivery - £4.95; UK Mainland Next Day Delivery - £9.95; Europe
CM23 4WP, United Kingdom (EU) - £12.95; Rest of World - £14.95 (up to 0.5Kg).
!! Order online for reduced price postage and fast despatch !!
Tel: 01279 467799 Payment: We accept all major credit/debit cards. Make cheques/PO’s
E-mail: [email protected] payable to Quasar Electronics Limited.
Please visit our online shop now for full details of over 1000 electronic
Web: quasarelectronics.co.uk kits, projects, modules and publications. Discounts for bulk quantities.

Solutions for Home, Education & Industry Since 1993

Bidirectional DC Motor Speed Controller


Controllers & Loggers Control the speed of
Here are just a few of the controller and data most common DC
acquisition and control units we have. See motors (rated up to
website for full details. 12Vdc PSU for all 32Vdc/5A) in both the
units: Order Code 660.446UK £10.68 forward and reverse
directions. The range
of control is from fully
OFF to fully ON in both directions. The direc-
USB Experiment Interface Board
tion and speed are controlled using a single
Updated Version! 5
potentiometer. Screw terminal block for con-
digital inputs, 8 digital
Official Main Dealer stocking the outputs plus two ana-
nections. PCB: 90x42mm.
full range of Kits, Modules, Ro- Kit Order Code: 3166KT - £19.99
logue inputs and two
Assembled Order Code: AS3166 - £29.99
bots, Instruments, tools and analogue outputs. 8 bit
much, much more... resolution. DLL.
8-Ch Serial Port Isolated I/O Relay Module
Kit Order Code: K8055N - £39.95 £22.20
Computer controlled 8
Assembled Order Code: VM110N - £35.94
channel relay board.
PIC & ATMEL Programmers 2-Channel High Current UHF RC Set 5A mains rated relay
State-of-the-art high outputs and 4 opto-
We have a wide range of PIC, ATMEL Ar- isolated digital inputs
duino and Raspberry Pi projects. security. Momentary or
latching relay outputs (for monitoring switch
rated to switch up to states, etc). Useful in a variety of control and
PIC Programmer & 240Vac @ 12 Amps. sensing applications. Programmed via serial
Experimenter Board Range up to 40m. 15 port (use our free Windows interface, termi-
Great learning tool. Tx’s can be learnt by one Rx. Kit includes nal emulator or batch files). Serial cable can
Includes programming one Tx (more available separately). 9-15Vdc. be up to 35m long. Includes plastic case
examples and a repro- Kit Order Code: 8157KT - £44.95 130x100x30mm. Power: 12Vdc, 500mA.
grammable 16F627 Assembled Order Code: AS8157 - £49.96 Kit Order Code: 3108KT - £74.95
Flash Microcontroller. Test buttons & LED Assembled Order Code: AS3108 - £89.95
indicators. Software to compile & program Computer Temperature Data Logger
your source code is included. Supply: 12- Serial port 4-ch temperature 8-Channel RF Remote Control Set
15Vdc. Pre-assembled and ready to use. logger. °C/°F. Continuously Control 8 onboard relays
Order Code: VM111 - £38.88 £35.94 log up to 4 sensors located with included RF remote
200m+ from board. Choice control unit. Toggle or
USB PIC Programmer and Tutor Board of free software applications momentary mode for
The only tutorial downloads for storing/using each output. Up to 50m
project board you data. PCB just 45x45mm. Powered by PC. range. Board Supply:
need to take your Includes one DS18S20 sensor. 12Vac, 500mA
first steps into Kit Order Code: 3145KT - £19.95 £16.97 Assembled Order Code: VM118 - £71.94
Microchip PIC Assembled Order Code: AS3145 - £19.96
programming us- Additional DS18S20 Sensors - £4.96 each Temperature Monitor & Relay Controller
ing a PIC16F882 (included). Later you can Computer serial port
use it for more advanced programming. 8-Channel Ethernet Relay Card Module temperature monitor &
Programs all the devices a Microchip Connect to your router relay controller. Ac-
PICKIT2® can! Use the free Microchip tools with standard network cepts up to four Dallas
for PICKit2™ & MPLAB® IDE environment. cable. Operate the 8 DS18S20 / DS18B20
Order Code: EDU10 - £46.74 relays or check the digital thermometer sensors (1 included).
status of input from Four relay outputs are independent of the
USB /Serial Port PIC Programmer anywhere in world. sensors giving flexibility to setup the linkage
Fast programming. Use almost any internet browser, even mo- any way you choose. Commands for reading
Wide range of PICs bile devices. Email status reports, program- temperature / controlling relays are simple
supported (see website mable timers... Test software & DLL online. text strings sent using a simple terminal or
for details). Free Win- Assembled Order Code: VM201 - £130.80 coms program (e.g. HyperTerminal) or our
dows software & ICSP free Windows application. Supply: 12Vdc.
header cable. USB or Computer Controlled / Standalone Kit Order Code: 3190KT - £79.96 £47.95
Serial connection. ZIF Unipolar Stepper Motor Driver Assembled Order Code: AS3190 - £59.95
Socket, leads, PSU not included. Drives any 5-35Vdc 5, 6
Kit Order Code: 3149EKT - £49.96 £29.95 or 8-lead unipolar step- 3x5Amp RGB LED Controller with RS232
Assembled Order Code: AS3149E - £44.95 per motor rated up to 6 3 independent high
Assembled with ZIF socket Order Code: Amps. Provides speed power channels.
AS3149EZIF - £74.96 £49.95 and direction control. Preprogrammed or
Operates in stand-alone user-editable light
PICKit™2 USB PIC Programmer Module or PC-controlled mode for CNC use. Con- sequences.
Versatile, low cost, nect up to six boards to a single parallel port. Standalone or 2-wire
PICKit™2 Development Board supply: 9Vdc. PCB: 80x50mm. serial interface for
Programmer. Programs Kit Order Code: 3179KT - £15.26 microcontroller or PC communication with
all the devices a Micro- Assembled Order Code: AS3179 - £22.26 simple command set. Suits common anode
chip PICKIT2 program- RGB LED strips, LEDs, incandescent bulbs.
mer can. Onboard sockets & ICSP header. 12A total max. Supply: 12Vdc. 69x56x18mm
USB powered. Card Sales Kit Order Code: 8191KT - £24.95
Assembled Order Code: VM203 - £35.94 & Enquiries Assembled Order Code: AS8191 - £27.95
Teach-In 8 CD-ROM CD
EE M
FR RO
-

ELECTRONI CS
£8.99

Exploring the Arduino TEACH-I N 8


FROM THE PUBLISHERS OF
FREE
CD-ROM
SOFTWARE

SERIES
FOR
THE TEACH-IN
8

This CD-ROM version of the exciting and popular Teach-In 8 series INTRODUCING THE ARDUINO
• Hardware – learn about components and circuits
• Programming – powerful integrated development system
has been designed for electronics enthusiasts who want to get to • Microcontrollers – understand control operations
• Communications – connect to PCs and other Arduinos

grips with the inexpensive, immensely popular Arduino microcontroller,


as well as coding enthusiasts who want to explore hardware and
interfacing. Teach-In 8 provides a one-stop source of ideas and
practical information.
The Arduino offers a remarkably effective platform for developing a
huge variety of projects; from operating a set of Christmas tree lights PLUS...
to remotely controlling a robotic vehicle wirelessly or via the Internet. PIC n’MIX
PICs and the PICkit 3 - A beginners
guide. The why and how to build
Teach-In 8 is based around a series of practical projects with plenty of PIC-based projects

information for customisation. The projects can be combined together


in many different ways in order to build more complex systems that can
be used to solve a wide variety of home automation and environmental
monitoring problems. The series includes topics such as RF technology,
wireless networking and remote web access.
PRICE
£8.99
PLUS: PICs and the PICkit 3 – A beginners guide Includes P&P to UK if
ordered direct from us
The CD-ROM also includes a bonus – an extra 12-part series based around the popular
PIC microcontroller, explaining how to build PIC-based systems.

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

ORDER YOUR COPY TODAY!


JUST CALL 01202 880299 OR VISIT www.epemag.com

Practical Electronics | October | 2019 3


D NA –
IG E
Practical
!
E
ES M
N
EW W P
N NE E

Electronics
UK readers SAVE 73p on every issue
Why not pay £3.92 instead of £4.65 for your copy of Practical Electronics?

D NA –
D NA –

D NA –
IG E
IG E

D NA –
D NA –

IG E
Practical Practical

!
E

Practical

!
ES M
ES M

IG E
N
N

IG E

ES M
N
Practical Practical

!
E

EW W P
EW W P

ES M
ES M

EW W P
N

EW W P
EW W P

N NE E
N NE E

N NE E
N NE E
N NE E




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
Micromite Circuit Surgery Cool Beans PIC n’ Mix Micromite Circuit Surgery Cool Beans PIC n’ Mix Micromite Circuit Surgery Cool Beans PIC n’ Mix Micromite Dynamometer Circuit Surgery Cool Beans Micromite Electronic Circuit Surgery Cool Beans
Digital inputs Comparator Max’s amazing Small, cheap and Subroutines Circuit simulation ‘Micing’ an Small, cheap and Building smart Understanding Fixing a dynamic Small, cheap and Using sound Power electronics Transistor theory Nixie tubes Build a dice Building Blocks Transistor theory Fixing
and outputs circuit design 4-bit computer powerful PICs and interrupts with LTspice Arduino powerful PICs Electronic dice bipolar transistors range problem powerful PICs Mac operation for a rolling road and practice Metastability prediction game LED Clocks and practice Metastability

WIN! Powerful Digital Arduino WIN!


2× 12V Battery
WIN! Wide-range LAN7430 WIN!
NFC Microchip
AVR-IoT WG
Arduino-based PCIe 3.1
WIN!
Sound Effects Microchip dsPIC33CH
Balancer Development Ethernet Bridge
Microchip Module
SAM L11
Xplained Pro
Shield Curiosity
Development
Board
LC Meter Evaluation
Board SAM L21 Evaluation Kit Board
WIN! Xplained Pro WIN!
Evaluation Kit
WIN!
Digital Sound
Deluxe Amazing Arduino Effects Module
Frequency Switch 10A Universal Motor brainwave monitor
Speed Controller
MIDI Ultimate Complete the Control your
Synthesiser – Part 5 PE Theremin PC with an Micromite
Putting MIDI in the MIDI Ultimate IR remote Clock
Event NEW SERIES
USB Port Protector Reminder Build your own
USB
Flexitimer LS3/5A speakers!
MIDI Ultimate
Synthesiser – Part 4 Build your
Build the superb See our Super See our Super
PE Theremin! White Noise Source
PLUS!
Modulation sources
PLUS! own Theremin! PLUS!
PLUS!
Summer Sale! PLUS!
Summer Sale!
4GHz Digital Attenuator 500MHz frequency counter
Net Work, Techno Talk and The Fox Report May 2019 £4.65 June 2019 £4.65
July 2019 £4.65 Watchdog Alarm August 2019 £4.65 Sophisticated lathe speed controller Sep 2019 £4.65
MIDI Ultimate Synthesiser 08
TEACH-IN 2019 – Powering Electronics Net Work, Techno Talk and Electronic Building Blocks 07 World’s best DIY car immobiliser Practically Speaking returns!
09
Net Work, Techno Talk and Electronic Building Blocks
35MHz-4.4GHz digitally controlled oscillator TEACH-IN 2019 – Powering Electronics 9 770262 361195 Barry Fox, Net Work and Techno Talk 9 772632 573009
Net Work and Techno Talk 9 772632 573009
TEACH-IN 2019 – Powering Electronics
www.epemag.com @practicalelec practicalelectronics www.epemag.com @practicalelec practicalelectronics www.epemag.com @practicalelec practicalelectronics
www.epemag.com @practicalelec practicalelectronics www.epemag.com @practicalelec practicalelectronics

Just take out a one-year subscription and save 73p on every issue, or £8.80 over the year.
Even better – save 94p per issue if you subscribe for two years – a total saving of £22.60

Subscribe today and avoid the price


rise on 1 October 2019 – see page 6
for special offers!
SUBSCRIPTION ORDER FORM
Practical  6 Months: UK £25.00, Europe £30.00 (Airmail),

Electronics
Rest of the World £37.00 (Airmail)
 1 Year: UK £47.00, Europe £56.00 (Airmail),
Rest of the World £70.00 (Airmail)
 2 Years: UK £89.00, Europe £107.00 (Airmail),
SUBSCRIPTION PRICES Rest of the World £135.00 (Airmail)
Subscriptions for delivery direct to any address in: To: Practical Electronics
Wimborne Publishing Ltd
UK: 6-months £25.00, 12-months £47.00, 24-months £89.00 113 Lynwood Drive, Wimborne, Dorset BH21 1UU
Europe Airmail: 6-months £30.00, 12-months £56.00, Tel: 01202 880299 Fax: 01202 843233
24-months £107.00 Email: [email protected]
Rest Of The World Airmail: 6-months £37.00, 12-months I enclose payment of £ ..............
£70.00, 24-months £135.00 (cheque/PO in £ sterling only)
payable to Practical Electronics
Cheques (in £ sterling only) payable to Practical Electronics
and sent to: Wimborne Publishing Ltd, 113 Lynwood Drive,  Please charge my Visa/Mastercard
Merley, Wimborne, Dorset BH21 1UU. My card number is: .......................................................................
Please print clearly, and check that you have the number correct
Tel: 01202 880299. Fax: 01202 843233.
Email: [email protected]. Card Security Code .................. Valid From Date........................
(The last 3 digits on or just under the signature strip)
Also via our secure online shop at: www.epemag.com.
Card Ex. Date ......................................
Subscriptions start with the next available issue. We accept
MasterCard or Visa. Name ............................................................................................
(For past issues see the Back Issues page.)
Address ........................................................................................

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


ONLINE SUBSCRIPTIONS Email ............................................................................................
Electronic subscriptions (PDF download or online) are available,
£22.00 for 12 months, visit www.epemag.com for more details. Subscriptions start with the next available issue.

4 Practical Electronics | October | 2019


Your Choice—Any Core,
Any Performance, Any Feature Set
Scalable Performance for Changing Requirements

Are you facing changing design requirements–again? Let Microchip help you
put an end to the frustrations and wasted time that result from these changes.
Microchip is the only semiconductor supplier innovating across 8-, 16- and 32-bit
microcontrollers, digital signal controllers and microprocessors. Our upward-
compatible architectures preserve your time and resource investment in code
development. In addition, our development ecosystem allows you to leverage a
common ecosystem across multiple designs. Changing design requirements don’t
need to be painful; learn how Microchip can make it efortless.

Simplify your life at www.microchip.com/Scalable

The Microchip name and logo and the Microchip logo are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. All
other trademarks are the property of their registered owners.
© 2019 Microchip Technology Inc. All rights reserved. DS30010186A. MEC2290A-ENG-07-19
Super Summer Sale!
Subscribe now and avoid
October’s price rise!
Practical Electronics special offers
40% off all PCBs up to and including those in the February 2019 issue
25% off all PE/EPE hard-copy (print) back issues
25% off all PE/EPE back-issue 6-month CD-ROMs – see page 57
25% off all PE/EPE back-issue 5-year CD-ROMs – see page 57

Practical Electronics subscription offer


Subscribe to PE hard copy for 12-months and receive a free 6-month back-issue
CD-ROM of your choice from Volume 1-40 (see page 57), normal price £16.45.

Subscribe to PE hard copy for 24-months and receive three free 6-month back-issue
CD-ROMs of your choice from Volume 1-40 (see page 57), normal price £16.45 each.

Existing subscribers are welcome to renew early for another 12 or 24 months and
still receive the offer – your new subscription will simply be added to the end of your
existing subscription – no issues lost by renewing early and you avoid October’s
subscription price rise!

Teach-In bundle
Electronics Teach-In bundle includes
TI CD-ROMs 3, 4 and 5 – normal price £18.95
Special offer 25% discount price £14.21 – see page 56

PAYMENT MUST BE RECEIVED BY CLOSE


OF OFFER: 30 SEPTEMBER 2019

Don’t miss out!


Just call 01202 880299 or visit our secure online shop at:
WWW.EPEMAG.COM
Practical
Volume 48. No. 10
October 2019
ISSN 2632 573X

Electronics Editorial
Editorial offices
Practical Electronics Tel 01273 777619 Competitions – please enter them!
Electron Publishing Limited Mob 07973 518682 First, some good news. I’m pleased to tell you that we have a
1 Buckingham Road Fax 01202 843233
Brighton Email [email protected]
new competition this month (and next). Our recommended PCB
East Sussex BN1 3RA Web www.epemag.com provider – PCBWay, as used by PIC n’ Mix’s Mike Hibbett and
Audio Out’s Jake Rothman – are generously offering six $50 prizes.
Advertisement offices All you have to do is use the link on page 38 to set up an account,
Practical Electronics Adverts
1 Buckingham Road
and six lucky readers will be drawn at random on 1 October.
Brighton Setting up an account is free and easy – you have nothing to lose
East Sussex BN1 3RA and may well win a nice prize.
Phone 01273 777619
Mob 07973 518682 This is in addition to our regular competition from Microchip
Email [email protected] (page 23), who have generously supported the magazine for many
years. Please do enter both company’s competitions; it really does
Editor Matt Pulzer
General Manager Louisa Pulzer tell them that supporting Practical Electronics is worthwhile –
Subscriptions Stewart Kearn thank you!
Online Editor Alan Winstanley
Web Systems Kris Thain
Publisher Matt Pulzer Price rise
And now some less welcome news... it’s been nearly two and a
Technical enquiries half years since the last magazine price rise, and unfortunately
We regret technical enquiries cannot be answered over the increases in paper and distribution costs, not to mention inflation
telephone. We are unable to offer any advice on the use, purchase,
repair or modification of commercial equipment or the incorporation mean that we need to raise the cover price of Practical Electronics
or modification of designs published in the magazine. We cannot to £4.99 from the next issue (November). Subscriptions will rise at
provide data or answer queries on articles or projects that are the same rate (approximately 7.5%).
more than five years old.

Questions about articles or projects should be sent to the editor We really do try and keep our costs to a minimum, but we also need
by email: [email protected] to charge a fair price that ensures the future of Practical Electronics.
Projects and circuits
All reasonable precautions are taken to ensure that the advice and With that in mind, let me make one final reminder that we’re still
data given to readers is reliable. We cannot, however, guarantee running our annual summer sale (see opposite). If you renew your
it and we cannot accept legal responsibility for it. subscription between now and the end of September then not
A number of projects and circuits published in Practical Electronics
only will you receive your choice of CD-ROM(s), but also you’re
employ voltages that can be lethal. You should not build, test, guaranteed to avoid the price rise. So, subscribe by the end of
modify or renovate any item of mains-powered equipment unless September for 24 months and you’ll avoid the price rise until the
you fully understand the safety aspects involved and you use an
RCD (GFCI) adaptor.
summer of 2021.

Component supplies Remember, even if your subscription is not due yet, you won’t lose
We do not supply electronic components or kits for building the out; your additional subscription will simply start after the current
projects featured, these can be supplied by advertisers. We
advise readers to check that all parts are still available before
one ends and you’re still guaranteed to avoid any price rises.
commencing any project in a back-dated issue.
What are you waiting for? Grab a bargain!
Advertisements
Although the proprietors and staff of Practical Electronics take
reasonable precautions to protect the interests of readers by Matt Pulzer
ensuring as far as practicable that advertisements are bona fide,
the magazine and its publishers cannot give any undertakings
Publisher
in respect of statements or claims made by advertisers, whether
these advertisements are printed as part of the magazine, or in
inserts. The Publishers regret that under no circumstances will
the magazine accept liability for non-receipt of goods ordered, or
for late delivery, or for faults in manufacture.

Transmitters/bugs/telephone equipment
We advise readers that certain items of radio transmitting and
telephone equipment which may be advertised in our pages
cannot be legally used in the UK. Readers should check the law
before buying any transmitting or telephone equipment, as a fine,
confiscation of equipment and/or imprisonment can result from
illegal use or ownership. The laws vary from country to country;
readers should check local laws.

Practical Electronics | October | 2019 7


The Fox Report
Barry Fox’s technology column

Free 4K material via satellite


By looking outside the usual SES/Astra satellite broadcasts of UK Freesat and free Sky programmes,
Barry Fox has discovered additional no-charge 4K HDR material.

S
o, you have your nice new 4K TV with a satellite dish, rather than set will find around 1000 TV and
UHD TV, but all you can watch a normal Freeview terrestrial TV radio channels.
on it is 2K material. You don’t aerial, because Freeview reception  Go to List or similar option on
want to buy a new Blu-ray player on the UK’s South Coast is bedevilled the remote control, choose
and UHD discs, or pay Amazon or by interference from French stations Satellite TV, and the TV will
Netflix for streamed 4K, which your in warm weather. show all the channels found, some
broadband connection may or may with unhelpful numbering and
not be able to support. gobbledegook names, but most with
Exchanging 4K home-grown movie helpful labels such BBC News HD,
files with friends is an ‘orrible obstacle BBC Four HD or Sky News HD.
course to navigate.  Avoid anything marked with a key
I recently failed so many times to icon, which denotes ‘scrambled’.
download a friend’s two-hour item Accessing new channels These are for use by Sky boxes
in 4K, which soaked up over 60 GB, Although details may vary, the basic with integrated de-encryption or
that I finally got on a train to collect method of tuning is likely to be the TVs with European Conditional
a physical copy on an SSD HDD. In same for other pan-European 4K TVs Access modules plugged in.
fact, I had to do the journey twice that come with a satellite socket as  Press whichever button on the
because I had not realised that my 4K well as a terrestrial aerial socket. I remote control offers to mark chosen
TV would only read from an NTFS- did the following: channels as Favourites. On the
formatted disc (not exFAT).  Connect the set’s satellite socket to Philips set it is the green button.
a single coax feed from any working  From then on, use the Satellite
Free 4K channels Sky or Freesat dish. Favourites channel List to choose
However, I then discovered a free  Go to: Settings > Install Channels, channels to watch.
source of 4K HDR material, broadcast and choose Satellite Installation.
direct to home by satellite. The Ignore any offer to use any Freesat In among all the familiar Freesat
content is travel and lifestyle, not software that the set may have and and free Sky channels you should
drama. But beggars can’t be choosers. select a generic satellite option. find several dedicated to 4K HDR
The trick is to look outside the  Then click to ‘Search for Satellite’ demo channels, including a couple
bundle of UK Freesat and free Sky and the set will find the 28.2 East from Astra/SES and one intriguingly
programmes broadcast from the bird(s) because that is the only labelled ‘BBC Olympics’. This has
SES/Astra satellite(s) at 28.2 East. satellite slot a correctly installed presumably been set aside for the
I discovered this by accident while Sky/Freesat dish will be ‘seeing’. 2020 Tokyo Games. Who knows, it
trying to use a new Philips 4K HDR  Click ‘Install Channels’ – and the may well carry some 4K feeds.

Extruded enclosures
standard and heatsink
www.hammondmfg.com/1455.htm
www.hammondmfg.com/1455NHD.htm

01256 812812
[email protected]
8 Practical Electronics | October | 2019
Two cheers Techno Talk
for 5G Mark Nelson

You’ve probably read the good news about 5G – the fabulous new fifth-gen mobile comms and data
technology, packaged as a digital blessing for mankind. However, new technology has a nasty habit of
springing surprises and biting where it hurts, which is why an increasing number of informed observers
are voicing concerns over 5G.

B
ut first, what’s not to like ionising and non-ionising electromag- evidence, in the hell-for-leather dash to
about 5G? It promises consid- netic radiation is not sharply defined: create the 5G electronic ecosystem, is the
erably higher data rates, lower different molecules and atoms ionise at conviction in government circles that,
latency (time-lag) plus an increased differing energy levels. Overall, some unless we introduce it immediately, we
number of simultaneous connections. argue far more study needs to be made will be left behind and our economic
What’s the problem? In a word, ‘health on the long-term effects of exposure to growth and competitiveness will be put
risk’. (That’s two words, but never mind.) millimetre radiation. at risk. There is simply no time to con-
Cast your mind back 110 years to the sider the possible health consequences.’
early days of research into radioactivity. Bee-stly effects
Although Marie and Pierre Curie were Of course, it’s not just us humans who To hell in a handcart?
keen proponents of the opportunities may be affected. Our loyal friends the Are we, as some observers claim, rush-
offered by their discoveries of poloni- bees, which act as vital pollinators for ing headlong into a new nirvana of total
um and radium, they had absolutely our food production, are already under connectivity? Jeffrey Naydler further ar-
no idea about the damaging effects of attack by neonicotinoid insecticides, gues that, ‘the electromagnetic energies
ionising radiation. Marie carried test colony collapse disorder and verroa that we have summoned, and which
tubes containing radioactive isotopes mite disease. In this situation, 5G radio promised to give us new powers, now
in her pocket, and was also exposed could become a further threat. At the appear to be overpowering us, carrying
to X-rays from unshielded equipment 26GHz frequency band allocated for 5G us down into an Underworld realm of
while serving as a radiologist in First in the UK and Europe, the wavelength hellish entertainment and distraction,
World War field hospitals. Her husband (11.5mm) is close to the bee’s size and of illusion and disconnection from the
was equally unaware of the health risks radiation penetrates further into the body. reality that really matters – the reality
of radiation exposure; experimenting A campaigning organisation, Physicians of nature and the spiritual order that
with radium next to the skin of his arm. for Safe Technology (http://bit.ly/pe- infuses nature, the reality of fellow crea-
oct19-tt), cites academic reports that bee tures with whom we share our world,
Ionising radiation behaviour is already being disrupted by living in soil and sky and walking the
Radiation mirrors the possible problem exposure to cell phone GSM radiofre- Earth beside us.’
with 5G that many argue has not been quency radiation, causing worker bees He suggests we demand greater scru-
examined adequately. As the authori- to emit a piping signal to swarm. tiny of 5G’s rollout – and protest. There
tative website EETech.com observes, are campaigns we can join, petitions to
the effect of radio waves on health has Industry denial sign, letters to write and legal actions to
been a matter of concern for decades. The foregoing may sound contentious, support. The best place to begin is the
The onset of 5G has revived these con- but there is not sufficient scientific International Appeal to Stop 5G on Earth
cerns, as new hardware presents fresh evidence to prove one way or anoth- and in Space (www.5gspaceappeal.org),
opportunities for misunderstandings, er. The usual industry excuse is that which has already gathered more than
not to mention the need for better edu- we have been bombarded by radiation 50,000 signatures, including those of
cation. Many experts, it acknowledges, from broadcast transmitters for many many health professionals, environ-
do dispute the idea of any health-related decades and from cellular towers for mentalists and other scientists.
concerns, because mobile-technology the past 25 years, with no conclusive
radio waves are in the centimetre range, correlation between exposure to radio More speed less haste
and therefore non-ionising (they can frequency energy and health. This is Smoke for a day and you’ll probably be
cause heating, though). 5G, however, specious, because that radiation was at fine (but please don’t risk it), smoke for
uses much higher frequencies, which a significantly lower frequency. 30 years and you massively increase the
are millimetric and thus that much To underscore this, campaigner Jeffery risk of fatal disease. Where and how do
closer to the ionising range. Add to this Naydler, states: ‘Earlier this year, The you draw the line? Perhaps the real point
an increased number of base stations, Guardian published an article cit- with 5G is we just don’t know. It offers
and there are those who question the ing research that showed that while real and important benefits, but as the
technology’s safety. 67% of independently funded studies frequencies and power levels climb so
Ionising radiation, it should be found a biological effect of exposure should our vigilance. 5G signals will be
explained, is radiation that carries suf- to radio-frequency radiation, only everywhere all the time, so even if they
ficient energy to detach electrons from 28% of industry-funded studies did. turn out to be relatively harmless, it is
atoms or molecules – thereby ionising Industry-funded studies are almost well worth understanding the effect of
them. It is harmful and potentially le- two-and-a-half-times less likely than 24/7 exposure to high (and rising) fre-
thal, causing radiation burns, cancer and independent studies to find health ef- quency non-ionising radiation on not just
heritable effects. The boundary between fects. One of the reasons for ignoring the us, but the ecosystems we depend on.

10 Practical Electronics | October | 2019


TC-08: Your 8-Channel
Thermocouple Data Logger

1 Connect
Take your irst temperature
logger measurements in
three simple steps

2 Configure

3 Collect

When paired with the power and astounding lexibility


of PicoLog 6 software, the TC-08 temperature logger
can start recording reliable, accurate, detailed
Only
measurements in under 60 seconds. £289
(excl VA
T)

To ind out more visit: www.picotech.com/A396


Net Work
Alan Winstanley
This month, we look back 50 years to the very start of what became the Internet, as a pair of
computers 350 miles apart in Caifornia formed a simple network and exchanged data.

N
ext month marks a milestone carried out by Paul Baran of America’s 1969, a day Kleinrock dubbed ‘the day
for the Internet as we know it RAND Corporation. Their work coin- the infant Internet took its first breath’.
today: precisely 50 years ago cided with that of Donald Davies of (See Personal History/ Biography: the
the very first attempt was made to log Britain’s National Physical Laboratory birth of the Internet, at: www.lk.cs.ucla.
into a remote computer over a network. (NPL), though Davies is generally cred- edu/personal_history.html)
This momentous achievement is attrib- ited with devising the core principles
uted to Leonard Kleinrock, an American of ‘packet switching’, as NPL called it, Network
engineer who devoted the early part of in 1965. The NPL also demonstrated A second node was then installed over
his career to researching principles of to the US Advanced Research Projects at Stanford Research Institute (SRI, 350
transmitting data over networks, an idea Agency (ARPA) the benefits of running miles to the north in what was about to
that attracted very little interest back in dedicated high-speed data networks. become Silicon Valley), and towards
the early 1960s. In the new Sputnik era, the defence the end of October UCLA endeavoured
Like many of the best engineers, department had been charged with a to connect to it over a remote network,
Leonard Kleinrock started out as an building a resilient communications another ground-breaking event. Notable
electronics hobbyist who was fascinat- network – the ARPANET – to counter too was the early use of autocomplete:
ed by early crystal radios and the inner threats posed by the emerging satellite after sending the first few characters ‘l-
workings of radio sets. He honed his and nuclear age at a time when Amer- o-g’ the SRI host was set up to fill the
electronic engineering skills at science ican telecoms relied on slow and busy field with ‘login’, but after receiving
school before entering university. At phone lines. ARPA was soon sold on the ‘g’ the host crashed! The remote
the time, the emerging science of in- the new idea of using packet switch- transmission of the first successful
formation technology was somewhat ing at the core of a ‘digital’ network. login characters took place fifty years
over-subscribed, Kleinrock felt, and so ago on 29 October 1969, the day ‘the
he decided to focus his attention on Packet switching and the UK’s NPL infant Internet uttered its first words’.
something brand new: data networks. According to archive footage, it is Two months later, a total of four US
It is said that in a paper he wrote claimed that the NPL’s own research on sites had been hooked together on
back in 1962, Leonard Kleinrock first packet switching influenced the design the embryonic ARPANET. Although
floated the basic idea of splitting large of the first network hardware created by only a dozen or so nodes were online
chunks of data into smaller pieces that Bolt, Beranek and Newman in Amer- by the mid 1970s, it was enough to
were more suited for transmission over ica in 1969, when they produced the develop, debug, refine and expand a
a network. Research on transmitting world’s first data switch – the IMP or packet-switching network that was the
data using ‘message blocks’ was also Interface Message Processor – based on precursor to today’s Internet.
a rack of Honeywell The NPL’s own story of packet switch-
minicomputers. In ing can be found on YouTube at: https://
August 1969 the first youtu.be/tT4AaelwvV4, a fascinating
IMP was delivered to documentary and a ‘must see’ for Net
Leonard Kleinrock at Work readers. It explains the gradual
UCLA (University of development of the Internet proper
California at Los An- – an inter-networking data communica-
geles) where he and tions system that eventually interfaced
his ARPA-sponsored with a computer network overseas,
team of engineers all reliant on the principle of packet
aimed to connect switching. As they explain, the irony
the switch to its first is that thanks to VoIP (Voice over In-
‘host’ computer, a ternet Protocol), data networks have
technical challenge largely taken over the role of those old,
that had never been slow analogue lines that once formed
attempted before. In- the indispensable backbone of voice
terest in this event communications.
was industry-wide
and, happily, data A Cardboard world
successfully flowed More than three years ago in Net Work
between the IMP and (June 2016) I trialled a Google-Card-
IMP – the world’s first data switch – towering over Dr Leonard the host for the first board-compatible viewer, a simple but
Kleinrock, ‘the grandfather of the Internet’. (Image: UCLA). time on 2 September effective VR (virtual reality) device that

12 Practical Electronics | October | 2019


was made from diecut E-flute corrugat-
ed cardboard. It holds a smartphone
in place and displays a stereoscopic
split-screen of ‘Cardboard compatible’
media for viewing VR video through a
pair of glass lenses. The viewer opens
a new world of virtual reality, where
compatible apps and videos can be
viewed on-screen in an immersive 360°
experience. Google Cardboard and a
range of compatible ‘Works with Card-
board’ viewers from other suppliers can
be sourced via http://bit.ly/nw-oct19-
360 or eBay, typically starting from
just £2.99. Decent-quality VR visors
made of plastic can be sourced from
the usual online suppliers for next to A 360° VR film of a Jaguar sports car on Nürburgring, available for Cardboard and
nothing; unlike Cardboard, they may compatible VR visors.
feature adjustable inter-pupillary dis- phone is panned around, 360° panora- military satellites with swarms of ‘nano
tance (IPD) and focal length settings, ma style. Outdoors, the phone’s camera satellites’ or equipping them with
making them a good choice for specta- can be used to point at the night sky high-power lasers.
cle wearers. The ‘VR Box’ visor used by or an AR scene of the night sky can be Back on Earth, France has imple-
the author is a very inexpensive entrée rendered indoors instead. A moody mented a new 3% digital sales tax
into VR and 360° video, and is a good musical score adds to the experience aimed at raising tax revenue on ‘soft’
choice for those wishing to dabble for and, overall, SkyView provides an trade generated by tech giants such as
the first time. enchanting view of some of the won- Facebook and Google. European efforts
The free Cardboard app for Android ders of our night skies. Android and to implement a digital sales tax (see
and iOS is available from Play Store. iOS versions are available, including Net Work, January 2019) fell through
Paid-for media is also sold, such as a a free ‘Lite’ version to get you started. due to a lack of universal agreement
VR tour of London’s famous Abbey A handful of Play Store reviewers are among EU member states. All eyes are
Road studios, or a spaceman’s view less than kind considering the low now on the OECD tackling the issue of
of the world (Astronaut VR), which cost, but it’s worth a try and is just the global taxation in an Internet-enabled
the author found was a ‘fast game thing to spark an interest in astronomy market. The UK is applying a 2% dig-
played slow’, but it might appeal to as the nights start to draw in. ital levy of its own.
youngsters. YouTube also carries free Good news for Microsoft Windows
Cardboard-compatible videos that often Newsbeat stick-in-the-muds: it appears that
seem to consist of roller coaster rides or Back to cardboard tech – Kodak has pro- rounded corners on applets and win-
(be warned) house of horror videos. For duced a cheap film scanner. Utilising dows will be reintroduced in a move
family friendly viewing, a good place the Kodak Mobile Film Scanner app, away from the stark, barren squared-
to start is by opening the ‘360 video the clever design uses rigid cardboard off effect of the unappealing ‘Metro’
channel’ in the Cardboard app, and components coupled with an LED back- tiled interface. Rounded corners are
remember to find and click the ‘Card- light that enables a smartphone to scan slated for a future Windows 10 release.
board’ icon to open the video in split 35mm positive and negative film strips At the time of writing, Huawei con-
screen before popping the smartphone and slides. It collapses into a 6-inch tinues to advertise its high-end P30
into your VR viewer. As one example, box and it might be all that some users Pro smartphone in the British press,
motorsport fans might enjoy being a need to scan a few old films. Presently adding that it’s ‘business as normal’,
passenger while lapping the Nürbur- it is only available in the US. despite the trade spat with the Trump
gring circuit in a monster Jaguar XE SV, France is considering ways of pro- administration. No one really knows for
complete with audio, and thanks to the tecting its satellites orbiting in space. sure whether Google will be forced to
360° panoramic video you can even As part of a new weapons program withhold future support and updates
nose around the car too. It’s great fun! called Maîtrise de l’Espace (Masters for apps and the Android OS found
of Space), proposals include shielding on current or future Huawei phones.
Augmented reality Amazon’s smartspeaker is to offer
Apart from virtual reality, a number British users medical advice gleaned
of popular augmented reality (AR) from the National Health Service
apps are available that make the most website. Alexa’s hands-free voice-rec-
of your smartphone or tablet. If your ognition and search system may help
budget doesn’t stretch to a GPS com- the elderly, partially sighted or those
puter-controlled telescope, then one with disabilities who are unable to use
astronomy app to try is SkyView by the phone or visit their GP. The NHS
Terminal Eleven. This AR program website is at: www.nhs.uk and contains
uses GPS to determine location (or a plethora of professional, non-com-
enter yours manually) and displays mercial advice and information. See
the night sky on screen. Constellations you next month for more Net Work!
and some satellites are recognised and
superimposed on the screen as well,
and individual stars and planets can The author can be reached at:
be pinpointed by the cursor as the Kodak’s card/smartphone film scanner [email protected]

Practical Electronics | October | 2019 13


Accuracy better than 100 parts per billion
Part 1 – by
Tim Blythman

Lab Quality
Programmable GPS-synced
FREQUENCY REFERENCE
In design, service and repair, calibration or any other critical task in electronics,
there are times when a really accurate and stable frequency reference is
needed. The chances are, whatever frequency you require, this Micromite
BackPack-based project can provide it. Exactly!

O
ur new GPS-based Frequency Reference frequency counters, oscilloscopes and spectrum analysers
provides three high accuracy, customisable outputs with external reference inputs, especially if their inbuilt
which are set up using a touchscreen and synchro- oscillator is not terribly accurate.
nised to the 1pps signal from a GPS module. Two of these For example, many devices need a 10MHz reference and
can be set to a wide range of frequencies over the range of this unit can produce that exact frequency. But it’s also quite
about 1-100MHz. The onboard temperature-compensated common to see test equipment needing some oddball frequen-
oscillator is within a temperature-controlled oven for cies, so you can set up one of the outputs to cater to those too.
maximum stability. We’ve gone to quite some length to make this design not
Not only is its GPS-synchronised oscillator very stable, only very accurate and flexible, but also compact, easy to
but also you can choose from a huge range of possible output build, easy to use and relatively inexpensive. And we have
frequencies – in fact, it has three separate outputs, so you also addressed most of the criticism levelled at our previous
can even produce more than one signal at a time. design, mainly to do with its ability to reject jitter from the
It’s especially useful in satellite signals.
combination with We satisfied the compactness and ease of construction
requirements by making this unit considerably simpler than
our previous design (April-May 2009).
This is possible because we are using a considerably more
powerful micro (a PIC32) which means we’ve been able to
replace a substantial portion of the hardware with software
routines. So this unit is not only better than the earlier mod-
els, it’s cheaper!
Since this project is based on the Micromite LCD Back-
Pack V2 (May 2018), the touchscreen eliminates the
need for all the extra display and button-sensing
circuitry and therefore the need for many
cutouts in the front panel. Our usual
(
Micromite supplier (micromite.org) can

14 Practical Electronics | October | 2019


supply a kit to build the BackPack V2 module; see the
parts list for details. Features and specifications
The simplification of the circuitry has also meant that • Main 40MHz oscillator is disciplined from GPS signals
we can fit the extra circuitry on a much smaller board. In • Accuracy of around ±100ppb after 30 minutes
fact, it’s now a similar size to the BackPack V2 and simply
• Three BNC outputs with programmable frequencies:
stacks behind it, so the whole lot will easily fit into a small
~ 1–100MHz
UB3 Jiffy box.
Plus, the touchscreen means we can make the user inter- • Main oscillator is temperature compensated and oven regulated
face much easier to understand and simpler to use, with a • MicroMite BackPack-based 320 x 240 pixel LCD touchscreen
lot of extra features. for coniguration and status
But it’s the triple PLL IC which provides the cherry on • Compact unit, 160 x 68 x 44mm overall (in UB3 Jiffy box)
the cake – that is, the three configurable outputs. One of the • Powered from 5V USB supply @ 400mA (500mA at start-up)
outputs is limited to a small range of frequencies (including • Optional disciplined 1pps output
that all-important 10MHz option) but for the other two, you • Works with a wide range of GPS units, with external or
can type in just about any frequency and chances are, it will internal antenna
produce that exact frequency, or something very close. And
• Low parts count
if it isn’t exact, it will tell you the difference.
• Modest parts cost
Excellent long-term precision • Most parts are easy-to-solder SMDs.
The jitter reduction mentioned earlier is possible because
we are no longer using a phase-locked-loop (PLL) IC to lock Since the new unit is less complex, we’ve also managed to
the voltage controlled oscillator (VCO) onto the GPS 1pps make it use much less power. Rather than needing a 12V sup-
signals. A PLL will adjust the VCO frequency immediately ply, it runs off 5V instead. That simplifies the power supply
upon detection of a phase difference, but that could just and the unit simply runs from any USB (5V) power source
be due to jitter. Instead, we’re using a software algorithm such as a phone charger or even directly from a computer.
which averages the VCO frequency over a range of time
periods and makes small, calculated adjustments to the Principle of operation
frequency. We’ll have more on that algorithm in the next The block diagram in Fig.1 shows the basic principle of the
article in this series. Frequency Reference. The oven section is shown at upper
Also, for it to be as effective as possible, we need an ex- left, and inside it, there is a voltage-controlled oscillator
tremely stable oscillator. This has been achieved by putting (VCO1), a DS18B20 temperature sensor and transistor Q1.
a temperature-compensated oscillator in a temperature- The Micromite controls the output voltage of the DAC
controlled oven, along with a very stable reference regulator (digital-to-analogue converter – IC6) using an SPI (serial
which is used to derive the VCO’s control input voltage, peripheral interface) bus. This voltage affects the dissipa-
along with a DAC that can produce very small voltage steps. tion in transistor Q1 and it heats up the components inside
The end result is that with a satellite-derived 1pps signal the oven, including the digital temperature sensor.
with sufficient long-term accuracy, we can trim the VCO’s The temperature reading is fed back to the Micromite over
output so that its error is measured not just in parts-per- a Dallas 1-wire serial bus, and this information is used to
million... but in parts-per-billion. adjust the voltage fed to Q1, regulating the oven temperature.

Fig.1: block diagram of the Programmable GPS-Synced Frequency Reference. The VCO is located in the oven section, with
transistor Q1 and a DS18B20 thermometer used to maintain it at a fixed temperature. This feeds the PLL, which then routes
the signal to the Micromite and to the three outputs. The Micromite chip can then send commands to DAC IC1 to shift the
VCO frequency via buffer IC3, to discipline the 40MHz VCO frequency using 1Hz pulses from the GPS module.

Practical Electronics | October | 2019 15


A second SPI DAC (IC1) produces a voltage which getting its output very close to exactly 40,000,000Hz.
is buffered by IC3 and then fed to the VCO, to shift its Once the oven reaches the target temperature, it varies
output frequency slightly, over the range of 39,999,800- over a range of less than 1°C, improving the stability of
40,000,200Hz. the VCO into the parts-per-billion range.
The initial tolerance of the VCO is ±2ppm which The trimmed frequency from the VCO is fed to a multi-
equates to ±80Hz, with a drift of up to ±1ppm (±40Hz) PLL chip (IC2) and from there back to a high-frequency
per year, and some small additional variation with counter within the Micromite. The Micromite can then
temperature or supply voltage changes. By shifting the count the number of pulses received between each 1pps
VCO frequency, we can compensate for these errors, pulse from the GPS module to determine whether the VCO’s

Programmable GPS-synced Frequency Reference

16 Practical Electronics | October | 2019


frequency is spot on. If it is not, the Micromite adjusts the IC5, to provide a low impedance for BNC-socket output
drive to the VCO to bring it back in line with the GPS pulses. connectors CON2-CON4. If LK2 is fitted instead of LK1,
Note that it can also average its readings over a CON2 will instead be fed with a disciplined (ie, more
longer period to reduce the influence of jitter in accurate) 1pps signal from the Micromite, instead of the
the GPS 1pps pulses on the output of the VCO. third PLL output.
The 40MHz frequency from the VCO is also fed to three
programmable PLLs within IC2, which can be configured Circuit description
to produce a wide range of different frequencies. The Turning now to the full circuit diagram in Fig.2, you can
outputs of the three PLLs are then buffered by IC4 and see that there is a little more to it than described above.
Although oscillator VCO1 (TXEAACSANF-40) is in the
oven, we also decided to use a temperature-compensated
oscillator, for extra stability. IC1, the DAC controlling the
VCO frequency, is an MCP4922 dual 12-bit type. We need
fine control over the voltage fed to the VCO, so we can shift
its frequency by very small amounts.
Rather than use an expensive 24-bit DAC, we are instead
averaging the two outputs of the dual 12-bit DAC using
different resistor values, so that the pin 10 output gives
fine control and the pin 14 output adjusts the frequency
in larger steps. With this arrangement, we can vary the
frequency of the VCO over its full range, in steps of
around 60ppb.
So that the VCO output is stable, the control voltage
must also be very stable, so both the averaging resistors
and the 2.5V reference for the DAC (REG2) are inside the
oven, indicated by the shaded area on the circuit diagram.
The combined DAC output is fed to an LMV641 op-
amp (IC3) so that the VCO’s control input doesn’t load up
the averaging resistors and cause the voltage to shift, and
also so that the VCO control input is driven from a low-
impedance source to ensure it operates correctly. This is
a high-precision, low-noise, low-power op amp. A 22pF
capacitor at its input reduces unwanted noise.
While IC3 has no gain, there is a 2kΩ resistor in its
feedback path so that the impedance seen by both inputs
(pins 2 and 3) is the same. This is important, because mis-
matched input impedances cause increased thermal drift in
op amps, and that is something we definitely do not want.
DAC IC1’s reference inputs (pin 11 and 13) are fed with
2.5V from REG2, a MAX6166A precision regulator with
5ppm/°C temperature coefficient.
Since its temperature variation is within 1°C and the
VCO ‘pulling range’ is ±5ppm, that means the influence of
variations in REG2’s output should be no more than (2 ×
5ppm) × 5ppm × 1°C, which is a fraction of a part per billion.
Also, REG2 is fed from a 2.7V regulated rail provided by
REG1, itself a very stable 2.7V low-dropout (LDO) regulator,
so its line regulation should be excellent.
It should be apparent that we have gone to a lot of effort
to ensure that the VCO’s output is extremely stable and
only shifts when the micro wants it to.
NPN transistor Q1, which provides heat for the oven, is
connected directly across the 3.3V supply and so its dis-
sipation is directly proportional to collector current, which
Reproduced by arrangement with in turn is related to its base current. The base current is
SILICON CHIP magazine 2019. determined by the voltage at output pin 10 of IC6, another
www.siliconchip.com.au MCP4922 dual SPI DAC, which uses a 2.7V reference from
REG2 to avoid loading up REG1 unnecessarily.
Fig.2: complete circuit diagram for the Frequency
Q1’s 2.7kΩ base-current-limiting resistor was chosen to
Reference, showing the Micromite BackPack V2 as a ‘black
box’ (the May 2018 article has the details). The 40MHz keep the maximum dissipation in Q1 to a safe level. The
signal from VCO1 is fed to PLL IC2, which then produces Micromite sets the DAC output to control the temperature,
the three programmable frequency output signals fed to as measured by TS1, forming a closed control loop.
CON2-CON4, as well as the signal fed back to RX/T1CK The second DAC in IC6 is not needed for any function
on the BackPack. This is divided down and compared to related to the oven, so its output at pin 14 is connected to
the 1pps signal from the GPS module at pin 21; and the LED1 to vary its brightness as well as CON7, which is used
difference is used to change the voltage at the outputs of for diagnostic purposes.
dual DAC IC1, which are combined and buffered by IC3 The DS18B20 oven temperature sensor (TS1) sends its data
and then fed to the VCO’s control input. to the Micromite pin 16 and its output is fitted with a 4.7kΩ
pull-up resistor, as required for the Dallas 1-wire protocol.

Practical Electronics | October | 2019 17


The Main Page provides buttons to The settings are organised into three The Presets page allows frequency
access all the features of the Frequency main groups: Presets, Temperature (for settings to be copied and pasted. All the
Reference, as well as displaying the tuning the oven’s operation) and VCO presets are saved to non-volatile storage,
current state of the three outputs. Trim (for manual adjustment of the VCO). so are preserved during power cycles.

Phase-locked loop IC Unfortunately, the CDCE906 data pins 1 and 5 are wired to ground, this
The PLL (IC2) is what allows us to have sheet was not specific about the output gives you the option of feeding either
three customisable frequency outputs loading requirements and we found or both signals to off-board connectors
which are not simply integral fractions these resistor values necessary to by placing a 2-wire plug over pin pairs
of the VCO’s 40MHz frequency. provide reliable operation. 1 and 2, and 4 and 5.
It is a Texas Instruments CDCE906 The dividers only reduce the output
triple-PLL clock synthesiser IC, the signal swing by about 33%, and since GPS module interface
only chip that is in a TSSOP (fine- the chip runs off a 3.3V supply, that The GPS module’s serial TX and RX
pitch) SMD package because it is not still gives a useful swing of around pins are wired directly to pins 9 and
available in a larger package. 2.2V peak-to-peak. 10 on the Micromite so that the latter
It has six programmable outputs, but Output Y4 is fed back to the RX pin can receive NMEA serial data.
since it only has three internal PLLs, (pin 12) on the Micromite via jumper A jumper is placed on LK1 to select
some settings are shared between LK1, as this is the only pin which between a 3.3V or 5V power supply for
them (we are using four of the six). It can measure frequencies this high (as the GPS module.
is controlled over an I2C bus at pins 9 described below). We used the trusty old VK2828U7-
and 10, which are connected to pins Since this prevents the serial con- G5LF GPS module with onboard
17 and 18 of the Micromite and 4.7kΩ sole from operating, LK1 has been ceramic antenna, which can operate
pull-up resistors are fitted, as required provided; simply remove the jumper from either 3.3V or 5V.
by the I2C standard. to access the serial console and re- Some constructors will prefer to use
If you are not familiar with PLLs, insert it to allow normal operation. a module with an external antenna,
then (briefly) they consist of a voltage- The other three remaining outputs and in this case, you may need to
controlled oscillator followed by a at pins 16, 19 and 20 (outputs Y3-Y5) choose a particular voltage to suit the
programmable divider. are fed to paralleled pairs of gates in module used.
A phase comparator compares the hex inverter chips IC4 and IC5. These Whichever module you select, make
frequency and phase of the divided are 74ALVC14 devices, which are a sure it has a TTL serial interface along
output to the input frequency and pro- modern equivalent to the 74HC14 hex with a 1pps output pin.
vides negative feedback, to adjust the schmitt trigger inverter. The NMEA output from the GPS
oscillator frequency until the output The difference is that these chips module is a stream of serial text data
of the divider matches the input, thus can operate at lower voltages (1.65- which contains satellite information,
providing a fixed ratio between the 3.6V) and much higher frequencies including the time, date and location.
input and output frequencies. (up to about 100MHz). They can also The module also produces a 1pps
The 40MHz signal from VCO1 is fed source or sink up to 50mA per output. pulse, which is fed directly to pin 21
into the three PLLs within IC2, via a Thus, each pair can supply up to on the Micromite.
51Ω resistor, to provide IC2 with the 100mA and they feed the outputs via Once the Micromite confirms from
expected 50Ω source impedance. 39Ω impedance-matching/current- the NMEA data that a valid satellite
Each PLL has a multiplier and a limiting resistors. fix has been achieved, it starts timing
divider, which allows a vast number A dedicated pair of inverters the 1pps pulses in order to discipline
of ratios to be chosen, and in turn, a (IC5e/f) is also provided to buffer the the VCO.
wide range of frequencies to be derived disciplined 1pps output from pin 22
from the input clock. of the Micromite. Power supply
Each output can be programmed to Four of the twelve inverter stages are You can fit either a mini USB (CON5)
take its input from any of the PLLs, unused (IC4a/b/e/f), so their inputs are or micro USB (CON6) socket and
and the PLL frequency can be further tied to ground to prevent oscillation. power then comes from a 5V USB
divided down to give an even wider The link arrangement to select the charger or similar.
range of output frequencies. signal source for CON2 is a little more The 5V supply is fed directly to the
The two unused outputs of IC2, at complex than was shown on the block Micromite BackPack V2, where it pow-
pins 12 (Y1) and 15 (Y2) are termi- diagram. A 5-pin header is used, which ers the LCD touchscreen and is regu-
nated to ground with 510Ω resistors, allows a jumper shunt to be placed lated to 3.3V to power the Micromite
while the other four outputs are fed over either pins 2 and 3, or 3 and 4 to chip. The 3.3V supply is then fed back
to their destinations via 510Ω/1.1kΩ feed either signal through to the cen- to the Frequency Reference board, to
potential dividers. tral pin of the BNC socket. But since power the remaining circuitry.

18 Practical Electronics | October | 2019


Tuning the temperature settings can be The VCO settings are basic, but very A Status page is provided to give
done on this page, although we found the useful. Changing the C Value (control information about how the Frequency
initial values we tried were quite good. value) allows the VCO to be manually Reference is performing. In this case, no
You may need to raise the setpoint if your tuned, perfect if you have an atomic GPS module is connected, and the unit
workspace consistently gets above 35°C. clock source for calibration. has fallen back to PLL-only mode.

The only component on the Fre- compensation, so does not require a Micromite pin 4 is wired to the
quency Reference which may draw capacitor on its output. LDAC input of IC1 (pin 8), which
directly from the 5V supply is the GPS To minimise noise from DACs IC1 is driven to ensure that the output
module, and that’s only if you have and IC6, and jitter from PLL IC2, these voltages of both DACs within IC1
selected the 5V option. three devices also have 10mF ceramic change at the same time. This prevents
Everything else runs from 3.3V, bypass capacitors near their supply pins, glitches from changes in the DAC out-
with the 2.7V (REG1) and 2.5V (REG2) in parallel with the 100nF capacitors. put voltage being propagated to the
regulators only being used to provide input of VCO1.
the DAC reference voltages. Micromite BackPack Communications with the DACs is
The Micromite is responsible for simple since the micro only needs to
Remaining components coordinating the functions of all the send the new digital value over the
By default, pin 1 of IC2 (S0/A0/CLK_ components on the GPS Frequency SPI bus and the output voltages then
SEL) is configured to disable the six Reference board. As mentioned earlier, change in response.
outputs when low. So we have fitted the two DACs IC1 and IC6 use the SPI The PLL IC has a more complex
a 10kΩ resistor to ground to make the bus, which is on pins 3 (SPI OUT) and interface and is controlled by program-
outputs disabled by default. 25 (SPI CLK) of the Micromite. This ming an array of internal registers
This pin is wired back to Micromite same bus is also used on the Micromite which have various functions.
pin 24 so it can enable the PLL outputs BackPack V2 for communications Note that we had to use the Micro-
by making that pin a digital output and with the touchscreen, but at different mite’s pin 26 beause there are no free
setting it high. times, so the functions do not interfere. pins on the I/O header (pin 14 is a
All ICs have 100nF bypass capaci- The Micromite’s digital output pin shared SPI pin, so cannot be used). The
tors between their main supply pins 5 is pulled low when the software Micromite BackPack V2 uses pin 26 for
and ground, for reliable operation; and sends an SPI command to IC1 and this the optional software LCD backlight
all regulators have 10mF ceramic input is wired to its chip select (CS) input. control, so Micromite BackPack V2
bypass and output filter capacitors, Similarly, Micromite pin 26 drives the must be built with hardware (trimpot)
except for REG2, which has internal CS input of DAC IC6. backlight brightness control instead.

Parts list – Precision Frequency Reference


1 double-sided PCB, code 04107181, 120mm x 55mm Semiconductors
1 Micromite BackPack V2 kit (described in May 2018) 2 MCP4922 dual 12-bit SPI DAC ICs, SOIC-14 (IC1,IC6)
[available from micromite.org] 1 CDCE906 programmable PLL/clock synthesiser,
1 VK2828U7G5LF or equivalent GPS module TSSOP-20 (IC2)
[Banggood ID: ID: 965540] 1 LMV641 low-power op amp, SOIC-8 (IC3)
3 PCB-mount BNC sockets (CON2-CON4) [Jaycar PS0661] 2 SN74ALVC14 hex schmitt trigger inverter, SOIC-14 (IC4,IC5)
1 UB3 Jiffy Box 1 DS18B20 temperature sensor IC, TO-92 (TS1)
1 40-way snappable pin header (GPS1,JP1,JP2,LK1) 1 MCP1700-2.7V voltage regulator, TO-92 or SOT-23 (REG1)
[Altronics P5430, Jaycar HM3212] 1 MAX6166AESA 2.5V voltage regulator, SOIC-8 (REG2)
3 jumper shunts (shorting blocks) (JP1,JP2,LK1) 1 3mm LED (LED1)
1 SMD USB mini-B (CON5) or micro-B (CON6) socket 1 BC337 NPN transistor, TO-92 (Q1)
3 M3 tapped 12mm-long nylon spacers 1 TXEAACSANF-40 VCTCXO IC, 4-SMD (VCO1)
3 M3 x 20mm pan-head machine screws
1 USB charger or similar power supply with cable to suit Capacitors (all SMD X7R, 3216/1206 size)
CON5/CON6 5 10mF 7 100nF 1 22pF

Parts for oven enclosure Resistors (all SMD 1%, 3216/1206 size)
2 100mm cable ties 1 8.2M 1 10k 3 4.7k 1 2.7k 2 2k
2 bottle caps, film canisters, small foam cups or similar 4 1.1k 6 510 1 220 1 51 4 39

Practical Electronics | October | 2019 19


Each output (CON2, CON3 and CON4) The advanced screen gives direct control CON4’s advanced PLL control is
has its own control screen and allows of the N, M and P dividers, which are used restricted to modifying the P value,
setting of the output frequency by by each PLL, as well as reporting whether as N and M are locked to provide the
automatic seeking, manual adjustment of the resulting PLL frequency is within the 40MHz reference that is fed back into
PLL parameters and from stored presets. correct range. the Micromite.

Also, the Micromite must use its output frequency is limited to a range is 127. This is also what determines the
internal TIMER1 feature to keep track from 1-167MHz. Our output buffers lowest possible frequency that the PLL
of the frequency, as none of the other limit the maximum usable frequency output can produce, which is 630kHz
timers are fast enough to manage the to around 100MHz. (80MHz÷127).
40MHz signal. Unfortunately, the We configure the registers in IC2 so Since the N and M registers have 12
TIMER1 pin is attached in hardware that PLL1 feeds into CON2, PLL3 feeds and nine bits respectively, that puts
to the Micromite’s console RX on pin into CON3 and PLL2 feeds into both an upper limit on their values at 4095
12, so we have to shut down IC2 until CON4 and back to the Micromite’s pin and 511 respectively. There is also
it is needed. 12 frequency counter input. While a restriction that N must be greater
Using the console RX pin to capture PLL1 and PLL3 can be set to a wide than or equal to M, but given that the
the 40MHz signal from the VCO means range of frequencies, PLL2 is fixed to minimum PLL frequency is 80MHz, N
that we cannot use the console during run at 160MHz, so that a ‘P’ divider must be greater than M to achieve this
normal operation, as this will cause of four gives us our 40MHz signal to from a 40MHz source anyway.
the 40MHz signal to be swamped by feedback to the Micromite. Since M has a smaller range of
signals from the console. That means, however, that CON4 values, the algorithm iterates over
To get around this, the two USB cannot be set to produce just any the valid values of P and M, works
sockets on the board (CON5 and frequency. But it can still be set to out what the exact (decimal) value of
CON6) are used for power only. Link a number of different frequencies, N would need to be to produce the
LK1 is provided so that you can still ie, 160MHz divided by an inte- desired frequency, and then tests the
program the Micromite via the serial ger between two and 127 (80MHz, next highest and lowest integer values
console, and it is then shorted with a 53.3MHz, 40MHz, 32MHz, 26.7MHz, to see how close they would be to our
jumper for normal operation. …, 1.26MHz). target frequency.
While CON2 and CON3 can provide As the iteration occurs, if a bet-
Controlling the PLL a much more flexible range of frequen- ter match is found, it is stored. If an
IC2’s software registers allow us to cies, the software actually has to do exact match is found, then no further
provide a comprehensive range of quite a bit of work to calculate the N, searching need be done. Otherwise, it
output frequencies – we can set up M and P values required to produce a continues until all viable PLL setting
internal multipliers and dividers to specific frequency. After all, there are combinations have been tested.
determine a wide range of internal PLL 268 million possible combinations Unfortunately, when this algorithm
frequencies. We have the capability to [2(12+9+7)]. was implemented in BASIC, it took
read and write these internal registers; While it’s possible that there is no over a minute to complete, which is
the read function is used only to verify combination of values which will give far too long.
that the writes have occurred correctly. a particular frequency that you want, Thus, we had to write a CFUNCTION
Each PLL inside IC2 has a 12-bit ‘N’ chances are, if it is in the range of 10- to speed up the process. Once the C
divider and a 9-bit ‘M’ divider. But 100MHz then the unit will be able to code has been compiled, it generates
since the ‘N’ divider is in the feedback produce something very close (and PIC32 machine code which is inserted
loop of the PLL, it actually has the you will be able to see on the screen into and can be called from the BASIC
effect of multiplying the frequency. It what that frequency actually is). program, and this runs much faster.
is the N/M fraction which determines Since there are so many combina- Our CFUNCTION version of the code
the ratio between the PLL and input tions of values, we had to carefully takes less than one second to complete.
frequencies. Each of the six outputs design an algorithm to find the best As well as the N, M and P values,
also has a separate 7-bit ‘P’ divider. combination. It starts by determining there are a number of registers which
The N, M and P values are all integers what values of P are valid given the need to be set up for the PLL to operate
(ie, whole numbers). desired frequency. Because the PLL fre- as required. Most of these are initially
In more detail, the incoming (nomi- quency must fall between 80MHz and set by ‘dumping’ an array of data into
nally 40MHz) frequency is multiplied 300MHz, this gives a fairly small range. the registers during the initialisation
by N and then divided by M to give the For example, to produce a 40MHz phase. After this, the N, M and P reg-
PLL frequency, and the PLL frequency frequency, P must be between two isters are about all that is changed by
is divided by P to arrive at the output (80MHz PLL) and seven (280MHz the program in the Micromite.
frequency. The PLL frequency must PLL). Since the value of P is limited to Each PLL also has a one-bit flag
be in the range of 80-300MHz, and the seven bits, the highest valid value for P which can be used to select either a

20 Practical Electronics | October | 2019


The Seek page allows the frequency to If an entered frequency is too low for the When a valid Seek frequency is entered,
be entered by a numeric keypad and Seek algorithm, a message box advises the Micromite finds the nearest frequency
provides MHz and kHz shortcuts to the fact and returns to the previous which can be generated by the PLL and
speed up entry of custom frequencies. screen, preventing invalid results. displays it so that it can be checked
before being output.

high-speed mode (above 180MHz) or Other software considerations display these values on the status page
low-speed mode (below 200MHz). As The rest of the software is relatively as confirmation that the GPS module is
each group of registers are updated, this straightforward. Updating the DAC out- working correctly.
is set to the appropriate value. puts only requires selecting the chip, Apart from the software algorithm
As well as being able to enter a de- writing 16 bits, then de-selecting the for setting frequencies, we also had to
sired frequency and having the register chip, which is just a few lines of code. create a second CFUNCTION to count
values calculated for you, we decided Processing and parsing the NMEA the incoming 40MHz pulses from the
to give users the option to enter the data from the GPS module is a bit more VCO. This requires setting up the
values of N, M and P manually. We involved, as we have to check that the TIMER1 interrupt and an interrupt
found during testing that the restric- GPS module has a proper fix before try- service routine to keep track of when
tions stated in the data sheet on the PLL ing to discipline the VCO from the 1pps the 16-bit hardware counter overflows
frequency are not hard-and-fast rules, signal (otherwise the 1pps signal may (the 32-bit timers are not able to operate
and that the chip is able to operate at not be accurate). This involves check- at this high a frequency).
frequencies outside the specified range. ing that we have received the $GPRMC The same routine also provides the
So our software does not enforce sentence and that it has the value ‘A’ at disciplined 1pps output by toggling pin
these rules for manually-entered val- a certain point, and not ‘V’. 22 every 20 million received pulses. So,
ues, although it does give a warning Since it is not much more effort, the accuracy of the output 1pps signal is
for combinations that would result in a we also decipher the GPS latitude, matched to the accuracy of the 40MHz
PLL frequency outside the normal range. longitude, UTC time and date, and oscillator, as they work in lockstep.

Developmental trials and tribulations


This project took some time to inish, error messages. While the V2 Back- remove one of them as it considered
and like many of our more ambitious Pack has a USB console connector, it redundant. So the chip’s ground
projects we encountered a few stum- unlike the one on the Plus BackPack, connection was via a long, circuitous
bling blocks along the way. The inal this shares the same TX and RX pins, path, hence the noise.
design is pretty close to the initial so that doesn’t help. We also found that IC2 operated
concept, but we had to make a few The other major problems we had much more reliably when the outputs
reinements for it to work properly. were with the PLL/Clock Synthesiser were loaded up with around 1.5kΩ to
As is typical, we are using all of chip, IC2. It would randomly freeze ground and with a 50Ω series resistor
the Micromite BackPack’s free I/O up the I2C bus, sometimes locking to set the source impedance for the
pins. The only way to get more I/Os the Micromite and often just failing to clock input; this was not mentioned
would have been to use a board with respond at all. The I2C signals from in the CDCE906 data sheet, so we
an SMD micro, but they are trickier the Micromite looked ine on a scope. had to igure it out ourselves.
to solder. In the end, the only real After many hours of probing, it Finally, we managed to simplify
compromise we had to make was to became apparent that the I2C sig- the design during development. We
use one of the console pins for I/O, nals were ine, but the chip couldn’t originally had two extra logic ICs, a
making our debugging more diicult. decode them because its ground divider to produce 20MHz and 10MHz
This was necessary because the was so noisy. We then noticed that signals from the 40MHz VCO output,
PIC32 only provides one input pin the ground trace to the PLL/Clock and another to select which of these
for each timer clock and only one of Synthesiser chip had disappeared. three signals was fed to CON4.
the timers is fast enough to measure This chip is closest to the Micromite We later realised that all these func-
the 40MHz signal from the VCO. That header on the PCB and we had laid tions could be done inside IC2, which
pin just happens to coincide with the a short ground trace between them. would also allow for more frequency
serial console transmit function. We realised that Altium Designer options for CON4. Since we had to
So we had to use the touchscreen thinks it’s smarter than us; it saw that revise the board to get IC2 to work
to display debugging messages. there were two diferent ground paths properly, we eliminated the two extra
That meant we couldn’t see BASIC between those pins and decided to ICs at the same time.

Practical Electronics | October | 2019 21


We came up with an easy way to do code to display information and pro- adjustment interval can be changed
this accurately. Rather than letting the cess user input is quite involved and, too. Longer adjustment periods mean
16-bit timer roll over at 65,536 as it including font data, takes up about half more data is available to perform a
would normally (ie, after 216 pulses), of the BASIC source code. more accurate adjustment, but it will
we set it to roll over after 62,500 pulses. There are nine distinct interface take longer to settle.
Then, each time it rolls over, we in- screens, each quite different. The main
crement another counter and once it overview page has five buttons, one to Physical construction
reaches 320, that means that 20 million access the ‘Settings’ page, one for the Like many of our Micromite projects
pulses (62,500 x 320) have occurred. ‘Status’ page and one each to set up the that use the Micromite LCD BackPack
So we only need to determine three outputs. The current frequencies V2 board, the Programmable GPS
whether to toggle the state of pin 22 at CON2, CON3 and CON4 are also Frequency Reference is designed to fit
right at the start of the interrupt handler displayed on this screen. into a UB3 jiffy box, making for a very
routine, and since the delay will be the The output settings screen allows compact piece of test equipment.The
same each time, the duty cycle will be one of four preset frequencies to be BNC connectors project out the side of
exactly 50% and the frequency will be loaded, or custom frequencies to be the box, with the front panel dedicated
exactly locked to the VCO. programmed, either using the auto- to the touchscreen.
The TIMER1 interrupt handler also matic search algorithm or by manu- Building this project is not par-
increments a 64-bit counter by 62,500 ally setting the N, M and P divider ticularly difficult, although there are
each time it is called. Then, when a values. A long press on one of the a number of SMD parts. This is be-
1pps pulse from the GPS module is preset buttons allows the current out- cause IC2 is only available in an SMD
detected on pin 21, the TIMER1 value put frequency value to be stored in a (TSSOP) package, and we would have
is added to this counter and that forms preset, while a short press loads that had to use a significantly larger box
the timestamp, which is stored in a frequency immediately. if we had used mostly through-hole
circular buffer. The settings page allows the presets parts. Except in the case of IC2, where
The intervals between these time to be copied between the various out- we had no choice, we have selected
stamps are then fed into an algorithm puts. The characteristics and response mostly easy-to-solder (larger) SMDs.
to determine whether to adjust the VCO of the temperature controller and The oven is made from just a few
frequency, and if so, in which direction VCO adjustment algorithm can also commonly available parts and does
and by how much, to keep it running at be changed. not take long. A few holes need to be
exactly 40MHz, or as close as is possible. The VCO’s control voltage can be drilled and cut into the plastic case,
changed manually, so you can di- but once you have built the PCBs, the
User interface rectly adjust the VCO frequency if you rest is pretty easy.
As is usually the case with projects have access to a high-precision fre- We’ll get into the construction and
using a complex touch interface, the quency reference for calibration. The operating details in Part 2, next month.

STEWART OF READING
17A King Street, Mortimer, near Reading, RG7 3RS
Telephone: 0118 933 1111 Fax: 0118 933 2375
USED ELECTRONIC TEST EQUIPMENT
Check website www.stewart-of-reading.co.uk
Fluke/Philips PM3092 Oscilloscope HP 54600B Oscilloscope
(ALL PRICES PLUS CARRIAGE & VAT)
2+2 Channel 200MHz Delay TB, Analogue/Digital Dual Trace 100MHz
Autoset etc – £250 Please check availability before ordering or calling in
Only £75, with accessories £125
LAMBDA GENESYS PSU GEN100-15 100V 15A Boxed As New £400 Marconi 2305 Modulation Meter £250
LAMBDA GENESYS PSU GEN50-30 50V 30A £400 Marconi 2440 Counter 20GHz £295
IFR 2025 Signal Generator 9kHz – 2.51GHz Opt 04/11 £900 Marconi 2945/A/B Communications Test Set Various Options POA
IFR 2948B Communication Service Monitor Opts 03/25 Avionics POA Marconi 2955 Radio Communications Test Set £595
IFR 6843 Microwave Systems Analyser 10MHz – 20GHz POA Marconi 2955A Radio Communications Test Set £725
R&S APN62 Syn Function Generator 1Hz – 260kHz £295 Marconi 2955B Radio Communications Test Set £800
Agilent 8712ET RF Network Analyser 300kHz – 1300MHz POA Marconi 6200 Microwave Test Set £1,500
HP8903A/B Audio Analyser £750 – £950 Marconi 6200A Microwave Test Set 10MHz – 20GHz £1,950
HP8757D Scaler Network Analyser POA Marconi 6200B Microwave Test Set £2,300
HP3325A Synthesised Function Generator £195 Marconi 6960B Power Meter with 6910 sensor £295
HP3561A Dynamic Signal Analyser £650 Tektronix TDS3052B Oscilloscope 500MHz 2.5GS/s £1,250
HP6032A PSU 0-60V 0-50A 1000W £750 Tektronix TDS3032 Oscilloscope 300MHz 2.5GS/s £995
HP6622A PSU 0-20V 4A Twice or 0-50V 2A Twice £350 Tektronix TDS3012 Oscilloscope 2 Channel 100MHz 1.25GS/s £450
HP6624A PSU 4 Outputs £400 Tektronix 2430A Oscilloscope Dual Trace 150MHz 100MS/s £350
HP6632B PSU 0-20V 0-5A £195 Tektronix 2465B Oscilloscope 4 Channel 400MHz £600
HP6644A PSU 0-60V 3.5A £400 Farnell AP60/50 PSU 0-60V 0-50A 1kW Switch Mode £300
HP6654A PSU 0-60V 0-9A £500 Farnell XA35/2T PSU 0-35V 0-2A Twice Digital £75
HP8341A Synthesised Sweep Generator 10MHz – 20GHz £2,000 Farnell AP100-90 Power Supply 100V 90A £900
HP83630A Synthesised Sweeper 10MHz – 26.5 GHz POA Farnell LF1 Sine/Sq Oscillator 10Hz – 1MHz £45
HP83624A Synthesised Sweeper 2 – 20GHz POA Racal 1991 Counter/Timer 160MHz 9 Digit £150
HP8484A Power Sensor 0.01-18GHz 3nW-10µW £75 Racal 2101 Counter 20GHz LED £295
HP8560E Spectrum Analyser Synthesised 30Hz – 2.9GHz £1,750 Racal 9300 True RMS Millivoltmeter 5Hz – 20MHz etc £45
HP8563A Spectrum Analyser Synthesised 9kHz – 22GHz £2,250 Racal 9300B As 9300 £75
HP8566B Spectrum Analsyer 100Hz – 22GHz £1,200 Solartron 7150/PLUS 6½ Digit DMM True RMS IEEE £65/£75
HP8662A RF Generator 10kHz – 1280MHz £750 Solatron 1253 Gain Phase Analyser 1mHz – 20kHz £600
Marconi 2022E Synthesised AM/FM Signal Generator 10kHz – 1.01GHz £325 Solartron SI 1255 HF Frequency Response Analyser POA
Marconi 2024 Synthesised Signal Generator 9kHz – 2.4GHz £800 Tasakago TM035-2 PSU 0-35V 0-2A 2 Meters £30
Marconi 2030 Synthesised Signal Generator 10kHz – 1.35GHz £750 Thurlby PL320QMD PSU 0-30V 0-2A Twice £160 – £200
Marconi 2023A Signal Generator 9kHz – 1.2GHz £700 Thurlby TG210 Function Generator 0.002-2MHz TTL etc Kenwood Badged £65

HP33120A Function Generator 100 microHz – 15MHz £350


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

22 Practical Electronics | October | 2019


Exclusive offer

Win a Microchip PIC-IoT WG


Development Board
Practical Electronics is offering its readers the chance The kit board is supported by the MPLAB X Integrated
to win a Microchip PIC-IoT WG Development Development Environment (IDE) and MCC rapid
Board (AC164164). prototyping tool. The board is compatible with
The PIC-IoT WG Development Board more than 450 MikroElektronika Click boards
combines a powerful PIC24FJ128GA705
MCU, an ATECC608A CryptoAuthenti-
Worth that expand sensors and actuator options.
As part of Microchip’s extended partner-
cation secure element IC and the fully $29.00 ship with Google Cloud, the PIC-IoT WG
certified ATWINC1510 Wi-Fi network Development Board enables PIC MCU
controller, which provides the most
(approx £23.25) designers to easily add cloud connectivity to
simple and effective way to connect em-
bedded applications to the Google Cloud
each next-generation products using a free online
portal at www.PIC-IoT.com. Once connected,
IoT Core. The board also includes an on- developers can use Microchip’s MPLAB Code
board debugger and requires no external Configurator (MCC) rapid development tool to
hardware to program and debug the MCU. develop, debug and customise their application.

Free-to-enter competition

Microchip PIC-IoT WG Development Board

How to enter June 2019 winner


For your chance to win a Microchip PIC-IoT WG Steve Wilson
Development Board, enter your details in
the online entry form at: He won a Microchip
LAN7430 PCIe 3.1 Ethernet
http://page.microchip.com/PE-PIC-IoT-WG-Board.html Bridge Evaluation Board
worth £45.50
Closing date
The closing date for this offer is 31 October 2019.

Practical Electronics | October | 2019 23


ONE FOR MODEL RAILWAY ENTHUSIASTS

DIGITAL COMMAND CONTROL


PROGRAMMER for DECODERS
by Tim Blythman

DCC – Digital Command Control – is a widely-used method for controlling


model railways, especially when running multiple locos/trains on the same
track(s). This DCC programmer is simple, cheap and easy to build – and
operates from a computer’s USB port.

is a great innovation, and each locomotive also needs a de- We have also designed the shield

DCC allowing many model


locomotives to be
addressed and operated independently
coder. Usually, even the simplest base
stations include the option to program
decoders, but this can be a bit fiddly to
to be compatible with the DCC++
Arduino software. DCC++ is an open-
source hardware and software system
on the same track at the same time. It use and can interfere with the opera- for the operation of DCC-equipped
has been embraced as a standard by tion of other trains on the ‘main line’. model railroads; see: https://github.
the NMRA (National Model Railroad In this article, we describe how to com/DccPlusPlus/
Association, based in the US), so build a standalone programmer based When programmed with the
equipment from different manufacturers on an Arduino microcontroller mod- DCC++ software, the programmer can
can inter-operate without issue. And ule with a custom shield. be used with the Java Model Railroad
since the standards are public, anybody It connects to a computer USB port Interface (JMRI), which provides a
can create DCC-compatible devices. to provide a convenient interface for way to control DCC-based model
But the big downside to DCC (es- programming. It allows you to read trains from a computer. Its most rel-
pecially for beginners) is the cost of a and write the Configuration Variables evant functions for this project are the
base station. Even the cheapest base (CVs) on DCC rolling stock, customis- ability to load and save locomotive
stations cost several hundred pounds ing their operation and performance. (decoder) configurations.

24 Practical Electronics | October | 2019


There is also another graphical user using a low-cost, standard 556 dual
interface (GUI) which is compatible
with DCC++, written in the ‘Process-
timer IC. This IC is basically two 555
timers together in a 14-pin package.
Why DCC?
ing’ language. See the DCC++ web The outputs on the 556 can deliver If you’re running more than one loco/
page for details. up to 200mA at 500kHz, so it is per- train on a layout, the only logical way to
As well as being able to use the fectly suitable for this project. do it is with DCC, which gives control to
DCC++ software, we have written a The Arduino module generates the each one without affecting any other(s).
small Arduino program which allows DCC signals with the correct timing, And because the power and control
CVs to be read and written via com- which the 556 converts into the correct signals are separate, the locos are still
mands on the Arduino Serial Monitor. voltage levels. We’re also using a cur- powered even when not moving, so
You don’t need JMRI or DCC++ to use rent sense (shunt) resistor so that the their lights and any sound effects can
it in this mode. Arduino can detect how much current still be operated.
the attached locomotive is drawing. The downsides of DCC are mostly to
DCC hardware interface The DCC decoder can send data do with the cost and there is also the
A typical DCC system requires 12- back to the programmer by varying additional complexity of adding decod-
15V to operate (see the two-page end its current draw. It sends a response ers to your locomotive.
panel for an explanation of how DCC by briefly drawing at least 60mA from DCC allows manual control over each
works). You can power an Arduino the tracks. This is important, as it is train, just as you normally have with a
from a voltage in this range, but it the only way to read data back from normal controller – but DCC has the
isn’t necessary; we’re using a small the decoder. big advantage of being able to take its
boost regulator module so that you operating commands from a computer,
can also run it off a 5V USB supply. In Circuit description allowing completely automated model
this case, the boost regulator provides Fig.1 shows the circuit of the DCC Pro- layouts, if you wish.
the 12-15V DC to power the tracks and grammer. It’s based around dual 556 This is especially useful in larger
DCC decoder(s). timer IC1 and boost converter MOD1. layouts. DCC also allows automatic
The DCC signal is a square wave at Pins 4 and 10 of IC1 are the reset point switching, level crossing boom
several kilohertz and the locomotive/ inputs of the two timers and the timer gates control and so on, obviously with
decoder could draw a few hundred outputs are disabled if these pins are suitable motors.
milliamps, so our programmer needs low. They are held low initially by the The Java Model Railroad Interface
to be capable of rapidly switching the 1kΩ resistor from pin 10 to ground, (JMRI) software mentioned in the text
track voltage and supplying sufficient so output pins 5 and 9 are low. These allows control over all these functions.
current. Luckily, this can be achieved pins connect to either side of the

Reproduced by arrangement with


SILICON CHIP magazine 2019.
www.siliconchip.com.au

Fig.1: besides the Arduino


itself, the other components
are mounted on a plug-in
shield. It’s based around
dual timer IC1, which acts
as two power inverters with
some built-in logic circuitry,
forming a basic low-power
full-bridge driver under the
control of the Arduino. DC/
DC boost converter MOD1
provides the ~13V DC
supply for IC1 when
the Arduino is running
from a 5V USB supply. Digital Command Control Decoder Programmer

Practical Electronics | October | 2019 25


track, via CON6 (a header socket) or Therefore, the result is a voltage analogue pins. Rather than make these
CON7 (terminal block), depending on across that 2.2Ω resistor. fixed, and risk interfering with the
which suits you best. That voltage is fed to CON5 via a 1kΩ function of any other shields plugged
So when both timers are in reset series resistor and on to one of the Ar- into the Arduino, all three pins can
and both outputs are low, there is no duino’s analogue, pins where it feeds be selected using jumper shunts for
voltage across the track. The enable the internal 10-bit analogue-to-digital maximum flexibility.
signal from the Arduino is fed to CON3 converter (ADC) and is converted into The digital pins are selected by
so when this goes high, the reset input a digital value in the range of 0-1023 placing one jumper between CON1
at pin 10 is pulled high via the 100Ω by the software. The combination of and CON2 (for the polarity signal)
series resistor. the 10-bit ADC and the 2.2Ω current- and another between CON1 and CON3
Schottky diode D1 is then reverse- sense resistor means the resolution of (for the enable signal). By default, our
biased, so that the other reset input this reading is around 2mA. software is set up to use digital output
at pin 4 can also be driven high by JP1 is a three-pin header which D5 for the polarity signal and D11 for
the Arduino, via CON2 and its 10kΩ allows you to choose whether the the enable signal, but you can change
series resistor. voltage fed to the 556 IC is from the the software if you place the jumpers
The trigger input of the first timer Arduino’s DC input socket (via the in other locations.
(pin 6) is pulled to ground while the VIN pin) or from MOD1, an MT3608 Similarly, the analogue pin is se-
threshold input of that same timer 2A boost DC/DC converter module. If lected by connecting a pin on CON4 to
(pin 2) is tied to VCC (pin 14), so its you are powering the Arduino from a the associated pin on CON5 and by de-
output at pin 5 is high by default. 12V plugpack, then you can put JP1 fault, we’re using analogue input A1.
However, if the pin 4 reset input is in the VIN position, so the plugpack
held low by the Arduino (via CON2), provides the track voltage. The software
then this timer is in its reset state, so But if you are powering the Arduino The primary job of the software is
output pin 5 is low. Therefore, during from a computer or a 5V USB charger, to produce a signal across the tracks
operation, the output at pin 5 follows this voltage is not sufficient to power which carries the required DCC pack-
the signal at pin 4. the tracks. In this case, you can place ets. It does this using an interrupt
Output pin 5 is also connected to JP1 in the VOUT+ position and adjust software routine (ISR) which is trig-
the trigger input of the second timer, the trimpot on the MT3608 module to gered every 58µs by a timer. 58µs is
at pin 8, while that timer’s threshold provide 13V to IC1. the half-period of a ‘1’ bit.
input (pin 12) is also tied to VCC. So While not vital, as MOD1 has on- To send a ‘1’ bit, we toggle the DIR
output pin 9 is low when output pin board bypass capacitors, the shield pin each time the interrupt fires. To
5 is high and vice versa, and thus the has provision for 100µF input bypass send a ‘0’, we should ideally have a
second timer operates as an inverter and output filter capacitors. We rec- half-period of 100µs, but 116µs (2 x
once it is enabled. ommend that you fit the input bypass 58µs) is within the limits that are rec-
Thus, when IC1 is enabled, there is capacitor, but leave the output filter ognised by the decoder. So we merely
always a voltage across the track, with capacitor off (as described in the Con- wait for two timer interrupts to occur
the magnitude being close to VCC and struction section). before toggling the DIR pin to transmit
the polarity depending on the signal There is also an onboard 6.8Ω re- a zero bit.
from CON2. sistor between the 5V supply and the The interrupt handler steps through
A 2.2Ω resistor between IC1’s ground module’s VIN+ terminal, to reduce the DCC data array as each bit is trans-
pin and the main circuit ground is the inrush current from the 5V sup- mitted, then sets a flag to indicate that
used to sense the current flowing ply when it is first connected and to the complete packet has been sent and
between the track connections. limit the maximum current drawn moves onto the next packet. Thus,
Irrespective of the direction of during operation (eg, if the tracks are most of the real work is done inside
current flow through the track con- accidentally shorted). the interrupt routine.
nections, that current must ultimately The shield is driven using two of the During most programming sequenc-
always flow back through IC1 and Arduino’s digital pins and feeds the es, the programmer sends several
then to the power supply ground. current-sense voltage back to one of the reset packets to the loco, followed by

The stand-alone Arduino program has a very simple This is the Simple CV Programmer interface in DecoderPro,
interface, and allows direct reading and writing of CVs. This and it allows CVs to be directly written and read. Using the
is sufficient to fully manipulate any parameters, but may Roster feature allows the locomotive to be given a name, and
not be as intuitive as the advanced roster settings available CVs to be saved to a configuration file, as well as grouping the
with DecoderPro. CVs into logical groups.

26 Practical Electronics | October | 2019


Fig.2: use this PCB overlay
diagram and the photo at
right as a guide when
building the shield.
Make sure that MOD1 is
oriented correctly, with
its VIN pins towards the
electrolytic capacitor. IC1,
D1 and the electrolytic
capacitor are also
polarised. The jumper
locations shown here suit
our sketch as well as the
DCC++ code, when being
used as a DCC programmer.

multiple ‘write’ packets, and this is You can now fit the 100µF input by- shields on top of this board. Either
accomplished by placing the appro- pass capacitor for MOD1. This should way, make sure the long pins project
priate commands in the array to be be laid over on the PCB so that you out the bottom of the board. You need
transmitted. can later stack another shield on top to solder the stackable headers care-
The detection of acknowledge- if you need to. Make sure its positive fully to avoid getting solder on the
ment pulses from the loco is done (longer) lead goes in the pad nearest pins except near where they connect
by continually sampling the voltage the adjacent edge of the PCB. to the pads.
across the current sense resistor, at Next, solder in pin headers CON1- Note that the stackable headers give
the selected Arduino analogue input. CON6 and JP1 where shown. You more clearance for the components
The quiescent sample value is used as can then fit MOD1, by first soldering on the board underneath (eg, the Ar-
a baseline value. If an acknowledge- four component lead off-cuts to the duino). If you use standard headers,
ment is expected, the current sample pads so that they stick out the top of you may find that CON7’s pads short
is compared with the baseline and if the board, then lowering MOD1 over to the shield of the USB connector
the threshold is reached, a flag is set those leads and soldering them to the below, which is connected to ground.
indicating an acknowledgement has pads on the top of the module. You
been received. can then trim off the excess lead length Adjusting MOD1’s output voltage
As well as being able to use the on top of MOD1 and on the underside Before installing IC1, you must ad-
DCC++ software, we provide a basic of the PCB. just MOD1’s output voltage. Plug the
serial terminal interface. This allows Now solder CON7 to the board, shield into your Arduino board and
you to send DCC commands straight making sure it has been pushed then apply power.
to the locomotive, assuming that you down so it is sitting correctly on top Use a DMM set to measure DC volts
know what is required. These are of the PCB and its wire entry holes to probe the VOUT+ and VOUT– pads
inserted into the array of packets to are facing towards the outside edge on MOD1. Adjust its onboard trimpot
be sent, but they are not transmitted of the board. screw to get a reading just below 15V;
until you indicate that they are ready. Fit the Arduino headers next. We’ve counter-intuitively, the voltage is
The software then sets a flag to start specified stackable headers but you decreased by turning the adjustment
the transmission. could potentially use standard head- screw clockwise. We set our track volt-
ers if you don’t plan to attach any age to 13V, and it works well.
MOD1 is optional
We are using boost regulator MOD1
for convenience, so that you can run
the programmer off a 5V USB supply. Parts list –
However, if you plan to power the
Arduino from a 12-15V DC supply,
Arduino DCC Decoder Programmer
you could omit MOD1. In this case, 1 double-sided PCB, code 09107181, 68.5 x 53.5m
you would need to place JP1 in the 1 set of Arduino stackable headers (1 x 6-pin, 2 x 8-pin, 1 x 10-pin)
‘VIN’ position. Keep that in mind as 1 Arduino Uno or equivalent
you assemble the shield. 1 MT3608 2A boost module [Banggood ID: 1213134]
3 14-pin headers (CON1-CON3)
Construction 2 6-pin headers (CON4,CON5)
The DCC Programmer Shield is built 1 2-pin female header socket (CON6)
on a PCB measuring 68.5 x 53.5mm 1 2-way terminal block, 5/5.08mm pin spacing (CON7)
(the size and shape of a standard Ar- 1 3-way pin header (JP1)
duino shield) and coded 09107181, 4 jumper shunts/shorting blocks
available from the PE PCB Service – see Semiconductors
page 78. Use the overlay diagram in 1 556 dual timer IC (IC1)
Fig.2 as a guide during construction. 1 1N5819 1A schottky diode (D1)
Fit the smaller resistors first, con-
firming the values with a DMM before Capacitors
soldering each in place. Follow with 1 100µF 25V electrolytic
diode D1, taking care to orient it as Resistors (all 0.25W, 1% unless otherwise stated)
shown in Fig.2. Then install the two 1 10kΩ 3 1kΩ 1 100Ω 1 6.8Ω 1W 5% 1 2.2Ω 1W 5%
larger 1W resistors.

Practical Electronics | October | 2019 27


You can then remove The DCC++ software also
power, unplug the shield and uses a serial interface, so
fit IC1, ensuring that its pin 1 you can use the serial moni-
notch faces into the middle tor to examine its output.
of the board, as shown in The DecoderPro program
Fig.2. You could potentially has the option to use a
use a socket, but given that DCC++ programmed Uno,
the IC is supplying signifi- so our reprogrammed board
cant current to the tracks, it’s can now be used with Deco-
better to avoid that. derPro. JMRI is available for
Now fit the jumpers to Windows, Mac and Linux
select your desired track (including a Raspberry Pi
voltage source and to config- version). However, note
ure which Arduino pins are that you need to have Java
used for control. If you are installed to use it.
unsure, insert the jumpers Now, get JMRI from:
in the positions shown in http://jmri.sourceforge.net/
Fig.2. The shield assembly download/index.shtml and
is then complete. The DCC programmer shield mounts open the DecoderPro program. Go
on top of the Arduino UNO board, as to the Edit → Preferences menu and
Software setup and testing seen here. under Connections, choose DCC++
Now you need to upload the Arduino as System Manufacturer and DCC++
sketch code to the board. This is done either CON6 or CON7 and type ‘r1’ Serial Port as System connection.
using the free Arduino IDE (integrated in the Serial Monitor, followed by Ensure the Serial port matches that
development environment). It is the Enter key. of the Uno.
available for Windows, macOS and If everything is working, you should Save the configuration and close
Linux. The IDE is used to compile and see some text appear on the Serial DecoderPro so that it can reload the
upload the software to the Arduino. Monitor indicating the locomotive’s new settings. Open DecoderPro again
You can download this software from: short address (CV 1). Other CVs can be and under Edit → Preferences choose
www.arduino.cc/en/Main/Software written to and read from with simple defaults, and ensure that DCC++ is se-
Now download the software pack- commands like this. To write a CV, lected for Service Programmer. Unless
age from the October 2019 page of the use the format w1:3 That command you have other hardware, you should
PE website. This contains a ‘stand- writes the value 3 to CV 1. select DCC++ for all options.
alone’ Arduino sketch called DCC_ Save, close and reopen DecoderPro
Programmer_Shield_V2, which is the Using it with DCC++ and JMRI again. Click the red power button and
easiest way to test your shield. Before DecoderPro ensure that it turns green. You should
you can use this sketch, you need to If you want to run DCC trains from see ‘Service Mode Programmer DCC++
install a library called TimerOne. a computer, you can use the open- Is Online’ in the bottom left corner of
TimerOne can be installed from the source JMRI software. It comes with the screen.
IDE’s Library Manager (Sketch menu DecoderPro, which has a compre- Now use the Actions → Single CV
→ Include Library → Manage Librar- hensive ‘Roster’ feature which can be Programmer menu option to open the
ies…). Open the Library Manager and used to save and restore locomotive Simple Programmer window. This
search for TimerOne and then when programming parameters. window allows you to read and write
you find it, select it and click the ‘In- If you have a fleet of similar locomo- single CVs via a basic interface.
stall’ button. tives, this is a convenient way of man- If you find you are getting the ‘No
In case you have trouble with that aging their various performance CVs. acknowledge from locomotive’ error
method, we also include a zipped So that our Programmer can operate then the threshold that DCC++ uses
copy of the library in the sketch down- with JMRI, we can use the open-source for detecting acknowledge pulses
load package. This can be installed DCC++ Arduino sketch. This was de- from the track may need to be ad-
using the Sketch → Include Library → signed to work with other hardware, justed. This is a parameter in the
Add .ZIP Library menu option. but our shield has been designed to be DCCpp_uno sketch.
Now extract and open the DCC_ compatible with that hardware, so you Close DecoderPro (so that it no
Programmer_Shield_V2 sketch from can run DCC++ on it without making longer has control over the Arduino)
the download package; eg, using the any modifications. and navigate to the ‘PacketRegister.h’
IDE’s File → Open menu option. Con- Our software download package tab in the DCCpp_uno sketch. Near
nect the Uno to your computer and for this project includes the DCC++ line 20, there is a value called ACK_
select the ‘Uno/Genuino’ option from software. To use it, extract and open SAMPLE_THRESHOLD which is 30
the Tools → Board menu. the DCCpp_uno sketch. Then check by default. We found that reducing
Also, check that the correct COM the ‘Config.h’ tab and make sure that this to 12 gave consistent results with
port listed under the Tools → Port this line is set correctly: three different decoders.
menu matches the one assigned to Save the sketch with the changes,
your Uno board. #define MOTOR_SHIELD_TYPE 0
then upload it to the Arduino board
Select the Upload option under You need to set up the jumpers on again. Ensure that the Serial Monitor
the Sketch menu and then open the CON1-CON5 for your shield to match is closed before reopening Decoder-
serial monitor (Tools → Serial Moni- those shown in the overlay diagram in Pro and try the Single CV Programmer
tor) at 115,200 baud. You should get Fig.2. This configuration is required option again.
a message describing how to use the to emulate this motor shield type. While the default value of 30 cor-
sketch. If you have a DCC locomotive, Upload the sketch to the Uno board, responds to the specified value of
place it on a length of track wired to as described above. 60mA for the acknowledge pulse,

28 Practical Electronics | October | 2019


OVERLEAF I I I I I I I I I I I I I I I I I I
HOW DCC WORKS

the DCC++ sketch also applies some smoothing to the without the need for an external power source. It’s suit-
sensed current, so this may change the actual detected able for motors drawing up to about 2W. Note that your 5V
current threshold. supply must be able to deliver enough current.
To use the Roster feature, click the ‘New Loco’ button
in the top left corner of the main DecoderPro window. Useful links
Click ‘Read type from decoder’ and DecoderPro will read Setting up DCC++ with JMRI DecoderPro:
a number of the CVs to identify parameters such as the https://github.com/DccPlusPlus/BaseStation
manufacturer. If this does not work, you can also choose
Roster → Create entry to enter this manually. DCC Standards Page:
Once a Roster entry has been created, double-click it http://bit.ly/pe-oct19-nmra
to open the Comprehensive Programmer, allowing more
detailed and complex programming to occur.
JMRI is a vast program with many features and we can’t
pretend that we’ve covered a fraction of them here. There
is comprehensive documentation online.
The article at: http://bit.ly/pe-oct19-decpro introduces
DecoderPro and is a good place to start.
JMRI also has a layout editor (PanelPro) so that you
can create track diagrams and these can be animated
with information from the layout if you have the correct
sensors installed.

Other uses for this project


You may not think that having a DCC Programmer is all
that useful, but this device can also be used as a minimal
DCC base station. With the DCC++ software, the Program-
mer can act as a low-power booster. JTAG Connector Plugs Directly into PCB!!
If you set the board jumpers for EN on pin D3, DIR on No Header! No Brainer!
pin D10 and Current Sense on A0 then the DCC++ sketch
can use the Programmer as its ‘main line’ output.
This means that the output can be connected to some
track and DecoderPro’s throttle window can be used to
control a DCC decoder-equipped locomotive.
Because its current capacity is limited, you’re not going
to be running a fleet of trains, but it could be handy for
testing and experimentation.
In our trials, we found a small H0-scale locomotive Our patented range of Plug-of-Nails™ spring-pin cables plug directly
was able to be driven at low speed, including operating into a tiny footprint of pads and locating holes in your PCB, eliminating
the lights. the need for a mating header. Save Cost & Space on Every PCB!!
Solutions for: PIC . dsPIC . ARM . MSP430 . Atmel . Generic JTAG . Altera
Xilinx . BDM . C2000 . SPY-BI-WIRE . SPI / IIC . Altium Mini-HDMI . & More
What about driving a small motor?
Another possible use for this shield is as a small 12V
motor-driver board. If you need to drive a small 6-15V
www.PlugOfNails.com
DC motor using USB power or some other source of 5V Tag-Connector footprints as small as 0.02 sq. inch (0.13 sq cm)
then this shield can be used as a reversible motor driver,

Practical Electronics | October | 2019 29


How DCC works
I
f you are not a model railway The DCC signal is a square wave The peak frequency of this signal is
enthusist, DCC’s advantages may with a 50% duty cycle and varying around 8kHz, which is higher than the
not be obvious. To understand why pulse width. The data is encoded in the 5kHz that the widely-used L293 full-
it’s so useful, we’ll explain how model pulse widths, while the square wave, bridge motor driver IC can deliver. So
railway systems worked before DCC. once rectified, provides DC power for DCC base stations designed around the
For a standard DC model railway, a the decoder, motor, lights and so on. L293 IC probably won’t work reliably.
single locomotive is fed power through The track voltage is typically 30V
the tracks, with one rail being negative peak-to-peak, with cycle times of DCC protocol
and the other positive. Varying the av- around 100µs. A typical DCC base sta- The bitstream is broken up into pack-
erage voltage between the rails changes tion consists of a microcontroller feed- ets, with each packet containing one
the loco’s speed, while swapping the ing an H-bridge of some sort, usually command, for tasks such as setting
rail polarities reverses its direction of with some form of current detection the motor to a particular speed or
travel. A typical H0-scale locomotive to shut it down in the event of a short turning a light on and off. The loco’s
(1:87 scale) runs from 12V DC, drawing circuit. With exposed conductors in state is stored by the decoder and
from a few hundred milliamps up to the form of rails, it’s bound to happen kept consistent until it is updated by
an amp or so. sooner or later. a future packet.
Such a system only allows a single A simplified circuit diagram of a There are also dedicated program-
locomotive to be controlled, as mul- typical DCC decoder is shown in Fig.3. ming commands that set configuration
tiple locomotives would receive the This shows some of the circuitry to values (CVs) in non-volatile EEPROM.
same track voltage. And direct control drive two lamps (eg, headlight and These values are used to determine
of accessories such as headlights, marker LEDs) as well as the motor. which address the locomotive re-
steam or sound effects is not possible. The DCC protocol encodes a binary sponds to, how the speed changes
With clever use of diodes, it’s possible 1 as a pulse that is nominally 58µs high with throttle position and how lights
to have directional headlights, but a and 58µs low, with a binary 0 having and other accessories react to inputs.
battery is still needed for lights if the high and low periods that are 100µs or It’s these CVs that our programmer is
locomotive is stopped, as there is no longer (see Fig.4). Because the locomo- designed to read and modify.
voltage on the track. tive can be placed on the track either Each valid packet starts with at least
The most common way to allow forwards or backwards, the absolute 14 sequential ‘1’ bits. This is referred
multiple locomotives to operate is polarity cannot be determined, so the to as the ‘preamble’, and allows the
to divide the track into individual high pulse may come before or after decoder to synchronise itself with the
‘blocks’ or sub-circuits, which can be the low pulse. start of the data packet, which is indi-
switched between controllers. As you Fig.5 shows what these ‘0’ and ‘1’ cated by the first following ‘0’ bit. The
can imagine, the switching rapidly bit pulses look like when they are data for the first byte of the command
becomes very complicated as the track arranged back-to-back, forming a con- (which is an address) follows this,
layout expands or more controllers tinuous AC waveform. with all bytes sent most-significant-bit
are added. While the standards are specific as (MSB) first (see Fig.6).
DCC transmits both power and to what should and should not be ac- Subsequent bytes are prefixed
control signals using the tracks. cepted as valid data, merely sampling with a zero bit, so each byte transfer
The locomotive’s onboard decoder the ‘high’ period of adjacent bits is requires nine bits to be sent. The last
interprets the control signals and sufficient to decode the bitstream, byte to be transmitted is the afore-
commands the motors, lights and and in any case, each command has mentioned checksum byte.
other accessories. Power is supplied a checksum byte, so errors caused by After this, a ‘1’ bit is sent, indicat-
continuously, allowing accessories timing inaccuracies can be detected ing that the packet is complete. The
to operate even while the locomotive and the corrupt command ignored. final ‘1’ can also count as the start of
is stationary. Beyond lights, features
such as smoke generators and sound
effects modules are quite common (if
not especially cheap).

Fig.3: a simplified version of a typical


DCC decoder circuit, showing the
bridge rectifier and filter capacitor
used to convert the AC voltage on
the tracks to a DC voltage, with the
raw track signal also being fed to
the micro so it can be decoded. The
micro then controls the H-bridge
motor driver transistors, lamps, sound
effects module and other accessories.

® – Registered DCC trademark of the


National Model Railroad Association (US).

30 Practical Electronics | October | 2019


Fig.4: in a DCC
system, the voltage
across the tracks
has a more-or-less
constant magnitude,
but its polarity is
continuously reversing,
creating a 5-8kHz
square wave.
This is rectified by the
DCC decoder(s) and is
used as a power source www. poscope. com/ epe
for their logic circuitry
as well as driving
motors, lights, audio station is equivalent to asking ‘is this
amplifiers... but the bit of this configuration variable set?’,
frequency modulation to which the decoder replies either
also encodes digital with an acknowledgement or not.
commands, addressed The acknowledgement is per-
to individual locos. formed by the decoder by placing
a load of 60mA or more across the
the next preamble if packets are sent tracks for 6ms. In practice, this is
back-to-back. usually done by the decoder briefly
Since each byte in the packet is powering the motor, often resulting
separated by a ‘0’ bit, the only place in the locomotive inching forwards
that more than eight ‘1’ bits can appear during programming.
in a row in a valid DCC sequence is The acknowledgement is one of two
in the preamble, so decoders can’t be reasons why programming usually
fooled into thinking a new packet is occurs on a dedicated programming
starting in the middle of a valid packet. track. First, it would be difficult to
Each packet is a minimum of accurately detect the acknowledge- - USB - PWM
three bytes, so the minimum packet ment pulse in the presence of other - Ethernet - Encoders
transmission length is 40 bits, giving loads (such as other locomotives) on - Web server - LCD
- Modbus - Analog inputs
a minimum packet time of just over the rails.
- CNC (Mach3/ 4) - Compact PLC
5ms. So it’s possible to send close to Second, many programming pack- - IO
200 commands per second using DCC. ets are broadcast to all decoders on
Once the decoder has received a the track. So the only way to guaran-
packet and the checksum is correct, it tee that only the correct locomotive
checks the address byte. If it matches receives the programming packets is
the address stored in the decoder’s to have a dedicated section of track
EEPROM, it can act on the command for programming.
and if necessary, send a response. The DCC standards are very detailed
That is generally only necessary and make for interesting reading. It
for programming commands, as the could potentially be used in situations
programmer needs a way to read the other than model railways, where - up to 256 - up to 32
microsteps microsteps
configuration from the decoder. In power and commands need to be sent
- 50 V / 6 A - 30 V / 2. 5 A
this case, the packet sent by the base and received over two wires. - USB configuration
- Isolated

PoScope Mega1+
PoScope Mega50

Fig.5: the sequences of ‘0’ and ‘1’ bit pulses are strung together to create a
continuous AC waveform across the tracks, effectively forming a frequency-
modulated square wave. The RMS voltage is very close to the peak voltage,
providing a similar voltage and current to the motors in the locos, while the
average voltage is effectively zero since the waveform is symmetrical.

- up to 50MS/ s
- resolution up to 12bit
Fig.6: this illustrates the structure of the shortest possible valid DCC - Lowest power consumption
command, containing one address and one data (command) byte. The - Smallest and lightest
preamble always consists of at least fourteen sequential ‘1’ bits and each byte - 7 in 1: Oscilloscope, FFT, X/ Y,
Recorder, Logic Analyzer, Protocol
is separated by a ‘0’ bit, with the command being terminated by a checksum decoder, Signal generator
byte (to detect errors) and then a final ‘1’ bit to indicate that there is no
further data in this command.

Practical Electronics | October | 2019 31


Keep the bitey bits out of harm’s way!

Opto-isolated Mains Relay

By Tim Blythman

If you need to switch mains voltages, say from a micro’s output or any other
low-voltage source, you need to isolate them from each other. That’s what this
project does – it’s easy to build and keeps mains voltages locked away from the
controller... and you! Virtually any low-voltage source will do – from 2.7 to 10V.

A
rduino and Raspberry Pi You can use a wide range of sensors 2015 issue – see Programmable mains
modules are popular because to decide when to switch those devices timer with remote switching.
it’s so easy to get into them, on and off; we’ve covered many easy- While simple and elegant, it’s more
even if you’re a beginner. But many to-use sensors in our ongoing cheap expensive and more work, as you need
people do not like working with electronic modules from Asia (China). to buy and modify the remote mains
mains, and with good reason – it’s switch units.
easy to create an unsafe situation if Other versions So we have designed this unit,
you don’t know better. There are some existing designs which which is simple, cheap, reliable and
Incorrect wiring or inadequate insu- do this job, but most seem to be de- able to switch just about any mains de-
lation is a hazard, not just to you, but signed for 110-120VAC mains, as used vice, up to 10A rating. You could even
to anyone who comes in contact with in the US and some other countries. connect several units to one micro to
your invention. For example, Adafruit’s PowerSwitch switch multiple devices.
This project is an ideal way of Tail performs a similar function to our
switching mains power, whether you design. You definitely wouldn’t want How it works
are a beginner or not. If you follow the to use these with 230VAC mains, as The 230V Opto-Isolated Mains Re-
instructions in this article carefully, used in Australia, Europe and else- lay uses a logic signal (eg, 3.3V, 5V or
within an hour or two, you will have where. It would probably blow up and up to 10V) and switches a mains-rated
a working – and more importantly – even if it didn’t, it wouldn’t be safe. relay on or off based on the state of
safe, mains switch. In the past, when we needed to con- that signal.
You could control a heater, light, fan, trol mains outlets using a microcon- The optical isolation ensures that
pump, television, amplifier, computer troller, we modified a 433MHz remote there is no chance that mains voltages
– just about anything that plugs into a mains switch to do the job. The last could appear on the logic input and
mains socket. time we did this was in the November cause a shock hazard, or damage the

32 Practical Electronics | October | 2019


driving circuitry. The 4N25 optocou- mains waveform, if RLY1 is latched
plers we are using have an isolation
rating of 5300V RMS.
on. CON3 can be connected between
a microcontroller digital input pin
What do you
It also has a logic signal output,
which can be used by the driving cir-
and ground so that the micro’s pin is
pulled low in this case.
use it for?
cuitry to detect whether mains power A pull-up of some sort is required Have solar panels and a pool? You can
is present and also allows the phase on that pin, to ensure its state changes use a light sensor and a real-time clock
and frequency of the mains waveform when OPTO2’s output switches off; (RTC) module to switch the pool pump
to be sensed. This output uses the same many micros have built-in pull-ups on during the day when solar power is
type of optocoupler for safety. which can be enabled in software. available, or during off-peak hours if the
An optocoupler consists of an LED That micro can also measure the weather is bad.
(usually infrared) and phototransistor frequency of the pulses from CON3 to
in a plastic package. The LED shines on determine the mains frequency (this is
the phototransistor junction through usually pretty accurate, so it could be Own a different type of pump? Use a float
an insulating clear plastic section, so used as a reference) and the transitions switch to control a pump. Turn it on when a
are near the zero crossings. storage tank is full or off when empty. Some
that the phototransistor conducts when
float switches are light duty and may fail when
the LED illuminates it. It behaves like There will be a slight phase shift
switching high currents. Using the Opto-
a transistor with separate base-emitter due to the threshold being 2V rather
isolated Mains Relay to buffer the signal from a
and collector-emitter junctions. The than 0V, but this can be compensated float switch will save its contacts from burn out
gain (called the ‘current transfer ratio’, for in software if accurate detection of
or CTR) is much lower than a stand- zero crossings is necessary.
ard transistor, so the collector current Need to control a heating/cooling
is generally of a similar magnitude to Mains power supply system? Add a temperature sensor (and/or
the LED drive current. RLY1 has a 24V DC coil because a an RTC) to build a custom thermostat.
The CTR may be above or below higher coil voltage means a lower coil
100%, depending on the particular current for the same power, and we
optocoupler used (it can vary from have limited current available to drive Own an amplifier (or other appliance)
sample to sample) and on the LED it with such a simple power supply. without a power switch? Add a remote-
current; the CTR tends to peak at a Neutral is connected directly to the controlled on/off switch to an amplifier,
few milliamps of LED drive current. circuit ground and the supply current by merely adding an IR decoder to a
Now take a look at the circuit dia- comes from the live conductor via a microcontroller module, hooking up our
gram shown in Fig.1. The control sig- 470nF X2-class capacitor, which lim- isolated relay, writing a few lines of code
nal is applied to pin header CON2. its the average current and a 150Ω se- and using a spare TV remote.
When a sufficient voltage is applied, ries resistor, which limits the inrush
current flows through the 220Ω cur- current. The resulting voltage is then
rent-limiting resistor and through rectified by a bridge rectifier compris- Unreliable Internet connection?
ing diodes D1-D4, and this is filtered Automatically reboot your router if your
OPTO1’s internal LED, which usually
internet connection goes down, using a
has a forward voltage of around 1V. So to pulsating DC using a 100µF elec-
micro board with a Wi-Fi module.
with 3.3V across CON2, around 10mA trolytic capacitor.
flows through it. A 470kΩ resistor across the X2 ca-
Assuming the 24V mains-derived pacitor discharges it when the unit is What about a wireless power switch?
power supply on the other side of the unplugged, to minimise the risk of get- Controlled by a micro or handheld remote
optocoupler is present, the phototran- ting a (small) shock from the circuit. control; just wire up a remote control receiver
sistor then acts as an emitter-follower, If you consider what happens start- to its logic-level control input (the receiver
supplying voltage to the base of NPN ing at a zero crossing, when the live needs a separate DC power supply).
transistor Q1 via a 10kΩ current-lim- voltage is rising, the right-hand side of
iting resistor. the X2 capacitor rises to around 350V
Q1 provides some gain so that suf- DC while the left-hand side is limited Or you can implement a complex light
ficient current flows through the coil to around 25V, due to zener diodes switching arrangement, with multiple light
of RLY1 to latch its armature, con- ZD1 and ZD2, which are effectively switches controlling the same set of lights.
necting pins 1 and 2 of CON1, the across the output of the bridge recti- Wire the switches to perform low-voltage
mains terminal and connecting the fier. Thus, the X2 capacitor charges signalling and then use this signal to drive
live pin of the mains output socket up to around 325V DC. the lights via the Opto-isolated Mains Relay.
to the mains input. When the live voltage starts to drop You could even use switches that are not
Diode D6 prevents OPTO1’s inter- again, current flow through this part of mains-rated, incorporate remote control...
nal LED from being reverse-biased the circuit ceases, until the live volt-
if the voltage at CON2 is reversed, age drops to around 300V DC. The
left-hand side of the X2 capacitor will You don’t even need a microcontroller to
mainly to protect against damage from
use the Opto-isolated Mains Relay. Any
static electricity. then be at about –25V and so current
logic signal, from 2.7V up to about 10V can
The outgoing live line also drives will flow through the other half of the
be used to activate the relay. This could
the LED in OPTO2 via a 100kΩ 1W bridge rectifier and the X2 capacitor come from an op amp output, logic gate,
mains-rated resistor and a simple will start to discharge. relay, switch, battery, plugpack or any other
half-wave rectifier consisting of di- It will have fully discharged when source of switched DC.
odes D7 and D8. So when the live the live voltage is around –25V and
voltage is above about 2V, D7 is then the capacitor will start to charge WARNING: this project involves mains
forward-biased and current flows in the opposite direction and the voltages which can be dangerous
through the LED in OPTO2. As a re- whole process will repeat as live if not handled correctly. Follow the
sult, current flows between the pins of reaches –350V and then starts head- instructions in this article carefully.
CON3 during the positive half of the ing back towards 0V.

Practical Electronics | October | 2019 33


LIVE
IN

LIVE
OUT L

WARNING!
Opto-isolated Mains Relay The Opto-isolated Mains Relay operates directly from the 230VAC
mains supply and contact with live components is potentially lethal.

Fig.1: the complete circuit and wiring diagram for the Opto-isolated Mains Relay. The control signal at CON2 drives the
LED in OPTO1, which switches NPN transistor Q1 to activate relay RLY1. The incoming mains live voltage is applied to
a 470nF X2 capacitor, then rectified by diodes D1-D4 and filtered by a 100µF capacitor to provide around 25V DC for the
relay coil. OPTO2 allows mains phase sensing and indicates when the load has mains power.

This process repeats continually, The second 150Ω series resistor, components in the circuit before the
maintaining the charge across the between the 100µF capacitor and fuse has a chance to blow.
100µF capacitor at around 30V, draw- relay coil, helps to prop up the coil The Opto-Isolated Mains Relay is
ing just a few milliamps from the mains. voltage for the first few milliseconds built on a PCB coded 10107181 which
after Q1 switches on, ensuring cor- measures 99 x 60mm and is available
Voltage regulation rect latching. from the PE PCB Service – see page 78.
When there is no signal at CON2 and This works because the 100µF ca- The PCB is designed to clip into the
RLY1 is off, the two zener diodes pacitor can charge to a slightly higher internal side rails of a UB3 Jiffy box,
keep the positive end of RLY1’s coil at voltage initially, due to the voltage leaving just enough room at the end of
around 24V; this is more than enough across this added resistor. the box to fit two cable glands, which
voltage to allow its armature to latch. Diode D5 protects Q1 from voltage are used to secure the mains cables.
When Q1 does pull in, it diverts spikes caused by back-EMF when Use the PCB overlay diagram, Fig.2,
some but not all of the current that RLY1 switches off; while fuse F1 as a guide during assembly.
was flowing through the zener diodes blows if there is a fault on the mains The first step is to fit the low-profile
to the relay’s coil instead. side of this circuit, or if the load goes passive devices, starting with the resis-
At 50Hz, the 470nF capacitor has short-circuit, preventing any further tors. It’s best to check the values with
an impedance (reactance) of about circuit damage. a multimeter before soldering them in
6.8kΩ, limiting the current drawn from As noted, RLY1 requires around place where shown in Fig.2.
the mains (230VAC) to around 33mA. 22mA to operate. Q1’s hFE is typical- Fit diodes D1-D8 next. Take care to
The 24V relay draws around 22mA at ly over 400, meaning a base current ensure you insert them with the cath-
24V, so the current through the zener of 55µA is needed to activate the re- ode stripe in the orientation shown in
diodes drops from around 33mA to lay. Assuming that OPTO1’s CTR is the overlay diagram. Note that D1 and
around 11mA. at least 20%, that means the driving D2 face the opposite direction to D3 and
This assumes the mains is at the circuitry needs to be able to supply D4. Then mount the two identical zener
nominal 230V. These numbers change around 0.3mA at a minimum voltage diodes. Again, ensure that the cathode
if the supply voltage changes, and so of about 2.2V, to switch on the relay. band is oriented correctly.
the extra current means the relay will Q1 is the only transistor, and it
work reliably even with mains voltages Construction should be oriented as shown in Fig.2.
slightly below 230V. As with any circuit involving mains You may need to bend and adjust the
ZD1 and ZD2 also limit the volt- voltages, it is imperative that the case legs to fit the holes on the PCB (eg, us-
age across the 100µF filter capacitor and mechanical construction are com- ing smaller pliers).
to a safe level. We have used two 12V pleted correctly to ensure the safety of The two optocouplers, OPTO1 and
zeners rather than one 24V zener be- the completed circuit. OPTO2, should be soldered next.
cause the total dissipation with RLY1 Attention to detail when build- Note that the notches on the pack-
off is not much below 1W and could be ing the PCB is critical too, as a single ages both point in towards the centre
higher if the mains voltage is elevated. reversed diode could destroy other of the board.

34 Practical Electronics | October | 2019


The PCB has been slotted to reduce
the chance of leakage between the two
halves of the board (ie, increase the
creepage distance), so we have added
a dot adjacent to the number one pin
in each case. Align this with the dot
on the optocoupler packages.
If you are going to install header ter-
minals for CON2 and CON3, now is a
good time to do so. You could instead
solder wires directly to these pads lat-
er. If you are installing the extension
pieces, fit the header terminals with
the long pins down.
Next, fit the fuse holder clips to the
board. Make sure the retention tabs are
facing towards the outside or else the
fuse will not fit. You can temporarily
install the fuse to make sure the holder
clips are placed correctly, but be care-
ful if you solder the clips with the fuse LIVE IN
in place, as the heat could damage
the fuse (eg, you could accidentally
LIVE OUT
desolder the end caps). Remove the
fuse after soldering.
Install the electrolytic capacitor
next. It is polarised, so it must be fitted
the right way around. The stripe on the
capacitor body indicates the negative
lead while the positive lead is longer.
The positive lead should go into the
pad marked with a ‘+’ sign. We have
specified a 50V capacitor, but a 35V or
63V-rated capacitor would work fine. Fig.2: use this overlay diagram to assemble the PCB. The safe, low-voltage side is
Solder the barrier terminal in place at the right, while the rest of the board is connected directly to the mains. During
now. If you’re using the Jaycar ver- construction, take care with the orientation of the diodes and the electrolytic
sion, which we prefer, you should at- capacitor. The PCB should be sealed in its box before plugging it in. The layout
has changed slightly since the prototype was built, to increase track clearances.
tach it to the board using two machine
screws, washers and nuts before sol-
dering the pins. The two slots on one end of the from accidentally poking inside the
These screws prevent any stress box are designed to provide access to case, which could (in an admittedly
on the solder joints. But the cable CON2 and CON3. You could simply unlikely scenario) make contact with
glands we’re going to use to clamp solder some light-duty figure-8 wires live portions of the board.
the mains cords should also prevent to those pads, or use twin leads with A step drill is handy for drilling the
stress, so the Altronics version with- DuPont headers on the end to plug into larger holes for the cable glands, but
out the moutning screw holes should the pin headers. if you don’t have one, you can use a
be OK too. We’ve also prepared two slim PCBs, tapered reamer instead. Fit the cable
The terminals on the barrier terminal which are supplied along with the glands to the enclosure and make sure
are quite large, so you may need a bit of main PCB and these can be soldered to the nuts are done up tight. We found
extra solder and heat to ensure a good the board in place of CON2 and CON3. that the lips on the mounting nuts
mechanical and electrical connection. They then pass through slots in the overlapped slightly, so we trimmed
Finally, fit the X2 capacitor and re- case and have mounting pads for small them with a sharp pair of sidecutters.
lay. Both should be pushed down fully terminal blocks, which sit just outside
onto the PCB before soldering. The ca- the plastic case and make it easy for Preparing the mains cable
pacitor is not polarised while the relay you to attach wires for connection to It’s up to you where to cut the mains
can only go in one way. your control module. cable to form the two leads. You could
Regardless of which approach you cut it in the middle to get two equal-
Putting it in the box take, we suggest you make the slots length cords, or you could make the
You must mount the PCB in the Jiffy anyway, since you need some way to plug or socket end longer, depending
box to provide sufficient insulation to get the control signals into the case. on your application. Make sure there
make it safe. Start by drilling two holes They can be made by drilling a few is at least 30cm of cable left at each
at the end of the UB3 Jiffy box to suit small holes in a row (eg, using a 2mm end after cutting it.
the cable glands. The specified glands drill bit) and then joining and shaping Once you have cut the cable, there
require 16mm holes. If you are using a them with a needle file. are exposed ends that present an elec-
different gland, you may need a differ- You could drill a larger hole, but trocution risk if the plug is connected
ent hole size. Use the cutting template that would make it easier for dust and to a socket. Take great care to ensure
in Fig.3 as a guide – it is available for debris to get inside the box. You cer- that the plug cannot be plugged into a
download from the October 2019 page tainly shouldn’t make these holes any socket while you are working on it (or
of the PE website. larger than necessary to prevent wires if you leave it unattended). It helps to

Practical Electronics | October | 2019 35


Reproduced by arrangement with
SILICON CHIP magazine 2019.
www.siliconchip.com.au

Left: the Opto-isolated Mains Relay


mounted inside a UB3 Jiffy box with
the mains power plug and power
socket wired up. Note the terminal
extension boards, as shown above,
are wired positive (+) to positive.
These are optional attachments
to make connecting your control
module easier.

plug the plug end into the socket end to the third terminal and the outgoing tightening the glands. This ensures
until you have finished wiring it up. (socket) neutral wire to the bottom that the glands grip the cables securely.
Feed the cut ends of the cable screw terminal.
through the glands. The plug end The two earth leads should now be Testing
should go through the gland closest joined using the BP-style double screw The first tests (with the low-value fuse
to the fuse. Make sure to thread the connector. Twist the wires together in place) are to verify there are no prob-
domed nut onto the cable first, if you and then insert them into the connec- lems with the PCB construction. Don’t
had to remove it. tor, making sure that they both reach connect anything to the mains socket
Strip back the outer insulation by all the way to the end, then do up both yet. Place the unit somewhere stable
25mm on both ends, then strip the screws tight and check that they have and during testing, stay well away
insulation back by 5mm on the live both clamped the wires. from it – don’t touch anything inside
(brown) and neutral (blue) wires. The Now check your work to ensure there the box. Plug the unit into a switched-
earth wires (green and yellow stripes) are no exposed copper strands from any off mains socket and then switch it on.
should be stripped back about 15mm. of the wires floating around or touching If the fuse blows or the relay acti-
Remove the clear barrier from the the wrong terminals and then replace vates (you will hear it click), you may
terminal barrier and attach the wires the transparent barrier strip over the have mis-wired something. Turn off
as shown in Fig.2. The top screw ter- barrier terminal. Check also that none the power point and unplug the plug.
minal takes the incoming live (brown) of the wires can move around in their You can test for residual charge by
from the plug lead. The next screw ter- respective screw terminals. carefully connecting a multimeter on a
minal is for the outgoing live wire to To test the unit, insert a 100mA (or high DC volts range across the live and
the socket, also brown. Ensure both of similar current) fuse in the holder and neutral pins of the mains plug. If there
these are firmly screwed down. slot the PCB into the grooves in the en- is voltage present after a few seconds,
The bottom two screws are for the closure, then tidy up the wires using your bleed resistor may not have been
two neutral wires (blue) and they are cable ties. You can tuck the BP-style fitted correctly.
connected together on the PCB. While screw connector under the gland entry If all is well, nothing obvious should
it will work regardless of which wire inside the box. Check that around 5mm happen. Turn off the power point, un-
goes to which screw, it is neater to con- of the outer mains cable insulation is plug the unit and connect a 3.3-10V
nect the incoming (plug) neutral wire visible inside the box before firmly DC voltage source to CON2 with the

Fig.3: drilling and cutting diagram for the UB3 plastic Jiffy box, reproduced same size (available for download from the
October 2019 page of the PE website). The two 16mm holes are for the cable glands that clamp the mains cords, while the
slots are for either figure-8 wires or extension PCBs to give access to the isolated control and feedback signals. The slots
can be made by drilling a series of small holes which are then joined and shaped using a needle file.

36 Practical Electronics | October | 2019


indicated polarity. Turn on the power
again and check that the relay clicks Parts List – Opto-Isolated Mains Relay
as the armature pulls in. That shows
1 double-sided PCB, coded 10107181, 99mm x 60mm
that the circuit is working.
2 double-sided PCBs, coded 10107182, 38mm x 10.5mm (optional)
Turn off the power, unplug the lead
[Both PCBs are available from the PE PCB Service – see page 78.]
and replace the fuse with the final val-
1 230V 10A extension cord (or mains plug and socket with leads)
ue. For example, if you are using the
2 cable glands to suit mains cord
Jaycar 5A relay, the fuse rating should
[eg, Jaycar HP0724 or Altronics H4312A/H4313A]
be no higher than 5A. If you are using
1 UB3 Jiffy box [Altronics H0153/H0203 or Jaycar HB6013/HB6023]
the 16A relay from Altronics, use a
1 4-way PC-mount terminal barrier (CON1) [Jaycar HM3162 or Altronics P2103]
10A fuse, as the mains leads cannot
1 BP-style double screw connector [Jaycar HM3192 or Altronics P2125A]
safely carry a higher current.
1 250V-rated 24V DC coil relay (RLY1)
[Altronics S4199 (16A, recommended) or Jaycar SY4051 (5A)]
Testing the mains presence/
2 M205 PCB-mount fuse clips (F1) [Jaycar SZ2018, Altronics S5983]
phase output
1 M205 slow-blow fuse to suit relay contact rating, no more than 10A
The easiest way to test that the CON3
[Altronics S5662, Jaycar SF2178]
output is working is to connect a high-
1 M205 100mA or similarly rated fuse (for initial testing only)
brightness LED with its cathode to pin
2 2-way headers, 2.54mm pitch (CON2,CON3)
1 of CON3, then connect the anode to
2 M3 x 20mm nylon machine screws
pin 1 of CON2 (the positive control
2 M3 nylon hex nuts
signal input) and wire pin 2 of CON3
2 M3 nylon flat washers
to pin 2 of CON2. You still need to ap-
ply the DC voltage to CON2 since the Semiconductors
CON3 output is only active when the 8 1N4007 1A 1000V diodes (D1-D8)
relay is latched. 2 12V 1W zener diodes, eg, 1N4742 (ZD1,ZD2)
If you plug the unit back into mains 2 4N25 optocouplers (OPTO1,OPTO2)
and switch it on, you should find that 1 BC549 100mA NPN transistor (Q1)
the LED lights when the relay is en-
Capacitors
gaged and switches off when you cut
1 470nF 275VAC X2-class MKT/MKP
mains power. It will actually be flash-
1 100µF 50V RB electrolytic
ing at 50Hz with a ~50% duty cycle,
but this may not be obvious to the Resistors (all 1W, 5% unless otherwise stated)
naked eye. The LED current will be 2 150Ω 1 470kΩ 1 100kΩ 1 10kΩ 0.25W 1% 1 220Ω 0.25W 1%
limited to one or two milliamps due
to the limited CTR of OPTO2.
If you are planning to use the out- close, that pin will remain high. You
Finishing it off put/phase sense signal from CON3 can detect that condition and flag an
Before you put the lid on, if you with an Arduino, you can enable an error (eg, by sounding a buzzer).
haven’t already done so, make the con- internal pull-up current on the digital Mains phase detection is possible
trol connections to CON2 and CON3. input pin using a command like this, using this signal, but it’s a little bit
If using our small extension boards, fit within your setup() function: complicated due to the phase shift –
the terminal blocks on the wider end, you need to use a timer to measure the
pinMode(3,INPUT_PULLUP);
then feed the boards through the slots positive and negative times, calculate
in the case (lining up + with + and − In this example, connect digital pin 3 the delay between the zero crossing
with −) and place the holes in the ex- to the + terminal of CON3 and GND and the pin going low, then use an-
tension PCBs over the header pins. You to the – terminal of CON3. When the other timer (or possibly the same one)
can then solder them in place. mains is off, pin 3 will read high (1), to compensate. That’s a bit too much
Note that once this has been done, while you would get a low reading detail to get into here.
they need to be desoldered to remove (0) during the positive-going half of You don’t necessarily need to use
the PCB, so it is important that every- the mains cycle when the relay is on. the output sensing function, though.
thing is working and the lid fits cor- You could use a pin change interrupt You can leave CON3 disconnected if
rectly before doing this. or counter function to detect the pin you do not need that feature.
If soldering wires to the pads for toggling if you simply need to know
CON2 and CON3, pull them tight and whether the load is powered.
then glue them into the holes in the In the event of a blackout or if, for
box with silicone sealant. This ensures some reason, the relay fails to
that if the solder joints fail, the wires The finished Opto-isolated
cannot come in contact with the high- Mains Relay. The two
voltage section of the PCB. small extension boards
Now screw the lid on, to ensure make it easy to connect
that no live parts are exposed. Also, the low voltage
unwind the cable gland nuts and isolated terminals
add a few drops of super glue to the to a suitable
controlling
threads, then do them up tight again.
module.
This stops anyone from undoing them
while the device is plugged in. The UK constructors
230V Opto-isolated Mains Relay is will need to
now complete and can be used for use a UK mains
your intended purpose. plug/socket.

Practical Electronics | October | 2019 37


ESR Electronic Components Ltd

All of our stock is RoHS compliant and CE


approved. Visit our well stocked shop for
Your best bet since MAPLIN all of your requirements or order on-line.
Chock-a-Block with Stock
Visit: www.cricklewoodelectronics.com
We can help and advise with your enquiry,
from design to construction.
Or phone our friendly knowledgeable staff on 020 8452 0161
Components • Audio • Video • Connectors • Cables
Arduino • Test Equipment etc, etc
3D Printing • Cable • CCTV • Connectors • Components •
Enclosures • Fans • Fuses • Hardware • Lamps • LED’s •
Leads • Loudspeakers • Panel Meters • PCB Production •
Power Supplies • Relays • Resistors • Semiconductors •
Soldering Irons • Switches • Test Equipment • Transformers
and so much more…
Monday to Friday 08:30 - 17.00, Saturday 08:30 - 15:30

Station Road
Visit our Shop, Call or Buy online at: Cullercoats
North Shields
www.cricklewoodelectronics.com Tyne & Wear
Visit our shop at: NE30 4PQ
020 8452 0161 40-42 Cricklewood Broadway
London NW2 3ET Tel: 0191 2514363 [email protected] www.esr.co.uk

38 Practical Electronics | October | 2019


P955H PIC Training Circuit
by Peter Brunning
When you are first learning about PICs, whether you are a
complete beginner or an experienced programmer, you need an
uncomplicated system which allows you to learn without getting
bogged down in system procedure. That is why we created the
P955H PIC training circuit and our own PIC assembler. In the first
book we learn about PIC programming using the Brunning Software
PIC assembler BSPWA, but in chapter 3M there is an introduction to
the Microchip assembler MPASM X. All our assembler text will run
in both systems, so from there on, if you wish you can use MPASM
X. Likewise, we start by using the on-board PIC programmer to
write the code into the PIC, but if you prefer, plug in a PICkit 3 and
use that. The P955H training circuit has the flexibility to be what you
need as your learning process advances.
The P955H training circuit has been designed to work with both
32-bit and 8-bit PICs. The idea is to start learning about PICs using
assembler with 8-bit PICs. Then learn C with 8-bit PICs, study serial
communications using 8-bit PICs, and finally study C programming
using 32-bit PICs. It is a simple approach to a subject that has no
limit to its ultimate complexity.

The Brunning Software P955H


PIC Training Course
We start by learning to use a relatively simple 8-bit PIC microcontroller.
We make our connections directly to the input and output pins of the
chip and have full control over the internal facilities of the chip. We work
at the grassroots level.
The first book teaches absolute beginners to write PIC programmes
using assembler, which is the natural language of the PIC. The first book
starts by assuming you know nothing about PICs, but instead of wading
into the theory we jump straight in with four easy experiments. Then,
having gained some experience, we study the basic principles
of PIC programming, learn about the 8-bit timer, how to drive
the alphanumeric liquid crystal display, create a real-time clock,
and experiment with the watchdog timer, sleep mode, beeps
and music. Then there are two projects to work through. In
the space of 24 experiments, two project and 56 exercises we
work through from absolute beginner to experienced engineer
level using the latest 8-bit PICs (16F and 18F).
The second book introduces the C programming language for
8-bit PICs in very simple terms. The third book, Experimenting
with Serial Communications, teaches Visual C# programming
for the PC so that we can create PC programmes to control
PIC circuits.
In the fourth book, we learn to programme 32-bit MX PICs using fundamental C instructions. Flash the LEDs, study
the 16-bit and 32-bit timers, write text to the LCD, and enter numbers using the keypad. This is all quite straightforward
as most of the code is the same as already used with the 8-bit PICs. Then life gets more complex as we delve into serial
communications with the final task being to create an audio oscilloscope with advanced triggering and adjustable scan rate.
The complete P955H training course is £259, which includes the P955H training circuit, four books (240 × 170mm,
1200 pages total), six PIC microcontrollers, PIC assembler and programme text on CD, two USB-to-PC leads, a pack of
components, and carriage to a UK address. (To programme 32-bit PICs you will need to plug in a PICkit 3, which you can
buy from Microchip for £38.)
Prices start from £175 for the P955H training circuit with Books 1 and 2 (240 × 170mm, 624 pages total), two PIC
microcontrollers, PIC assembler and programme text on CD, USB-to-PC lead, and carriage to UK address. (PICkit 3 not
needed for this option). You can buy Books 3 and 4, USB PIC, 32-bit PIC and the components kit as required later. See the
Brunning website for details: www.brunningsoftware.co.uk

Mail order address:


138 The Street, Little Clacton, Clacton-on-sea,
Essex, CO16 9LS. Tel 01255 862308
Part 1 | by Paul Cooper | technobotsonline.com

Introduction to stepper motor technology

F
or 18 years, I have been apparent for applications where positional  Permanent magnet
answering customer’s technical control or a slow rotational speed is  Variable reluctance
questions at: technobotsonline.com required without the need of a positional  Hybrid
Technobots supplies electronic and me- feedback sensor.
chanical components to hobbyists, trade The key differences are found in the
and education. A recurring topic from Stepper motor applications rotor (the part of the motor that rotates)
customers has been the use of stepper Stepper motors can range in size from and the stator (the stationary windings
motors and how to control them. Despite milliwatts to hundreds if not thousands wrapped around the rotor). You will
stepper motors being around since the of watts, and are found in numerous see the term ‘soft iron’ used. Soft iron is
1950s and in common use since the 70s, commercial products including: annealed, and unlike magnetically ‘hard’
they remain a bit of a mystery to many  Wrist watches iron, it has low coercivity, which means
hobbyists. In this series of articles, I will  3D printers it does not remain magnetised when the
cover both their theory and how to use  Photocopiers and printers magnetic field from the stator coils is
them, culminating in a full 3-axis CNC  CNC machine tools removed. This is vital in applications
controller. On the way, various control-  Consumer electronics such as camera where the magnetic field is required to
ler designs will be covered; so whether focus and zoom control be repeatedly switched on and off.
you simply want a slow rotating radar  Digital pumps for accurate metering
dish on your model ship, or perhaps a of liquids Permanent magnet
motorised camera slider, these articles  Robotics stepper motor
will show you the way. By the end of  Throughout the automation industry These motors have an axially magnetised
this fi rst article, you should have an  Legacy computer accessories – floppy cylindrical rotor with alternating north
insight into the main types of stepper disk drives and south poles parallel to the rotor shaft.
motor available. In its simplest form, the stator usually
Unlike brushed DC motors, stepper motors consist of two windings, each wound on
What is a stepper motor? draw most current when they are not diametrically opposite poles in series to
The everyday brushed DC motor requires rotating due to their holding current. Some form a two-phase winding enclosed in
little introduction; it has powered stepper drivers will reduce the holding a metal can. In practice, more poles are
everything from small toys to powerful current to a motor until it is needed
machine tools for over a century. Connect to rotate again. The holding current
it to a DC supply and it will spin at many and lack of fan-assisted forced-air
thousands of RPM. Reverse the polarity cooling means that steppers can
and it will spin in the opposite direction. run rather hot, especially when
DC motors, therefore, are one very they are stationary.
effective way to supply rotational speed
control; but what if you didn’t want to just Types of stepper motors
control rotational speed, but rotational This series of articles is not about
position too? This is where stepper motors the internal operation of stepper
are used. However, stepper motors are motors – fascinating though that
not as straight forward as DC motors; a is – but how to use them. If you
simple pot won’t do the job – they do want a good introduction to how
require an electronic controller to manage they work, then the YouTube
the energising of the motor coils. video mentioned below in the
A stepper motor is a brushless DC Hybrid stepper motors section is
motor that moves in discrete steps in an excellent place to start. That
either direction and can be made to stop said, we can’t treat them purely
and hold at any of these step positions. as black boxes, so here is a quick
Immediately, the advantages of stepper overview of the three main types Fig.1. A 48-step bipolar permanent-magnet stepper
motors over DC brushed motors should be of stepper motor: motor with two stacked ‘cans’.

40 Practical Electronics | October | 2019


Fig.2. Internal view of a 28BYJ-48 permanent-magnet stepper motor with integral gearbox. Note the ‘fingers’ around the inside of the
stator giving 32 steps per revolution. The number of step at the output shaft is approximately* 32 x gearbox ratio 64 = 2048 in full-step
mode. (*note that the gearbox ratio is not exactly 64:1).
needed to create more steps per revolution which is where ‘can is not commonly used and has limited availability. They tend
stacked’ motors (Fig.1) come in. To create more poles but keep to to be used in very specific markets – you may well find one
the two windings is achieved through the use of ‘fingers’ or ‘teeth’ driving your new washing machine drum. They will not be
around the inside of each coil stacked. Typically such steppers described further in this series.
are available with 12, 20, 24, 48 and 100 steps per revolution,
sometimes higher, but 24 and 48 are common. The low step Hybrid stepper motors
count can be offset with models having integral gearboxes, the Last, we have hybrid motors, which use elements of both
28BYJ-48 stepper motor (Fig.2) with its approximate 64:1 ratio permanent magnet and variable-reluctance stepper. Hybrid
gearbox can be obtained with a driver for under £2 with free stepper motors consist of a permanent magnet rotor with
carriage on eBay! Not bad for a stepper motor that can achieve radial soft iron teeth (see Fig.3), and a multi-pole wound stator
over 2,000 steps per revolution in what is called ‘full-step mode’. with corresponding teeth (see Fig.4). They are perhaps the
(Step modes will be described in a later article.) most common type of stepper motor as they offer better step
The key advantages of permanent magnet stepper motors are resolution, holding torque and speed, but can be more expensive
high suitability for low-speed applications with moderate torque than the other types. Perhaps the most common hybrid stepper
requirements and they tend to be less expensive than hybrid motors. motors have 200 steps per revolution which is 1.8° (360°/200).
400-step motors are available which give a step size of 0.9°
Variable-reluctance stepper motors (360/400). Fig.5 and Fig.6 show a NEMA 17 400-step rotor and
These motors do not have a permanent magnet in the rotor, stator respectively. The drive electronics tends to be similar for
but one made of soft iron / slotted steel laminations. The soft
iron rotor is multi-toothed and offers good angular resolution
and rotational speed but lacks torque compared to the other
types. One significant difference of this type of motor is that
it cannot produce detent torque. Detent torque is the amount
of torque the motor produces when the rotor coils are not
energised. You can feel the ‘cogging’ from the detent torque
on the permanent and hybrid motors when turning the shaft
by hand with no power applied. This type of stepper motor

Fig.4. A NEMA 17 2-phase hybrid bipolar stepper motor stator


with the rotor (see Fig.3) removed. Each of the 8-poles has a
winding, the windings on poles 1, 3, 5 and 7 are wired in series
to form phase ‘A’, similarly 2, 4, 6 and 8 are series wired for
phase B. The controller sequentially energises the phases which
Fig.3. A NEMA 17 hybrid stepper motor rotor from a 200-step-per- attract the teeth on the rotor until some of the rotor teeth are
revolution motor with its two rotor sections, each with 50 teeth. aligned with some of the 48 stator teeth (two fewer than the
Look closely and you should see the two rotor sections’ teeth are rotor). The other teeth are out of alignment by ¾, ½ or ¼ of a
offset from each other by half a pitch (3.6°) effectively making a tooth pitch, so with the next step, the rotor will move ¼ of a 7.5°
100-tooth rotor. step or 1.8°, which equals 200 steps per revolution.

Practical Electronics | October | 2019 41


Fig.5. NEMA 17 400-step bipolar motor rotor, note the increased
number of teeth compared to the 200-step stator in Fig.3.

both permanent and hybrid stepper motors, and can effectively


increase the number of steps per revolution many fold with Fig.6. NEMA 17 400-step bipolar motor, like its stator, it also has an
techniques that will be discussed in a later article. increased number of teeth compared to the 200-step stator in Fig.4.

How a hybrid stepper motor works current to be reversed and thus reverse the magnetic field of the
Most tutorials on the Internet use a very simplified view of a windings. We will discuss driver circuits in a later issue. You
stepper motor that does not really help in understanding how may be wondering why not always use the simpler approach to
these 200-step motors actually function. Describing this in the drive unipolar motors. It’s simply that unipolar motors suffer
necessary detail in these articles would be less effective than the from reduced torque as only half of each winding is energised at
animated graphics on the excellent explanation in the Nanotec a time, unlike a bipolar where the whole winding is energised.
video, which can be viewed at: https://youtu.be/Ew6eVGnj7r0 Unless you are building your stepper driver from discrete
(recommended viewing for those who would like a better components, bipolar is the way to go as many semiconductor
understanding of what happens in a hybrid stepper motor). manufacturers now offer dedicated H-bridge driver chips.

Unipolar and bipolar windings Hybrid motor sizes


When looking at permanent or hybrid stepper motor, you may Of the three stepper motor types, we now know that the hybrid
well notice in the description they are referred to as ‘unipolar’ or variety is the most commonly available and bipolar is the most
‘bipolar’. This describes the motor wiring winding configuration common drive method. Hybrid stepper motors are available
and are classified as either unipolar or bipolar, see Fig.7. in various physical frame sizes and are identified by a NEMA
4-phase unipolar motors consist of two windings each with a number. ‘NEMA’ is an acronym for the National Electrical
centre tap. How the centre taps are brought out can be individually Manufacturers Association, a US-based body representing over
(6-lead, see Fig.7c) or as a common (5-lead Fig.7b). 2-phase 300 electrical equipment manufacturers from various market
bipolar motors do not have a centre tap, just the ends of the sectors. The NEMA standard is based on the inch, and despite
windings are brought out (4-lead Fig.7a). 6-lead unipolar motors this it is the most common frame size reference. There is also
can also be used as a bipolar motor by not using the two centre an IEC metric frame size standard, but for the hobby market
tap leads. There is a third arrangement called ‘bifilar’, where most retailers use the NEMA classification.
instead of winding each coil with a single wire, two wires are The NEMA number is related (approximately) to the width
wound in parallel with each end brought out (8-lead Fig.7d). of the square face of the stepper motor (Table 1). There is
This allows the motor to be driven in either unipolar or bipolar also a NEMA 24 size, which while not a formal standard,
by connecting the windings in series or parallel. mounts like a NEMA 23 but is slightly wider, which allows
Unipolar motors (Fig.8) are easier to drive in that the driver for a larger rotor and stator, and thus more torque.
circuit does need to reverse the current through the winding The NEMA 17 is widely used by hobbyists, especially those
making the circuitry much simpler to implement. The bipolar building 3D printers. For a given NEMA motor size, the body
motor requires a full ‘H’ bridge driver circuit to allow the length can also vary, the greater the body length, the greater the

A
A A
A

B B B
B
a) 4-wire stator, 2-phase, bipolar b) 5-wire stator, 4-phase, unipolar c) 6-wire stator, 4-phase, unipolar d) 8-wire stator, bifilar

Fig.7. Stepper motor wiring configurations; the 4-wire type is most commonly used.

42 Practical Electronics | October | 2019


Fig.8. Example of a NEMA 17 unipolar Fig.9. NEMA 17 motor with a hollow shaft Fig.10. NEMA 17 bipolar stepper motor with
stepper motor. – Technobots used these for a client who integral T4 lead screw driving a brass ‘nut’.
needed to continuously rotate in one direction
motor torque. Other sizes of stepper motor a very bright LED light panel. The motor
are used in commercial applications, both shaft drove a slip ring, which in turn drove screw shafts where rotational to linear
smaller and larger than the NEMA range the LED panel around. The slip ring wires movement is required (Fig.10).
below. While the NEMA number relates were passed through the hollow shaft to the
to the physical size, other mechanical LED driver such that the wires never twisted. Next month
and electrical specifications can and do In November’s article, we will look at
differ. Two NEMA-sized motors may look choosing a stepper motor and how to
identical, but their electrical performance Various motor shafts are also available identify the leads on that surplus stepper
can be very different and they are not for stepper motors, round shafts, ‘D’ motor you extracted from a defunct piece
necessarily interchangeable. shafts, hollow shafts (see Fig.9), even lead of equipment.
Table 1: Relationship between
NEMA frame size number and NEMA 8 NEMA 11 NEMA 14 NEMA 17 NEMA 23 NEMA 34 NEMA 42
the face width.
Motor face
~0.8 ~1.1 ~1.4 ~1.7 ~2.3 ~3.4 ~4.2
size (inches)

Practical Electronics | October | 2019 43


Circuit Surgery
Regular clinic by Ian Bell

Understanding bipolar junction transistors – Part 4

T
his month, we conclude
our look at the different bipolar Common emitter Common collector Common base
transistor circuit configurations In B C Out In B E Out In E C Out
– common-emitter, common-base and E C B
common-collector – inspired by questions
on this topic on the EEWeb forum (http://
bit.ly/eeweb-pe). Previously, we’ve looked
at the common-emitter and common-base Fig.1. Concept of transistor configurations. These apply to both NPN and PNP. Actual
configurations – specifically the basic single circuits require additional components.
transistor amplifier circuits that use these
configurations. This month, we’ll focus far as the signal is concerned the power
VCC
on the common-collector amplifier, also supply is like a short circuit. So from a
known as the ‘emitter follower’. To support signal perspective, the collector is directly
In Q1
the discussion on specific circuit designs connected to ground in the circuit in Fig.2.
we have also covered some general topics, Like the other configurations, we need to
Out
including biasing, small-signal model- supply bias for the circuit to work. Again,
ling and high-frequency behaviour of the we can use a potential divider at the base R1
transistor. Last month, we also looked at (see Fig.3) and follow similar arguments
input impedance and here we return to to those used with the other circuits to
this, along with output impedance, in the arrive at suitable component values. We
context of the common-collector amplifier. chose a bias current for the emitter (IE) as
the operating current, taking factors such as Fig.2. Basic common-collector amplifier
Common collector optimal transistor performance and power without bias circuitry.
Looking at Fig.1, we see that unlike the consumption into consideration. We choose
common-emitter and common-base circuits a no-signal output (emitter) voltage (VE), Many resistor combinations are suitable,
discussed previously, the output from the and half the supply gives the largest po- but we should not use values that are too
common-collector configuration is from the tential output amplitude, but other values small because of power consumption and
emitter, not the collector. Fig.2 shows the can be used if desired. The chosen VE and the effect on input impedance. The values
basic common-emitter amplifier without IE set the emitter resistor value (R1 = VE/IE). should also not be too large – we should
bias circuitry. As with the other circuits, The transistor’s base-emitter voltage (VBE) have a current in the bias resistors more
we connect a resistor from the configura- to emitter current relationship – the Ebers- than ten times the bias base current. Again,
tion’s output terminal to the supply, but Moll diode equation that we discussed in this was discussed previously. We can
due to the polarity of the transistor we need Part 2 – tells us the required VBE based on choose a reasonable total resistance (RT),
to connect the output resistor between the our chosen operating IE. say 30kΩ, and use the required ratio of
emitter and ground. It serves the same pur- supply-to-base voltage to find the grounded
pose as the collector resistor in the other Bias calculations resistor (R3 in Fig.3), that is R3 = (VB/VCC)RT
configurations – connecting power to the If we use similar values to the common- = (12/6.635) × 30kΩ = 16.6kΩ. The other
transistor and converting the transistor’s emitter circuit discussed in Part 2, we resistance is simply this value subtracted
output current to an output voltage. The choose IE = 1mA and with VCC = 12V, from the chosen total (here, 13.4kΩ).
common connection – the collector – is and a no-signal emitter voltage of VCC/2
connected directly to the power supply. = 6V, then we get R1 = 6kΩ. In Part 2 we VCC
This might seem odd as we usually asso- discussed the non-linear relationship
ciate the common connection for a signal between VBE and IE in detail, and for the R2
with ground, but recall from our previous example transistor used (BC547B), found
Q1
discussion on small-signal models that as that a VBE of 0.635V was required for an
emitter current of 1mA. This is based on In Out
the model provided with LTspice and of
Simulation files course, as we have discussed, will vary R3 R1

Most, but not every month, LTSpice with individual transistors.


is used to support descriptions and Having found our required VBE we can
analysis in Circuit Surgery. select suitable resistors for the bias po-
The examples and files are available tential divider. With the emitter at 6V we Fig.3. Common-collector amplifier DC
for download from the PE website.
need 6.635V at the base for VBE = 0.635V. bias circuitry.

44 Practical Electronics | October | 2019


circuit last month. To
C
keep things as simple as
possible we will ignore
ic = βib the bias components and
ib substitute the model for
B
the transistor in Fig.2,
vBE adding a signal source.
re
We also use an ideal
input source with zero
ie
E
source resistance. This
gives the small-signal
Fig.4. Transistor small-signal model with re. model shown in Fig.5 –
note the power supply
Variations in individual transistors and ground connected
and changes in circuit conditions, such together, as discussed
as temperature mean that a carefully cal- earlier. We can redraw Fig.7. LTspice schematic for a basic common-collector amplifier.
culated bias set up may differ significantly this schematic with an
for individual transistors, or vary during alternative layout, as shown in Fig.6. resistance of the bias components is sig-
operation. To overcome this we can apply Referring to Fig.6, it is reasonably nificantly larger than the source resistance.
feedback to stabilise the bias; again, we straightforward to see that re and R1 form
introduced this idea for the common-emit- a potential�divider, so we have: Simulation
!
ter circuit, where we added a resistor in �!"# = � �!" Fig.7 shows an LTspice schematic for a
� +! �!
the emitter circuit. The common-collec- �!"# = ! �!" basic common-collector amplifier, with
�! + �!
tor circuit already has an emitter resistor, input and output decoupling capacitors,
so the circuit in Fig.3 has stabilised bias So the gain is: and component values as discussed for
without needing extra components. An- �! Fig.3 above. The results of simulating the
other issue with the bias components is ≈ 1 circuit are shown in Fig.8 – here we see
�!�+! �!
their potential impact on input imped- ≈1 that the output voltage amplitude is very
�! + �!
ance – we will return to discuss this later. This value is usually typical close to (and close to the input voltage and is in phase
always slightly less than) unity because in a with the input. The common-collector
Analysis �!" r�e!"will be significantly smaller
typical circuit amplifier is non-inverting, unlike the
We can analyse the circuit using a small- �!" =
than R1�.� !"
The= value
�! or r is approximately common-emitter layout. The fact that the
!" = �!"
e
signal model, as we have done with other �!"E=at room
25/I temperature, so with an op- output voltage signal is very similar to the
�!" �!
circuits we have looked at. In this case, we erating current of 1mA re is around 25Ω. input leads to the name ‘voltage follow-
will use the model with re rather than rbe This indicates a gain of 6000/(6000+25) er’ commonly being used for this circuit.
(see Fig.4) – as we did for the common-base = �0.996 with R equal to 6kΩ as selected If we zoom in very close to a peak in
! = �! + ��! 1= 1 + � �! ≈ ��!
above – close to unity,
�! = �! + ��! = 1 + � �! ≈ ��!as expected. waveforms, as in Fig.9, we can see that
The model circuit used is simplified (as expected) the amplitude of the output
C – we have ignored the input (vin) source is slightly less than the input. Measur-
�! = �! �
resistance, the bias components and the ing this simulation with the waveform
transistor’s
�! = �! � output resistance. Including cursors indicates a gain of 0.994, which
ib ic = βib
these components results in more com- given the amount of simplification used
B plex algebra for the circuit analysis, but is acceptably close to the value calculated
produces �!"fundamentally the same result: earlier. Fig.10 shows the voltages directly
re
�!" = � �
a gain �!"
close to unity – at least under the at the base and collector. These are the
�!" = ! �
vin E ie assumption �! that the transistor gain is typi- same signal waveforms as in Fig.8, but
vout cally ‘large’ (eg, 100 or more) and that the include the DC bias voltages around the
R1 �!"#
�!" = � �
�!"#
�!" = ! �
�!

Fig.5. Small-signal model for common-


�!" = �! �
collector amplifier ignoring bias components.
�!" = �! �
ib
�!" �!"
�! = � � + 1 ≈ � �
�!" �!"
re
�! = ! � + 1 ≈ ! �
�! �!
E
vin βib vout

�!
R1 �!"# = ��� �!" =�
�!"# = ��� ��!" � = �!
! �
�! �

Fig.8. Simulated input and output waveforms for the circuit in Fig.9. These voltages
Fig.6. Fig.5 redrawn with alternative layout. are almost equal.

Practical Electronics | October | 2019 45


telegraph engineer. Thévenin’s theorem
states that a linear electronic circuit that
comprises any combination of voltage
sources, current sources and resistors,
with two output terminals, is electrically
equivalent to a single voltage source and
a single series resistor – for example, the
amplifier output voltage (vA) and output
resistance in Fig.11. The theorem also ap-
plies to circuits in which the sources are
AC (sinewave), all at the same frequency,
and the other components are impedanc-
es (resistance, capacitance, inductance).

Finding Thévenin
To obtain the Thévenin equivalent for
any suitable circuit we find the open-
circuit output voltage and then the
Fig.9. Zoom in on one of the peaks in Fig.9 to show that output amplitude is slightly short-circuit output current. The open-
smaller than the input. circuit voltage is used as the equivalent
source voltage and the open-circuit volt-
age divided by the short-circuit current
gives the source resistance.
In Fig.11 the source is also modelled in
the same way – it could be the Thévenin
equivalent of a previous amplifier stage,
or it could be some physical signal source,
which can also be modelled as a voltage
source and an associated source imped-
ance. Use of pure resistance for input and
output impedance may be a simplification
in both cases (see last month’s discussion),
but it is sufficient for our purposes here.
If the amplifier in Fig.11 has a much
higher input resistance (r in) than the
source’s output resistance (rs) then the
potential divider formed by rs and rin
will produce a voltage very close to the
applied voltage; that is, vin will be very
Fig.10. Simulated waveforms from Fig.7 directly at the base of an emitter. This shows the close to vs and we can assume vin = vs. If
signals together with the bias voltages around the transistor. the amplifier has unity gain (A = 1) then
we have vA = Avin = Avs = vs.
transistor, which are blocked by the cou- current level than it takes from its input. We can find the Thévenin equivalent of
pling capacitors. We see that the DC levels This leads us to a discussion of the input the combination of the source and ampli-
of the signals at the emitter and base have and output impedance of amplifiers. Last fier. The open-circuit output voltage (ie,
a constant 0.66V DC difference between month, we looked at amplifier input im- with RL disconnected) is vA (so equal to
them – the VBE voltage set by the biasing. pedance in the context of how it might vs). The short-circuit output current (with
vary with frequency, potentially reducing RL = 0) is simply vout/rout, so we just get
Input and output impedance signal amplitude at high frequencies. We rout as the Thévenin source resistance.
On first thoughts, an amplifier with unity used a generic circuit like the left-hand side Therefore, the Thévenin equivalent of the
voltage gain may not seem very useful; Fig.11 to represent the connection between circuit in Fig.11 is as shown in Fig.12. The
however, this is not the whole story. The the signal source and amplifier input. The key thing to note here is that we have the
common-collector amplifier has a current same form of circuit model can be used same source voltage, but with an output
gain much larger than unity – it can de- for the output of the amplifier connected resistance of rout instead of the original
liver the output signal at a much higher to a load – as seen on the right-hand side
of Fig.11. Overall, Fig.11 is a
model of the source, ampli- Source and amplifier
Signal Amplifier Amplifier
source input output Load fier and load together. rout iout

rs iin Amplifier gain, A rout iout The idea of represent-


ing the output of a complex
circuit, such as an ampli- vs vout RL

vs v = Av fier or filter, by a single


vin rin A in vout RL
voltage source and resis-
tor (or impedance) is based
on Thévenin’s theorem,
which is named after Léon Fig.12. Thévenin equivalent of the circuit in
Fig.11. Generic circuit for a signal source connected to an Charles Thévenin (1857– Fig.11 for amplifier with unity gain and very
amplifier driving a load. 1926), who was a French high input resistance.

46 Practical Electronics | October | 2019


�!"#
�!" = �
�!
rs. On the assumption that we have an But, looking at Fig.6 we see that (using
amplifier with low rout (as we do with a Ohm’s law) R1 = vout/ie, so: C
common-collector circuit), another way
�!" = �! �
to describe this to say that that a buffer
ib ic = βib
amplifier effectively lowers the output im- The input resistance of the circuit is the
pedance of the signal source applied to it. emitter (or load) resistance multiplied by B
A common use of emitter-follower cir- �!"
the transistor gain. As�!"
before, our analysis re
cuits is the output stage of multiple-stage �! =
has been � + 1 ≈ by ignoring
simplified � the bias
�! �! RS
(multi-transistor) amplifiers. Typically, components. In the small-signal model E ie
the first stages provide high voltage gain both bias resistors are connected between vout
vin
and the common-collector circuit facili- the base and ground, so they are effectively
tates delivering the amplified voltage at in parallel with the input�! resistance we R1
= ���
�!"# just �!" =This has a signifi- �!
relatively high current to the load. Power have calculated.
� � �!"# = �
amplifiers – for example, those used to cant effect. For�example,
! for the circuit in �! + �! !"
drive loudspeakers – can be based on Fig.8, with a β of 300, we have a potential �!
�!"# = �
the emitter follower. However, in these rin of 6kΩ × 300 = 1.8MΩ, but this will Fig.14. �! + �! !" model from Fig.5 with
Small-signal
circuits two transistors are employed to be greatly reduced by the less than 10kΩ source
�! resistance added.
cover the negative and positive half cycles parallel combination of the bias resistors. ≈1
of the waveform separately, which leads We can use different bias arrangements

high! +effective
�! value of R3 means that
to�additional
�! complexity in the biasing, to overcome this problem. A simple ap- the � circuit does
!"# = � �!" ! �! not suffer from the rel-
� � �+!!! �! not
� �!"#low =≈ 1resistance �
!"# = �
which we!will cover here. proach is to use a single resistor between atively
�! + �! �! + �! !" bias components

�!"# = �
!"# = �! + �!"
�!"# = � +! ���!!! �
�!! + !"
�!" VCC and the base (R2 in Fig.9, with no R3 bypassing �!" the�high input resistance of the
�! + �! !"
Input resistance present). The value is calculated using �!" =
transistor (as
!"
= happens with the circuit in
�!" �!
Using our small-signal model circuit the required base current. For example, Fig.7). This effect only applies to signal
�! � �
�!" =�! =
(Fig.5) we can get some idea of the actual for an operating current of IE = 1mA and frequencies, not to the DC bias, which is
� �+! � ≈ 1 !" !"
!�
�!! and a β of 300, we require a base current of � ≈ 1

�! �! ≈ ≈1
input ! output resistance of a com- blocked
�! +!"�! by C . The DC base bias current
1 3 !

� + ��!! ≈
�!!! +
mon-collector
+
1
≈ 1 circuit. Starting with input 1mA/300 = 3.33µA. With a required base is�small,
= � so��
+ there = is1only
+ � a�!small
≈ ��!DC volt-
�! + �! this is by definition: ! ! !
resistance, voltage of 6.635V (see earlier discussion) age drop across R3, which can be taken
�!" �!" the drop across the (R2) resistor is 12V – account of in bias calculation if needed.
�!" = � = � 6.635V = 5.365V. To achieve the required �! = �! +�!" ��! =�!"1 + � �! ≈ ��!
��!" = ��!"
� !"
!" =
!" ��!"
� !
!" � = =
�!"!" =
= ���!"!" =
!"
= ���!"
base current requires a resistor value of �! =!" �! resistance
Output �!"
� �!
= �transistor,
�!" the = !
For !" � ! the emitter current is 5.365V/3.33µA = 1.6MΩ. This will have We can calculate the output resistance of
�!"
!" �!!
the sum of the base current (ib) and col- much less impact on the input resistance the common-collector amplifier by finding
lector current (equal to βib), that is: than the potential divider bias resistors, the = �! � equivalent of the small-sig-
�! Thévenin
�! = �! + ��! = 1 + � �! ≈ ��! �!" circuit in Fig.14 (the same as
nal �model
�!" !== �! �+ ��! = 1 + � �! ≈ ��!
but use of a single resistor like this re-
��! == ���!! ++ ��
��!! == 1
1++�� ���!! ≈
≈ ��
��!!
�!! = + �� = 1 + � ≈ �� duces the bias stability – the circuit is Fig.5, �! with source resistance added).
but
�! = �!! + ��!! = 1 + � �!! ≈ ��!!
In which we can approximate (1 + β) = β more sensitive to variations between The output resistance is the open-circuit
on the assumption that β is much larger individual transistors and changes in output
�!"
�! = �! � �!" = voltage � divided by the short-circuit
than =1,� from � which we get: conditions such as temperature. �! =�!�! The
resistance. � open-circuit output volt-
���!!! == ��!!! � � age is �!"# v , which is equal to v
simply
�! = �! � �!" = � out in
Bootstrapping as we have �! close to unity gain. With the
Using this�!" in the rin equation we can write: Another option is to use bootstrap bias- output �shorted (short across R1) we have
�!" = � � ing, which makes use of AC feedback �!"of
all =vin �!"� r and r . If we assume r
!"#
��!" = ��!"
� ! �
!" �!" =�across � e s e
!" ! �!
!" =
�!" = ���!" �
� to make a pair of potential divider bias is small compared to rs (high-impedance
�!" = �!!! � resistors appear to have much higher �!" = �and
source) ! � ignore re, the output short-
�!
But we have a unity-gain amplifier (vout resistance to the signal, while still re- circuit base current is vin/rs. Thus the
�!"#
= vin), so: taining acceptably small resistance for short-circuit output (emitter) current is:
�!" = � � �!" = �!��!"#
��!"#
� DC. A version of the circuit in Fig.7 with �!" �= � �!"
���!" = ! �
!"#
= ��!"# !" �!
!" = !"# �
� bootstrap bias is shown in Fig.13. �! = �+1 ≈ �
�!" = ��!!! �
!"
�! �!
�! The boostrap bias circuit adds a re-
sistor between the bias and potential �!" add base and
Here, we �!" emitter currents
�!" = �! � divider (R4 in Fig.13), but the input is �! =
and �+1 ≈
approximate, as we �
VCC
�!" �=! Dividing
�! � �! did for the input
��!" =
= �! � fed straight to the base as usual via the analysis. the open-circuit output
�!"
!" =��! �� ��� v = v= )�by !
�!" = �!! � R2 coupling capacitor (C1). An additional �!"# =(using
voltage �!"out in � this we get the
13.4kΩ �
C1 capacitor (C3) feeds the output signal output resistance:�!
In �!"
10µF
�!" back to the potential divider junction. If �!
�! =� �+1 ≈� � �!"# �!"
��� = �!"
=���!" ≈���!" �! =
= ��+!" 1 ≈ � �
���!!! �++11
!
!" ! �
!" we assume C1 is effectively a short cir-
�! � � �!
= !" � ≈ !" �
= ���!" �+ 1 ≈ ���!" � Q1
�! = �!!! �+R41 ≈ �!!! � BC547B cuit for signals, and remembering that !
�! 10kΩ �! C2 the circuit has a gain of close to 1, we The circuit’s output resistance is the
100µF
find that a voltage equal to input signal source resistance divided by the transistor
C3 �!
�!"# = ��� � =�
10µF Out is fed to the potential divider junction. gain – note the symmetry�!with the input
���
��!"# = ���
��� R3

!"
�!" � = ���!!! R1
The input signal is on the other side �!"# = being
resistance �the =
!" load resistance times
�!"# = ���
= = �! � �
� !" � = �
16.6kΩ
! 6kΩ
�!"# = ��� ��!" � =� � of R4, so the signal voltage across R4 is �!
the gain. Again, there are some approxi-
!"# ! �
���!" �
!! �

!
very small (it has almost the same signal mations here –R1 and/or the transistors
voltage on each side), which means the output resistance may need to be includ-
signal current through it is very small ed in parallel if they are not significantly
Fig.13. Common-collector amplifier with and its effective resistance is very large larger than rs/β. On the other hand if rs is
bootstrap bias. (much larger than its actual value). The very small re will need to be included.

Practical Electronics | October | 2019 47


AUDIO AUDIO OUT

L R

OUT By Jake Rothman


Designing Hi-Fi mini-monitor loudspeakers – Part 2

L
ast month, we introduced equaliser and a third-order high-pass there is also a trend for simple first-order
the classic British mini-moni- section, as illustrated in Fig.34. More crossovers, using a single capacitor and
tor loudspeaker, the LS3/5A. We recent speakers aim for a Linkwitz-Ri- inductor. These are louder and more dy-
looked at many of the design, material ley (LR) fourth-order response because namic on percussive electronic music,
and component choices and decisions it has a predictable phase result and but less accurate sounding on vocals.
that go into a successful loudspeaker, lends itself to computer design and ac- Loudspeaker drivers are inductive res-
and we will continue that approach tive systems. Personally, I find the LR onant loads, so the response of the filter
this month, starting with the vital filter crossovers to be more noticeable (ie, less circuits is not as predictable as with a re-
at the heart of the electro-acoustic sys- natural) because of their steeper slope sistive load. Consequently, the response
tem – the crossover, a circuit designed and big off-axis power dip. Conversely, of crossovers must always be measured
to steer the right frequencies to the ap-
propriate driver. R1 R2* *Old versions may use C5 = 6.2µF
82Ω 22Ω
2W 6W or 8.3µF, and R2 = 33Ω depending
on the mid-equalisation required.
Crossover design
Integrating the LS3/5A’s two KEF driv- L1
1.53mH
L2
2.67mH
ers made the BBC crossover filter circuit 0.18Ω 0.3Ω
*Drake Transformer
2501-128* 2501-127*
rather complicated, as shown in Fig.32 part numbers

and 33. However, the result is an al- Input from


amplifier
Woofer
most seamless integration that is rarely B110A
surpassed. The crossover is the most C3 +
C1 *C5
expensive part of the speaker, costing 3.7µF 10µF 3µF
(2x 1.5µF)
(2.2µF + 1.5µF)
£196.00 for an ‘official’ (Falcon) pair,
using exactly the specified components. 0V

The crossover frequency is 3kHz,


which generally sounds good because
it is far enough away from the criti- Input from C2
power 2µF PCB tap selection
cal 200Hz to 2kHz midrange area and amplifier L3 Yellow
0.64mH 5 4
not too high for a 110mm bass unit. Tap No. 7 6 3
–3dB
It also allows a 19mm dome tweeter C2 value depends on tap selected (75 turns) The taps off L3 7 2
because load impedance changes. give 0.5dB steps
to be used, which gives superior dis- Violet
0.5mH in the signal to the
+10% added in 1984 to compensate tweeter, relative
persion compared to the more normal for T27 tweeter changes Tap No. 6 to the power amp
–2.5dB To C2
25mm size that has to be used for low- Tap C2 C2a + C2b (66 turns)
signal output.
7 1.22µF 1µF + 220nF
er crossover frequencies. 6* 1.5µF Grey
0.38mH
This crossover design set the topolo- 5*
4*
2µF
2.67µF
1µF + 1µF
2.2µF + 470nF
Tap No. 5
–2dB Tweeter wired
gy for most mini-monitors up until the 3 3.52µF 3.3µF + 220nF (58 turns) C4 out of phase.
2 4.8µF 3.3µF + 1.5µF 5.03µF
1990s, a second-order, low-pass sec-
Select L3 tap for C2 connection

Brown 0.3mH
tion combined with a mid-range peak *Tap 4, 5, 6 are the usual positions Tap No. 4
–1.5dB
C4 = C4a + C4b = 4.7µF + 0.33µF (51 turns)
R4
Green 8.2Ω
Coil specification 0.22mH 2W
Tap No. 3 Black
Wire: 0.9mm –1dB wire
(44 turns) R3 –
Laminations: size P No.39T Orange 82Ω Tweeter
158 mils thick stack 3/8-inch 0.165mH 2W T27
Scotch 56 tape Tap No. 2 +
Air gap 62 mils (1/16-inch) –0.5dB
Inductance 0.64mH ±5% (38 turns) Blue
Measured at 3kHz 1V RMS C6 wire
White Inductance 680nF
Inductor coils originally made by measured
Drake Transformers (type 2501-126), Tap No. 1 from here
now made by Volt (type E126)

0V

Fig.33. The BBC 15Ω LS3/5A crossover (model FL6/23). (top) The low-pass section of
the crossover circuit; (bottom) the high-pass section, note the tweeter is connected out of
Fig.32. 15Ω LS3/5A crossover assembly. phase relative to the woofer; this is normal in all variants of the LS3/5A.

48 Practical Electronics | October | 2019


Furthermore, in better hearing. Celestion always used
These two sections may be reversed
Second-order low-pass
the nightmare that them for their swept sinewave rattle test.
filter (baffle equalisation is crossover design, I have a pair of the first ‘computer de-
often incorporated here) Mid-range dip
the three dimen- signed’ speakers, the 1979 KEF 104aB
sional, off-axis (Fig.36). The ‘aB’ stands for ‘acoustic
Input
+ response of the sys- Butterworth’, the resulting electroacous-
f = 1.8kHz f = 850Hz Bass-mid unit tem also has to be tic curve – a maximally flat 18dB/octave
(woofer)
0V 0V
– taken into account. at 3.5kHz response. They still sound
0V 0V In addition to this, amazing, like LS3/5As but ‘with bass’
Together give cossover at 3kHz
there is the relative because they are big. Off the reference
phase between the axis, (not directly in front of the speaker
two driver outputs. as, shown in Fig.37) the curve is not flat,
– These factors de- having a loss of energy between 500Hz
f = 3kHz Tweeter termine the overall and 3.5kHz. They have to be in a very
+
0V
0V
acoustic energy the dead, almost anechoic room pointing at
Third-order high-pass 0V
filter at 3kHz speaker puts into the the listener to sound their best.
Attenuation can be before, in or after filter.
(In the LS3/5A this is achieved in an room. This makes
auto-transformer / inductor)
crossover design an Inductors
iterative, empirical Getting hold of the original LS3/5A trans-
Fig.34. The basic structure of the 15Ω LS3/5A crossover. This
subject for most en- former low-distortion Radiometal-cored
circuit structure set the pattern for most high-quality two-way
gineers, resulting in (50% nickel/iron alloy) inductors is
speaker crossovers for 20 years. Note the out-of-phase tweeter.
multiple cycles of: particularly difficult (Fig.38). Volt, the
with the specified drive units connected select topology, calculate, tweak cir- Yorkshire loudspeaker company, now
when plotting the electrical curve. It’s also cuit, measure, and listen. I still have make these inductors exclusively for
important to remember that the acoustic big development boards stacked with Falcon. I’ve resorted to winding my
response has to be added to the electri- inductors and capacitors from when I own, not as difficult as you would ex-
cal response to get the required overall did crossover design as a job – see Fig.35. pect if you have an inductance meter
electro-acoustic transfer function. (If a It is possible to do multiple – an essential piece of kit for any cross-
speaker designer says his speaker uses simulations with software to get ‘almost over maker – and can obtain Belclare or
(say) a fourth-order crossover, he means there’. KEF was the first company to Drake cores from old BBC engineers’
the electroacoustic order, the electrical do this, and their KEF Topics papers junk boxes (although this is not an op-
order of the circuit will be less.) are well worth reading (see: http://bit. tion for most people). These cores give
Another thing to keep in mind is the ly/pe-oct19-kefus). relatively lower third-harmonic dis-
way the different parts of the electrical In my early 30s I had good hearing tortion compared to normal iron-dust
curve add up. In the LS3/5A the mid- and could knock up a good crossover cores (Fig.39).
peak equalisation curve adds to the ‘by ear’. Not any more, always beware Air-core coils (Fig.40) give the lowest
low-pass filter curve in such a way as of 50-year-plus guys designing stuff ‘by- distortion, but have higher resistance, are
to push its effective corner frequency ear’! I have measured many a curve that much bigger and cost twice as much as
up. Thus, instead of a low-pass filter at is a mirror-image of their hearing defi- ferrite cored types simply because much
3kHz we require one at 1.8kHz. ciencies. Young women generally have more copper is needed. A ferromagnetic

Fig.36. The KEF 104aB is one of the


Fig.35. One of my crossover development boards from the 1990s. Since most speakers nicest sounding speakers because of
have a low impedance and only a small range of crossover frequencies, a great range of it’s smooth slightly recessed midrange. It
values is not needed. Here, I can use: 0.1 to 6mH for the inductors, 0.22µF to 22µF for also has lower distortion due to its short
the capacitors and 0.22 to 330Ω for the resistors. voice-coil in a long gap.

Practical Electronics | October | 2019 49


configuration mini-monitor crosso-
vers. A populated 11Ω KEF-made board
is shown in Fig.42b. Falcon also do a
similar PCB called the ‘23aB’ (shown
in Fig.43a), which is designed for the
23aB circuit shown in Fig.51.
It can be argued that because of the
size of crossover components, a PCB isn’t
really needed at all. Hardwiring, 1930s
style, using M4 solder-tags screwed into
wood (shown in Fig.44) is superior,
Fig.37. Frequency response of 104aB.The fundamental resonance of the tweeter was having lower resistance and higher me-
suppressed using a notch in the crossover. chanical strength. Inductor orientation
is important to avoid mutual coupling.
Keep them as far apart as possible and
at right angles to one another, using
non-magnetic fixings – do remember
that metal boxes and steel screws can
cause inductance changes and distor-
tion. The Radiometal inductors in the
original LS3/5A are not so critical in
this respect, having a more enclosed
magnetic field. Hot glue is often used
to stop the components rattling.

Active crossovers
Passive crossovers are expensive because
they use large coils and non-polarised
capacitors which are rare, having almost
disappeared from mainstream elec-
tronics in the last 30 years. The coils
Fig.38. A Radiometal loudspeaker inductor used by the BBC. It combines the low distortion are typically £3.00 to £12.00 each and
of air-cored inductors with the low resistance of ferrite cores. Nickel-based laminations have the capacitors £1.00 to £5.00. Even the
a bright appearance rather than the dull grey look of silicon-iron transformer cores. 3W-rated resistors cost over £0.50 each.
The best solution is to go active and put
core reduces the turns of wire need- in Fig.33. Note that the non-standard ca- the filter before two power amplifiers,
ed for a given inductance because it pacitor values, such as C1 (3.7µF), are one each for the woofer and tweeter.
has a magnetic-field-boosting parame- made up from parallel combinations of This involves screwing a board con-
ter called ‘permeability’. It is easier to standard E6 series values. For C1, a 2.2µF taining a couple of power amps and a
wind air core coils yourself since any and a 1.5µF are used (denoted C1a and low-level active filter to the back of the
non-magnetic non-conducting former C1b) respectively. Likewise, C2 (3µF), is speaker cabinet. It enables standard
can be used, and we’ll wind some later. made of two 1.5µF capacitors in parallel. small passive components, op amps
LS3/5A crossover PCBs available on The capacitors are plastic-film (originally and lower-power power-amps to be
eBay, usually from Hong Kong where polycarbonate) with 5% tolerance and a used, reducing the total system cost
there is a thriving ‘unofficial’ (pirate) voltage rating of 63V minimum. and distortion.
LS3/5A industry. A new Chinese origi- A board for KEF’s 11Ω version is also Active speakers have not been as
nal BBC design 15Ω example is shown in available (shown in Fig.42a), which is popular as they should be because the
Fig.41 for the classic BBC circuit shown particularly useful for most standard potential cost reductions have not been
passed on to the customer. I’ve never un-
derstood why an active monitor often
costs twice as much as the passive ver-
sion. I suspect it’s production logistics,
insurance and labour costs. One aspect
that has also been ignored is that pas-
sive loudspeakers last 30 years while
the active electronic part usually lasts
about ten, and this has also put people
off. I’ve had active speakers in the work-
shop with popped SMPS electrolytics,
blown Class-D power-amp chips and
Fig.39. A ferrite-cored inductor – Malcolm burnt-through SMT boards that have
Jones of Falcon invented a trick where Fig.40. An air-cored coil – these need only just lasted beyond the guarantee.
the turns of wire were bonded together loads of turns to get the required Other problems are no circuit diagrams
by passing a large current though it. This inductance which pushes the cost and test data. It’s a great time to be in
was sufficient to just soften the insulation and resistance up. They have very low the landfill business! The only speak-
enough to get it to stick together without distortion and are easy to make one’s ers I’ve seen where the electronics is of
shorting. KEF and Celestion used to battle self as this example shows. It’s ‘held commensurate quality were in the Me-
with glue and tape for their inductors. together’ with red insulating tape. ridian M2 design.

50 Practical Electronics | October | 2019


Fig.41. (top left) LS3/5A PCBs can be bought on eBay from Hong
Kong (item 191278013041). (Technically, this is IP theft, but I
suspect the BBC is not interested in chasing PCB manufacturers);
(bottom left) Close up of Fig.32 showing the board populated.
Fig.42. (top right) A KEF-designed 11Ω crossover board from
eBay (item 201203704788). (below) a populated version of this
board. This is ideal for building standard ferrite inductor designs
of the topology described in Fig.34.
Fig.43. (below) Falcon 23aB crossover board layout, with BBC
15Ω low-pass section using ferrite inductors and the 104aB
(acoustic Butterworth) topology in the high-pass section.

Practical Electronics | October | 2019 51


B110A B200 / SP1039
Over-hung long voice coil Short voice coil, long gap
56,000 maxwell magnet Large 117,000 maxwell magnet

12mm 5.5mm
6mm front plate coil coil 9.5mm front plate
Force factor = 7.1N/A Force factor = 7.2N/A

Fig.44. (left) In passive crossovers, the components are so large


with impedances so low that 1930s-style building on wooden
boards gives excellent results – but with high labour costs
(fortunately, irrelevant for home constructors).
Fig.45. (above) Coil geometries giving large linear excursions:
(left) long-coil, short-gap used in the B110A, max linear
excursion (xmax 6mm peak-to-peak); (right) short-coil, long-
gap used in the 104aB (xmax 5mm peak-to-peak); and ATC
bass drivers.

Limitations acoustic music, such as soft jazz and bass end it’s much higher, typically 1%
There are limitations with small speak- choral, and appreciate stereo depth and to 3% mainly second harmonic. Along
ers governed by the immutable laws of low tonal colouration, then mini-mon- with the third harmonic distortion from
physics. They will not go loud or give itors are ideal. ferrite inductors and some capacitors
deep bass. However, the mid and top re- There is normally an optimum in- in passive crossovers, the situation can
sponse can be as good if not better than ternal air volume for a particular bass seem worrying. However, this type of
larger speakers. Significant bass below driver. For the B110A it is around five low-order harmonic distortion which
about 75Hz is generally impossible, litres. This is quite small because the increases with level is unnoticeable to
which is a realistic lowest fundamental B110 has a very floppy cone assembly, human ears, (on simple music). It can
resonance for a small sealed enclosure ie only a small amount of force is need- be enhancing and electronic music pro-
of five litres (0.2 cubic feet). To even get ed to move it a long way. This is called ducers often add it to the mix via FET
the bass down to this point efficiency ‘compliance’ and is normally expressed limiters and other processors.
has to be greatly sacrificed and to bring in meters per newton (m/N). More mod- As an illustration of speaker electro-
what bass there is into balance means ern drive units generally have stiffer mechanical non-linearity, Fig.46 shows a
attenuating the mid and top by about (less compliant) suspensions and high- graph (the only one I have seen) showing
10dB. Also, because the cone area is er resonant frequencies. These need a the cone excursion for a Richard Allen
so small the cone has to travel much bit more internal volume, say 7.5 litres, HP8B bass unit, an excellent eight-inch
further. This means using a very long possibly with a small reflex port, or the woofer from the late 1970s. Despite hav-
voice coil to get what is called a ‘long- resonance will end up nearer 85Hz. ing a 15mm-long voice coil, the linear
throw driver’. A long coil is only partly There are now many online calculators bit of the curve is only about 4mm. It is
immersed in the magnetic field, which for speaker enclosure formulae. An ad- also asymmetrical, these factors account
means two thirds of the coil is doing vantage of small cabinets is that they emit for the copious amounts of distortion
nothing (Fig.45, left). The system can be less acoustic coloured sound from their most speakers produce. The Wavecor
reversed, having a short coil in a long side and back panels compared to larger bass drivers from China and ATC driv-
gap (Fig.45, right), but then two thirds boxes, because of the reduced surface ers are among the few modern designs
of the magnet is doing nothing. area. Their narrow fronts also give more that address this problem.
Although giving superior linearity and natural dispersion on voices, possibly
reduced coil mass, the short coil results because they have similar dimensions to Impedance
in a very expensive loudspeaker, the a human head. One of the reasons small The original LS3/5A has a nominal
magnet assembly being the most cost- speakers seem to work well in typical- impedance of 15Ω (see Fig.47), which
ly part. Mini-monitor bass units often ly small English Victorian living rooms means the amplifier driving it gives
have a magnet that is almost the same is the bass boost that occurs due to the reduced power. This does minimise
diameter as the cone. Efficiency is also proximity of the heavy masonry and lath- solid-state amplifier distortion at low
reduced by measures used to reduce and-plaster walls. This effect is called powers, however; and I suspect this
colouration. Typically mini-monitors ‘boundary reinforcement’. If you live
have an efficiency of 82 decibels per in a modern open-plan/timber-framed
8
watt (dB/W) at one metre, but a 5-inch house then there will be little of this 6
Displacement
bass unit can only handle around 40W. bass boost available. Another factor is outward (mm) 4
These factors limit the maximum output midrange absorption from carpets and 2
Current (mA)
to typically 96dB at around one metre soft furnishings. 700 500 300 100 2100 300 500 700
for a stereo pair. This is loud enough
4 Displacement
for me with my ageing ears that were Distortion 6 inward (mm)
once very sensitive, but for many young Loudspeakers often have very high dis- 8
high-volume fans it is not enough. If tortion figures compared to amplifiers
you like gut-thumping bass, go for a and digital recording media. The low- Fig.46. Displacement graph for the
large modern bass-reflex design with a est total harmonic distortion that can be Richard Allen HP8B bass-mid driver –
paper cone. If you listen to small-scale achieved is 0.1% in the midrange. In the note the asymmetry and non-linearity.

52 Practical Electronics | October | 2019


which had a PVC rather than rubber sur-
round. This damped the cones’ break-up
modes better, but spoilt the bass transient
response due to mechanical hysteresis.
Subjectively, it sounded more coloured
than the BBC design, despite its much
smoother curve. A simplified version
of the crossover omitting the protection
circuitry is shown in Fig.48. However,
the BBC used live vs reproduced sound
comparisons and found that for small
Fig.47. Impedance curve of the LS3/5A – note the bass resonance at 80Hz. This is speakers a flat curve was not optimum;
a bit out of spec, it should be 75Hz. (The impedance plots still have a log frequency there had to be peaks and dips in the
scale, but the impedance on the vertical axis is linear. In this case it is 2Ω per division, right places for it to ‘sound’ flat.
or 50Ω for the whole scale). A typical LS3/5A curve is shown in
may contribute to the clarity of the copper into the available space in the Fig.49. It can be seen there are signifi-
LS3/5A in many Hi-Fi systems. Some voice-coil. cant peaks at 150Hz partly due to the
speaker designers attempt to gain extra high (1.2) Q of the bass resonance. It dis-
power by dropping the impedance to Amplifier plays a 1.2kHz cone resonance typical of
4Ω, such as the Harbeth HPL3, which When choosing an amplifier for the Bextrene cones with a rubber surround,
dips to 3.5Ω at 50Hz. This strategy LS3/5A, it should be a type that can sometimes described as a ‘quack colour-
fails because the real limiting factor swing a lot of volts, at least 50Vpk-pk. ation’, and an 8kHz to 10kHz tweeter
in acoustic power output is the usea- Massive current delivery into a low peak. The mid peak became more trou-
ble cone excursion and surface area. It impedance is not necessary. Lateral MOS- blesome to control with later versions of
also makes standard transistor power FET amplifiers with their high-voltage the B110A when flame retardants were
amps generate around four times more ±50V rails, such as the classic Maplin added to the Bextrene. Because of this,
crossover and power-supply-induced 50W MOSFET and Hitachi designs fit KEF redesigned the whole LS3/5A for
distortion. It’s best to stick with stand- into this category. It would be worth the BBC in 1988, making a new version
ard 8Ω drivers for this reason if doing using the MX50 board (see May 2017) of the bass unit (B110C) with a high
one’s own design. Also, 4Ω drivers with the Exicon MOSFETs, which I will damping coefficient PVC surround and
are less efficient, since they fit less do sometime. Lateral MOSFETs are also ferrite inductors. This had an 11Ω av-
ideal because they erage system impedance compared to
are the most reliable the original 15Ω BBC version. The cir-
16µF
audio output power cuit is shown in Fig.50 for reference.
Low-frequency
tuning capacitor devices. I’m a great Again, this just did not sound as good
1.3mH 2mH
400µF believer in using a as the original, having higher distortion
£200 amplifier and and poorer bass, which is why modern
15Ω
Input 10W digital player with LS3/5A manufacturer Falcon are only
7µF
+ £2000 loudspeakers making the original version. As a final
Woofer
10Ω
SP1057 because the speaker note, however, the variants can work
5W is the weakest link. well if relieved of their bass burden by
0V This is the audio en- use of an active subwoofer.
gineer’s approach, Other versions occasionally encoun-
Hi-Fi people will tered are the early kits sold by Falcon.
220Ω 330nF
definitely disagree! They used a crossover called the Fal-
con 23aB which used the original BBC
2.2Ω 3.3µF 7µF
LS3/5A variants low-pass section with the KEF 104aB
KEF made their own T27 tweeter section. This ‘new’ high-
speaker similar to pass circuit is shown in Fig.51 (and also
Tweeter
0.25mH T27 the LS3/5A called Fig.43). A 104aB crossover assembly
+
the R101 which had is shown in Fig.52. I think this high-
a much flatter fre- pass filter sounds better than the proper
quency response. It LS3/5A design because it suppresses
used an ‘improved’ the tweeter’s fundamental resonance.
Fig.48. Kef R101 crossover circuit (simpliied with the protection version of the B110A KEF also did a ‘Home Constructor
circuitry omitted). called the B110B Series’ mini-monitor called the CS1A,
which was designed to mimic the
LS3/5A and used the same bridged-T
circuit trick in Fig.51. The CS1A cross-
over circuit is shown in Fig.53. There
was also a popular Wilmslow Audio kit
from the 1980s called the Micro Moni-
tor that was based on this. The electrical
crossover curve of the proper LS3/5A
is shown in Fig.54.
Finally, the JR149 (Fig.3) crossover
had a unique layout with a circular PCB
mounted in the base, as shown in Fig.55.
Fig.49. Typical LS3/5A acoustic frequency response – measured with a microphone.

Practical Electronics | October | 2019 53


humidity, causing voice-coil rubbing. It
Input
R5
0.33Ω
R6
0.33Ω
R7
0.33Ω
R8
0.5Ω
R5-R12 3W is usable up to 250°C, but does sound
very good. Aluminium is a good con-
Link
ductor of heat and is usable up to 350°C.
+1dB +0.5dB –0.5dB –1dB Output
It is also a good conductor of electricity,
Link which causes a damping problem. This
C1, C2, C3
16µF
NC is what causes the problem. We have all
(6.8µF + 6.8µF +2.2µF) R9 R10 R11 R12
0V 22Ω 15Ω 10Ω 22Ω 0V seen the YouTube video of dropping a
magnet down a copper pipe (https://
16Ω*
11W L4 Attenuator network youtu.be/lnY9u8TfFKI). It shows how
*R1 + R2 C6 0.066mH inserted here
2x 33Ω in parallel 3.3µF the magnet is slowed due to currents
induced in the pipe, which causes an
C7, C8 R4 Tweeter
Woofer 6.6µF 10Ω T27 opposing magnetic force. It’s a prop I
L1 L2 B110C SP1032
Input 1.43mH 1.1mH SP1228
(2x 3.3µF) 3W
8Ω use as one of my classroom demos. This
R3 6Ω R13
2.2Ω 8.2Ω slowing-damping effect also occurs with
11W + L3 3W
0.24mH aluminium voice-coil formers and can
+
C4, C5
9µF R13 readily be felt when moving a detached
2.2µF
0V
(6.8µF + 2.2µF) cone/coil assembly up and down in the
magnetic gap. These voice coils normally
have a gap to avoid creating a complete
Fig.50. The ‘new’ post-1987 KEF-designed 11Ω LS3/5A crossover circuit. shorted turn to reduce this effect, but it
It seems it’s virtually impossible to PE ‘LS3/5A style’ monitor. Unlike most doesn’t really work, possibly because of
improve the LS3/5A, there is some imitators, it will use the most impor- eddy currents in the aluminium.
overall synergy about the design that tant part, the B110A bass unit, which In addition to the damping problem,
is difficult to quantify, which is why imparts most of the LS3/5A ‘character’. there is another, more insidious effect,
Falcon are making an exact copy of the Descending into the swamp of Hi-Fi which is increased intermodulation dis-
1970s design. subjectivism, this is mainly due to the tortion in the mid-range, which is clearly
There was a ‘crazy’ speaker that used Bextrene ‘quack’ which is enhancing. audible, although I’ve not measured it
the same sized cabinet and B110 bass All cone materials have some coloura- yet. This may arise from the aluminium
unit called the ‘Kan’, made by that Brit- tion; there is the ‘polypropylene sound’, eddy currents being coupled by trans-
ish Hi-Fi leviathan, Linn. It was quite which is lower in frequency and Q, but former action into the iron pole-pieces of
popular in the 1980s, even the editor dulls rather than enhances. Modern bass the speaker magnet assembly. This iron
had a pair. (In fact, they still have quite units do not sound as good because of has high hysteresis, which when an in-
a following.) This was not designed to their higher resonance, no doping and duced current flows through it will, in
be accurate, but entertaining with Linn higher surround damping. They will turn, couple a distorted current into the
vinyl sources. It had no mid-range flat- go louder, however – essential for all voice-coil current. ATC have got round
tening, sounding very punchy and loud. fans of Spinal-Tap-style approaches to this problem (which occurs to some ex-
It had to be used against a wall to pro- volume (https://youtu.be/s9F5fhJQo34). tent in all electromagnetic transducers)
vide a compensating bass boost. This by using electrically insulating sin-
position destroyed the illusion of stereo New theory tered-iron rings on the centre pole and
depth, which requires stand-mounting Another factor, which I do not yet fully front plate. Another trick, used by Seas
away from walls. These speakers did not understand, is the poor sound quality and Wavecor, is to put copper caps and
sound so good with CD sources, but I that comes from using aluminium voice- shorting rings on the centre pole. The
have used a parametric equaliser with coil formers (Fig.56), which are now lower resistance of the copper shunts
them to good effect. the norm for raised power handling. away any currents from the higher resist-
The B110A uses Nomex, a polyamide ance iron. This loose-coupling distortion
PE ‘LS3/5A style’ monitor ‘paper’ which is an
If you are rich, then do buy a new pair electrical insulator,
of 1975-designed LS3/5As. If not, I but it tends to blis-
have arranged with Jerry Bloomfield, ter when it gets hot
the MD of Falcon, to supply parts for a in conditions of high

Component numbers
are for Falcon PCB 7 C7
C7: tweeter
(see Fig.43) 600nF
resonant dip
(±10%)
All capacitors are R6
plastic film 3Ω
C5 C6 5W
R4 3.3.µF 10µF
3.9Ω to 5.6Ω (0 +10%) (0 +10%)
Input
C8 Black
10µF wire
L3 is air-cored with (0 –10%) –
0.55Ω DC resistance Tweeter
L3
0.3mH T27
C7 selected low-value
680nF polyester capacitor +
Blue
0V wire
Fig.52. KEF 104aB crossover internals. Note the Callins/Elcap
EX50 non-polarised capacitors. These are old wet electrolytics, but
Fig.51. KEF T27 acoustic Butterworth ilter, to be coupled with epoxy sealed so they last well. They should still always be checked
the 15Ω LS3/5A low-pass section shown in Fig.33. This was for high ESR and raised capacitance values. In this case, an original
used in the KEF 104aB and the Falcon 23aB circuits. 600nF device has been replaced with a yellow polyester type.

54 Practical Electronics | October | 2019


C1
25µF
*Ferrite core

L1 L2
0.85mH* 3.1mH*
(≤0.3Ω) (≤0.3Ω)

Woofer
B110A
Input R1 R2
47Ω 150Ω +
6W 2W C2
5µF

0V

R5 C3
220Ω 330nF

R4
3Ω C4 C5
6W 3.3µF 7µF

L3 Tweeter
0.18mH T27
≤0.2Ω +

Fig.53. The KEF CS1A crossover. This has less of a mid-peak Fig.55. No, it’s not a missile circuit board, but the circular
than the proper LS3/5A crossover. I prefer the CS1A. crossover from a JR149.
effect becomes more intense as the fre- systems because the damping effect lim- old adage ‘you can buy it ready-made at
quency increases, so is worse in bass/ its ‘jump-out’ when the coil moves too Richer Sounds for half the cost of buy-
mid drivers in two-way systems. It does far out of the magnetic gap. ing the bits’. I have a classic solution
not seem to be a problem with woofers for the beleaguered constructor who
below around 200Hz. Here, aluminium Good news can’t afford the Falcon monitor parts,
voice-coils do offer a worthwhile power One problem encountered by home and that is some nice surplus stock.
handling advantage in large bass reflex constructors of Hi-Fi equipment is that This was kindly donated to me by the
wife of Hi-Fi designer Charles Pepper,
a retired speaker maker. I had a whole
garage full of these excellent Beyond-
The-Box speakers based on Danish Vifa
units. I’ve kept 30 drivers and cross-
overs back for readers, although the
bulk had to go to Earworm Records in
York. They are happy to supply com-
plete speakers, although you will have
to paint the cabinets. More details, in-
cluding simple tweaks that can be done
to improve these speakers in later arti-
Fig.54. The electrical crossover curve of the BBC 15Ω LS3/5A using the drivers as loads. cles of this series.

PE Mini-monitor resources Falcon Acoustics Next month


www.falconacoustics.co.uk We’ve covered a huge amount of
BBC R&D papers 01865 358001 LS3/5A-specific material in Part 1 and
www.bbc.co.uk/rd/publications Part 2. Next month, we take a short break
Wavecor to look at some general speaker hardware
Drive units B110 data sheet and cut www.wavecor.com items (but still relevant to this project)
out details – see the October 2019 before returning in the December issue
download on the PE website for data Good article: A History of Kef Drive with the design and construction of a
sheets for both the B110A and T27. Units from the 1960s and 70s passive LS3/5A design.
www.t-linespeakers.org/drivers/ http://bit.ly/pe-oct19-kef
b110.html
Wilmslow Audio
Unofficial LS3/5A Support Site www.wilmslowaudio.co.uk
This has a fantastic section ‘library &
links’ with the BBC papers. The cab- If you want to hear some electronic
inet drawings by Peter Lotter can be music mixed on LS3/5As.
found in the DIY section. https://soundcloud.com/shufflehound
www.ls35a.com
Sealed box calculator
Earworm records http://bit.ly/pe-oct19-boxcalc
www.earwormrecords.co.uk
[email protected] Free speaker design software Fig.56. Voice-coil wound on an aluminium
01904 627488 http://bit.ly/pe-oct19-spkr former. I suspect these cause problems
with eddy-current induction.

Practical Electronics | October | 2019 55


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

Mike & Richard Tooley CD


JUMP START ELECTRONICS
CD

TEACH-IN 3
£7.99

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

FROM THE PUBLISHERS OF


TEACH-IN 5
huge range of subjects that will interest everyone involved 15 design and build circuit projects for newcomers or
CIRCUIT SURGERY JUMP START
in electronics – from newcomers to the hobby and i The how and why of circuit design those following courses in school and colleges. 15 desi gn and bui l d ci rcui t proj ects
dedi cated to newcomers or those

PRACTICALLY SPEAKING
fol l owi ng courses i n school s and

students to experienced constructors and professionals. The projects are:  Moisture Detector  Quiz
col l eges
i The techniques of electronic
project construction PRACTICALLY SPEAKING
The first section (80 pages) is dedicated to Circuit INGENUITY UNLIMITED
i Over 40 different circuit ideas
Machine  Battery Voltage Checker  Solar- The techni ques of proj ect constructi on

Surgery, EPE/PE’s regular clinic dealing with readers’ Powered Charger  Versatile Theft Alarm  Spooky
PIC ‘N MIX
Star ti ng out wi th PIC mi crocontrol l ers

nics
Teach-
In FREE Circuits  Frost Alarm  Mini Christmas Lights 
queries on circuit design problems – from voltage ro
FREE M
TEACH-IN 1 CD-ROM bo
rn e Pu
blishing Ltd 20
10 CD-RO

iPod Speaker  Logic Probe  DC Motor Controller


im

regulation to using SPICE circuit simulation software.

t
W

1
TWO TEACH-INs FOR TEACH-I N 2

Elec
©
THE PRICE OF ONE!
TWO TEACH-I Ns FOR

The second section – Practically Speaking –  Egg Timer  Signal Injector Probe  Simple Radio
THE PRI CE OF ONE!
i The free CD-ROM provides cal
Plus:
MikroElektro
nika,

a broad-based introduction
a practi The fr ee CD-ROM pr ovi des a
Provides to PIC Microchip pe
introduction llers L-Tek PoSco
to electronics microcontro
for Windo
ws software pr ac t i c al i nt r oduc t i on t o PIC

Receiver  Temperature Alarm.


CD ROM
i A complete stand-alone
start
n Program
should m i c r oc ont r ol l er s

covers hands-on aspects of electronics construction.


This CD
Simulatio
y, if not
Circuit d version)
automaticallindex.html
8 TINA (Limite ramming tutorial in 11 parts plus free double-click
In 2 Pl us Mi kroEl ektroni ka,
PIC Prog n) Teach-
8 FLOW
CODE V3 d versio software nicsorne Publishing
Ltd

Software Quizzes to Test


(Limite Ele©ctro
2013 Wimb
PIC and
dsPIC are
rated
MPLAB, logy Incorpo ogy
Mi crochi p and L-Tek PoScope
active
Again, a whole range of subjects, from soldering to
and logo, Techno Technol
ledge
ip name of Microchip ip
8 Inter The Microch
Microch .09 software
Your Know
arks s. © 2013 016-02
ed tradem countrie 1. MCCD1
register and other d. Issue
in the USAAll rights reserve
Inc.

avoiding problems with static electricity and identifying PLUS 29/07/201


3 09:59:25

components is covered. Finally, our collection of PIC’n’ Mix – starting out with the popular range of PIC
Ingenuity Unlimited circuits provides over 40 circuit designs submitted by readers. microcontrollers and Practically Speaking – tips and techniques for project construction.
The CD-ROM also contains the complete Electronics Teach-In 1 book, which
provides a broad-based introduction to electronics in PDF form, plus interactive The CD-ROM also contains:
quizzes to test your knowledge and TINA circuit simulation software (a limited  Complete Teach-In 2 book, a practical introduction to PIC microprocessors
version – plus a specially written TINA Tutorial).  MikroElektronika, Microchip and L-Tek PoScope software.
The Teach-In 1 series covers everything from electric current through to
microprocessors and microcontrollers, and each part includes demonstration circuits
to build on breadboards or to simulate on your PC.

ELECTRONICS TEACH-IN 4 – CD-ROM EE M


Three Teach-ins for the great price of
FR -RO £8.99

A BROAD-BASED INTRODUCTION TO ELECTRONICS


CD

£18.95
ELECTRONICS FROM THE PUBLISHERS OF

Mike & Richard Tooley


TEACH-IN 4 FREE
CD-RO

PLUS you also get the contents of the


M
WORT
A BROAD-BASED
The Teach-In 4 CD-ROM covers three of the most
H
£2 9.9
5
INTRODUCTION TO ELECTRONICS
i An el even par t t u t or i al
important electronics units that are currently studied in
many schools and colleges. These include, Edexcel
i Uses i n expen si ve c i r c u i t
si m u l at i on sof t w ar e free CD-ROM from each issue...
BTEC level 2 awards and the electronics units of the
... so that’s another TWO Teach-Ins and
FREE M
CD-RO

Diploma in Engineering, Level 2. THE MODERN ELECTRONI CS MANUAL


Th e e s s e n t i al r e f e r e n c e

The CD-ROM also contains the full Modern w o r k f o r e ve r yo n e

The Full Modern Electronics Manual!


s t u d yi n g e l e c t r o n i c s

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

contains over 800 pages of electronics theory,


i I n -dept h t h eor y
autorun,
should
This software in Windows
i Ext en si ve dat a t abl es

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

This CD-ROM
Adobe®
requires
Reader™
from
an d w eb l i n k s
UAL
projects, data, assembly instructions and web links.
dable Free
Downloa be.com

MAN.co.u
www.ado

BA SE .epe mag
k
2011
www ne Publishi
ng Ltd.

A package of exceptional value that will appeal


© Wimbor

to anyone interested in learning about electronics –


hobbyists, students or professionals.

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


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

Audio Out – an
CD
£8.99 FR RO
- £8.99

ELECTRONI CS ELECTRONI CS and Circuit Surgery


CD
ELECTRONI CS
The Teach-In 6 CD- FROM THE PUBLISHERS OF

analogue expert’s take FROM THE PUBLISHERS OF

by Ian Bell – ‘State


FREE

ROM also contains all TEACH-I N 6 on specialist circuits


TEACH-I N 7 TEACH-I N 8 CD-ROM SOFTWARE

Machines part 1 and 2’.


FOR
THE TEACH-
IN 8
FROM THE PUBLISHERS OF SERIES

RASPBERRY Pi ®
DISCRETE LINEAR CIRCUIT DESIGN
the necessary software A COMPREHENSIVE GUIDE TO RASPBERRY Pi
Practically Speaking – • Understand linear circuit design INTRODUCING THE ARDUINO
• Pi PROJECT – SOMETHING TO BUILD • Design simple, but elegant circuits
The CD-ROM includes
• Hardware – learn about components and circuits
• Pi CLASS – SPECIFIC LEARNING AIMS
for the series, so that • PYTHON QUICKSTART – SPECIFIC PROGRAMMING TOPICS
the techniques of
• Learn with ‘TINA’ – modern CAD software
• Five projects to build: Pre-amp, Headphone Amp,
• Programming – powerful integrated development system
• Microcontrollers – understand control operations
• Pi WORLD – ACCESSORIES, BOOKS ETC
the files for:
Tone Control, VU-meter, High Performance Audio Power Amp • Communications – connect to PCs and other Arduinos
• HOME BAKING – FOLLOW-UP ACTIVITIES
readers and circuit project building.
FREE
designers can get DVD-R
OM
ALL THE
SOFTWA
TEACH-I
RE
N6
FREE M
-RO
CD CIRCUIT
 Teach-In 8
FOR THE RRY Pi

started quickly and RASPBE ALL THE

 Microchip MPLAB
RE FOR
SERIES SOFTWA 7
CH-IN
THE TEA
SERIES

easily with the projects


IDE XC8 8-bit compiler
and ideas covered. PLUS
PLUS...
 PICkit 3 User Guide
Pi B+ UPDATE
INTERFACE – a series of AUDIO OUT
ten Pi related features An analogue expert’s take
on specialist circuits
PLUS...
 Lab-Nation
REVIEWS – Optically PIC n’MIX
isolated ADC and I/O PRACTICALLY SPEAKING PICs and the PICkit 3 - A beginners
interface boards The techniques of project guide. The why and how to build

Smartscope software.
building PIC-based projects

ORDER YOUR BUNDLE TODAY!


JUST CALL 01202 880299 – OR VISIT www.epemag.com
STORE YOUR BACK ISSUES ON CD-ROMS
VOL 1 BACK ISSUES – January 1999 to June 1999
Plus bonus material from Nov and Dec 1998 ONLY £16.45 each
VOL 2 BACK ISSUES – July 1999 to December 1999
Five years just £29.95
VOL 3 BACK ISSUES – January 2000 to June 2000
including VAT and p&p
VOL 4 BACK ISSUES – July 2000 to December 2000
VOL 5 BACK ISSUES – January 2001 to June 2001 VOL 23 BACK ISSUES – January 2010 to June 2010
VOL 6 BACK ISSUES – July 2001 to December 2001 VOL 24 BACK ISSUES – July 2010 to December 2010
VOL 7 BACK ISSUES – January 2002 to June 2002 VOL 25 BACK ISSUES – January 2011 to June 2011
VOL 8 BACK ISSUES – July 2002 to December 2002 VOL 26 BACK ISSUES – July 2011 to December 2011
VOL 9 BACK ISSUES – January 2003 to June 2003 VOL 27 BACK ISSUES – January 2012 to June 2012
VOL 10 BACK ISSUES – July 2003 to December 2003 VOL 28 BACK ISSUES – July 2012 to December 2012
VOL 11 BACK ISSUES – January 2004 to June 2004 VOL 29 BACK ISSUES – January 2013 to June 2013
VOL 12 BACK ISSUES – July 2004 to December 2004 VOL 30 BACK ISSUES – July 2013 to December 2013
VOL 13 BACK ISSUES – January 2005 to June 2005 VOL 31 BACK ISSUES – January 2014 to June 2014
VOL 14 BACK ISSUES – July 2005 to December 2005 VOL 32 BACK ISSUES – July 2014 to December 2014
VOL 15 BACK ISSUES – January 2006 to June 2006 VOL 33 BACK ISSUES – January 2015 to June 2015
VOL 16 BACK ISSUES – July 2006 to December 2006 VOL 34 BACK ISSUES – July 2015 to December 2015
VOL 17 BACK ISSUES – January 2007 to June 2007 VOL 35 BACK ISSUES – January 2016 to June 2016
VOL 18 BACK ISSUES – July 2007 to December 2007 VOL 36 BACK ISSUES – July 2016 to December 2016
VOL 19 BACK ISSUES – January 2008 to June 2008 VOL 37 BACK ISSUES – January 2017 to June 2017
VOL 20 BACK ISSUES – July 2008 to December 2008 VOL 38 BACK ISSUES – July 2017 to December 2017
VOL 21 BACK ISSUES – January 2009 to June 2009 VOL 39 BACK ISSUES – January 2018 to June 2018
VOL 22 BACK ISSUES – July 2009 to December 2009 VOL 40 BACK ISSUES – July 2018 to December 2018

FIVE-YEAR DVD/CD-ROMs 15 YEARS OF EPE!


No.1 – Jan 03 to Dec 07 AMAZING
No.2 – Jan 04 to Dec 08 BUNDLE OFFER
No.3 – Jan 05 to Dec 09 No.1 – Jan 03 to Dec 07
No.4 – Jan 06 to Dec 10
PLUS
No.5 – Jan 07 to Dec 11
No.6 – Jan 08 to Dec 12
No.6 – Jan 08 to Dec 12
PLUS
No.7 – Jan 09 to Dec 13
No.8 – Jan 10 to Dec 14
No.11 – Jan 13 to Dec 17
No.9 – Jan 11 to Dec 15
ALL FOR JUST
No.10 – Jan 12 to Dec 16
No.11 – Jan 13 to Dec 17 £39.95
No.12 – Jan 14 to Dec 18 – NEW! All DVD/CD-ROMs are suitable for any PC with a DVD/CD-ROM drive.
They require Adobe Acrobat Reader (free from: www.adobe.com/acrobat)

ORDER YOUR CD-ROMs TODAY!


JUST CALL 01202 880299 – OR VISIT www.epemag.com
Make it with Micromite

Phil Boyce – hands on with the mighty PIC-powered, BASIC microcontroller

Part 9: Introduction to MMBASIC graphical commands

L
ast month, in Part 8, we The IDM introduced last month will be Ctrl-C to stop the test program. Notice
discussed how to assemble the used throughout the topics covered here that the clock is still displayed on the IPS
versatile IPS Display Module (IDM). (and also for future projects). So, if you screen – but, a closer look reveals the time
We also covered how to check that it had haven’t already done so, we recommended is not being updated.
been assembled correctly by loading a test you first take the time to build an IDM –
program into the MKC; this resulted in a this will also help you appreciate just The IDM test program
simplified clock being displayed on the how easy it is to create a project which The IDM test code is currently a single
IPS screen, as shown in Fig.1. incorporates a high-quality IPS screen. program; this was intentional to help
The IDM comprises four useful elements: make last month’s testing easier.
 Mini IPS colour display Preparation However, this test program should really
 Accurate real-time clock (RTC) module In order to set things up for this month, be considered as comprising two main
 Infrared (IR) receiver you will need to successfully install and ‘blocks’ of code. Referring to Listing 1,
 Piezo sounder. run the IDM test program (as outlined at and to help with the following discussion,
the end of Part 8). there are two blocks of code: one without
With these four elements connected to a To recap the steps involved, first plug a shaded background and one highlighted
Micromite, the IDM forms the perfect basis the IDM into the DM/MKC, and connect with a shaded background to indicate
for our Mini MKC Clock project; and by only this to your computer. Start your terminal the following:
changing the program in the Micromite, application (TeraTerm or PuTTY for  The unshaded block of code (ie, the top
the IDM can also be used as the hardware Windows; Terminal/Screen for MacOS) and part of the listing) is the actual program
base for many other different projects. ensure that you have the IDM_TestCode. code. This code redraws the time and
In previous parts of this series we txt file installed in your MKC (download date (continually) on the IPS screen,
have discussed how to interact with an from the September page of the PE website) synchronises the Micromite with the
IR receiver, and also a piezo sounder. – note that you may still have this in your RTC (every minute), and ‘beeps’ the
Therefore, to be able to write programs MKC if you followed last month’s article. piezo sounder (whenever an IR signal
that fully utilise all of the IDM’s hardware Press the reset button on the DM, check to is detected).
we need to learn how to use MMBASIC’s see if the IPS display shows a simplified  The shaded code is the IPS screen driver.
graphical commands; and this will be the clock. If not, type RUN at the command This is an essential (and pre-written)
main topic covered this month. We will prompt to start the program (ignore any piece of code and ensures the IPS screen
learn by example, demonstrating how to ‘CPU exception’ errors), and then press the works properly and responds correctly
use the commands that write and draw to reset button once again. You should now to MMBASIC’s graphical commands.
the mini IPS colour display. We will also see the clock; if not, simply work through You do not need to worry about how
discuss the two commands that interact the detail of the test procedure discussed this code works – just accept that it does
with the RTC module. To assist with our at the end of last month’s article. all the ‘difficult stuff’ required to make
learning, we will first go over the details Important Note – some people have the attached IPS screen work.
of the IDM test program from last month, reported that the IDM test program displays
and how we can ‘tidy up’ the code by using the clock but that it is drawn in the wrong If you now start the EDITor (F4) you will
what is called the ‘Library’ to store the IPS colours (and is offset slightly) as shown see the IDM_TestCode program; it should
screen driver. Finally, to wrap everything in Fig.2. If this is the case, then you will be identical to that shown in Listing 1 (note
up, we will load a new version of the need to change the last three parameters in that Listing 1 has a chunk of the shaded
Mini MKC Clock program into the MKC, the line of code within SUB mm.startup IPS screen driver code missing – this is
and discuss some additional ideas and (which is at the end of the program, and just to keep the printed listing reasonably
features you may wish to implement into which is also highlighted in bold in Listing short). Starting at the top, and working
your own customised version of the code. 1). Make the change as follows: down towards the line: ‘IPS DRIVER,
(from): ST7735S 22,23,21, 1,1,-1,-2
(to): ST7735S 22,23,21, 1,0,0,0 Micromite code
Questions? Please email Phil at:
[email protected] The code in this article is available
Once the IDM test program is successfully
for download from the PE website.
running and the colours are correct, press

58 Practical Electronics | October | 2019


screen driver built into MMBASIC would consume much too
much memory. For this reason, the specific screen driver that
you require (when not using an ILI9341 screen) will first need
to be installed (ideally in the method that we will now discuss).
The screen driver should be regarded as a block of pre-
written code that never needs to be changed. As it currently
stands in the IDM test program, the IPS screen driver is at risk
of being altered (accidentally or otherwise) from within the
EDITor; for example, a slip of the hand on the keyboard could
result in just one of the many lines of hexadecimal numbers
Fig.1. Running the IDM test program will display this simple being changed; and even if it is only changed by just a single
clock on the IPS screen. character, the result will almost certainly make the IPS screen
you should recognise all of the commands used apart from unresponsive (and possible the Micromite too). To avoid this
three (don’t worry if you don’t understand what the program is we are now going to learn how to keep the screen driver code
doing – it will be explained shortly). The three commands not out of harm’s way by placing it in a part of the Micromite’s
covered so far are: BOX, TEXT and RTC GETTIME. These will be memory called the ‘Library’.
explained later in this article; they are commands that control
graphics and the RTC. The Library – a safe place to be
Scroll through the rest of the IDM test code (below the line: The Library is a special area in the Micromite that can be thought
‘IPS DRIVER) and you will see lines of alphanumeric characters. of as a safe place to store code that does not need to be altered
This is the screen driver and will be unintelligible, but do not in any way. This code is permanently stored in the Micromite’s
alter it in any way! (It is a hexadecimal representation of some C memory – even after typing NEW to delete a program. Understand
code – but this is a topic that is beyond the scope of this series.) that code stored in the Library will not appear in the EDITor
when editing a program (which is exactly why the Library is
The screen driver a safe place for the code to be), but it is still accessible to the
The important point to understand is that the screen driver program code. Some examples of code that are suited for the
is an essential block of pre-written code that in simple terms Library include:
makes it possible to use MMBASIC’s graphical commands with n D rivers (as currently being discussed)
an attached screen. We are not talking here about the console n U ser-defined fonts (a future topic)
screen – we are referring to a dedicated graphical screen to which n S UBs you’ve written which add new commands to MMBASIC
the Micromite can write text and numbers, and draw graphics.
MMBASIC’s graphical commands do not communicate with Note that a subroutine can be written in the C language (instead
the console screen (but PRINT does, as do VT100 Escape codes of the more usual BASIC); and in this case it is called a CSUB. Any
discussed last month). subroutine written in C will run much faster than one written in
There are many different types of graphical screens that we can BASIC; and a CSUB is visible in MMBASIC code as a sequence
connect with a Micromite; however, only one type of graphical of hexadecimal numbers (generated by an external program). If
screen can be connected at a time. The choice really depends on you look at the IPS screen driver in the IDM test program you
which screen best suits the requirements of a project. Different will see that it is a CSUB.
screens have different properties, the most obvious are its To add code to the Library, you first enter it into the EDITor
physical size and the screen’s pixel resolution. On a technical as you would do with a normal program, and then RUN it to
level, each screen will have a different, yet essential, ‘start-up test that it works as expected. Once you are happy it is working
configuration sequence’. This is a sequence of data values that correctly, you simply type LIBRARY SAVE at the command
need to be sent to the screen’s dedicated built-in controller chip prompt. This will then compress the code, and move it into
in order to define certain properties (including screen size, pixel the Library. The program memory will then be emptied (since
count, orientation, and type of hardware interface). The start-up the code is now safe within the Library). Note that LIBRARY
sequence is an important part of the screen driver code and is SAVE can be used multiple times – each time, any code in the
sent from the Micromite to the attached display whenever power program memory (EDITor) will be added to the end of any
is first applied (get the sequence of the startup-data wrong, and existing code in the Library. We will now put the IPS screen
the screen simply won’t work). So the next important point to driver into the Library – take care to follow the steps exactly
understand is that each type of screen as discussed below.
needs its own specific pre-written screen First, we need to remove the parts
driver to work properly; there is no one of the code from the IDM_TextCode
generic screen driver that will work with program that are not part of the screen
every type of graphical screen. driver (in other words, delete the lines
That said, there is a family of screens of code that are unshaded in Listing 1).
that all use the ILI9341 IC. The ILI9341 Simply go to the EDITor and delete the
typically controls LCD screens ranging top section of the program to remove
in size from 2.2 up to 3.2-inches, and the initial comments, the Setup, the
all with a pixel resolution of 320 x 240. Main-Program, and the three SUBs –
These ILI9341 screens can actually use this will leave everything from the line
the same ILI9341 screen driver; so for ‘ IPS DRIVER down to the end (do not
this reason, this ‘common’ screen driver shorten the CSUB section in any way).
is built into the MMBASIC firmware. To Now press F2 to SAVE and RUN the
enable it, you use the command OPTION code. Check you get no syntax errors.
LCDPANEL ILI9341,... However, Fig.2. If your clock is displayed with incorrect Next, press the reset button and check
there are many other different types of colours (and is offset) as shown here, then that after the usual MMBASIC ‘welcome
graphical screen that you may wish to change the last three parameters in SUB message’ you see the line ST7735S
use instead, and to have every single MM.STARTUP (see ‘Important Note’ opposite). driver loaded (as shown in Fig.3).

Practical Electronics | October | 2019 59


Fig.4. To view
any code in
the Library, use
the command
Library List.
Here we see the
compressed
version of the
Fig.3. On power-up, you should see the above confirmation
IPS screen driver
message indicating that the ST7735S screen driver has been
code.
successfully loaded.
If you get any syntax error, or you do not see the line ST7735S ‘Preparation’ section above). The first of these three numbers is
driver loaded, then repeat the above steps of loading IDM_ either a 0 or a 1, and will result in the binary representation of the
TestCode.txt, and the subsequent editing to extract the IPS screen colour values being ‘logically inverted’ (put another way, if the
driver, taking care not to alter the screen driver code in any way. colours are wrong, change this value). The last two parameters
Once this is operating correctly, type LIBRARY SAVE (at the are an offset so that the top-left corner of the screen can be set
command prompt). On pressing Enter, the Micromite will store as coordinate 0,0 (more on coordinates later).
a compressed version of the code into the Library. To check this, And that’s all there is to it – we have loaded the required pre-
two things are worth mentioning that you should try out. First, written IPS screen driver ‘C’ code into the (safe) Library where it
go into the EDITor – it should now be blank with no code visible can’t be accidentally altered; and used a SUB named MM.STARTUP
(if not – then check for any missed error messages in the steps to ensure that the screen driver is loaded on power up.
above). Exit the EDITor. The second check is to view the code in
the Library with the command LIBRARY LIST. This will show the ‘Tidier’ version of IDM_TestCode
compressed version of the IPS screen driver – see Fig.4 (note that Since we now have the IPS screen driver safely stored in the
the hexadecimal numbers between the lines CSub ST7735S and Library, we can remove its code from the original IDM test program
End CSub have been compressed and hence are no longer visible). (ie, remove the shaded code in Listing 1). This produces a much
You have now successfully loaded the IPS screen driver into shorter (and hence tidier) version of the IDM_TestCode program.
the Micromite’s Library where it will remain in place until The MKC should now have no code in the program memory
you purposely delete it. Just for your information, to remove (wiped clear after performing the Library Save). Reload the
the screen driver, you simply delete all the code stored in the original IDM_TestCode.txt file into the MKC, and then use the
Library. This is achieved with the command LIBRARY DELETE EDITor to remove every line of code after the last SUB in the
(don’t do this now). One more useful tip: if you need to check Subroutines section (hence delete all the lines from ‘ IPS
if there is code in the Library, simply type LIBRARY LIST at the DRIVER to the very end). Press F2 to SAVE and RUN, and the
command prompt. This is handy because sometimes any existing code should run as it did before – if not, check the code in the
(and unrequired) Library code that you have forgotten about may EDITor is the same as that shown unshaded in Listing 1.
prevent you from accessing an I/O pin due to the Library code Let’s just take a moment to understand that all we have done is
reserving certain I/O pins. To demonstrate this, simply type to split the initial IDM test program into two parts – the screen
the following at the command prompt: SETPIN 22,DOUT – you driver ‘chunk’ is stored safely in the Library (this code doesn’t
will see an error message warning you that pin 22 is reserved need to change), and the program code ‘chunk’ is stored in the
on startup (it is used by the IPS screen driver). program memory (we can still edit the code’s functionality in
One more very important point that needs to be discussed here the same way we would alter any program).
is the subroutine SUB mm.startup in the last three lines of code.
How the IDM test code works
SUB MM.STARTUP With this shortened version of the program, it is much easier to
This is really simple to follow – I promise! If a SUB is given the explain how it works. For the following explanation, you can
reserved name MM.STARTUP then the code contained within that either refer to the unshaded code in Listing 1, or look at your
SUB will be run on initial power-up (before the program in the code in the EDITor. As previously mentioned, all commands
main memory is even run). One very good example as to why (apart from BOX, TEXT, and RTC GETTIME) have been discussed
you may need to do this is to load a screen driver – exactly as in earlier parts of this series.
here. Note that SUB MM.STARTUP can be placed either in the We will now explain the functional lines of code (do also refer
Library, or in normal program memory; however, in most cases to the comments included at the end of each line of code), and
it makes sense to test it first in program memory, and then once remember that this code is simply showing the time (and date)
it is working as expected, place SUB MM.STARTUP in the Library on the IPS screen.
so that nothing is accidentally altered. The first line of code in the SETUP section of the program sets
Assuming you have successfully followed the previous steps, OPTION AUTORUN ON, ensuring that the program will automatically
then SUB MM.STARTUP will be in the Library. On powering up the run on power up (no need to manually type RUN at the command
MKC, the single line of code we have here in SUB MM.STARTUP prompt). Remember, this only takes effect after the first time the
is run, and this is just a call to the subroutine named ST7735S program is run (unless you have already set OPTION AUTORUN
(which is a CSUB containing the pre-written IPS screen driver). ON at the command prompt).
The numbers you can see alongside are (configurable) parameters The next line sets up an IR interrupt subroutine (named
that CSUB ST7735S needs to be informed about. For those IR_Int) which will automatically be called whenever the
interested in a little more detail: the first three numbers are the Micromite detects an IR signal on input Pin 16 (the pin to
I/O pin numbers that connect the Micromite with the IPS display which the IR receiver outputs any IR data detected).
(to IPS module pins DC, RES, CS). Next is a value between 1 A subroutine (SUB TimeFromRTC) is set to be called automatically
and 4 that represents the screen’s orientation (ie, landscape or every minute (60000ms = 60s = 1min) with the SETTICK command.
portrait, normal or inverted). The last three numbers are ‘tweaks’ The fourth line of code immediately calls the subroutine
to alter the image on the screen to allow for variations across TimeFromRTC, which in turn loads the Micromite’s Time$ and
different IPS module manufacturers (see ‘Important Note’ in the Date$ with the high-accuracy data stored in the RTC module

60 Practical Electronics | October | 2019


(by use of the RTC GETTIME command Now repeat the above command,
that will be explained shortly). but this time press Ctrl-C to stop the
The PWM line of code performs two animation. You will see now that the
simultaneous tasks (on PWM Channel 2, circles remain on the screen (rather
at a frequency of 800Hz). PWM Channel than being cleared). We will use these
2A (Micromite pin 26) is set to 100% circles for the next topic.
duty cycle and this turns on the IPS
backlight to maximum brightness. IPS backlight control
PWM Channel 2B (Micromite pin 24) When designing a project that
is simultaneously set to 50% duty cycle incorporates a display, sometimes the
resulting in an 800Hz square-wave signal display may need to be switched off
on one side of the piezo sounder. Note (to save power, or because no screen
that the piezo sounder will not make information needs to be displayed).
a sound until its other pin (connected Likewise, at some other time, the display
Fig.5. GUI TEST LCDPANEL produces this
to Micromite pin 15) is at 0V. The next will need to be turned on. Rather than
animation drawing lots of circles. It is useful to
line of code is using the BOX command, just abruptly switching the screen
check that the attached screen is working, and
and this functionality will be explained between dark (off) and bright (on), a
also that the screen driver is correctly installed.
in detail shortly (in brief, it clears the nice effect is a smart-looking fade-up/
screen by drawing a blue box with a green border). fade-down. To achieve, this we need to be able to adjust the
Next, a subroutine (colon) is called; this in turn uses two TEXT backlight’s brightness; and this is why the IDM has been designed
commands (that will also be explained shortly); in essence, it with the screens backlight (BLK pin) connected to a PWM output
draws two separate dots which form the ‘:’ character between on the Micromite (PWM channel 2A; pin 26).
the clock’s hours and minutes. By default, the backlight will be fully on when the BLK pin
Next comes the MAIN PROGRAM section, which is just a DO/LOOP on the IPS screen is either floating or is at 3.3V. However, by
containing four lines. Each of these four lines of code uses the sending (low-going) pulses to PWM channel 2A, we can adjust
TEXT command to continually display the current time and date. the brightness of the backlight.
The only other code left to explain is the three lines of code in With the ‘static’ coloured circles that are currently on the screen,
SUB IR_Int which is called whenever an IR signal is detected. enter the following PWM command (being sure to look at the IPS
This subroutine (when called) initially sets Micromite pin 15 display when you hit the Enter key): PWM 2,800,50,50 – this
to an output, which by default is set low (ie, set to 0V). This sends a 50% duty cycle (ie, a square-wave) to the backlight; so
places 0V onto the second pin of the piezo sounder, enabling it it is rapidly (800Hz) switched between on/off. The result is that
to make ‘noise’ (at 800Hz). you should see the IPS backlight brightness reduce slightly. If
The next line of code is just a PAUSE for 10ms, after which the you missed it, then repeat the above with a lower value in place
final line of code will set Micromite pin 15 back to a ‘floating’ of the highlighted 50 (for example, use: PWM 2,800,20,50).
state – the piezo sounder will be ‘silenced’. The end result of this Repeat with 10, and then 0. You will see that the backlight
subroutine is a simple ‘beep’ whenever an IR signal is detected becomes darker and darker, until it eventually turns off (with
– and here in the test code it is used to confirm that both the 0). The reason it turns off with a PWM value of 0 is that the
piezo sounder and IR receiver are working properly (and that PWM output is effectively always at 0V (and taking the BLK
those parts of the IDM have been assembled correctly). pin low (0V) means the backlight is turned off). So by altering
If the above still seems a little tricky to understand, just think of the relevant parameter of the PWM command (for channel 2A)
the program as continually updating the IPS display with the time we can control the IPS backlight brightness. Now set it back to
and date from the Micromite’s built-in Time$ and Date$. Every full brightness with PWM 2,800,100,50 and the circles will re-
60 seconds, the Time$ and Date$ in the Micromite (which can appear. One thing to point out here is that the value used (think
drift very slightly) are resynchronised with the high-accuracy RTC. of it as a percentage value between 0 and 100) is not a linear
Whenever an IR signal is detected, a short beep sound is heard. representation of backlight brightness. In other words, a value
With the IPS screen driver safely installed in the Library, of 50(%) does not mean half brightness.
along with a better understanding of how the IDM test program Now back to the fade effect mentioned above. You can, for
operates, we can now begin exploring MMBASIC’s graphical example, use a FOR/NEXT loop and send the increasing brightness
commands. We can actually do this by typing the command(s) value to the PWM pin to create a fade-up effect. To see this in
directly at the command prompt (no need to remove, edit, or action, type the following (case insensitive) at the command
replace the IDM test program). But the really nice thing about prompt (look at the IPS display when you hit the Enter key):
all this is that with the IDM’s high-quality IPS screen, we will FOR i=0 to 100:PWM 2,800,i,50:PAUSE 10:NEXT i
immediately see the result of each command.
So before we start, ensure you have completed all the steps If you get an error, it will be because of a syntax (spelling) error.
above, and then press Ctrl-C to stop the IDM test program from In this case, simply retype the line, being careful to check that
running – this should mean that you can see the command it is as shown above before you press the Enter key.
prompt in your terminal program.
CLS command
MMBASIC graphical commands One of the very first BASIC commands that most people learnt
Let’s start by using a built-in graphics command to test that a back in the 1980s was the CLear Screen command, CLS. With the
connected screen does indeed work correctly. At the command circles still on the screen, type CLS at the command prompt and
prompt type GUI TEST LCDPANEL (and press Enter). You will watch the screen when you hit Enter. Remember, the graphics
now see the IPS screen fill up with rapidly drawn coloured commands that we are working through here only affect the
circles – see Fig.5. Note that the command prompt on the console attached (IPS) screen, they do not act on the console screen.
is unavailable while this test animation is playing on the IPS You will recall from last month’s article that it is certain Escape
screen. To stop the test (and to get the command prompt back) Codes that affect and control the behaviour of the console screen.
simply press any key on the keyboard. Pressing a key will also In MMBASIC, we can add an optional colour parameter to
clear the IPS screen by turning it back to black. CLS. To do this, we use the RGB(colourname) feature, replacing

Practical Electronics | October | 2019 61


colourname with one of the following x = 80, y = 40. The alignment parameter
recognised colours: red, green, blue, allows us to use different parts of the
cyan, magenta, yellow, black, white, displayed text to be positioned at the
brown, gray. Now type the following specified coordinates. Two letters are
(case insensitive): CLS RGB(red) used to specify the alignment, the first
No prizes for guessing what this will is the horizontal alignment and can
do. Take a few minutes to try the other be either: L(eft), C(entre), or R(ight)
colours from the list. Note that the whole – similar to left, centre, and right
screen is changed to the colour specified justification in a wordprocessor. The
(or currently black if the optional colour second alignment letter is the vertical
parameter is not specified). alignment and it can be either: T(op),
M(iddle), or B(ottom). Note that as with
TEXT command most things in MMBASIC, the alignment
By now you are reasonably familiar letters are not case sensitive.
with the PRINT command. It is used to Fig.6. The result of the command: So, back to our previous example,
display alphanumerics on the console TEXT 80,40,”HELLO”,cm,1,4,rgb(green) to get the word HELLO centred in the
screen. The TEXT command is simply the middle of the screen, we need to use
equivalent for displaying alphanumerics the two-letter alignment CM (Centre-
on the attached (IPS) screen. However, there are several additional Middle). Type CLS and then: TEXT 80,40,”HELLO”,CM
parameters that it needs. The command structure is as follows This time you will see the word HELLO in the middle of the
(do also refer to the Micromite User Manual): screen. These different alignments are useful in different scenarios.
TEXT x, y, string$ [,alignment] [,font] [,scale] For example, if you want to display a number (of varying length)
[,ink_colour] [,paper_colour] in the bottom-right hand corner of the screen, then use the TEXT
command with coordinates x =159, and y = 79, and with RB
It looks complex, but actually it has been designed to be both alignment – try it with: TEXT 159,79,”12345”,rb
easy to use and powerful. All the parameters in square brackets No matter how long the number, it will not run over the right
are optional (and will take a default value if left unspecified). (or bottom) edge of the screen. Take a few minutes to experiment
So to keep things easy for now, just type CLS (screen to black), with some of the other alignment combinations.
and then type: TEXT 0,0,”Hello World!”
You will now see the words printed (in white) in the top left Font size
corner of the IPS screen – not very exciting, and certainly not The next two parameters, font and scale affect the size of the font
very colourful, but we will be expanding on this. displayed by the TEXT command. The font parameter is a number
and simply defines which font to use – although in the standard
Screen coordinates Micromite there is just one built-in font (number 1). It is possible
To understand what happened with the last command we first to add user-defined fonts (ie, different styles and different sizes
need to talk about screen coordinates. Any point on the screen of font) and this topic will be covered next month. For now, just
can be specified by a pair of numbers (the coordinates) called use 1 for the font parameter. The scale parameter is a number
‘x’ and ‘y’. The x-coordinate represents the horizontal position between 1 and 15 and is the ‘pixel multiplier’ value that determines
(across the screen), and the y-coordinate represents the vertical the size of the displayed characters. For example, a scale of 2
position . The top-left corner of the screen is defined as coordinate will double both the width and the height of the characters. To
x = 0 and y = 0. Moving across to the right of the screen means see this type CLS and then: TEXT 80,40,”HELLO”,cm,1,2
a higher x value, and moving down the screen means a higher You will now see the word HELLO displayed twice as big. Repeat
y value. The coordinates MMBASIC use are defined in terms of the above TEXT command but increase scale to 3 (there is no
individual screen pixels. need to clear the screen as the bigger font size will overwrite
Our IPS screen has a pixel resolution of 160 pixels wide by 80 the smaller font), and then repeat with scale values of 4 and
pixels high. So with the top-left corner being defined as position 5. Notice that scale 4 just fits on the screen, whereas scale 5
x = 0, y = 0; this means the opposite corner (in the bottom-right) runs over the edges (but it is still centred in the middle of the
has coordinates x = 159, y = 79. screen). For the IPS screen used here with a finite number of
The first two parameters of the TEXT command always need pixels, larger scale values are meaningless and will result in
to be specified as they represent the screen position where the no characters appearing to be displayed (6 is the highest value
text will appear. And as we have just seen with the previous we can use in the example here).
TEXT example, x = 0 and y = 0 resulted in the text being in the
top left corner. Note that most of the other graphical commands Font Colour
also require the x and y coordinates to be specified in order to Expanding on the above (and using scale 4), type CLS and then:
define the relevant screen position. TEXT 80,40,”HELLO”,cm,1,4,RGB(GREEN). This defines the
ink_colour parameter and you will see HELLO in green (and
Changing text appearance filling the screen due to the scale parameter of 4) – see Fig.6.
To introduce how to use some of the other parameters of the TEXT Any of the colours previously mentioned can be used, so try some
command, we will now repeat the above but use the coordinates others (vary the scale, alignment, and x, y coordinates too).
for the centre of the screen, which are simply half way along So far, all the text displayed has been on a black background, but
the 160 pixel width, and half way down the 80 pixel height; so there are situations where we may want a coloured background;
this means x = 80 and y = 40. Now type: TEXT 80,40,”HELLO” eg, to highlight a warning. To do this we use the last parameter
– paper_colour. Type CLS and then: TEXT 80,20,” ALARM!
Alignment ”,cm,1,2,rgb(red),rgb(yellow) – see Fig.7.
Notice that the word HELLO is not centred in the middle of the You should now have a good understanding of the TEXT
screen. This is because by default, the alignment uses the top-left command, and how to vary the parameters to give many different
corner of the displayed text to be positioned at the specified co- effects. Refer back to the IDM test program and look at how the
ordinates. Therefore, the top-left corner of the letter ‘H’ is at position parameters are being used in each of the six lines of code that use

62 Practical Electronics | October | 2019


‘ Make it with Micromite Listing 1: The IDM_TestCode program. The unshaded code is the actual program code,
‘ IPS Display Module (IDM) - Test Code and the shaded code is the ‘IPS screen driver’. Note that many lines from the IPS driver
‘ Code written: July 2019
have been removed here to allow the listing to fit on the page.
‘ --------------------------------------------------------------------------------------------------------
‘ IMPORTANT NOTE:
‘ ===============

‘ After installing the code - PRESS THE RESET BUTTON on the DM to load the IPS DRIVER. Then type RUN.

‘ If you get any error, power down, then power back up!
‘ --------------------------------------------------------------------------------------------------------

‘ SETUP
‘ =====

Option autorun on ‘ ensure program starts automatically on power-up
IR DevCode, KeyCode, IR_Int ‘ set up an Infra-Red interrupt (to test IR and Piezo)
SetTick 60000,TimeFromRTC ‘ every 60 seconds, update MM time & date from RTC (to avoid drift)
TimeFromRTC ‘ call SUB to initially get the correct time and date from the RTC
PWM 2,800,100,50 ‘ PWM 2 (800Hz): backlight 100% (ON), buzzer 50% (ON when Pin15=0v)
Box 0,0,160,80,3,RGB(green),RGB(blue) ‘ clear IPS screen to a blue background with a thin green border
colon ‘ call SUB to draw a colon for the clock (between hours and minutes)

‘ MAIN PROGRAM
‘ ============

Do
Text 31,25,Left$(Time$,2),cm,1,3,RGB(yellow),RGB(Blue) ‘ display hours (font 1, scale 3)
Text 88,25,Mid$(Time$,4,2),cm,1,3,RGB(yellow),RGB(Blue) ‘ display minutes (font 1, scale 3)
Text 132,30,Right$(Time$,2),cm,1,2,RGB(white),RGB(blue) ‘ display seconds (font 1, scale 2)
Text 80,58,Left$(Date$,6)+Right$(Date$,2),cm,1,2,RGB(red),RGB(Blue) ‘ display date (font 1, scale 2)
Loop

‘ SUBROUTINES
‘ ===========

Sub Colon ‘ SUB to draw a colon for the clock (between hours and minutes)
Text 60,15,”.”,cm,1,1,RGB(white),RGB(blue) ‘ draw ‘top’ dot
Text 60,29,”.”,cm,1,1,RGB(white),RGB(blue) ‘ draw ‘bottom’ dot
End Sub

Sub TimeFromRTC ‘ SUB to get time from RTC and load MM system Time$ and Date$
RTC gettime ‘ (refer to User Manual for further details)
End Sub

Sub IR_Int ‘ IR interrupt SUB (makes a BEEP sound whenever an IR signal detected)
SetPin 15,dout ‘ set pin 15 to 0v i.e. piezo will sound (at 800Hz, at 50% duty)
Pause 10 ‘ brief pause to allow audible ‘beep’
SetPin 15,off ‘ return pin 15 to ‘floating’ i.e. switch piezo OFF
End Sub

‘ IPS DRIVER ‘ WARNING: DO NOT CHANGE ANY VALUES or CODE below!!!!


‘ ==========

CSub ST7735S
00000232
‘spi_write_data Peter Mather
27BDFFE0 AFBF001C AFB10018 AFB00014 309100FF 3C109D00 8E030090 8E02001C
8064002C 0040F809 24050006 8E030090 8E02001C 8064002D 0040F809 24050005 I want to give credit to Peter Mather, based in the
3C02BF80 AC515820 3C03BF80 8C625810 30420080 1040FFFD 3C02BF80 8C425820 UK. He has written the ‘C’ code screen drivers for
3C029D00 8C430090 8C42001C 8064002D 0040F809 24050006 8FBF001C 8FB10018 all of the different screen types that the Micromite
8FB00014 03E00008 27BD0020
‘spi_write_command is compatible with. These range from tiny mono
27BDFFE0 AFBF001C AFB10018 AFB00014 309100FF 3C109D00 8E030090 8E02001C OLEDs, to larger colour OLEDs, LCDs with sizes
8064002C 0040F809 24050005 8E030090 8E02001C 8064002D 0040F809 24050005
.
from 1.8 to 9-inches, LED matrices, and also IPS
. screens like the one we are using here. Peter’s
. work has allowed Geoff Graham (the brain behind
AC515830 AC575800 AC5E5840 3C049D00 24841314 0411FD67 00000000 8FBF0074
8FBE0070 8FB7006C 8FB60068 8FB50064 8FB40060 8FB3005C 8FB20058 8FB10054 MMBASIC) to focus on the features of each of the
8FB00050 03E00008 27BD0078 graphical commands without worrying about the
‘.rodata actual screen hardware attached to the Micromite.
‘startup
37375453 20533533 76697264 6C207265 6564616F 000A0D64
End CSub

Sub mm.startup ‘ system SUB to ensure IPS driver loaded at Power-Up


ST7735S 22,23,21, 1,1,-1,-2 ‘ DCpin, RESETpin, CSpin, orientation (1-4)[, invertdisplay(0,1)], xshift, yshift
End Sub

the TEXT command. You should now be able to appreciate what COLOUR command
is happening in the four lines in the Main Program to display the We have just seen how to display coloured text (potentially
time and date, and also the two lines in the colon subroutine on a coloured background) on the IPS screen. The colours
to display the ‘:’ character between the hours and the minutes. used are defined by the ink_colour and paper_colour
Try writing a short program that creates your own colourful parameters in the TEXT command. We have also seen how
screen of different sized text. CLS (with no parameters) clears the screen to black. In fact,

Practical Electronics | October | 2019 63


CLS clears the screen to the current Other graphical commands
paper_colour, which by default is Having explained the TEXT command
black. (Note that the default ink_ in some detail, the following graphical
colour is white.) commands will be much easier to follow.
Now imagine a scenario where we The syntax will be shown, along with
want to have a program that will use a brief description, and an example
the IPS screen mainly with green text (or two), for each command. It is
on a blue background. To clear the recommended you try the examples
screen, we would need to use CLS first, and then experiment with each
RGB(BLUE), and to write text, we command by changing the parameters
would always need to set the ink_ to see its effect(s). Use CLS when the
colour parameter to RGB(GREEN), screen gets too ‘busy’; and press the
and always set the paper_colour DM’s reset button if you wish to set the
parameter to RGB(BLUE). None of default ink and paper colours back to
these are really an issue, but we could Fig.7. The result of the command: white and black respectively. Parameters
save a bit of typing (especially if we TEXT 80,20,” ALARM! ”,cm,1,2, in square brackets are optional.
have lots of lines of code using TEXT) rgb(red),rgb(yellow)
if we were able to set green and blue as the default ink and PIXEL x,y [,ink_colour]
paper colours. This is where the COLOUR command is useful. Sets the defined pixel at location x, y to the colour specified (or
Type CLS (the screen clears to the default black) and then type: to the default ink_colour if no colour is specified).
COLOUR rgb(green),rgb(blue)
Nothing will appear to have happened; however, this command Example: look very closely, the pixel is small:
has now set the default ink and paper colours to green and blue PIXEL 80,40,rgb(magenta)
(respectively). Now type CLS and see what happens. Then type:
TEXT 80,40,”HELLO”,cm,1,3 LINE x1,y1,x2,y2 [,line_width] [,ink_colour]
You will notice that the text is now in the default green colour Draw a straight line between coordinate pairs x1,y1 and x2,y2.
without having to set the ink_colour parameter in the TEXT For horizontal or vertical lines (ie, where x1=x2 or y1=y2), the
command. The default colours remain in place until you change optional line_width parameter determines the thickness of the
them once again with the COLOUR command (or when you first line (in pixels) and is a value between 1 and 100. The colour of
power up the Micromite, upon which the colours revert to white the line is defined by the optional ink_colour parameter (or
(ink) and black (paper)). defined by the default ink_colour if no colour is specified).

More colours please Example 1: draw a yellow line three-pixels thick across the
So far, when we have needed to specify a colour, we have top of the screen: LINE 0,0,159,0,3,rgb(yellow)
used RGB(colour_name) with colour_name being one of
the ten built-in defined colours from the list: red, green, Example 2: draw a diagonal line (in default ink colour) from
blue, cyan, magenta, yellow, black, white, brown, and the bottom-left to the top-right corner. Note that even though a
gray. However, it is possible to use many more colours in line_width of 50 is specified, this parameter is ignored (and a
MMBASIC by using the standard RGB numeric notation that value of 1 used) as the line is not purely horizontal or vertical:
computers use. A computer typically uses a 24-bit number line 0,79,159,0,50
to represent ‘any’ colour in the spectrum by mixing a certain
amount of red, green and blue together. So by using three BOX x,y,box_width,box_height [,border_width]
separate 8-bit binary numbers (three values between 0 and 255 [,border_colour] [,fill_colour]
decimal) to represent the three intensity values of red, green, Draw a box with its top-left corner at coordinate x,y. Parameters
and blue, we are able to define virtually any colour (16,777,216 box_width and box_height determine the size of the box (in
hues to be precise!). An intensity value of 255 represents full pixels). The optional border_width parameter (defaults to 1)
intensity, and a value of 0 represent ‘no intensity’. Note: If defines the size of the border line that draws the outside edge
you have ever used an art, or photo-editing application, on a of the box (and may be set to 0). The optional border_colour
computer then you will no doubt have seen a colour-selector parameter is used to define the colour of the border (or uses
tool which will highlight the three specific RGB values for default ink_colour if not specified). The optional fill_colour
any colour selected. parameter will fill the inside of the box with the colour specified.
If possible, start an application such as Microsoft Paint, and If omitted, the screen area inside the box is left unaffected.
use the colour selector/editor tool to see the RGB values of any
colour you click on. Selecting a pre-defined pale pink colour Example 1: draw a blue box with a green border (three pixels
yields the RGB values as 255,128, and 192 respectively. Once thick) over the whole screen area:
we have the required RGB values, MMBASIC makes it very Box 0,0,159,79,3,rgb(0,255,0),rgb(blue)
easy to implement the colour by using the syntax: RGB(red,
green, blue) where the parameters red, green and blue Example 2: draw a thick-walled (and unfilled) square in the
are simply replaced with the three individual RGB intensity centre of the screen using the default ink colour:
values (between 0 and 255). To see this type CLS and then: TEXT BOX 60,20,40,40,10
80,40,”HELLO”,cm,1,4,rgb(255,128,192)
The result should now be the word HELLO in a pale pink RBOX x,y,box_width,box_height [,border_radius]
colour, filling the entire IPS screen. Experiment further by [,border_colour] [,fill_colour]
choosing a different colour that you like. Use either a colour Draws a box with rounded corners. Similar to the above BOX
selector tool, or search on the internet for ‘RGB colour command; the top-left corner is at coordinate position x,y; and the
picker’; and after obtaining the three RGB values, use the parameters box_width and box_height determine the size of the
CLS RGB(r,g,b) command to fill the screen with your rbox (in pixels). The optional border_radius parameter (defaults
chosen colour. to 10) defines the radius of the rounded corner (in pixels). Note

64 Practical Electronics | October | 2019


that the border_width is not definable as it is fixed to a width command. The syntax is: RTC SetTime year, month, day,
of one pixel. The optional border_colour parameter is used hours, minutes, seconds
to define the colour of the border (or uses default ink_colour Providing there is an RTC module attached to the Micromite,
if not specified). The optional fill_colour parameter will fill and the RTC module has a working back-up battery, then the RTC
the inside of the rbox with the colour specified. If omitted, the SETTIME command only needs to be used whenever the time
screen area inside the rbox is left unaffected. (and/or date) needs to be set – the RTC will then accurately keep
a track of time. However, this time is ‘inside’ the RTC module
Example 1: draws an ‘athletics track’ shape touching all sides and not in the Micromite itself. To get the time information into
of the screen: rbox 0,0,159,79,40 the Micromite’s built-in Time$ and Date$, the RTC GetTime
command is used (there are no parameters required for this
Example 2: draws a white rectangular ‘button’ with a gray border. command). Referring back to the IDM test program, you will
Note that even though the IPS screen is not a touch screen, the see the subroutine SUB TimeFromRTC contains just a single line
RBox example given here is useful for creating on-screen buttons of code that uses the RTC GETTIME command. So, calling SUB
for use with touch-screens. Combine with a TEXT command to TimeFromRTC will load the current ‘correct’ RTC information
position a ‘button label’ on top of the button (more on this in a into Time$ and Date$ – however, the Micromite’s Time$ will
later article when we explore touch-screens): still drift, so ideally it needs to be resynchronised with the correct
RBox 40,30,80,40,10,rgb(gray),rgb(255,255,255) (or at least more accurate) RTC information on a regular basis.
This is why in the IDM program the SETTICK command has
CIRCLE x, y, radius [,border_width] [,aspect_ratio] been used to set an interrupt that calls SUB TimeFromRTC every
[,border_colour] [,fill_colour] minute. Now the built-in Time$ and Date$ will be kept accurate.
This command draws a circle, centred at position x,y and with
the specified radius (in pixels). The optional border_width MKC Clock v2
parameter is the width of the border used for the circumference The topics covered this month should make the IDM test program
and can be zero (it defaults to 1). The optional aspect_ratio much easier to follow; and it can be considered as version ‘v1’
parameter is a (floating point) number and defaults to 1. An of the Mini MKC Clock project. To improve on the software,
aspect_ratio of 0.5 will draw an oval where the width is half and also to assist with next month’s topic of user-defined fonts,
the height. The optional border_colour parameter is used to please download the file: MKC_Clock_v2.txt from the October
define the colour of the border (uses default ink_colour if not 2019 page of the PE website and load it into your MKC. However,
specified). The optional fill_colour parameter will fill the before you do this, make sure that you have the IPS screen driver
inside of the circle with the colour specified. If omitted, the (and sub mm.startup) installed correctly inside the Library.
screen area inside the circle is left unaffected. On running the MKC Clock v2 program, everything should look
more or less the same as before; however, note that the date is
Example 1a: draw a white ‘eye shape’ in the centre of the screen now displayed in a more ‘human-friendly’ format. As usual, the
– (continue with next two examples, don’t type CLS in between!): code has comments throughout to explain its operation – but
Circle 80,40,20,1,2,rgb(red),rgb(white) don’t worry if you can’t follow it all. The main thing is to get
the code running so that you have a clock displayed correctly
Example 1b: draw a green ‘eyeball’: (and accurately) on the IPS screen.
Circle 80,40,15,1,1,rgb(gray),rgb(green)
Some future ideas for the MKC_Clock
Example 1c: draw the eye’s pupil: The idea behind the Mini MKC Clock is to show how the
Circle 80,40,10,1,0.3, rgb(gray),rgb(black) elements that we are learning about can be implemented into
creating something useful. It is important to understand that
Try experimenting by mixing commands on the screen at the they are all just ‘building-blocks’, any combination of which
same time (like the last three examples that created an ‘eye’). may spark some ideas for your own use. We are currently in a
Mixing text and graphics allows for some professional-looking position to add functionality to our Mini MKC Clock by simply
screens to be created – all under software control. writing the relevant code (and without the need to change the
hardware). Here, I just want to highlight some ideas to provoke
RTC commands some thoughts as to what we could add:
For completeness, and to understand how to interact with all n I R Remote – add a menu to select different functions
four hardware elements of the IDM, we need to briefly cover n A larm – set an alarm time; optional ‘snooze’ feature
MMBASIC’s two RTC commands. n T imer – set a countdown ‘start’ time; sound the piezo
The Micromite has two built-in ‘strings’ (Time$ and Date$) n S topwatch – start counting up from 00:00:00
that keep a ‘count’ from whenever the Micromite is powered n T hermometer – display temperature with high/low alarms
up – hence, they do not contain the true time and date. We
can set them manually, for example: Time$=“09:43:22” and These features may seem complicated, but it just comes down
Date$=“21/09/2019” – however, there are two disadvantages to coding (as we will see next month…). And this is the real
with this. First, we need to manually set the time and date beauty of the Micromite and MMBASIC: it is quick and easy to
whenever the Micromite is powered up (or is reset); and second, implement powerful features that would otherwise be difficult.
Time$ ‘drifts’ by a few seconds each hour – so it is not very
accurate. Thus, for the Micromite to keep track of the true Next month
time, we need to add an RTC module. We saw last month how We have seen how to use MMBASICs graphical commands. Next
to physically connect an RTC module. For the software side month, we will add useful information such as temperature to
there are just two simple commands to use: RTC SETTIME (to the Mini MKC Clock’s display using an inexpensive DS1820
initially set the date and time), and RTC GETTIME (to receive digital thermometer and a handful of lines of code. We will also
time data and automatically set the Micromite’s built-in Time$ add other functionality that allows an IR remote to have overall
and Date$). control of the Mini MKC Clock. Plus, to make the time display
Last month, we showed you how to load the correct time into look more traditional (think seven-segment), we will discuss
the RTC module by passing six parameters to the RTC SetTime how to implement user-defined font’s. Until then, have fun!

Practical Electronics | October | 2019 65


Max’s Cool Beans
By Max the Magnificent

A little more on metastability, and back to the ‘HRRG’

T
here is an old adage that goes: (Fig.15) alleviates the metastability prob- loop, three of which are used to drive our
‘There are no stupid questions, lem. Say ASYNC changes state just before two-stage synchroniser.
only stupid answers.’ Of course, t2 (instead of just before t1), thereby vio- To look at this another way, we have a
this prompts us to ask, ‘If there are no lating the setup time of DFF1 and causing group of three pulses on our CLK signal fol-
stupid questions, then what sort of META to end up in the wrong state due to lowed by 15,997 cycles of the main system
questions do stupid people ask?’ metastability somewhere between t2 and clock before we see another group of three
While you are pondering this conun- t3. Doesn’t this still result in CLEAN being pulses on our CLK signal. Bearing this in
drum, let me tell you a short story. After in the incorrect state?’ mind, let’s consider the various violation
university, my first job was in a team at a This is a very good question. To address possibilities (Fig.2.)
large company designing central process- it, let’s remind ourselves that our asynchro- We begin with the ASYNC, META, and
ing units (CPUs) for mainframe computers. nous signal from the outside world, which CLEAN signals all carrying the same 0 or 1
Every week, we would all attend an inter- we are assuming is connected to something value (we don’t care which), which we’ve
nal lecture on a technical topic. Invariably, like a hand-operated toggle switch, is being shown in green. At some stage a user flips
the speaker would say something that went fed into a two-stage synchroniser (Fig.1). the toggle switch (see also my column
right over my head and I would sit there As we discussed in my previous Cool on different types of switches https://bit.
thinking, ‘What on earth did that mean?’ Beans column, when we initiate a read op- ly/2Mqqk6k) to its opposite 1 or 0 value,
I didn’t like to raise my hand because I eration in our code, this actually triggers which we’ve shown in blue.
was sure everyone else did understand and a series of three pulses on the CLK signal. Let’s start with the case of no violations
they’d think me foolish. Then a more expe- Assuming a transition on the ASYNC signal (a). The first edge on CLK loads the new
rienced engineer called Joe Taylor would causes a setup or hold violation on DFF1 (blue) value on ASYNC into DFF1, appear-
pipe up and say, ‘Excuse me, can you ex- on the first active (rising) edge on the CLK ing on its META output after the register’s
plain that point in a little more detail?’ signal, then the worst-case scenario is that propagation delay. The second edge on CLK
And I would breathe a sigh of relief and it will require three active edges on CLK loads the new (blue) value on META into
think, ‘Thank you, Joe!’ to convey the new value on the ASYNC DFF2, appearing on its CLEAN output. So,
It was only relatively recently that I came signal to the CLEAN signal being fed into we’re all done after just two CLK cycles
to realise that Joe already knew the answers the CPU. As our astute reader observed, (the third CLK simply reloads everything
– he was only asking the questions to help however, we didn’t discuss what would without changing anything).
out any inexperienced engineers like yours happen if the transition on the ASYNC Now let’s consider the transition on
truly. Now that I’m older and wiser I do signal were to cause a violation on the ASYNC causing a violation on the first
the same thing myself; if I’m attending a second or third active edges on CLK. CLK (b), thereby causing DFF1/META to
lecture and I see any younger engineers The problem is, we’ve been focusing go metastable (pink). Assuming the worst-
looking puzzled, I’ll put my hand up and too closely on our three CLK pulses. Let’s case scenario, following its recovery time,
ask the question that’s on everyone’s lips. ‘zoom out’ a bit and consider things from a DFF1 ‘collapses’ into its original, unwanted
higher level. A typical scenario is that our (green) state. So, it’s not until the second
Feeling a little unstable program will be cycling around a loop in edge on CLK that the new value on ASYNC
The reason I’m waffling on about not being which we perform a bunch of
afraid to ask questions is that I just received different tasks, one being to read (n) ms (n+1) ms
an email from a long-time member of the PE the state of our digital input pin.
community querying last month’s column Let’s say we’ve set our loop to CLK

saying: ‘I really found your last couple execute once every millisecond. ASYNC
of PE articles interesting. Your August Assuming we’re running an META (a) No violation
column really extended my understand- Arduino Micro, Uno, or Mega CLEAN
ing of the SR latch. However, with respect with a 16MHz clock, this means
to September’s column, I am struggling to there are 16,000 clock cycles ASYNC
Violates 1st
see how the 3-clock cycle read of ASYNC every time we go through our META (b)
clock edge
CLEAN
Outside World Inside the MCU
ASYNC
Two-Stage Synchronizer Violates 2nd
META (c)
clock edge
Input pin DFF1 DFF2
CLEAN
ASYNC META CLEAN To the
d q d q CPU
Asynchronous ASYNC
signal Violates 3rd
META (d)
clock edge
CLEAN
CLK Derived from
system clock

Fig.1. Two-stage synchroniser. Fig.2. Different violation possibilities.

66 Practical Electronics | October | 2019


involves two sets of instructions like LOAD/
STORE to read/write the memory and IN/
There can be
muliple OUT to read/write the I/O ports. The ad-
ROM RAM
blocks of RAM vantage of this scheme is that the same
and ROM
memory addresses can be used to point to
clock locations in memory or to I/O ports, de-
12 pending on which instructions are used.
Address bus An alternative technique that’s simpler
4 to implement and easier to understand is
CPU Data bus called memory-mapped I/O (MMIO). In
? this case, the I/O ports share the same ad-
reset_n
Control bus dress space as the memory, and they are
IRQ_n accessed using the same LOAD/STORE
instructions. This is the technique we’ve
There can be
Input Output lots of input decided to use in the HRRG.
Port Port and output One point I’d like to make while I’m
ports
thinking about it is that even though the
Fig.3. Bird’s-eye view of the From the To the HRRG has only a 4-bit data bus, it is con-
HRRG 4-bit computer. outside world outside world ceptually able to do anything a larger ma-
chine can do, just slower and with less ef-
is loaded into DFF1/META, but this CLK gates and registers. In the fullness of time, ficiency. For example, a 4-bit nibble can
also loads the original, unwanted value on the physical implementation will involve only store 24 = 16 different values, so we
META into DFF2. Thus, it’s not until the a suite of glass-fronted wooden cabinets, could use it to represent unsigned integers
third edge on CLK that the new, desired each containing a portion of the HRRG in the range 0 to 15. If we wish to work
value on META is loaded into DFF/CLEAN. realised in a different implementation with larger values, we can simply use
Things start to get interesting when the technology, including relays, vacuum more nibbles: two nibbles (8 bits) would
transition on ASYNC causes violations on tubes, transistors, and jelly-bean integrated allow us to represent unsigned integers in
the second or third CLK edges, as illustrat- circuits, along with cabinets containing the range 0 to 255, three nibbles (12 bits)
ed in (c) and (d), respectively. The result mechanical, magnetic, pneumatic, and would allow us to represent unsigned in-
is that the new value on ASYNC doesn’t hydraulic/fluidic logic. tegers in the range 0 to 4,095, and so on.
make its way to the CLEAN signal until The idea is that you will be able to start
the first or second CLK edge in the next off by creating and running programs in The CPU register map
group of three pulses one millisecond later. the virtual world on Joe’s HRRG Emulator, When you are designing a computer, there
What we have to realise is that there’s a and then gradually add physical cabinets are myriad decisions and trade-offs to be
(relatively) long time between transitions into the mix, where a physical cabinet made, including the number and types
on our toggle switch. The absolute fastest could contain as little as one 4-bit word of of registers you are going to have in the
we can turn it on and off would be about memory or one 4-bit input/output (I/O) port. CPU. For example, some of the early mi-
five times a second, which means that the One final point before we proceed – in croprocessors had a special register called
fastest on-off toggle will take 200ms. computer terminology, an 8-bit quantity is an accumulator (ACC), which was used to
The point of all this is that the two- referred to as a ‘byte’, while a 4-bit quan- store values read from memory and the re-
stage synchroniser’s task is to filter out tity is referred to as a ‘nibble’ (or ‘nybble’) sults of arithmetic and logical operations.
any metastability, which it does admira- on the basis that two nibbles make a byte, Later, some processor designers decided it
bly. The real worst-case scenarios (viola- thereby showing that engineers do have a would be better to have two accumulators
tions on the second or third CLK edges in sense of humour, albeit not a tremendously (ACC1 and ACC2). Still later, other proces-
a group) mean that the new signal on the sophisticated one. sor designers opted to provide a bunch of
toggle switch isn’t seen until the first or general-purpose registers, each of which
second CLK edges in the next group; that A birds-eye view could adopt the role of an accumulator.
is, one millisecond after the switch actually Let’s start with a bird’s-eye view of the Since the HRRG has a 4-bit data bus that
transitions, which is absolutely insignifi- system (Fig.3). This figure is, of course, a can carry only 24 = 16 different values, we
cant in the case of a hand-operated switch. simplification – there can be multiple blocs decided to have only 16 CPU registers (at
of RAM and ROM and lots of input, output, least, only 16 registers as far as the user is
The 4-bit HRRG Computer and bi-directional input/output (I/O) ports. concerned; there will be additional registers
Now, let’s return to the Maxfield-Farr One of the main things to take away from that the CPU uses to perform its magic, but
4-Bit HRRG Computer (hereafter, just this diagram is that the HRRG’s data bus the user doesn’t need to know about these).
‘HRRG’) discussed in the May 2019 issue is 4-bits (one nibble) wide (as indicated by These registers are listed in Fig.4 (the ‘$’
of Practical Electronics. This is a machine the line with the ‘4’ annotation). characters indicate hexadecimal values).
that my co-conspirator, Joe Farr, and I Also, the address bus is 12-bits (three As we see, in the case of the data pro-
are designing from the ground up. Joe is nibbles) wide, which means we can ad- cessing and status logic, we decided to
working on a virtual implementation of dress 212 = 4096 unique memory locations have six general-purpose 4-bit registers
this beauty in the form of an emulator or I/O ports. We will leave any discussion called R0-R5 and two 4-bit status registers
that runs on a PC, while I am tasked with of the bits forming the control bus for a called S0 and S1. Regarding the address-
defining the physical realisation of the future column. ing logic, we opted to have four 12-bit
beast. (As an aside, Joe is a member of the Now, although we haven’t talked about registers to implement the program coun-
EEWeb Experts, https://bit.ly/2MvmYyS, the HRRG’s instruction set yet, this does ter (PC), stack pointer (SP), index register
and you can discover more about him in lead to an interesting point, which is the (IX), and interrupt vector (IV). Also, we
a recent column, https://bit.ly/2GHhGga). way in which we address our I/O ports. have three virtual registers called CV (con-
Currently, I’m working on defining the Some processors employ an approach stant value), MD (memory direct), and MX
logical functionality at the level of switches, known as port-mapped I/O (PMIO), which (memory indexed). The way in which all

Practical Electronics | October | 2019 67


that all the bits in the result are 0s, Suppose we wanted to increment the
R0 $0 4-bit General-Purpose Register 0
while a 0 in the flag indicates that contents of the 12-bit index register IX. Re-
R1 $1 4-bit General-Purpose Register 1
one or more bits in the result contain member from Fig.4 that the code for this

ALU and Status


R2 $2 4-bit General-Purpose Register 2
1s). Assuming we are working with register is $A. So, our 2-nibble machine
R3 $3 4-bit General-Purpose Register 3 signed binary numbers, the N flag code would be $0 $A or $0A (opcode =

Logic
R4 $4 4-bit General-Purpose Register 4 is primarily used to indicate if the $0 = INC, operand = $A = index register).
Physical

R5 $5 4-bit General-Purpose Register 5 result from an arithmetic operation Alternatively, suppose we wanted to in-
S0 $6 4-bit Status Register 0 is negative (a 1 in this flag indicates crement the 4-bit memory location at ad-
S1 $7 4-bit Status Register 1 a negative number; a 0 indicates a dress $462. In this case, we will be using
PC $8 12-bit Program Counter
positive number). Meanwhile the the virtual MD (memory direct) register.

Addressing
SP $9 12-bit Stack Pointer
C and O flags are primarily used to From Fig.4 we know that the code for this

Logic
indicate the carry-out and overflow register is $D. In this case, our 5-nibble
IX $A 12-bit Index Register
status of a result following an arith- machine code would be $0 $D $4 $6 $2,
IV $B 12-bit Interrupt Vector
metic operation. (As we will see, the or $0D462 (opcode = $0 = INC, operand
CV $C 12-bit Constant Value
various flags can also be used to in- = $D = memory direct virtual register, and
Virtual

MD $D 12-bit Memory Direct dicate other conditions.) additional operands $462 to provide the
MX $E 12-bit Memory Indexed The I flag is used to enable or dis- address in memory).
-- $F -- Unused/Reserved* able external interrupts. Following Trust me, that this will all start to make
*Do not use on pain of death (results are undefined) power up or a reset, this flag will much more sense when we delve deeper in
contain 0, thereby disabling exter- future columns (especially when we start
Fig.4. The HRRG’s CPU register map. nal interrupts. In order to enable thinking in terms of assembly language).
these registers work will become clear as interrupts, this flag must be set to 1 under For the moment, just peruse and ponder
we proceed. Amazingly enough, we ended program control (ie, the currently running the following notes associated with the
up with one unused register ($F) which program is in charge of setting and clear- instruction set table:
we are reserving for future enhancements. ing this flag). 1. If the source is a 4-bit register or a 12-bit
I think this is a good time to emphasise The H flag is used to halt the CPU. Fol- register, then there won’t be a <src-aop>
the fact that there are countless ways of lowing power up or a reset, this flag will (additional operand).
doing everything when it comes to com- contain 0, thereby allowing the CPU to 2. If the source is a memory location (as
puters. The decisions are made a little run. If the program sets this flag to 1, the indicated using the MD or MX virtual
trickier when you limit yourself to a 4-bit CPU will halt. The only way to wake the registers), then the <src-aop> will be a
machine. On the one hand, Joe and I are CPU up again is for an external interrupt 3-nibble address.
pretty much making this up as we go to occur (assuming the I flag is set to 1) or 3. If the source is a constant value (indi-
along; on the other hand, we are using for the system to be reset. cated using the CV virtual register), then
our decades of experience to ‘munge’ all The last two flags are hardwired to <src-aop> will be a 1-nibble value if the
sorts of concepts together to come up with logic 0 and 1 values. As we will see, target is a 4-bit register or a memory lo-
something we think is interesting and fun these allow us to implement rather cun- cation; otherwise it will be a 3-nibble
to play with. The point is that nothing is ning JMP (jump) and JSR (jump to sub- value if the target is a 12-bit register.
‘written in stone’; if you decide to design routine) instructions. 4. If the target is a 4-bit or 12-bit register,
your own machine, you might make vastly then there won’t be a <tar-aop> (addi-
different decisions. The instruction set tional operand).
Once again, since the HRRG has a 4-bit 5. If the target is a memory location (as
The status registers data bus that can carry only 24 = 16 dif- indicated using the MD or MX virtual
If you ever played with an old 8-bit micro- ferent values, we decided to have only 16 registers), then the <tar-aop> will be a
processor like the 6502, you may recall that instructions in our instruction set. This 3-nibble address.
it had an 8-bit status register of which three isn’t quite as dire as it seems, because 6. If the source is a 4-bit register, the
bits remained unused. The five commonly each instruction opcode (operation code) target will typically be a 4-bit regis-
used status bits, or flags, are N (negative), nibble is accompanied by one or more op- ter or memory location; if the source
Z (Zero), C (Carry), O (Overflow), and I erands, which specify the data to be pro- is a 4-bit register and the target is one
(Interrupt Mask). In our case, we opted cessed (Fig.6). of the 12-bit registers (PC, SP, IX, IV),
to have two 4-bit status registers (Fig.5.) Don’t panic! I know this appears to be then the contents of the 4-bit register
The Z flag is primarily used to indicate complicated, but that’s because we are at- will be moved (copied) into the least-
if the result of a logical or arithmetic op- tempting to cram a huge amount of infor- significant nibble (LSN) of the target
eration is zero (a 1 in this flag indicates mation into a ‘one-stop-shop’ table. As a register; if the source is a 12-bit register,
S1 S0
quick example of how this all the target will typically be a 12-bit reg-
Bit numbers seen by the works, let’s look at the INC (incre- ister or a memory location (see note 7);
7 6 5 4 3 2 1 0 JMP and JSR instructions
ment) instruction, whose opcode if the source is a 12-bit register and the
3 2 1 0 3 2 1 0 Status register bit numbers is $0 (remember ‘$’ indicates a target is a 4-bit register, then the con-
1 0 H I O C Z N
hexadecimal value; we will also tents of the LSN of the 12-bit register
Negative Flag use ‘%’ to indicate binary values; will be copied into the 4-bit register.
Zero Flag eg, %0000). From the table we 7. If the contents of a 12-bit register are
Carry Flag
see that the INC opcode will be copied into memory, the target operand
Overflow Flag
followed by a <tar> (target) oper- will be the least-significant address of a
Interrupt Enable Flag
and nibble, which will indicate 3-nibble field. If the contents of memory
what we wish to increment. If are copied into a 12-bit register, the
Halt Flag
the target is a memory location, source operand will be the least-signif-
Hardwired Logic 0
then we will have an additional icant address of a 3-nibble field.
Hardwired Logic 1
operand <tar-aop> in the form 8. If the source is a 4-bit register or a
Fig.5. The HRRG’s status registers and bits/flags. of a 3-nibble memory address. memory location, then a 1-nibble value

68 Practical Electronics | October | 2019


is pushed onto the stack Mnemonic
and SP = SP + 1. If the Opcode Fig.6. The HRRG’s instruction set.
source is a 12-bit regis- Operands
ter, then a 3-nibble value INC $0 <tar>4R,12R,Mx <tar-aop> Increment contents of register or memory location4,5
will be pushed onto the DEC $1 <tar>4R,12R,Mx <tar-aop> Decrement contents of register or memory location4,5
stack and SP = SP + 3. CV,4R,Mx 4R,Mx
ADDC $2 <src> <tar> <src-aop> <tar-aop> Add contents of <src> and <tar> (with carry); store result in <tar>1,2,3,4,5
(The stack pointer will CV,4R,Mx 4R,Mx
SUBB $3 <src> <tar> <src-aop> <tar-aop> Subtract contents of <src> from <tar> (with borrow); store result in <tar>1,2,3,4,5
be incremented after the 4R,Mx
ROLC $4 <tar> <tar-aop> Rotate contents of <tar> left through the carry (C) status bit/flag4,5
PUSH.) 4R,Mx
RORC $5 <tar> <tar-aop> Rotate contents of <tar> right through the carry (C) status bit/flag4,5
9. If the source is a con-
CV,4R,Mx 4R,Mx
AND $6 <src> <tar> <src-aop> <tar-aop> AND contents of <src> and <tar>; store result in <tar>1,2,3,4,5
stant value, then the
CV,4R,Mx 4R,Mx
OR $7 <src> <tar> <src-aop> <tar-aop> OR contents of <src> and <tar>; store result in <tar>1,2,3,4,5
source operand will be a
XOR $8 <src>CV,4R,Mx <tar>4R,Mx <src-aop> <tar-aop> XOR contents of <src> and <tar>; store result in <tar>1,2,3,4,5
1-nibble value, this value
CMP $9 <src1>CV,4R,Mx <src2>4R,Mx <src1-aop> <src2-aop> Compare contents of <src> and <tar>; update C and Z status bits/flags
will be pushed onto the
stack, and SP = SP + 1. PUSH $A <src>CV,4R,12R,Mx <src-aop> Push contents of <src> onto the stack1,2,8,9

(The stack pointer will POP $B <tar>4R,12R,Mx <tar-aop> Pop value from stack into <tar>4,5,10,11

be incremented after the JMP $C <0/1 #sb> <tar-aop> Jump to location12

PUSH.) JSR $D <0/1 #sb> <tar-aop> Jump to subroutine12

10. If the target is a 4-bit reg- NOP $E -- No operation (don’t do anything furiously)
ister or a memory loca- MOV $F <src>CV,4R,12R,Mx <tar>4R,12R,Mx <src-aop> <tar-aop> Move (copy) the contents of <src> (the source) to <tar> (the target)1,2,3,4,5,6,7
tion, then SP = SP – 1
<src> = Source CV = Constant value
and a 1-nibble value will <tar> = Target (destination) 4R = One of the 4-bit registers (R0-R5, S0-S1)
12R = One of the 12-bit registers (PC, SP, IX, IV)
be popped off the stack <src-aop> = Additional operand (none if source is a 4R/12R register)
<tar-aop> = Additional operand (none if target is a 4R/12R register) Mx = Either the MD or MX virtual registers.
(ie, the stack pointer will If MD, the address (operand) is used directly.
0/1 = 1-bit logic 0 or 1 value If MX, the address (operand) is first added to the
be decremented before #sb = 3-bit value specifying status bit to test (0-7) contents of the index register (IX)
the POP). If the target is
a 12-bit register, then a 3-nibble value a value of 1 in the selected status bit 5. If the target is status register S1, then
will be popped off the stack (ending will cause a jump; for example, JMP its flags will be loaded from the stack
up with SP = SP – 3). %0001 <target address> is equivalent and the contents of S0 will not be af-
11. There are no RTS (‘return from sub- to a ‘Jump if Zero’. By comparison, a 1 fected; if the target is S0, then its flags
routine’) or RTI (‘return from inter- in the most-significant bit of the control will be loaded from the stack; if the
rupt’) instructions – the same effect is nibble will invert the operation of the target is any other 4-bit location (regis-
achieved by using a POP instruction to jump; for example, JMP %1001 <target ter or memory), then the N and Z flags
retrieve the return address off the stack address> is equivalent to a ‘Jump if Not will behave as usual.
and load it into the PC. Zero’. Note that status bit 7 [bit 3 in S1] 6. These flags work as usual for a 4-bit
12. JMP and JSR instructions are followed is a hard-wired 1, which is equivalent target with one exception – if the target
by a control nibble and then a 3-nibble to an unconditional jump. is one of the status registers S0 or S1,
target address. The control nibble is then the flags in S0 will not be auto-
used to perform unconditional jumps Instructions and status flags matically updated; if the source is a
or conditional jumps. The least-signif- Finally, for this column, let’s consider the 12-bit register and the target is a 4-bit
icant three bits of the control nibble way in which the various instructions affect register, then the Z and N flags will
point to the bit to be tested in the 8-bit the status flags as illustrated in Fig.7. In be based on the contents of the least-
status register formed from S1 and S0; particular, consider the following notes as- significant nibble of the 12-bit register
this will be in the range 000 to 111 (0 sociated with the status flag table: (ie, the only bits to be copied); if the
to 7). Assuming a 0 in the most-sig- 1. The most-significant bit (MSB) of the source is a 12-bit register and the target
nificant bit of the control nibble, then target value is copied into the C flag; is memory, then the Z flag will be set
at the same time, the original contents based on the contents of the entire 12-bit
Target <tar>
of the C flag are copied into the least- register and the N flag will be set based
4R or Mx 12R
significant bit (LSB) of the target value. on the contents of the most-significant
INC $0 -- C Z N -- -- Z7 N7 2. The least-significant bit (LSB) of the nibble of the 12-bit register.
DEC $1 -- C Z N -- -- Z7 N7 target value is copied into the C (carry) 7. The Z flag will be set based on the con-
ADDC $2 O C Z N -- -- -- -- flag; at the same time, C flag’s original tents of the entire 12-bit register and
SUBB $3 O C Z N -- -- -- -- contents are copied into the most-sig- the N flag will be set based on the con-
ROLC $4 1
-- C Z N -- -- -- -- nifi cant bit (MSB) of the target value. tents of the most-significant nibble of
RORC $5 2
-- C Z N -- -- -- -- 3. The Z flag is set to 1 if the values being the 12-bit register.
compared are equal, otherwise it’s
AND $6 -- -- Z N -- -- -- --
cleared to 0. Coming soon…
OR $7 -- -- Z N -- -- -- --
4. The values being compared are consid- Phew! There’s a lot to wrap our brains
XOR $8 -- -- Z N -- -- -- --
ered to be unsigned integers. The C fl ag around here, but things will start to make
CMP $9 -- C4 Z3 -- -- -- -- --
is set to 1 if the value in the <src1> is much more sense when we begin to work
PUSH $A -- -- -- -- -- -- -- -- greater than the value in <src2>; oth- in assembly language – the topic of my
POP $B -- -- Z5 N5 -- -- -- -- erwise it’s cleared to 0. next column. Until then, have a good one!
JMP $C -- -- -- -- -- -- -- --
JSR $D -- -- -- -- -- -- -- -- Cool bean Max Maxfield (Hawaiian shirt, on the right) is emperor
NOP $E -- -- -- -- -- -- -- -- of all he surveys at CliveMaxfield.com – the go-to site for the
MOV $F -- -- Z 6 N6 -- -- Z 7 N7
latest and greatest in technology.
Comments or questions? Email Max at: [email protected]
Fig.7. The instructions and status flags.

Practical Electronics | October | 2019 69


PRACTICAL ELECTRONICS IS PLEASED TO OFFER YOU THESE

ELECTRONICS CD-ROMS
GCSE ELECTRONICS
Suitable for any student who is serious about studying and who wants to achieve
the best grade possible. Each program’s clear, patient and structured delivery will
aid understanding of electronics and assist in developing a confident approach to
answering GCSE questions. The CD-ROM will be invaluable to anyone studying
electronics, not just GCSE students.

*Curriculum
Contains comprehensive teaching material to cover the National
*
syllabus Regular exercises reinforce the teaching points
*
*
Retains student interest with high quality animation and graphics Stimulates learning through interactive
*
exercises Provides sample examination ques-tions with model solutions
* Authored by practising teachers
* * *
Covers all UK examination board syllabuses Caters for all levels of ability Useful for self-tuition and revision

SUBJECTS COVERED
£12.50 Electric Circuits – Logic Gates – Capacitors & Inductors – Relays – Transistors – Electric Transducers – Operational
inc. VAT and P&P Amplifiers – Radio Circuits – Test Instruments
Over 100 different sections under the above headings

CIRCUIT WIZARD
Circuit Wizard is a revolutionary software system that combines circuit design, PCB design, simulation and CAD/CAM
manufacture in one complete package. Two versions are available – Standard or Professional.
By integrating the entire design process, Circuit Wizard provides you with all the tools necessary to produce an electronics project from start to
finish – even including on-screen testing of the PCB prior to construction!

* *
Circuit diagram design with component library (500 components Standard,1500 components Professional) Virtual instruments
(4 Standard, 7 professional) On-screen animation Interactive circuit diagram simulation True analogue/digital simulation
* * *
* * *
Simulation of component destruction PCB Layout Interactive PCB layout simulation
* *
Automatic PCB routing Gerber export
Multi-level zoom (25% to 1000%) Multiple undo and redo Copy and paste to other software Multiple document support
* * * *
This software can be used with the Jump Start and Teach-In 2011 series (and the Teach-In 4 book).
Standard £61.25 inc. VAT. Professional £75 plus VAT.

From TINA Design Suite V12 FE


£49.00
ATU
Analogue, Digital, Symbolic, RF, MCU and Mixed-Mode OU RE
RT D IN
Circuit Simulation and PCB Design with TINA 201 EA CH
5S -IN
TINA Design Suite V12 is a powerful yet affordable software package for analysing, designing and ER
IES
real time testing analogue, digital, MCU, and mixed electronic circuits and their PCB layouts. You can
also analyse RF, communication, optoelectronic circuits, test and debug microcontroller applications.
Enter and analyse any circuit up to 100 nodes (student), or 200 with the Basic (Hobbyist) version
within minutes with TINA’s easy-to-use schematic editor. Enhance your schematics by adding text
and graphics. Choose components from the large library containing more than 10,000 manufacturer
models. Analyse your circuit through more than 20 different analysis modes or with 10 high tech
virtual instruments.
Present your results in TINA’s sophisticated diagram windows, on virtual instruments, or in the live
interactive mode where you can even edit your circuit during operation.
Customise presentations using TINA’s advanced drawing tools to control text, fonts, axes, line
width, colour and layout. You can create and print documents directly inside TINA or cut and paste
your results into your favourite word procesing or DTP package.
TINA includes the following Virtual Instruments: Oscilloscope, Function Generator, Multimeter,
Signal Analyser/Bode Plotter, Network Analyser, Spectrum Analyser, Logic Analyser, Digital Signal
Generator, XY Recorder.
This offer gives you a CD-ROM – the software will need registering (FREE) with Designsoft (TINA),
details are given within the package.
Get TINA 12 Design Suite (Hobbyist) for £129 or Student V12 version for £49
Prices include VAT and UK postage
+ get a 1 year free subscription for TINACloud the breakthrough cloud version of TINA which you can run on
most operating systems and computers, including PCs, Macs, thin clients iPads and other tablets – even on many
smart phones, smart TVs and e-book readers.
To order please either fill out and return the order form, or call us on 01202 880299
Alternatively you can order via our secure online shop at: www.epemag.com

70 Practical Electronics | October | 2019


PICmicro TUTORIALS AND PROGRAMMING
HARDWARE
PICmicro Multiprogrammer Board
and Development Board
Suitable for use with the three software packages
listed below
This flexible PICmicro microcontroller programmer board and
combination board allows students and professional engineers
to learn how to program PICmicro microcontrollers as well
as program a range of 8, 18, 28 and 40 pin devices from the
12, 16 and 18 series PICmicro ranges. For those who want to
learn, choose one or all of the packages below to use with the
hardware.

• Makes it easier to develop PICmicro projects


• Supports low cost Flash-programmable PICmicro devices
• Fully featured integrated displays – 16 individual LEDs, quad
7-segment display and alphanumeric LCD display
• Supports PICmicro microcontrollers with A/D converters
• Fully protected expansion bus for project work
• USB programmable
• Compatible with the E-blocks range of accessories £159.99 including VAT and postage (worldwide)

SOFTWARE
ASSEMBLY FOR PICmicro V7 FLOWCODE FOR
(Formerly PICtutor) PICmicro V8
Assembly for PICmicro microcontrollers V7.0 (previously known as PICtutor) by Flowcode is a very high level language programming system based on flowcharts.
John Becker contains a complete course in programming the PIC16F84, 16F88 Flowcode allows you to design and simulate complex systems in a matter of
and 16F877a PICmicro microcontroller from Arizona Microchip. It starts with minutes. A powerful language that uses macros to facilitate the control of devices
fundamental concepts and extends up to complex programs including watchdog like 7-segment displays, motor controllers and LCDs. The use of macros allows
timers, interrupts and sleep modes. you to control these devices without getting bogged down in understanding the
The CD makes use of the latest simulation techniques which provide a superb tool programming. When used in conjunction with the development board this provides
for learning: the Virtual PICmicro microcontroller, this is a simulation tool that allows a seamless solution that allows you to program chips in minutes.
users to write and execute MPASM assembler code for the PIC16F84 microcontroller • Requires no programming experience
on-screen. Using this you can actually see what happens inside the PICmicro MCU • Allows complex PICmicro applications to be designed quickly
as each instruction is executed, which enhances understanding. • Uses international standard flow chart symbols
• Comprehensive instruction through 45 tutorial sections • Full on-screen simulation allows debugging and speeds up the development
process.
• Includes Vlab, a Virtual PICmicro microcontroller: a fully functioning
simulator • Facilitates learning via a full suite of demonstration tutorials
• Tests, exercises and projects covering a wide range of PICmicro MCU • Produces code for a wide range of devices
applications • 16-bit arithmetic strings and string manipulation
• Includes MPLAB assembler • Pulse width modulation
• Visual representation of a PICmicro showing architecture and functions • I2C.
• Expert system for code entry helps first time users Please note: Due to popular demand, Flowcode is now available as a download.
• Shows data flow and fetch execute cycle and has challenges (washing Please include your email address and a username (of your choice) on your order.
machine, lift, crossroads etc.)
A unique download code will then be emailed to you.
• Imports MPASM files.

Single License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . £99 plus VAT


PRICES
Prices for each of the CD-ROMs above are: Site Licence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . £499 plus VAT
(Order form on next page)
Flowcode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Contact us for pricing
(UK and EU customers add VAT to ‘plus VAT’ prices) (choose PIC-8b, PIC-16b, PIC-32b, AVR/Arduino,ARM)

Practical Electronics | October | 2019 71


ELECTRONICS TEACH-IN 2 ELECTRONICS TEACH-IN 3 ELECTRONICS TEACH-IN 4

ELECTRONICS TEACH-IN 2 CD-ROM ELECTRONICS TEACH-IN 3 CD-ROM ELECTRONICS TEACH-IN 4 CD-ROM


USING PIC MICROCONTROLLERS A PRACTICAL
The three sections of this CD-ROM cover a very wide range of A BROAD-BASED INTRODUCTION TO ELECTRONICS.
INTRODUCTION
subjects that will interest everyone involved in electronics, from
hobbyists and students to professionals. The first 80-odd pages The Teach-In 4 CD-ROM covers three of the most important
This Teach-In series of articles was originally published electronics units that are currently studied in many schools and
in EPE in 2008 and, following demand from readers, has of Teach-In 3 are dedicated to Circuit Surgery, the regular EPE
colleges. These include, Edexcel BTEC level 2 awards and the
been collected together in the Electronics Teach-In 2 clinic dealing with readers’ queries on circuit design problems –
from voltage regulation to using SPICE circuit simulation software. electronics units of the Diploma in Engineering, Level 2.
CD-ROM.
The series is aimed at those using PIC microcontrollers The second section – Practically Speaking – covers the The CD-ROM also contains the full Modern Electronics
for the first time. Each part of the series includes breadboard practical aspects of electronics construction. Again, a whole Manual, worth £29.95. The Manual contains over 800 pages
layouts to aid understanding and a simple programmer range of subjects, from soldering to avoiding problems with of electronics theory, projects, data, assembly instructions
project is provided. static electricity and indentifying components, are covered. and web links.
Also included are 29 PIC N’ Mix articles, also republished Finally, our collection of Ingenuity Unlimited circuits provides A package of exceptional value that will appeal to all those
from EPE. These provide a host of practical programming over 40 circuit designs submitted by the readers of EPE. interested in learning about electronics or brushing up on
and interfacing information, mainly for those that have The CD-ROM also contains the complete Electronics Teach-In their theory, be they hobbyists, students or professionals.
already got to grips with using PIC microcontrollers. An extra
1 book, which provides a broad-based introduction to electronics
four part beginners guide to using the C programing language
for PIC microcontrollers is also included. in PDF form, plus interactive quizzes to test your knowledge, TINA CD-ROM Order code ETI4 CD-ROM £8.99
The CD-ROM also contains all of the software for the circuit simulation software (a limited version – plus a specially
Teach-In 2 series and PIC N’ Mix articles, plus a range written TINA Tutorial).
of items from Microchip – the manufacturers of the PIC The Teach-In 1 series covers everything from Electric Current
microcontrollers. The material has been compiled by through to Microprocessors and Microcontrollers and each part
Wimborne Publishing Ltd. with the assistance of Microchip includes demonstration circuits to build on breadboards or to ELECTRONICS TEACH-IN 5
Technology Inc. simulate on your PC.

CD-ROM Order code ETI2 CD-ROM £9.50 CD-ROM Order code ETI3 CD-ROM £8.50 EE M
FR -RO £8.99

ELECTRONICS
CD

FROM THE PUBLISHERS OF

TEACH-IN 5
JUMP START

ELECTRONICS TEACH-IN
ORDERING 15 desi gn and bui l d ci rcui t proj ects
dedi cated to newcomers or those
fol l owi ng courses i n school s and

ALL PRICES INCLUDE UK col l eges

PRACTICALLY SPEAKING
BUNDLE – FOR PARTS 3, 4 & 5 POSTAGE The techni ques of proj ect constructi on

PIC ‘N MIX

Standard/Student/Basic (Hobbyist)
Star ti ng out wi th PIC mi crocontrol l ers

FREE
Version price includes postage to most countries CD-R
OM

TEACH-I N 2
in the world EU residents outside the UK add £5 for TWO TEACH-I Ns FOR
THE PRI CE OF ONE!
airmail postage per order Plus: onika,

Order code ETIB3 CD-ROM £18.95


a pract
ical MikroElektr
Provides Microchip pe The fr ee CD-ROM pr ovi des a
CD-ROM
to PIC
introduction ollers L-Tek PoSco
microcontr ows software pr ac t i c al i nt r oduc t i on t o PIC
for Wind
CD ROM start
This CD
should m i c r oc ont r ol l er s
ly, if not
automaticalk index
.html
double-clic
In 2 Pl us Mi kroEl ektroni ka,
onicsorne Teach- Ltd
Publishing
Ele©ctr
2013 Wimb
and logo,
MPLAB
Techno
logy
dsPIC are
, PIC andIncorporated
Techno
logy
Mi crochi p and L-Tek PoScope
hip name of Microchip Microc
hip
software
The Microctrademarks © 2013 1016-02.09
red countries. 1. MCCD
registe and other d. Issue
in the USAAll rights reserve
Inc.

13 09:59:25
29/07/20

ELECTRONICS TEACH-IN 5
JUMP START FREE
CD-ROM
15 design and build circuit projects
Please send me: CD-ROM ORDER FORM dedicated to newcomers or those
following courses in school and
Version required: colleges. The projects are: Moisture Detector, Quiz Machine,
 Assembly for PICmicro V6  Single Licence Battery Voltage Checker, Solar-Powered Charger, Versatile
 ‘C’ for 16 Series PICmicro V6  Site licence Theft Alarm, Spooky Circuits, Frost Alarm, Mini Christmas
Lights, iPod Speaker, Logic Probe, DC Motor Controller, Egg
Timer, Signal Injector Probe, Simple Radio Receiver, Tempera-
ture Alarm.
Note: The software on each version is the same, only the licence for use varies. PLUS:
PIC’ N MIX – starting out with PIC Microcontrollers and PRAC-
TICALLY SPEAKING – the techniques of project construction.
 PICmicro Multiprogrammer Board and Development Board (hardware) FREE CD-ROM – The free CD-ROM is the complete
Teach-In 2 book providing a practical introduction to PIC
Microprocessors plus MikroElektronika, Microchip and
 Circuit Wizard – Standard  Teach-In 2 L-Tek PoScope software.
 Circuit Wizard – Professional  Teach-In 3
 Teach-In 4 £8.99
 GCSE Electronics
160 Pages Order code ETI5
 Teach-In Bundle
 TINA Design Suite V11 Basic (Hobbyist) (3, 4 and 5)
 TINA Design Suite V11 (Student) Single License and Site License Versions
– overseas readers add £5 to the basic price
Full name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . of each order for airmail postage (do not add
Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . VAT unless you live in an EU (European Union)
country, then add VAT at 20% or provide your
. . . . . . . . . . . . . . . . . . . . . . Post code . . . . . . . . . . . . . . . . . Tel . . . . . . . . . . . . . . . official VAT registration number).

Email: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Send your order to:


Wimborne Publishing Ltd
113 Lynwood Drive
 I enclose cheque/PO in £ sterling payable to Practical Electronics for £ . . . . . . . . .
Wimborne
 Please charge my Visa/Mastercard: £ . . . . . . . . . . Dorset BH21 1UU
To order by phone call:
Valid From: . . . . . . . . . . Card expiry date: . . . . . . . . . . . . .
01202 880299. Fax: 01202 843233
Goods are normally sent within seven days
Card No: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E-mail: [email protected]
Card Security Code . . . . . . . . . . Online shop:
(The last 3 digits on or just under the signature strip)
www.epemag.com

72 Practical Electronics | October | 2019


DIRECT BOOK SERVICE
The books listed here

Teach-In 2017
have been selected by
the Practical Electronics
editorial staff as being
of special interest to
everyone involved
in electronics and
Introducing the computing. They are
supplied by mail order
direct to your door.
BBC micro:bit 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.epemag.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
GETTING STARTED WITH THE BBC MICRO:BIT IN 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

PRACTICAL ELECTRONICS HANDBOOK – 6th Ed


Ian Sinclair
440 pages Order code NE21 £33.99
B O O K O R D E R I N G D E TA I L S
STARTING ELECTRONICS – 4th Ed
Keith Brindley All prices include UK postage.
296 pages Order code ELSEV100 £18.99 For airmail, add £3 per book to Europe, £4 for rest of the world per book.
ELECTRONIC CIRCUITS – FUNDAMENTALS & CD-ROM prices include VAT and/or postage to anywhere in the world.
APPLICATIONS – Updated version
Mike Tooley Send a cheque, (£ sterling only) made payable to: Practical Electronics or credit card details
400 pages Order code TF43 £32.99 (Visa or Mastercard) to:
FUNDAMENTAL ELECTRICAL AND ELECTRONIC WIMBORNE PUBLISHING LIMITED,
PRINCIPLES – 3rd Ed 113 LYNWOOD DRIVE, WIMBORNE, DORSET BH21 1UU
C.R. Robertson
368 pages Order code TF47 £21.99
Books are normally sent within seven days of receipt of order.
Please check price (see latest issue of Practical Electronics or website) before ordering from old lists.
A BEGINNER’S GUIDE TO TTL DIGITAL ICs
Robert Penfold For a full description of these books please see the shop on our website.
142 pages OUT OF PRINT BP332 £5.45 Tel: 01202 880299 – E-mail: [email protected]

UNDERSTANDING ELECTRONIC CONTROL SYSTEMS Order from our online shop at: www.epemag.com
Owen Bishop
228 pages Order code NE35 £36.99

Practical Electronics | October | 2019 73


ARDUINO COMPUTING AND ROBOTICS

NEWNES INTERFACING COMPANION COMPUTING FOR THE OLDER GENERATION


Tony Fischer-Cripps Jim Gatenby

Teach-In 2016 295 pages Order code NE38

HOW TO BUILD A COMPUTER MADE EASY


Robert Penfold
£41.00 308 pages

Second Edition – John Iovine


Order code BP601

ANDROIDS, ROBOTS AND ANIMATRONS


£8.99

See opposite for our popular 224 pages Order code MGH1 £16.99
120 pages Order code BP707 £8.49
introduction to the Arduino
EASY PC CASE MODDING ROBOT BUILDERS COOKBOOK
Robert Penfold Owen Bishop
192 pages + CD-ROM Order code BP542 £8.99 366 pages Order code NE46 £26.00

FREE DOWNLOADS TO PEP-UP AND PROTECT INTRODUCING ROBOTICS WITH LEGO


YOUR PC MINDSTORMS
Robert Penfold Robert Penfold
128 pages Order code BP722 £7.99 288 pages + Order code BP901 £14.99

WINDOWS XP EXPLAINED MORE ADVANCED ROBOTICS WITH LEGO MINDSTORMS


N. Kantaris and P.R.M. Oliver Robert Penfold
264 pages Order code BP514 £7.99 298 pages Order code BP902 £14.99

THE INTERNET – TWEAKS, TIPS AND TRICKS HOW TO FIX YOUR PC PROBLEMS
Robert Penfold Robert Penfold

128 pages Order code BP721 £7.99 128 pages Order code BP705 £8.49

ARDUINO FOR DUMMIES WINDOWS 7 – TWEAKS, TIPS AND TRICKS


eBAY – TWEAKS, TIPS AND TRICKS
John Nussey Robert Penfold
Andrew Edney
Arduino is no ordinary circuit board. Whether you’re an artist, 120 pages Order code BP708 £8.49
a designer, a programmer, or a hobbyist, Arduino lets you 128 pages Order code BP716 £7.50
learn about and play with electronics. You’ll discover how to GETTING STARTED IN COMPUTING FOR
build a variety of circuits that can sense or control real-world AN INTRODUCTION TO eBAY FOR THE OLDER
GENERATION THE OLDER GENERATION
objects, prototype your own product, and even create inter- Jim Gatenby
active artwork. This handy guide is exactly what you need to Cherry Nixon
build your own Arduino project – what you make is up to you! 120 pages Order code BP709 £8.49 120 pages Order code BP704 £8.49
 Learn by doing – start building circuits and programming
your Arduino with a few easy examples – right away! HOW TO FIX YOUR PC PROBLEMS WINDOWS 8.1 EXPLAINED
Robert Penfold Noel Kantaris
 Easy does it – work through Arduino sketches line by
line, and learn how they work and how to write your own. 128 pages Order code BP705 £8.49 180 Pages Order code BP747 £10.99

 Solder on! – don’t know a soldering iron from a curling COMPUTING WITH A LAPTOP FOR THE OLDER
AN INTRODUCTION TO WINDOWS VISTA
iron? No problem! You’ll learn the basics and be prototyp- P.R.M. Oliver and N. Kantarris GENERATION
ing in no time. Robert Penfold
 Kitted out – discover new and interesting hardware to 120 pages Order code BP703 £8.49
120 pages Order code BP702 £8.49
turn your Arduino into anything from a mobile phone to a
Geiger counter. WINDOWS 8.1 EXPLAINED AN INTRODUCTION TO EXCEL SPREADSHEETS
 Become an Arduino savant – find out about functions, Jim Gatenby
arrays, libraries, shields and other tools that let you take 180 Pages Order code BP747 £10.99
your Arduino project to the next level 18 pages Order code BP701 £8.49
AN INTRODUCTION TO THE NEXUS 7
 Get social – teach your Arduino to communicate with KINDLE FIRE HDX EXPLAINED
software running on a computer to link the physical world 118 Pages Order code BP744 £8.99
with the virtual world
118 Pages Order code BP743 £8.99
438 Pages Order code ARDDUM01 £19.99

AUDIO & VIDEO


VALVE AMPLIFIERS – 4th Ed BUILDING VALVE AMPLIFIERS
Morgan Jones Morgan Jones

288 pages Order code ELSEV33 £46.99 368 pages Order code NE40 £29.00

RASPBERRY PI
EXPLORING ARDUINO RASPBERRY Pi FOR DUMMIES
Jeremy Blum Sean McManus and Mike Cook
Arduino can take you anywhere. This book is the roadmap. Write games, compose and play music, even explore electronics – it’s easy as Pi! The Rasp-
Exploring Arduino shows how to use the world’s most berry Pi offers a plateful of opportunities, and this great resource guides you step-by-step, from
popular microcontroller to create cool, practical, artistic downloading, copying, and installing the software to learning about Linux and finding cool new
and educational projects. Through lessons in electrical programs for work, photo editing, and music. You’ll discover how to write your own Raspberry
engineering, programming and human-computer interaction, Pi programs, create fun games, and much more!
this book walks you through specific, increasingly complex Open this book and find:
projects, all the while providing best practices that you can What you can do with Python; Ways to use the Raspberry Pi as a productivity tool; How to
apply to your own projects once you’ve mastered these. surf the web and manage files; Secrets of Sonic Pi music programming; A guide to creating
You’ll acquire valuable skills – and have a whole lot of fun. animations and arcade games; Fun electronic games you can build; How to build a 3D maze in
 Explore the features of commonly used Arduino boards Minecraft; How to play music and videos on your Raspberry Pi.

 Use Arduino to control simple tasks or complex electronics


400 Pages Order code RPiDUM01 £17.99
 Learn principles of system design, programming and
electrical engineering
RASPBERRY Pi MANUAL: A practical guide to the PROGRAMMING THE RASPBERRY Pi
 Discover code snippets, best practices and system
revolutionary small computer
schematics you can apply to your original projects 192 pages Order code MGH4 £10.99
 Master skills you can use for engineering endeavours
176 pages Order code H001 £17.99
in other fields and with different platforms
RASPBERRY Pi USER-GUIDE – 4th Ed GETTING STARTED WITH RASPBERRY Pi
357 Pages Order code EXPARD01 £26.99 262 pages Order code JW001 £20.90 164 pages Order code OR01 £11.50

74 Practical Electronics | October | 2019


TEACH-IN BOOKS
ELECTRONICS TEACH-IN 7
ELECTRONICS TEACH-IN 6 ELECTRONICS TEACH-IN 8
(Includes free CD-ROM)

EE OM EE M
FR -R FR -RO EE M
D
£8.99
CD
£8.99 FR RO £8.99
DV -
ELECTRONI CS FROM THE PUBLISHERS OF
ELECTRONI CS FROM THE PUBLISHERS OF
CD
ELECTRONI CS
TEACH-I N 6 TEACH-I N 7 TEACH-I N 8
FREE
CD-ROM
SOFTWARE
FOR
THE TEACH-IN
8
FROM THE PUBLISHERS OF SERIES
RASPBERRY Pi ® DISCRETE LINEAR CIRCUIT DESIGN
A COMPREHENSIVE GUIDE TO RASPBERRY Pi • Understand linear circuit design INTRODUCING THE ARDUINO
• Pi PROJECT – SOMETHING TO BUILD • Design simple, but elegant circuits • Hardware – learn about components and circuits
• Pi CLASS – SPECIFIC LEARNING AIMS • Learn with ‘TINA’ – modern CAD software • Programming – powerful integrated development system
• PYTHON QUICKSTART – SPECIFIC PROGRAMMING TOPICS • Five projects to build: Pre-amp, Headphone Amp, • Microcontrollers – understand control operations
• Pi WORLD – ACCESSORIES, BOOKS ETC Tone Control, VU-meter, High Performance Audio Power Amp • Communications – connect to PCs and other Arduinos
• HOME BAKING – FOLLOW-UP ACTIVITIES
FREE
OM
DVD-R
ALL THE
RE
SOFTWA
IN 6
FREE M
TEACH- -RO
CD CIRCUIT
FOR THE RRY Pi
RASPBE ALL THE
RE FOR
SERIES SOFTWA 7
CH-IN
THE TEA
SERIES

PLUS
Pi B+ UPDATE PLUS...
INTERFACE – a series of AUDIO OUT
ten Pi related features An analogue expert’s take
on specialist circuits PLUS...
REVIEWS – Optically PIC n’MIX
isolated ADC and I/O PRACTICALLY SPEAKING PICs and the PICkit 3 - A beginners
The techniques of project
interface boards guide. The why and how to build
building
PIC-based projects

ONLY AVAILABLE ON CD-ROM RUNNING LOW – ORDER NOW! ONLY AVAILABLE ON CD-ROM
ELECTRONICS TEACH-IN 6 ELECTRONICS TEACH-IN 7 ELECTRONICS TEACH-IN 8
A COMPREHENSIVE GUIDE TO RASPBERRY Pi DISCRETE LINEAR CIRCUIT DESIGN INTRODUCING THE ARDUINO
Mike & Richard Tooley Mike & Richard Tooley Mike & Richard Tooley
Teach-In 6 contains an exciting series of articles that Teach-In 7 is a complete introduction to the design of Hardware – learn about components and circuits; Programming
provides a complete introduction to the Raspberry Pi, analogue electronic circuits. Ideal for everyone interested in – powerful integrated development system; Microcontrollers –
the low-cost computer that has taken the education and electronics as a hobby and for those studying technology at understand control operations; Communications – connect to
computing world by storm. schools and colleges. Supplied with a free cover-mounted PCs and other Arduinos
This latest book in our Teach-In series will appeal to CD-ROM containing all the circuit software for the course, This exciting series has been designed for electronics
electronic enthusiasts and computer buffs wanting to get to plus demo CAD software for use with the Teach-In series enthusiasts who want to get to grips with the inexpensive,
grips with the Raspberry Pi. Discrete Linear Circuit Design* Understand linear circuit immensely popular Arduino microcontroller, as well as coding
Anyone considering what to do with their Pi, or maybe design* Learn with ‘TINA’ – modern CAD software* Design enthusiasts who want to explore hardware and interfacing.
they have an idea for a project but don’t know how to simple, but elegant circuits* Five projects to build: Pre- Teach-In 8 will provide a one-stop source of ideas and prac-
turn it into reality, will find Teach-In 6 invaluable. It covers: amp, Headphone Amp, Tone Control, VU-meter, High tical information.
Programming, Hardware, Communications, Pi Projects, Pi Performance Audio Power Amp. The Arduino offers a remarkably effective platform for
Class, Python Quickstart, Pi World, and Home Baking. PLUS developing a huge variety of projects; from operating a set
of Christmas tree lights to remotely controlling a robotic
The CD-ROM also contains all the necessary software for Audio Out – an analogue expert’s take on specialist circuits
vehicle through wireless or the Internet. Teach-In 8 is based
the series so that readers can get started quickly and easily Practically Speaking – the techniques of project building
with the projects and ideas covered. around a series of practical projects with plenty of informa-
tion to customise each project.
160 Pages Order code ETI6 £8.99 160 Pages Order code ETI7 £8.99 This book also includes PIC n’ Mix: PICs and the PICkit 3 -
A Beginners guide by Mike O’Keefe and Circuit Surgery by
Ian Bell - State Machines part 1 and 2.
The CD-ROM includes files for Teach-In 8 plus Microchip

VISIT OUR WEBSITE FOR MORE BOOKS MPLAB IDE XC8 8-bit Compiler and PICkit 3 User Guide.
Also included is Lab-Nation Smartscope software.

AND FAST, EASY ONLINE ORDERING 160 Pages Order code ETI8 £8.99

WWW.EPEMAG.COM

THE BASIC
BOOK ORDER FORM SOLDERING
Full name: ....................................................................................................................................... GUIDE
Address: .......................................................................................................................................... LEARN TO SOLDER
SUCCESSFULLY!
ALAN WINSTANLEY
.........................................................................................................................................................
The No.1 resource for
learning all the basic
.............................................. Post code: ........................... Telephone No: .................................... aspects of electronics
soldering by hand.
Email: .............................................................................................................................................. With more than 80 high quality colour photographs,
this book explains the correct choice of soldering
 I enclose cheque/PO payable to Practical Electronics for £ ......................................................... irons, solder, fluxes and tools. The techniques of
how to solder and desolder electronic components
are then explained in a clear, friendly and non-
 Please charge my card £ ....................................... Card expiry date......................................... technical fashion so you’ll be soldering successfully
in next to no time! The book also includes sections
Card Number ..................................................................................... on reflow soldering and desoldering techniques,
potential hazards, useful resources and a very
Valid From Date ................ Card Security Code ............... (The last three digits on or just below the signature strip) useful troubleshooting guide.
Also ideal for those approaching electronics
Please send book order codes: ....................................................................................................... from other industries, the Basic Soldering Guide
Handbook is the best resource of its type, and
thanks to its excellent colour photography and
......................................................................................................................................................... crystal clear text, the art of soldering can now be
learned by everyone!
..........................................................................................................................................................
Please continue on separate sheet of paper if necessary 86 Pages Order code AW1 £9.99

Practical Electronics | October | 2019 75


Electronic Building Blocks
By Julian Edgar

Quick and easy construction Great results on a low budget

Automotive gadgetry
T
his month, I am going to look solitary red LED; this indicator of low
at a variety of items that are suitable battery voltage occurs at any voltage
for use with your car. However, less than 10V. The first green LED on
even if you’re not interested in automotive the bar graph lights with an input of
electronics, all the products also have 11V, and the last LED at 13.3V. The
non-automotive uses. USB output under no-load conditions
is about 5.2V; this drops to 5.1V un-
12V battery monitor with USB power der a 1A load.
This small module is designed to work The digital display was reasonably
with a lead-acid 12V battery (eg, in accurate – to within 0.1V – and at 1A
Fig.2. On braking, this module will flash a
a car), but it could be added to any load, the module didn’t get warm. centre-high-mount LED brake light. After
equipment that provides nominally However, like many very low-cost some initial flashes to attract the attention of
12V power. It combines a numerical modules, it might be wise to de-rate the following driver, the brake light resumes
display of battery supply voltage, an it a bit, rather than trying to pull the its steady-on mode.
8-LED bar graph that also shows bat- claimed 2A.
tery voltage, and two USB 5V power Cost is just under £3 delivered. small enough to be tucked almost any-
supply outputs. Designed to clip into Search on eBay under ‘12V Lead where. The electronics are also potted,
a 46 × 26mm hole, the module flush- Acid Battery BMS Capacity Level so the module should be largely weath-
mounts like a normal panel meter. The Indicator Volt Meter Dual USB Charg- erproof. Wiring is straightforward: red
USB outputs are in the front face of the er’ (at the time of writing, eBay item and black ‘in’ connections, and sim-
module, allowing easy access when 253777635432). In addition to instal- ilarly polarised ‘out’ connections. In
the module is installed. lation in a car, the module is ideal for use, the wires to the LED brake light
The device works down to about equipment like 12V power supplies. are cut and then the module inserted
6V – by ‘working’, I mean that the – very easy.
USB outputs stay at 5V and the dis- LED brake light flasher Claimed power handling is 15W
play operates. At that voltage (which In some countries, the centre high- (plenty for any LED brake light) and
of course would indicate a very sick mount LED brake light in cars is cost is low at £4 delivered – to find it,
12V battery) the bar graph is flashing a configured to flash a small number of search on eBay under ‘UK 12V-24V
pulses when first acti- Flash Strobe Controller Flasher Mod-
vated. This draws the ule for LED Brake Stop Light Lamp’
attention of the follow- (at the time of writing, eBay item
ing driver to the fact 222685223667).
that you’re decelerat- In use, the controller causes the brake
ing. After the initial light to flash very fast for about a sec-
pulses, the brake light ond, then pulses more slowly for about
then stays on until the 3s, before staying fully illuminated un-
brake pedal is released. til the brake is released.
The module shown In addition to the brake light func-
here is easily added to tion, the module is ideal anywhere
an LED brake light to a warning needs to be given that
achieve the same puls- equipment has been switched on or
ing outcome. is moving.
Only about 50 × 30 × Note: you must check the legality of
Fig.1. This low-cost 12V module integrates bar graph and 14mm, the module is flashing brake lights in your jurisdiction
digital battery voltage displays with dual USB power outputs. housed in a box that is before fitting this module to a vehicle.

76 Practical Electronics | October | 2019


Fig.3. Shaped and sized like a pen, this
handy device measures the percentage of
water in your car’s brake fluid. If the water
content is too high, get the fluid changed.

Brake fluid water detector


One thing that few people know is that
brake fluid in cars is hygroscopic – it
absorbs water from the atmosphere. This cheap breathalyser is fun to play with, ... involved consuming standard drinks of
That’s a primary reason why car man- but testing it… whisky (the things I do for you!) which did
ufacturers have fixed service periods not give results that matched my weight
for brake fluid – if it is not changed at and the consumed alcohol.
appropriate intervals, its moisture con-
tent rises. So why is that unacceptable? CR2032 button cell. Two lights are sup- In operation, the device is switched
Corrosion of internal brake components plied in each packet. Each of the lights on, whereupon a timer counts down
can then more readily occur. contains three bright surface-mount from ten to zero as the sensor warms
So that’s where this gadget comes in. LEDs – red in the case of the ones I up. The user then blows into an or-
It comprises a pen-shaped instrument bought. When triggered, the LEDs flash ifice, after which the blood alcohol
that has five LEDs along its length. Be- rapidly for about 8s, before reverting to level is shown on the digital display
hind a removable end-tip are two metal a lower current consumption mode of as a percentage.
probes. The instrument is switched on three quick flashes about every second. Wanting to do all this scientifically, I
(a green LED first shows that the single But the trick is in the phrase ‘when trig- rapidly consumed two standard drinks
AAA cell is OK) and then the probes gered’ – the lights are triggered by the of whisky, that according to reputable
are submerged in the brake fluid – eas- removal of a magnet. online calculators, with my weight,
ily accessible at the master cylinder The lights are designed to be placed should have given me a blood alco-
reservoir. Four LEDs then show the on the trailing edge of the car door (the hol level of 0.004. The tester showed
percentage of water in the fluid – less part that is exposed when the door is 0.003. After 4-6 hours, this should
than 1%, 2%, 3%, or more than 4%. 2% open). When the doors are open, the have returned to zero, but the test-
or less is OK; higher than that is not. lights flash a warning to drivers ap- er didn’t show that either. The next
Some testing with new brake flu- proaching from behind. When the doors evening, I started from scratch, but this
id showed it had zero water in it, but are closed, the lights are switched off time rapidly drinking three standard
adding even a tiny quantity of water by the presence of the small supplied whiskies. Again, the device showed
quickly caused the reading to rise. magnet. The circular magnet (only only 0.003, but by blowing very hard
You can get the tester for around £3 a few millimetres thick) comes with for as long as I could exhale, I got it
delivered from Banggood, ID: 1077231. a self-adhesive pad and needs to be momentarily up to 0.004 – again, low-
placed within about 5mm of the light er than it should have been. However,
Magnet-controlled flashing light to disable it. The lights also come with one positive for the tester is that when
I was initially a fraction reluctant to in- double-sided adhesive pads to allow I had drunk no alcohol at all, the de-
clude these lights here, but they work them to be held in place. Of course, vice always showed a zero reading.
so well that I felt I had to! So what are you need to ensure that within the car’s So perhaps it’s worthwhile fun for a
they? They’re small (29mm diameter × body design there is room for the light party, but definitely not something to
9mm depth) lights that use an included and its magnet (a combined thickness use to evaluate whether or not you are
of about 11mm). over the legal limit.
You can find the lights for £3 a pair
delivered from Banggood, ID: 1417651. Next month
And the use of the lights isn’t limit- In the next issue, I’ll cover four cheap
ed to just cars. The lights can be used modules based around LEDs that are
anywhere a warning that something is small and simple kits you build yourself.
open is required. I used one on a large
kitchen pantry door – a door that’s easy
to walk into when it’s open.

Cheap breathalyser
Fig.4. At left is the small flashing LED light,
Finally, we have a low-cost (£5 deliv-
complete with internal button cell. On the
right is the magnet, the removal of which ered) alcohol breath tester, available
triggers the light. The light is designed to from Banggood, ID: 987311. It’s pow-
mount on the inner edge of a car door, warn- ered by two AAA cells (and an AG13
ing approaching drivers when the door is button cell for the clock), and doesn’t
open. When the door is closed, the pres- have any claimed accuracy – as we will
ence of the magnet switches off the light. see in a moment, that’s just as well!

Practical Electronics | October | 2019 77


Practical Electronics PCB SERVICE
PROJECT CODE PRICE PROJECT CODE PRICE
DECEMBER 2017 JUNE 2019
Precision Voltage and Current Reference – Part 2............ 04110161 £15.35 Arduino-based LC Meter ................................................... 04106181 £8.00
JANUARY 2018 USB Flexitimer................................................................... 19106181 £10.45
High-Power DC Motor Speed Controller – Part 1 .............. 11112161 £12.88
JULY 2019
Build the SC200 Ampliier Module ..................................... 01108161 £12.88
Full-wave 10A Universal Motor Speed Controller .............. 10102181 £12.90
FEBRUARY 2018 Recurring Event Reminder ................................................ 19107181 £8.00
GPS-Syncronised Analogue Clock Driver ......................... 04202171 £12.88 Temperature Switch Mk2 ................................................... 05105181 £10.45
High-Power DC Motor Speed Controller – Part 2
+ Control Board ................................................... 11112161 £12.88 AUGUST 2019
+ Power Board .................................................... 11112162 £15.30 Brainwave Monitor ............................................................. 25108181 £12.90
MARCH 2018 Super Digital Sound Effects Module .................................. 01107181 £5.60
Stationmaster Main Board ................................................. 09103171 Watchdog Alarm ................................................................ 03107181 £8.00
£17.75
+ Controller Board .............................................. 09103172 PE Theremin (three boards: pitch, volume, VCA) ............. PETX0819 £19.50
Build the SC200 Ampliier Module – Power Supply 01109111 £16.45 PE Theremin component pack (see p.56, August 2019) ... PETY0819 £15.00
APRIL 2018 OCTOBER 2019
Spring Reverberation Unit ................................................. 01104171 £15.30
Programmable GPS-synced Frequency Reference .......... 04107181 £11.50
DDS Sig Gen Lid ............................................................... Black £8.05
DDS Sig Gen Lid ............................................................... Blue £7.05 Digital Command Control Programmer for Decoders ........ 09107181 £8.75
DDS Sig Gen Lid ............................................................... Clear £8.05 Opto-isolated Mains Relay (main board) ........................... 10107181 £11.50
Opto-isolated Mains Relay (2 × terminal extension board)...10107182
MAY 2018
High Performance RF Prescaler........................................ 04112162 £10.45
Micromite BackPack V2..................................................... 07104171 £10.45
Microbridge ........................................................................ 24104171 £5.60

JUNE 2018
High Performance 10-Octave Stereo Graphic Equaliser ... 01105171 £15.30 PE/EPE PCB SERVICE
JULY 2018 Order Code Project Quantity Price
Touchscreen Appliance Energy Meter – Part 1 ................. 04116061 £17.75
Automotive Sensor Modiier .............................................. 05111161 £12.88 .........................................................
AUGUST 2018 .........................................................
Universal Temperature Alarm ............................................ 03105161 £7.05
Power Supply For Battery-Operated Valve Radios ........... 18108171 .........................................................
18108172
£27.50
18108173 .........................................................
18108174
.........................................................
SEPTEMBER 2018
3-Way Active Crossover .................................................... 01108171 £22.60
Ultra-low-voltage Mini LED Flasher ................................... 16110161 £5.60 Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCTOBER 2018 Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6GHz+ Touchscreen Frequency Counter .......................... 04110171 £12.88
.........................................................
Two 230VAC MainsTimers ................................................ 10108161 £12.88
10108162 Tel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
NOVEMBER 2018
Super-7 AM Radio Receiver .............................................. 06111171 £27.50 Email . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
FEBRUARY 2019 I enclose payment of £ . . . . . . . . . . . . . . (cheque/PO in £ sterling only)
1.5kW Induction Motor Speed Controller........................... 10105122 £35.00
payable to: Practical Electronics
MARCH 2019
10-LED Bargraph Main Board ........................................... 04101181 £11.25 Card No . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
+Processing Board ............................................. 04101182 £8.60
Valid From . . . . . . . . . . . . . . . . . Expiry Date . . . . . . . . . . . . . . . .
APRIL 2019
Heater Controller ............................................................... 10104181 £14.00 Card Security No . . . . . . . . . .
MAY 2019
2× 12V Battery Balancer ................................................... 14106181 £5.60 You can also order PCBs by phone, Fax, Email or via the
Deluxe Frequency Switch .................................................. 05104181 £10.45 shop on our website on a secure server: www.epemag.com
USB Port Protector ............................................................ 07105181 £5.60

PCBs for most recent PE/EPE constructional projects are available. All prices include VAT and UK p&p. Add £2 per board for airmail outside
From the July 2013 issue onwards, PCBs with eight-digit codes have silk of Europe. Orders and payment should be sent to:
screen overlays and, where applicable, are double-sided, plated-through Practical Electronics, Wimborne Publishing Ltd
hole, with solder mask. They are similar to photos in the project articles. 113 Lynwood Drive, Merley, Wimborne, Dorset BH21 1UU
Earlier PCBs are likely to be more basic and may not include silk screen Tel 01202 880299 Fax 01202 843233
overlay, be single-sided, lack plated-through holes and solder mask. Email: [email protected]
Always check price and availability in the latest issue or online. A large On-line Shop: www.epemag.com
number of older boards are listed for ordering on our website. Cheques should be made payable to Practical Electronics (Payment
We do not supply kits or components for our projects. For older in £ sterling only).
projects it is important to check the availability of all components NOTE: While 95% of our boards are held in stock and are dispatched
before purchasing PCBs. within seven days of receipt of order, please allow a maximum of 28 days
Back issues of articles are available – see Back Issues page for details. for delivery if we need to restock.

78 Practical Electronics | October | 2019


CLASSIFIED ADVERTISING

Practical
Electronics
If you want your advertisements to be seen by the largest readership at
the most economical price our classified page offers excellent value. Practical Electronics
The rate for semi-display space is £10 (+VAT) per centimetre high, with reaches more UK
a minimum height of 2·5cm. All semi-display adverts have a width of readers than any other
5.5cm. The prepaid rate for classified adverts is 40p (+VAT) per word UK monthly hobby
(minimum 12 words).
electronics magazine.
Cheques are made payable to Practical Electronics. VAT must be added.
Our sales figures prove it.
Advertisements with remittance should be sent to: Practical Electronics,
113 Lynwood Drive, Wimborne, Dorset, BH21 1UU. We have been the leading
Tel 01202 880299 Email: [email protected] monthly magazine in
For rates and further information on display and classified advertising this market for the last
please contact our Advertisement Manager, Stewart Kearn – see below. twenty-seven years.
Unit 10, Boythorpe Business Park, Dock Walk, Chesterield,

Send large letter stamp for Catalogue

BOWOOD ELECTRONICS LTD The British Amateur Electronic Club at:


Suppliers of Electronic Components baec.tripod.com COAST ELECTRONICS
www.bowood-electronics.co.uk Has many interesting articles on BREAKOUTS-COMPONENTS-
Unit 10, Boythorpe Business Park, Dock Walk, Chesterield, computers; digital electronics CONTRACT DESIGN-3D PRINTER PARTS-
Derbyshire S40 2QR. Sales: 01246 200 222 and analogue electronics. MUSICAL-MICROCONTROLLERS
Send large letter stamp for Catalogue WWW.COASTELECTRONICS.CO.UK

MISCELLANEOUS Electrical Industries Charity (EIC) Andrew Kenny – Qualified Patent Agent
We help people working in the EPO UKIPO USPTO
VALVES AND ALLIED COMPONENTS electrical, electronics and energy Circuits Electric Machinery Mechatronics
IN STOCK. Phone for free list. Valves, community as well as their family
Web: www.akennypatentm.com
books and magazines wanted. Geoff members and retirees. Email: [email protected]
Davies (Radio), tel. 01788 574774. We use workplace programmes that Tel: 0789 606 9725
give the industry access to financial
PIC DEVELOPMENT KITS, DTMF kits grants and a comprehensive
and modules, CTCSS Encoder and range of free and
Decoder/Display kits. confidential services.
Visit www.cstech.co.uk www.electricalcharity.org

ADVERTISING INDEX
BRUNNING SOFTWARE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Advertisement offices
CRICKLEWOOD ELECTRONICS . . . . . . . . . . . . . . . . . . . . . . . . . 38 Wimborne Publishing Ltd
ESR ELECTRONIC COMPONENTS . . . . . . . . . . . . . . . . . . . . . . . 38 113 Lynwood Drive
HAMMOND ELECTRONICS Ltd . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Merley
JPG ELECTRONICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 Wimborne,
MICROCHIP . . . . . . . . . . . . . . . . . . . . . . . . . . Cover (ii), Cover (iii), 5
Dorset BH21 1UU
PCBWay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 38
PEAK ELECTRONIC DESIGN. . . . . . . . . . . . . . . . . . . . . . Cover (iv) Tel 01202 880299
PICO TECHNOLOGY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Fax 01202 843233
POLABS D.O.O.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Email [email protected]
QUASAR ELECTRONICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
SOUNDTRONICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Web www.epemag.com
STEWART OF READING. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
TAG-CONNECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 For editorial contact details see page 7.
TECHNOBOTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

Practical Electronics | October | 2019 79


Next Month – in the November issue
Tinnitus and Insomnia Killer
Suffer from tinnitus or insomnia? No promises! – but this
clever device produces pink or white noise which is widely
recognised as easing those problems.

GPS-synced Frequency Reference – Part 2


Next month, we’ll walk you through the detailed assembly
instructions and provide further information on how to use it,
including all the various customisable settings.

Electronic Compass modules


Lean how to use the Elecrow GY-271 and the GY-511 low-cost electronic
compass modules. Both incorporate a 3-axis magnetometer and work with
an Arduino, Micromite or any other microcontroller which supports I2C.
Using Stepper Motors
In Part 2, we explain how to choose a stepper motor and provide techniques
for identifying the leads on surplus motors saved from defunct equipment.

The Colour Maximite


Whether you want to control external hardware, learn to code, or play a classic
arcade game, this retro project is definitely for you. The Colour Maximite is a
modern take on an 80s home computer and will provide you with hours of fun.

PLUS!
All your favourite regular columns from Cool Beans, Circuit Surgery and
PIC n’ Mix, to Electronic Building Blocks, Techno Talk and Net Work. On sale 3 October 2019
Content may be subject to change

Welcome to JPG Electronics Calling all subscribers!


Selling Electronics in Chesterfield for 29 Years
Open Monday to Friday 9am to 5:30pm
And Saturday 9:30am to 5pm Practical
• Aerials, Satellite Dishes & LCD Brackets
• Audio Adaptors, Connectors & Leads
• BT, Broadband, Network & USB Leads
Electronics
• Computer Memory, Hard Drives & Parts If you are one of our valued subscribers then
• DJ Equipment, Lighting & Supplies
• Extensive Electronic Components
please note that we have changed the way
- ICs, Project Boxes, Relays & Resistors we send subscription renewal reminders.
• Raspberry Pi & Arduino Products Instead of sending you a renewal card, we
• Replacement Laptop Power Supplies
• Batteries, Fuses, Glue, Tools & Lots more...
now print a box on the address sheet that
comes with your copy of Practical Electronics.
T: 01246 211 202 This box will advise you of the last issue of
E: [email protected] your current subscription.
JPG Electronics, Shaw’s Row,
Old Road, Chesterfield, S40 2RB To renew, you have three easy choices:
W: www.jpgelectronics.com 1. Call us on: 01202 880299
2. Visit our website at: www.epemag.com
Shaw’s Row

JPG Electronics
Britannia Maison Mes Amis
Inn
Old Road
3. Send a cheque with your details to:
ad

Rose & Crown


Johnsons
all Ro

Roa
d Electron Publishing Limited
Old H

orth
Cha
tsw
Morrisons 113 Lynwood Drive
Sparks Wimborne
Retail & Trade Welcome • Free Parking • Google St View Tour: S40 2RB Dorset BH21 1UU
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: £25.00 (6 months); £47.00 (12 months); £89.00 (2 years). EUROPE: airmail service, £30.00 (6 months); £56.00 (12 months);
£107.00 (2 years). REST OF THE WORLD: airmail service, £37.00 (6 months); £70.00 (12 months); £135.00 (2 years). Payments payable to ‘Practical Electronics’, Electron Publishing Limited, 113 Lynwood Drive,
Wimborne, Dorset BH21 1UU. 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.

80 Practical Electronics | October | 2019


Faster Programming, Wider Voltage Ranges
and Enhanced Interface Options
PICkitTM 4 enables faster design development

With five times faster programming and a wider 1.2V to 5V range, the Microchip
MPLAB® PICkit™ 4 Development Tool supports low-cost development of even more
Microchip controllers.

PICkit™ 4 also introduces improved USB connectivity with a hi-speed USB 2.0
interface and advanced debugging over 4-wire JTAG and serial wire debug with
streaming data gateway in addition to legacy interfaces.

The new advanced interfaces support in-circuit programming and debugging of


Microchip’s CEC1702 hardware cryptography-enabled MCUs, in addition to dsPIC®
Digital Signal Controllers and PIC® microcontrollers from 8- to 32-bit.

www.microchip.com/PICkit4eu

The Microchip name and logo, the Microchip logo, MPLAB, PIC and dsPIC are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. PICkit and In-Circuit Serial Programming (ISCP) are
trademarks of Microchip Technology Inc. in the U.S.A. and other countries. All other trademarks mentioned herein are the property of their respective companies. © 2018 Microchip Technology Inc. All rights reserved.
DS-50002745A. MEC2206Eng04/18

You might also like