Elektor USA - January, February 2017
Elektor USA - January, February 2017
Elektor USA - January, February 2017
www.elektormagazine.com
Sand Clock
Cool Power
with D-Watt
A high-performance
amplifier with lots of
output power
a real
CAD for PCBs
eye-catcher
Free and non-free
PCB layout software Analog Random Numbers • AxiCat • BrainBox Arduino • Build a Chipamp!
• CAD for PCBs • Catdoku • Color LEDs • Connect Objects with Genuino
101 • Cool Power with D-Watt • DAB+ Antenna Diplexer • Debugging
the Arduino Zero & M0 Pro • electronica Fast Forward Award 2016 •
Elektor Labs Pipeline • Elektor SDR Reloaded (4) • Err-lectronics • The
Fetron • Retronics: From Verobox to Heavy Metal • Internet Radio with
Fluorescent Display (2) • IoT Shield for Arduino • LED Stairway Lighting •
LEGO Control Board for the Raspberry Pi • MAXREFDES99# Display Driver
Shield • The Mendocino Motor • Opamp Power Supply Connexions •
AxiCat
Link an IC to a Programming Adapter for USBasp • Sand Clock • Sensors make Sense (2)
Linux or Windows PC • Simple Interfacing to Analog and Digital Position Sensors • Simulation
with SystemVision • Super Simple Dice • SUPRA 2.0 MC Version
► More than 45 years
of experience
► 24-hour shipping
► More than 70,000 products
THE REICHELT
ADVERT
rch.lt/vuk
Photo : Foto- und Bilderwerk
14.25
14 digital I/Os (6 as PWM)
6 analog inputs ARDUINO UNO
USB port
www.reichelt.co.uk
PAYMENT METHODS:
www.elektor.com
www.elektormagazine.com
74
Volume 43 – Edition 1/2017
No. 481 & 482 January & Februrary 2017
21 electronica 2016
Overview of what’s hot
42
128 Elektor World News
130 Play & Win: Catdoku
To kick in the New Year our traditional
Hexadoku got a feline makeover. ELEKTOR SDR RELOADED:
STANDALONE SOLUTIONS
Can we also use the SDR Shield
with just an Arduino and no
LEARN DESIGN SHARE PC at all? Certainly we can.
It’s entirely feasible (with a
6 Welcome to the LEARN section few restrictions) because all
of the vital control functions
7 Peculiar Parts, the series are available on the Elektor
The Fetron, a Solid-state Tube
Extension Shield. The only task
8 Color LEDs that remains then is processing
Past, present and future of these colorful the IQ signals.
indicator lamps that have no filament or gas
filling.
15
With some simple changes this design can
An overview of a limited selection of currently
be adapted for use with moving-coil (MC)
available free PCB CAD programs.
cartridges.
119 Err-lectronics
Corrections, Updates and Feedback to
published articles.
94
120 The Mendocino Motor
It spins and sways… by solar power alone.
next edition
the answer: AxiCat. This multi-
protocol USB adapter can be used
for communicating with ICs with an
I2C or SPI interface, and you don’t
have to write any code to use it.
Heating Monitor using ESP8266
This heating monitor logs essential operating parameters,
shows them on its built-in display and stores them on a USB
stick for analysis later. The data is sent via Wi-Fi, so you check
85 Sensors make Sense (2)
CAD
it out from anywhere around the home or via the Internet.
Some sensors have dual outputs, one analog
and one digital. Swiss Pi Extensions
We take a trip
The journey from Cologne to electronica in Munich takes a few
hours by train. As usual the on-board Wi-Fi was distinctly flakey
and there wasn’t a reliable cell phone signal. It’s at times like
these you really appreciate the benefits of hard copy. There
was plenty of time to browse the electronics magazines I had
tucked into my
bag before I left. A
common thread in
many of the arti-
cles was of course
the IoT in general
and IoT security in
particular, which
are also the two main themes of electronica this year.
I lost count of the number of development systems and
boards from different manufacturers available — most
were preconfigured to operate with one of the Cloud ser-
DESIGN
So much to see
We certainly didn’t have any spare time on our hands at the Elektor stand during the Munich trade
show. My first priority was to get better acquainted with the entrants taking part in the Fast Forward
Start-up Award and explore their prototypes more closely (I wasn’t entirely successful at this, there
were just so many interesting things to see, the photo only shows a few of the entrants).
I also didn’t get a chance to visit the stands of the major semiconductor companies. Luckily one of
our freelance contributors and utter microcontroller fan Viacheslav Gromov was able to do that job
for me and you can read his report in the LEARN section.
One I was determined not to miss was the Microchip/Atmel stand. While there I spied an interesting
‘Power’ debugger and also a kit, which – you guessed it – has been specifically designed for secure
LEARN
The Fetron,
a Solid-state Tube
Peculiar Parts, the series
It’s shiny and tubular, 25 mm tall and 15 mm in diameter, with seven gold-plated pins at one end. It’s
clearly an active device but is it hollow-state or solid-state? The answer is both: it’s a tube and it’s solid-
state, because it’s a Fetron.
By Andrew Emmerson (United Kingdom) and drew zero filament current was an attractive proposition.
Telephone companies took a particular shine to them and the
Actually it’s a tube substitute, entirely solid-state but in the examples seen in Figure 1 came from New Zealand, where they
form factor of the tube that it replaces. It uses cascoded JFETs were used in the launch amplifiers for the sub-sea telephone
(junction field-effect transistors) to duplicate the transfer char- cables between that country and Australia. Other applications
acteristics of specific types of vacuum tubes (mainly pentodes were in high-spec. broadcast equipment and guitar amplifiers
but some triodes were also made). Introduced by Teledyne (!), whilst Teledyne marketed special tube conversion kits for
Semiconductor in 1972 and intended for military applications upgrading vacuum tube voltmeters and oscilloscopes by Hewlett
and other ‘high utilization’ equipment (not consumer electron- Packard and Tektronix to give these the same stability, low-noise
ics), the Fetron was able to extend the service life of expensive characteristics and reliability as high-quality bipolar transistors
tube apparatus, deferring the cost of its replacement. Because (Figure 2). When the time came for users to finally replace their
Fetrons were entirely solid-state, they consumed less than half equipment with solid-state, the need for Fetrons vanished to leave
the power of vacuum tubes and slashed the cost of air condi- only a few memories of this ingenious but short-lived device.
tioning. The need for frequent adjustment and periodic tube (160265)
replacement was eliminated and despite their eye-watering price,
For further reading
Fetrons could repay their cost within six months of installation.
Teledyne developed the Fetron for the direct plug-in replace- https://en.wikipedia.org/wiki/Fetron
ment of several types of existing vacuum tubes, but herein lay http://hrsasa.asn.au/docs/Fetron.pdf
their weakness. The connoisseur of Fetrons, Dr Hugo Holden of www.philipstorr.id.au/radio/eleven/fetron.htm
Queensland, Australia, explains that marketing Fetrons as tube
www.worldphaco.com/uploads/WORLDFETRON.pdf
substitutes was a fatal error. In many applications they were not
at all ideal, for example in circuits such as local oscillators that www.elektormagazine.com/magazine/elektor-201609/39810
rely on grid current automatic bias. A Fetron malfunctions in this
application and draws gate current, he states, causing device
saturation and introducing severe harmonics into the output. Please contribute your Peculiar Parts article,
Nevertheless, a ‘tube’ that generated no heat, would not drift, email [email protected]
Color LEDs
Past, present and future
By Dr Thomas Scherer (Germany)
We have known for a hundred years how to get certain inorganic materials to emit light when a current
is passed through them, and LEDs themselves have existed for some fifty years. These colorful indicator
lamps that have no filament or gas filling have been gradually refined and have become available in more
varied and vivid colors. In recent years their efficiency has improved to the point that LED technology is
replacing even fluorescent lighting. The most recent developments include LEDs that can replace LCDs.
After the invention of the crystal rectifier being insensitive to vibration and having
by Karl Ferdinand Braun in 1874 it was a much longer life. Neon lamps, with their
another 33 years before Henry Joseph working voltages of 70 V to 100 V, also
Round discovered that the point of contact went the way of the vacuum tube: LEDs,
between the metal wire and the crystal operating from voltages of 1.2 V to 4 V
could be made to emit light, yellow, red (see the text box Voltage and Color)
or even blue depending on the applied worked much better in transistor circuits.
voltage. Round was therefore the orig- Also in the 1970s seven-segment dis-
inal inventor of the LED and the elec- plays began to appear using (red) LED
Figure 3. From the antiques collection: a red troluminescent effect in semiconductors technology: see Figure 3. Some readers
seven-segment LED display with a character that he discovered has been named the will be able to remember the first pocket
height of 10 mm. ‘Round effect’ in his honor. And so our calculators like the one shown in Fig-
story begins. ure 4, which used tiny red displays that
often consumed more power than the chip
A slow evolution doing the actual calculating. My TI-59
The first modern-style LED was made at from 1977, one of the first programma-
RCA. It produced invisible infrared light. ble calculators, had many more functions
That was in 1955, and the inventor was than that example, but still only had the
called Rubin Braunstein. Texas Instru- same type of minuscule display. And it
ments (TI) has the honor of being the took such a long time for this schoolboy
first mass producer of LEDs, starting in to save up for it!
1962. TI’s infrared LED had an efficiency Three different colors of LEDs were
of a mere 1.1 %! The first visible red LED available in the 1970s: red, yellow and
was made by General Electric (GE), also green. The upper row in Figure 5 shows
in 1962; there was a surprisingly long (ignoring the blue LED on the right for
gap of ten years before the first success- the moment) some antiques dating from
Figure 4. The first mass-market pocket
ful yellow LED was made, again at GE. this period. They were in general not par-
calculators used tiny red seven-segment LED
Through the 1970s red LEDs gradually ticularly bright, the shades of red and
displays. (Source: Erhaka, Wikimedia Commons).
improved. Efficiencies approached 5 % yellow light emitted varied from device
and they started to be used as indicator to device, and the green color was not
lights. Devices typically came in round exactly convincing. Figure 6 shows the
3 mm or 5 mm plastic packages and brightness and color variation in green
used only about 40 mW of power. They LEDs from that time: all four LEDs are
had many further advantages over bulbs wired in series, with a current of 5 mA
with glowing tungsten filaments, including flowing through them. The LED at the
Figure 5. A LED miscellany. Top row, from left to right: red, yellow and four different green LEDs
of 1970s vintage, compared to a modern blue LED which is so bright that its light saturates the
camera sensor. Bottom row: modern green LEDs in 10 mm and 20 mm packages, and RGB, white
and infrared LEDs.
tions. The voltage across the LED yellow 570 to 590 AlGaInP aluminum gallium indium phosphide 2.0 to 2.4
will also increase with increasing GaP gallium phosphide
InGaN indium gallium nitride
current. The reason that the tran-
GaN gallium nitride
sition between current not flowing
green 500 to 570 GaP gallium phosphide 2.2 to 2.7
and current flowing is not perfect-
AlGaInP aluminum gallium indium phosphide
ly sharp is that in the transition
AlGaP aluminum gallium phosphide
region electrons behave statisti-
ZnSe zinc selenide
cally, having a certain probability
blue 450 to 500 InGaN indium gallium nitride 2.6 to 3.3
of overcoming the bandgap which
SiC silicon carbide
rises with increasing voltage. The
violet 400 to 450 InGaN indium gallium nitride 3.2 to 3.6
spectrum of the light from an LED
AlN aluminum nitride
also moves slightly towards lon-
ultraviolet 230 to 400 AlGaN aluminum gallium nitride 3.5 to 4.2
ger wavelengths (‘warmer’ colors)
AlGaInN aluminum gallium indium nitride
sonable prices. This will no doubt happen use in specialist lighting applications such
within the next decade, and then we will as providing precise illumination for surgi-
have at our disposal a wonderfully ener- cal operations and other uses where color
gy-efficient lighting technology based on accuracy is critical. Despite its small size,
modern semiconductors which, thanks to this SMD device can output over 500 lm
its excellent service life, will also have a of light at its nominal current of 1.4 A.
relatively small carbon footprint. Readers who like to strut their stuff
occasionally will already be aware of the
Color LEDs widespread usage of LEDs in discos and
In recent years LEDs have reached such clubs. Stage spotlights, or ‘PAR cans’
high efficiency and, thanks to mass pro- as they are sometimes called, used to
duction, low prices, that they have by be incandescent lamps rated at several
and large completely superseded filament hundred watts equipped with colored fil-
Figure 10. Cameo type CLP56RGB05PS PAR stage
lamps. And LED lamps have moved on ters. Nowadays they have been largely
effect light with 151 colored LEDs and a power
from the ungainly units seen in the past LEDified with all-electronic control (see rating of around 30 W at 230 V. Not only does the
containing a large number of SMD chips: Figure 10). Although the LED versions light sport a DMX interface for remote control,
these days you can buy bulbs whose inter- are not yet quite the equal of the old it also has a built-in microphone to enable ‘light
nal LED structures mimic the filaments technology in all respects, the availabil- organ’ effects.
of traditional slender candle-shaped fila- ity of ever brighter LEDs is closing the
ment bulbs (see Figure 8). So now it is gap. Service life, robustness, much lower
possible to populate your chandelier with heat generation, reduced risk of injury
modern energy-efficient bulbs while still (stage spotlights are prone to explosion)
remaining faithful to its style. LED lighting and instant electronic control all weigh in
is now available in practically any shape, favor of the LED versions.
size and color you can imagine: we shall Colored LEDs don’t have to be used in
return to this topic later. conjunction with music, of course. At
Infrared LEDs have of course been used an early stage Philips realized that even
for many years in remote controls, as well Joe and Janet Bloggs would be keen to
as more recently in providing unobtrusive have configurable mood lighting in their
night-time lighting for security cameras home. Under the ‘LivingColors’ brand the
or for military purposes. Another inter- Dutch electronics giant has been mar-
esting application is the use in industry keting a range of table and wall lights Figure 11. Philips LivingColors: this lamp from
the highly successful range contains remotely-
of infrared lamps consisting of hundreds for a few years now (see Figure 11).
controllable colored and white LEDs in a plastic
of SMD LEDs with a total output power of These remotely-controlled LED lamps can
enclosure.
over 100 W as a component in projectors be adjusted over a wide range of colors.
to shine a grid of infrared illumination Each lamp contains a number of color and
on one part of a production line or on an white LEDs that can produce static mixed
assembly station. The idea behind this is colors or flashing patterns, and the lamps
that, unlike a human operator’s eyes, a can also be dimmed. The success of this
robot’s cameras can easily see the pro- range led Philips to produce the ‘Hue’
jected grid and hence orientate itself in range (Figure 12). This brand includes
space and better estimate the position not only lamps, but also LED strips and
of units on the production line. Humans ‘normal’ colored bulbs for E27 fittings,
working alongside the robots or monitor- all remotely controlled using a ‘bridge’. A
Figure 12. The Hue series from Philips includes
ing their operation are not disturbed by range of lamps with built-in lithium bat-
colored LED lamps with E27 fittings and a
the infrared light. teries is also available under the ‘Hue Go’ ‘bridge’ for remote control
White LEDs are not the only way to gen- brand. These lighting systems have been
erate white light: a more expensive, but highly profitable for Philips and so doubt-
equally good, if not better, alternative, less further variants will also appear on
is to use RGB LEDs. These consist of LED the market. If you are looking for a more
chips in (at least) the three primary colors economical alternative, you will not be
mounted in a single package. By passing disappointed: the DIY sheds have spot-
different currents through the different ted the opportunity and offer shelfloads
chips the outputs from the individual LEDs of inexpensive color LED lighting of all
can be mixed at will to produce practi- kinds (Figure 13), costing just a fraction
cally any desired color. Figure 9 shows of the price of the big-brand products. For
an example, an OSTAR SMD LED, which an even cheaper solution, you can import
includes not only chips with red (625 nm), directly from China using eBay or Alib- Figure 13. These days you can find a huge
green (530 nm) and blue (453 nm) LEDs, aba. In this case, of course, you have to selection of LEDs strips, bulbs and effect lamps
but also a white LED. It is designed for reckon with the complications of dealing with or without remote control in any DIY shed.
boards or building ‘black lights’. Another environment, but that is now changing.
application for ultraviolet LEDs is illumi- OLEDs can very easily be used, for exam-
nating the water flowing through a trans- ple, to make displays, as printing tech-
parent pipe, with the aim of reducing the nology allows the organic light-emitting
growth of algae in aquaria and swimming pixels to be manufactured along with
pools. Some varnishes can be cured using their interconnect wiring. RGB OLED dis-
ultraviolet light, and the LEDs can also be plays are bright and contrasty. Similar
used to test the resistance of products to approaches to manufacturing displays
exposure to ultraviolet light. with semiconductors are much more
complicated and decidedly more pricey.
OLEDs OLED displays are increasingly compet-
Organic LEDs (OLEDs) were discovered ing with LCD displays and in principle the
much later than inorganic LEDs, and so OLED beats its liquid-crystal counterpart
far cannot compete with them in terms of in virtually all departments. There is no
Figure 14. Google Nexus 6p: the OLED display light output or long-term stability. How- backlight or any of its attendant prob-
on this reasonably-priced smartphone has a
ever, their star is in the ascendant: the lems, as the OLED pixels are themselves
resolution of 2560x1440 pixels.
advantages of OLEDs are low-cost raw the source of light. Current consumption
materials and, in principle, lower cost of is also lower, as much of the light from
with possible customs charges, and of manufacture, as they do not require such an LCD’s backlight is lost in the diffuser
course always bear in mind that cheaper strict ‘clean room’ conditions. OLEDs can and in the polarization filters. Colors that
does not necessarily mean better value also be made in flat sheets: this is an change with viewing angle are a thing
(see the text box Feel the Quality). advantage in many lighting applications, of the past with OLEDs. And last but not
Naturally ultraviolet LEDs also have their as the sheets do not have to be rigid. least the contrast ratio of an OLED display
uses. As well as specialist applications Flexible lamps are therefore a possibility. cannot be beaten: when an LED is off, it
there are uses such as exposing the For a long time it has proved difficult to is off. Blacks really are black.
photosensitive lacquer on printed circuit make OLED products outside a laboratory Given all these wondrous advantages you
Feel the Quality Correcting for this effect, a lamp consisting of ten LEDs might
have a service life of only 15000 hours rather than the hoped-for
LED lamps, containing a large number of individual LEDs to pro- 50000 hours. And, if in the real-world vehicle environment, the
vide sufficient light output, have been available for some time. life of an individual LED falls to only 10000 hours, one LED in the
Since the mid-1990s car makers have routinely used a string of ten-LED lamp might easily fail after only 3000 hours. But that is
red LEDs for the ‘third’ brake light, even on mid-range vehicles: not the end of the story: in vehicle lights that use LEDs designed
the red LEDs of the time were already bright enough and cheap for a 12 V supply, the LEDs are often wired in series strings of two
enough. Customers were happy too, as the light did not need or three devices each, and so the failure of one LED leads to the
replacing as often over the life of the vehicle as an incandescent loss of light from one or two more. Another problem is that the
version. Brake lights are an important part of vehicle safety, and LEDs in vehicle lights are often hermetically sealed and so are not
so not failing after a few hundred operating hours is a significant replaceable. Instead of just replacing a two-dollar bulb the whole
benefit. All very warm and fluffy, but cracks start to appear in the lamp assembly has to be taken out and replaced.
story when it comes face to face with reality. These are not mere academic considerations, but reflect my own
More specifically, two phenomena come into play, which togeth- personal experience: the brake light on my 1996-model Fiat failed
er make the situation far from ideal. The LED brake lights do in- in just the way described above after only three years, and a re-
deed have a huge ‘theoretical’ service life of up to 50000 hours. placement part plus labor was not a cheap proposition. And in
But in the vehicle environment that does not represent much of case you are thinking ‘well, that’s Fiats for you’ I should say that,
a guarantee, what with vibration, bad weather and high humidity despite the alleged reliability of Toyota vehicles I had an LED fail
levels (which can lead to corrosion of printed circuit board tracks, in exactly the same way on my Prius. In this case it was part of
for example), and extreme temperature variations. These lead to the left-hand rear light cluster, which contains a large number of
mechanical stress on the LED packages, chips and bond wires. As integrated LEDs all firmly fixed in position. At eleven years (in
a result the quoted service life of 50000 hours is a pipe dream. fact, at the same time as the brake disks needed to be replaced)
The car’s bodywork can get very hot in sunshine, and the heat one of the lights failed. Fortunately a third-party replacement part
dissipated by the LEDs adds to this to generate very high oper- was within my means, but still not cheap. If the LEDs in the head-
ating temperatures. The consequence is that LEDs in automotive light on a modern vehicle should fail, you are certainly looking at
applications do indeed last longer than incandescent bulbs, but a tall bill from your garage. Modern technology comes at a price!
not by the large factor that you might have hoped for. In addi- This disadvantage of multi-LED clusters becomes a significant
tion to this there is the ‘multiple LED effect’: even under optimal problem when they are used for domestic lighting. Although hu-
conditions, when many LEDs are in use it is statistically inevitable midity and temperature fluctuations play a lesser role in this en-
that the time for which all LEDs will be working will be reduced. vironment, there is still the question of the quality of the com-
would be forgiven for asking whey OLED being increased, however, and the rumor This is because total operating costs are
displays are not more widespread. The mill has it that there may be sufficient much lower than other technologies, not
problem lies in the extremely demand- capacity by the end of 2017 for an OLED just because of their greater energy effi-
ing requirements of the manufacturing panel to appear at least on the higher-end ciency, but because they require less fre-
process. The many LEDs in a single dis- versions of the iPhone 8. quent maintenance as a result of their
play must all be equally bright (within longer service life. Street lighting is one
rather narrow limits), and must stay that The future application where soon there will be no
way over time. The consequence is that Besides the rumors of an iPhone 8, OLED alternative to LEDs. LEDs could allow the
as little as two years ago even small- panels will shortly be found in all kinds construction of intelligent car headlights
screen TVs were unrealistically expensive. of gadgets and appliances that need to that automatically adjust the shape of
However, towards the end of 2016 LG, display something. It is no exaggeration the light cone away from oncoming vehi-
the market leader in OLED TVs, intro- to say that pretty much every other kind cles to avoid dazzling their drivers; per-
duced a model with a 55-inch diagonal of display technology will soon have had haps manually dipping and undipping the
for a reasonably affordable US$1500. its day. OLEDs will also make inroads into headlights will no longer be necessary.
Smartphones with OLED displays have lighting applications: when that starts We should be so lucky!
been around for rather longer, and the to become economically feasible, many (160246)
price difference for small displays com- lighting manufacturers will jump on the
pared to LCDs is now relatively small: bandwagon. Lamps for conventional fit-
the moderately-priced Google Nexus 6p, tings will remain the domain of semicon- Web Links
produced by Huawei (Figure 14) con- ductor LEDs, since for the foreseeable [1] ‘Let There Be LED’:
tains a 2560x1440 pixel panel with some future OLEDs do not offer the light den- www.elektormagazine.com/150577
11 million OLEDs. You might wonder why sity required to provide adequate illu- [2] www.youtube.com/
no iPhone has been produced using an mination from a small bulb. Inorganic watch?v=Oj8RIEQH7zA
OLED display: the answer is that, as of LEDs will also supersede practically all
2016, there is insufficient manufacturing other lighting technologies except in niche
capacity in the world. Capacity is steadily applications with specialist requirements.
ponents used. Low-cost LED strings from of the same color from a spare strip and
the Far East used for Christmas decora- mended the original strips, but after an-
tions or for fun are of course fine, but in other two months two more LEDs were
many cases it is hardly possible to believe pushing up the daisies (Figure 15), and
the price of a product on offer. A whole no doubt this is not the end of my woes.
string can often be sold for less than the Regular LED lighting can also often have
total cost of the LEDs it contains. How do shorter life than expected. LED bulbs have
they do it? The easiest reply to this ques- not been around for all that long, but nev-
tion is usually ‘at the expense of quali- Figure 15. A failed LED strip. It is perhaps partly ertheless I have had four bulbs with E27
ty’. And aesthetic considerations are no my fault that LED L30 has gone to join the choir fittings and two GU10 spotlights bite the
determinant of when an LED becomes invisible: because of the kink in the strip it was dust. In the case of the E27 bulbs it was
not being properly cooled, and it has failed to a
an ex-LED [2]; even my Christmas dis- the switching supply circuit whose coil
short-circuit rather than an open-circuit. Other
plays, which are of course done in the proved all too mortal, whereas in the case
LEDs in the same strip, however, seem to have
best possible taste, have on occasion suf- of the GU10 spotlights the LEDs them-
met their demise without such a good excuse.
fered from LED strings (or at least parts selves became history after exposure to
of them) going to meet their maker. excessive temperature. In the case of two
Low-cost LED strips with a self-adhesive LED tubes bought as replacements for flu-
backing, which are powered indirectly orescent lights the engineers at LG had
from a low-voltage supply and which are put a fuse with too low a rating in the in-
often used for illumination in furniture and tegrated switching power supply circuit:
similar applications, suffer from the same uprating the fuse fixed the problem and
problem. My personal tribulations involve the tubes still work today. Also, my home-
two LED strips, each 2 m long, stuck to made LED lamp (Figure 16), which uses
a length of aluminum section: a total of 13 high-quality LEDs, is still going strong
120 LEDs. My estimate for the time to after more than a decade.
the first failure had been of the order
of 4500 hours, but after just six months
Figure 16. The first ‘Scherer-brand’ home-made
and perhaps 600 hours of operation eight
LED lamp was made in 2005, and continues
LEDs had already kicked the bucket! I to run to this day, after over 10000 hours of
desoldered some replacement SMD LEDs operation.
Programming adapter for USBasp programmer to power the board). These are
From Antonello della Pia then soldered to the corresponding pins on the
8-way socket. The pin header is connected to the
other end of the cable.
I think it’s a great idea to provide a forum where we can
share ideas with the rest of the electronics community (not Now, where does this go? The cables cannot pass under the socket
forgetting the chance to win £50!). One of my all time favor- or cross so I made up another cable fitted with a female header
ite microcontrollers is the ATtiny85, which I usually program using to make the necessary connections to the USBasp. Check out the
a simple and low-cost USBasp programmer.
Table 1. Programming pin assignment pin number correspondence between the 8-way socket and the
(ICSP) for the ATtiny85. USBasp header (Tables 1 and 2)!
Signal Pin Pin Signal
RESET 1 8 VCC It should be clear from the photo how it all goes together. I also
found another use for the adapter: when there’s no space or you
nc 2 7 SCK
don’t want to fit an ICSP header to a board just for programming,
nc 3 6 MISO
this adapter can be used as an intermediate socket between the
GND 4 5 MOSI
ATtiny and its socket on the board for programming purposes.
Have you come up with an inspired way of solving a really challenging problem? Or found an ingenious
but ‘alternative’ way of using some component or tool? Maybe you’ve invented a better or simpler way of tackling
a task? Do write in – for every tip that we publish, we’ll reward you with UKP40 (or local equivalent)!
Hardly anyone who works with electronics, whether professional or enthusiast, is content to leave their
design at the breadboard stage. Particularly with SMD components or relatively complex circuits, this is
anyhow difficult, and prototyping boards are not the ideal solution. There is no getting around a real PCB in
such cases. For that you need suitable software, and to choose the right software, you need information.
KiCad
KiCad is also an open source electronic design automation
suite, with the relatively mature version number 4.0.4. The
high level of user community support for this software project
can be seen from the periodic software updates as well as the
fact that finished distributions are available not only for Win-
dows and in some cases OS X, but also for the Linux deriva-
tives Ubuntu, Debian, Mint, Arch, Fedora, openSUSE, Snappy
and Gentoo. This means that if you opt for KiCad, you can be
fairly certain that you will not suddenly find yourself stuck with
files that are no longer readable or editable because current
software is not available.
CometCAD
Some freeware is good, and some is not. CometCAD unfortu-
nately falls in the latter category. Although this simple com-
bination of a schematic editor and a layout program can do
forward annotation and you can make usable PCBs with it, it’s
not exactly easy.
Osmond PCB
Osmond PCB is similar to CometCAD. There is a limited free
version and a payware version. The limitations here are not
as severe; the free version is only limited to a maximum of
700 pins if you want to output the board data in a file (Excellon,
etc.) or print the layout. There are two significant differences
with respect to CometCAD: Osmond PCB is Mac only, which
means it is only available for OS X, and there are periodic bug
fixes. The current version (1.1.33) dates from August 2016.
However, that’s the end of the good news. The look and feel of
the program have not changed since the original design, which
means OS X 10.5. Since then the Mac world has changed a lot,
with OS X now at version 10.12. The user interface is simple, Figure 5. It works, but on the thin side and limited: CometCAD.
and the features are equally simple. One of the biggest short-
comings is the components library, which is a key resource for
PCB design. The library contains a total of 130 components,
which is pitifully few.
Support for scripting and data output in all major file formats
is not enough to make things right. In light of what other
packages offer, it is difficult for small software developers to
compete, and users have to consider whether they want to put
the effort into learning how to use niche software.
EasyEDA
If you are not a fan of big, feature-rich CAD packages from
major vendors with long pedigrees, or you only want to make
occasional “quick and dirty” PCBs, you might want to take a Figure 6. Mac only, and also thin and limited: Osmond PCB.
matic and PCB views within the simulation session. The idea
appears to be that modern electronic designers don’t bother
with breadboarding, since they can simulate the circuit and
then go straight to the PCB.
Other options
Along with open source programs and free versions of commer- limited to Eurocard format (100 x 160 mm). A prerequisite is
cial CAD packages (usually with limitations), there is a third a valid .edu email address. The Express version is available to
category of CAD software which is fostered by major electronics everybody. Although it also has an autorouter, the schematic
distributors. Some examples of this are EAGLE from Farnell/ is limited to two sheets and the maximum board size is half
element14, DesignSpark PCB from RS Components, and Mul- as large (100 x 80 mm). That makes the board size the key
tiSIM Blue from Mouser Electronics. Informative articles on all difference. Interestingly enough, EAGLE is available not only
of these programs have been published in previous issues of for Windows, but also for OS X in 32-bit and 64-bit versions.
Elektor. Their key features are briefly described below.
A control panel provides access to the various modules, includ-
EAGLE ing the schematic editor, PCB layout and component libraries.
EAGLE is probably the best known PCB layout program amongst EAGLE is fully sufficient for most purposes. The Elektor Store
hobbyists. One reason for this is that along with paid versions, offers several good books on EAGLE, to help you get started
it has always been available in completely free versions, mainly quickly, correctly and comprehensively.
limited with respect to board size. Students are especially fre- EAGLE was recently acquired by Autodesk. The new owner has
quent users of the free versions. EAGLE consists of two modules: already announced that the free versions will remain available.
one for drawing schematic diagrams and the other for laying
out PCBs. They communicate with each other through direct MultiSIM Blue
forward and backward annotation. There are two different free This is a limited version of the expensive professional MultiSIM
versions: Educational and Express. The Educational version is CAD package from National Instruments. Mouser collaborated
intended for schools and universities and has minimal limita- with NI to make a free version available. Of course, the free
tions. It has an autorouter and allows up to 99 sheets per sche- version has several limitations, but fortunately (and for obvi-
matic. Boards can have up to six layers, with the maximum size ous reasons) it comes with a library of more than 100,000
components from the Mouser catalog. Although that falls well
short of the full Mouser product portfolio, it is gradually being
expanded. You can even put together a components list for a
schematic and get the Mouser prices for the components. That
is very practical, of course, but if there is a component that
Mouser does not carry and you want to add it from another
supplier, you have a problem.
Altium Designer and EAGLE. It can also import net lists from Web Links
LTspice. And last but not least, it can import libraries from KiCad.
Pad2Pad: www.pad2pad.com/General/Software.html
EasyEDA comes from a Chinese company that also sells PCBs,
gEDA: www.geda-project.org
which can be ordered directly from the program. At about $17
for a single double-sided board measuring 100 x 100 mm, they KiCad: http://kicad-pcb.org
are reasonably priced. This online package is certainly worth Fritzing: http://fritzing.org/home
bookmarking as good backup CAD solution. CometCAD: www.cometcad.com
Osmond PCB: www.osmondpcb.com
What else?
The selection of packages described here is far from complete, EasyEDA: https://easyeda.com/editor
but it gives you a good idea of what is currently available in EAGLE: https://cadsoft.io
the form of slimmed-down free versions or completely open- MultiSIM Blue: www.mouser.co.uk/multisimblue
source programs with no limitations. Wikipedia has a good
DesignSpark: www.rs-online.com/designspark
tabular overview of electronic design automation (EDA) soft-
ware, including custom and niche products. If the web links CAD overview: https://en.wikipedia.org/wiki/
listed below are not enough for you, the Wikipedia overview Comparison_of_EDA_software
is a good source of additional leads.
(160176-I)
DesignSpark
DesignSpark from RS Components is a version of the Easy-PC
PCB CAD program from UK software developer Number One
Systems, specifically adapted for RS. Two additional versions
have been released in recent years: DesignSpark Electrical Figure 10. DesignSpark provides 3D visualization of finished PCBs and is
for drawing electrical system diagrams, and DesignSpark free from distributor RS Components.
When 2,913 exhibitors and around 73,000 visitors from 88 different countries all get together you can
be sure there’s lots to talk about and marvel at. From passive components via new types of special
connectors and new sensors with pattern-recognition software the range of innovation was exhilarating.
Here we present just a tiny selection of some of the intriguing items that caught our eye at the electronica
trade show in Munich, Germany, last November.
Semiconductor design and manufactur- point at the show and Cypress already kit built around the SHT31 humidity and
ing company Cypress Semiconductor has much to offer in this area. New temperature sensor. This new sensor is
were showcasing new products in two solutions for the technology include the available in a 2.5 mm square package
different areas of interest. Firstly they EZ-PD CCG3 (48 MHz, 64 KB dual flash), and communicates via an I²C interface.
have a new addition to the established with a 32-bit ARM Cortex M0 core which It samples the temperature and humid-
can fully support a USB-C port includ- ity (with 2% or 0.3°C accuracy) at a rate
ing all the interfaces with power deliv- defined by the user. At one measure-
ery. The evaluation kit to go with this is ment per second the sensor draws just
the CY4531 EZ-PD CCG3 Evaluation Kit 2 µA. The board shows the measured
priced at $250. values which can also be read via Blue-
tooth on smart gadgets running an app.
Also from Cypress is the new CY4500 It also serves as a reference design for
EZ-PD Protocol Analyzer board which designers planning to use the sensor. The
looks like a very interesting tool for board is powered by a button cell and has
USB-C developers. The board has a an LCD screen and an 8-bit MC9S08LL-
USB-C port and a USB-C receptacle 8CGT MCU, a pushbutton and the Nordic
connector allowing it to be inserted, nRF51822 BLE module (Bluetooth Low
for example between a computer and Energy). Connections to the sensor, MCU
a peripheral device. It’s transparent to debug pins and the BLE module are easily
the passage of this USB-C data. A third accessible for development purposes. All
connector type USB micro-B hooks up to information for the hardware and software
a host computer for power and for anal- is also available from GitHub [3].
ysis of the USB data. The analyzer costs
around $200 but looks like an indispen- Infineon certainly had much to show
sible tool for developers of USB-C appli- and tell. They have serious numbers of
cations, it allows you to test programmed Arduino shields fitted out with their latest
communication between two devices as ICs. One of their popular small USB-stick
PSoC MCU family called the PSoC Ana- well as the cable and wiring [2]. sized evaluation boards the ‘XMC 2Go’ for
log Coprocessor (48 MHz, 32 KB Flash). the ARM based XMC1100 (M0+, 48 MHz,
This 32-bit MCU, based on the ARM-Cor- 64 KB) processor has now spawned a
tex-M0+ core forms an interface between family of three similar sized boards using
the analog and digital world. On board the same MCU plus sensors on board. The
there are ADCs, DACs, opamps, compar- SPI-current sensor board ‘Current Sensor
ators, analog filter, capacitive-sensing
touch interface und much more. The $49
CY8CKIT-048 PSoC Analog Coprocessor
Pioneer Kit has been developed to allow
designers to explore the possibilities of
this flexible PSoC technology. The board In addition to their advanced gas flow
has many analog sensors on-board suit- sensors Sensirion were showcasing their
able for applications ranging from tem- small but sophisticated SHT31 Smart
perature measuring to inductive proximity Gadget Development Kit priced at €30.
sensing and PIR motion detection [1]. This Smart Gadget dev kit is a simple
USB-C technology was also a big talking reference design board and development
Web Links
[1] www.cypress.com/products/psoc-analog-coprocessor
[2] www.cypress.com/products/ez-pd-ccg3-type-c-port-controller-pd
AES, DES, SHA and RNG for IoT applica- [3] https://www.sensirion.com/en/products/humidity-sensors/development-kit/
tions. Test and calibration functions for [4] http://goo.gl/o9hhGd
the internal peripherals (e.g. ADC and [5] http://goo.gl/Xu5Lkr
GPIOs) are also implemented. [11]. [6] www.st.com/en/evaluation-tools/32f769idiscovery.html
[7] http://katalog.we-online.de/en/pm/MAGIC-FISM
Amid all the new innovation in the truly
[8] http://katalog.we-online.de/en/pm/MAGIC-FDSM
analog world Analog Devices were
demonstrating the capabilities of their dis- [9] www.ti.com/tool/launchxl-cc1350
tinctly digital but no less impressive ADZS- [10] www.ti.com/tool/ldc0851evm
BF707-BLIP2 (Blackfin low-power imaging [11] www.renesas.com/en-eu/solutions/key-technology/human-interface/rx71m-revelation.html
platform) board. This was running some [12] Http://goo.gl/LpdZig
software libraries with multiple functional
[13] www.atmel.com/tools/ATTINY817-XMINI.aspx
profiles for applications such as intelligent
[14] www.microchip.com/promo/pic18f67k40
motion sensing, people counting, vehicle
The Mowea modular wind energy appliances for JF Brandon from BotFactory came all the way Artem Kuchukov (second from the left) shined a
off-grid areas project was unanimously selected from Long Island City (USA) to present his happy smile when he received the Third Prize for
as the Overall Winner of the Fast Forward Award Squink desktop PCB printer. It was definitely the Kewazo scaffolding assembly robot project.
2016. Till Nauman (second from the right) worth the effort as he flew home with the
received the Grand Prize from electronica CEO Second Prize.
Falk Senger (right), assisted by our sponsors
(from left to right) Shawn Silberhorn (Conrad),
Alexander Gerfer (Würth Elektronik) and Jacky
Perdrigeat (STMicroelectronics).
In industrial drive control system designs, “glue” elements like control and connectivity building blocks
pose many challenges such as lengthier development cycles, a larger board area or a higher BOM
cost. As a result, developers are often
unable to concentrate
on differentiating
features like enhanced
performance, greater
precision and
improved control
loops. Here, some
new supportive
technologies are
discussed to make
life easier.
A particular example of this is the task of interfacing micro- mentation would add cost to the system by increasing the sys-
controllers (MCUs) to position sensors. These sensors can be tem’s electronic BOM, impacting the necessary board space and
linear, angular or multi-axis and typically are used to sense the requiring lengthy development cycles. Moreover, developers
relative or absolute position of a mechanical system in motion, also have to complete extensive compliance testing to certify
propelled by a motor. The sensed position is then converted conformance with industry standards.
to an analog or digital electrical signal for transmission to the This situation begs for a solution that would simplify the inter-
controlling circuit. facing of position sensors to control elements in industrial
Historically, interfacing a position sensor to an MCU could be drive systems and thereby free designers to concentrate on
a time-consuming task that often involved the integration of features and functionality that would make their systems truly
the communication protocol into a field programmable gate distinctive, as well as more competitive, in the marketplace.
array (FPGA) or the programming of an additional MCU with
the decode protocols. In addition, this situation is exacerbated Integrating position feedback
by the fact that there are multiple encoder protocols available, Building on the C2000™ Delfino™ MCU portfolio, Texas Instru-
each suited to certain types of functionality and subsystems. ments provides a comprehensive platform for industrial drive
The system design team might be forced to develop several and control systems. Starting with the processing capabilities
protocol-specific FPGAs which would not scale effectively from required by sophisticated and precise control systems, the
one application to another. Of course, this type of FPGA imple- C2000 Delfino F28379D and F28379S MCUs are equipped with
Analog Sub-System
A SinCos
PM
B SinCos SinCos is a feedback methodology which is incorporated into
Library
encoder interfaces like Hiperface® as well as other proprietary
I
SinCos
interfaces. These so-called sinusoidal absolute encoders typ-
position encoder 160221-14 ically offer much higher position and speed resolutions than do
resolver or incremental encoders. In conventional quadrature
encoders, angle information is obtained by counting the edges
Figure 4. Industrial servo drive with SinCos position encoder interface.
of a pair of quadrature pulses.
Angular resolution is fixed by the number of pulses per mech-
anical revolution. However, in SinCos transducers, precision of
the angular measurement is increased by computing the angle
8-Wire cable,
Data+
Data–
between edges using the relationship between a pair of sine
single shielded Clock+
and cosine outputs from the sensor. Effectively, an interpola-
Clock–
Up (Power) tion between edges is made to obtain a ‘fine’ angle. The fine
Un (Ground)
Up* (Power) angle is computed using an arctangent of the two sinusoidal
Un* (Ground)
inputs. For this computation to be valid, both inputs must be
Encoder sampled simultaneously.
EnDat 2.2 Master
TMS320F28379x
Connector Supply
Motor M12, 8-pin
Connector Typically, several thousand electrical revolutions of the sinus-
RS485 oidal signals occur during each mechanical revolution of the
RS485
encoder shaft.
The internal analog sub-system of the F28379 Delfino MCUs
SinCos is ideal for interfacing to SinCos transducers. The presence of
position encoder 160221-15
multiple ADCs, which can be triggered from the same source,
allows simultaneous measurements of both input channels. In
Figure 5. Industrial servo drive with EnDat 2.2 position encoder interface. addition, the F28379 MCUs include a native ARCTAN instruction
as part of the Trigonometry Math Unit (TMU) which means the
angle calculation can be done in as little as 70 nanoseconds!
Another consideration is the high motor shaft speed state
(Figure 4). In this case, there is no longer a need for precise
angle information and the measurement algorithm only needs
to count the number of complete sinusoidal revolutions to deter-
Encoder mine a “coarse” angle measurement. Typically, this is done
EnDat 2.2 Master
TMS320F28379x
Supply
using a pair of analog comparators which compare the incom-
RS485 ing sinusoids with a threshold representing the zero crossing
point. The comparator outputs correspond to the sign of each
RS485
sinusoid and the resulting digital signals are similar to those
produced by a quadrature encoder. On the F28379 MCUs, there
160221-15
are up to eight pairs of analog comparators, each with its own
programmable threshold voltage. These allow the quadrature
Figure 6. Industrial servo drive with BiSS-C position encoder interface. pulses to be generated which are then fed internally to one of
the on-chip quadrature encoder peripheral (QEP) modules for
coarse angle and speed measurements.
tomer projects. The lower system layers are provided on-chip EnDat
or through reference designs and a ready-to-use library of EnDat is a digital bi-directional four-wire interface developed
application programming interface (API) modules. by the German company, HEIDENHAIN. A sensor with an EnDat
In addition to reducing development time, Position Manager encoder can communicate position values, transmit and update
technology also decreases the compliance and interoperabil- information stored in the encoder, or save the information. Data
ity testing that system manufacturers have undertaken in the is sent along with clock signals. The C2000 MCU can select
past. The Position Manager technology is fully tested across the type of data the encoder will transmit, including positon
a variety of sensors. Please see the user’s guides for details values, parameters, diagnostics and others.
on the testing results. Moreover, future revisions and updates Position Manager technology interfaces the C2000 F28379 MCU
to the applicable standards will also be supported by Position directly to the EnDat encoder (Figure 5). The only compon-
Manager technology. ents external to the MCU are two RS-485 transceivers and the
encoder power supply circuit. The EnDat Master is implemented face can be adjusted to feature improved control of modular
using the C2000 MCU’s configurable logic block, where the functions and timing by transmitting position information from
communication protocol is handled. encoders every control cycle.
Position Manager technology has been tested against a range
of rotary, linear and multi-turn encoders from HEIDENHAIN Industrial drive control systems-on-chip
and across resolutions from 13 bits to 35 bits at distances of Powerful and programmable MCUs like TI’s C2000 Defino
70 meters or more. F28379 MCUs represent the next step toward industrial drive
control systems-on-chip (SoC). They empower more effective
BiSS-C and efficient system architectures by eliminating the need for
The open source BiSS (bi-directional/serial/synchronous) digital an external FPGA for ancillary processing requirements or by
interface is based on a real-time communications protocol. reducing the size of the FPGA significantly.
The original specification was developed by iC-Haus GmbH of By enabling a direct connection between a C2000 MCU and a
Germany. position sensor, Position Manager technology frees developers
BiSS-continuous mode (BiSS-C) is employed in industrial appli- from the more mundane tasks of device connectivity so they
cations. The specification has its roots in the Synchronous can focus on the features and capabilities that will make their
Serial Interface (SSI). The BiSS-C interface consists of two system solutions truly distinctive in the marketplace with sig-
uni-directional or bi-directional lines for the clock and data. nificant competitive advantages.
As with all interfaces supported by Position Manager technology, (160221)
a BiSS-C master running on a C2000 F28379 MCU can connect
directly to a BiSS-C encoder slave on a position sensor (Fig- The platform bar, C2000 and Delfino are trademarks of Texas Instruments. All
ure 6). The interface transmits position values and additional other trademarks are the property of their respective owners.
information directly from the encoder to the MCU.
The MCU is able to read and write directly to the encoder’s
internal memory. TI’s Position Manager technology includes a
feature-rich BiSS-C library of capabilities, which system develop-
ers can readily draw on for their development projects. For
example, clock frequencies of 8 MHz are supported on cables
up to 100 meters long. In addition, the C2000 MCU BiSS inter-
Advertisement
#redCUBE
Not a one-trick pony, Heinrich also laid the foundations for the cur-
rent field of contact mechanics when he solved the contact problem
of two elastic bodies with curved surfaces. With his observation that
a charged object loses its charge faster when illuminated by ultra-
violet radiation he helped to establish the photoelectric effect. His experiments
even place him at the beginning of X-rays. That Heinrich lived at the edge of
knowledge was proven for the last time when he died from a rare disease that
was only discovered officially some 40 years later.
Although he died too young, Heinrich did manage to pass some of his genius
on to his offspring, allowing his youngest daughter Mathilde to become a
world-renowned biologist and psychologist. His brother’s son, Gus-
tav Ludwig, won the Nobel Prize for Physics in 1925. Comparing
photos of Heinrich and his clever nephew, the resemblance is so
LEARN
striking that one wonders that maybe his nephew’s daddy wasn’t
his nephew’s daddy, but his nephew’s daddy didn’t know?
The SI unit for frequency became the hertz (Hz) in 1960 when it
replaced the cycle per second (cps). One hertz is defined as 1/sec-
ond or s-1, exactly as the becquerel (Bq), however one hertz means
one event per second with the events spaced exactly one second
apart, whereas one becquerel means one event per second on average.
Where Joseph Henry has a mountain range named after him, Heinrich
has a crater on the dark side of the moon that caries his name. Searching
the Internet I did manage to find a recipe for a Hertz burger, nicely com-
bining the two great nineteenth century Hamburger concepts into one.
(160247)
BTA 08-600S
MASTER A1
G
TRI
A2
It works like this: the full AC grid voltage directly to the AC grid with no galvanic The type of triac used here depends on
(120 V or 230 V) is applied to connection isolation, it is imperative to ensure that the amount of current drawn by the mas-
A1 of the triac and the master equipment the circuit is fully enclosed to avoid any ter and slaves. A BTA08-6008 (600 V/8 A)
live feed connects to the gate (G) lead. possibility of accidental contact with any triac requires a very small gate current
Live supply to the slave equipment comes part of the circuit during use. The Pro- and low trigger voltage.
from the A2 lead on the triac (Figure 1). tective Earth (US: Ground) lead should (130419)
remain intact to all the sockets.
When the master equipment is switched
on, its supply voltage flows between A1
and G. The triac conducts and provides
a live supply to all the slave equipment
from its A2 pin. When the master equip- K3 K4 K5
F
SLAVE SLAVE
ment is turned off the gate current drops
< 6A3 SLAVE
to zero, the triac turns off and power to
the slave equipment also turns off. A2 BTA 08-600S 230V~ 230V~ 230V~ / 115V~
TRI
K1 A1 G
It also functions if the gate and A1 con-
nections are switched so that the AC input
AC power *
connects to the gate and A1 provides 230V / 115V
power to the master socket. In this con-
K2
figuration however combined power to the
master and slave will now pass through MASTER
the gate instead of A1, see Labs com-
ment below. 230V~ / 115V~
Sand Clock
A real eye-catcher
By Ilse Joostens & Peter S’heeren (The Netherlands)
This nifty gadget built around an Arduino Uno uses some servos and a pantograph mechanism to write
the time in a sand bed. After a configurable time interval the sand is smoothed out by a pair of vibration
motors and the cycle starts over again. Along with the automatic time mode, the clock software has a
command mode which allows you to control the pen using simple commands.
Figure 1. The kit contains all the parts (including the AC adapter) necessary Figure 2. The positioning of the two vibration motors beneath the sand bed
to build the Sand Clock. However, you have to program the Arduino yourself is critical for shaking the sand surface smooth.
using the free download software.
The original idea for this project came Most of the mechanical parts of the Sand age. Another relative from a mechani-
from one of our friends at the German Clock are made from 3-mm extruded cal perspective is the Autopen signing
magazine Make:, who in turn was inspired PMMA (acrylic) sheet, also known by the machine, which uses a pantograph mech-
by the plotter clock built by FabLab in brand names Perspex and Plexiglas. Along anism to duplicate handwritten signatures
Nuremberg (Germany). During the first with being readily available, this material on paper. These machine are still used by
hardware team meeting with the folks at can be cut very easily with a laser cut- high-ranking politicians and public figures.
Make:, the authors selected a number of ting machine, resulting in nicely finished They are also sometimes used in fund
projects that appeared to be suitable for edges. The thermoplastic properties of raising campaigns because an Autopen
adaptation and modification by Elektor the material are an added bonus. signature looks more authentic than a
Labs to produce DIY kits for retailing. Here we use three model servos to drive printed signature. Many US presidents
The first project tackled by the Elektor the clock mechanism, the same as in the have been well-known Autopen users,
Labs is the Sand Clock described here. original plotter clock. The torque neces- including Barak Obama, who used the
sary for this is very small, so the require- machine to sign a number of laws while
We started by modifying the mechanical ments on the servos are fairly relaxed. visiting France or on vacation in Hawaii.
components to make them suitable for Due to the simple drive shaft mounting The “Inverse Kinematics” inset gives
a kit, and easy to assemble. Then we arrangement for this application we opted an overview of the equations which form
designed an Arduino shield for the addi- for servos with metal gears, which also the basis for the operation of the Sand
tional electronics, and finally we rewrote keeps the mechanical play reasonably Clock, and which were also used to pro-
the original software to make it easier small. duce the software for the project.
to understand and easier to use, and to The sand bed is shaken smooth by two
add more features. All of that together 6-mm vibration motors mounted at a 45° Vibrating sand bed
resulted in the project described here. angle below the sand bed and secured The most difficult part of the project was
with plastic cable clamps. not the dense mathematics described in
A kit with all the parts, including an the inset, but instead the design of the
Arduino Uno and a fully assembled Pantograph mechanism sand bed. We tried out a lot of prototypes
shield, is available in the Elektor Store The key mechanical components of the before arriving at a satisfactory solution.
(see Figure 1). If you have access to a Sand Clock are the two servos (left and The vibration motors are supposed to
laser cutting machine and are not afraid right) and the acrylic arms, which posi- shake the sand, but not the entire clock,
of a bit of SMD soldering, all of the CAD tion the drawing pen. This arrangement so the energy should be confined to the
files and Gerber files are available as is called a pantograph due to its similarity sand bed as much as possible. For this
free downloads [1]. to pantograph drawing tools of a bygone purpose the sand bed is mounted loosely
100k
the course of time. After experimenting DC IN USB
22u 10u
with different configurations and a variety MOD1 SCL
POWER
GND D9/PWM
of the motors is crucial, and they have to
DIGITAL INPUT/OUTPUT
GND D8
+9V
be oriented at a 45° angle to the edge of C1 VIN
SERVO_L
D7 R3
the sandbox base plate (see Figure 2). 100n +5V_1 D6/PWM 220R
1
2
20 AN0 D5/PWM R2
R8 R9 3
VDD AN1 D4 220R
ANALOG INPUT
The type of sand is also important. The IC2 AN2 D3/PWM
4k7
4k7
R1
19 7
VBAT CLKOUT AN3 D2 220R
flow characteristics of sand depend on 2
SDI SDA/CE
4
AN4 D1/TX R5 R6 R7
SERVO_Z
3 1 1
the grain size (from coarse to fine) and B1 SDO SCL AN5 D0/RX
4k7
4k7
4k7
6 5 2
C2 TS IFS
the shape of the sand grains (sharp or 17
INT BBS
18 3
Electronics
The main electronic module of the Sand You can also control the Sand Clock manually
Clock is an Arduino Uno, which provides
enough processing power for this appli-
using commands
cation despite the many equations shown
in the inset. There are also some other
components necessary for powering the as possible, we designed an Arduino the DC/DC converter still have to be sol-
servos, driving the vibration motors and shield for the additional electronics. The dered on the board.
keeping the time correct when the power shield PCB (Figure 4) is mainly populated The clock is powered by a standard
is disconnected (see the schematic dia- with SMDs. To avoid potential soldering switch-mode AC adapter with an output
gram in Figure 3). difficulties, the board in the kit is supplied voltage of 9 to 12 V. The vibration motors
To make building the Sand Clock as easy pre-assembled. Only the connectors and and servos draw a fair amount of current,
Advertisement
Inverse Kinematics
The objective of in- θ2 is thus:
end effector verse kinematics Θ2= α 2− β 2
for the Sand Clock
is to determine the We use the triangle P1-P3-P5 to calculate
angles θ1 and θ2 of angle θ1. The position of P5 (x5,y5) is a
the actuators (the variable which first has to be calculated.
positions of the two The triangle P4-P5-P6 is a rigid body with
servos) for a given constant sides and angles.
pen position (x6,y6).
Since the pivot In order to calculate (x5,y5), we assume
joints have only one that triangle P4-P5-P6 with side L56
degree of freedom rotates about P6 through an angle α5 as
and there are only indicated in the diagram.
two actuators, the First we determine the angle α6:
mathematical equa-
⎛ L 2+ L 2− L 2 ⎞
tions are fairly sim-
α 6= arccos ⎜ 26 46 24
⎟
ple and can be han- ⎝ 2 ⋅ L 26⋅ L 46 ⎠
dled by an Arduino
module based on We already know angle α2. Now we can
a n ATm e g a 3 2 8 p determine angle α5:
microcontroller.
α 5= π + α 2 + α 6− α 564
actuator actuator To simplify the cal-
culations, the left The position of P5 is then given by:
and right servos are
x 5= x 6 + L 56 ⋅ cos(α 5 )
A ‘kinematic chain’ in robotics is a math- assigned the same Y position: y1 = y2.
ematical model of a mechanical system The diagram shows the various positions, y 5= y 6 + L 56 ⋅ sin(α 5 )
consisting of a set of rigid bodies and lengths and angles. Some of them are
joints. The motions of kinetic chains can constant, and others are variable. Now we return to angle θ1. We derive
in turn be modelled using mathematical this angle from α1 and β1. α1 is the
equations. Constant: (x1,y1), (x2,y2), L13, L 24, L35, angle between the X axis and the line
L45, L46, L56, α564 passing through P1 (left servo) and P5:
Forward kinematics means that the con-
⎛ y − y ⎞
figuration of the kinematic chain is cal- Variable: (x5,y5), (x6,y6), L15, L26, L46, α1, α 1= arctan2 ⎜ 5 1 ⎟
culated based on the positions of the β1, θ1, α2, β2, θ2, α5, α6 ⎝ x 5 − x1 ⎠
joints. Inverse kinematics is the oppo-
site. It takes the desired configuration of First we determine the angle θ2. We We use the sides of triangle P1-P3-P5 to
the kinematic chain as the starting point derive this angle from α2 and β2. α2 is calculate angle β1. Length L35 is known.
and calculates the joint positions neces- the angle between the X axis and the We calculate length L15 as follows:
sary to achieve that configuration, usu- line passing through P2 (right servo)
ally with the objective of determining the
position and trajectory of an end effector
and P6 (pen):
L15= ( x 5− x1 )2+ ( y 5− y1 )2
⎛ y − y ⎞
α 2= arctan 2 ⎜ 6 2 ⎟
or manipulator.
⎝ x 6− x 2 ⎠ β1 is then:
Outside the domain of robotics, inverse ⎛ L 2+ L 2− L 2 ⎞
kinematics is also used in 3D animations We use the sides of triangle P2-P4-P6 to β 1= arccos ⎜ 15 13 35
⎟
and computer games. The motions of the calculate angle β2. Length L46 is known. ⎝ 2 ⋅ L15⋅ L13 ⎠
human body and of animals can also be We calculate length L26 as follows:
modelled this way. Finally there is θ1:
2 2
L 26= ( x 6− x 2 ) + ( y 6− y 2 ) Θ1= π − β 1− α 1
When we apply inverse kinematics to the
sand clock, the kinematic chain consists
of four rigid bodies and five pivot joints, Now we can determine β2: These calculations are implemented in
as shown in the accompanying illustra- the sketch in the function pen_calc.
⎛ L 2+ L 2− L 2 ⎞
tion. Two of the five pivot joints have an β 2= arccos ⎜ 26 24 46
⎟
actuator, which in this case is a servo. ⎝ 2 ⋅ L 26⋅ L 24 ⎠
The end effector here is the pen.
so it is not a good idea to use the 5 V 5-V tolerant, so they can simply be con- together with the sketch [2]), as well as
supply voltage from the Arduino board. nected to the I2C interface of the Arduino the clock functions which write the time
The 5-V voltage regulator on the Arduino without any need for level shifting. in the sand.
Uno is a low-drop linear regulator with a
maximum rated load current of 800 mA. Arduino sketch We also made several internal functions
That does not provide much margin, and The sketch for the Sand Clock is designed of the sketch accessible via commands,
due to the low efficiency things get pretty for the Arduino Uno, and it also works so that you can move the pen under man-
warm while the time is being written. with the Elektor Uno R4. The sketch ual control, draw figures in the sand,
With a USB connection between a com- includes all the functions necessary for and switch the vibration motors on and
puter and the clock, there is also a risk calibration of the Sand Clock after assem- off. For this purpose the sketch has two
that the computer’s USB supply voltage bly (described in detail in the assembly modes: autonomous and command. In
will collapse if you forget to plug in the instructions, which can be downloaded autonomous mode the Sand Clock oper-
AC adapter.
For the above reasons, we decided to
provide a separate power supply for the
motors, isolated from the supply for the Component List
Arduino. For this we use a switch-mode Resistors 2 pcs. bolt, M3x6, zinc-plated steel, Pozidrive
R1,R2,R3 = 220Ω, SMD 0805 DIN 7985A
DC/DC converter in the form of a 78xx
R4 = 1.8kΩ, SMD 0805 2 pcs. bolt, M3x8, zinc-plated steel, Pozidrive
replacement with three leads (IC1), which R5–R9 = 4.7kΩ, SMD 0805 DIN 7985A
is connected directly to the input voltage R10 = 100kΩ, SMD 0805 15 pcs. bolt, M3x10, zinc-plated steel,
Pozidrive DIN 7985A
of the Arduino board. It provides an out-
Capacitors 1 pc. bolt M4x30 plastic, Phillips (sharpen end
put voltage of 5 V at 1 A maximum with with pencil sharpener)
C1–C4 = 100nF, SMD 0805 MLCC
an efficiency of over 90%, with an input C5 = 10μF 10V, SMD 1206 MLCC
6 pcs. nut, M2, zinc-plated steel, DIN 934
7 pcs. nut, M3, steel, DIN 934
voltage in the range of approximately 9 C6 = 22μF 16V
3 pcs. locking nut, M3, zinc-plated steel, DIN
to 12 V. 985
Semiconductors
The vibration motors are driven by an 1 pc. nut, M4, polyamide
D1,D2,D3 = S2J-E3 2 pcs. washer, M3, zinc-plated steel, DIN 125A
NPN transistor (T1) under control of T1 = BCX56 4 pcs. washer, M3, plastic, DIN 125A
an Arduino I/O pin. The voltage on the IC1 = SIP3 5V/1A DC/DC converter (Würth 4 pcs. standoff, 3mm high, polyamide, for M3
Elektronik # 173 010 578)
vibration motors is reduced somewhat by 4 pcs. spacer, 25mm, M/F M3, nickel-plated
IC2 = PCF2129A brass (min. 33mm total height, e.g. TME
diodes D1 and D2 in combination with the
TFM-M3X25/DR213)
saturation voltage of the transistor (VCE- Miscellaneous 2 pcs. cable clip, polyamide, Panduit type
). This is necessary because the oper- K1 = set of SIL pinheaders, 0.1’’ pitch (1 pc. CCS25-S10-C
sat
10-pin, 2 pc. 8-pin, 1 pc. 6-pin) 4 pcs. self-adhesive rubber foot
ating voltage of the motors (according to SERVO_Z,SERVO_L,SERVO_R = 3-ppin right- 3 pcs. micro servo, Tower Pro MG90S of MG90
the data sheet) is only 3 V. angled pinheader, 0.1’’ pitch with metal cogs
The control signals for the servos are sup- B1 = CR2032 button cell with holder 2 pcs. vibration motor, round, 6mm diam.,
Arduino UNO R3 or equivalent type VM6ZK273 (JPR Electronics # 450-007)
plied directly by three I/O pins of the
Extruded (XT) PMMA, 3mm, clear, laser-cut
Arduino board. Three connectors are Mechanical parts: Fine-grain white sand (see text)
mounted on the shield for the three ser- 6 pcs. bolt, M2x10, Pozidrive/Phillips Nourishment coloring additive (optional)
6 pcs. bolt, M2.5x8, zinc-plated steel,
vos. Resistors R1, R2 and R3 are there
Pozidrive DIN 7985A A DIY kit including all parts and the SMD-
to protect the Arduino if one of the servo 6 pcs. bolt, M2.5x12, zinc-plated steel, preassembled shield is available through the
cables is accidentally plugged in with the Pozidrive DIN 7985A Elektor Store.
wrong orientation. Resistors R5, R6 and
R7 keep the levels on the data lines to the
servos stable when the Arduino micro-
controller is in sleep mode.
A real-time clock IC is included to main-
tain the correct time, so the clock does
not have to be set again every time it
is powered up. For this we chose an
PCF2129A (IC2), which has a built-in
crystal. This IC is inexpensive and very
precise, with internal temperature com-
pensation and an accuracy of 3 ppm. A
CR2032 button cell serves as a backup
battery with a lifetime of about ten years.
The RTC IC is not suitable for a 5-V sup-
ply voltage, but fortunately the Arduino
Figure 4. The shield PCB is mainly populated with SMDs, which are pre-assembled on the
board provides a 3.3-V supply voltage on
board in the kit.
the shield connectors. Equally fortunate
is the fact that the I2C pins of the IC are
ates independently. In command mode positions of the left and right servos, connectors. Then connect the AC adapter
the sketch executes the commands you expressed in radians. This calculation is to the Arduino board and connect the
send to the sand clock. performed by the function pen_calc and USB port of the Arduino to a computer
can either succeed or fail. The calculation on which the Arduino IDE is installed.
After uploading the sketch to the Arduino, fails when the stated coordinates cannot Compile the sketch [2] and load it into
you can use the serial monitor of the be reached by the pen. If the calculation the Arduino.
Arduino IDE to send commands to the succeeds, the resulting servo positions
sand clock. Select 9600 baud and some- are converted from radians to PWM pulse After the sketch is loaded and the Arduino
thing other than “No line ending” in the widths for the left and right servos. is reset, the servos are automatically
adjacent selection box. The commands moved to their midpoint positions (pulse
consist of letters (e.g. svd), optionally The sketch uses floating point operations width 1500 ms). Disconnect the Arduino
followed by one or more parameters to calculate the inverse kinematic func- from the computer and disconnect power
(for example, ps -20.55 +55.8). Press tions. The floating-point variables have to the Arduino. Then remove the shield
the Enter key to send a command. The a width of 32 bits. The standard used and disconnect the servos so they can
Arduino returns a response for most of here is IEEE 754. All of these properties be mounted on the clock. If you have a
the commands. All available commands are determined by the AVR GCC compiler servo tester, you can use it instead to
are listed at the start of the sketch. For used to compile the sketch. set the servos to the midpoint position.
example, you can use the command pa All positions and distances are expressed Now it’s time to start the mechanical
to draw an arc. in millimeters. These values correspond assembly. Attach four rubber feet to
to the real world. The sketch includes the bottom of the base plate and mount
Now let’s get back to the original sub- definitions of the physical dimensions of the four supports for the sandbox. Next
ject. During the assembly process you run the mechanical parts of the clock. Angles assemble the base frame with the lift
through the calibration procedure. This are expressed in radians. servo, and then mount this assembly
procedure requires you to enter a series The diagram in Figure 5 shows the posi- along with the Arduino and the shield
of commands, in some cases with accom- tions (in millimeters) of the left and right on the base plate.
panying parameters. Once all the settings servos with respect to the sand bed, as
have been made (see the command sed), defined in the sketch. Now it’s time for the left and right servos
they are written to the EEPROM (com- of the pantograph mechanism. Connect all
mand sew). During start-up, the sketch During drawing in the sand the pen is the servos to the shield again and assem-
checks the validity of the EEPROM con- moved in steps with a maximum step ble the arms and pen of the pantograph.
tent. If the EEPROM content is valid, it size of 0.25 mm. Despite the many cal- When you assemble the arms of the pan-
determines the start-up mode of the culations, the processor is more than fast tograph, thread the screws directly into
clock. In most cases you will probably enough, so the code waits 5 ms between the acrylic plastic. That works quite well
set it to autonomous mode. If the content successive changes in pen position during thanks to the previously mentioned ther-
is invalid, the clock starts up in command drawing to prevent the pen from being moplastic properties of this material:
mode, the same as the first time after pushed through the sand too quickly. the heat generated by friction when the
you upload the sketch. You can interrupt autonomous mode at screws are threaded in effectively causes
Note that the EEPROM of the microcon- any time by sending an end of line (EOL) the plastic to flow around the threads.
troller is not cleared when the sketch is character over the serial interface. Press This mounting technique minimizes the
uploaded. This means that you do not the Enter button in the serial monitor mechanical play of the arms. However,
have to enter the settings again (and to switch the sketch to command mode. the mounting hole for the pen does have
save them with the sew command) every Bear in mind that the transition to com- to be threaded. If you cut your own parts
time you upload the sketch. If necessary, mand mode may take a while when the using a laser cutting machine, you have
you can use the command sec to erase clock is busy writing in the sand. You can to tap that hole with an M4 thread tap.
the EEPROM. return to autonomous mode by sending Mount the sandbox, but leave the vibra-
the command ma. tion motors aside for the time being. Now
In autonomous mode the Sand Clock peri- it’s time for the calibration. Connect an AC
odically draws the current time in the Construction adapter to the Arduino board and plug it
sand. This drawing action consists of a In this article we only provide a brief in. Then connect the Arduino board to the
number of pen motions in the horizontal description of how to build the Sand computer through a USB cable. Now you
plane, as well as up and down motion. Clock. If you want to build the project, can use the serial monitor of the Arduino
The sketch uses the current X/Y pen posi- please consult the assembly instructions IDE to send commands that set the servo
tion as the starting point for all types of [2] for a more extensive description with positions. To calibrate the servos, you
motion: drawing a straight line, tracing many detailed photos. have to determine the positions where
an arc, drawing a character, or reposi- Start by mounting the connectors and the they are exactly vertical and horizontal.
tioning the pen. DC/DC converter on the Arduino shield These positions are then stored in the
board with the pre-assembled SMD com- EEPROM. The next task is to calibrate the
The function pen_set moves the pen to ponents. Then plug the shield onto the lift servo. Put the sandbox in place and
the stated X/Y position. First the coor- Arduino board and connect the servos. position the lift servo so that the tip of
dinates are converted to the angular Pay attention to the orientation of the the pen hovers a few millimeters above
134
114
74
54
10
(0;0)
30
( 0 ; -30 )
Figure 5. The positions (in millimeters) of the left and right servos relative Figure 6. The structure of the Sand Clock is clearly visible here.
to the sand bed, as defined in the sketch.
the bottom of the box, regardless of the X/Y position. You can
also adjust the distance by turning the pen higher or lower in
the mount. Once the pen is in the right position, tighten the
plastic M4 nut to hold it in place. Next you have to set the mid- Advertisement
dle position and the highest position of the lift servo. These are
not critical, and usually you can simply take the values from
the assembly instructions.
USB Add USB to your next project.
It's easier than you might think!
Write the settings to the EEPROM and then set the clock to the
right time. Now you can do a dry run with the clock (without DLP-USB1232H: USB 2.0 UART/FIFO
sand) to check its operation. If that all goes well, you can set
the clock to autonomous mode so that it automatically writes
HIGH-SPEED
the time at fixed intervals, and then disconnect it from the 480Mb/s
computer. On
Multipurpose: 7 interfaces ly $
Now disconnect the Arduino power source and mount the vibra- 28.
95!
tion motors underneath the sandbox. Twist the matching leads Royalty-free, robust USB drivers
of the two motor cables together and solder the ends to the No in-depth knowledge of USB required
solder pads on the shield. Be careful not to touch the acrylic
Standard 18-pin DIP interface; 0.6x1.26-inch footprint
parts with the hot soldering iron. Then place the sandbox on
the supports, taking care that the vibration motors do not touch
any leads and are free to turn.
DLP-IO8-G DLP-IOR4
Finally, pour the sand into the sandbox. That completes the 4-Channel Relay Cable
8-Channel Data Acquisition
construction of the sand clock. DLP-TH1b
Temp/Humidity Cable
Only
If you wish, you can give the sand a special tint. To do so, put $29.95! DLP-RFID1
the sand in a tin with a lid and add a few drops of food color. HF RFID Reader/Writer
Then shake the closed tin until the sand has a uniform color. DLP-FPGA
8 I/Os: Digital I/O USB-to-Xilinx FPGA Module
Repeat if necessary until you obtain the desired color. Let the
Analog In
sand dry completely before pouring it into the sandbox.
Temperature
(160065-I)
USB Port Powered
Single-Byte Commands
Web Links
[1] www.elektormagazine.com/160065
www.dlpdesign.com
[2] www.elektor.com/sandclock-160065-71
This simple electronic dice was designed specifically for beginners in electronics. The board
has a spacious layout, with only a handful of components, which are all through-hole mounted.
There is no microcontroller in this circuit; all the hard work is carried out by
two CMOS ICs.
The aim of the design published here was itor C1. With the values (to limit the current
to make a simple circuit with LEDs, which used here, the frequency is about through the LEDs)
didn’t have any ‘difficult’ components, 5 kHz. This signal then goes to the clock and Schottky diodes in
and which was easy to construct. A bat- input (pin 14) of decade counter IC1, a certain configuration to
tery holder with a CR2032 button cell which is a 74HC4017. By connecting the the six outputs (Q1-Q5 and CO) of IC1.
is mounted on the board, which makes Q6 output (pin 5) to the Reset input (pin The diodes prevent short circuits between
the circuit easy to carry around. This 15), the counter can only count from 1 an active output and any non-active out-
configuration also makes it very easy to to 6, when it will receive a reset pulse. puts that drive the same LEDs. Since the
replace the battery. This is a very neat This is exactly what we need for our dice. carry-out output of the IC (pin 12) is high
kit to make people interested in elec- The pulses at the clock input are only after a reset and when outputs Q0 to Q4
tronics, even if they’ve never soldered counted by IC1 when its enable input is are active, the diode matrix produces the
before. With a bit of help, anybody could low. When a pushbutton and a pull-up following numbers: pin 2 high: 3, pin 4
build this! resistor are connected to this pin, we high: 4, pin 7 high: 5, pin 10 high: 6,
can make IC2 count for as long as S1 pin 1 high: 1, pin 12 high: 2.
The circuit is pressed. When the pushbutton is
The complete circuit is shown in Figure 1. released, one of the Q1-Q5 and CO out- Since the supply voltage to the circuit is
This consists of an oscillator (IC2) and a puts will remain at a logic high level. so low (3 V), the diodes used are Schottky
decade counter (IC1), which has 7 LEDs Because the 555 operates at such a high types in order to keep the voltage drop
connected to its outputs. frequency, it’s not possible to manipulate across the diodes as small as possible. A
The well-known 555 timer was selected the selected output with S1, so the result lot of experimenting with the values of the
for IC1 It is configured here as an astable is completely random! series resistors took place in the proto-
multivibrator by connecting pins 2 and The seven high-efficiency LEDs (LED1- type, because the outputs of a 74HC4017
6 (Threshold and Trigger) together. The LED7) are of course arranged in the same can only supply a small current at that
oscillator frequency is determined by the pattern as that found on a real dice. They supply voltage, and the output voltage
values of resistors R1 and R2, and capac- have been connected via series resistors drops at greater currents. The values of
10k
10k
D6
A 3 V lithium button cell has been used 16
VCC 3
to power the circuit. It’s been mounted 4 8
Q0 D2 D1...D6 = BAT85
2
Q1
in a holder on the board to make it easy 7 RES VCC
IC1 Q2
4
DIS D1
to replace. The dice can be turned on and R1
IC2 Q3
7
3 14 10
off with the help of slide switch S2. Since OUT CLK Q4
10k
D3
6 1
THR Q5
the current through the LEDs is only sev- 2 TR TLC555 74HC4017 5
BAT1 Q6
CV GND 13 6
eral milliamps, a button cell should last 5 1
ENA Q7
9
Q8
several hours. 15 11
RST Q9
12
C1 S1 CO
GND
Construction 8
R5 R6 R8 R4 R7 R9 R10
10n
The printed circuit board shown in Fig-
100R
100R
220R
100R
220R
10R
10R
ure 2 has a spacious layout, with slightly
LED1 LED2
larger tracks and pads than usual, to
make it easier to construct for people
with less experience in soldering. For the
enthusiast, an attractively priced kit con- LED3 LED4 LED5
sisting of the board and all the compo-
nents can be obtained from the Elektor
shop.
The construction of the dice isn’t difficult, LED6 LED7
Figure 1. Display on the Elektor Extension Shield: 7001.040 kHz, adjustable Figure 2. 198 kHz, set up using the PC.
in 20 Hz steps.
using the PC or with the controls on the Shield. But we can +5V
also do this without involving a PC at all. The simplest way is
to use the SDR Shield as a direct mixer.
220k
1k
Direct mixer
A direct mixer transposes an RF signal down to the audio
100n ½ 100R
range in one step. Of course the Shield is actually intended LM358
47u
for an IF of 12 kHz, but the IF stages provide sufficiently wide 16V
+3V3
1k
4mH7
22n
22u Ge
I 10k 220k
16V 1n
16 kHz
Q
1n
BC547B 4mH7
22n 1n
600Ω
GND
low-impedance load. This problem is mitigated by providing It does, with some limitations. You must set the VFO on the
the 1-kΩ resistor from the output to the supply rail, because zero-beat position, i.e. as precisely as possible on the exact
at smaller modulation levels only the lower part of the push- carrier frequency of the transmitter. Then you can hear the
pull output is active. In series with the headphones we also modulation clearly, admittedly with an additional beat over-
have a 100-Ω resistor. On the one hand this reduces the work laid at most times. Phase-locked tuning is not possible, you
of the op-amp and on the other it eliminates any risk of dam- see. Nevertheless, receiving AM stations is certainly feasible.
aging your hearing. Limiting comes into play for the amplifier However, it will work a lot better with the AM IQ demodulator
in time to ensure that the maximum power to the headphones to be described next.
remains within bounds at all times. Incidentally, the LM358 can
be driven almost down to GND level but not quite all the way The IQ detector
up to the power rail. Consequently the open circuit voltage is Under normal circumstances the SDR software processes a
about a third of the operating voltage. 12-kHz IQ signal. The question now arises whether you can-
The amplifier can raise the signal level by up to 40 dB. This is not also ‘solidify’ signal processing into hardware format. Our
more than you need in most situations, so normally the volume goal is now to create an AM demodulator for IQ signals. This
control is throttled well back. Receiving CW stations is truly turns out to be simpler than expected.
a pleasure with this setup. Even SSB comes in well, because The first attempt (Figures 5 and 6) was based on an IF filter
the frequency can be set so conveniently and precisely. You with two fixed inductances. An operating frequency of 16 kHz
can listen for hours like this. was determined more or less by chance, because 22 nF capac-
itors were available to hand. With a coupling capacitor of 1 nF
But what’s it like when listening to AM? Actually this is not the a good band filter with suitable bandwidth was the result.
right job for a direct mixer. But does it work nevertheless? The two signals I and Q need to be mixed together with a
+9V
470R
1k
4mH7
22n
22u Si 100u
I 10k 220k 22k 100k
16V 1n 22n 16V
16 kHz
Q
1n
3k3
GND
Advertisement
mouser.com
The Newest Products for Your Newest Designs®
The second task is signal filtering, which is what the band filter
is for. This always worked fine in old tube radios and still does
here, only at a lower frequency. After the filter we have the AM
demodulator, in the form of a diode detector. To underscore
Over 4 Million
the historical continuity an OA61 more than 50 years old is products from over
600 manufacturers.
employed (you can also use a 1N60A or something similar of
course). Beyond this come some high-impedance headphones
or low-impedance ‘phones with a matching transformer. Already
we can hear something. The sound is very pleasant and easy on
the ear, which is probably thanks to the band filter in the main.
The first attempt worked well only for the strongest signals and
even then it produced no great volume level. For that reason
we added a further IF amplifier stage (Figure 7). Now the AM
rectifier has some bias, which is why a silicon diode also works
here. The result is good sensitivity and plenty of volume using
32-ohm headphones. Naturally the AM detector is also suitable
for connecting to a loudspeaker amplifier.
[1] www.elektormagazine.com/140009
[2] www.elektormagazine.com/160165
Photo: Ortofon
By Ton Giesberts (Elektor Labs) ular amongst audio enthusiasts. Many steep price due to the high-quality com-
of them have taken the effort build this ponents contained in the kit.
preamp, which offers truly superior per- However, a lot of vinyl fans were holding
The SUPRA 2.0 MM/MD phono preampli- formance. There were even quite a few back and hoping for the option of con-
fier [1] has proven to be especially pop- purchasers for the parts kit, despite its necting a moving-coil (MC) cartridge to
the SUPRA 2.0 preamp. MC cartridges
are generally better than their MM or MD
Specifications & Measurements counterparts, but they require a special
preamplifier with additional gain because
Measurements made with an input signal level of 0.3 mV at 1 kHz
their output signal level is about 0.2 to
(source impedance 5 Ω).
0.5 mV. The original SUPRA was actually
Values measured with a laboratory power supply and supply voltages of ±14 V.
designed for MC cartridges, but for the
SUPRA 2.0 we decided to initially focus
• Input impedance: 100 Ω
on MM/MD cartridges and leave MC for a
• Output level with 0.3 mV input: 270 mV
bit later. Since then we have modified a
• SNR
SUPRA 2.0 in the lab and increased the
Linear: >73 dB (BW = 22 Hz to 22 kHz)
gain, and of course we checked it out on
A weighted: >79 dB (BW = 22 Hz to 22 kHz)
the test bench.
• THD+N (1 kHz): <0.02% (only noise, BW = 80 kHz)
• THD at 1 kHz: <0.0007% (from averaged FFT measurement)
The changes
• THD at 10 kHz: <0.0002% (from averaged FFT measurement)
As previously mentioned, the changes
• Deviation from RIAA curve: <0.1 dB (50 Hz to 10 kHz)
are fairly simple. If you already have
<1 dB (20 Hz)
a fully assembled SUPRA 2.0, you only
<0.15 dB (20 kHz)
need to change nine resistors in each
V+_1
1
V+_1
3 8
R16
JP1 6
P1 IC1 6k81 C4 C7 C10 C13 C20
2
1M R3 R4 5 7 100n 7 100n 7 100n 7 100n 8 100n
R5
2k2
IC1 IC2 IC3 IC4 IC5
10M
10R
4 C5 4 C8 4 C11 4 C14 4 C21
R6 C3
10R
V-_1 470p
100n 100n 100n 100n 100n
R2 1
C2
3 8
10M
MC 6
R17
V-_1 Line
IC2 6k81
220n 2
K1 R7 5 6 K3
R8 R27
1 3 7 1
2k2 C19 IC5B 47R
10R
1 5
2 R9 C6 IC5A 2
2
10R 2µ2
R1
C1 C1' 470p R26
1 C15 C16 R24 R25
100R
62k 4k7
7k5
3 8
100p
* IC3
6
R18
6k81
22n 22n C17 C18
1k6
R12 C9 IC1, IC2, IC3, IC4 = LT1028
10R
R20 IC5 = LM833
470p
1
110R
3 8
R19
6
IC4 6k81
2
R13 5
R14
2k2
10R
R15 C12
10R
470p
Figure 1. Schematic diagram of one channel of the SUPRA 2.0 with altered resistor values for use with MC cartridges.
channel. The portion of the schematic harm in leaving them where they are. Of Another reason for reducing the nominal
where changes are necessary is shown course, if you are building the SUPRA 2.0 output signal level compared to the MM/
in Figure 1. from scratch you can simply omit these MD version of the SUPRA 2.0 (468 mV
Most MC cartridges are specified for a capacitors. with a 2.5 mV input signal) is to keep
termination impedance of about 100 Ω. the bandwidth of the four parallel opa-
To achieve that, the resistors which deter- Next, all sixteen 47 Ω resistors in the neg- mps large enough despite the fairly high
mine the input impedance of the pream- ative feedback networks of IC1–IC4 and amplification factor of the MC version.
plifier (R1 and R30) must be replaced by IC6–IC9 (R4, R6, R7, R9, R10, R12, R13, The open-loop bandwidth of the LT1028
100-Ω resistors. However, if your car- R15, R33, R35, R36, R38, R39, R41, R42, opamps is 70 MHz. With an amplification
tridge is specified for a different input R44) must be replaced by 10-Ω resistors. factor of 221 the bandwidth is a bit more
impedance (for example, 47 Ω), then you That puts the overall amplification factor than 300 kHz. The 470 pF capacitor in
should use that value for R1 and R30. of the preamplifier at 900, with the four the feedback network limits the band-
opamps wired in parallel accounting for width of the input stage to 150 kHz. The
Capacitors C1 and C26 determine the the lion’s share (amplification factor 221). resulting effective bandwidth is approx-
input capacitance of each channel of To determine the necessary amplification imately 115 kHz.
the preamplifier. With MM and MD car- factor, we took the average output signal
tridges you can influence the high-fre- level of 26 MC cartridges, which yielded a If we increased the gain of the input stage
quency characteristic with this capaci- signal level of slightly more than 0.3 mV. even more, there would be a noticeable
tance, but with MC cartridges it has little As the line input of most audio ampli- effect on the signal amplitude at 20 kHz.
effect because their internal resistance fiers has a sensitivity of 100 or 200 mV, If more gain is needed, it would be better
is only a few ohms and their inductance we thought it prudent to choose a level to increase the gain of the second stage.
is negligible due to the small number that is not much higher, namely 250 mV, However, adjusting the gain of that stage
of turns in the coil. You can remove C1 to avoid making the amplification factor is not straightforward because it incor-
and C26 from the board, but there is no greater than necessary. porates part of the RIAA correction. It
• R4,R6,R7,R9,R10,R12,R13,R15,
R33,R35,R36,R38,R39,R41,R42,
R44 = 10 Ω / 1%
would therefore be necessary to change of the four opamps to be nulled if nec- leave them in place.
all the resistors in that stage. essary. Due to the low input impedance, For the MC version of the SUPRA 2.0
these networks (P1/R2/R3/C2/JP1 and we opted for the type A version of the
There are also several compensation P2/R31/R32/C27/JP2 are not necessary LT1028. It costs a lot more than the stan-
circuits on the SUPRA 2.0 PCB for each in the MC version. However, if they are dard version (which is already expen-
channel to allow the input bias currents already fitted on the PCB you can simply sive), but it has lower input offset and
A -2
20 50 100 200 500 1k 2k 5k 10k 20k
result when you consider that all of the
Hz
is 247.2 nV/√Hz. The total noise at
components responsible for the RIAA
the summing junction is half this
correction have a tolerance of 1%.
value, which makes it 123.6 nV/√Hz.
Audio Precision
+0
This figure does not take the current
-10
noise into account.
-20
-30
Chart B shows an FFT plot with a
-40
1-kHz input signal. The displayed
-50 The noise level of the MC input
-60 spectrum runs from 10 Hz to 130 kHz,
d
B -70 stage is 3.7 times that of the MD
r
with the fundamental frequency at
input stage (with the input shorted).
-80
A
-90
1 kHz suppressed. To give a clearer
-100
However, the amplification factor is
impression, the curve is the result
-110
-120
4.62 times greater in the MC version.
-130
of averaging sixteen measurements.
-140 If we recalculate the measured
B -150
No harmonics are visible on this plot,
10 20 50 100 200 500 1k
Hz
2k 5k 10k 20k 50k 100k
noise of the MD stage with the input
from which it can be concluded that
shorted (88 dB) for a 270-mV output
the total harmonic distortion is less
signal level, the signal to noise ratio
than 0.0007%.
is 4.84 dB lower at 83.15 dB. The
Audio Precision
+0 calculated difference in noise level
-10
-110
of the SUPRA 2.0 MC version will be
level of ‑114 dB, corresponding to
-120
-130
about 72 dB. That is very close to
-140
0.0002% THD.
C -150
10 20 50 100 200 500 1k 2k 5k 10k 20k 50k 100k
the actual measured value (see the
Hz
specifications).
Connect Objects
with Genuino 101
Make any device talk to your mobile
By Clemens Valens (Elektor Labs)
The Internet of Things (IoT) and Connected Objects have been on everybody’s lips
for a couple of years now; industry analysts predict billions of connected devices
in the near future and the market will be worth tens of billions of dollars.
Impressive numbers, big money, wouldn’t it be nice to get a share of that? It
would, so here’s how to jump the bandwagon: connect an object.
This article sets out to teach connecting ers, we prefer an easy approach, and a Prerequisites
the ‘101’ to a mobile, BLE-capable device good tool for us kind of people is Evoth- • Genuino 101;
running Android 4.4 (KitKat) or higher. ings. The idea behind this tool is sim- • BME280 shield;
Officially BLE support is available since ple: provide a basic App framework to • PC (Windows, Linux or OSX) with at
Android 4.3, but because its reliability which the developer can add his own code least one free USB port, a plain text
leaves a lot to desire, it’s best to stay using JavaScript, HTML and CSS, stan- editor and, optionally, an image edi-
away from it. dard, well-known webpage development tor (I used Windows 7 Family, SP1,
languages. 64-bit);
First we will add an extension board (a • Mobile device, BLE capable, run-
Shield in Arduinospeak) with a BME280 Actually, designing an App in Evothings ning Android 4.4 or higher (I used a
sensor to capture temperature, air pres- amounts to creating a tiny website and Samsung Galaxy J5 running Android
sure and relative humidity [1]. Further- then displaying it in the framework, the 5.1.1);
more, we are going to capture data from Viewer, running on the mobile device. • Internet access for PC and mobile
the 101’s inertial measurement unit Because in Evothings the App is nothing device.
(IMU, the gyro-accelerometer combo, more than a simple website, it can be
that is) and display it in pleasant graphs changed on the fly without lengthy compi- Assemble the hardware
on the mobile device [2], and you will lation steps. All you do is write and mod- Putting together the hardware is quite
be able to read the 101’s analog inputs ify code; as soon as you save it, Evoth- simple as it consists of plugging the
and control its digital outputs from the ings will update its viewer. Instant result BME280 shield on the 101 (Figure 2).
mobile device. on your mobile — isn’t that neat? No If you want to get fancy, you can add your
risk of crashing your mobile either, the own extension board with some resistors,
In order to connect the Genuino 101 to viewer catches your mistakes. Once you LEDs and trimmers to play with the digi-
an Android device over BLE an App is are completely satisfied with your app, tal and analog I/O functionality, but this
required. Since we design the connected you can create a ‘real’ App for it and dis- is optional.
object to our own specifications, it is also tribute it through the Google Play Store.
our job to create this App. Several ways If you do, take care to avoid pin conflicts
lead to Android Apps, but some are easier Sounds good, doesn’t it? So how do we with the BME280 shield. Digital pins 0 to
than others. Being newbie App develop- go about it? 6 and analog inputs 0 to 3 are free.
Set up Evothings
Evothings Studio is also called Evothings
Workbench — just launch the executable
Figure 2. Building our whatever its name is. Open the New tab
Connected Object did not require and enter “Genuino-101-Explorer” as App
any soldering. folder name. Before clicking Create, make
a note of the Parent folder where the App
will be saved. Close Evothings Workbench.
With a file manager navigate to the
Install the software • PC: Download and install Arduino App folder you just created and delete
Softwarewise there is rather a lot to install IDE (www.arduino.cc, I used version everything inside. From [1] download the
and set up before you can create and pub- 1.6.10) Genuino 101 Explorer Evothings project
lish your App in the Google Play store, • PC: Download and install Evothings and unpack it in this folder. You should
but we will start unpretentiously: Studio (https://evothings.com/, I now have some folders and files includ-
used version 2.0.0) ing index.htm and app.js. Those two are
• Mobile: Download and install Evoth- the important ones. Relaunch Evothings
ings Viewer (Google Play Store, I Workbench and open the MyApps tab.
used App version 1.4.1) You should see an entry labeled: Arduino/
Genuino 101 Explorer.
Genuino 101 On your mobile launch the Evothings
Do not connect the board to the PC Viewer App (Figure 4). It will open and
yet, you must install some drivers first. request a connect key. This key is gener-
Launch the Arduino IDE and open the ated by the Evothings Workbench: click
Boards Manager (Tools ¨ Boards ¨ the Connect tab and then the Get key.
Boards Manager…). In the top-left cor- Enter the key in the viewer and tap Con-
ner choose Arduino Certified, this will give nect. For this to work, both the PC and the
you a shorter list in which you can eas- mobile must be connected to the Internet.
ily find the Intel Curie Boards. Click on When the connection is successful the
it, and then click on the Install button. viewer will tell you what to do next. What
Depending on your Internet connection it means to say is that you have to open
the installation may take a while. When the MyApps tab in the workbench and
done, close the Manager, then go back click on the Run button of the Arduino/
to the Tools ¨ Boards menu and scroll Genuino 101 Explorer app. Do this and
down through the list until you find the observe the Loading icon appear in the
Arduino/Genuino 101. Select it. viewer, followed by the App opening a
Connect the board to the PC. A serial port few seconds later.
should become available; select it in the If the Internet connection on both your
Arduino IDE (Tools à Port). mobile and PC is good and stable, the
If you run into trouble with the installa- connection between the viewer and the
tion of the 101, please consult the online workbench will persist. However, if you
installation guide at https://www.arduino. are seeing bizarre loading errors you may
cc/en/Guide/Arduino101. try to reconnect the two with a new key.
Download the BME280 sketch from [1].
The QR code on the back of the BME280 Try it out
Figure 3. Sketch uploaded successfully and board shield contains the URL (http://bit.ly/2aN- If you had disconnected the Genuino 101
waiting for a Bluetooth connection! NDq7) that will get you there. Load the from the PC, now is the time to recon-
Figure 4. Evothings Workbench on the PC and its Figure 5. A few screenshots from the App showing the different data views.
Viewer on the mobile device.
nect it (or power it from a supply). If it Regarding the Sketch new unique ID for it. You do this by gen-
was connected already, press the Reset Now that you have a working environ- erating a Universal Unique Identifier or
button (not the Master Reset button). ment it is time to investigate the different UUID (with an online UUID generator, for
Give it ten seconds or so to get going, components that make up the system. instance). Then, for each kind of informa-
use the Serial Monitor to be sure that it is Let’s start with the Genuino 101 sketch. tion that must be received or sent, a char-
waiting for a connection, then tap the red This sketch is based on the CurieBLE and acteristic must be added to the service
Connect button in the Evothings viewer CurieIMU examples (Arduino IDE à File as an attribute, each characteristic with
on your mobile. à Examples) to which I have added the its own unique ID. Characteristics can be
BME280 driver. In this article we will con- read-only, write-only or read-write and
If Bluetooth was not yet activated on your centrate on the BLE side of things, we they may generate notifications.
mobile, it will ask you for authorization to take the hardware interfacing for granted. In theory a characteristic can convey up
activate it now. Accept this and observe The basic idea is that BLE uses services to 512 bytes, but the Genuino 101 BLE
the status messages that appear below that are identified by unique IDs. A num- library limits this to 20. Our application
the connect button. If all goes well, the ber of such services are defined by the produces three 4-byte floating point val-
button turns green after a few seconds. Bluetooth SIG (www.bluetooth.com), but ues for the accelerometer (i.e. 12 bytes
Tap the menu button in the upper-right since our combined IMU weather service in total), the same for the gyro and for
corner and select a data view (Figure 5). is a not existing one, we must create a the BME280; the analogue data fits in
In the CLI, cd into the project folder you somewhere for future reference. Then run the same as in the viewer (but much big-
just created: “cd [my_project]” (again, one line command, be careful with ger). If not, try to find the reason and
Delete everything inside the subfolder the double dashes): fix it.
‘www’, but do not delete this subfolder. A final word on BLE. Handling a BLE con-
Copy your Evothings project into the cordova build android --release -- nection properly is a bit tricky as it is
folder ‘www’, i.e. all the files and subfold- --keystore=”[Path]\[Name].keystore” almost impossible to completely exit an
ers that accompany app.js and index.htm. --storePassword=[Password] App. Android keeps it running in the back-
In the CLI, enter the command “cordova --alias=[Alias] ground where it may remain (partly) con-
plugin add cordova-plugin-ble” to add nected. To get out of this kind of loopholes
the BLE library to your project. Repeat Where [Name] and [Alias] are the same kill the App in the mobile’s application
this for any other plugin that you may as before, [Path] is the path to the new manager and, just to be sure, restart the
require. keystore file, and [Password] the one connected object.
In the CLI, enter the command “cordova you were asked by keytool to create.
platform add android ”. For IOS use A tiny pop-up window will ask you for Conclusion
“cordova platform add ios”. You can your password once more, enter it and This article showed how to connect a
add more than one platform. click OK. The result is an .APK file named Genuino 101 board to a Bluetooth Low
“android-release”. Energy (BLE) capable (mobile) device like
Now you’re all set to build the project If you haven’t one already open a Google a smartphone or tablet by using open
from the CLI with these commands: Play Store publisher account (one-time source and free tools only. The board was
$25 fee), upload the APK file, go through extended with a BME280 shield to capture
cordova build android the forms, publish, and you are in busi- temperature, air pressure and relative
cordova build ios (not on Windows) ness (Figure 6)! humidity data. After defining a custom
BLE service and some custom characteris-
Normally the build should succeed with- Pitfalls tics any kind of data could be exchanged
out warnings and errors and the result Your Android App may (will?) not work between the two connected devices. This
can be found in: platforms/android/build/ as expected from what you saw in the way typical IoT data like accelerometer,
outputs/apk. To test it on your mobile viewer. The most likely reason is that gyro and weather information was trans-
device you have to copy the APK file on you did not fix all the problems that were ferred to the mobile device. A user inter-
it and install it through the mobile’s file silently handled by the Evothings viewer. face (UI) running on the mobile device as
manager. This requires your device to To find out what’s wrong, use the JavaS- a native App allowed displaying the data
allow Unknown Sources (in the security cript console in the Evothings workbench, and user interaction, and provided the
settings). on the Tools tab, and run your App in the Internet capabilities needed for transfer-
To publish your App in the Google Play viewer. Everything that’s Unreferenced ring data to and from the cloud. Finally,
Store you must recompile it in Release and Unhandled etc. must be fixed. we published the App in the Google Play
mode and sign it. For this it is necessary Keep in mind that timeouts may be too Store for our future users to enjoy.
to first create a key (one line command): short for real-life situations. Also keep in (160109-2)
mind that things work differently when
keytool -genkey -v -keystore the mobile is connected to the object. The
Web Links
[Name].keystore -alias [Alias] Bluetooth stack may be blocking some-
thing. Maybe you should close the con- [1] www.elektormagazine.com/labs/
-keyalg RSA -keysize 2048 -validity
nection first before you can do what you bme280-evaluation-board-160109-2
10000
want to do? [2] www.hackster.io/gov/
Where [Name] and [Alias] are for you What if your App doesn’t look as imu-to-you-ae53e1
to choose. Fill in the requested infor- expected? Open the file index.htm in a
mation and make sure to write it down browser on your computer, it should look
BrainBox Arduino
A ‘tough’ Arduino with screw terminals
Although the BrainBox ardo, the BBA also has four LEDs, These extra features make it possible to
Arduino was originally designed of which two are user programma- use this board in a range of projects,
for use in the educational sector, the ble. The differences are mainly due to without the need for spaghetti circuits
board is so versatile that it lends itself the extra features of the BBA, compared on breadboards or extra Arduino shields.
for use in many other electronics pro- to the standard Arduino boards:
jects. Anybody can program this BrainBox A buzzer with a wide frequency response. Circuit diagram
Arduino (shortened to BBA for the rest This is ideal for trying out all those ring The complete circuit diagram for the BBA
of this article) in next to no time, using tones you’ve created. is shown in Figure 1. At first sight this
their preferred programming language, appears rather complex. In view of the
since the example programs have all been A double H-bridge with four power out- educational background of the BrainBox
developed for five different development puts, which can source up to 600 mA per Arduino, it would be better if beginners
environments. pin. You can use this to directly drive 4 looked at the connection diagram in Fig-
The BBA can be obtained fully assembled, DC motors in half-bridge mode, or two DC ure 3, which clearly shows all the con-
complete with a programmed bootloader, motors in full-bridge mode. These power nections on the board with their name,
from the Elektor Store, which means you outputs can also be used to drive power as well as the functions of the main com-
don’t need any soldering experience to LEDs, to generate heat using power resis- ponents on the board.
get started with this board. Furthermore, tors or to drive stepper motors, to give a
there is also an educational kit available few examples. The user can select one of For those of you who would like to know
that contains all the hardware, software the following power sources for the four more about the ‘real’ circuit, we’ll take
and courseware to build the robot buggy power outputs, using a set of jumpers: a look at the components shown in the
shown in the inset, and to control it with 5 V, mains adapter, battery, or an exter- schematic. At the heart of the BBA is
a dedicated app. nal supply. The voltage to the power out- an Atmega32U4. This low-power 8-bit
puts must be between 4.5 V and 36 V. RISC-based microcontroller has 32 KB
Extras The power source for the processor is of flash memory, a 2.5 KB SRAM and a
The BBA is built around a powerful Leon- selected via a jumper from one of the 1 KB EEPROM. It has a built-in USB 2.0
ardo processor, the ATmega32U4, which following: USB, mains adapter or battery. full-speed interface, a 12-channel 10-bit
runs at 16 MHz. This processor can be Two connectors for servo motors. A/D converter and a JTAG interface for
programmed directly via the USB port. Extra connectors for an HC06 Bluetooth on-chip debugging. The maximum clock
Just as with the standard Arduino Leon- module, RS232 and I2C. frequency is 16 MHz, which is the speed of
10k
3 2 1 3 2 1 3 2 1 3 2 1 3 2 1 3 2 1
22u 100n
+5V
CONN4
A5
A4
A3
A2
A1
A0
1
VBUS
2 R3 D–
D– 22R
3 R4 D+
HWB
AREF
UCAP
VUSB
A5
A4
A3
A2
A1
A0
RESET
D+ 22R
4 V1 V2
R10 VIN +5V
GND C13 C14
10k
1 2 3 4 5 6 1 2 3 4 6 7 8
USB-B 100n 100n
V V
CONN17 CONN18 5
V1, V2 = CG0603MLC-05E
+5V
VIN
LD1117S50
CONN21 JP1 +3V3
1 5
D3 IC2 IC3
3 3 2 R9
2 LP2985-33
1 3 4
SS16 ON/OFF BP
1k
C10 +5V
7 - 16V DC C8 C16 1 C6 C9 5V
SOURCE SELECT LED4 2
1u L1
100n 22u 100n 22u
CONN10 MH2029-300Y
D2 +5V
1 C3 C4 C12
7 - 16V DC
2 SS16 100n 100n 1u
GND
Vbatt 3
2 14 24 34 44
(6V2 max !)
UVCC VCC AVCC VCC AVCC
JP2 +5V D7 1
PE6(INT6/AIN0)
42 AREF
AREF
VPOWER D– 3 41 A5
D– PF0(ADC0)
SOURCE SELECT D+ 4 40 A4
D+ IC1 PF1(ADC1)
R5 UCAP 6 39 A3
D1 UCAP PF4(ADC4/TCK)
ARDUINO SHIELDS
VUSB 7 38 A2
10k
VBUS PF5(ADC5/TMS)
+5V RXLED 8
PB0(SS/PCINT0) PF6(ADC6/TDO)
37 A1
C7 C15 SS16
RESET SCK 9 36 A0
PB1(PCINT1/SCLK) PF7(ADC7/TDI)
100u MOSI 10 33 HWB
22u SW4 PB2(PDI/PCINT2/MOSI) PE2(HWB)
MISO 11 32 D13
P 8 16 PB3(PDO/PCINT3/MISO) PC7(ICP3/CLK0/OC4)
D11 12 31 D5
POWER VCC1 RESET PB7(PCINT7/OC0A/OC1C/RTS) PC6(PC3A/OC4A)
9 RESET 13 30 D10
3,4EN RESET PB6(PCINT6/OC1B/OC4B/ADC13)
D7 D10 15 14 D3_SCL 18 29 D9
IN4 OUT4 PD0(OC0B/SCL/INT0) PB5(PCINT5/OC1A/OC4B/ADC12)
D2_SDA 19 28 D8
U1 PD1(SDA/INT1) PB4(PCINT4/ADC11)
D9 10 11 D0_RX 20 27 D6
IN3 OUT3 PD2(RXD1/INT2) PD7(T0/OC4D/ADC10)
D1_TX 21 26 D12
PD3(TXD1/INT3) PD6(T1/OC4D/ADC9)
1 TXLED 22 25 D4
1,2EN PD5(XCK1/CTS) PD4(ICP1/ADC8)
BUZZER D6 7
IN2 OUT2
6 5
UGND ATMEGA32U4
L293D GND GND XTAL1 XTAL2 GND GND
D5 2 3
IN1 OUT1 15 23 17 16 35 43
+5V XTAL1
GND
4 5 12 13
PL3 C11 C5
1
P 16MHz
2 22p 22p
3 D0_RX
ISP +5V
4 D1_TX MISO CONN19 CONN20
SCK
HC06 BT RESET
1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 9 10
D2_SDA
D2_SDA
D3_SCL
D3_SCL
D0_RX
D1_TX
MOSI
AREF
D10
D11
D12
D13
D4
D5
D6
D7
D8
D9
D10 OUT
+5V +3V3
RXLED
TXLED
D13
D11
D12
D8
D4
D3_SCL
D2_SDA
D1_TX
D0_RX
D5 OUT
D6 OUT
D9 OUT
SERVO
R6 R7 R8 1 2 3 4
+5V +5V
1k
1k
1k
Figure 1. The circuit diagram of the Arduino, with an Atmega32U4 at its heart.
the crystal (XTAL1) used with this board. A buzzer is connected to pin 1 and a Pin headers JUMPER1 and JUMPER2 are
The USB connector (CONN4) is connected reset button is connected to pin 13 of used to select one of the different power
directly to the controller via protection the controller. supply options. JUMPER1 is used to select
resistors R3 and R4. The supply to this the power source for the board: USB con-
connector is fed via a resettable fuse (T1), There is an extensive power supply sec- nector, mains adapter or battery pack.
which is connected to JUMPER1 for the tion in order to cater for a wide range JUMPER2 is used to select the power
selection of the power supply source for of supply options. A mains adapter with source for the motors that are connected
the board. an output voltage between 7 V and 16 V to the motor driver IC (U1). Here you have
The Motor driver (IC U1), an L293D, con- can be connected directly to CONN21. a choice of the regulated 5 V from IC2,
tains a double H-bridge that drives the Alternatively, the 3-way screw terminal the mains adapter, or the battery pack.
four power outputs on CONN13, with a (CONN10) can be used to connect an
maximum current of 600 mA per pin. The external power supply (also 7–16 V) or The rest consists of various connec-
electronics inside the IC is powered by a battery pack with a maximum voltage tors and screw terminals. CONN17 to
voltage regulator IC2; the power drivers of 6.2 V. The 7–16 V DC voltage is fed CONN20 are available for the connec-
in the IC have a separate power connec- via reverse-polarity protection diode D3 tion of Arduino shields. There are also
tion, where the source can be selected to a 5 V voltage regulator (IC2), which six groups of 3-way screw terminals for
via JUMPER2. provides power to the microcontroller and analog and digital inputs (CONN2, CONN5
There are also four LEDs, of which two motor driver IC (U1). This is followed to CONN9), each with its own 5-V power
are used as indicators for the serial com- by a 3.3-V voltage regulator (IC3), with supply. These are all grouped on one side
munications via CONN3 (RXLED is also its output made available on the shield of the board. On the other side are the
programmable), a power indicator LED connectors and on the Power screw ter- screw terminals for the motors (CONN13),
and a freely programmable LED (LED3). minals (CONN11). two digital outputs (CONN12), serial and
Software options
Apart from the Arduino IDE, there are several other program- to the hardware. Even though this is a graphical language which
ming environments that can be used to easily program the BBA. is amply provided with libraries that make programming easier,
An important feature of this BBA project is that in many instanc- it remains the case that Flowcode is much closer to real ‘em-
es the example programs have been written for all of the five bedded programming’ than the Arduino IDE, for example. Flow-
programming environments listed below. This way you can pro- code is therefore the ideal first step on the road to Embedded C.
gram the BBA using your preferred programming environment.
Atmel Studio 7 with GCC compiler
Arduino IDE with libraries Atmel Studio is the professional development environment for
The original Arduino IDE is a simple C compiler with a large Atmel controllers, and GCC is probably the most-used free C
number of libraries. On the one hand, these libraries and the compiler for Atmel AVR controllers. You can quickly program
unique pin numbering make it possible to write fairly complex the BBA from within this environment. If you want to, you can
programs without needing much knowledge about the micro- still use the extensive Arduino libraries in this environment, to
controller. On the other hand, this means that you hardly learn make the programming of certain functions easier.
anything about the microcontroller itself.
Snap 4 Arduino
Arduino IDE without libraries With S4A it becomes possible to program the BBA with the im-
What many people don’t know is that the Arduino IDE can also mensely popular ‘Scratch puzzle blocks’. S4A uses a fairly stable
be used to program the Arduino using the real register names connection to the BBA, which requires that the ‘Firmata’ pro-
and pin numbers. Users will first have to familiarize themselves gram is loaded first. From then on, all instructions on the screen
with the microcontroller before they can start writing programs are carried out live on the hardware of the connected BBA – a
for it. It’s also possible to use a combination of both systems, bit like an emulator, really.
with and without libraries.
The beta version can translate most basic programs into real
Flowcode (7) for AVR code, which could be loaded at a later stage using the Arduino
From an educational point of view, Flowcode is without a doubt IDE, making it possible to run some programs independently.
the best way to get started with embedded programming. The It looks like a promising start for S4A, which is an ideal way
flowcharts make it very easy to see the program structure, and to impart some of our electronics enthusiasm to the younger
the clever simulator lets you try out the code before you send it generation.
Overview
The layout of the Brainbox Arduino has
deliberately followed the IPO principle:
Input – Processing – Output. At the
top are all the connections for sensors,
the processing is done by the powerful
ATmega32U4 processor, and at the bot-
tom are all the connections for actuators.
The sensors and actuators are connected
directly via sturdy 5 mm screw termi-
nals. The sensor inputs can all be used
as either analog or digital inputs. Each
input has its own GND and 5 V connec-
tions. There is also a set of typical Arduino
connectors for the connection of Arduino
shields.
The BBA has a wide range of power sup- Figure 2. Connection details for the board, with brief descriptions.
ply options, which makes it suitable for
use in many applications.
On the right-hand side of the board are
the programming options. The BBA is (Dutch) teaching material and further Web Link
supplied with a pre-programmed Arduino information is available from [1].
[1] http://e2cre8.be/ (in Dutch only)
Leonardo bootloader as standard. You can (160001)
therefore immediately program the BBA
via the USB port. If you decide to pro-
gram the ATmega32U4 processor with- The Author
out a bootloader, you can do this via the
Bart Huyskens is an electronics and ICT teacher in Belgium. In addition, he
6-way ISP header.
organizes workshops and develops hardware, software and teaching material to
At the bottom-left are two connectors for
encourage inquisitive and creative STEM education.
servo motors and 4 power outputs with
PWM capabilities. These are driven by a
double H-bridge, which can supply up to
600 mA per pin.
At the bottom-right are the two most pop- Complete BrainBox Arduino kit
ular communication ports, I2C and RS232.
The BrainBox Arduino kit retailed by
These can be used to connect a huge
Elektor comes complete with all the
range of sensors, actuators and LCDs to
required sensors, actuators, wires,
the BBA. The 4-way connector at the bot-
mechanical parts, teaching material
tom-right corner is used to directly con-
and example programs to build the
nect a popular HC06 Bluetooth module.
robot buggy shown here, and control
Example programs for both the BBA and
it via a dedicated app.
the APPINVENTOR help you on your way
to use your own apps on a smartphone to
But don’t stop there, give your
communicate with your BBA. You should
creativity a free reign and use the
give it a try — you’ll be amazed how
BBA to create your own projects.
quickly you can get your app up and
running.
This Raspberry Pi HAT puts at your disposal 4 motor-control outputs for LEGO EV3 motors and 16 buffered
I/O connections that can be used in combination with a powerful Raspberry Pi. Programming is possible
in languages such as C and Python. As an application example we show how this board and a few LEGO
parts can be used to build a ‘useless box’.
The board described here combines mechanical construction and the flexi- for the Raspberry Pi, you therefore only
the flexibility of LEGO with regards to bility of the Raspberry Pi with regards to need to connect a 9-V (line) power sup-
software, Internet communications and ply to this board (recommended rating
a wide range of potential sensors. 5 A; positive to center pin). From this the
When you attach this board to a Rasp- motors, the board itself and the Rasp-
berry Pi 2 or 3, you will have at your berry Pi are powered. Mobile applications
disposal 4 motor-control outputs for EV3 can use batteries, because the board uses
motors (or compatible types), which you an efficient buck converter.
can use to animate your LEGO models.
There are also 16 buffered digital inputs Since the Raspberry Pi header is con-
and outputs present, to which you can tinued through the LEGO control board,
connect sensors, LEDs, etc. You cannot, you can also connect SPI and I2C devices
however, connect LEGO sensors (in that and sensors. You can therefore combine
case you would be better served using all the projects and sensors from the
a standard EV3 controller), but you can book “Raspberry Pi – Explore the RPi in
Figure 1. The connections to the LEGO control board. connect all sorts of other sensors such 45 Electronic Projects” with your LEGO
1) 4 LEGO motor connections; 2) 16 I/O connections as infrared, ultrasonic, tilt and switches. models!
with screw terminals; 3) power supply socket, 9 V; You are limited only by your imagination. Through the Raspberry Pi itself you can
4) feedthrough of the Raspberry Pi I/O pins.
The board also contains a power supply communicate via the Internet, with your
choice of a wired or Wi-Fi connection. If nicate with your model when it is away models where you combine LEGO motors
you connect a USB/4G dongle to your from your home. and various types of sensors with the
Raspberry Pi then you can even commu- With this board you can therefore make power of the Raspberry Pi!
Table 1. Strong and weak points of the LEGO EV3 and Raspberry Pi.
• The mechanical construction, which allows you to do anything • The number of connections for sensors. A reasonably serious
you like. robot would need 4 and that is only the start.
• The motors, although for serious applications you would need • Video processing and all the other things for which LEGO have
servos and hydraulics. not come up with a sensor.
• Openness of the system; in combination was the easy-to- • Connection pins are mechanically weak and not electrically
learn language Python much is possible. For the enthusiast C protected.
is an even more powerful option. • Current consumption is on the high side.
• Many connectors and via I/O-expanders offers the possibility
of ‘unlimited’ expansion.
+5V
K10
1
+5V +5V +9V
2
GND +5V
+5V
C3 C4 C5 K2 M1
C10 6
R6 R5
100n 100n 10u 5
33k 18k
K6 100n 63V 4
1 20 19 24 13 14 3
IO16 18
2
STBY
VM1
VM2
VM3
VCC
2 VCC
IO15 6 15 11 1
17 RST PWMB BO1
3 GP7 12
IO14 16 +5V BO1 NXT-Socket
GP6 8 16 7
4 15 IC3 INT BIN2 BO2
IO13 GP5 2 17 IC2 8
14 SDA
K11 BIN1 BO2 K3 M2
GP4 1 6
13 SCL R8 R7
GP3 1 2 23 5 5
1 12 MCP23008 PWMA AO2 33k 18k
IO12 GP2 5 3 4 6 4
11 A0 TB6612FNG AO2
2 GP1 4 5 6 22 1 3
IO11 10 A1 AIN2 AO1
GP0 3 7 8 21 2 2
3 A2 AIN1 AO1
IO10 9 10 1
GND
PGND1
PGND1
PGND2
PGND2
4 11 12
GND
IO9 9 NXT-Socket
13 14
18 3 4 9 10
K7 15 16
17 18
+5V
19 20
C9 21 22
23 24
+5V +9V
R18
R19
K8 100n
R4
R3
R2
R1
25 26
IO8
1 27 28 +5V
100k
100k
100k
100k
100k
100k
18
29 30
2 VCC C6 C7 C8 K4 M3
IO7 6 31 32 6
17 RST R14 R13
3 GP7 33 34 5
IO6 16 100n 100n 10u 33k 18k
GP6 8 35 36 63V 4
4 15 IC4 INT
IO5 GP5 2 37 38 20 19 24 13 14 3
14 SDA
GP4 1 39 40 2
STBY
VM1
VM2
VM3
VCC
13
GP3
SCL +5V
15 11 1
1 12 MCP23008 PWMB BO1
IO4 GP2
11 A0
5 Raspberry Pi BO1
12
NXT-Socket
2 GP1 4 16 7
IO3 10 A1 BIN2 BO2
GP0 3 17 IC5 8
3 A2 BIN1 BO2 K5 M4
IO2 6
GND R16 R15
4 23 5 5
IO1 9 PWMA AO2 33k 18k
6 4
TB6612FNG AO2
K9 22 1 3
AIN2 AO1
21 2 2
+9V AIN1 AO1
4 1
K1 +5V
PGND1
PGND1
PGND2
PGND2
T1
R10
R12
R11
FB
R9
GND
VOUT 18 3 4 9 10
LM2596S 33uH LED1 +9V +5V
5.0V 2A1
GNDPAD ON
ON/OFF GND R17
C1 D1 C2
5 6 3 C14 C15 C11 C12 C13
330R
1000u 220u
25V MBRS540 16V 100n 100n 100n 100n 100n
159010 - 11
GND
Figure 2. The circuit of the control board comprises 2 motor driver ICs, 2 I/O expanders and a step-down voltage regulator.
+9V 4
+9V 4
+5V +5V
FB FB
L1 +5V L1 +5V
1 IC1 2 1 IC1 2
VIN VOUT VIN VOUT
LM2596S 33uH LED1 LM2596S 33uH LED1
5.0V 2A1 5.0V 2A1
GNDPAD ON GNDPAD ON
ON/OFF GND R17 ON/OFF GND R17
C1 D1 C2 C1 D1 C2
5 6 3 5 6 3
330R
330R
a GND b GND
Design considerations flywheel. The LM2596 begins by ‘turning board uses addresses 0x20 and 0x21.
The LEGO control board is certainly not up’ the voltage to ‘full’. This gets the You can, for example, add further I/O-ex-
a copy of the EV3 controller, but it does flywheel started. This does not happen tenders, D/A converters for generating
combine the strong points of LEGO with immediately, because the capacitor first analog signals, or A/D converters to sense
those of the Raspberry Pi. Table 1 lists needs to be charged via the inductor. analog signals.
the strong and weak points of each. The inductor itself builds up a magnetic
The conclusion is that this board needed field. The diode does not conduct at this Motors
to have the following characteristics (and time since the current returns via the The two TB6621FNG ICs (IC2 and IC5)
it therefore was given them): LM2596 itself. each contain two H-bridges to allow the
control of four motors in total. The cur-
• 4 LEGO EV3 motor control connec- When the voltage at the output threatens rent consumption of the LEGO motors is
tions (for LEGO 45502, 45503 or to become too high, the LM2596 switches approximately:
compatible), with all 4 of provided its output off. The magnetic field in the EV3 small EV3 large
with tacho feedback signals and 2 inductor will now collapse, which causes
free running 85 mA 80 mA
provided with PWM outputs; the voltage across it to reverse and the
slowly
• 16 buffered I/O pins (expandable diode will now conduct. This creates a 500 mA 1000 mA
forward
thanks to the I2C connection); current that circulates via the load and
• energy efficient power supply for the the diode (the path via the LM2596 is no stalled 780 mA 1800 mA
Raspberry Pi (using buck-converter); longer possible because this is switched
• free Python 2 software library; ‘off’). The capacitor also discharges. An EV3 motor can be stalled for only a
• feed-through of the Raspberry Pi When the voltage at the output threatens short amount of time, because the pro-
header (you therefore can add fur- to become too low, the LM2596 switches tection built into the motor will switch it
ther connections yourself, such as on again. off. It is nevertheless always a good idea
protected I/O or analog I/O). to prevent stalling the motor, because
The LM2596 therefore only switches on should the protection not work for some
Design result and off. The effect of this is that the effi- reason the motor could burn out.
The complete schematic for the LEGO ciency is very high and the LM2596 there-
control board is shown in Figure 1. The fore barely heats up. Because of this con- The TB6621FNG can typically handle
most relevant parts in this circuit are the tinuous on and off switching, the value 1.2 A (per channel, so per motor) with a
two motor-driver ICs type TB6612FNG of C1 is also important and for both C1 peak of 3 A; this is therefore more than
from Toshiba (which each can drive two and C2 low-ESR types need to be used. sufficient.
motors with a maximum output current
of 1.2 A) and two 8-bit I/O-expanders I/O If you intend to make a software library
type MCP23008 from Microchip with a The MCP23008 I/O extenders IC3 and IC4 for the motor controllers, then take into
high-speed I2C interface and SPI inter- are controlled via I2C and ensure that the account that the PWM pins have to be
face. We now take a look at a few inter- I/O connections of the Raspberry Pi do high in order for the TB6621FNG to oper-
esting details of the circuit. not need to be used directly. This design ate. When you apply a PWM signal then
has several advantages: it is always correct, independent of the
Power supply direction of rotation.
In order to enable everything to be pow- • The I/O connections operate at 5 V
ered a single source, the Raspberry Pi • The I/O pins have a greater current Circuit board
is powered from the control board. The capability than the Raspberry Pi pins In Figure 4 you can see the circuit board
board itself is powered from a 9-V DC • Should something nevertheless go that was designed for this LEGO control
power source. This power source can wrong, the damage will generally be board. The dimensions and connector
either be batteries or a substantial line limited to the I/O extender chip positions are obviously selected such that
power supply (recommend rating 5 A). the board will fit trouble-free on a Rasp-
To go from 9 to 5 V (the voltage required The maximum current that the MCP23008 berry Pi model 2 or 3 (using a 40-way
by the Raspberry Pi) an energy-efficient can supply is 25 mA, with a maximum per I/O connector). Since most of the com-
method needs to be used to prevent IC of 125 mA. Note that one IC can dissi- ponents are in SMD packages, you can
the batteries from draining too quickly. pate a maximum power of no more than also purchase a completely built version
The choice therefore fell on a buck con- 700 mW. This applies to each MCP23008, of the board from Elektor. Of course, it is
verter based on the step-down regula- so if you need a lot of current it would also possible to do everything yourself,
tor LM2596S-5.0V, a so-called Simple be best to spread the loads across both the circuit board layout is available from
Switcher Power Converter from Texas MCP23008s and not connect everything [1]. Note when assembling the board that
Instruments. This operates at a frequency to a single IC. the 40-way connector K11 is fitted on the
of 150 kHz and can supply 3 A. Because the Raspberry Pi headers are bottom side of the circuit board and is
The buck converter functions as follows continued through to the top of the con- soldered from the top side. The four NXT
(see Figure 3). The loop formed by the trol board you can add additional I2C com- sockets for the motors are quire rare, you
diode (D1), the inductor (L1) and the ponents yourself, provided that they have will have to search on the Internet for a
capacitor (C2) act like a kind of electronic different addresses. The LEGO control suitable supplier.
C10
0.25W;
IC3
V2.1
K4
K1 GND 5V • An (easily operated) small in-line
IC1 C8
R14
C7
IC5
R13
switch (see Figure 4).
C1 D1 C6
C5 C15 K3
The hardware
We use a ‘large’ LEGO motor type 45502
C4
IC2
R8
C2 R7 which can be found in, for example, the
C3
LEGO Mindstorms EV3 box and the parts
R17 LED1 C14
T1
L1 K2 that are shown in Figure 5. In the down-
R6
R12
R10
R19
R18
R11
R9
R1
R3
R4
R2
40
into the motorized finger, which is shown
on the right in the figure. You now attach
Figure 4. The layout of the circuit board. The 40-way connector K11 is mounted on the bottom of the in-line switch on top of the assembly
the circuit board. in such a way that the black beam can
push the switch to its off position.
Demo project: The Useless Box ate the switch, a ‘finger’ appears from This switch is connected with two resistors
The concept of this ‘Useless Box’ is a box the box which turns the switch off again. (see Figure 6) to I/O pin 16. This could
with a switch on top. When you oper- For this project we only build the inner also be accomplished with only one resis-
tor (the 10 kΩ one), but the additional not noticeably slow down the program. As 7. Repeat step 6 as many times as you
resistor serves as protection. If you now soon as the switch is off again, the pro- like and then stop the program using
inadvertently make the input into an out- gram will turn on the brake in the motor. Ctrl-C.
put and set its level low then nothing bad The next step (Listing 1b) is to return
will happen. Without the additional 1-kΩ the LEGO finger at a slower speed This is only a simple application example.
resistor the I/O port could be damaged. (PWM 30, 30% of the maximum speed) The LEGO control board can of course be
to its rest position. For this case there is used to realize much more complicated
The software no switch at the end of the movement, applications with its four motor control
The software is surprisingly simple. (Note: so the program now uses the tacho. The connections and 16 I/O pins.
the library expects Python-2 programs!) program counts the tacho changes and (150597)
You can find more information about the once there are 100 (28% of a circle) the
library and the instructions in the manual, motor stops with the float instruction. The
Web Links
which is a free download accompanying LEGO finger is now about one centimeter
this project [1]. The very first thing we do above the surface. [1] www.elektor.com/150597
is load the rpirobot library and execute it
with the instruction ‘execfile’. The motor In the except-construct (Listing 1c) any
outputs of the LEGO control board are errors or a Ctrl-C instruction from the
now automatically configured correctly user are caught. The program gives a
and the PWM threads are running. We brief abort instruction to the Raspberry Pi
then make pin 16 of the I/O on the con- library and then terminates itself as well. Listing 1a.
trol board an input, because this is where Without this construct it is obviously still
try:
the switch is connected to. possible to exit the program using Ctrl-C,
while 1:
but then the library continues running and
# wait for the user
execfile(‘rpirobot.lib’) that is clearly not the intention.
# to push switch on
The steps if ioread(16):
# Switch on io 16, input
1. Set the LEGO finger in the rest posi- # push switch off
iodir(16,1)
tion, that means as far as possible time.sleep(0.5)
from the switch (against the bottom reverse(1)
print "Useless Box Program running"
surface for example). pwm(1,60)
2. Start the Raspberry Pi and wait until while ioread(16):
We use a try/except construct (see List- the booting process has completed. time.sleep(0.000001)
ing 1a), so that the program waits until 3. Copy the test folder from the download
brake(1)
the switch is turned on by the user or the to the Raspberry Pi (using WinSCP, for
user has quit the program using Ctrl-C. example).
Once this happens, the program waits half 4. Return to the test folder with the Listing 1b.
a second to give the user timer to remove instruction ‘cd test’.
their finger and then activates the LEGO 5. Now issue the instruction ‘python use- # retract lever
finger with a PWM value of 60 (60% of lessbox.py’. forward(1)
the maximum speed). We wait in a loop 6. Wait until the text ‘Useless Box Pro- pwm(1,30)
because of the threads that are running. gram running’ appears on the Rasp- counter1=0
Since nothing happens in the loop this is berry Pi and turn the switch on (and lastpin1=tacho(1)
not actually helpful, so we introduce a get your fingers out the way!). The while counter1<100:
short sleep instruction. This instruction LEGO finger will now return the switch time.sleep(0.000001)
takes 0.000001 seconds (1 µs), and will to its off position. if tacho(1)!=lastpin1:
counter1+=1
lastpin1=tacho(1)
S
# float motor
10k
1k float(1)
M4
+5V
GND
IO16
M3
Listing 1c.
except:
LEGO Control Board M2
LEGO 45502
# user aborts program with
M
M1 Ctrl-C
print "Program aborting"
abort()
Figure 6. Connection diagram for the switch with Figure 7. The complete model.
print "Done"
the two resistors.
Debugging
the Arduino Zero & M0 Pro
Delving deeper into the world of Arduino
By Stuart Cording (iSystem, Germany) Atmel (now Microchip), are kitted out with a slightly different
programming interface compared to previous boards. The device
behind the USB “programming” connecter is also an Embed-
Boards like the Arduino M0 Pro and DUE provide, respectively, ded Debugger (EDBG) which can be used by many different
the same pin-out as their 8-bit Arduino Uno and Mega cous- development environments as an interface to not only program
ins, but with the advantage of significantly more SRAM, flash the board but additionally to interrogate the internal workings
memory and CPU clock speed. Perhaps the only disadvantage of the MCU at the heart of the system. With an appropriate
or challenge with these boards is the 3.3-volt restriction on the IDE, it is then possible to debug not only your sketch, but the
input and output pins. However, these advantages, combined entire Arduino core code and libraries.
with support for many of the available shields on the market One such IDE is iSystem’s winIDEA Open, the free version of
and the established base of libraries, make the ‘upgrade’ sim- their IDE targeted at MCUs that use ARM’s Cortex-M processor
ple and fast. technology. As a professional tool it is easy to get started, as,
The biggest challenge remaining for the advanced hobbyist at the most basic level, all that is needed is the output file from
or professional using Arduino for rapid prototyping is the lim- a sketch built in the classic Arduino IDE. However, as we will
ited Integrated Development Environment (IDE). For entry discover, the build manager can also be invoked to speed up
into the world of Arduino, the Arduino IDE is perfect with its the compilation of sketches. Additionally, the integrated test
simplicity and clarity. Once a sketch becomes slightly more environment testIDEA can be used to check whether any bugs
involved, however, and failures in the code cannot be found have scurried into our project during development.
with a blinking LED or serial message output alone, the sheer There are many details and nuances behind configuring and
power of a professional IDE is highly alluring. using such a tool. In order to provide both an overview for those
simply interested in this concept as well as detailed instruc-
Debug (as) a Pro, Pay Nothing tions for those who would like to go hands on, the overview in
The Arduino M0 Pro (from Arduino.org) as well as the Arduino/ this article is supplemented by a series of tutorials and code
Genuino Zero (from Arduino.cc), based on the SAM D21G from available online [1].
My First Project Workspace” window (Figure 1) all the files that belong to the
When starting a new project for a SAM D21 MCU in other IDEs, project, along with all the used functions, are listed in a tree
such as Atmel Studio which has been covered by Elektor before structure just like in Windows’ File Explorer. So, if you have
[2][3], you really need to start from a template and have to ever wondered what code lies behind the delay() function,
include many pre-defined library source code files. The win- simply expand the “Functions” folder, scroll down until you
IDEA Open IDE is different in that it forms the premise that find delay(unsigned long ms) and double-click. In the editor
the output of the compiler toolchain, for example the ELF window, the function will be displayed. If you are interested to
file containing the binary code of your Arduino sketch, is the see when the function is called, you can set a break-point on
most important file of your project. From this single file, the a line of code where a grey box is also shown in the editor’s
IDE can find all of your source code and the core Arduino files gutter (the grey region in the text editor to the left of the line
and libraries needed to debug the application code. Thus the numbers). Simply right-click with the mouse and select “Set
simplest method to debug an Arduino sketch is to create and Breakpoint”. Once the code is restarted, the MCU will halt when
build it in the Arduino IDE and then import and download the it reaches this breakpoint, allowing you to analyse the content
resulting ELF file into the Arduino M0 Pro using winIDEA Open. of variables, registers and memory.
In the first three projects of Tutorial 1 [1], the classic ‘Blink’ Note that, despite the Arduino environment’s apparent simplic-
sketch is created in the standard Arduino IDE. Due to slight ity, the code in its core software makes good use of many of the
differences between the Arduino M0 Pro and Arduino/Genuino advanced tricks the C programming language has to offer. As
Zero, winIDEA Open needs to be configured slightly differently. such, some ‘symbols’ (names of variables and functions) may
However, for those who just want to get started, a preconfig- appear listed in the Project Workspace window but may not actu-
ured workspace is provided allowing the developer to simply ally be associated with any code of significance in the software.
open the appropriate workspace and download the ELF file that
the Arduino IDE has created. Speeding Up the Workflow
Once the code is in the MCU, it is then possible to start exploring One of the issues with the method discussed thus far is that
the internal workings of the Arduino core code. In the “Project the original Blink.ino cannot be debugged properly. The issue
relates back to how the Arduino IDEs compile the sketch. For
the beginner, this is really no problem, but when wanting to
go deeper into the code, it would be nice to be able to build a
sketch outside of the Arduino IDE.
There is also another benefit to be gained from this. One of
the most frustrating things about the standard Arduino IDEs is
that every compilation rebuilds the entire project from scratch.
Again, for smaller sketches this is no big deal. However, as
soon as a couple of libraries are included and you have several
source files, rebuilding and programming the board starts to
become quite a laboured activity. Here again, a professional
IDE can help by providing the means to build the project out-
side of the IDE.
In addition, you will need the make utility which can be installed
as part of MinGW. Detailed instructions on how to do this can
be found in Tutorial 2, available from [1].
Now, instead of building the sketch in the Arduino IDE (Fig-
ure 3) and then simply programming and debugging the code
in the winIDEA Open IDE, the whole process can be under-
taken in winIDEA Open.
As a result, we can now debug our sketch. The project work-
space works in a manner similar to that of Windows Explorer,
allowing the elements listed to be “expanded” to show their
contents in the same way folders can be expanded. In the
Project Workspace simply expand the elements listed using the
Figure 2. Blink.cpp in the winIDEA Open IDE. plus symbol to the left of each element in the following order:
sketch.elf ª Modules ª src ª Blink.cpp (Figure 4). Finally,
double-click on loop() or setup() and the editor will open the
source code at the respective line of code where the function
is implemented. As we see in the gutter, each line of code has
a grey box associated with it allowing us to set a breakpoint in
the code execution if we wish. Simply right-click on the desired
line of code and select “Set Breakpoint”.
Beyond Debugging
Typically, when developing an application, specific functional-
ity will be broken out into separate functions. For small pro-
jects, where perhaps a single developer is responsible, it is
relatively easy to keep track of what is working, what isn’t
and where a bug might be when the code fails. However, for
larger, multi-programmer projects, it can help to have a bat-
tery of tests available that, when executed, ensure that the
code is still operating as originally specified. For this purpose,
winIDEA includes the Original Binary Code (OBC) unit testing
tool testIDEA. Here we will use it to develop some tests for a
function that evaluates an imaginary input value and returns Figure 4. The sketch executable can be explored as if it was a folder tree.
a new time delay for our delay() function call.
The algorithm implemented in the code is quite simple (Fig-
ure 7). If the passed value is less than 50, it returns 150. If
the passed value is between 50 and 99, it returns 1000. For
all other values, it returns 1750. Having developed the code,
it would make sense to develop a short test that could be exe-
cuted to ensure that it still works, even if someone else makes
changes and introduces a bug into the code.
Before writing tests for a function, it is worthwhile initially
considering how you would go about testing it by writing the
steps down on a piece of paper or making a small table of
Figure 5. Message when no more breakpoints are available.
input and expected output values. In the Table 1 we have
focused on input values at the extremes of possible inputs
as well as values that are close to the boundaries defined in
the algorithm (50 and 100).
In order to develop our tests, from the menu bar, we select project by clicking the refresh symbol. Once complete we
Test ª Launch testIDEA. Upon starting testIDEA, the tool sug- can select our function to be tested, evaluateNumber(),
gests creating a ‘test specification file’. This file is where our from the drop-down list.
tests will be stored and the file extension is ‘iyaml’. Here we • In the Parameters box we enter the value to be passed to
explain how to create a test: the function. For test number 1, this is 0.
• Next we enter the Expected Result, first selecting the
• From the menu, select Test ª New Test… ‘Default expression’ radio button. In the field we enter
• Now we need to define the function to be tested. Before 150, which is the expected response entered in our table.
we can do this, we have to refresh the link to our winIDEA • Click OK and the first test is complete.
Advertisement
returnValue = 0
The SAMD21 is just one in the range of SAM D ARM
Cortex-M0+ based, 32-bit microcontrollers from Atmel.
These devices offer up to 256 kB of flash memory and
x < 50? returnValue = 150
32 kB of SRAM. Additionally, the devices boast a wide range
of interfaces, including full-speed USB, a real-time counter
for implementing a clock, USART, SPI and I²C interfaces,
and a 12-bit ADC. Optimal energy efficiency is also covered
x < 100? returnValue = 1000
with the power consumption lying at 70 µA/MHz. The family
also features an automotive grade version of the MCU and
some devices can be used to implement a capacitive touch
returnValue = 1750 End interface, making use of Atmel algorithms to implement
buttons, sliders and wheel user interfaces.
www.atmel.com/products/microcontrollers/arm/sam-d.aspx
Figure 7. Flow diagram of a simple algorithm.
It’s easy enough these days to generate random numbers digitally using a computer program. But there is
also an analog approach: the project described here processes the noise produced by a transistor junction
using an Arduino. The random numbers so generated can be used in various interesting experiments and
will even lead us a little into the world of mysticism.
It is not only mystics who wonder whether there exists some Arduino passes the random numbers derived from the analog
universal consciousness that connects us all together and lets source to a PC over USB, where they can be displayed graphi-
us communicate subconsciously with one another. Thanks to a cally. The PC software has no pretensions to completeness and
project run from Princeton University using a collection of ran- interested readers are encouraged to extend it. Both the source
dom number generators spread all over the world, we may now code for the PC program and the Arduino sketch are available
have some signs that there may be a connection between human as a free download from the Elektor Magazine website [1].
consciousness and the behavior of electrons in a noisy pn-junc-
tion (see text box). Since I had just finished soldering together Hardware
a simple random noise source for my home-built analog syn- The circuit of the noise source is shown in Figure 1. The noise
thesizer, I hit upon the idea of trying to reproduce the Princeton originates in the reverse-biased base-emitter junction of tran-
experiment with my own hardware and software. sistor T1. This extremely weak signal has its DC component
Random numbers produced by a computer are just the results removed by C1 and is then amplified by IC1. The noise signal,
of mathematical calculations, and so are in fact deterministic, or now symmetric about zero, is taken via capacitor C2 to summing
‘pseudo-random’. Such numbers are not suitable for this project: amplifier IC2, where a voltage set by P2 is added to ensure
instead we must use an analog method to generate the numbers. that the output is always positive. This is required because
One approach is to process the noise created by the electrons the analog inputs of the Arduino can only work with positive
in the pn-junction of a reverse-biased diode. If this noise volt- voltages. Preset P1 can be used to adjust the amplitude of the
age is amplified and fed into an analog-to-digital converter, we noise signal. You can use an oscilloscope to set the average
will obtain a steady stream of unpredictable random numbers. level of the signal to about +1.4 V and the amplitude to about
1 VPP (an accurate measurement of these parameters of the
The project noise signal is not possible). The output of the noise source
The hardware I designed consists of a simple noise source can now be connected to the input of the Arduino.
whose output signal is fed into an Arduino microcontroller. The Figure 2 shows how the noise signal is fed into the Arduino:
PC via USB
+15V
R1 USB
R3
10M
10M R5 SCL
100k ARDUINO SDA
IC1
C1 R2 1 AREF
2 7 IC2
10k C2 P1 1 GND
8 6 7 NC
2
4n7 OP07 8 6 IOREF
13
3 R4 12
3u3 500k OP07 RESET
T1 4 3 Noise ~ 11
470k
C3 5 3.3V
4 Generator ~ 10
5 +15V 5V
4u7
P2 GND
~9
GND
POWER
Power GND
GND
8
BC547B –15V
DIGITAL (PWM ~ )
VIN 7
GND 100k
~6
AN0
AN0 ~5
AN1 4
C4
AN2 ~3
ANALOG IN
AN3 2
4u7
AN4 TX 1
AN5 RX 0
–15V 150831 - 11
150831 - 12
Figure 1. The circuit of the noise source uses a transistor and two Figure 2. Connections between the power supply, the Arduino and the noise
operational amplifiers. source.
Figure 3. User interface presented by the program, which automatically Green curve (mode 1)
starts collecting data when it is launched. If a sample is above the horizontal center line a variable is
incremented; if it is below the center line, it is decremented. It
is not easy to set the offset potentiometer in the hardware suf-
an Arduino Uno is used in this case. There are two connec- ficiently accurately, and in any case the offset will vary slightly
tions: first, the signal connection, which is taken to analog with temperature, and so a calibration process is required. The
input A0 of the Arduino; and second, the ground connection. calibration buttons help with this.
The noise source can be powered from any suitable external
2 x 15 VDC power supply. The Arduino is powered from the Calibration buttons
PC over the USB cable. These are the two buttons towards the top of the display, which
can be used to make vertical adjustments to the horizontal
Software line in the upper graph window that divides the positive sam-
As already mentioned, two separate pieces of software are ples from the negative ones. Depending on this setting, the
needed in this project: one running on the Arduino and one on green curve in the lower graph window will either run hori-
the PC [1]. The program running on the PC is written in Pro- zontally or will trend up or down. The offset potentiometer in
cessing. The Processing programming environment (which so the noise source should be adjusted so that the green curve
far I have only used under Windows XP and Windows 7) can runs as horizontally as possible when the threshold position is
be downloaded from the Internet free of charge [2]. A Pro- set to 150 using the buttons. In this case the random points
cessing file must always be placed in a directory that has the displayed in the upper graph window should appear to be per-
same name as the program file itself. fectly symmetric with respect to the center line. The threshold
value of 150 appears among the variable declarations in the
It is very important to ensure that you enter the correct COM Processing code, as follows:
port number in the setup part of the Processing code so that
the Arduino is recognized by Windows. You can find the correct int limit = 150 ;
number using the Device Manager. For example:
If a different value suits your hardware better, you can mod-
serport = new Serial(this, “COM3”, 115200); ify the code.
Unfortunately it can happen that the port number changes by Divider buttons
itself while you are experimenting with the system. The next two buttons down allow for the expansion and com-
After using the Arduino IDE to flash the sketch into the Arduino, pression of the curves in the Y direction, to allow them to be
it can be connected to the PC and then the Processing program analyzed in greater detail. The two numbers shown at the top
can be launched. After a brief delay the signal should appear on of the display are the most recent values plotted on the curves.
the screen in the upper graph window (see Figure 3, above),
and it should be symmetric about the horizontal center line. If Files and ‘LOAD FILE’
it is shifted or if the amplitude is not correct, P1 and P2 must Normally every thirty minutes a file is created storing the data
be adjusted. Below we will describe how you can fine-tune represented by the curves in the lower graph. These files are
these settings using the software. saved in the same directory as the Processing program. The
file name is determined when the program is started and con-
Operation sists of the time and the date when the program was started.
The time interval between files being saved can be adjusted
Upper graph window by modifying the variable declarations in the code: details on
how to do this are given in the program. On the other hand, you might prefer to spend your time mod-
Clicking on ‘LOAD FILE’ brings up a file selection dialog where ifying the processing program to display and analyze other
you can navigate to any previously-saved file and reload it. types of data more obviously influenced by the outside world,
such as readings from a temperature sensor!
Display current data / Display loaded file (150831)
The data plotted in the lower graph can be changed by clicking
Web Links
on the two buttons ‘Display current data’ or ‘Display loaded
file’. When the plot is changed to ‘Display current data’ it is [1] www.elektormagazine.com/150831
not updated until the plot in the upper graph reaches its right- [2] https://processing.org/download/
hand edge.
Cool Power
A high-performance amplifier
with lots of output power
By Ton Giesberts (Elektor Labs)
with D-Watt
Elektor has a long history and a good reputation
with high-end yet DIY, audio projects. This time
we proudly present a new power amplifier aimed
at all audio enthusiasts, built around a digital
audio driver IC and operating in class-D. This
has the advantage that the amplifier can
deliver a lot of output power (like 200 watts
into 8 ohms) with very low heat dissipation.
Say goodbye to big heatsinks!
IN- VAA+VSS
SIDE
CS
simple copy of the reference design.
2
HO
OTA
GND Amplifier
HV
LEVEL VS
With an IC designed for a specific appli-
COMP SHIFT HV HV
LEVEL
FLOATING HIGH SIDE
LEVEL cation, it’s a good idea to start with the
SHIFT SHIFT
VCC standard application circuit from the man-
VSS
ufacturer. That certainly holds true for
the IRS2092. A detailed description of
this IC can be found in application note
CSD DEAD TIME
LO
AN-1138 [3].
HV SD DT
Our version is shown in Figure 2, where
LEVEL
SHIFT
COM the configuration around the driver stage
PROTECTION
CONTROL HV
LEVEL
IC2 and the dual MOSFET T1 is virtually
VREF
SHIFT LOW SIDE CS “by the book”. Transistor T1 is specifi-
OCSET
cally designed for this sort of application,
DT with two n-channel MOSFETs housed in a
single package. The IRFI4020H-117P is a
member of the Infineon family of digital
Figure 1. Block diagram of the IRS2092 digital driver IC used in this amplifier. audio MOSFETs and has a rated UDS max of
200 V, ID cont of 9.1 A and RDS(on) of 80 mΩ.
It is a perfect choice for power amplifiers
with output power of 200 to 300 W into
It has been nearly three years since we ferent components or component values 8 Ω. Thanks to the single package, this
presented our last power amplifier proj- if you wish. dual MOSFET is easy to mount on the
ect in Elektor — the Q-Watt Audio Power circuit board and on a heatsink.
Amplifier [1]. That was a standard class Design choices The feedback network between the out-
AB power amplifier with high output It is possible to build a class-D amplifier put and the input consists of R7 and R8,
power and low distortion. Since then a entirely from discrete components, but along with capacitor C6 to suppress RF
large number of audio enthusiasts have that does not make for a simple design. signals (in combination with R8). The gain
built their own copy of that amplifier. Fortunately, there are several semicon- is determined by the ratio of R7 + R8 to
With the design presented here, we are ductor manufacturers who make dedi- R5 + R6. The input impedance of this
taking the digital route for a change. In a cated ICs for class-D amplifiers. A large inverting amplifier is determined by R5
class-D power amplifier, the output tran- variety of ICs are available for low power and R6 and is fairly low (about 3.3 kΩ).
sistors operate in switching mode with amplifiers, but the choice is fairly limited if For that reason we added a buffer stage in
a very high switching frequency. Pulse you are looking for high power combined the form of opamp IC1A (an AD8031ANZ,
width modulation converts the amplitude with high quality. We found an outstand- which is a fast rail-to-rail opamp). You
of the analog input signal into a specific ing solution in the form of an IC designed can choose which of the two inputs you
ratio of positive and negative pulse widths by International Rectifier (now Infineon): want to use by fitting a jumper in the
in the output signal. A filter at the output the IRS2092. This 16-pin IC goes by the appropriate position on header JP1. The
blocks the high-frequency switching signal name “Protected Digital Audio Amplifier”, input impedance of the opamp stage is
and passes the amplified audio signal to and it integrates nearly everything you 11 kΩ. It is designed with a gain of 1,
the loudspeaker. The main advantage of need to build a relatively simple high-per- but if you wish you can increase the gain
this type of digital power amplifier is its formance class-D amplifier. You only have by fitting a resistor in the R3 position
high efficiency, which allows the heatsinks to add some power transistors. (A = R4/R3 + 1). The supply voltage
to be much smaller than with a compa- The IC contains gate drivers that can for the opamp is provided by the ±5 V
rable conventional design. deliver high currents for the connected voltage regulators, which also supply the
The key components in this amplifier are power MOSFETs, a PWM modulator with auxiliary voltages for IC2 (see below).
a driver IC in a 16-pin package and a dual built-in oscillator, bidirectional current
power MOSFET. Together with extensive protection and programmable dead
protection circuitry, they are mounted on time for driving the MOSFETs, and it can
a single PCB, so you only have to add a operate with switching frequencies up to
suitable power supply —either regulated 800 kHz (see the block diagram in Fig- Figure 2. Complete schematic diagram of the
or unregulated. There are no SMDs in ure 1). Along with the datasheet [2] and D-Watt amplifier. The amplifier circuitry is shown
the design, so building the board is very a wealth of application notes, Infineon in the top half, with the protection circuitry in
easy and you can experiment with dif- offers a lot of reference designs for the the bottom half.
10R
10k
IC3 +5V
1k8
33k
1u 100n 1 3
10R
2
U 50V 10u 100n 10u R22
OCPH=19.5A
R24
50V 18V 1u 10u 100n
1 12 15 1W3 50V 50V
JP1
8k2
10k
U = unbuffered VAA VCC VB
B = buffered C4 R5 R6
U 3 16
330R 3k0 IN- CSH
+5V -5V B C7 C21 R23 -VP
10u C5 T1 +VP
C26 C27 C28
10k
2x D1 D2 +5V 1n 22u
1N4148 AD8031ANZ 1n 50V R25 D8
R9 C8 14 100n 100n 100n
B R1 HO 18R 2x
3 C2 L1
470R
10R
4 R26
reader project
R29
10k
R4 1n 11
LO 18R
1R
1n 2k 100n 1k 2 470n
2k2
GND
R3 1W -VP
-5V IRFI4020H-117P 2W
10
-5V COM
NM
C30
VCC K2
C24 C25 2
D5 R11 5
C19 C18 R14 CSD R19 -VP 100n 1 LS-
C14 100n 680u
10R VSS VREF OCSET DT
2k2
100V
1
1u
5k6
18V 100n
50V 50V 10u 6 7 8 9
1W3 2 3 R17
R13 6k8
7905 R18 R20
D3 C12 C13
IC4 -5V
1k8
NM
3k0
2W 1N4007 50V 10u 100n +VP
+5V OCPL=19.5A
-VP +VP
-VP D16
labs project
R37 K3
Ext. R43 R44 R45 +5V R49 R51 0W5 2
Test DC
1 +
10k
68V
820k
T5
15k
22k
22k
R48
2k7
R53
22k
T9
47k
JP2 D12
D13 RE1A T12
HS1 BC557C R54 K4
CSD
D11 Ext. Amp. T11 10k 2
R32 R33 1N4148 R38
+5V RT314048 D17 1 0
5520 Ω
4x R35 T7 R39 R41 1N4148 4x
4k7
15k
22k
BC547C BC547C R50 R52
T8 1N4148
6k8
22k
D14
1M
1N4148
120k
10k
Over-Voltage Protection
K5
R34 T10 2
D15
R36
C34
R40 C35 R42
IRFD 1 –
T3 T4 T6
10k
210PBF 0W5
10M
10k
4k7
2u2 68V
100u 50V R46 R47 –VP
10k 150k
Under-Voltage Protection 150115 - 11
-5V -VP
learn design share
Virtually all of the components around additional decoupling at the auxiliary sup- tive to ground, is used to drive the high-
IC2 have specific functions. The major- ply voltage pins of IC2 (VAA and VSS) is side MOSFET. This pin is connected to a
ity of the resistors connected to the IC provided by networks in series with the standard bootstrap circuit consisting of
determine the two current limit levels, supply lines (R10/C10/C11 and R11/C12/ R16, D6 and C21, along with R21 which
the dead time, the bootstrap drive volt- C13). Diode D3 protects the IRS2092 if is necessary to charge C21 before the
age for the high-side MOSFET, and the the negative supply voltage drops out. PWM oscillator starts running. Resistor
feedback from the output. The voltage on the negative supply volt- R16 limits the peak current.
IC2 requires two auxiliary voltages (+5 V age pin VCC (which is used to drive the
and –5 V). Instead of deriving them low-side MOSFET) is +12 V with respect The dead time (the time interval when
directly from the main supply voltages to the main negative supply voltage -VP. both MOSFETs are cut off to prevent large
using Zener diodes and series resistors, This pin draws somewhat more current peak currents through both devices at
we use separate voltage regulators (IC3 than the auxiliary supply voltage pins, so the same time) can be set with voltage
and IC4) to keep the auxiliary voltages a stabilization circuit consisting of volt- divider R19/R20 to one of four discrete
stable even when the amplifier is pow- age regulator IC5 in series with an exter- values: 105, 65, 40 or 25 ns. Here we
ered from an unregulated power supply. nal Darlington power transistor (T2) is selected the minimum dead time set-
There are Zener diodes (D4 and D5) at provided here. In this arrangement the ting of 25 ns by omitting R20. Note that
the inputs of the voltage regulator ICs to transistor handles the additional power increasing the dead time causes a sig-
keep their input voltages at a safe level dissipation. The VCC pin of IC2 is locally nificant increase in THD in the upper fre-
(the maximum allowable supply voltage decoupled by C20 and R15. quency range. You should bear in mind
is ±70 V) and reduce the dissipation of that MOSFETs generally need about twice
these ICs. To prevent HF switching noise The voltage on the positive supply volt- as much time (or longer) to switch off
from affecting the voltage regulators, age pin of IC2 (VB), which floats rela- than to switch on. Resistors R25 and R26
limit the charge and discharge currents
to and from the gates of the power MOS-
FETs. The short-circuit current ratings of
Measured performance the driver outputs are 1 A for sourcing
Measured with the 6/8 Ω version and ±60 V supply voltages and 1.2 A for sinking. With a value of
(Hypex SMPS400A400), BW = 22 kHz, R7 = 100 kΩ 18 Ω for R25 and R26, the peak charge
and discharge currents are limited to
• Input sensitivity: 1.3 V (189 W / 8 Ω, THD+N = 1%)
about 0.5 A.
1.25 V (174 W / 8 Ω, THD+N = 0.1%)
• Input impedance: 3.33 kΩ / 11 kΩ
Voltage divider R17/R18 determines the
• Continuous output power: 174 W into 8 Ω (THD+N = 0.1%, 1 kHz)
low-side current limit. Here the on resis-
189 W into 8 Ω (THD+N = 1%, 1 kHz)
tance (RDS(on)) of the MOSFETs is used for
224 W into 6 Ω (THD+N = 0.1%, 1 kHz)
current sensing. The positive tempera-
246 W into 6 Ω (THD+N = 1%, 1 kHz)
ture coefficient of RDS(on) has the advan-
• Power bandwidth: 5 Hz (–3 dB) to 20 kHz (–1 dB) tage that the current limit level decreases
• Slew rate: 15 V/µs (8 Ω) when the temperature of the MOSFETs
• Rise time: 4.4 µs (8 Ω) increases. The IRS2092 has an internal
• Signal to noise ratio: >77 dB (linear, BW = 22 Hz to 22 kHz) 5.1 V reference voltage (VREF on pin 7)
(reference 1 W / 8 Ω) >80 dBA for precise setting of the current limit.
• Total harmonic distortion plus noise: 0.014% (1 kHz, 1 W / 8 Ω) Unfortunately, the drain-source resis-
(BW = 22 kHz) 0.004% (1 kHz, 50 W / 8 Ω) tance of MOSFETs has a fairly high tol-
0.024% (1 kHz, 1 W / 6 Ω) erance. With a gate-source voltage of
0.0046% (1 kHz, 50 W / 6 Ω) 10 V, the RDS(on) of the MOSFETs used
• Intermodulation distortion: 0.013% (1 W / 8 Ω) here is 80 mΩ typical and 100 mΩ max-
(50 Hz / 7 kHz, 4:1) 0.023% (50 W / 8 Ω) imum (at 25°C). At 125°C, RDS(on) rises to
0.013% (1 W / 6 Ω) more than 175 mΩ. In our design we set
0.017% (50 W / 6 Ω) the current limit voltage to 1.56 V, which
• Dynamic IM distortion: 0.037% (1 W / 8 Ω) puts the current limit at 19.5 A (typical)
(3.15 kHz square wave / 0.009% (50 W / 8 Ω) at a junction temperature of 25°C. At
15 kHz sine wave) 0.043% (1 W / 6 Ω) 125°C the limit level drops to approxi-
0.008% (50 W / 6 Ω) mately 8.7 A. If the output current is too
• Damping factor: 174 (1 kHz, 8 Ω) high, the IRS2092 shuts down and the
• Efficiency at full power: 93% with 8 Ω load
LO and HO outputs are set low to protect
the MOSFETs.
(THD+N = 0.1%) 94% with 6 Ω load
• DC protection: +3 V / –4 V
The high-side current limit is set using
• DC output offset: <0.3 mV
the CSH input (pin 16). This pin has a
• Switch-on delay: 6s
fixed threshold voltage of 1.2 V relative
to VS (pin 13). For high-side current lim- amplifier with a 4 Ω load, it will frequently protect the connected loudspeaker. The
iting, a blocking diode (D7) is necessary go into current limiting with ±60 V sup- DC protection circuit reacts at a DC level
in addition to the voltage divider in order ply voltages. In that case it is better to of a few volts. A relatively high value was
to protect the CSH pin against high volt- modify the amplifier and use different chosen for this because there is always
age when the high side is switched off. supply voltages, as described in the “4 Ω some DC voltage present at the out-
The 0.6 V forward voltage drop over D7 Configuration” inset. put when no load is connected and the
increases the drain-source voltage of the IRS2092 is shut down. Apparently there
high-side MOSFET by 0.6 V. Resistor R24 Protection is a leakage current from the VS pin when
provides a bias voltage for D7 when the To supplement the built-in protection the IRS2092 is in shutdown mode.
high-side MOSFET is switched on. Volt- of the IRS2092, we added a number of
age divider R22/R23 reduces the voltage external protection circuits: overvolt- The DC protection circuit consists of R38,
over the high-side MOSFET and D7. All age protection for both supply voltages, R39, R40, C34, T6 and T7. Voltage divider
this means that if you want to set the undervoltage protection (also for both R39/R40 determines the trip levels. With
same limit level here as for the low side, supply voltages), and DC protection with the indicated resistor values, they are
you have to take D7 into account. That switch-on delay. Each of these protection +3 V and –4 V. Although the selected
yields a value of 10 kΩ for R23 and 8 kΩ circuits can de-energize the output relay levels are somewhat higher than usual,
(adjusted to 8.2 kΩ) for R22. See the and shut down the IRS2092. they should not be harmful to the loud-
description of this amplifier on the Elek- The DC protection circuit
tor Labs website [4] for the calculation. ensures that the output
The PWM signal at the output of the is switched off if the DC
MOSFETs is filtered by a second-order voltage at the output is
filter consisting of toroidal inductor L1 too high, in order to
and capacitor C29. It is followed by a
Boucherot network (R28/C30), which pro-
vides an output load for the amplifier at
high frequencies.
Component List
Resistors 5x11 mm, 2mm pitch IC4 = MC7905ACTG
Default: 5%, 0.25W C15 = 10nF 10% 100V, X7R, 0.2’’ pitch IC5 = MC7812CTG
R1,R8 = 1kΩ C17,C19,C33 = 1µF 20%, 50V, 5x11 mm,
R2,R23,R24,R30,R34,R36,R37,R46,R50,R54 2mm pitch Miscellaneous
= 10kΩ C21 = 22µF 20%, 50V, 5x11 mm, 2mm pitch K1,K2,K3,K4,K5 = Faston spade connector,
R3,R20 = not mounted C22,C24 = 100nF 10%, 250V, MKT, 4x10 mm, PCB mount, dim. 6.35x0.81 mm, 0.2’’ pitch
R4 = 2kΩ 1% 7.5mm pitch (TDK type B32520C3104K000) JP1,JP2 = 3-pin pinheader, 0.1’’ pitch, with
R5 = 330Ω C23,C25 = 680µF 20%, 100V, 28mΩ @ 2.57A, jumpers
R6,R18 = 3kΩ 1% 18x40 mm, 7.5mm pitch (Rubycon type RE1 = relay, PCB mount, SPCO, 16A,
R7,R52 = 120kΩ 100ZL680MEFC18X40) 48V/5.52kΩ (TE Connectivity/Schrack type
R9 = 470Ω C26 = 100nF 10%, 200V, X7R, 0.2’’ pitch (Ke- RT314048)
R10,R11,R15,R31 = 10Ω met type C330C104K2R5TA) HS1 = heatsink, PCB mount, 2.6K/W, mount-
R12,R13 = 1.8kΩ, 2W C27,C28,C30 = 100nF 5%, 400V, poly- ing pins spaced 1 inch (Aavid Thermalloy
R14 = 2.2kΩ propylene, 15mm pitch (TDK type type 530002B02500G)
R16 = 4.7Ω B32652A4104J000) Heatsink for IC4/IC5/T2: 27x90 mm alumi-
R17,R35 = 6.8kΩ C29 = 470nF 5%, 400V, polypropylene, 15mm num sheet, 2mm thick
R19 = 5.6kΩ pitch (TDK type B32652A4474J000) Heatsink for IC3: 30 x 30 mm aluminum
R21 = 33kΩ C34 = 100µF 20%, 10V, bipolar, 2.5mm or sheet, 1mm or 2mm thick
R22 = 8.2kΩ 3.5mm pitch, diam. 8mm max. Isolation materials for T2,IC3,IC4,IC5 (TO-220
R25,R26 = 18Ω C35 = 2.2µF, 50V, 5x11 mm, 2mm pitch thermal pad + TO-220 bush)
R27 = 1Ω, 1 W 6 pcs solder pin, 1.3mm diam.
R28 = 10Ω 1W Inductor 1 pc DIP-16 IC socket
R29 = 2.2kΩ, 2W L1 = 22µH, Micrometals type T130-2 ring 1 pc DIP-8 IC socket
R32,R40 = 4.7kΩ core, max. 20x40mm. Wire: 200cm of Kit of parts incl. PCB 150115-1 (mono), excl.
R33,R43 = 15kΩ 1.5mm/AWG15 enameled copper supply: Elektor Store # 150115-71
R38,R39,R45,R48,R51 = 22kΩ PCB # 150115-1, available separately and
R41 = 1MΩ Semiconductors optionally
R42 = 10MΩ D1,D2,D11,D13,D14,D17 = 1N4148
R44 = 2.7kΩ D3,D8,D9 = 1N4007
R47 = 150kΩ D4,D5,D10 = BZX85C18 SB00018/E1, Ancillaries for Hypex SMPS400A400 PSU
R49 = 820kΩ 18V/1.3W zener diode connection
R53 = 47kΩ D15,D16 = BZX55C68-TR, 68V/0.5W zener di- 1 pc JST VHR series 5-way straight case for
P1 = 1kΩ trimpot, top screw adjustment ode (alternatively, NXP type BZX79-C68) PCB connector, 3.96mm pitch (RS Compo-
D6 = MUR120G (200V, 1A) nents # 820-1188, set of 5 pcs)
Capacitors D7 = BAV21 (250V, 250mA) 1 x JST VHR series 3-way straight case for
C1,C5,C7,C8,C9 = 1nF 1%, 63V, polystyrene, D12 = LED, green, 3mm PCB connector, 3.96mm pitch (RS Compo-
7.18mm pitch (LCR Components type EXFS/ T1 = IRFI4020H-117P nents # 820-1175, set of 5 pcs)
HR 1000pF ±1%) T2 = TIP122G 5 x JST cable set with crimp connectors at
C2,C3,C11,C13,C16,C18,C31 = 100nF 10%, T3,T4,T6,T7,T9,T10,T11,T12 = BC547C both sides (RS Components # 820-1135, set
50V, X7R, 0.2’’ pitch T5 = BC557C of 5 pcs)
C4 = 10µF 10%, 63V, MKT, 15mm pitch T8 = IRFD210PBF 3 pcs isolated Faston connector, female, 0.25’’
C6 = 150pF 5%, 500V, silver mica, 5.9mm IC1 = AD8031ANZ pitch
pitch (Cornell Dubilier type CD15FD151JO3F) IC2 = IRS2092PBF
C10,C12,C14,C20,C32 = 10µF 20%, 50V, IC3 = MC7805CTG
+2
Test equipment: Audio Precision System Two Cascade +1
-1
-2
-3
d
Plot A B
r
-4
-5
This shows the measured amplitude versus frequency with load A
-6
impedances of 4, 6 and 8 Ω. In the 20 kHz region the curves show that -7
-8
the dimensioning of the output filter is a good compromise for the different -9
-10
impedances. The deviation from 10 to 20 kHz is approximately ±1 dB. -11
With 8 Ω (cyan) the resonant frequency of the output filter is clearly A
-12
10 20 50 100 200 500 1k 2k 5k 10k 20k 50k 100k
Hz
visible. With 6 Ω (green) the curve is nearly flat, and with 4 Ω (blue) the
corner frequency is somewhat lower. Audio Precision
10
Plot B 1
0.5
THD+N at 1 W and 50 W with an 8 Ω load and measurement bandwidths 0.2
0.05
are usually not shown in data sheets for class-D power amplifiers because
0.02
the effect of the switching frequency increases with greater bandwidth. 0.01
However, the amplifier does produce output signals above 22 kHz, so 0.005
0.002
showing what happens above that frequency is only fair, even if you 0.001
B
20 50 100 200 500 1k 2k 5k 10k 20k
cannot hear it. The red curve shows the THD plus noise at 50 W, measured Hz
with a bandwidth of 22 kHz. The blue curve was measured at the same
power level but with a measurement bandwidth of 80 kHz. The cyan curve Audio Precision
+0
shows the THD plus noise at 1 W with a bandwidth of 22 kHz, and the -10
yellow curve show the THD plus noise at 1 W with a bandwidth of 80 kHz.
-20
-30
All measurements were made using a ninth-order elliptical low-pass filter -40
-50
with a corner frequency of 200 kHz ahead of the analyzer input to block -60
d
B -70
residual PWM noise from the amplifier. r
-80
A
-90
-100
-110
Plot C -120
-130
FFT of a 1 kHz signal at 1 W into 8 Ω. Hardly any harmonics are visible, -140
C
-150
although the second harmonic can be seen in the noise of you look closely. 10 20 50 100 200 500 1k
Hz
2k 5k 10k 20k 50k 100k
The TDH+N is 0.014% and consists almost entirely of noise. In this FFT
plot and the next one, the switching frequency of the Hypex power supply Audio Precision
+0
-20
ranges from 80 to 120 kHz), but the level is so low (–82 dB) that it is not -30
-50
-60
d
B -70
r
-80
A
Plot D -90
-100
The same FFT measurement as plot C, but with a power level of 50 W -110
-120
into 8 Ω. Here some harmonics are visible. The THD+N is 0.004%, and -130
the switching noise from the power supply has dropped to an insignificant -140
D
-150
Audio Precision
Plot E 10
5
THD+N versus output power (1 kHz / 8 Ω, BW = 22 kHz). The 2
50 W. The amplifier can comfortably deliver 200 W with the nominal % 0.1
0.05
0.002
0.001
1m 2m 5m 10m 20m 50m 200m 500m 1 2 5 10 20 50 100 300
E W
with a thickness of 1 mm. An area of First check that the leads are properly filter does not cause much distortion. The
30 x 30 mm is sufficient. The metal positioned in the holes without twisting, downside of this core material is its low
mounting tab of the IC is connected to and then tighten the screw firmly. After permeability, which means a lot of turns
ground, so the IC does not need to be this, solder the MOSFET leads to the PCB. have to be wrapped on the core to obtain
insulated from the heatsink. Mount the the necessary inductance.
heatsink plate on the voltage regulator Output inductor You need 2 meters (approx. 7 feet) of
so it is a few millimeters above the sur- The most difficult component in this proj- 1.5 mm enameled copper wire (15 AWG)
face of the board. Also make sure that ect (in terms of construction) is the induc- for the winding, and you have to wind 45
the mounting hole in the corner of the tor of the output filter. You have to wind turns on the core. They will not fit in a
board remains accessible (see Figure 4). it by hand on a toroidal core with a diam- single layer on the inner circumference
IC4, IC5 and T2 are all mounted on an eter of 33 mm (1.3 inch) using 1.5 mm of the core, so the coil must be wound
aluminum plate 2 mm thick with dimen- enameled copper wire (15 AWG). The in a special way to keep the parasitic
sions of 27 x 90 mm, with one end bent core is an iron powder type from Micro- capacitance low. The turns of the sec-
at a right angle 65 mm from the end (see metals. We chose this core ond layer of the winding are placed on
Figure 4 again). To avoid contact with for its linear character- top of the turns of the first layer on the
other components, mount the heatsink istics, so that the inner circumference of the core. On the
on these three components so it is outer circumference, the turns of the sec-
at least 5 mm above the surface of ond layer are placed next to the turns
the board. All three components must of the first layer. The turns of the
be insulated, and two of them (IC5 third layer are placed next to the
and T2) are mounted opposite each turns of the first layer on the
other and secured by the same screw. inner circumference, and next
The two holes in the plate are spaced to the turns of the
4 Ω Configuration
second layer on the outer circumference. PCB and solder it in place. usual, so we measured output voltages of
Repeat this procedure for the fourth layer. That completes the assembly of the cir- ±60 V). With this power supply the ampli-
After you have wound 45 turns on the cuit board. fier is suitable for loads from 6 to 8 Ω.
core this way, the ends of the copper For lower load impedances it advisable to
wire will be located opposite each other Power supply and enclosure modify the amplifier (see the inset), as
on either side of the core. You may have Next you have to fit the board and its otherwise the protection circuit will trip
to improvise or make a few adjustments power supply into a suitable enclosure. occasionally during high-power passages.
to get all 45 turns on the core this way, Although it is possible to use a conven-
but hopefully you understand what we tional power supply with a hefty power In Figure 6 you can see how we fit-
mean. Have a look at the picture of the transformer, bridge rectifier and filter ted two amplifier boards and two Hypex
finished coil in Figure 5. We should warn capacitors, that doesn’t really fit with a power supplies into a standard enclosure.
you that 1.5 mm copper wire (15 AWG) modern class-D amplifier. Furthermore, There is not much wiring in the enclo-
is fairly stiff and not easy to bend. Work the measured performance of the D-Watt sure because everything is located on a
carefully and wind the wire as tightly as Amp is significantly better with a regu- single PCB.
possible against the core, but do not use lated power supply. For that reason, we
any metallic tools due to the risk of dam- used switching power supplies from the We hope you enjoy building and using
aging the insulation of the wire. Dutch company Hypex in our prototype. this cool high-power amplifier. More
They are specifically designed for use with detailed information about the ampli-
When you are done, you will have a coil class-D power amplifiers. We chose the fier, along with even more measurement
with an inductance of SMPS400A400, which can supply 400 W data, is available on the Elektor Labs
22 µH and a resistance at 20 Hz with nominal output voltages website [4].
of about 20 mΩ. Now of ±64 V (the mains voltage (150115-I)
you can mount it in our lab is a bit
vertically on the lower than
Figure 6. Two amplifier boards and two switching power supplies fitted
in an enclosure.
Web Links
[1] www.elektormagazine.com/magazine/elektor-201309/23330
[2] www.infineon.com/dgdl/irs2092.pdf?fileId=5546d462533600a401535675f1be2790
[3] www.infineon.com/dgdl/an-1138.pdf?fileId=5546d462533600a40153559a077610d1
[4] www.elektormagazine.com/labs/200w-class-d-audio-power-amplifier-150511
By Burkhard Kainka (Germany) actual sensor in a voltage divider that this time is preset with a
25-turn precision trimmer pot. A second voltage divider made
up from two 100 kΩ resistors provides a reference voltage of
A glance at the sensor combo kit (available from Elektor [1]) 2.5 V for the comparator. The temperature sensor (Digital Temp)
reveals seven superficially identical PCBs equipped with differ- can now be adjusted so that the sensor voltage at the desired
ing sensors. All of them have one analog output AO and one temperature will likewise be exactly 2.5 V. A rising tempera-
digital output DO. As you know, to create a digital signal from ture at the NTC sensor makes the comparator switch on the
an analog one, we use a comparator. There is one of these digital output DO, whilst a falling temperature switches it off.
included on each of these boards, or more precisely an LM393 The second comparator connected downstream operates only
dual differential comparator. the status LED. Thanks to these LEDs we can test all seven
sensors without any need for software.
Sensors equipped with comparators
When we examine the circuit of the board in Figure 1 more The circuit does not include a bypass capacitor (see inset),
closely, its function becomes clear. Once more we find the meaning that any variations or spikes on the supply voltage
may affect the operation. The length of the wiring and other
random factors can also have some influence. In actual fact with
the temperature sensor and the heat rising, we find a narrow
region in which the output oscillates, which is possibly caused
by parasitic capacitance on the PCB. If we fit a small capaci-
10k
100k
tor between the input and the second comparator output, we
100k DO
A1
½ LM393 can see an oscillator in action. This is easy to recognize with
½ LM393 the oscilloscope. The status LED on the sensor PCB shows it
1k
1k
+5V
as well. When things warm up slowly, it lights up initially at
half brightness (state of oscillation) and only after this does it
1k5
G
GND
reach full brilliance (stable condition). If the software behaves
AO
A2 strangely, bear this point in mind.
100k
-T NTC The other sensors using this circuit behave in more or less
the same way, even if the changes in the measured value are
Digital Temperature usually not so gradual. Most comparable with the NTC sensor
+5V is the phototransistor in the flame sensor. The dark housing
allows the longer wavelengths to pass through preferentially, in
order for flames to be detected. The Hall sensor differs in that
S N it expects an operating voltage on its third pin. The fact that
the reed switch is connected as an analog sensor may surprise
MPSA13
you. But there are two out-of-phase outputs. When a magnet
Linear Hall Reed Switch Sound Touch Flame is brought closer, one output goes on and the other goes off.
Sound and touch behave somewhat differently; normally they
deliver a squarewave signal with rapid transitions. The two
sound sensors employ one large and one small electret micro-
phone. With the pot adjusted correctly, half waves of loud sound
Figure 1. Sensors with comparators. signals appear at the output as square waves. This must be
Bypass capacitors
100k
1k
+5V
comes into play but also the inductivity. A piece of twin- Bypass
10n
1k5
G
conductor cable 1 m long can have an inductance of around GND
-T NTC
has a varying current load, effectively you have an alternating
current in the supply lead and with this some voltage
Digital Temperature
drop. Typical problems with voltage drop of this kind are
susceptibility to radio interference and vulnerability to failures
in the passive elements of the circuit. The long (from a radio
perspective) cable can also act as an antenna. Then you have between GND and VCC, as otherwise they would not pass
radio-frequency (RF) signals radiating that potentially may their test for electromagnetic compatibility. In this case they
exceed the permitted limits. Conversely pulses of interference are usually called decoupling capacitors, because any radio-
may induce brief fluctuations in the supply voltage that might frequency currents can be diverted or decoupled by taking a
interfere with the correct functioning of a circuit. shortcut through this capacitor mostly commonly of 100 nF.
The older expression ‘blocking capacitor’ used for these
DC motors will produce a varying load on the current source components has fallen out of fashion.
and can lead to radio interference. This is why capacitors are
connected direct to the supply terminals and are generally Our sensors are all definitely not particularly susceptible to
called anti-interference or suppressor capacitors. The DC interference problems of this kind. If you do wish to employ a
motor in an RC model cannot function without these, as cable longer than 12 inches (30 cms), you should connect a
otherwise it would interfere with its own receiver onboard. bypass capacitor of 100 nF direct to the sensor between the
Microcontrollers like the Arduino also require a capacitor supply terminals (see image).
Software-based
Schmitt trigger
+5V
+5V When you have a transition
region a comparator can gen-
10k
10k
10k
erate highly volatile output
SMD RGB LED
DO DO DO
states. A Schmitt trigger helps
R
DO
91R
mitigate this by displacing
G Laser
the transition points that set
Komparator
B the switch-on and switch-off
points. An example is switch-
G
G G G ing on at 25 degrees Celsius
Sensor 1 Sensor 2 Sensor 3 and off at 20 C, as discussed
regarding the NTC sensor
(Analog Temp) in first part of
Figure 2. Direct connection to RGB LED. Figure 3. The laser on the
this series.
comparator output.
from the A-D converter (as always, all of the code samples can
be downloaded from the Elektor Magazine website [3]). The
center of the measurement range represents a value of 512.
The switching threshold points in this example lie at 509 and
515. With around 5 mV per A-D step we then have a hysteresis
of 30 mV. The program also controls LED2 on the Extension
Shield. This means you can compare the switchover with that
on the sensor board yourself. The software offers two slightly
displaced switchover points as opposed to the sharply defined
switching point of the sensor-comparator. The complete pro-
gram additionally displays the analog sensor voltage, both on
the LCD of the Shield and on the terminal screen. This helps
you find the correct trimmer setting.
Oscillators
One of Murphy’s Laws states that when input voltage will make the output voltage
you construct an oscillator it never drop. All the same, you can build an
oscillates, whereas when you make oscillator with only one transistor. All
an amplifier it oscillates all the time. you need do is ensure that the phase is
There’s something in this observation, reversed accordingly. You can do this, for
which is why it’s always worth looking instance, using several capacitors and
closely when your circuit turns into an resistors (phase-shift oscillator). Or use
oscillator and ‘starts to hoot’ as people 0V7...5V a transformer for the feedback (Meissner
say. An oscillator consists fundamentally oscillator). If the oscillator still observes
of an amplifier and some matching Murphy’s Law and doesn’t oscillate, all
feedback from the output to the input. you normally need to do is reverse one
The signal fed back must moreover have of the two windings to get the phase
the correct phase relationship. If the right. So it’s likely that the small buzzer
voltage at the input rises directly, the is constructed in this way (image). The
same should happen at the output, only ‘loudspeaker’ has two windings, which at
correspondingly amplified. Then it’s sufficient to feed back a the same time make a transformer.
part of the output signal to the input using a capacitor — and
now you have an oscillator. If you construct an amplifier with multiple stages and higher
overall gain, it may actually be not that easy to prevent self-
An amplifier of this kind can be constructed with two oscillation. Signals from the output can sneak back to the
transistors, in which both of them rotate the phase by input via the supply voltage, which you may be able to avoid
180 degrees. Or you can use an op-amp or an integrated using a fairly large bypass capacitor. Or some small capacity
loudspeaker amplifier. may exist between the output and input wiring. In extreme
A single amplifier stage with one transistor in grounded cases the only remedy that can still solve this problem is a
emitter mode turns the phase through 180 degrees. Rising physical screening (shielding) plate.
10k
to do rather more, namely switching something on. This is
entirely feasible if we write our program somewhat differently.
AC AC
10p 10p
To manage this, all we need do is make sure that the switch-
CMOS-Input
ing-on process takes precedence and switching-off takes place
after a short delay. Our Touch programs (Listing 5 and List-
ing 6) additionally employ a delay period of 10 µs and conse-
GND GND quently interrogate the Port very frequently. Once a High state
Figure 5. Contact sensor with Figure 6. Input Port used as contact Listing 3. Input and output Port in Bascom.
Darlington transistor. sensor.
Dim D As Boolean
Config Portb = Output
where the Arduino-internal LED is located. Externally you can
also hook up another LED or the laser light. Do
The program consists of a simple loop that has a waiting time Portb.2 = Pinc.1
of 21 ms built in. If you now tap the touch sensor, the output D = Pinc.1 Xor 1
flashes. What actually happens is that touching it applies a 50
Portb.5 = D
Hz interference signal to the base of the Darlington transis-
Waitms 21
tor. Therefore we get a 50 Hz squarewave signal on the digital
Loop
output, i.e. a cycle duration of 20 ms. If we now sample this
signal using a slightly different frequency, you obtain a signifi-
cantly smaller frequency. The cycle duration 21 ms indicates
Listing 4. Input and output Port using Arduino-C.
a sampling frequency of around 48 Hz. The difference 50 Hz
– 48 Hz = 2 Hz appears in antiphase at outputs B2 and B5. //Touch1 A2 > 10, 13
It may not be self-evident that we can control a transistor in #include <LiquidCrystal.h>
this manner. Usually we specify a base current and determine int input = A2;
the bias point in this way. With small signals, things would not int output1 = 10;
work without base current. The person touching the sensor is
int output2 = 13;
seen as one plate of a capacitor, with the second plate formed
by all the wires and cables located in the environment. A base
void setup() {
current would charge this capacitor so far negative that the
pinMode(output1, OUTPUT);
transistor would block completely. It works only because every
bipolar transistor contains a zener diode in the range 7 V to pinMode(output2, OUTPUT);
10 V between base and emitter (see Figure 5). The idle state }
mains hum voltage of a person is generally significantly higher void loop() {
than 10 Vpp. Therefore an alternating current flows, with its digitalWrite (output1, digitalRead(input));
positive half-wave driving the transistor. digitalWrite (output2, 1-digitalRead(input));
delay(21);
You might expect that on the collector of the Darlington tran- }
sistor we would also find an approximately equal squarewave
signal. So let’s also try coupling the analog output AO to the
digital input A1. That’s right; now the output flashes when the Listing 5. Contact sensor and touch switch
base is touched. However, the difference is that this time the (Touch2.bas).
output in idle mode is ‘on’, because the comparator on the
Dim T As Word
sensor board inverts the signal.
It even works without the sensor board. At input A1 we have Config Portb = Output
just a piece of insulated wire connected (Figure 6). If you
then touch the outside of this insulation, it still flashes! This Do
happens because the input of the controller has extremely high If Pinc.1 = 1 Then T = 50000
impedance. The wire, insulation and finger form a small cou- 'If Pinc.1 = 0 Then T = 50000
pling capacitor of a few picofarads in value. If an AC voltage If T > 0 Then T = T - 1
is applied to the input, it is limited to the input voltage range If T > 0 Then Portb.2 = 1 Else Portb.2 = 0
by the internal protection diodes. The open input does admit- If T > 0 Then Portb.5 = 0 Else Portb.5 = 1
tedly have a disadvantage compared to the correct touch sen-
Waitus 10
sor. The idle state is not unambiguous, you see, which makes
Loop
evaluation tricky.
is detected, the program sets counter T to a value of 50000 two sound sensors in the Sensor Kit, with which, according to
and switches on the output. The counter decrements slowly the sound frequency being sampled, up to 10 kHz or more can
and only after about 500 ms without any further pulse does the appear on the output. Correct adjustment of the trimpot will
output switch off. Any further impulse that occurs will reset the give you a very usable speech switch that will also react to loud
counter High again and the timeout period is extended accord- whistling, hooting or other noises. Even gentle tapping your
ingly. Now everything functions as desired. The output goes on finger on the microphone will set off the switch. The sensitiv-
immediately if someone touches the sensor and goes off again, ity depends very much on the precise setting of the pot. You
not when the contact ceases but after some delay. The func- need to keep in mind that this type of microphone normally
tion corresponds to a retriggerable monostable multivibrator. delivers less than 1 mV. This means you must maintain the
Now our touch sensor, with its Darlington transistor, is working sensor voltage to the switching point within a few millivolts of
the way we want it to. The squarewave signal on the digital accuracy in order for sound signals to make the comparator
output has been transformed into an unambiguous switching change level correctly.
signal that will work even in environments without mains hum.
Short pulses caused by static charge are sufficient to trigger Shock sensor
the output. Certain other digital sensors, such as the Tap Module, are
appropriate for this kind of sampling. This contains a spring
There’s a special reason why we chose the loop delay of 10 µs that can close a contact when disturbed. Two very brief pulses
to be much smaller than necessary for a 50 Hz signal. The for- are produced in this process. You need to be aware that the
mat of the program makes it equally suitable for use with the module has a pull-up resistor, meaning that the output volt-
age is +5 V when not operated and the pulses are 0 V. In this
situation the sampling process needs to invert the input sig-
nal, which is marked in the software with a commented line.
Listing 6. Touch switch in Arduino-C.
Alternatively in this case you might also connect +5 V and GND
void loop() { transposed and leave the software unaltered, as the polarity
if (digitalRead(input) == 1) timeout = 50000; is of no interest to the switch and resistor.
//if (digitalRead(input) == 0) timeout = 50000;
if (timeout > 0) timeout = timeout -1; The Shock Sensor was tested in the same way, in which an
if (timeout > 0) { internal contact is closed for a short duration each time it is
digitalWrite (output1 , 1); disturbed. The sensitivity of the Shock Sensor is greater than
digitalWrite (output2 , 0); that of the Tap Module. The Tilt Switch (ball switch) can also
be sampled in this manner. At the right degree of inclination
}
a small ball rolls downwards and closes two contacts. If you
else {
shake the sensor rapidly to and fro, you can hear the ball rat-
digitalWrite (output1 , 0);
tling and watch the program triggering the output.
digitalWrite (output2 , 1);
} In point of fact all switching sensors can be polled or sam-
delayMicroseconds(10); pled meaningfully using this method, as well as press buttons
} (Button), reed switches (Mini Switch) and the reed switch on
the comparator board. Using this type of time delay we can
achieve effective debouncing of the switches. Just about every
mechanical switch (apart from mercury switches, which are
Listing 7. Additional serial output. now banned in many territories, however, on account of the
void loop() { poisonous mercury in them) bounces momentarily one or more
if (digitalRead(input) == 1) timeout = 50;
times when operated, generating several impulses to begin
with. The software turns this into a single, elongated pulse. If
if (timeout > 0) timeout = timeout -1;
you alter the period somewhat you can make a time switch,
if (timeout > 0) {
for instance to illuminate a staircase at night. The light can
digitalWrite (output1 , 1);
then be activated, according to the type of sensor, by loud
digitalWrite (output2 , 0); speech, touch, tapping or advancing a magnet. Even the digital
} output of the temperature sensor could be polled in this way.
else { This would simultaneously eliminate the problem of fluttering
digitalWrite (output1 , 0); transitional states between Low and High.
digitalWrite (output2 , 1);
} With a minor alteration (Listing 7) the function of a compara-
Serial. tor sensor could also be made clearer using the serial monitor.
println(analogRead(sensorPin)+100*digitalRead For this we additionally make use of the analog signal at AD2,
(output1));
while the digital output signal of the comparator carries on with
the task of triggering the actual switching process. To display
delay (20);
the output signal with only one channel, we raise the output in
}
a High state by 100. You can then observe the original analog
12 (GND)
between red, green and blue. This is another case requiring
R
a dropper resistor, since color-change LEDs of this kind are in V
fact designed for 3 V. Incidentally, although there is indeed 10
Incidentally, the internal controller of the color-change LED, like Web Links
most ICs, includes an inverse polarity-protection diode on its [1] www.elektor.com/arduino-sensor-kit
supply voltage connections and therefore reacts sulkily if you
[2] www.elektormagazine.com/160152
reverse the supply connections. Without the dropper resistor
a reversed power connection could lead to destruction. This [3] www.elektormagazine.com/160173
is vitally important: GND lies in the middle of the three con-
nections. By the way, just for fun, you can also connect the
passive mini-speaker in series. Then you can not only see the
switching process but also hear it.
(160173)
MAXREFDES99#
Display Driver Shield
256 LEDs at your command
By Clemens Valens (Elektor Labs)
The Shield…
… RD99 for friends, is an Arduino compatible extension
board sporting a 16x16 LED array (actually four 8x8 LED arrays) Arduino sys-
and the necessary drivers for it. The 7.7 x 7.7 cm (3 x 3”) tems, indicates the I/O voltage level
square board is intended for signage applications and its 256 of the host system. A level shifter automatically adapts
LEDs probably allow displaying any international alphanumeric to this voltage making the shield suitable for systems with I/O
character that you can think of. It can also display scrolling signal levels as low as 1.2 volts.
messages in a 5x7 font, or some other font. What exactly it Communication with the host system requires only three sig-
shows is up to you. nals: clock (rising edge on ‘D13’, H4, pin 5), data (‘D11’, H4,
The shield is supported by open-source software libraries (C++) pin 7) and a load signal (rising edge on ‘D10’, H4, pin 8).
for both the Arduino and ARM mbed rapid development plat- These signals are compatible with 16-bit SPI busses where
forms. The libraries not only take care of the low-level commu- the Slave Select (SS) signal can be used as the load signal.
nication with the display, they also offer high-level functions Add to these signals a reset line (active low, H3, pin 3), the
for displaying all printable ASCII characters from ‘space’ (32) IOREF voltage and power, and you know that the all singing,
to ‘~’ (126) and for scrolling text messages. all dancing interface needs eight connections.
The shield must be powered from 5 VDC, supplied by either the
host system or the on-board power supply, depending on the The MAX7219
position of switch SW1. The input voltage for the on-board The RD99 has four MAX7219 LED display drivers, one for each
regulator is limited by the maximum voltage allowed on the VIN 8x8 LED matrix. Each part is capable of driving up to eight
pin (connector H3, pin 8) of the host system or by the voltage 7-segment displays (with decimal dot) or up to 64 individual
rating of C1 (25 V), whichever is lowest. For an Arduino Uno LEDs. The MAX7219 includes a BCD code-B decoder, multiplex
R3 host this is 20 VDC, although it is recommended limiting it scan circuitry, segment and digit drivers, and an 8x8 bit static
at 12 VDC. The kit comes with a 9 VDC 1.3 A wall-mount power RAM to store the value for each LED. A serial interface allows
adapter with American-style pins, which is a bit of a shame programming the device’s registers and, of course, activating
since it accepts anything from 100 to 240 VAC as input. or deactivating individual LEDs. Individual digits (or groups of
The RD99 monitors the IOREF pin (H3, pin 2), the pin that, in eight LEDs) may be addressed and updated without rewriting
the entire display. The integrated BCD decoder may save some
work upstream but can be deactivated when it is not needed.
The brightness of all LEDs is controlled by a single external
resistor that sets the current flowing through them; four of
these control the four 8x8 LED matrices. Display brightness
can also be set digitally (PWM) by using the intensity register.
A convenient 4-wire serial interface permits easy connection to
a microcontroller. The serial protocol is very similar to 16-bit
SPI. If the microcontroller’s SPI peripheral is not capable of
controlling the MAX7219 (because it is 8-bit only) then it is
easy enough to bit-bang the data into the device as there are
no strict timing constraints. The only thing to keep in mind
is that data always passes through the chip’s internal shift
register no matter what the state of the LOAD pin is. A rising
edge on this pin will load the data from the shift register into
internal memory and update the display, so be careful to load
at the right moment.
AxiCat
A versatile USB development tool
an actual design. That’s easy jumper JP1. For that reason we opted for
with the AxiCat multi-protocol USB a 12 MHz clock crystal instead of a higher
adapter, and you don’t have to write any frequency, to ensure that the microcon-
code to use it. troller remains within its safe operating
Nowadays there area with a 3.3 V supply voltage.
are thousands of useful Schematic and structure The USB connection is handled by IC2,
ICs available to electronics hobbyists and The key component of the circuit, an FT245RL from FTDI. Unlike the bet-
professionals. A lot of them only come in as shown in Figure 1, is an Atmel ter known FT232RL, this device does
SMD packages, which are not very con- ATmega164A microcontroller (IC1). You not have a serial interface, but instead
venient for hobbyists, but don’t worry: can also mount other members of the an internal FIFO with an 8-bit data bus.
many well-known (and less well-known) same microcontroller family, such as the The advantage of this is that with Full
vendors who focus on the hobby sec- ATmega324A, 644A and 1284. The only Speed USB and a 12 MHz clock frequency,
tor offer a broad spectrum of breakout difference is the amount of internal mem- you can achieve a respectable data rate
boards. Most of these ICs have an I2C ory. The AxiCat normally comes with an between the USB bus and the microcon-
or SPI interface, and it would be handy ATmega164A or an ATmega324A, depend- troller (IC1).
if you could quickly connect them to a ing on availability. Thanks to the underlying layers of the
Linux or Windows PC to check out their The microcontroller is powered from 5 V USB communication protocol between
functions before you start using them in or 3.3 V, depending on the position of the driver in the host system and the
FT245RL, the data arrives in the FIFO of
the FT245RL without any bit errors. This
Features means that the data read by the micro-
controller is error-free, and the data out-
• Based on a powerful ATmega164A microcontroller clocked at 12 MHz
put by the microcontroller also arrives in
• Compatible with Windows and Linux
the host system free of errors, eliminating
• Selectable 3.3 V and 5 V logic levels
the need for error correction in the com-
• 17 bidirectional I/O lines with configurable pull-up
munication protocol. That also pays divi-
• I2C bus with pull-up resistors, master and slave mode; maximum speed 400 kHz
dends in terms of speed. IC3, a USB6B1,
• SPI master with four slave select lines; maximum speed 6 MHz
protects the bus lines against ESD, mak-
• Two independent serial ports
ing the board significantly more robust.
• 1-Wire master with strong pull-up option and built-in accelerators for
The 3.3 V supply voltage is provided by
enumeration
IC4, an LM1117-3.3 low-drop voltage reg-
• Powered over the USB bus
ulator. This voltage is available on GPIO
• Asynchronous design – all interfaces can be used simultaneously
connector K2, and along with the 5 V sup-
• Can be used as an in-system programmer for AVR microcontrollers
ply voltage from the USB port it can be
• Boot loader for easy firmware upgrade and loading your own software
used as desired to power the microcon-
• GPIO connector pinout compatible with Raspberry Pi A and B
troller and the I/O portion of IC2.
Polyfuse F1, with a rated value of 350 mA, power to the Raspberry Pi from also feed- connected to the AxiCat. However, exten-
limits the total current consumption to ing power to the AxiCat and through the sion cards for the newer Raspberry Pi
prevent overloading of the supply voltage USB port to the computer. models with additional I/O lines on the
lines of the USB port. Specifically, this GPIO connector K2 is a 26-pin header. 40-pin connector (A+, B+, 2 and 3) are
means you should keep the total current This connector and its pinout (see Fig- not compatible.
drawn from the GPIO connector (I/O lines, ure 2) were not chosen randomly; they Finally there is jumper/connector K3,
5 V supply voltage and 3.3 V supply volt- largely correspond to the GPIO connector which can be used to manually reset the
age) below 350 mA. on the early Raspberry Pi models (A and AxiCat. If jumper JP2 is kept closed at
Diode D1 in the 5 V supply line to pins B). The main advantage of this is that the same time, the internal boot loader
2 and 4 of GPIO connector K2 is there a large number of extension cards and is activated. This allows you to send your
to prevent extension cards that supply HATs for the Raspberry Pi can also be own firmware to the AxiCat.
+UB +UB
C7 C8 C9 C10
+5V +UB +UB
R5
100n 100n 100n 100n
10k
R4
C11 C6
10k
F1
5 17 38 29 27
1u 100n
VCC VCC VCC AREF AVCC
4
20 4 RESET
350mA
VCC VCCIO IC1 R1
8 1 37 19 PC0
NC D0 PA0(PCINT0/ADC0) PC0(PCINT16/SCL)
100R
19 5 36 20 PC1
RESET D1 PA1(PCINT1/ADC1) PC1(PCINT17/SDA)
3 35 21 PC2 C5
D2 PA2(PCINT2/ADC2) PC2(PCINT18/TCK)
27 11 34 22 PC3
OSCI D3 PA3(PCINT3/ADC3) PC3(PCINT19/TMS) 1
K1 IC3 28
IC2 2 33 23 PC4 10n
L1
OSCO D4 PA4(PCINT4/ADC4) PC4(PCINT20/TDO) K3
1 1 8 9 32 24 PC5
VBUS VCC D5 PA5(PCINT5/ADC5) PC5(PCINT21/TDI)
2 2 7 15 10 31 25
D– IO1 USBDP D6 PA6(PCINT6/ADC6) PC6(PCINT22/TOSC1)
3 3 6 16 6 30 26 PC7
USB
PB5 1 14 PD5
GND
GND
GND
1M
PB5(PCINT13/MOSI) PD5(PCINT29/OC1A)
4n7 10n PB6 2 15 PD6
1u 7 18 21 25 PB6(PCINT14/MISO) PD6(PCINT30/OC2B/ICP)
PB7 3 16
PB7(PCINT15/SCK) PD7(PCINT31/OC2A)
GND
GND
GND
GND
XTAL2 XTAL1
6 18 7 8 28 39
X1
JP2
IC4
LM1117-3.3 1
+5V +3V3 C1 12MHz C2
10u 1u 1u 22u
+UB +3V3 +5V
D1
R2 R3
K2
4k7
4k7
1N5819
1 2
+5V +UB +3V3
PC1 3 4
PC0 5 6
PC5 7 8 PD1
3 2 1 9 10 PD0
PC4 11 12 PD5
JP1 PC3 13 14
PC2 15 16 PD3
17 18 PD2
PB5 19 20
PB6 21 22 PD4
PB7 23 24 PB4
25 26 PD6
Figure 1. Schematic diagram of the AxiCat, which is built around an
Atmega164A microcontroller.
150585 - 11
that involve bus transactions, such as ciency of the interrupts. Instead of inter-
an SPI transfer or a 1-Wire enumera- rupt routines, we use non-blocking tasks
tion. To avoid blocking of the incoming integrated into the main loop. TIMER1,
flow of data packets, the AxiCat executes which acts as a millisecond counter, is
long-duration commands asynchronously, the only hardware function that works
which means in the background. With with an interrupt routine.
asynchronous commands, the AxiCat We chose the size of the working buf-
waits until the command has been exe- fers based on the available RAM and the
cuted before it returns a response to the code generated by the compiler. The
host. main program uses working buffers with
Asynchronous commands are stored in a size of 2n bytes and a maximum size
working buffers, which are available for of 128 bytes, which results in very effi-
Figure 2. The header pinout is designed to be
the following components: I2C master, cient and compact code for an AVR 8-bit
compatible with Raspberry Pi models A and B.
This allows a large number of Raspberry Pi HATs I2C slave Tx, I2C slave Rx, SPI master, microcontroller.
to be connected directly to the AxiCat. 1-Wire master, UART #0 Tx, UART #0 Rx, The main program supports USB remote
UART #1 Tx, and UART #1 Rx. Note that wakeup, so the AxiCat can wake the host
the UART working buffers do not retain computer when it is in sleep mode. Of
any commands; they only send data course, this is only possible if the oper-
bytes (Tx) or receive data bytes (Rx). ating system of the host also supports
K2 The working buffers enable the AxiCat to USB remote wakeup.
3.3V 1 perform bus transactions on several dif- AxiCat Bootloader is executed when the
ferent interfaces in parallel. The effective AxiCat starts up. The boot loader first
ground size of the working buffers can be con- checks the state of jumper JP2. If the
GPIO0 figured in the firmware and is primarily jumper is open, the boot loader jumps
VCC determined by how much RAM is available to the main program. If the jumper is
GND in the microcontroller. closed, the boot loader remains active
RESET and you can use the boot loader pro-
There are also autonomous response gram aximcubldr to download a new main
MOSI
ATtiny45 packets, which are called unsolicited program from the host computer to the
MISO
SCK
responses. For example, there is no com- AxiCat.
mand for reading received data bytes
from a UART. This means that the AxiCat Software
automatically sends a response packet The AxiCat Server program provides the
when a UART receives data bytes. functionality of the AxiCat via network
Figure 3. Using the AxiCat as a programmer
ports and standard I/O in the form of
connected to an ATtiny45.
Firmware a communication protocol. The server
The main program of the AxiCat is AxiCat can accept multiple client connections,
Main, which is what makes everything allowing several clients to work with the
Serial data protocol tick. The serial data protocol is imple- AxiCat concurrently. The server acts as a
The serial data protocol consists of byte mented here. The main program is written multiplexer between several clients and
packets which flow between the host and in C; we used WinAVR 20100110 for this. a single AxiCat, which creates a lot of
the AxiCat in full duplex mode. The host WinAVR is a Windows version of GCC for flexibility.
sends command packets, and the Axi- AVR 8-bit microprocessors and AVR Libc. The communication protocol consists of
Cat sends response packets. The file axi- During the development of the AxiCat we commands and corresponding responses.
cat.h, included in the download package frequently checked the generated assem- A client sends a command, and the server
from [1], contains the definitions in the bler code, and in many cases we rewrote returns a response once the command
C language. the source code to make the machine has been executed. The communication
There are two types of commands: syn- code more efficient and compact. That protocol is coded in ASCII format. The
chronous and asynchronous. They differ was necessary for two reasons: firstly syntax is designed to make the commu-
in how the AxiCat executes them after because fast iteration of the main loop is nication protocol easy to use both man-
they are received. Synchronous com- crucial for the performance of the AxiCat, ually and in software.
mands are executed immediately. If a and secondly because the main program
response package is defined for the com- has to fit in the 16 KB of flash memory The server supports a large number of
mand, the AxiCat returns it to the host in the ATmega164A. commands for working with the AxiCat.
immediately. Among other things, syn- Some examples are:
chronous commands are used to read We opted to use interrupts as little as
status data, modify settings, and access possible, because the GCC compiler often Configure GPIO pin 1 as an output, set
GPIO lines. generates interrupt routines that push a the output low and read the state:
Some commands take a relatively long lot of registers onto the stack and later Command iod 1 out
time to execute. These are commands retrieve them, which degrades the effi- Response iod ok
LED
Stairway
Lighting
One controller for a
whole bunch of LEDs
If the Stairway to Heaven was fitted with lights I guess they would look something like this… Each step is
softly illuminated in sequence by a microcontroller, not just fascinating but energy efficient as well!
A friend was telling me how he had been case is seldom likely to have more than can be connected directly to the micro-
impressed by a cool stairway lighting sys- 20 steps. For inputs we need a pushbut- controller I/O pins. Looking at the sche-
tem he had seen in a high-tech house. A ton at the top and at the bottom of the matic in Figure 1 the only other items
pushbutton at the bottom of the staircase stairway to turn the lighting on and off. besides the controller and output buffer
starts a lighting sequence where each step This number of I/O lines could easily be chips are the two pushbuttons connected
beginning from the bottom is gradually lit taken care of by an ATmega8 control- via connector K2 and the power supply.
up until the topmost step is reached. At ler. Without the need of a serial port or The circuit does not contain any dan-
the top another pushbutton turns off the external crystal all the I/O pins are free gerous high voltage levels because it is
stair lighting, again in a sequence which to be used as required. powered by a mains adapter unit. The
begins from the bottom all the way up to Each step can be lit by a string of LEDs adapter should be able to supply an out-
the top step. Pressing the top pushbutton and where necessary two strings wired put voltage in the range of 12 to 20 V DC
again begins the lighting sequence but this in parallel to give more light. A standard and can, for example be salvaged from a
time from the top to the bottom. Hey, that microcontroller I/O will not be able to disused router. The processor runs with
sounds neat but after some research I supply the voltage or current required for a supply of 4 V so a simple linear voltage
found the cost of a commercially available each string so we will need some output regulator would need to dissipate con-
controller unit — at few hundred euros driver chips to drive the LEDs. siderable power. Despite the fact that
seemed a bit excessive. I have been work- for operation the controller only draws a
ing with Atmel microcontrollers for some This job can be performed by the ven- few milliamps, each active output adds
time now and wondered how simple it erable ULN2003 chip which comes in a around another milliamp so the power
would be to build my own version. DIP package and contains eight Darling- dissipated by a smaller outline L-type lin-
ton-transistor drivers able to switch up to ear regulator would quickly exceed its
First thoughts 50 V at 500 mA, much more than we need limit. We would therefore need to use a
To work out what we would need, we in this application. The inputs to each larger TO220-outline linear regulator or
can firstly assume that a domestic stair- buffer include a series resistor so they a more efficient switched-mode regulator
+4V1
K3
+12V K6
2 1 1
K4
4 3
to ATMEL 2 1
6 5
9
ISP
1
I1
CD+
O1
16 R8
47R *
+4V1
2
I2 O2
15 R9
47R *
+12V
3
I3 IC3 O3
14 R10
47R *
7 20
4
I4 O4
13 R11
47R *
C3
VCC AVCC
5
I5 O5
12 R12
47R *
R1 220n 1
PC5
28
27
6
7
I6
ULN2003
O6
11
10
R13
47R * 1
K5
C1 PC6 PC4 I7 O7
26 GND 2
PC3
1R
21 25 8 3
820u AREF PC2
IC2 PC1
24 4
6 23 5
L1 PC0
1 VCC 2 9 6
K1 SWC SWE
*
7 220uH 19 1 CD+ 16 R14 7
2 D2 IPK IC1 PB5 I1 O1 47R
1
8
DRC PB4
18 2
I2 O2
15 R15
47R * 8
12V
3
TC COMP
5
12K PB2
16 4
I4 O4
13 R17
47R * 10
GND
R2 PB1
15 5
I5 O5
12 R18
47R * 11
ULN2003
*
C2 4 D1 C6 2 6 11 R19 12
PD0 I6 O6 47R
*
5k1
3 7 10 R20 13
PD1 I7 O7 47R
470p 560u
1N5819 ATMEGA8-16PU GND 14
6 8 15
PD4
9 16
PB6
10 17
R6 R4 PB7
K2 4 11 9 18
5k6 5k6 PD2 PD5
3
R7 R5 PD6
12 1
I1
CD+
O1
16 R21
47R * 19
2
5k6 5k6
5
PD3 PD7
13 2
I2 O2
15 R22
47R * 20
1
PB0
14 3
I3 IC5 O3
14 R23
47R *
GND GND
4
I4 O4
13 R24
47R *
C4 C5 8 22
5
I5 O5
12 R25
47R *
6
I6
ULN2003
O6
11 R26
47R *
2u2 2u2 7
I7
GND
O7
10 R27
47R *
8
160233 - 11
like the MC34063A which only requires in the wires. All of the outputs driving to be modified to make it work with the
a few additional external components. the LEDs are fitted with series resistors demo version of the compiler.
to limit maximum current to safe values. The port pins have been individually
Circuit building The ULN2003 driver chip has in built pro- declared and are referenced via their
The circuit was first tested using some tection diodes at each output which can alias names so that porting to a different
perfboard (a.k.a. stripboard/Veroboard). be used to suppress voltage spikes when controller or any changes to the I/O pin
The driver chips use a DIP package so the chip is used to switch inductive loads. assignments will be made easier.
they were really quick and easy to wire In this application we connect the com- Generating the pulse width modulated
up. The step-down converter chip was mon cathode pin of the three driver chips (PWM) signals to control the LED bright-
also quickly configured according to infor- together. When this connection is linked ness was a bit more challenging. The
mation from the datasheet and takes up to ground via a jumper it switches all the built-in PWM functions are only avail-
little space on the board. The connec- LEDs on together — that’s really useful able for use on a few port pins so they
tions necessary for programming the con- during installation to test the LED wiring are not of much help in this application.
troller were more difficult to arrange, a independent of the controller program. We can of course do the necessary work
double-sided board would certainly make ‘long hand’: A variable Pwm_help is used
the job easier. This PCB contains a few The Program in Bascom and continuously increments from 1 to
components not essential to the board’s The program has been written in Bascom 254 and rolls over to 1. A byte variable
function; D2 is included to prevent any (free download from [1]). I have pur- for each LED and step level defines the
damage if the input supply voltage is con- chased the full version of the compiler value of brightness. When this value is
nected the wrong way round. The push- without the code size restrictions of the smaller than Pwm_help the LED is off and
buttons to activate the lighting sequence free demo version. The controller also when it is greater the LED is switched on.
are likely to have long cable runs so they has more than enough memory for this A brightness value of 0 corresponds to
are fitted with an RC filter network to sup- application so no attempts were made at the LED being completely dark and val-
press any unwanted interference pickup code optimization. The code would need ues from 1 to 254 define the mark/space
no significant difference in power con- You can also use continuous, adhesive
sumption. Experimenting with different LED strips cut to length. This type of
sleep modes in the controller did not pro- LED lighting strip is specified for opera-
duce significant savings in the 36 mW tion at 12 V. The strip consists of groups
consumed by the board. With the operat- of three LEDs in series together with a
ing mode triggered, current to the board series resistor and will not require any
rises to just above 14 mA and then you additional board-mounted series resistor.
need to add the current taken by the The 47 Ω resistors can, in this case be
LEDs to this figure. Here the resistors in replaced with short lengths of wire. The
series with the LEDs produce the biggest Darlingtons in the ULN driver chip have
losses. This equates to an energy loss of a saturation voltage in the range of 0.8
2.5 watts. In normal operation the LEDs to 1 V, you will need to factor this value
will not be in continuous operation so into any calculation of the LED drive cur-
these power losses can be considered rent and supply voltage to achieve the
Figure 2. The uncluttered PCB layout makes it acceptable. desired brightness.
easy to fit the components. How you hook up all the LEDs is up to
Assembly you, for the purposes of experimentation
The PCB layout is shown in Figure 2 you can use a connector but when the
ratio increasing until at 255 it is continu- and is available as a Target3001! file unit is installed its simpler to just solder
ously on. It only remains for this evalua- for download from the Elektor Magazine the wires onto the board pads.
tion process to be linked to an interrupt project page [1]. Fitting all the compo-
routine which is called at a reasonable nents to the board should be fairly sim- Why stop there?
frequency. In this case a reasonable fre- ple on this well designed board. All the The PCB can of course be used for other
quency is one that’s high enough so that components are standard and stocked projects; everything that you need to
the eye cannot detect the LED switching. by many suppliers but it will first be nec- control LEDs is on board. According to
When a pushbutton at the bottom of the essary to work out the best value and the data sheet the voltage regulator can
stairway is pressed the illumination level power rating for the LED series resistors. accept an input voltage up to 40 V. The
of the individual steps is increased from The 47-Ω 0.25-W values specified in the voltage rating of reservoir capacitor C1
the bottom step to the top step (also in parts list are designed for use with nine will however need to be increased corre-
the other direction for descending) with LEDs per step. The nine LEDs consist of spondingly. If you find your style is get-
a delay between each step. This is simply three ‘strings’ of LEDs wired in parallel ting cramped by the relatively small 8-K
controlled using the value of a few bits (each string is made up of three LEDs flash memory in the ATmega8 you could
and effective over four steps. You can wired in series). It will be useful if all the substitute the more powerful, pin-com-
alter the speed change value by chang- LEDs come from the same manufacturing patible ATmega328.
ing the values of the variables Delay1 batch so that their characteristics will be (160233)
and Delay2. similar and produce more or less equiv-
alent light output.
Web Link
Energy efficiency To work out the value of the LED series
Any lighting system such as this should resistors I first used information from the [1] www.elektormagazine.com/160233
be energy efficient. Powered from a LED data sheet. After some experimenta- (Bascom source code and
12 V supply the switch regulator alone tion with the LEDs however, it was clear Target PCB files)
draws around 2.5 mA, with the control- that their forward voltage drop was consis-
ler plugged into its socket the current tently lower than the value stated. Some
increases by a further 3 mA. Tests using experimentation may be necessary to
different versions of the ATmega8 showed arrive at the best value for these resistors.
The Author
Ever since he was young Peter Grundmann (b. 1956) has been fascinated by electronics. His first
practical experiences were connected with his interest in model trains. Much later he graduated in
business studies and now works as a software development engineer.
He has always been drawn to hobby electronics and besides analog and digital projects he is now
mainly occupied with microcontroller project design and programming. Along the way he has
developed specialized lighting effects and electromechanical actuators for model train installations.
These have also been incorporated into commercial products.
Peter is always happy to hear of your own experiences in this field of activity. You can contact him
at: [email protected].
The plan is to make a kitchen radio using a good, old-fashioned, tried-and-tested fluorescent display, but with
the added twist of an Internet connection. In the first installment we looked at its functions, the hardware and
how we drive the display. But, without software, the hardware is nothing: the ATmega in the display module
needs firmware, and code is also needed to turn the Raspberry Pi into an Internet radio.
Figure 1. All the boards fitted into a clamshell enclosure and wired Figure 2. Lid on, firmware in: the kitchen Internet radio in operation. The
together. electronics is visible through the acrylic front panel.
If, with a little help from the circuit diagrams, board layouts Communication protocol
and other documentation you have built the VFD module from If two computer systems want to exchange data packets with
the first installment of this series [1], you may have discov- one another it is necessary to agree beforehand on how the
ered that (even assuming you have put everything together packets are to be interpreted: a protocol has to be defined.
correctly) not a lot happens when you power it up. Even with The homebrew protocol used here was also designed for use
all the printed circuit boards installed in the box and wired in a home automation system using a two-wire bus, and so
together (Figure 1), and with the lid closed (Figure 2) the has a few features that we will not be needing in this case.
display will still not light up as shown in the photographs. The Nevertheless, its structure follows the same lines as other
reason behind this is that the microcontroller in the display similar protocols. The firmware for the ATmega in the display
module needs firmware, so that it can understand the control unit was written entirely within the AtmelStudio development
commands sent to it. This firmware and, last but not least, environment (see screenshot in Figure 3).
the code for the Raspberry Pi, forms the topic of this second Table 1 shows the general structure of a data packet. A mes-
and final installment. sage of type TDataBuf is passed to the transport layer. The
void initSerial(void);
void sendMsg(TDataBuf msg);
uint8_t peekMsg(TDataBuf *msg);
in serial.h. The other serial port parameters are eight data bits,
no parity, and one stop bit (‘8N1’). The function sendMsg()
takes a message of type TDataBuf, copies it to the internal
Figure 3. Screenshot of the AtmelStudio development environment showing
transmit buffer (if it is free) and then returns immediately to
the ATmega firmware for the display module.
the caller. Transmission and reception proper all happen under
interrupt control in the background. As soon as a valid mes-
transport layer starts by sending an STX character to mark the sage is received it is stored in one of the two receive buffers.
beginning of a transmission; an ETX character is sent at the A call to the function peekMsg() will then return a ‘1’ and the
end of each transmission. The STX and ETX characters should valid message will be written to msg.
not appear within the message itself: if they do, they should
be escaped by prefixing them with the data link escape (DLE, The escape mechanism is handled transparently within these
0x10) character. The receiver removes any escape character functions. There is one transmit buffer, but two receive buf-
from the data stream and appends the immediately following fers that are used alternately: this allows one message to be
character to the partially-assembled message. If it is desired processed while the next one is being received.
to transmit the escape character itself, it is necessary to send The code module is structured independently of the format
of the messages being sent, which is defined in protocol.c
and protocol.h. Two-wire bus systems such as RS-485 require
Table 3. Message codes.
an extra control signal which switches the hardware between
Field Meaning transmit and receive modes. The default mode is ‘receive’,
Source address: transmit mode being enabled only for the duration of a mes-
SRC
0 to 255 except for the values 2 and 3. sage transmission. This is the purpose of the two definitions
Destination address:
DST
0 to 255 except for the values 2 and 3. #define SENDER_OFF
Message type. The following are defined: #define SENDER_ON
0x10 StatusReq
0x11 StatusResp in serial.h. The receiver runs continuously, and so will pick up
0x12 DisplayReq any message that is sent: this can be used to detect a bus
0x13 DisplayResp collision. The only function we need in protocol.h is ownAdr(),
MT 0x14 Key_Req which returns our own address on the bus.
0x15 Key_Resp
0x16 Time_Req Table 2 shows the individual components of a packet and
0x17 Time_Resp Table 3 describes their meanings. Listing 1 shows the structure
Note that codes 0x02 and 0x03 may not be used; of a message as a C ‘struct’; the ‘union’ is a construct which
other codes are available for future expansion. describes how the TDatagramm structure and the TBuf byte
array can overlay one another at the same memory addresses.
Bit Meaning
This allows easy reading and writing of the message as a sim-
0...3: Length of payload in bytes: 0 to 15
ple array of bytes, which makes the receive and transmit code
4: 0/1 = checksum absent/
more straightforward.
checksum present
5: 0/1 = acknowledgement with ACK not
MODE ATmega communication
required/acknowledgement required
The following message types are defined.
6: 0 (reserved)
7: always 1
#define MT_STATUS_REQ 0x10
Note: values 0x02 and 0x03 may not be used. To
#define MT_STATUS_RESP MT_STATUS_REQ + 1
ensure this bit 7 is specified to always be 1.
CS Message checksum.
Internet Links
[1] Software download and first installment: https://www.elektormagazine.com/150720
[2] Raspberry Pi operating system installation: https://www.raspberrypi.org/documentation/installation/installing-images/
[3] Raspberry Pi as an Internet radio: https://www.youtube.com/watch?v=jf3M1RVpQbM (audio in German)
[4] NetBeans for the Raspberry Pi: http://bit.ly/2aBZ14A
[5] Internet radio tutorial: https://www.youtube.com/watch?v=jf3M1RVpQbM (audio in German)
[6] Automatically run a program on boot: http://pi.bek.no/autostartProgramOnBoot/
adjust
Let’s walk through the shield’s functions
10k 3V3
step by step helped by Figure 1.
+5V
P1
1k
Small signals
IC1A, powered from the 5-V line, is a rail- Component List
to-rail input-output operational amplifier Resistors
All 5%, 0.25 W
(opamp) meaning that both its input as
R1, R3 = 1kΩ
its output cover the range of 0 to 5 V R2 = 100kΩ
(within a few millivolts). This output is P1 = 100kΩ, trimpot,
horizontal
connected to the Arduino analog input
P2 = 10kΩ, trimpot,
A0 only, hence its signal is not available horizontal
on a screw terminal block. The opamp is
Capacitors
wired as a non-inverting amplifier with its
C1 = 100nF, 0.2’’ pitch
gain is controlled by P1. The maximum
gain is about 100, the minimum gain, Semiconductors
one. The result is that the input signal D1 = BZX85C, 3.3 V, 1.3 W
Zener diode
on K1, pin 1 can either be amplified or
IC1 = MCP6232
it can simply be buffered. Although the IC2 = ULN2003
input impedance of the input is very high,
Miscellaneous
it can be fixed at 100 kΩ by shorting JP2.
JP1, JP2 = pinheader, 2-way,
Doing this is useful because it avoids the 0.1’’ mm pitch
opamp struggling with noise, hum and 2 pcs jumper for JP1 and JP2
other interference when its input is left K1,K2,K3,K4,K5,K6,K7 =
3-way PCB screw terminal
open. If, on the other hand, the source block, 5 mm pitch
connected to this input has a very high K8, K10 = 8-way stackable
IC socket, DIP-8 for IC1
output impedance, it may be better to pinheader socket, SIL, 0.1’’ mm pitch
IC socket, DIP-16 for IC2
K11 = 10-way stackable pin socket, SIL,
open JP2 to prevent squashing such a 0.1’’ mm pitch
PCB # 149014-1 v1.1
sensitive signal.
Detect high voltages max), a relay, a lamp or a motor for VIN, Reset, IOREF and AREF are only acces-
K1, pin 2 is a voltage and current limited instance, to 0 V as they can handle rela- sible on the shield connectors.
analog input. Zener diode D1 will limit tively large currents. An Arduino output (160169)
high DC voltages to 3.3 V maximum — cannot do this without the help of such
Web Links
a safe level for Arduino boards. But be a driver circuit. In case you must switch
careful, negative (AC) voltages are not more current than one channel can han- [1] www.elektor.com/
allowed, not on this input and, by the dle you can put two or more of these interfacing-screw-shield-149014-91
way, not on any other input. R1 provides outputs in parallel. If you want to switch [2] www.elektormagazine.com/160169
current limiting for both the input and inductive loads (like a solenoid, relay or
D1. Its value is a little high, meaning motor) you should add a flyback diode
that when you connect the input to, say, in parallel with the load (cathode to the
Great examples of how the shield
about 5 V, the voltage will be limited to power supply, anode to the output of IC2)
described in this article can used for
around 3 V, but with an input voltage of as the chip’s internal flyback diodes are
all sorts of applications, IoT or not,
12 V or 15 V you will measure 3.3 V here. not used on this board.
can be found in the book IoT Get U
The purpose of this input is to detect volt-
Going (Elektor Store SKU # 17460).
ages (much) higher than the Arduino can Some remarks
www.elektor.com/iot-get-u-going
accept, for instance the output voltage Power to the shield is supplied by the
of a DC adaptor or the state of a switch Arduino that carries it; do not power the
connected to a high voltage. Although shield through K7 when it is plugged onto
in theory this input can easily withstand an Arduino. This connector is intended for
voltages up to 100 V, never ever con- powering devices connected to the shield
nect it to the AC line voltage! only, not to power the Arduino.
The 3.3-V output is the Arduino’s 3.3 V
Powerful outputs output which is not very powerful, so treat
Part IC2, a ULN2003A, has a long-stand- it with loving care.
ing reputation, and a good one, which is IC1 and IC2 are mounted in sockets so
why it was used here. In it are seven pow- they can be replaced easily in case of a
erful Darlington transistors that can be mishap.
controlled digitally. Although the device
has seven channels, only six were used Most of the Arduino extension signals
on this shield. Each transistor can switch have been brought out to sturdy screw
500 mA and can stand up to 50 V. These terminals to allow easy connection of
transistors are very good to switch some- wires and cables to the board. Most, but
thing connected to a power supply (50 V not all: the serial port pins (pins 0 & 1),
If you feel like replacing the VHF-FM radio in your car with something more modern offering DAB+
reception too, you’ll discover that combination receivers have two separate antenna inputs. That’s
because two individual antennas are required. But this RF combiner makes it possible to connect both
inputs to one standard car antenna.
First trials
You could, however, achieve the desired separation also by
combining a lowpass and a highpass filter with suitable fre-
Figure 1. Image of the DAB+ spectrum at 178 MHz, Channel 5c. quency characteristics.
Diplexer software
A diplexer could offer a solution here. This employs a com-
bination of lowpass and highpass filters (or bandpass filter/ Figure 2. Lowpass filter SLP-150+ and highpass SHP-250+ by Mini-Circuits,
band rejection filter). In other words a frequency divider for each swept independently with a network analyzer.
radio frequency use.
Both filters are matched to each other in such a way that they
can (and must) be driven in parallel by the source. For calcula-
tion there is the ‘Diplexer Design’ software by James L. Tonne
[1]. This program allows you to select between lowpass/high-
pass and bandpass/bandstop variants. The following descrip-
tion covers only the lowpass/highpass version.
On the Design page of this program (Figure 4) you can define
the characteristics of the diplexer. The ‘Order’ is a measure-
ment of the complexity, and hence outlay (the number of
components), and the abruptness of the filtering achievable.
‘Crossover freq’ indicates the point of intersection of the two
filters. In this VHF/DAB+ example it is roughly in the middle
between the highest VHF frequency (108 MHz) and the low-
est DAB+ frequency (174 MHz). The crossover frequency can
be fine-tuned to the extent to make the attenuation of the
unwanted band in each filter more or less equal. You can also
attempt to replace ‘awkward’ (i.e. not made commercially) coil
values calculated with readily available ones.
The lowpass in the upper section begins always with a series
inductance. When calculating an individual filter you can select
Figure 3. Both filters are connected in parallel here by T-adapter. This
whether you want to start with the series inductance (T-struc- creates a strong mutual influence on the frequency response.
ture) or a shunt capacitor (Pi-structure). Here this is not an
option. Correspondingly the highpass always begins with a
series capacitor.
‘Passband ripple’ indicates the amplitude of the periodic vari-
ation in the passband region, as in a Chebyshev filter. The
greater the ripple, the sharper the filter and vice versa.
‘System Z’ indicates the impedance, in our example 50 ohms.
When you press the ‘Plot’ button, you reach the next screen-
grab (Figure 5).
You can change the order, ripple and crossover frequency again
at this stage and observe the effects directly. You can set the
presentation style using ‘Plot Options’ and at ‘Markers’ super-
impose markers.
Next we use Simetrix to simulate the diplexer we designed
and compare it with a Chebyshev lowpass filter.
A practical design
Following this work, I developed a PCB using EAGLE. Awkward
coil and capacitor values were handled using available values Figure 4. Design page of the Diplexer Design program.
Active version
Figure 5. Plot page of the Diplexer Design program.
As the transmit power of DAB+ transmitters is rather mod-
est in comparison with analog VHF stations, I searched for an
appropriate preamplifier and struck rich with the MAX2630
wired in parallel and series. It is possible to connect capacitors from Maxim.
in parallel and install them side by side without any problems.
Connecting coils in series is another matter. The two magnetic As shown in the datasheet [2], it comes in a 4-pin SAT143
fields can interact, creating a transformer (albeit a very bad package. The only extra circuitry, besides the bypass capac-
one), and the effective inductance value is not the desired itor for the supply voltage, is one capacitor each at the input
sum of the two values. Accordingly the coils were offset by and output. Since it fits perfectly on a scrap of perfboard, no
90 degrees and, as far as the SMD layout would permit, sep- PCB had to be developed for testing. Its gain is around 15 dB
arated from one another by distance. and the noise figure is 4. The measured frequency response
L1 L2 L3 L4 L5 L6 L7 L8
SIG
68nH 22nH 100nH 15nH 100nH 4nH7 39nH 0nH
SIG
(Coax)
2p7 0p 1p 10p
SIG
C7 C9 C12 C14
L16 L9 L10
12p 12p 12p 22p FM (Coax)
160234 - 11
L3 L4 L5 L6 L7
L2
L1 C5
C3 C4 L8
C1C2 C10
L16 L9
L10
C7 C6
C8 C11 C14
C9 C12 C13
Figure 7. EAGLE layout for the circuit in Figure 6. Figure 8. Prototype of the diplexer in its plastic housing.
+3V3
LD1117 3.3V
LSP1 D1 R1 R2 U$1
150R 150R
ES2B SMD LED1
C20 C24
+3V3
4
C22 L1 L2 L3 L4 L5 L6 L7 L8 C17 C16
3 1
SIG
+3V3 68nH 22nH 100nH 15nH 100nH 4nH7 39nH 0nH
1n 1n 1n
2
C21
C1 C2 C3 C4 C5 C10 DAB (Coax)
4
C23
3 1
SIG
1n +3V3
2
(Coax) C18
GND
100n
C6 C8 C11 C13 4
C19
2p7 0p 1p 10p 3 1
C7 C9 C12 C14
SIG
L16 L9 L10 1n
2
12p 12p 12p 22p FM (Coax)
33nH 33nH 39nH
GND
160234 - 12
6. Mooshimeter
www.elektor.com/sandclock www.elektor.com/mooshimeter
BBC micro:bit - 35 Touch Develop CAN Projects with ARM and Arduino SmartScope Maker Kit
& microPython Projects
NEW
This book is about the use of the BBC micro:bit computer This book details the use of the ARM Cortex-M family of The new SmartScope Maker Kit (available exclusively from
in practical projects. The BBC micro:bit computer can be processors and the Arduino Uno in practical CAN bus based Elektor) contains a version of the SmartScope that’s specially
programmed using several different programming languages. projects. Inside, it gives a detailed introduction to the prepared for FPGA development, with ready assembled
This book makes a brief introduction to the Touch Develop architecture of the Cortex-M family whilst providing examples internal headers and additional FPGA pins that permit reading
programming language and the microPython programming of popular hardware and software development kits. Using and writing. The remainder of the kit contents, including 2
language. It then gives 35 example working and tested these kits helps to simplify the embedded design cycle programmers and 2 probes, is also highly worthwhile.
projects using these language. Complete program listings are considerably and makes it easier to develop, debug, and test
given for each project. a CAN bus based project.
member price: £20.95 • €22.45 • US $25.00 member price: £28.95 • €33.75 • US $38.00 member price: £242.95 • €269.95 • US $300.00
Mastering Microcontrollers
Helped by Arduino
3RD revised edition
with AVR Playground and Elektor Uno R4
Door Spy with Raspberry Pi Red Pitaya for Test & Measurement Elektor SDR Reloaded
This GSM HAT-board for the Raspberry Pi can be used in The Red Pitaya is a credit card-sized, open-source test This Arduino shield is a remake of our famous SDR project
combination with a Pi camera to build a hi-tech doorbell. and measurement board that can be used to replace most published in 2007. A Software Defined Radio is a universal
When a visitor rings your doorbell, the camera takes a measurement instruments used in electronics laboratories. tool in RF technology circles, one that can also be put to use
picture of him/her and sends it in an MMS-message to your This book aims to teach the principles and applications of for making measurements. The characteristics of the receiver
cell phone. You can start a telephone conversation via the basic electronics by carrying out real experiments using are defined in software, which now gives us the opportunity
built-in intercom, and you can even send an SMS to open the Red Pitaya. Many fun and interesting experiments are to use an Arduino Shield as a front-end.
your front door. included. The book also makes an introduction to visual
programming environment.
£52.95 • €58.46 • US $65.00 member price: £26.95 • €31.45 • US $36.00 member price: £98.95 • €26.96 • US $144.00
the operation of the temperature or the flow sensor, but that turning the plug around would have any
effect we find at least a little suspicious. This leads to the conjecture that somewhere in the electronics
in the heater, part of a circuit has been economized away during the development. But that doesn’t
mean we are not interested in knowing what is happening exactly! If you know what is going on, write
to us at [email protected] and we will share it with the Elektor community. We are very curious.
Now something completely different. As the permanent Retronics editor, colleague Jan Buiting frequently
comes into contact with tubes. Old tubes. Such-thick-layers-of-dust-that-the-type-number-is-unread-
able tubes. So, what do you do? Exactly! Clean them. Only in that past the (white) ink used wasn’t the
best, so if you don’t take
care you will clean the
number off right along
with the dust!
Jan has by now devel-
oped a knack for this,
which I would like to
share with you:
Firstly: never ever wipe
a cloth over the printing.
You are sure to rub off
the printing! Wipe only
the dust off the other
LEARN
(160252)
Simulation
with SystemVision
A free web-based tool
It’s common knowledge that the ear- who register for the service through their Twitter, for example, you see a pop-up
lier you find an error, the less it costs to Facebook, Microsoft, LinkedIn, Twitter or window on the screen where you have to
correct. Computer verification of circuit Google accounts. The actual login process enter your Twitter address to give Sys-
designs is especially suitable for circuits depends on which network you use. With temVision access to your account.
without programmable components.
Getting started
For our needs, that should be enough
to get started. Go to the website www.
systemvision.com and click the Log In
button to open the pop-up login window.
At the time of publication of this article,
SystemVision accepts not only traditional
user accounts, but also accounts for users Figure 1. The SystemVision workspace.
The main feature is the ability to share designs with your friends and colleagues
If you want to save yourself the trouble sional version, but you can also stay If you are interested in circuit simulation,
of constantly digging through the results below the five-design limit by deleting you should definitely check out this pro-
folder, you can use the pencil symbol to designs that are no longer needed or gram. Particularly with regard to usability,
create a watcher as illustrated in Fig- releasing them for sharing. Unfortunately, it is miles ahead of PSpice.
ure 7. A watcher is a component that clicking the Upgrade Account button only (160203-I)
hovers above the circuit and displays the leads to an email address. No price infor-
results of the current simulation run. mation can be found on the Internet.
At the time of publication of this article, If you are looking for inspiration, you can
SystemVision had an annoying bug in the browse through the circuits provided by
simulation system: when you launch a other designers under the Find a Design
second simulation, an additional folder heading. That is especially helpful when
is created in the simulation window. For you want to learn more about a particu-
this reason it is advisable to delete dia- lar component or you are looking for tips
grams and simulation components that on how to set up effective simulations.
are no longer needed, by right-clicking
them and selecting Delete in the con- Summary
text menu. Another minor irritation is Although SystemVision appears a bit com-
how changes are saved: SystemVision plicated at first glance mainly due to the
only saves changes to the circuit diagram cloud-based user interface, it offers an
Opamp
Power Supply Connexions
Capricious or logical?
What can go wrong when fitting a component on a circuit board? All sorts of things of course, but in this case
the cause turned out to be really strange: The power supply connections of the IC were in the wrong place!
By Luc Lemmens (Elektor Labs) to not function properly, but one of those turer of the device in hand in order to
was very remarkable. be 100 percent sure of the correct pin-
out. With ICs, the suffix after the part
During the testing of the first prototype The true and tested method of finding number is usually an indication of the
of the Tabula Tangibles (a project that such faults is very simple: Remove the specifications or the type of package,
is a collaboration between Elektor Labs components one by one from the circuit but that an R on an IC means that the
and Aachen Technical University), there board and measure the resistance across supply connections are reversed, that’s
was something seriously amiss with the the power supply after each one, until new to me! I can’t think of any plausi-
power supply: the output of the volt- the culprit has been found. Fortunately ble explanation why, as a manufacturer,
age regulator appeared to be short-cir- there are not that many components on you would produce both these variants;
cuited. The first thought is a soldering this board and I also had the good for- the datasheet doesn’t mention a single
problem. An SMD board that’s built by tune that after unsoldering the first IC word about this either.
hand could, for example, have a solder the short-circuit disappeared! This was
bridge between the pins of an IC, or a single opamp type MCP601 from Micro- As already mentioned, there was some-
something. This is generally not a big chip in a SOT23-5 package, so back to thing else wrong (incorrect step-down
deal and is easily fixed with some solder studying the datasheet once more and converter for the desired voltage range),
wick. However, a thorough visual inspec- what turns out to be the case: there are so that is why I haven’t investigated
tion of the board didn’t reveal any prob- two variants of this IC in this particu- this phenomenon any further at the
lems. An additional check of the sche- lar package — the 601 and the 601R, moment. But after I promised the Editor
matic did not bring anything suspicious with the difference that the latter has to write a From the Labs article about
to light either. Neither did another check the power supply connections VDD and it, I found it so improbable that I mea-
of the footprints and the connections of VSS the other way around than planned sured it again, just to be doubly sure.
the components. Nevertheless there was on my PCB... But it is really so: there are two vari-
a suspiciously low resistance between ants. Whoever understands the logic
the output of the voltage regulator and I have come across many surprising behind it may elucidate us.
ground, there had to be ‘something’ hap- things in electronics. For example, con- (160257)
pening here. In the end there appeared sider the BF254 or BS170P FETs, where
to be two things that caused the circuit you need to know the actual manufac-
Err-lectronics
Corrections, Updates and Feedback to published articles
ELF Receiver
Elektor 10/2014, p. 8 (140035)
FEEDBACK. In addition to my participation in lectures at the University of Jena I am also actively investigating
low frequency (electromagnetic) vibrations. So far the frequency range of my investigations has been between
3 Hz and 1 MHz.
I am also interested in lower frequency signals below 1 Hz. I went on to build the Elektor ELF receiver and the
resulting investigations are very interesting. I was surprised to detect signals in the frequency range from 0.01 to
0.02 Hz. I use a wire antenna 8 cm to 17 m in length so these signals are more likely to be electrical rather than magnetic
in nature. So far I have been unable to find any literature describing these signals. Also I have not had
any satisfactory explanation as to their origin at the University of Jena.
Maybe geological vibrations of the earth are the key but I don’t know the mechanism
involved where (mechanical) spherical or toroidal vibrations could induce these
electrical signals. The frequency range is maybe about right?
I wonder if any other reader has had a similar experience.
Walter Koch
At first sight it looks like something that came out of a wizard’s studio — hovering in mid-air and spinning
on its own, apparently without any source of energy. The first time you see a Mendocino motor you can’t
help being fascinated. The operating principle is really very simple, a well-designed and neatly-finished
model adds to the intrigue and makes the effect even more magical.
A Mendocino motor is a type of electric support the rotor in mid air. They are also available to order from the Elektor Store.
motor powered by energy produced by slightly offset to keep the rotor in suspen- The frame of this motor is made from
solar cells. It uses a rotor suspended on sion. According to Earnshaw’s theorem transparent acrylic sheet. A powerful neo-
low-friction magnetic bearings. The motor it is not possible to achieve static levita- dymium magnet is positioned centrally
was invented by Larry Spring who comes tion using any combination of fixed mag- beneath the rotor. Its magnetic field per-
from Mendocino County in California. nets and electric charges. To make this meates the rotor coils above it. A small
The motor consists of a rotor and frame. bearing arrangement stable, one end of current flows through the coil when light
The rotor is an eight-sided cylinder with the axle is terminated with a ball bearing falls on the illuminated solar cell. The
an axle passing through its centre. Circu- which is pushed against a plate to form Lorentz energy produced in the coil gives
lar magnets are fitted at each end of the a low-friction contact. This prevents the the rotor a pulse to make it rotate. The
axle with the same magnetization direc- rotor being pushed out of its position in arrangement of coils and solar cells on
tion as magnets fitted to the frame (Fig- the frame by the magnets. the rotor ensures that pulses of energy
ures 1 and 2). This arrangement acts To illustrate the motor principle we will will keep the rotor spinning, so long as
as the rotor bearings while the magnets take a closer look at the X-8 type of motor the light intensity falling on the cells is
exert a repelling force on one another to which was built by the author and is now sufficient.
Construction
of the Mendocino motor
Altogether there are eight solar cells Bearing magnet Field magnet
Base plate
arranged edge to edge to form the rotor.
This gives the rotor an octagonal cross
section. One cell will be illuminated while Figure 1. The magnets on the axle are suspended Figure 2. Sketch showing the Mendocino motor
its opposite number will be in the shade. by magnets fixed in the frame. bearing arrangement.
The two cells are wired in series which
would seem to present a short circuit
to the voltage generated (Figure 3).
In practice however it doesn’t cause a
problem because one of the cells will be The motor spins from the glow of a large tea light.
in the shade whilst its partner will be in
full sun. Between the cell facing upwards
and the cell facing downwards there is a
difference in the incident light and also a
difference in the current generated. The Light
cell facing the light produces a voltage
while the cell in the shade acts as a rela-
tively high impedance. Current therefore Coil about 5
flows through the coil. After the rotor has S
Solar cells,
rotated through 180˚ the coil has turned each 0.5 V
around so that the energy pulse supplied N
by the opposite cell (which now faces the
light) is of the correct polarity to reinforce
the rotor’s spin. N
Build a Chipamp!
Great sound with only a few components
The building and tweaking of audio equipment is something that occupies many enthusiasts. It is very
satisfying and nothing beats listening to music on equipment that you have built yourself, even partially.
In this installment of WebScouting we’ll show you that you don’t need a complex design, or a large
number of components, to produce a fine sounding power amplifier.
Elektor Labs
Pipeline
The New Year has begun, and of course the (stale) list of resolutions compiled a few years back got dug up
once more. Since these resolutions are never fulfilled anyway, why not replace some of them with things that
are feasible, like doing some electronics projects? Here are a few suggestions to get you started.
From Verobox
to Heavy Metal
Elektor lab instruments 1980s and 1990s style
Roughly between 1984 and
1988, Elektor published
several pieces of DIY
laboratory instruments
all housed in two-color
Verobox, hard plastic cases
with aluminum front and
rear panels. A second gulf
of benchtop instruments
for many more applications
was launched in 1989 and
marked by solid, metal cases and again a sort-of uniform ‘look and feel’ to them. I found a couple of both
series in the Retronics attic and decided to take the family picture “in the box, 15 years on”.
By Jan Buiting, Editor-in-Chief tor measurement series” in fact there plans for a series of affordable, high qual-
were several. This article is my attempt ity, DIY measurement apparatus, simply
at describing two, suitably identified by stopping at the PCB was not an option.
Back in 1995, with time on hands before the boxes the Elektor lab workers agreed Like true industrial designers, they started
my return flight, I was given a private to use. Did they? with the enclosure and the ergonomics
tour of the RadioSpares laboratories in of the controls, before even going to the
Corby, Northants. That’s right, it’s todays Product engineering library and opening the RS Components
headquarters of RS Components. It was If you are among the countless readers Datasheet Collection to find an opamp or
at a time when the first CD-ROM version who started out as an electronics hobby- a connector. Some designers argued that
appeared of the RS Catalog, complete with ist and now wield spreadsheets, $K bud- the prescribed enclosure was a restrictive
a search function, which was a sensation gets and BOMs “for the industry” you will factor to their creative genius but eventu-
although it proved unable to find ‘BC547’. remember that the sheer gusto produced ally followed suit. One size fits all — these
One function of the RS lab staff in Corby by your working circuit was often so great instruments must have the Elektor look
was to supply verified engineering data as to quench any desire to build the PCB and be instantly recognizable!
on components and systems, for use in into a case decent enough to show out-
the RS Datasheet Collection RS customers side your shack. And indeed many Elek- In the beginning was Vero
could subscribe to. All on paper of course tor projects published over the years The first more or less coordinated series
and in luscious, dark red binders complete are “done, finished, ready” when the was to be housed in the two-tone (two-
with tab sheets. To my amazement all five autorouter says zero errors and the pro- color) “Verobox” sized 205 (w) x 137 (d)
lab staff in the Components section had a totype board works. The fact that these x 75 (h) mm. As an example for your
full complement of Elektor test equipment days an increasing number of projects are amusement and déjà vu experience, I
published from about 1984 onwards as microcontroller based does not seem to have pictured the Elektor Pulse Gen-
DIY projects. The instruments were easy encourage any of the programmers out erator in Figure 1. The case consist of
to recognize from their Verobox housings there to have a go at giving the project an off-white cover and a greyish bottom,
with the distinctive grey and off-white a professional look (and feel). They hate both made from ABS (hard plastic). The
color scheme! The techies at RS were nuts and bolts. front and rear panels are 1.5-mm mm
very satisfied with the equipment and said thick aluminum sheet. I remember we
it all worked okay once calibrated against A case for the case sold ready-made screen-printed self-ad-
“the unaffordable gear at head office”. Back in the 1980s when a team of Elek- hesive foils for sticking on the front panel
While it’s tempting to think of one “Elek- tor lab workers and editors outlined their (which you had to drill first). The word-
Figure 1. To kick off in ABS: Elektor Pulse Figure 3. A rare bird and seldom used too Figure 5. Over to Telet metal cases with the HFE
Generator, mid 1980s. Sorry about the missing as nobody cares any longer about the exact Tester from 1990.
cap on the 0.1–1.0 Repetition Time variable expression of analog voltages: True RMS Meter,
control. again mid-1980s.
Figure 2. A look inside the Pulse Generator; Figure 4. Inside the True RMS Meter. Note the Figure 6. Plenty of space inside that Telet case!
note the vertically mounted boards and the two range switch connected directly to the PCB.
transformers rightly deferred to the rear panel.
ings and symbols used on the foil were Another fine specimen of the Verobox T many, Geist, while C-I Electronics served
fiercely debated between the four lan- & M series was the Elektor True RMS most non-European areas with mail order
guage departments within Elektor, and Meter I stumbled on in the Retronics only. The upshot: Elektor achieved a mas-
fortunately it was agreed to use a com- attic (Figure 3). Sorry about that LCD sive success and these instruments are
bination of (minimal) English and “fits-u- which went fuzzy over the years, I will now legendary.
all” symbols. The name of the instrument send a complaint to Sharp. In this instru-
remained a challenge though as you can ment the power transformer was mounted Italian metal is better
see in Figure 1 (top left hand corner). on a separate aluminum sheet, possibly Like just about any supplier of test and
The slots formed by pairs of protrusions because of its weight (Figure 4). measurement instruments, Elektor
at the short sides of the bottom half of Sadly I do not have the pinnacle of the worked to innovate and refresh the prod-
the Verobox were used to secure printed Elektor Verobox T & M series in my col- uct line and improve brand awareness. By
circuit boards vertically. As shown in Fig- lection, the Elektor XR2206 Function about 1988, the Verobox got a bit long in
ure 2, the slots allowed front panel con- Generator. Rest assured though that it the tooth and a new “standard enclosure”
trols such as potentiometers and switches looks just like the other two instruments was sought by the Elektor team to house
to (a) assist in securing the “controls” I was able to rescue from the skip back yet another glut of DIY instruments for
board to the front panel and (b) to be in 2006. That Function Generator is still use in the home lab. Still using the ada-
connected directly to the PCB tracks seen today on auction sites and it’s a gio: Affordable — Quality — Professional.
rather than with flying wires as in “hobby- veritable classic. Rumor has it that parts distributor Texim
ist” projects in EPE et al. LEDs and other From memory I recall several other Electronics, a fantastic source of elektor-
indicators could shine through transparent instruments in the Verobox series, like ical parts and located in a murky part of
clearances in the front panel foil. a wattmeter and a multimeter but I do Holland called Achterhoek (‘back corner’),
Everything to do with AC line voltage and not have them. “kindly advised” metal cases produced by
power transformer’ing was allocated to That Verobox was expensive and Elek- Telet, Italy. As opposed to the Verobox,
the rear panel. Note that the molded tor got many complaints especially from these Telet cases were (a) all-metal and
screw bases in the bottom half of the super thrifty Hollanders. Some advertisers (b) available in different sizes. They were
Verobox were not used — all PCB orien- were thrilled though with the T & M series accepted as the new standard.
tation was to be vertical. And note those and started to supply kits as well as the Figure 5 shows a random example of
ventilation holes carefully drilled in the infamous “elektorical” parts. In the UK, Elektor’s “new” T & M series, the HFE
top and bottom sections by Jan Visser Maplin was the main supplier. In Holland, Tester, sized 198 (w) x 180 (d) x 80
and/or Mr. Feron. DIL Elektronica ruled the roost, in Ger- (h) mm. Note the correct use of subscripts
PEOPLE NEWS ● Tanja Pohlen can take credit for organizing the electronica Fast Forward Award, as
trade show, Tessel Renzenbrink and Jens Nickel kept online readers updated on everything they needed
anchorman Jan Buiting and cameraman Patrick Wielders helped a few camera-shy people to speak up
Sales, Client, and Member staffers Julia Grotenrath, Chantalle Reuling and Raoul Morreau spoke to
Education:
PhD, Technical University Berlin
• The blocks are not square or rectangular, but are more As certain blocks contain fewer than 16 boxes, it’s not possi-
like pieces of a jigsaw (referred to as a hexadoku jig- ble to use all the hexadecimal characters in these ones. This
saw). is just a little extra difficulty to bear in mind when solving it.
Certain figures have already been entered in the grid to define
• Block #1 (pupils of the eyes, in bright yellow) is made the starting situation. In order to enter, there’s no need to send
up of two separate parts, one each for the left and right us the whole grid, all you need do is send us the sequence
eyes. of six figures in the grey boxes.
1 3 8 2
Block Number
2 3 3 8 8 4 number of boxes
3 3 3 3 8 8 8 6 1 8
4 3 3 3 3 6 6 7 7 8 8 8 11 2 11
5 3 3 3 3 6 6 6 7 7 7 8 8 8 8 14 3 16
6 3 3 6 6 6 6 6 7 7 7 8 8 8 9 14 4 13
7 4 4 4 6 6 6 6 7 7 7 9 9 9 9 14 5 13
8 4 4 4 1 6 7 7 1 9 9 9 11 6 15
9 2 4 4 1 10 1 9 9 9 9 7 13
10 2 4 4 1 10 1 9 9 11 11 10 8 16
11 2 4 4 4 1 10 10 10 1 9 9 9 11 11 14 9 16
12 2 5 5 5 10 10 10 10 10 10 10 10 10 11 11 11 16 10 14
13 2 2 5 5 5 15 15 12 12 12 12 13 13 11 11 11 16 11 12
14 2 2 2 5 5 5 15 15 12 12 12 12 13 13 11 11 16 12 15
15 2 2 5 5 15 15 15 12 12 14 14 14 12 13 4
16 5 5 15 15 15 12 12 12 12 12 14 14 12 14 9
17 15 15 15 15 15 14 14 14 14 9 15 15
18 16 16 16 16 16 16 6 16 14
19 16 16 16 16 4
204
20 16 16 16 16 4
1 3 7 16 15 13 10 14 11 13 13 13 13 16 11 13 10 6 4 2 204
n
1 9
2 8 0 F
3 B 7 1
4 1 6 3 0 4 A 5
5 D 5 9 B 4 2
6 0 E 3 7 F B
7 6 F 8 B 3 9
8 5 E B 0 D C
9 2 6 D A 4 E B
10 6 C 2 F 1 4 B
11 F A 8 3 5 1 D E
12 B 1 7 0 8 9 2
13 0 1 E C A
14 D 9 7 2 5
15 4 3 B 0 7 D
16 9 F D E 3 B
17 F 9 1 3 6 2
18 6 9 A 4
19 8 5 7
20 B D 0
Participate!
Ultimately February 1, 2017, supply your name, street address
and the solution (the numbers in the gray boxes) by email to:
[email protected]
3 6 4 5 A 7 B F 8 D E 0 2 9 C 1
D E 1 7 C 0 2 8 F 9 3 5 A B 4 6
A F 0 2 9 D 1 5 C B 4 6 8 E 3 7
Prize Winners 9 8 B C 3 4 6 E A 1 7 2 5 D F 0
The solution of Hexadoku installment 5/2016 (November & E C 3 6 D 8 4 7 0 2 F 9 B A 1 5
December) is: 6182F.
4 1 2 8 B 5 0 3 D 6 A E C F 7 9
The €50 / £40 / $70 book vouchers have been awarded to: 5 7 9 0 F A C 2 3 8 B 1 4 6 D E
Eugene Stemple (USA); Michael Staffler (Germany); B A F D E 1 9 6 4 C 5 7 3 0 8 2
Dirk Dreesen (Belgium). C 0 E B 2 9 7 4 6 A 8 3 D 1 5 F
Congratulations everyone! 1 2 A F 5 B 3 0 7 4 9 D 6 8 E C
6 3 8 4 1 E D C B 5 0 F 9 7 2 A
7 5 D 9 6 F 8 A 1 E 2 C 0 3 B 4
F 9 5 E 0 C A 1 2 3 D 8 7 4 6 B
0 B 6 1 8 2 F D 9 7 C 4 E 5 A 3
2 D 7 3 4 6 E B 5 0 1 A F C 9 8
The competition is not open to employees of Elektor International Media, its
8 4 C A 7 3 5 9 E F 6 B 1 2 0 D
subsidiaries, licensees and/or associated publishing houses.