Practical Electronics October 2019 Avxhm - Se
Practical Electronics October 2019 Avxhm - Se
Practical Electronics October 2019 Avxhm - Se
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
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.
ELECTRONI CS
£8.99
SERIES
FOR
THE TEACH-IN
8
This CD-ROM version of the exciting and popular Teach-In 8 series INTRODUCING THE ARDUINO
• Hardware – learn about components and circuits
• 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
SOFTWARE
The CD-ROM contains the software for both the Teach-In 8 and PICkit 3 series.
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
–
–
–
–
–
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
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 ........................................................................................
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.
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
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
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.
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.
1 Connect
Take your irst temperature
logger measurements in
three simple steps
2 Configure
3 Collect
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
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
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.
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.
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 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
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
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.
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
Free-to-enter competition
is a great innovation, and each locomotive also needs a de- We have also designed the shield
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.
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.
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.
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.
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
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.
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.
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
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’.
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.
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.
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
�!
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.
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
L R
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
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.
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.
12mm 5.5mm
6mm front plate coil coil 9.5mm front plate
Force factor = 7.1N/A Force factor = 7.2N/A
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.
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.
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.
TEACH-IN 3
£7.99
The three sections of the Teach-In 3 CD-ROM cover a Mike & Richard Tooley
FROM THE PUBLISHERS OF
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
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
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.
£18.95
ELECTRONICS FROM THE PUBLISHERS OF
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.
Audio Out – an
CD
£8.99 FR RO
- £8.99
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
Microchip MPLAB
RE FOR
SERIES SOFTWA 7
CH-IN
THE TEA
SERIES
Smartscope software.
building PIC-based projects
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
‘ 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
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,
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
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
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
(The stack pointer will POP $B <tar>4R,12R,Mx <tar-aop> Pop value from stack into <tar>4,5,10,11
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.
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.
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.
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
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
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,
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).
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
UNDERSTANDING ELECTRONIC CONTROL SYSTEMS Order from our online shop at: www.epemag.com
Owen Bishop
228 pages Order code NE35 £36.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
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
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
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.
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
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.
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!
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.
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,
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
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
JPG Electronics
Britannia Maison Mes Amis
Inn
Old Road
3. Send a cheque with your details to:
ad
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.
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.
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