Wifi Remote Control: Recycle Your Atx Power Supply

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

www.elektor-magazine.

com
magazine
June 2013

WiFi Remote
Control
for LED ribbon strips, relays, actuators and motors

Wi-Fi Controller Board l Recycle your ATX Power Supply


Off to the EF Library l Lost Model Finder l Lithium-ion Battery
Recycling Made Easy l Taming the Beast (5) l From BASIC to US $9.00 - Canada $10.00

Python (2) LCR Meter Shootout


  Konrad Zuse’s Z1 through Z4
Fax : + 81-72-620-2003 FPGA / CPLD Boards from JAPAN
SAVING COST=TIME with readily 5" LCD Touch Panel Module
available FPGA boards 5 inch TFT full color LCD display
with WVGA(800x480) resolution

Basic and simple features, single power supply operation resistive touch panel

Quality and reliability is provided by years of sales

Same board size and connector layout – ACM/XCM series

All stocked items are ready to be shipped immediately UTL-021

Over 100 varieties of FPGA/CPLD boards are available

Customizing speed grade and/or any features are possible • 3.3 V single power supply operation

Free download technical documents before purchasing • Piezo buzzer to beep
• Useful plastic bezel is included to assemble

High quality and highly reliable FPGA /CPLD boards from Japan • LTM-compatible pin assignment

Almost all products are RoHS compliance
ALTERA FPGA Board XILINX FPGA Board FPGA/CPLD Stamp Module
[email protected]

Cyclone IV E F780 FPGA board Spartan-6 FGG484 FPGA board PLCC68 Series
ACM-204 series XCM-018/018Z series Easy and Quickly Mountable Module
EP4CE30F29C8N XC6SLX45-2FGG484C FPGA Module IC socket mountable
EP4CE40F29C8N XC6SLX75-2FGG484C • 50 I/Os (External clock inputs
EP4CE115F29C8N XC6SLX100-2FGG484C are available)
Credit card size (86 x 54 mm) XC6SLX150-2FGG484C
Credit card size (86 x 54 mm) • 3.3V single power supply
RoHS compliant
operation (Voltage converters for auxiliary
RoHS compliant
power supply are built-in)
• Separated supply-inputs: Core, I/O drivers
Arria II GX F572 FPGA board Virtex-5 FFG676 FPGA board
• JTAG signal
E-mail :

ACM-025 series XCM-109 series • All PLCC68 series have common pin
assignment
EP2AGX45DF25C6N XC5VLX30-1FFG676C
• Very small size (25.3 x 25.3 [mm])
EP2AGX65DF25C6N XC5VLX50-1FFG676C
EP2AGX95DF25C6N XC5VLX85-1FFG676C • RoHS compliance
EP2AGX125DF25C6N XC5VLX110-1FFG676C • MADE IN JAPAN
Credit card size (86 x 54 mm) Compact size (43 x 54 mm)

RoHS compliant RoHS compliant XILINX PLCC68 Series


www.hdl.co.jp/EL/

Spartan-6 FGG676 FPGA board Spartan-6 PLCC68 FPGA Module


XCM-206 series XP68-03

CycloneIV GX F484 FPGA board XC6SLX100-2FGG676C


XC6SLX45-2CSG324C
3.3V single power supply operation
ACM-024 series XC6SLX150-2FGG676C
On-board oscillator, 50MHz
Credit card size (86 x 54 mm)
RoHS compliant
EP4CGX50CF23C8N RoHS compliant
EP4CGX75CF23C8N
EP4CGX110CF23C8N
EP4CGX150CF23C7N
ALTERA PLCC68 Series
Credit card size (86 x 54 mm)
Spartan-3A FTG256 FPGA board Cyclone III PLCC68 FPGA Module
RoHS compliant
XCM-305 series AP68-04

XC3S700A-4FTG256C EP3C25U256C8N
XC3S1400A-4FTG256C 3.3V single power supply operation
Compact size (54 x 53 mm) On-board oscillator, 50MHz

RoHS compliant
RoHS compliant

USB- FPGA Board


Cyclone IV USB-FPGA Board Spartan-6 USB-FPGA board Universal Board (Type2)
EDA-301 EDX-301 ZKB-106 ■ One for general power (3.3V 3A max)
and the Two variable outputs for
Vccio(0.8V to 3.3, 3A max)
EP4CE15F17C8N XC6SLX16-2CSG225C ■ For ACM/XCM-2 series FPGA boards
Compact size (54 x 53 mm) Compact size (54 x 53 mm) ■ Power Switch and LED
■ Power input:DC5V/2.1[mm] Jack/
RoHS compliant RoHS compliant
Terminal Block (option)
■ Board size : 156x184 [mm]
■ 4 Layers PCB, Thru-hole

See all our products, A/D D/A conversion board,


boards with USB chip from FTDI and accessories at : www.hdl.co.jp/EL/
Join the Elektor Community
Take out a GOLD Membership now!
Your GOLD Membership contains:
• 8 Regular editions of Elektor magazine in
print and digital
• 2 Jumbo editions of Elektor magazine in print
and digital (January/February and July/August
double issues)
• Elektor annual DVD-ROM
• A minimum of 10% DISCOUNT on all
products in Elektor.STORE
• Direct access to Elektor.LABS
• Direct access to Elektor.MAGAZINE; our online
archive for members
• Elektor.POST sent to your email account
(incl. 25 extra projects per year)
• An Elektor Binder to store these 25 extra
projects
• Exclusive GOLD Membership card

ALSO AVAILABLE:
The all-paperless GREEN Membership, which
delivers all products and services, including
Elektor.MAGAZINE, online only.

Take out your Membership now at www.elektor.com/members


Contents

magazine

Community Projects

8 Elektor World 14 Wi-Fi Controller Board will be used. This tool helps both
• The Tube in the Lunchbox Control your home from your beginners and old hands.
• Getting Control mobile phone with this universal
Wi-Fi controller board. We show 34 Lost Model Finder
how to set the color of an RGB Build this radio detection finder and
LED strip, but you can use it for a never lose your radio controlled
variety of other applications. plane again. Simply switch on the
receiver and it points you straight
22 Recycle your to the crash location.
ATX Power Supply
DesignSpark This ATX bench top power supply 40 Lithium-ion Battery
adapter board converts any Recycling Made Easy
Re-using Lithium-ion batteries can
10 Day 1 — Make it just the way standard ATX computer power
be tricky. Often they are charged
you want supply into a convenient supply
inside the equipment, so there
Getting started with DesignSpark for breadboarding and general
isn’t a separate charger available.
PCB and configure it to your likings. workbench use.
Luckily, a charger for used (or new)
This tutorial shows you how to set
Li-ion cells is fairly easy to build.
up your personal preferences in 26 Off to the EF Library!
this latest release of PCB design Using Elektor’s ‘Embedded
44 Taming the Beast (5)
software. Firmware Library’, code for
Although FPGA applications can be
an embedded project can be
designed using schematic diagrams
13 The Cat’s Whisker generated swiftly without the need
with logic symbols, in practice this
Crystal Diode FRIHO D.R.P to know which type of interface

4 | June 2013 | www.elektor-magazine.com


Volume 4 – No. 54 June 2013

Labs Magazine

is usually done with a hardware 64 LCR Meter Shootout 74 Retronics: Konrad Zuse’s Z1
description language. An advantage A quick comparison between through Z4 and beyond
of the latter approach is that Elektor’s 500 ppm LCR Meter Ever since the earliest days of
complex functions are often easier and two other LCR measurement mathematics and logical thought,
to express in algorithms than in devices people have tried to find ways to
schematics. Accordingly, in this simplify the repetitive work involved.
installment we guide you through This article takes a tour of Konrad
the process of programming an Zuse’s impressive contributions to
FPGA application. Industry the development of the computer.
Series Editor: Jan Buiting.
54 From BASIC to Python (2)
This second installment elaborates 66 New Performance Require-
78 Hexadoku
on graph plotting and Fourier
ments for Resistors
Elektor’s monthly puzzle with an
Today’s aircrafts are increasingly fuel
synthesis. And without much effort electronics touch.
efficient and need to conform to anti-
we setup a graphical user interface.
pollution regulations. The humble
79 Gerard’s Columns: In the
resistor can be helpful, provided
62 Beefing up DAC Resolution Clouds
some of its key specifications are
Improve the resolution of ordinary, A column or two from our
given close consideration.
cheap digital/analog converters columnist Gerard Fonte.
by using the output of one as a
programmable voltage reference
70 News & New Products
82 Next Month in Elektor
A selection of news items received
for the others. A sneak preview of articles on the
from the electronics industry, labs
Elektor publication schedule.
and organizations.

www.elektor-magazine.com | June 2013 | 5


•Community

No. 54, ~June 2013


ISSN 1947-3753 A Case for Boards
Elektor Magazine is published 10 times a year Looking at our readers’ main interests, PCB
including double issues in January/February and July/
design and production rank pretty high. Elek-
August at $80 per year, Canada add $15 per year; by
tor PCBs are famous the world over not just
Elektor International Media LLC for their quality, but also their consistent look
111 Founders Plaza, Suite 300
East Hartford, CT 06108. and feel. How did that come about?
Here at Elektor, the change from manual
Phone: 860.289.0800
Fax: 860.461.0450
artwork design using masking tape and pho-
www.elektor.com tographic reproduction techniques to a 100 %
PC-driven process was gradual, and took
Elektor is also published in French, Spanish,
German and Dutch. Together with franchised place in the early 1990s. The use of a PC to
editions the magazine is on circulation in more than draw a schematic and then run a PCB design
50 countries.
program was not forced or even suggested by
Memberships: the publishers at the time. Back then, some
Elektor USA
P.O. Box 462228 of the younger lab designers boldly set out to discover the advantages of the PC
Escondido, CA 92046. route, eventually supplying files instead of drawings to their colleagues in the
Phone: 800-269-6301
PCB design department. Others stuck to pencil, paper and rubber with equally
E-mail: [email protected] good results particularly in RF and space critical designs. No matter how the final
Internet: www.elektor.com artwork got produced, Elektor never actually mass-produced their circuit boards—
Head Office: this was always farmed out to PCB manufacturers. We did, however, handle the
Elektor International Media b.v. storage and packaging of what must have amounted to hundreds of thousands of
PO Box 11
NL-6114-ZG Susteren those blue and green boards. Also, to this day Elektor Labs have their own PCB
The Netherlands etching and drilling facilities. The equipment is used to make prototypes and one-
Telephone: (+31) 46 4389444,
Fax: (+31) 46 4370161
offs of any board, single or double sided, TH or SMD.
I do recall the excitement in the lab and editorial offices about 20 years ago when
Advertising: a parcel arrived containing 500 or so boards for a recently published project.
Strategic Media Marketing
Peter Wostrel At last, the proud designer was able to see the fruit of his design efforts. More
2 Main Street importantly however, readers all over the world were able to construct circuits on
Gloucester MA 01930.
superbly produced circuit boards with a component overlay and silk screen finish!
Phone: 978-281-7708, Today, there is still the satisfaction not only of publishing these wonderful designs
Fax: 978-281-7706
E-mail: [email protected]
and getting response from you, but also of holding a perfectly machined printed
Advertising rates and terms available on request. circuit board with an Elektor production number printed to aid identification.

Jan Buiting, Managing Editor


Copyright Notice
The circuits described in this magazine are for domestic
use only. All drawings, photographs, printed circuit
board layouts, programmed integrated circuits, disks,
CD-ROMs, DVDs, software carriers and article texts
published in our books and magazines (other than third-
party advertisements) are copyright Elektor International
Media b.v. and may not be reproduced or transmitted The Team
in any form or by any means, including photocopying,
scanning and recording, in whole or in part without prior Managing Editor: Jan Buiting
written permission from the Publisher. Such written
permission must also be obtained before any part of Publisher: Hugo Van haecke
this publication is stored in a retrieval system of any
Membership Manager: Shannon Barraclough
nature. Patent protection may exist in respect of circuits,
devices, components etc. described in this magazine. International Editorial Staff: Harry Baggen, Thijs Beckers, Eduardo Corral, Wisse
The Publisher does not accept responsibility for failing
to identify such patent(s) or other protection. The
Hettinga, Denis Meyer, Jens Nickel, Clemens Valens
submission of designs or articles implies permission to Laboratory Staff: Ton Giesberts, Luc Lemmens, Tim Uiterwijk,
the Publisher to alter the text and design, and to use the
contents in other Elektor International Media publications Clemens Valens, Jan Visser
and activities. The Publisher cannot guarantee to return
Graphic Design & Prepress: Giel Dols, Jeanine Opreij, Mart Schroijen
any material submitted.
Online Manager: Daniëlle Mertens
© Elektor International Media b.v. 2013
Printed in the USA Managing Director: Don Akkermans

6 | June 2013 | www.elektor-magazine.com


USA
Hugo Van haecke Our network
+1 860-875-2199
[email protected]

United Kingdom
Wisse Hettinga
+31 46 4389428
[email protected]

Germany
Ferdinand te Walvaart
+49 241 88 909-17
[email protected]

France
Denis Meyer
+31 46 4389435
[email protected]

Netherlands
Harry Baggen
+31 46 4389429
[email protected]
Connects you to
Spain
Eduardo Corral
+34 91 101 93 95
[email protected]

Italy
Maurizio del Corso
+39 2.66504755
[email protected]

Sweden
Wisse Hettinga
+31 46 4389428
[email protected]

Brazil
João Martins
+55 11 4195 0363
Supporting Companies
[email protected]
AP Circuits Pololu
www.apcircuits.com . . . . . . . . . 33 www.pololu.com . . . . . . . . . . . . 33
Portugal
João Martins
+351 21413-1600 Beta Layout Saelig
[email protected] www.pcb-pool.com . . . . . . . . . . 39 www.saelig.com . . . . . . . . . . . . 73

India Cleverscope
Sunil D. Malekar www.cleverscope.com . . . . . . . . 39
+91 9833168815
[email protected] DLP Design
www.dlpdesign.com . . . . . . . . . 33
Russia
Nataliya Melnikova ExpressPCB
+7 (965) 395 33 36
[email protected] www.expresspcb.com . . . . . . . . 71

EzPCB
Turkey
Zeynep Köksal www.ezpcb.com . . . . . . . . . . . . 53
+90 532 277 48 26
[email protected] Fabstream
www.fabstream.com . . . . . . . . . . 9
South Africa
Johan Dijk HuMANDATA
+31 6 1589 4245 www.hdl.co.jp/EL/ . . . . . . . . . . . . 2
[email protected]

China Not a supporting company yet?


Cees Baay Contact Peter Wostrel ([email protected], Phone 978-281-7708, Fax 978-281-7706)
+86 21 6445 2811
[email protected] to reserve your own space for the next edition of our members' magazine

www.elektor-magazine.com | June 2013 | 7


•Community

Elektor World
Compiled by
Wisse Hettinga

 
The Tube in the Lunchbox:
reader comments
Elektor readers like you, consistently demonstrate the
true spirit behind the magazine, enhancing and extending the
editorial content with your own investigations and experiments. Component
related articles remain the most popular and in last April’s Elektor World we
showed the ‘Tube in the Lunchbox’ and asked for more details.
Among others, Christopher Kessler from Germany and Jan Swenker from The
Netherlands dug out more information on this. Christopher found the specs of
this tube in the “Valvo Fotovervielfacher 1978-79”. In total he found 6 pages
of information on the device and figured that its current price tag was around 30 dollars. Jan’s information
confirms the date of origin: 1978. He pointed us also to the Hamamatsu Photomultiplier Tubes book from
1986 (you can find the PDF on the internet). The book has the specs of a replacement tube, the model
R1450... It is time to get our hands dirty getting this tube to work!
Many thanks to Jan and Christopher

 Getting control
“In engineering, control system theory focuses on how to manipulate a
system’s inputs to change its behavior. DIYers are familiar with many
simple, open-loop control systems — such as those in basic stepper
motors. But today, project kits for everything from robotic sumo cars
to auto-piloted model aircraft demand DIYers learn more about the
theory behind complex, closed-loop control systems”, Brian Douglas
says in his “Tech the Future” essay in Circuit Cellar magazine’s June
2013 edition. “DIYers aren’t going back to the classroom, they’re going
online — educating themselves on websites and turning to open-source
software and hardware”. Douglas should know. The Seattle-based
control systems engineer has a YouTube site dedicated to fostering a
practical understanding of control system theory, www.youtube.com/
user/ControlLectures. Douglas is one of the essayists featured in CC’s
recurring “Tech The Future” section, which focuses on developing
trends and breakthroughs in technology. Visit circuitcellar.com/
category/tech-the-future to read more of Douglas’s essay, and others.

8 | June 2013 | www.elektor-magazine.com


Day 1 – Make it
just the way you want
By Neil Greunding The good folks at RS Components have just released version 5.0 of
DesignSpark PCB and the first thing I like to do with a new tool is to get it
configured just the way I like it. DesignSpark lets you configure everything on
a per file basis or globally.

Today I will walk you through how to make global primitives like shapes, text and tracks. Each style
setting changes using DesignSpark technology has a name to make it easy to reference, just
files so that you can make DesignSpark work like in a word processor. I normally try to give
just the way you want. styles meaningful names so that you can know
what the style is without checking its properties
Getting started directly. For example, having a style named “Via”
But before we start configuring DesignSpark is ok if you only have one via but calling it “Via
it’s important to know that DesignSpark uses (0.45 mm x 0.95 mm)” makes it immediately
styles to specify the formatting rules for design obvious that the via has a 0.45 mm drill and a
0.95 mm copper pad. You are free to add custom
styles to the technology files but this discussion
we will be focusing on the system default styles
like “[Symbol Names]” which is the style name
used for reference designators and component
names.

Also, don’t forget to double check the DesignSpark


technology file path which can be changed on
the General tab in the Settings->Preferences
menu. In my installation I had to change it to C:\
Users\Public\Documents\DesignSpark PCB 5.0\
Technology. If this path is incorrect DesignSpark
Figure 1.
won’t find any technology files automatically
Schematic with default
parameters. which makes it harder to use. You can check
if the directory path is correct if it contains .ptf
and .stf files.

Schematic technology files


Schematic technology files are where you can
configure:

• The line styles used for terminal and junction


connections
• Predefined text styles used in the schematic
(font, size, etc.)
• How various line elements are drawn (solid,
Figure 2. dashed, etc.)
Default Fonts set to Arial. • How the connection line elements are drawn

10 | June 2013 | www.elektor-magazine.com


TIPS & TRICKS

(solid, width, etc.)


• Any predefined electrical nets, although I
would do this in the schematic instead
• Any predefined electrical net classes
(ground, power, etc.)
• The colors used to draw various elements
You can change these parameters from the
Settings->Design Technology menu and in the
View->Colors menu.
You can see what the default parameters look like Figure 3.
by loading an example project. The chipKit Max32 Configuring the layers.
project schematics should appear as shown in
Figure 1.
resolution.
I personally find that the stroke fonts look old • The design grids, especially the working grid
fashioned and so I like to change them to Arial • The layer stackup and colors
since it’s a standard true type font. After playing • The track spacing and clearance rules
around for a few minutes this is what I came up • The pad and track styles, although you
with Figure 2. would usually specify the pad styles in your
library components and only specify the
So how do we implement this in the schematic default track styles in the technology file
technology file? The first thing you need to do • The default net classes, but I usually specify
is open the default.stf schematic technology file them in the schematic instead
which is normally located in C:\Users\Public\ • Autorouter and autoplacer rules
Documents\DesignSpark PCB 5.0\Technology • Basic design elements like board shapes,
which will open as a blank schematic document. mounting holes, etc.
Now open the Settings->Design Technology menu
and change the Net Names, Pin Names, Pin Let’s see how this works by working through an
Numbers and Symbol Names text styles to use an example for a simple 2-layer board. The first step
Arial font with a height of 80. I also changed the is copy and existing technology file so we don’t
Normal text style to Arial as well but with a size have to start from nothing, so let’s start with C:\
of 120. I then went into the View->Colors menu Users\Public\Documents\DesignSpark PCB 5.0\
and changed the Pin Names and Pin Numbers Technology\metric.ptf to and save it with a new
fields to black. name like my2layer.ptf. The first thing to modify
Once you’ve made all of your changes, save is the design units in Settings->Units menu. I
the technology file so you can use it for new always use mm with a precision of 4 decimal
schematic pages by selecting “default.stf” in the places, but if you prefer imperial units choose in
new document menu window or mil instead. You can then set up your preferred
design grids in the Settings->Grids menu.
PCB technology files
PCB technology files are one of the best Configuring the layers in done on the Layers
DesignSpark features because they let you tab in the Settings->Design Technology menu.
combine all of your basic design rules and layer By default the metric technology file has a Top
stackups into files that are easily reused. For Silkscreen, Top Copper, Documentation, Bottom
example, I have a file for simple low cost 2-layer Copper and Bottom Silkscreen layers already
boards and another for 4-layer boards. I can then defined. Since all my boards are surface mount,
choose which file I want to use when creating a I added a Top Paste, Top Solder Mask, Bottom
new PCB document. This feature isn’t common Solder Mask and a Bottom Paste layer. You
with other PCB design packages. can add layers by clicking on the Add button
and entering the layer parameters as shown
PCB technology files let you configure: in the example of the Top Solder Mask layer
• The design units (mm, mils, etc) and the in Figure 3.
making the minimum 0.25 mm so that you can
route the power traces onto the component pads.
The final step is to edit the via styles in the Pad
Styles tab. For a basic technology 2-layer board
I would use a via with a 0.45 mm drill with a
0.95 mm pad. You can also define other via styles
if you like to use a variety of different via sizes.
At this point you have a set of basic design rules
and constraints for a basic 2-layer board that
can be easily reused with future 2-layer boards.
When you create a new PCB design, select the
appropriate technology file when prompted in
the PCB Creation Wizard.
Figure 4.
Configuring the layers.
Conclusion
Once you’ve added all the layers you want, you Now that we have configured DesignSpark’s
can order them properly in the layer stackup by default parameters the next steps are to
moving them up and down in the Layers window. configure DesignSpark’s libraries and to create
When you’re done you should see something some documentation templates. Fortunately
like Figure 4. DesignSpark comes with a large set of libraries
which makes getting started much easier.
Next, let’s configure the spacing rules by clicking (130172)
on the Spacings tab. Here you will see a matrix
of all the spacing rules between the different
object types. For a basic 2-layer board with 10-mil
tracks and 10-mil spacing, the rules could look
like in Figure 5.

Also don’t forget to click on the Rules tab. The


important parameters are the minimum annular
ring and the component spacing. After that it’s Hi, I’m Neil Gruending and I have used
time to set the default track widths in the Track numerous different PCB CAD packages as
Styles tab. For a 10 mil/10 mil board I would set an electronics design engineer over the
the minimum and normal signal track widths to years. I’m pretty particular about my tools
0.25 mm. The power track widths can be anything and I like to learn how to maximize my
you want for the normal width, but I recommend productivity with them whenever possible.
I also enjoy sharing what I’ve learned on
my website at www.gruending.net and on
Twitter as @ngruending.

Figure 5.
Design rules.

12 | June 2013 | www.elektor-magazine.com


weird World of Components

The Cat’s Whisker


Usually when I start writing an article, for inspira- To be honest, I have no idea how or when I Wisse Hettinga
tion I look at what’s around on my desk. For this acquired this component, but in my early years (Elektor)
edition of Weird World of Components a Crystal I used to spend a lot of time browsing stuff in a
Diode type FRIHO D.R.P. caught my eye. It is renowned shop called Quakkelstein in Vlaardin-
mentioned in an old Radio Bauer Katalog from gen, The Netherlands. Most likely this was where
1926 — we are talking old stuff here — and it is I picked it up and since then it had been living on
one of the main components of old crystal radio my desk or in my drawer. Now this component
systems. takes us back to the early days of Radio. It is an
automated ‘cat’s whisker’ diode. Turning the knob
changes the position of a small wire (the whisker)
on the galena crystal, allowing you to find the
best spot for the diode to be doing what a diode
should do: pass current in one direction only.
This is what listening to the Radio encompassed
those days. To get a decent signal you needed to
twist and tweak the inductor, the capacitor and
the rectifier diode.

But how good where these diodes compared to


what we have today? To measure the character-
istics of a diode is really simple. Basically, if you
1
want to do a decent job getting the I-V charac-
teristic, all you need is a power supply, a voltage
meter and an ammeter. Getting this diode to work
properly is challenging to say the least. You need
to fiddle around a bit to find the right spot where
the diode effect peaks. I started out trying to find
that spot with an ohmmeter, but soon I had to
conclude that wasn’t going to work. The mea-
surement results were all over the place. I was
ready to give up when I decided to give it a final
shot and bring in some more equipment. An HP
generator, a Hameg HMO1522 oscilloscope and a
330-ohm resistor finally gave me some promis-
2 ing results. In Figure 2 the oscilloscope displays
a very fuzzy signal, but with some imagination
you can see the FRIHO cutting of the sinusoidal
input signal. Figure 3 shows the characteristic
of a present-day diode in the same measure-
ment setup.

Looking at the results I am amazed a component


like the FRIHO D.R.P. actually worked! Today a
huge variety of diodes exists for all kinds of appli-
cations. Small signal diodes, zener diodes, vari-
cap diodes or varactors, tunnel diodes, and all of
them are available in a variety of packages. It is
interesting to realize they all relate to this very
3 old Cat’s Whisker diode in some way.
(130169)
•Projects

Wi-Fi Controller Board


Control RGB LED strips, motors,
relays & stuff, but no wires

With Wi-Fi modules pervasive


it’s high time to start
thinking about adding
household appliances to
your home Wi-Fi network.
Controlling your home
from your mobile phone
has never been easier
thanks to the universal
Wi-Fi controller board
presented here.
Although we used
it to set the color
of an RGB LED
strip, you can use
the board for a
plethora of other
applications.

By Clemens Valens The project you are about to encounter took a Also, I wanted a web browser based application,
(Elektor.Labs) while to complete. It all started a year ago with compatible with most browsers, and that used
a Home Automation system [1] originally devel- sliders to control the color of the strip. So Koen
oped by two trainees at Elektor Labs, Koen and set out to develop the lot, but unfortunately his
Jesper. One part of their system was an RGB trainee period ended before he could finish the
LED strip controlled over Ethernet, i.e. with a project and he went back to college. Before he
cable. The idea was nice, but I felt that a wireless left Elektor, Koen had explained to me the prob-
connection would be a more appealing solution. lems he had run into, some of which still needed

14 | June 2013 | www.elektor-magazine.com


Wi-Fi Controller Board

addressing. I then took it on me to finalize the


project, and so it spent the next few months on
my desk gathering dust! When I finally found the
time and energy to dive into it, I failed to recall
most of what Koen had told me, and basically I
had to start all over.

Koen’s circuit was essentially an ATmega328 AVR


microcontroller (MCU) controlling three MOSFETs
with PWM signals to regulate the intensity of the
three colors. For the Wi-Fi connection a WizFi220
module from WIZnet was used that communicates
with the MCU over a simple serial link. Since I
was in possession of an Arduino shield sporting
this very Wi-Fi module [2] and since an Arduino
Uno board is based on an ATmega328, I decided
to build my prototype as an Arduino application.
All I needed was a second shield with the MOS-
FETs on it so that I could drive the LED strip. This
was quickly slapped onto a piece of prototyping
board (Figure 1).

Then it was programming time. Parsing the HTTP


commands received from the Wi-Fi module and JavaScript that made the browser change its com- Figure 1.
sending back the required answers was not so munication port before it would send a command. The prototype based on an
complicated, but when I wanted to change the This workaround also involved using the HTTP GET Arduino Uno, an Elektor
web page I ran into Koen’s problems. First of all command to send the color data, whereas this com- Wi-Fi shield (120306) and a
piece of prototyping board.
there were the sliders that control the LED strip’s mand is actually meant to get data from a server
color from within a browser that I had so light- (who would have guessed that?). To send data you
heartedly requested. As I then learned, there are supposed to use the POST (or PUT) command.
are no sliders in standard HTML. Searching the
Internet I discovered that HTML 5 may be aware A much more elegant solution however is to add
of sliders, but only very few browsers support it, the line “Connection: close” to the server’s
so HTML 5 was not an option. Koen had solved reply to a GET command. Now I could delete the
this by using the JavaScript libraries JQuery and workaround script, making the web page much
JQuery-UI [3]. These are online libraries for web smaller, and I could switch to using the POST
pages to use to implement all kinds of nifty con- command, which, I felt, was more appropriate.
trols and other functions. Some inconveniences This is what the POST command looks like when it
of these libraries are that they are online, mean- is send by Firefox (the color data is at the end):
ing that you need an Internet connection to use
them, and also that they are too large to put POST / HTTP/1.1
them in the MCU’s program memory. Since I had Host: 192.168.2.15
no other solution, I decided to stick to the use User-Agent: Mozilla/5.0 (Windows NT 6.1;
of the online JavaScript libraries. WOW64; rv:17.0) Gecko/17.0 Firefox/17.0
Accept: */*
Looking through Koen’s web page code I suddenly
Accept-Language: en-US,en;q=0.5
remembered the problem he had mentioned before
Accept-Encoding: gzip, deflate
he left: for some reason the Wi-Fi module closed
DNT: 1
the connection after receiving a command, disal-
lowing the browser to send more commands. Con- Connection: keep-alive
sequently you could change the color of the LED Content-Type: application/x-www-form-
strip just once, unless you rebooted the module. urlencoded; charset=UTF-8
Koen had found a workaround using a complicated Content-Length: 23

www.elektor-magazine.com | June 2013 | 15


•Projects

Origin: null
PWM color control in software.
Pragma: no-cache Porting the AVR code to the PIC should have
Cache-Control: no-cache been an easy and straight forward exercise, but
it wasn’t. Of course I had complicated things a bit
red=79&green=10&blue=20 by wanting to include a bootloader and USB func-
tionality, but Microchip could have made it a bit
The next step was to make the web page look easier. I was using my super-duper full-featured
pretty on mobile devices. On my smartphone the XC8 compiler that Microchip is raving about but
sliders were shown very small, making it impos- found it impossible to get the USB code to com-
sible to move them with any precision. The solu- pile, let alone to work. I got this code from the
tion was to add the viewport meta tag to the Microchip Application Libraries v2012-10-15 and
header of the web page, like this: only after many hours of fruitless fiddling with
compiler settings and pragmas did I find a state-
<meta name=’viewport’ ment somewhere on the internet saying that XC8
content=’width=device-width, user- is not (yet) compatible with the Microchip Appli-
scalable=no’ /> cation Libraries. Duh! I needed another compiler.
Again internet came to the rescue and within fif-
With this line added to the HTML code of the web teen minutes I had an official full-featured C18
page it now nicely filled the screen of my Android compiler up and running without shelling out a
phone while looking good on a PC as well. (On dime. Another fifteen minutes more and I had
an iPad it occupied only about a quarter of the the USB serial port example up and running.
screen and I have not tried to improve that.) Now it was time to add my Wi-Fi code — which
Meanwhile I had also optimized the size of the went pretty smoothly except for fitting all the
rest of the program and now my goal was to data in the PIC’s segmented RAM — and try it
make it all fit in as little memory as possible. An out. And of course it worked. Not. Actually, it
important improvement came from compress- worked a bit. I could change the color of the
ing the web page. You can do this with gzip and strip once or twice, but then Wi-Fi communica-
then add the line “Content-encoding: gzip” tion would stop. When I controlled the strip over
to the server’s reply. Most, if not all, browsers the USB serial port, it all worked fine. So, back
will know how to handle zipped web pages. The to the debugging table where I discovered that
disadvantage of doing this is that it is now a bit the USB interrupt seemed to hold up the serial
more complicated to change the web page; there- port interrupt, causing data loss. By this time I
fore you only do this when its design is finished. was pretty fed up with it all and decided to sim-
ply disable the USB port in Wi-Fi mode instead of
At that point I had a fully working prototype based going to the bottom of the problem. (I suggest
on Arduino compatible hardware with software that you give it a try if it really interests you. Please
compiled within the Arduino IDE. If you want the let me know if you find the solution.)
details, please visit [4]. I could have stopped here,
but I wanted better hardware; a stack of three Building it
PCBs for such a simple circuit just didn’t feel right. Now my second — PIC-based — prototype was
Looking for an MCU with fewer pins I found that I functioning as intended with the parts I wanted
could not stay on Atmel’s AVR platform because to use (Figure 2); the time to design a nice PCB
the parts that would be suitable are difficult to had finally come. Since the goal was to control
get. However, I did happen to have a couple of an LED strip, I decided to build it into a small,
Microchip PIC18F14K50 devices lying around. This discreet enclosure. The PCB is designed in such
is a 20-pin MCU with USB, which was interest- a way that the enclosure requires minimal tool-
ing because that would allow for comfy PC-based ing, especially when you use the blue transpar-
configuration of the Wi-Fi module (see also [2]). ent version that allows you to view the status
Another interesting feature is the USB bootloader LEDs inside. In that case no drilling is needed at
Microchip provides (for free), which enables easy all; you only have to trim some standoffs inside.
firmware development without a special program- Even with a 20-pin MCU several pins remained
mer. Unfortunately, this MCU has only one PWM unused so I added some extra functionality to
channel, so I had to implement the three-channel the board. In combination with the bootloader

16 | June 2013 | www.elektor-magazine.com


Wi-Fi Controller Board

this made the board into a much more versatile sion port and three power channels;
platform that you can use for other applications • FlowBoard compatible with FlowStone 3 [5];
as well. It can be used as: • something I have not imagined yet.

• Wi-Fi RGB LED (strip) controller; To make these different applications possible the
• three-channel controller to switch relays or board has been equipped with a switched mode
control motors over Wi-Fi or USB (or both); regulator so it can be powered from a 7 V to
• USB to serial port adapter; 40 V DC power supply without wasting too much
• rapid prototyping system with Wi-Fi, expan- calories. The board can also be powered from

D4
IC3 +5V IC2 +3V3
1N5819 LM2575T-5.0/NOPB T P2 MCP1825S-3302E/AB TP3
Vin 1
FB
4 +5V +3V3
5 2
L1 +5V
OFF
330u 1A
TP4 C9 D3 C8 C4 C5 C6 C7
Vin 3
10u 10V 100n 10u 10V 100n
100u 50V 330u 16V
GND TP1
1N5819

JP1 ICSP
+5V D1
1N5819
1
2
3
4
5
6
1
2
R1
IC1 JP3
K1
1 20 1
1k VDD VSS VBUS
2 19 2
RA5/OSC1 D+ D-
X1 3 18 3
RA4/OSC2 D- D+
4 17 C3 4
RA3/MCLR VUSB GND
S1 5 16 100n
C2 C1 RC5 RC0
3x 1N5819 12MHz 6
RC4 RC1
15
USB-B
7 14
D11 D10 D9 22p 22p RC3 RC2
8 13 JP2
RC6 RB4 1
K2 9 12
RC7 RB5/RX 2
R2 10 11
1 T1 RB7/TX RB6 3
2 4
3
T2 1k
PIC18F14K50-I/P 5
4 Vin
5 IRL540
D5 TXD RXD EXPANSION
T3 TP6 TP5
6

IRL540
K3
BARREL JACK
IRL540
+3V3

R6 R3 R4 R5
GPIO29
32

33

34
9

TP8
1
VBAT VIN_3V3 EN_1V8 VDDIO
EXT ANT
47k 1k 1k 1k
2 47 D6
JTAG_TCK GPIO28
3 MOD1 46 LINK
JTAG_TDO GPIO29
4
JTAG_TDI WizFi220 GPIO30
45 D7
5 44 OK D8
JTAG_TMS GPIO31
6 43 RXD
JTAG_NTRST UART0_CTS/GPIO24 R8
7 42
ALARM1 UART0_RX/GPIO0
8
RTC_OUT1 UART0_RTS/GPIO25
41 BZX79-C3V0 D2 1k
10 40
DC_DC_CNTL UART0_TX/GPIO1
11 39
ALARM2 UART1_TX/GPIO2
12 38 GPIO27
ADC1 UART1_RX/GPIO3 TP7
13 37
14
ADC2 UART1_RTS/GPIO27
36
Figure 2.
MSPI_MISO/GPIO6 UART1_CTS/GPIO26
15
MSPI_MOSI/GPIO7 EXT_RESETN
35
+3V3 Circuit diagram of the
16 30
17
MSPI_CLK/GPIO5 SSPI_MOSI
29
Wi-Fi Controller Board.
VOUT_1V8 SSPI_CS
R7
19
MSPI_CS0/GPIO4 SSPI_CLK
28
Did you ever notice how
20 27
MSPI_CS1/GPIO13 SSPI_MISO
21
I2C_CLK/GPIO9 I2C_DATA/GPIO8
26 people always connect the
47k
22
PWM0/GPIO10 GPIO21/CLK_11MHZ
25
barrel jack the wrong way
23
GPIO19/CLK_44MHZ GPIO20/CLK_22MHZ
24 T4
GND GND GND GND
R9 around? The center pin is
10k supposed to be the common
1

18

31

48

BC547 120718 - 11 connection. I was wicked


here on purpose because of
PCB layout considerations.

www.elektor-magazine.com | June 2013 | 17


•Projects

For the power connector you can either use a


center-pin barrel jack or a standard 2-pin .2’’
pitch PCB terminal block. A diode provides a basic
protection against polarity inversion.
A 5-pin extension header allows the use of the
free MCU ports for custom purposes. A row of
test points extends this connector in one direc-
tion; the in-circuit serial programming (ICSP)
connector extends it in the other direction. All
together they give access to ten MCU pins and
all the power supplies. An LED connected to RC4
and a pushbutton are available too. Because the
application program can be changed easily thanks
Figure 3. to the bootloader and the USB interface, these
A typical RGB LED strip with
options make the board into an excellent rapid
an adapter cable salvaged
prototyping platform.
from a PC power supply.
All parts (except the Wi-Fi module) are standard
the USB port, but keep in mind that the Wi-Fi through-hole parts so it should not pose any
module may consume quite a lot of power when problems to assemble the board. I suggest you
it is transmitting. A large 3.3-V linear regula- mount the Wi-Fi module first as it is a bit fiddly
tor provides power for the Wi-Fi module (due to to position properly because of its many connec-
current requirements you cannot use the 3.3 V tions. Note that the voltage regulators should be
regulator integrated in the MCU). The module is mounted lying on their belly (see Figure 4, or on
accompanied by three status LEDs indicating if the solder side of the board). The reason for this
the module is connected to an access point or is that if you don’t use the proposed enclosure
not, and if data is being exchanged. Because the and you mount them standing up, they can eas-
MCU is powered from 5 V and the Wi-Fi module ily be screwed to a heat sink (not that you really
from 3.3 V, level converter circuitry was added need one). The MOSFETs should lie on their back
for the inputs of the Wi-Fi module. The MCU can to fit in the enclosure.
handle 3.3 V-level input signals directly. If the LEDs must stick through the enclosure
you should drill the holes first to get the length
The MCU is clocked from a 12-MHz crystal oscil- of their leads right. LED D5 (connected to RC4)
lator to get the USB timing right. The pushbut- and the pushbutton each have been positioned
ton connected to the reset pin (MCLR) will serve exactly under a standoff so that you can drill
mostly to activate bootloader mode (the external holes for them without tedious measuring first,
reset input must be disabled for this to work, fuse just drill through the standoffs. The enclosure
MCLRE=OFF). If the bootloader is not needed, this has a battery trap allowing you to mount Wi-Fi
pushbutton can function as a reset button or it status LEDs on the solder side so you can see
can be used for some other function. them only when you open the trap.
The pushbutton needs a cap of the right height.
The three conservatively rated MOSFETs feature The 16-mm model will be almost flush with the
an RDS(on) of 0.077 Ω, can switch up to 100 volts top side of the enclosure.
and are protected by flyback diodes so they can
handle inductive loads too. As an output con- To fit the PCB in the enclosure you need to trim
nector I have opted for a standard 4-pin .2’’ in the top cover the four standoffs that keep
(5.08 mm) pitch PCB terminal block even though the enclosure together. An easy way to do this
most of the LED strips I have seen are equipped is with a large drill bit. Do not trim too much or
with a smaller pitch connector. However, since the screws won’t have any material left to bite
I do not know how standard these connectors into. You should also break away the two bits of
are or if they are all wired in the same way, I plastic meant to keep the battery in place.
preferred a more flexible solution. You can easily The Wi-Fi module has a small connector for a
make an adapter cable from, say a floppy disk better antenna (Figure 5). If you use it, just
drive power cable (Figure 3). leave it dangling.

18 | June 2013 | www.elektor-magazine.com


Wi-Fi Controller Board

Programming the board


The firmware you can download for this project
[6] contains the bootloader, the RGB LED strip
application and the fuse settings in a single HEX
file. Burn the HEX file into the MCU using an
appropriate programmer (PICKIT, ICD or other)
and you’re set. With the bootloader programmed
in the MCU you’re ready to upload your own appli-
cations. The procedure is as follows:

• do not power the board, make sure JP3 is


not in place;
• connect the board to a free USB port of your
PC;
• press pushbutton S1 and keep it pressed
while you place JP3. Actually, instead of JP3,
I used a normally-closed (NC) pushbutton
(microswitches are perfect for this). In this
case, while you hold down S1, briefly press sion connector) and then connect the board to Figure 4.
the microswitch to enter bootloader mode; a free USB port of your PC. LED D5 starts blink- The almost finished
• The PC (Windows, Linux or Mac) should now ing and you can send AT commands to the new board, revision 1.0, fully
detect the board as an HID. If this is the first virtual COM port (the number or name of which assembled. Rev. 1.1 is
time on a Windows PC, you have to show it you will have to get from your operating system). identical except for some
the .INF file that comes with the download; If the Wi-Fi module is connected to an AP (i.e. parts that have been moved
slightly for a better fit with
• on the PC launch the HIDBootloader tool when status LEDs ‘LINK’ and ‘OK’ are both on)
the enclosure.
provided in the download (Windows, down- type “+++” in a serial port terminal program to
load the Linux or Mac version from the force the module into command mode (the ‘OK’
Microchip website) (Figure 6). It should dis- LED should be switched off). Now refer to [2] to
cover the board instantly; configure the module.
• browse to your executable (HEX file) and
click the program button; To put the Wi-Fi module in LAP mode instead
• to quit bootloader mode and to start the requires some dexterity. Watch the blinking LED
application, click the Reset button or toggle closely, and get into its rhythm. When you feel
Figure 5.
the power supply of the board without hold- ready, press pushbutton S1 when the LED is off
Three 2.4 GHz antennas,
ing down S1. and keep it pressed during two full blinks. Release one from Winizen (top)
the button only when the LED goes off after the and the two others kindly
Configuring the Wi-Fi module second blink. If you managed to do this properly provided by the girls from
In [2] I showed you how to configure the WizFi220 then after a second or so the three Wi-Fi status 2J (www.2j-antennae.com).
module over a serial port using AT commands.
This technique is useful if, for instance, you want
the MCU to reconfigure the module on the fly. It
also allows configuration of options not accessible
in another way. The board presented here has
a special mode to allow this way of configuring
the module. The Wi-Fi module offers an easier
way if all you want to do is connect to an existing
Wi-Fi network. In this case you have to put the
module in so-called Limited Access Point (LAP)
mode. The board can do this as well.

For both methods you have to put the board in


USB-to-serial mode first. To do so, connect RC2
to +5 V (for example, with a wire on the exten-

www.elektor-magazine.com | June 2013 | 19


•Projects

LEDs will suddenly flash rapidly several times and


the module enters LAP mode. (If you count three
blinks the module will restore its factory defaults,
it’s a quick way to get you out of trouble.) If you
have the board connected to a serial port moni-
tor you will see the message:

Figure 6. IP SubNet Gateway


Use this tool to upload a 192.168.1.1: 255.255.255.0: 192.168.1.1
new application to the Wi-Fi [OK]
Controller Board.
Now make sure that the module is in range of
the AP you want to use with the board. Check for
new access points with a PC, a smartphone or a
tablet. If all is well you should see one labeled
“WizFiAPxxxx” where xxxx is a number. Con-
nect to it — it is an open AP so you don’t need
any pass phrases — and point a web browser to
the address 192.168.1.1. You should see a page
similar to Figure 7. Click on the link “Find Avail-
able Wireless Networks”. A list will appear with
Figure 7. the networks in range from which you can pick
The WizFi module’s the one you want. Click “Save And Continue”.
configuration page that’s This will take you back to the first form, which
accessible in Limited Access now shows the details of the selected network.
Point mode makes life very
Depending on the security settings of this network
easy.
you can enter a pass phrase. Click the “Save”
button to store the configuration.

Click the link “Network Settings (TCP/IP)” and


fill in the form. I prefer to use a static IP for
the module so I always know its address, but
this is up to you. In the field “S2W Connection
method” type “1,1,,80”. This will turn it into a
serial gateway listening on port 80, the default
HTTP port used by web browsers. Again, feel
free to use another value. When done click the
“Save” button.

The “Administration Settings” link allows you to


enter a password for the module. I have not
used this option.

When done configuring click the “Logout” link.


Now you will see the message “Rebooting…” and
the Wi-Fi connection will be lost. The WizFi mod-
ule will restart and try to connect directly to the
selected network. If all goes well the LEDs “LINK”
and “OK” will light up, meaning that you can now
Figure 8.
connect to the board. Enter the IP address of the
The Wi-Fi Controller Board
module in the browser and wait until you get the
web page as seen from an
Android smartphone. Is blue
page from Figure 8. When the page loads cor-
semi On or semi Off? rectly you are ready to play.

20 | June 2013 | www.elektor-magazine.com


Wi-Fi Controller Board

It was fun to be able to control the lights in my Internet Links


house from the outside with my mobile phone. [1] Elektor Home Control:
However, this is not how I plan to use the board. www.elektor-labs.com/node/2325
My intention is to hook it up to the motorized
[2] Wi-Fi/Bluetooth shield:
garage door so a smartphone becomes the key.
www.elektor.com/120306
It will then also be possible to give access to our
home to someone even when we are (far) away. [3] JQuery(UI):
Indeed, this board has many possibilities, use http://jquery.com & http://jqueryui.com
your imagination! [4] Arduino version:
(120718) www.elektor-labs.com/node/2373
[5] FlowStone (in this issue):
www.elektor.com/130064
[6] Firmware, Eagle PCB files, BOM; ordering:
www.elektor.com/120718

COMPONENT LIST
Resistors (5%, 0.25W) IC2 = MCP1825S-3302E/AB
R1,R2,R3,R4,R5,R8 = 1kΩ IC3 = LM2575T-5.0/NOPB
R6,R7 = 47kΩ T1,T2,T3 = IRL540
R9 = 10kΩ T4 = BC547

Capacitors Miscellaneous
C1,C2 = 22pF, ceramic, 50V, 2.5mm pitch MOD1 = WizFi220 w. antenna, Elektor # 130076-92
C3,C5,C7 = 100nF, Z5U, 50V, 5mm pitch JP1 = 6-pin pinheader, 0.1” pitch, vertical
C4,C6 = 10µF 63V, radial, 2.5mm pitch JP2 = 5-pin pinheader, 0.1” pitch, vertical
C8 = 330µF 16V, radial, 3.5mm pitch JP3 = 2-pin pinheader, 0.1” pitch vertical
C9 = 100µF 50V, radial, 3.5mm pitch Jumper for JP3
K1 = USB-B receptacle
Inductors K2 = Connector 1x4, 90deg, 0.2” pitch, e.g. MSTBA4
L1 = 330µH 1A, 5mm pitch, e.g. Würth Elektronik K3 = DC socket
type 7447452331 20-way DIP socket for IC1
S1 = Multimec type RA3FTL6 w. cap type S09-16.0
Semiconductors X1 = 12MHz quartz crystal, HC49/S case
Enclosure, Hammond type 1593QGY
D1,D3,D4,D9,D10,D11 = 1N5819
PCB, Elektor # 120718-1
D2 = 3V zener diode, e.g. BZX79-C3V0
D5,D6,D7,D8 = LED, green, 3mm
IC1 = PIC18F14K50-I/P
6
5
1 23

4
3
2
1

www.elektor-magazine.com | June 2013 | 21


•Projects

Recycle
your ATX Power Supply
Elegant adapter board makes it easy
By Ben Jordan (USA) This ATX bench top power supply adapter board allows you to convert any stan-
dard ATX computer power supply into a convenient supply for breadboarding and
general electronics workbench use — simply and elegantly.

the-shelf PC ATX switching power supplies. This


Features is great, because somehow (I don’t exactly know
• Outputs for ±12 V, 5 V, 5 V Standby and 3.3 V how) over the years I have accumulated several
• No ATX power supply hacking necessary of them. They all have 3.3 V, 5 V, 5 V Standby
• Easy on and off switching of the connected ATX power supply and ±12 V supply outputs. Granted, on many,
• LED status indication cross regulation of the 12 V rails is not fantastic.
• Capable of handling heavy supply currents But for the vast majority of opamp circuits it is
• Binding posts for each voltage output more than adequate.
• Slots for easy connection of alligator clips
Design considerations
So, why not just put a bunch of banana jack bind-
For any electronics or embedded system tin- ing posts directly on the power supply, as I’ve
kering, you have to have a good power supply. seen so many people do across the web? Good
Now I don’t know about your personal lab equip- question! Here’s why:
ment budget, but mine is rather, well… let’s just
say that I’m married to the head of the finance • ATX PSUs are designed with extremely
department and she’s not exactly an electronics tight clearances inside them. If you go
engineer. You’ve probably crafted a few linear putting binding posts in there, you may be
regulated power supplies over the years, but it’s closing in on safety clearances (and these
no trivial task to design and build a variable high are important. The AC power input side of
powered lab supply. And also, if you’re anything most switching supplies sees voltage spikes
like me, the majority of what you tinker around over 1000 volts and DC busses around
with is digital circuits and low-voltage analog +370 volts. It’s not worth risking life and
stuff, like audio preamps and such. limb!)
• You have a perfectly good computer power
In most cases, I am messing around with a micro- supply, and if you’re anything like me you
controller and a few opamps, so typically it’s may want to use it to power op amps one
handy for me to have a 5 V rail for the controller day, and a computer motherboard the next.
(and any glue logic I might have) and +/-12 V Why modify it beyond its original use?
rails for the opamps. Increasingly, the sample
devices I’m working with (for example the Fre- I wanted a more elegantly designed solution, that
escale DSP56367 DSP or the NXP LPC2101 ARM-7 not only had the binding posts, but also some clip
microcontroller) require low voltage rails for inter- points I could clip alligator leads onto.
nal core and IO, namely 1.8 V and 3.3 V. This is So I set about designing a PCB for adapting
a pain in the butt if you have to build a supply the ATX supply to bench top use. As with any-
with all these rails for each project, but most of thing, a good place to start is to define some
them (except 1.8 V) can be obtained from off- specifications.

22 | June 2013 | www.elektor-magazine.com


ATX power supply adapter

The adapter shall: • be capable of handling heavy supply


currents;
• not alter the power supply itself; • have a switch circuit to make use of the ATX
• use an ATX connector; on/off controller;
• have binding posts for each ATX power • have LEDs to monitor standby and Power
supply voltage and standby; Good signal, and
• have a matching return (GND) binding post • use through-hole PCB design, so you, dear
for each voltage output; reader, can make one for yourself easily.

+5V STBY

VSTBY VSTBY

+3V3
K4 K11 K10 K3
+3V3 16 1
U1 = TC4049B U1
C2 C1 C4
8

100n 100n 100n K15 K18 K2 K1


3 S1 1
+5V0 PB ON

K5 K12 4 2
3 2 5 4
+5V0 1 1
OFF R3 R4 R1
C5 C8 10k U1.A U1.B
220R 220R
100n 100n 7 6
K17 K16 1 D2
J1 D1
U1.C
1 11
2 12 +12V U1.D
FAULT
3 13 K6 K13 9 10
R2 1
4 14 +12V
5 15 10k
C6 U1.E U1.F
6 16
S2 11 12 14 15
7 17 100n 3 1 1 1
K19 K20
8 18
4 2 PB OFF
9 19
10 20 C7
K7 K14
ON
C3
100n VSTBY
–12V
100n PWR
OK
K8 K9

–12V TP1 Figure 1.


ATX ON ATX ON
PWR OK PWR OK The schematic shows how
120619 - 11 simple this power supply
add-on actually is.

www.elektor-magazine.com | June 2013 | 23


•Projects

I had also considered a built-in panel meter in their multi-meter and get a more accurate
so you could monitor the output voltage of measurement anyway.
each output, but I quickly realized this would
be unnecessary feature-creep for this applica- No complex circuit
tion, since the outputs are fixed and fairly well Figure 1 shows the circuitry for this design. The
regulated, and most users (like me) can plug switching circuit is a simple latch based on two

COMPONENT LIST
Resistors D2 = LED, 3mm, 2-pin bicolor
R1,R4 = 220Ω IC1 = TC4049B
R2,R3 = 10kΩ
Miscellaneous
Capacitors K3-K7,K10-K14 = binding post (socket) for banana
C1-C8 = 100nF plug
J1 = ATX connector for PCB mounting
Semiconductors S1,S2 = tactile push button
D1 = LED, 3mm, yellow

Figure 2.
The component layout
leaves no room for
misinterpretation. Note that
the ATX connector should be
mounted on the bottom side
of the PCB.

24 | June 2013 | www.elektor-magazine.com


ATX power supply adapter

inverters from a 4049 HEX CMOS inverter, pow- The plated-through holes designated K3 to K14
ered from the ATX standby 5 V rail. The other are for bolting the back conductive end of the
gates in the inverter are used to drive the power banana socket binding post onto. Notice the use
on control signal to the PSU and the LEDs. Press- of multiple vias in a circle around each of these
ing S2 turns on the power supply while S1 turns and also around the mounting holes. These offer
it off again. D2, a bi-color LED, indicates standby increased strength for tightening up screws over
mode (green) or powered-on mode (red). them and also for the binding posts a good low-
ATX power supplies have built-in protection, but resistance current path through the PCB.
there’s also a Power Good output that tells the
motherboard when the PSU is ready, or if there’s In practice
a fault condition. It would be nice to have this This ATX adapter board offers standard 0.75”
displayed on an LED. I used a yellow LED for jack spacing for dual-banana plugs and has color-
D1 which indicates when Power Good goes high coded binding posts for each of the voltage rails:
(Power Good is an active low signal). This way, 5 V standby, 3.3 V, 5 V, +12 V and –12 V. I have
you get some warning of ATX power supply fault now been using this board extensively at work
conditions. In general, any continuous flashing and at home, powering several development kits
is bad and your power supply probably has a off a single ATX supply. At work I have an Altium
problem. Nanoboard-II and two Altium Nanoboard 3000
FPGA development boards all running at once
All the capacitors provide a bit of decoupling for from one power supply, as well as a few other
the different supply outputs, except C3 which is things. It has really simplified things well for me!
for de-bouncing the on-off circuit. All the capaci- (120619)
tors are ceramic 100 nF types. R1 and R4 are LED
dropping resistors and R2/R3 form the feedback
Internet Links
paths for the on/off dual-inverter latch.
[1] http://jordandsp.com/ATX-bench-top-power-
I have seen others converting ATX power supplies supply-adapter.php
to bench top lab supplies and putting minimum [2] www.elektor.com/120619
load resistors in them. In my experience this is
not necessary since the cooling fan is generally
enough of a minimum load and most modern
switching power supplies are designed to run
down to zero load anyway. But if it makes you
feel better, you can attach a 10 or 20 W resistor
to the 5 V rail (10 Ω will usually suffice) by sol-
dering the power resistor between the 5 V and
GND binding posts at the rear.

Board design
This adapter board acts as a break-out board with
an ATX header and the necessary on/off circuitry
as well as standard-spaced binding posts for plug-
ging in single or dual banana plugs. The silkscreen
overlay as a guide for placement is shown in Fig-
ure 2. Note that the ATX power supply socket must
be mounted on the rear side of the PCB, with all I want it
other components on the front side. This project is available in limited supply as a complete kit, with the
An additional novelty of this board is the unique PCB, all components including binding posts, components and an ATX
plated slots around its edge, which are used to connector, plus comprehensive assembly instructions which include
clip on ‘alligator’ style test leads as well. The the schematic diagram and PCB assembly diagram, as well as drill
silkscreen text indicates the output voltage of templates for panel mounting. Visit [1] for more information on price
each one. The board layout is available as a PDF and ordering.
download from [2].

www.elektor-magazine.com | June 2013 | 25


•Projects

Off to the EF Library!


Controlling hardware
using a UART or SPI interface

By Jens Nickel If a suitable protocol is defined, hardware connected to your PC can be controlled
(Elektor Germany Editor)
using a terminal emulator program. The necessary firmware can be rustled up
quickly using Elektor’s ‘Embedded Firmware Library’ (EFL), and the code can be
written without knowledge of whether a UART or some other interface will be used
for the connection. The protocol described here is ideal for experimentation and
development purposes.

In the previous edition we described our modular a code file for the board and a code file for the
‘Embedded Firmware Library’ (EFL), written in microcontroller.
the C programming language. This helps begin-
ners and old hands alike to develop code for However, the idea of modularity is taken even
an embedded project that is independent of the further in the EFL. Protocol libraries allow pro-
underlying hardware and which can therefore grams that communicate to be written without
easily be ported from board to board and from knowledge of the communication channel that will
microcontroller to microcontroller. This is achieved be used: it makes no difference whether com-
using a hardware abstraction layer consisting of mands and data are transferred using a UART and

26 | June 2013 | www.elektor-magazine.com


EFL

RS-232 or RS-485 connection, or using TCP/IP


over Ethernet. Just a couple of lines of the appli-
cation program code need to be changed to use
a different interface. In this article we will look
at this in more detail and present a protocol that
can be used in simple hardware control applica-
tions and for development.

Mini protocol
When trying to get code up and running simple
tests such as turning a LED on and off or reading
a digital input can be very helpful. Often, how-
ever, a microcontroller board will not have any
buttons to help you carry out such tests. One
alternative option is to control the board from
a PC, for example over a serial interface. If the
protocol is restricted to ordinary printable ASCII
characters it is easy to use a terminal emula-
tor program to send commands to the board,
avoiding the need for special-purpose software
on the PC.

Our mini protocol (called ‘BlockProtocol’) is


designed to let us set and clear pins on the {1}
SENSOR [3] RS485
microcontroller from the PC terminal. If there
ADC/2.0 3.0/RXD [4]
is an LED connected to the pin in question, this [5]
(+0) (4)
3.1/TXD {0}
ADC/2.1
(+1) (5)
gives immediate feedback; otherwise a multi- ADC/2.2 3.2
(10)
{2} (+2) (6)
3.3
meter or oscilloscope can be used. There are SENSOR (+3) (7)
ADC/2.3 (11)
ADC/SDA/2.4
also simple commands for obtaining the status (+4) (8)
(+5) (9)
ADC/SCL/2.5 µC (0) [0]
of digital inputs and for reading ADC conversion
3.4 (1)
results from the analogue inputs (see the text MOSI/1.3
3.5
MISO/1.4
box ‘BlockProtocol’). The code in the accompa- 3.6
(2)
SCK/1.5
3.7
[2]
nying library module can of course be extended
[1] (3)
in many ways as required. Perhaps a reader will
(12) (13) (14) (15)
be inspired by the control protocols designed by
Andreas Eppinger [2] and Uwe Altenburg [3], 120668 - 16

which offer a much wider range of facilities.

Map, blocks and board pins The peripheral blocks are shown in the middle, Figure 1.
The BlockProtocol includes the ‘x’ command spe- while on the right is a list of the pins on the board. Dump of the EFL tables
cially designed for use in development with the This is particularly important information for any- as seen in the terminal
emulator. On the left
EFL. The command causes the board to send a one planning to adapt or write an EFL board file
is the map with the
dump of the EFL tables to the PC. The tables are for a new board. More extensive documentation
microcontroller features in
used by the hardware layer to determine the on the internals of the EFL are given in the extra use (red numbers in the
microcontroller pins and registers that need to document that can be downloaded at [1]. board block diagram); in
be changed in response to a function call. The the middle is the block table
entries are specific to the board and any expan- Control via UART (blue numbers); and on the
sion board that might be attached. The screenshot We shall now show by example how easy it is to right are the board pins
in Figure 1 shows what appears in the terminal use the protocol in your own microcontroller appli- (green numbers).
window when the board shown alongside is used. cations. We will use an experimental node, famil-
On the left is the ‘map’ including the features of iar from our series on the ElektorBus. This is a
the microcontroller such as the UART and ADC very compact board based on an ATmega328. As
that are set up by the board initialization code. usual we will connect the node to the PC using its

www.elektor-magazine.com | June 2013 | 27


•Projects

In this case the code is the same as in the EFL


example software from the previous issue, as we
are using the same board and the same microcon-
troller. The ‘Libraries’ directory includes the files
UARTInterface.h and UARTInterface.c, which form
the library for the UART interface on the board.
Here this is our RS-485 driver (corresponding
to the ‘physical layer’ of our communications).
There is also a module implementing our proto-
col (BlockProtocolEFL.c and BlockProtocolEFL.h).
Together these two library modules provide a
defined software interface which we will now
look at.

A little code
In the main source file of the application code
itself we need to include the library header files
as follows.

#include “UARTInterfaceEFL.h”
Figure 2. RS-485 interface and a USB-to-RS-485 converter #include “BlockProtocolEFL.h”
Our small microcontroller (Figure 2). Instead of the ElektorBus protocol
board can be controlled over we will use our new text-based BlockProtocol. The main function in an EFL-based project is
a UART/RS-485 interface always structured in the same way: see List-
with the help of a simple
The necessary firmware for the microcontroller ing 1. In the application set-up function, which
ASCII text-based protocol
can be downloaded at [4]; the application can is called whenever the application starts up, we
and a terminal emulator
program. also be found in the EFL code base at [5]. An initialize the libraries:
overview of the files is given in the extra doc-
umentation mentioned above. Double-clicking UARTInterface_LibrarySetup();
‘ExperimentalUART.atsln’ opens the project in UARTInterface_SetBaudrate(0, 38400);
Atmel Studio: see the screenshot in Figure 3. BlockProtocol_LibrarySetup(UARTInterface_
On the right-hand side is a list of the files in Send, 0, UARTInterface_GetRingbuffer(0));
the project. The files Controller.h, Controller.c,
Board.h and Board.c form the hardware layer. Here the second line sets the baud rate of UART
interface block 0 (which is where we have our
RS-485 driver connected) to 38400 baud. The
Listing: third line needs a bit more explanation. We are
Basic structure of an EFL application. telling the BlockProtocol library that it should use
the function UARTInterface_Send when it wants
int main(void)
to send data from the board. The second param-
{
eter is the number of the UART interface block to
Controller_Init();
be used (even though on the experimental node
Board_Init();
there is only one UART interface).
Extension_Init();
The third parameter is a pointer to a ‘ring buffer’
ApplicationSetup(); (or ‘circular buffer’) to be used to store received
bytes. Here the required pointer is obtained as
while(1) the return value of the function UARTInterface_
{ GetRingbuffer(0), which is also implemented in
ApplicationLoop(); the UARTInterface library.
}
In the main application loop function, which is
};
called regularly when the application is running,

28 | June 2013 | www.elektor-magazine.com


EFL

we need just a single line:


BlockProtocol_Engine();

This is the main function in the BlockProtocol


library. It checks whether characters from the PC
have been received in the ring buffer, and as soon
as a <CR> (ASCII 13) is seen it is interpreted
as the end of a command and the command is
then carried out. A response is assembled, which
is either simply ‘Ok’ or a value such as ‘HIGH’
or ‘LOW’, or information about the EFL variables
in table form.

Let’s try it
Having compiled the code and flashed it into the
board we can try it out using a terminal emula-
tor program such as HTerm [6]. First we have to
specify which COM port to use and the baud rate.
In the ‘input control’ window we have to set the
program up so that the <CR> character is sent
when the Enter key is pressed (see Figure 4). character sequences given above. Figure 3.
Code to control hardware
We will first use the library at its lowest level to Higher-level commands over a UART interface.
demonstrate direct access to to the output port Directly controlling port pins is not the main rai-
pins of the microcontroller. From the circuit dia- son d’être of the EFL. If we want to port our
gram of the experimental node [7] we can deter- device control program to use a different micro-
mine that the red LED on the board is connected controller board with different wiring, we would
to port pin PD4. Port D on the AVR microcontroller have to change the character sequences given
Figure 4.
corresponds to port index 3. And so we simply above inside the PC or Android software.
The HTerm terminal
type into the terminal emulator For this reason the mini-protocol also allows emulator lets you choose
hardware-independent control of digital inputs what is sent when the Enter
p 3 4 + <ENTER> and outputs, just like when writing code to run key is pressed.

and the red LED on the board will light.

As another example, using commands like


‘p 2 0 +’ or ‘p 2 0 -’ we can set and clear pin
PC0 on the expansion connector. If an expansion
board, such as the sensor/LED board form the
previous issue or the relay board from the Elek-
torBus series [8], is fitted this gives us a simple
way to control external hardware devices from
the PC. Instead of the terminal emulator program
we could run a dedicated program on the PC to
send commands like ‘p 2 0 +’ to the appropriate
COM port in order to switch the relay.

Alternatively we could connect a smartphone to


the experimental node using the Andropod RS-
485-UART bridge board [9] and write a small
Android app. The software at [10] could be used
as a starting point for such a project, replacing
the bytes of the ElektorBus protocol with the

www.elektor-magazine.com | June 2013 | 29


•Projects

B 0 0 ? <CR>
on the microcontroller itself as described in the
previous issue.
With the string we can request the status of the test button (but-
ton 0 of button block 0). And with
L 0 1 + <CR>
R 0 0 + <CR>
we can switch on LED 1 in LED block 0 (which
on our board is the yellow LED). With we can turn on a relay.

Three-wire interface
The approach described above assumes that we
BlockProtocol have external access to a UART on the microcon-
troller, for example via RX and TX pins brought
Each command starts with a single character, possibly followed by one
out on the board. We also need a more-or-less
or two decimal values. These specify to the EFL the pin on which the
complete EFL microcontroller description file
command will act. A final character is used to specify any particular
which describes not only the I/O pins and ADC
action to be performed.
functions but also the UART functions that are
available.
x
Outputs the EFL map, block and board pin tables (see additional
When starting out with a new microcontroller (for
documentation at [1]).
example because you want to develop an EFL
microcontroller description file for other read-
p x y +, p x y –, p x y ?, p x y #, p x y *
ers to use) it is probably simplest to start with
For microcontroller pin y on port x: set high; set low; read state; read
the I/O functions. The first major hurdles are
ADC conversion result (if applicable); toggle under timer control.
to study the datasheet to determine how to go
about setting the level on the I/O pins and reading
b x +, b x –, b x ?, b x #, b x *
their status, and to find at least three general-
For board pin with index x in the board pin table: set high; set low; read
purpose I/O pins that are brought out to con-
state; read ADC; toggle.
venient points: fortunately most boards satisfy
this condition. It will then be possible to control
i x y +, i x y -, i x y ?, i x y #, i x y *
the board using the protocol described above,
For pin in position y within the block with index x in the block table: set
over a three-wire SPI interface implemented in
high; set low; read state; read ADC; toggle.
software. One of the wires is a clock signal, the
second carries bytes from the master (the PC)
C x y +, C x y –, C x y ?, C x y #, C x y *
to the slave (the board), and the third carries
For pin y of connector x: set high; set low; read state; read ADC;
bytes in the opposite direction.
toggle.

The SPI specification allows for the further pos-


L x y +, L x y –, L x y ?, L x y *
sibility of having communications over the three-
For LED in position y in LED block x: set high; set low; read state;
wire interface initiated by the slave rather than
toggle.
by the master. In this case each participant takes
its ‘out’ line high and waits for the other partici-
R x y +, R x y –, R x y ?
pant to do the same. Then communication can
For relay in position y in relay block x: set high; set low; read state.
begin, with, as usual in SPI systems, the mas-
ter providing the clock and data bytes flowing in
Bxy?
both directions simultaneously. When there are
For button in position y in button block x: read state.
no more data to send a ‘stop character’ (<LF>,
ASCII 10) is sent. When both participants have
Axy#
sent this byte, the communication is complete.
For ADC in position y in ADC block x: read conversion result.

We have encapsulated this protocol in the EFL


*
module called ‘ThreeWireInterfaceEFL’. With the
Stop timer-controlled toggling.
help of this module it is easy to set up communi-

30 | June 2013 | www.elektor-magazine.com


EFL

cations using the software SPI interface in place


of the UART interface.
The code required in the application set-up func-
tion is now as follows:

ThreeWireInterface_LibrarySetup();

BlockProtocol_
LibrarySetup(ThreeWireInterface_Send, 0,
ThreeWireInterface_GetRingbuffer(0));

These lines tell the BlockProtocol library that we


will be using the three-wire interface to send and
receive data: compare them with the code for
setting up the UART interface above.
In the main application loop we need the Figure 5.
command Communication with an
Arduino Uno over a three-
wire interface.
ThreeWireInterface_Listen(0);

which checks whether the other device has taken inserted in the main application loop the processor
its data line high to indicate a request to send will regularly check whether a string, terminated
data. If so, the communication is set up. When with a <CR> character, has appeared in one of
using the UART for communication we do not the input ring buffers. If so, then its contents
need a listener function like this, as in that case are sent out on the other communication chan-
a microcontroller interrupt can be used to detect nel. Then the other input ring buffer is similarly
when characters arrive and automatically store checked, and so on.
them in the ring buffer.
It should almost go without saying that the gate-
Making contact with an Arduino way module itself is programmed in a manner
To demonstrate the EFL concept we selected an independent of the underlying communication
Arduino Uno board. The code for this board can channels and can therefore easily be used to per-
be found in the project ArduinoUnoEFL [4][5]. We form other similar gateway functions. The func-
decided to use general-purpose I/O pins PB0, PB1 tion OneToOneGateway_LibrarySetup takes two
and PB2 to access the board: these are brought triples of parameters to specify the two com-
out on the ‘digital’ I/O connector as Digital8 to munications channels being connected. In this
Digital10. A simple three-way cable (for exam- example the call appears as follows:
ple using Conrad order code 741221) provides
a practical solution (see Figure 5). OneToOneGateway_
Of course we also need a connection to the PC at LibrarySetup(UARTInterface_Send,
the other end, and that will also need to have a 0, UARTInterface_GetRingbuffer(0),
three-wire interface. We pressed an experimen- ThreeWireInterface_Send, 0,
tal node board into service as a gateway, con-
ThreeWireInterface_GetRingbuffer(0));
verting from three-wire format to RS-485 (and
thence to USB) and back again. The firmware We now just need to plug the cable into the
involved can also be downloaded at [4] or [5]: experimental node’s expansion connector (pins
the Atmel Studio project can be found in the PC0 to PC2, see Figure 6) and flash the appro-
directory ‘ExperimentalSPI’. priate hex file into its microcontroller.
The gateway function has its own library mod-
ule called OneToOneGatewayEFL. With a call to The pins used to form the three-wire interface
have to be specified separately for the two dif-
OneToOneGateway_Engine(); ferent boards. The three-wire interface on each
device is a separate peripheral block: recall that

www.elektor-magazine.com | June 2013 | 31


•Projects

Figure 6. the board file encapsulates the mapping between (130154)


The experimental node acts peripheral blocks and microcontroller pins. The
as a gateway between the configurations for the three-wire interface, includ-
three-wire interface and the Internet Links
ing these pin assignments, can be found in the
UART/RS-485 interface. [1] www.elektor-magazine.com/120668
Board_Init function in the file BoardEFL.c.
[2] www.elektor-magazine.com/100576
It rocks! [3] www.elektor-magazine.com/120296
In the terminal emulator program we first issue
[4] www.elektor-magazine.com/130154
the ‘x’ command. The Arduino board responds
directly, sending the ELF variables out over the [5] www.elektor-labs.com/efl
three-wire interface, albeit at a rather more lei- [6] www.der-hammer.info/terminal/index.htm (in
surely pace than before (the speed is comparable German only)
to that of a 9600 baud serial port). [7] www.elektor-magazine.com/110258
The command
[8] www.elektor-magazine.com/110428

C 0 13 + <CR> [9] www.elektor-magazine.com/110405
[10] www.elektor-magazine.com/120097
can be used to set pin 13 of the Arduino’s ‘digi-
tal’ connector high: this pin drives an LED on
the Arduino Uno board, and so we get immedi-
ate visual feedback.

In the next installment we will take the EFL proj-


ect further: suggestions and contributions are
more than welcome.

The most recent version of the EFL code can be


found on the Elektor.Labs pages at [5].

32 | June 2013 | www.elektor-magazine.com


USB Add USB to your next project.
It's easier than you might think!
DLP-USB1232H: USB 2.0 UART/FIFO
HIGH-SPEED
480Mb/s
On
Multipurpose: 7 interfaces ly $
28.
95!
Zumo Robot
Arduino-controllable tracked
Royalty-free, robust USB drivers robot small enough for mini-
sumo (less than 10 cm × 10 cm)
No in-depth knowledge of USB required and flexible enough for you to
make it your own.
Standard 18-pin DIP interface; 0.6x1.26-inch footprint

DLP-IO8-G DLP-IOR4
8-Channel Data Acquisition 4-Channel Relay Cable
DLP-TH1b
Temp/Humidity Cable
Only Maestro USB
$29.95! DLP-RFID1
HF RFID Reader/Writer Servo Controllers
DLP-FPGA Compact, versatile servo
controllers that offer USB,
8 I/Os: Digital I/O USB-to-Xilinx FPGA Module serial, and internal scripting
Analog In control.
Temperature
USB Port Powered
Single-Byte Commands

www.dlpdesign.com
Metal Gearmotors
Available in a wide range of
motor types and gear ratios
that let you choose the right
combination of size, torque,
and speed for your application.

AltIMU-10 Gyro,
Accelerometer,
Compass, and Altimeter
Provides ten pressure, rotation,
acceleration, and magnetic
measurements that can be
used to calculate absolute
orientation and altitude.

Finding the right parts for your robot can be difficult,


but you also don’t want to spend all your time
reinventing the wheel (or motor controller). That’s
where we come in: Pololu has the unique products
— from actuators to wireless modules — that can
help you take your robot from idea to reality.

Find out more at www.pololu.com


•Projects

Lost Model Finder


By Robert Budniak
(Australia)
Straight to the crash site!

Every radio control plane flyer at some time has had a plane go down
outside of the airfield boundaries. Sometimes the location of the pre-
cious plane is easy and at other times they are hard to find. High grass,
trees or even uncertainty where the plane went down all make it hard to find
that elusive plane. So let’s build a radio direction finder (RDF) that ideally takes
you straight to the crash location.

There are a number of systems around used to • Battery backup in case of disconnection of
locate lost R/C models. I considered that I could the main battery
build a system that was a little bit better. The • Using commercial, type approved UHF ISM
concept specifications were: band radio modules
• Lightweight transmitter for the plane • Range at least 600 ft. (200 m)
• Receiver to be handheld and able to use
radio direction finding (RDF) to locate the
model.
Features
From this I was able to put to together the design
• low cost design described here. If you’re strong in model building
• TX board in SMD, RX board in T/H technology and flying, but not in electronics, consider doing
• Suits most 315/433 MHz ISM short range radio modules this project as a club activity.
• Programmable personal callsign on each TX
• Minimum range: 600 ft (200 m) Transmitter
• Maximum range: depends on terrain and TX and RX modules used Every country has a series of radio frequencies
• 4-element Yagi directional antenna on RX allocated to the Instrument, Scientific and Medi-

34 | June 2013 | www.elektor-magazine.com


Lost Model Finder

cal Band (ISM), sometimes combined with ‘Short


Range Devices’ (SRD). These frequencies vary K5
T2
between countries. While in the USA 315 MHz is DTB123YK
used, in Australia and most of Europe we find
K1 K4
433 MHz. Because there is a demand for sim- T1 BT1
DTB123YK Antenna
ple and cheap transmitters, there are a number +5V

of manufacturers supplying RF modules to this IC1


K3
8 1
market. The type of module used in this project K2 7
0V +V
2
Antenna
VCC
SER OUT SER IN
6 3
uses Amplitude Shift Keying (ASK), and these TXD
5
IN1 IN4
4
DATA
RXD IN2 IN3 GND
types of modules seem to have a standardized Transmitter
PICAXE-08M2
Module Figure 1.
pin configuration from different manufacturers.
R1
So that’s the RF transmission part taken care of. R2 22k Circuit diagram of the
transmitter, which is
Note that the parts list for the project indicates 10k
not much more than a
suggested types only. 120139 - 11
programmed PICAXE
As you can see in the schematic in Figure 1,
microcontroller.
the RF module just needs to have a data stream
applied its ‘DATA’ pin, and for this project I used
a simple PICAXE08M chip. I chose this microcon- Listing 1. PICAXE TX code
troller as it was readily available, the program- main:
ming language was easy to learn, and the chip
sound 4,(0,10,120,10,0,10,120,10,0,10,120,10,0,10)
did not require any special equipment to program
high 4
it. Really an ideal system for low volume and low
pause 2300
complexity projects.
goto main
The code is only a few lines (Listing 1), and in
the sample code for this project the coded gener-
ates three short 500-Hz tones and then a pause
of about 2.5 seconds. Whilst the code can be is not in use, or it will run down.
copied, I would recommend that the line where So that the Lost Model Finder can be left per-
the tones are generated is changed if you use manently in situ (it’s cheap enough that one can
a number of these transmitters near each other have one for each plane), it’s designed with a
(like in a club environment). charging port combined with an on/off switch.
The transmitter is normally powered off the This is achieved by using the switch in a 2.5-mm
plane’s receiver. However sometimes the plane’s jack socket that’s operated by a 2.5-mm jack.
battery gets disconnected in an accident, so a With the jack inserted, the backup battery is dis-
backup battery is provided. The backup battery connected. If a jack that is connected to a char-
is a small Li Po battery (around 130 mAh capac- ger is inserted, then you can charge the battery.
ity) that usually powers small indoor planes. This
battery is available cheaply from online suppliers.

IC2
Usually you’d use steering diodes to automati- NCP1117ST50 D2
PMEG2010AEH
cally select the power supply. However with the 2 3
K2
low voltages used in this project (5 volts and 3.7 C4 +6V5...15V
1

volts) even the 0.4 volt drop of a Schottky diode 10u


25V
0
AUX
was a sizable proportion of the voltage. Looking
R1
through some online databases, I found some JP1 1k5
+5V D1
small signal transistors type DTB123YK (T1, T2), AUX 4 IN

which also had base-emitter and base resistors in K1 USB C2


7 EN IC1
CHG
8

1 JP2
the chip. They work quite well in steering the volt- 2
10u
10V MAX1811 Figure 2.
C1 4V2 1 SELV 5
BATT
ages of the batteries, and the voltage drop across
3
4
4V1
BT1
A possible charger circuit
100n 2 SELI
5 JP3 C3 for the LiPo/Li-Ion battery in
the transistor is just 100 millivolts. The only down 500mA
GND GND 1C

the transmitter. It’s either


3

10u
side is that when the main battery is disconnected 100mA 10V
USB-B mini Li-ion/LiPo externally powered (6.5–
the backup battery takes over. Hence the backup 120139 - 13 15 VDC), or USB powered as
battery needs to be disconnected when the plane selected on JP1.

www.elektor-magazine.com | June 2013 | 35


•Projects

age to the regulator if the USB port is selected as


+5V +5V input source. The input decoupling of the MAX1811
K2
K3
IC1.A (C2) doubles as the regulator output decoupling.
+5V
RXD
2
1 1 This was done to save space.
TXD
VCC TXD
3 4
1 RXD
PICAXE PE interface
IC1.B At some point you’ll need to burn the plane ident
TTL-232R-5V K1

+5V IC1.F IC1.E IC1.D


program to the PICAXE chip. In case you are using
Figure 3.
13
1 12 11
1 10 9
1 8 an FTDI TTL-to-RS232 adapter to interface with
Build this inverter circuit C1 14 the TXD/RXD pins of the PICAXE in combination
IC1 IC1 = 74HC04
if you use an FTDI TTL- 100n 7 IC1.C with the PICAXE Programming Editor, you need an
to-232 adapter between the 5
1 6 additional inverter circuit as shown in Figure 3.
120139 - 14
transmitter’s TX/RX pins
and, say, a microcontroller. Receiver
The receiver is based on a complementary module
Charger to the transmitter. However a little more care is
A suggested circuit for a charger is shown in Fig- needed in the selection of the receiver, to ensure
ure 2. Two inputs control the mode the charger is it supplies the right signals to our circuit.
operating in. One input selects the regulating volt- Referring to Figure 4, the first output of the
age, 4.1 V or 4.2 V (jumper JP2, SELV). The other receiver module is from the DATA pin, 14. This
input sets the charge current, 100 mA or 500 mA passes to a small-signal FET T1 and the output
(jumper JP3, SELI). A nice feature of this IC is the goes to a piezoelectric transducer Bz1 (not a
ability to precondition a near-dead battery before piezoelectric buzzer). What you will hear from this
charging. The enable input (EN) is not used and transducer (hopefully!) is the tones and pauses
thus permanently connected to the power supply. generated by the transmitter. In use you listen
The general description in the datasheet states for your personal ‘call sign’ that was embedded
specifically it can be powered from a USB port and in the transmitter.
can handle input voltages as low as 4.35 V, the The second output from the transmitter is the
minimum of a USB port. With higher input voltages RSSA output (pin 13). Basically this is a voltage
Figure 4. (the MAX1811 can handle 6.5 V max.) and with the that is proportional to the signal strength and
The Lost Model Finder
high current set the IC will limit the charge current used as part of the automatic gain control (AGC)
receiver uses an old faithful,
to keep the die temperature at a safe level. In case in these receivers. This signal is applied to the
the LM3914 LED bar graph
indicator. The 433 MHz (315 only a power source with a higher voltage is avail- input of an LM3914 LED driver. The RSSA sig-
MHz) receiver (RX) module able a low-dropout 5V regulator is added (IC2). A nal on the prototype was found to vary between
gets plugged onto the MOD1 jumper selects the input voltage for the MAX1811 0.4 volts and 2 volts, so the upper and lower
connector. (JP1: AUX or USB). Do not connect an input volt- limits of the LED driver have been set to those
values. I won’t go into the design of the circuit
around the LM3914, since the IC has been used
a zillion times in DIY electronics projects over the
+4V8 +4V8
K2 past decades. If you want a more detailed tuto-
Antenna R1 BZ1
C1
D1 rial then point your web browser to [1] and enjoy
1
100n
D2 Dave’s EEVBlog #204. Say Hello to Dave for us.
2
The receiver is powered from four AA or AAA
3

1k
3 D3
V+

9 1
+4V8 4 MD SEL LED1
18 batteries, rechargeable or dry, although three
5 D4
IC1 LED2
K1 6
5
IN LED3
17
16
dries should also work. Despite the transmit-
+4V8 7 LED4 D5
0 8
6
DIV HI LED5
15 ter’s datasheet claiming a maximum voltage of
R2 7 14
D6
9
10
REF OUT LED6
LED7
13 5 volts, the module has been tested to work up
LM3914 12
11 620R 8
LED8
11
D7 right up to 7 volts.
12 T1 REF ADJ LED9
13
4
DIV LO LED10
10
D8 The only other major item associated with the
14 R3 R4
V-

15 D9 receiver is a 4-element ‘Yagi’ directional antenna.


2

2N7000
MOD1 360R 2k7 D10
This antenna was chosen for its simplicity and its
Receiver
Module 120139 - 12
directional properties, a feature which will becomes
obviously necessary in the how to use section.

36 | June 2013 | www.elektor-magazine.com


Lost Model Finder

Building
The transmitter is built on a double-sided PCB COMPONENT LIST
using SMD components (Figure 5). It uses Transmitter
0.1’’ pitch pinheaders for all external connec-
Resistors
tions except possibly K3. The artwork may be R1 = 10kΩ 1%, SMD0805
downloaded free from [2]. The PICAXE may be R2 = 22kΩ 1%, SMD0805
soldered in but also mounted in a DIL-8 socket.
Semiconductors
Only solder in the two transistors if using the IC1 = PICAXE-08M2, programmed
battery backup version. Do not connect the RF T1,T2 = DTB123YK
module yet to the footprint marked K3.
Miscellaneous
At this stage you can test the transmitter driver K1,K2,K5 = 3-pin pinheader, 0.1’’ pitch
by connecting a piezoelectric transmitter between K3 = 4-pin pinheader, 0.1’’ pitch (optional, see text)
the data and ground pins that go to the RF mod- K4,BT1, 2-pin pinheader, 0.1’’ pitch
Transmitter module (on K3), ASK, 433MHz ISM band,
ule. After applying power you should be able to type approved, e.g. Quasar Electronics type QAM-
hear your callsign. TX1 (433 MHz), Farnell/Newark # 1304024. USA
The RF module may be connected to the board readers, use 315MHz equivalent
LiPo battery, 3.7V, 130mAh
with a short length of 4-way flatcable and using PCB # 120139-1 Figure 5. The Transmitter
pinheaders and mating IDC sockets. Alternatively,
board is double-sided
it may lie flat over the microcontroller board as
Receiver and takes SMD parts;
shown in Figure 6 (433 MHz version built by the Receiver board is a
Resistors
Elektor Labs). Make sure the solder sides of the single-sided design for
R1 = 1kΩ
board do not touch. R2 = 620Ω 1% through-hole parts. TX
The final part is the installation of a quarter-wave R3 = 360Ω 1% board shown at 150 % of
R4 = 2.7kΩ true size.
antenna. A piece of stiff wire about 173 mm in
length will do (I use one core of an Ethernet Capacitor
cable). When using a 315 MHz TX module the C1 = 100nF, 5mm or 7.5mm pitch
antenna length becomes 240 mm — remember,
Semiconductors
from (300/f)÷4. D1–D10 = LED, orange, 2.5x5mm rectangular, 20mA
The microcontroller board, RF module and backup T1 = 2N7000
IC1 = LM3914
battery (if used) may be wrapped in a short
length of shrink wrap tube. Miscellaneous
BZ1 = (not on board) piezo transducer, flying leads,
Farnell/Newark # 1193640
The receiver PCB design is also shown in Fig-
K1,K2,(BZ1) = 2-pin pinheader, 0.1’’ pitch
ure 5. This is a single sided board for TH compo- (MOD1) = 15-pin pinheader, straight, SIL, 0.1’’ pitch
nents so it should be plain sailing. Insert and sol- MOD1 = AM SuperHet Receiver, QAM-RX3 (433MHz),
RS Components # 742-4484. USA readers, use
der all the parts into the PCB. The radio module is
315MHz equivalent
mounted vertically. The board and battery holder Battery holder for 3 or 4 AA(A) batteries, see text
for three (or four) AA(A) cells may be mounted on PCB # 120139-2
the Yagi boom behind the reflector. The radiator
(dipole) elements of the Yagi antenna should be
connected to the input of the radio module with building club may be persuaded to produce a few
a length of thin 50-Ω coax cable like RG174/U or sophisticated antennas for members. The author
/CU. Keep the length to an absolute minimum to made the radials from coat hanger wire, although
prevent excessive losses. Resist the temptation any stiff wire will do, like electrical installation
to use screened audio cable. wire. Try to cut the radials to the lengths shown
in the drawing in Figure 8 (dimensions for 433
The (optional) charger is built on the board MHz). The author’s prototype was made from
shown in Figure 7. Do not forget to fit the jump- some 3-mm (1/8 in.) corrugated plastic sheet
ers according to your requirements. (corflute; corriboard; Polyflute), with the radi-
als inserted into the cores. The spacing does
The 4-element antenna is all-homebrew. Var- not work out exactly, but works well in practice.
ious designs are around on the Internet, and Elektor Labs built their Yagi antenna from a 570 x
mechanically skilled members of your local model 53 x 12 mm piece of wood and lengths of 2.5 mm2

www.elektor-magazine.com | June 2013 | 37


•Projects

Testing
Fortunately there is no calibration required. Leave
the transmitter off at this stage. Turn on the
receiver and you should hear white noise with
the occasional pop. The LED indicator should be
showing the lowest LED on.
Turn on the transmitter. You should now hear your
callsign, and the bar graph should be moving up
Figure 6. and down in synchronization with the tones of the
LiPo Charger board (left) call sign. The bar graph should go to full scale
and TX assembly (right). when the transmitter and receiver are within 10
The PICAXE board and the feet or so (3 m) of each other.
transmitter module may
be connected without a In use
cable, simply by bending It’s going to take a little practice in order to
and soldering the four
successfully use the Lost Model Finder. It’s best
pins straight to K3.
to initially have a friend hide the transmitter
in a park or garden and then try and find the
csa electrical installation wire (introductory pho- transmitter.
tograph) fitted at the exact positions from Fig- The antenna is directional and the ‘sharp‘ end
ure 8. The boom is long and wide enough to hold is the end with the greatest sensitivity. When
the RX board and the battery holder. This antenna looking for the transmitter, hold the antenna in
should have about 7 dB gain, allowing the TX to be front of you and rotate a full circle. Listen for
found at a distance of about 1,000 feet (300 m) your call sign to make sure you’re chasing your
in a built-up area as Labs were able to measure transmitter. The bar graph will indicate where
in and around their location at Elektor House. the maximum signal is. Walk in the direction of
Connect the dipole elements of the antenna to maximum. Continue doing this, stopping occa-
the receiver via the previously installed cable. sionally to check your bearings. You should see
Sticklers for nanovolts may want to add a balun that the bar graph increases.
for proper matching of the symmetrical radiator At some point you will get close to the transmit-
to the asymmetrical coax cable, but in this case ter and the bar graph will be at maximum. Now
the work and cost may defeat the purpose. point the insensitive (‘blunt’) end of the antenna
in the direction where you think the transmitter
is. Now when you rotate the antenna around you,
you are not looking for the maximum signal but
COMPONENT LIST
the minimum signal. You’re sort of sneaking up
LiPo Charger (optional)
from behind.
Resistor You can also change whether you hold the
R1 = 1.5kΩ SMD 0805 antenna radials parallel to the ground, or per-
Capacitors
pendicular, or any other orientation.
C1 = 100nF SMD0805 X7R The last few ten feet or so are the hardest in
C2,C3 = 10µF 10V, SMD 0805, X7R finding a plane, especially one lost in vegeta-
C4 = 10µF 25V, SMD 1206, Y5V
tion or scrub. Also don’t forget to look up to the
Semiconductors tree top canopy! You never know where these
D1 = LED, red, SMD 0805 models are hiding.
D2 = PMEG2010AEH, Farnell/Newark # 1510673
(120139)
IC1 = MAX1811ESA+, Farnell/Newark # 1593327
Figure 7. The charger IC2 = NCP1117ST50T3G, Farnell/Newark # 2112617
board is a double-sided [1] Dave’s EEVBlog # 204:
design for surface mount Miscellaneous
K1 = mini USB receptacle type B, SMD www.youtube.com/watch?v=iIKGvHjDQHs&fe
components. K2,(BT2) = 2-pin pinheader, 0.1’’ pitch ature=player_embedded)
JP1,JP2,JP3 = 3-pin pinheader, 0.1’’ pitch, with
jumper [2] Project page:
PCB # 120139-3 www.elektor-magazine.com/120139

38 | June 2013 | www.elektor-magazine.com


Lost Model Finder

Figure 8.
Experimental Yagi antenna
with the receiver electronics
attached on top of the
wooden ‘boom’, behind the
reflector. The directors,
radiator and reflector
were made from electrical
installation wire (c.s.a.
I
around 2.5 mm2 / 13AWG)
and secured to the wooden
A B C D boom with tie wraps — after
A = 30 mm carefully centering on the
B = 124.4 mm boom, of course. For safety,
C = 138 mm the radial ends should be
E = director #2, 307.9 mm* covered with a blunt object
F = director #1, 310.8 mm* or some putty.
G = radiator, 2 x 163.5 mm* Gain is approximately 7
E F G H H = reflector, 338 mm* dB. For 315 MHz use, the
I = boom, 570 mm element spacing and lengths
* 2.5mm2 / AWG 13 wire should be scaled up by a
factor 1.37.
Advertisement

FREE Stencil
with every prototype order

Embedded RFID
authenticate, track & protect
your product

N EW ! www.magic-pcb.com

Call Tyler: 1 707 447 7744


[email protected]
PCB-POOL® is a registered trademark of

www.pcb-pool.com

www.elektor-magazine.com | June 2013 | 39


•Projects

Lithium-ion Battery
Recycling Made Easy
meaning: without a microcontroller

By Fons Janssen
(Maxim Integrated,
The Netherlands)

It can be quite tricky to reuse Lithium-ion batteries from discarded equipment


since these cells are often charged inside the equipment, meaning that there won’t
be a separate charger that can also be reused. Luckily, it turns out to be fairly
easy to build a charger for used (or new) Li-ion cells.

Like most people, you probably have some old The original equipment usually contains a special
equipment lying around that uses a Li-ion battery charger circuit for the battery, most likely on a
for the supply. This type of battery has been used small part of the PCB in the equipment. It is dif-
in most portable equipment produced in the last ficult to figure out which components are part
few years because it can be easily made in various of the charger circuit since no circuit diagram
sizes and shapes, whilst it also has a relatively is normally made available for portable equip-
large capacity (compared to NiMH and NiCd). ment. In that case we’ll just have to build our
What can you do with that old MP3 player or own Li-ion charger!
mobile that’s been replaced by a newer, better
version? The electronics can usually not be used The circuit
for any other purpose, but that battery can still The charger circuit described in this article is
come in useful, even if it’s for use in a toy. Since built around a Li-ion charger IC made by Maxim
electronics hobbyists tend to be an inventive lot (MAX8677A, see the block diagram in Figure 1).
they will usually find a way to incorporate and This IC works completely autonomously so that
connect a recycled battery. The author, for exam- there is no need for a microcontroller (and hence
ple, has built a Li-ion battery into a Lego train to no software!). A number of LEDs is used by the
replace three penlight cells (see the main photo). IC to indicate the state of the charging process.
This still leaves the need to charge the battery. The IC is very flexible and contains a ‘smart

40 | june 2013 | www.elektor-magazine.com


Li-ion-charger

power selector’ (see Figure 2), which consists


of three electronic switches that direct the charge MAX8677A

and load currents according to the situation. With


an external power source, the IC can use the
available power to both charge the battery and
supply the load. Should the load require more
power than the charger can deliver then the IC
can make the battery supply the extra current.
When there is no external power source avail-
able the load is obviously powered solely by the
battery.
The IC can be powered from a USB port via Figure 1.
pins 15 and 16 (USB). In this case the current Block diagram of the
drawn is limited to 500 mA (the maximum for a internal circuit of the
USB2.0 port). The IC can also be powered from an MAX8677A.
adapter via pins 2 and 3 (DC), where the current
limit can be increased up to a maximum of 2 A.
In the circuit for the charger in this article
(Fi­gure  3) we make use of the DC input, which
gives us greater flexibility in setting the vari-
ous limits. The operating voltage at the input
is between 4.1 to 6.6 V. If the voltage becomes
too high, the IC turns off the input to prevent Figure 2.
it from overheating. The IC can survive voltage The ‘smart power selector’
spikes up to a maximum of 14 V. splits the charge and load
The charging status is provided by D1, D2 and currents according to the
D3. The following three states are indicated: demand.

USB1 R1 R2 R5

1 4k7 4k7
+5V 4k7
2
D– C1 D1 D2 D3
3
D+
4 2 3 17 18
ID 4u7
5 DC DC BAT BAT
GND 1 24
DONE FLT

Mini USB R3
4 23
CEN UOK
IC1 R4
560k
5 22
PEN1 DOK
C2 560k
6 19
PEN2 CHG
20 FS1
100n SYS
8 21
VL SYS
R7 16
C4 MAX8677AETG+ USB
10 15 T3A
CT USB SYSTEM
68n 14
TSET
10k 12 13
NTC THM USUS
PSET ISET GND EP
NTC 7 11 9 25 BATT1
R8 R6 R9

*
C3

Figure 3.
4u7
10k 3k3 5k6 The complete charger circuit
130117 - 11 consists mainly of the
MAX8677 and a mini-USB
connector.

www.elektor-magazine.com | june 2013 | 41


•Projects

maximum charge current can never be reached


NTC BAT– BAT+
as it can not go higher than the maximum input
current.
Both these limits are set using a resistor:
NTC
Maximum charge current:
BATT1
Figure 4. ICHGMAX = 3000/RISET = 3000/R9 = 3000/5.6k
Most Li-ion batteries with Ω = 535 mA
three connections have an Maximum input current:
internal NTC connected as 130117 - 14 IDCMAX = 3000/RPSET = 3000/R6 = 3000/3.3k
shown. Ω = 909 mA

The battery is being charged (LED D3), the bat- You can obviously select more suitable values
tery is fully charged (LED D1), or the battery is depending on the power rating of the adapter,
faulty (LED D2). the power consumption of the device and the
There are two current limits that can be set with desired load current. The IC can provide a maxi-
this IC: one for the maximum charge current and mum charge current of 1.5 A.
one for the maximum input current. It’s clear that We’ve used a mini-USB connector, which makes
the second value should always be larger than it easy to power the circuit with contemporary
the first. If this isn’t the case, the programmed mains adapters. This also ensures that we’re
using a 5 V supply. The maximum input current
should be adjusted according to the rating of the
Component list adapter. The circuit will function just fine when
Resistors the adapter can provide a current of at least 1 A.
(default: SMD0603)
R1,R2,R5 = 4.7kΩ Is there an NTC?
R3,R4 = 560kΩ
R6 = 3.3kΩ Batteries are often provided with an NTC, which
R7 = 10kΩ is used to prevent them being charged at tem-
R8 = 10kΩ (only if NTC in battery) peratures that are too high or too low. The bat-
R9 = 5.6kΩ
tery therefore has three connections: a positive
Caoacitors terminal (BAT+), a negative terminal (BAT-) and
(default: SMD0603) a connection for the NTC (see Figure 4). You
C1,C3 = 4.7µF (SMD0805) should be aware that some batteries with three
C2 = 100nF
C4 = 68nF connections have only a normal resistor inside
that is used for identification. Its value will be
Semiconductors constant, so won’t vary with the temperature of
D1 = LED, green, 3mm
the battery.
D2 = LED, red, 3mm
D3 = LED. yellow, 3mm When an NTC is used it should be connected
IC1 = MAX8677AETG+ (24-pin TQFN) between the THM pin and ground (via the BAT-
connection). A resistor (R7) is also connected
Miscellanous
between the THM pin and a reference voltage
USB1 = mini USB connector, PCB mount, SMD,
(e.g. Molex 67803-8020, RS Components # (VL), which creates a potential divider. The value
720-6618) of the resistor is chosen such that it has the same
value of the NTC at a temperature of 25 °C. The
FS1 = fuse, SMD, rating dependent on battery
(e.g. LittleFuse nanofuse 3 AT, Farnell/Newark # voltage at the THM pin at 25 °C will then be equal
1596930RL) to 0.5 VL. When the temperature rises/falls, the
Print artwork # 130117-1 from [2]
resistance of the NTC falls/rises as will the volt-
age at the THM pin. The IC will only charge when
Figure 5.
this voltage is between 0.28 VL and 0.74 VL. With
The PCB designed for this
charger has been kept as contemporary NTCs this corresponds to a tem-
small as possible to make perature between 0 °C and 50 °C. When no NTC
it easier to build it into is available you should add R8, which causes the
existing equipment. voltage at the THM pin to be 0.5 VL.

42 | june 2013 | www.elektor-magazine.com


Li-ion-charger

Connection tips
If you’re reusing a cellphone battery it will already Soldering a TQFN by hand
have a protection circuit as standard, which pro- Mounting the IC with a hot
tects the battery from overloads and from being air soldering iron is possible
discharged too deeply. However, if you want to if you’re experienced enough,
use a single cell, for example from a battery pack although a reflow oven
from an old laptop, then you will have to make a
makes life much easier.
your own protection circuit. The circuit inside 1.50mm

The method described


the pack will have been designed to protect the here shows how to use an
whole pack and can therefore not be used to ordinary soldering iron to
protect a single cell. b
mount the IC, even though
A simple fuse (shown in the circuit diagram as the home made PCB is not
FS1; this is an SMD fuse on the PCB) offers suf- through-plated.
ficient protection from overloads, which means Locate one hole in the
c
that separated cells are perfectly usable. How- center of the IC’s exposed
ever, a fuse doesn’t offer any protection against pad instead of 9 like in the
deep discharging. When these types of cells are PCB design shown. Drill this
discharged too much it is possible to damage hole using a drill bit with
d
them. This can happen when an ohmic load is a diameter of 1.5 mm (a).
attached for too long a period, such as a small Position the chip on the PCB
incandescent light bulb. Most devices will stop (b) and solder all contacts
working once the supply voltage has dropped along the sides of the chip
e
below a certain value, which stops the cell from (c). Use Litze wire to tidy
discharging further. Whether or not a fuse offers everything up again (the
enough protection therefore depends very much author used a stereoscopic
on the type of device that is connected. microscope to get a good
f
view of everything). When all
Construction contacts on the top side have
130117 - 15

A compact PCB has been designed for this proj- been soldered properly we
ect, which uses a large number of SMDs (see turn over the board and drop a few pieces of solder into the hole (d).
Figure 5). This keeps the PCB very small, which Find a piece of solid copper cable that fits snugly in the 1.5 mm hole
makes it easier to build into the device. The board (one of the cores in a solid core mains cable would be a good choice)
layout (made using DesignSpark) is available as and use a file to make one of the ends completely flat. Put this end
a free download from [2]. through the hole and heat it up using the soldering iron (e). At some
You will need some dexterity and soldering expe- point the piece of copper wire gets so hot that the pieces of solder in
rience in order to mount the SMDs. For the TQFN the hole start to melt. The copper wire will then drop down slightly and
packaged IC you should ideally use a reflow oven, makes contact with the exposed pad of the chip. Then solder the piece
since the pins and the exposed pad are on the of wire to the ground plane on the solder side of the PCB (f).
underside of the 4x4 mm package. However, the You will now have a good electrical and thermal connection between
author has thought of a method that can be used the exposed pad of the chip and the ground plane on the solder side of
to solder the IC by hand, which is described in the PCB.
detail in the inset. There are holes on the PCB
for the connections to the LEDs, battery and the
load, so they can be connected easily via wires.
Internet Links
The mini USB connector has two plastic pins that
fit in the associated holes on the PCB, providing [1] http://datasheets.maximintegrated.com/en/
alignment of the socket. If you don’t want to use ds/MAX8677A.pdf
the mini USB connector you can use these two [2] www.elektor.com/130117
holes for connecting the power. In this case you
have to make sure that the supply voltage is 5 V.
(130117)

www.elektor-magazine.com | june 2013 | 43


•Projects

Taming the Beast (5)


Programming an array of 250 Kgates

By Clemens Valens Although it’s perfectly possible to design FPGA applications using schematic dia-
(Elektor.Labs)
grams with logic symbols, in practice this is usually done with a hardware descrip-
tion language. An advantage of the latter approach is that complex functions are
often easier to express in algorithms than in schematics. Accordingly, in this in-
stallment we guide you through the process of programming an FPGA application.

In the previous installment [4] we took a cautious ilog instead, but it reflects the fact that simula-
initial look at the hardware description languages tion often takes longer than synthesis, so in the
VHDL and Verilog for testing an application. In this end you’re done faster. To draw an analogy with
final installment we delve into hardware descrip- computer programming (Verilog fans should look
tion languages more extensively – in this case, the other way and plug their ears at this point),
to define an application. However, working with instead of just throwing together a bit of code and
two languages is too difficult, so I had to make a then using the debugger to turn it into a working
choice. After many sleepless nights and consult- algorithm, you can first spend some time thinking
ing dozens of experts, I ultimately decided to cast about your algorithm and then use the debugger
my lot with VHDL. There are various reasons that to make sure it works properly.
can be given for this choice. One is that VHDL The application I have chosen here is a DCF77
should require less simulation time because it is decoder. I can hear the snide remarks already,
more difficult to arrive at a synthesizable design. but there are good reasons for this choice. The
That might sound like a reason for choosing Ver- radio signal from the DCF77 atomic clock broad-

44 | June 2013 | www.elektor-magazine.com


FPGA

cast station near Frankfurt in Germany can be do for each clock pulse
received on 77.5 kHz easily in virtually all of {
Europe with an inexpensive module. The signal counter = counter + 1
coding is fairly simple – it consists of a sequence if (counter == 150ms)
of 59 pulses (one per second) which can have {
two different lengths (100 ms for “0” or 200 ms
shift­
_register = (shift_register << 1) + input_signal;
for “1”), which collectively represent the bits of
}
the time code. The end of the code sequence
if (rising_edge(input_signal) == true)
is marked by omitting the final pulse (number
{
60, corresponding to bit 59). A new code is sent
every minute. The date and time are in BCD for- if (counter >= 1750ms)
mat, and there are several check bits that can be {
used to verify the validity of the data. This signal show_content(shift_register);
is a good starting point for a project with VHDL }
(or Verilog) because it is relatively easy to show counter =;
the results on a 7-segment display with simple }
logic. For those of you who do not have a DCF77 }
receiver or who cannot receive the signal because
they live too far away from Frankfurt, we have The counter is incremented on each clock pulse.
written a DCF77 simulator program for Arduino When the counter reaches 150 ms, the input sig-
[5]. That way everyone can join in. nal is sampled and the sample is fed to the shift
Let’s start with a functional design for a DCF77 register. When a rising edge is detected in the
decoder. Here we take the ‘naïve’ approach, which input signal, a test is made to see whether the
means we assume that the input signal will usu- counter has exceeded the maximum value. If it
ally be good and will stay nicely within specifica- has, the shift register is full and the data can be
tions. Thanks to this assumption, the design can displayed. After this the counter is reset to 0.
be fairly simple. That’s all there is to it. You could add all sorts of
As previously mentioned, the input signal consists bells and whistles to this, such as error detection
of pulses with lengths of 100 ms and 200 ms, and more robustness, but that falls outside the
which represent zeros and ones respectively. If you scope of this introductory example.
sample the input signal at a point 150 ms after the
rising edge of each pulse, you will thus see either How do you do this in VHDL?
a ‘0’ or a ‘1’ (Figure 1). If you also measure the Doing the same thing in VHDL is fairly easy
time between two successive rising edges, you because translating pseudocode into VHDL is
can detect the missing pulse and therefore iden- straightforward. The result is the following code
tify the start of the time code. The bits that are fragment:
found in this manner are fed into a shift register.
Then the BCD sequences that encode the various 1 process (clock) is
date and time units are extracted from the shift 2 begin
bit string in the shift register and presented on the 3 if rising_edge(clock) then
7-segment display. In the C-based pseudocode, 4 counter <= counter + 1;
this looks roughly as follows: 5 if (counter=t150ms) then

Figure 1.
The DCF77 signal and
sampling points.

www.elektor-magazine.com | June 2013 | 45


•Projects

6 bits <= input & bits(58 downto 1); value of the input signal is fed into the bits
7 end if; shift register in line 6. This is done from the left
8 if input_rise=’1’ then end of the shift register, unlike the pseudocode
9 if (counter>=t1750ms) then where it is done from the right. We chose this
10 data <= bits; approach because the time code starts with the
11 end if; least significant bit, so the bits are fed into the
12 counter <= 0; shift register in the right order for our purpose.
13 end if; After 59 pulses, bit 0 is at position 0. The shift
14 end if; operation looks a bit strange because the con-
15 end process; catenation function “&” is used for this purpose.
This function simply joins the left part of the
The definitions and a bit of VHDL syntax are miss- expression to the right part. Here the right part
ing here, but the algorithm is there. I added the consists of the 58 bits from 1 to 58 (in reverse
line numbers here because they make it easier to order, without bit 0), which are shifted to posi-
explain how the code works. In this code, coun- tions 57 to 0. The left part is the 1-bit input sig-
ter is self-explanatory and bits are the stages nal, which now ends up in bit 58. The details of
of a 59-bit shift register. Let’s start at the top what ISE (or actually XST) does with this con-
with line 1. struction are not so important here; what mat-
ters is that it works (and it does).
This is a process, which means that it will be Line 8 checks to see whether a rising edge has
executed by the FPGA. Nothing happens without been detected in the input signal. Exactly how
a process. There can be multiple processes, and that works is not obvious from the code fragment
they are all executed at the same time. Within (I’ll explain this later), but if a rising edge has
a process, the order of execution is normally top been detected, line 9 checks whether the counter
to bottom. Our process is dependent on the sig- has exceeded the maximum value of 1750 ms. If
nal clock, which means that the process is only it has, the content of the shift register is copied
executed when the value of clock changes. The to a data register for further processing, which
process starts after line 2 and runs until line 15. is done in another fragment described below.
Line 3 causes everything in the process to be Line 12 resets the counter to zero. It is not nec-
synchronized to the rising edge of the clock sig- essary to flush the shift register, since it is com-
nal. This is made possible by the function ris- pletely filled every minute.
ing_edge. You will often see the following con-
struction in VHDL code: The lines not specifically mentioned here are only
there to conform to VHDL syntax rules.
if clock’event and clock=’1’ then To complete this fragment, all you need is an
.. edge detector, some VHDL syntax glue, and the
end if; specifications of the input and output signals for
this process. In the final design I also added a
This does the same thing as rising_edge, but it couple of signals that blink the LEDs on the FPGA
is a bit old-fashioned. Here we use rising_edge. board so you can see whether something is actu-
There is also a function called falling_edge. ally happening inside the FPGA.
The counter is incremented by 1 in line 4. Easy,
isn’t it? Yes, but you should be careful because Edge detection
whenever you use the increment function, The edge detector is a key part of this design.
which is represented by the “+” sign, you have At first I used a simple scheme that compared
to include the numeric_std library in the list of the current value of the input signal with the
libraries to be used (as described elsewhere in value during the previous clock pulse. This was
this article). not reliable and caused problems, with the result
that synchronization was occasionally lost. The
In line 5 the counter value is compared to a con- solution turned out to be adding another flip-flop
stant that corresponds to an interval of 150 ms so that instead of comparing the current value
with a clock frequency of 8 MHz (the FPGA clock with the previous value, we compare the previ-
rate). If the counter is at 150 ms, the current ous value with the one before it. In other words,

46 | June 2013 | www.elektor-magazine.com


FPGA

instead of comparing t = n with t = n - 1, we


Listing 1. An edge detector module in VHDL.
compare t = n - 1 with t = n - 2.
You may be asking yourself whether the func- library ieee;
tion rising_edge could have been used for this use ieee.std_logic_1164.all;
purpose, but unfortunately the answer is that
this won’t work. If you try this, the XST synthe- entity edge_detector is
sizer will think that a clock signal is involved, but port (input : in std_logic;
since this isn’t the case, XST doesn’t know what
clock : in std_logic;
to do and therefore generates an error message.
rise : out std_logic);
I included the edge detector in the project as a
end edge_detector;
separate module (a function in VHDL; see List-
ing 1), but this is not mandatory. However, it
has the advantage that you can easily use the architecture behavioral of edge_detector is
function in another project. begin
The module starts with a library instruction, process (clock)
followed by a use instruction. The purpose of variable history : std_logic_vector(1 to 3);
these instructions is to ensure that the module begin
can access the appropriate standard functions if rising_edge(clock) then
and signals. If necessary, you can also add other rise <= history(2) and not history(3);
libraries here, such as numeric_std (for “+”, as history := input & history(1 to 2);
you may recall). Unlike most programming lan-
end if;
guages, these instructions do not apply to the
end process;
entire file in which they appear, but only to the
end behavioral;
first entity block and associated architecture
block(s) appearing after the instructions. This
means that each entity block is normally pre-
ceded by library statements.
time the value of this signal changes.
Now let’s have look at the entity block. It can After the process declaration, there is a list of
be regarded as essentially equivalent to a symbol variables that are needed inside the process but
in a schematic diagram. This is where the inputs not outside. Here there is only one: history, a
and outputs of the component are defined in the 3-bit shift register. This variable is a vector, which
port section. Here you see that all the signals means that it consists of several bits. Note that
are of type std_logic from the std_logic_1164
library, which means that they are logic signals
that can assume various states defined in the
library, including “0”, “1”, and quite a few others. The fully assembled and tested FPGA
The signals with the suffix in are the inputs of
development board is available in the Elektor
the module, while the signals with the suffix out
are the outputs. Shop for just $66.89 plus shipping.
After the entity block there is an architecture
block that defines the function. The latter block
has a name (behavioral) and is an implemen-
tation of the specified entity (in this case edge_
detector). The name behavioral is assigned
when you let ISE create a VHDL module. Another
frequently seen name is rtl, which stands for
Register Transfer Level (the level where VHDL
code is compiled), but you can also choose your
own name.
The edge detector is implemented as a pro-
cess that is dependent on the signal clock. The
See www.elektor.com/120099
instructions in the process are executed each

www.elektor-magazine.com | June 2013 | 47


•Projects

here the vector is defined as (1 to 3), while the


Listing 2. DCF77 timecode decoder with edge detector.
shift register in the DCF77 decoder is defined
library ieee; as (58 downto 0). Both of these definitions are
use ieee.std_logic_1164.all; valid, but you must be careful to avoid acciden-
use ieee.numeric_std.all; tally getting the bits confused when you use the
two together.

entity dcf77_decoder is
The edge detector is only active after a rising
port ( input : in std_logic;
edge of the clock signal. When that happens, it
clock : in std_logic; determines the value of the output signal rise
data : out std_logic_vector (58 downto 0) ); from bits 2 and 3 of history, and then feeds the
end dcf77_decoder; current value of the input signal into the shift
register in the same way as the code fragment
architecture behavioral of dcf77_decoder is for the DCF77 decoder.

As you can see, each block ends with an end


component edge_detector is
statement (or perhaps end if), possibly followed
port (input : in std_logic;
by the name of the block concerned, so your fin-
clock : in std_logic; gers will be busy on the keyboard. This is one of
rise : out std_logic); the drawbacks of VHDL: it requires a lot of typing.
end component edge_detector; Figure 2 shows what ISE thinks the edge detec-
tor should look as a schematic diagram. I person-
constant t1750ms: integer := 14000000; -- 1750 ms @ 8 MHz ally find this interpretation somewhat strange,
but maybe I’m missing something. Let’s just say
constant t150ms: integer := 1200000; -- 150 ms @ 8 MHz
that ISE is not the world’s best draftsman.
signal counter : integer := 0;
signal bits : std_logic_vector(58 downto 0) := (others => ‘0’); I discussed this module in so much detail to illus-
signal input_rise : std_logic := ‘0’; trate what a VHDL module looks like. All modules
follow this pattern of library, entity and archi-
begin tecture, including the DCF77 decoder module.
edge_detect: edge_detector port map (input => input,
clock => clock,
Using modules
If you want to use the edge detector in the DCF77
rise => input_rise);
decoder, you have to somehow make XST aware
of its existence. There are various ways to do
process (clock) is this, such as using a library, but here we use the
begin component method. Listing 2 shows the details
if rising_edge(clock) then of how this works. This listing also shows the
counter <= counter + 1; complete DCF77 decoder module, including the
if (counter=t150ms) then entity block and the associated architecture
block, the input and output signals, and the local
bits <= input & bits(58 downto 1);
variables and constants. Just have a good look
end if;
at it, take your time, and use the Web for help if
if input_rise=’1’ then
necessary – it’s not all that difficult.
if (counter>=t1750ms) then
data <= bits; -- Transfer data. You include the edge detector in the module by
end if; declaring it as a component at the top in the
counter <= 0; -- Clear counter. architecture block. Then you copy the entity
end if; block and replace the word entity by compo-
nent. The next task is to link in this block, which
end if;
you do after the start of the architecture block
end process;
by generating an instance of the block. For this
end behavioral; purpose, you have to specify a label and then

48 | June 2013 | www.elektor-magazine.com


FPGA

Figure 2.
This bizarre schematic
is the result of letting
ISE’s RTL Viewer draw the
schematic diagram of the
edge detector described in
this article (Design tab,
Synthesize – XST ➞
View RTL Schematic).
The signal input is not
connected to anything, and
the operation of this circuit
is a complete mystery to
the author. Maybe he got
something wrong?

use a port map to indicate which signals (ports) clock period when a rising edge is detected in
of the DCF77 decoder on the right in the folder the DCF77 signal.
must be linked to the signals (ports) of the edge If you forget to map an input signal of a com-
detector on the left in the folder. The clock and ponent, you will see a rather baffling error mes-
input signals are already taken care of because sage. It tries to explain that the forgotten signal
they are inputs (ports) of the DCF77 decoder does not have a default value and may therefore
as part of the entity block. You have to add a remain unconnected. Don’t say I didn’t warn you.
local signal of the same type for the edge detec-
tor output signal rise. Here I gave it the name Display
input_rise. Now you can use this signal in your Articles of this sort tend to be long because I
process. It will assume the value “1” for one try my best to explain everything properly, but

Figure 3.
An ISE screenshot showing
the code for the display
and the project hierarchy,
along with the green check
marks which prove that
it’s possible to compile the
project and generate a bit
file.

www.elektor-magazine.com | June 2013 | 49


•Projects

my editor is not especially Listing 3. The top level of the final DCF77 decoder.
fond of long articles. Nev-
ertheless, I want to explain library ieee;
in an article how you can use ieee.std_logic_1164.all;
produce a working VHDL
design, since otherwise the entity top is
task is a bit frustrating. As port ( dcf77_input : in std_logic;
I still have a lot to explain, clk_in : in std_logic;
I am omitting the code for hour_month : in std_logic;
the 7-segment display time_date : in std_logic;
from this article. I used
led1 : out std_logic;
the same two-digit display
led2 : out std_logic;
as in the third installment
t_sample : out std_logic;
[3], with a BCD to 7-seg-
digit1 : out std_logic_vector (6 downto 0);
ment decoder as described
there. This is a standard digit2 : out std_logic_vector (6 downto 0) );
textbook exercise, so there end top;
is no need to explain it in
detail. Have a look at the architecture behavioral of top is
project for this installment
[5] to see how it all works. component two_digit_display is
Figure 3 also shows a few port ( bcd1 : in std_logic_vector (3 downto 0);
details. bcd2 : in std_logic_vector (3 downto 0);
digit1 : out std_logic_vector (6 downto 0);
Back to the top
digit2 : out std_logic_vector (6 downto 0) );
As in the previous install-
end component;
ments, everything comes
together at the top, but
now the top is a VHDL component dcf77_decoder is
module instead of a sche- Port ( input : in std_logic;
matic diagram. This detail clock : in std_logic;
must be communicated to tick : out std_logic;
ISE in the Design Prop- sync : out std_logic;
erties. First create a new data : out std_logic_vector (58 downto 0) );
project based on the previ- end component;
ous one, in the same way
as described at the start of
signal data : std_logic_vector (58 downto 0);
the third installment [3].
signal bcd1 : std_logic_vector (3 downto 0);
Then delete all schemat-
signal bcd2 : std_logic_vector (3 downto 0);
ics, but keep the UCF file.
signal tick : std_logic;
Next, open Design Proper-
ties (e.g. at the bottom of
the Project menu) and set begin
Top-Level Source Type to display: two_digit_display port map (bcd1 => bcd1,
“HDL” and Preferred Lan- bcd2 => bcd2,
guage to “VHDL” (if this
isn’t already done).
Now you will see a form that you can fill in if you
Now you can start adding new source files. To know which input and output signals you need.
do this, open the Project menu or right-click the If you don’t know, leave the form blank. When
Design tab and select New Source…. Then select you’re done, click Next and then Finish. ISE will
VHDL Module, enter the file name (e.g. top), ver- create a file for you, containing the template
ify that Add to project is ticked, and click Next. where you have to add your VHDL code. Add as

50 | June 2013 | www.elektor-magazine.com


FPGA

digit1 => digit1, of the input and output


digit2 => digit2);
signals in top, which are
the signals named in the
entity block of the top
dcf77: dcf77_decoder port map (input => dcf77_input,
module, must match the
clock => clk_in,
names in the UCF file,
tick => tick, because this is how the
sync => led2, pins of the IC are linked
data => data); to the VHDL code. All of
the signals in the UCF file
process (clk_in) is must appear here, as oth-
begin erwise ISE will complain.
t_sample <= tick; A new feature here is the
led1 <= tick; use of vectors for the dis-
if rising_edge(clk_in) then
play pins. You can do this
in the UCF file by using
if time_date=’1’ then
an index with the name of
-- Show time.
the vector – for example,
if hour_month=’1’ then
digit1(0) corresponds to
-- Show hours. bit 0 of the digit1 vector
bcd1 <= data(32 downto 29); in the top module.
bcd2 <= “00” & data(34 downto 33);
else Tw o c o m p o n e n t s a re
-- Show minutes. called in the architec-
bcd1 <= data(24 downto 21); ture block of the top
bcd2 <= “0” & data(27 downto 25); module: two_digit_dis-
end if; play and dcf77_decoder,

else
and one instance of each
of them is used. With a
-- Show date.
larger display, such as six
if hour_month=’1’ then
digits, you could generate
-- Show month.
and link three instances
bcd1 <= data(48 downto 45); of two_digit_display ,
bcd2 <= “000” & data(49 downto 49); each with its own label.
else For linking the two com-
-- Show day of month. ponents, I defined several
bcd1 <= data(39 downto 36); additional signals that are
bcd2 <= “00” & data(41 downto 40); not needed outside the
end if; top module. For example,
end if; the tick signal is used to
end if;
blink LED1 each time a bit
is received. Since this LED
end process;
is not connected to a pin
on the FPGA board, it is
end behavioral;
also linked to the t_sam-
ple signal, which in turn
is linked to pin P86 in the
many files as the number of modules you intend UCF file. This makes it easy to view the sampling
to generate. In the present project there are points on an oscilloscope relative to the DCF77
five: top, DCF77 decoder, edge detector, BCD to input signal.
7-segment decoder, and 2-digit display.
The process of the top module does not do any-
The top module is shown in Listing 3. The names thing especially remarkable. It is actually a mul-

www.elektor-magazine.com | June 2013 | 51


•Projects

tiplexer that shows the hours, minutes, day of


the month or month number on the two-digit
7-segment display, depending on the levels of the
two control signals time_date (P94) and hour_
month (P95). With a but of cutting and pasting
(“&”), the right bits are extracted from the shift
register string to form 4-bit BCD codes, which
in turn are converted into 7-segment signals by
the BCD decoders. Here it should be noted that
it is not necessary to explicitly route the vectors
bcd1 and bcd2 to the display component, since
this is done implicitly by the port map.

When you synthesize this design, you will see a


number of warnings. They are caused by the fact
that some of the bits of the DCF77 shift register
are not used, and that bit 3 of the vector bcd2
is always “0” because the design does not use
eight-bit data (only the year number component
encompasses eight bits, but it is not used here).
Figure 4. The schematic of the DCF77 decoder is virtually You will also see that a nicely ordered hierarchy
identical to the one in the third installment [3]. Since has been generated on the Design tab (Figure 3),
the FPGA is not especially comfortable with 5-V signals, just as when you entered the design in sche-
a Zener diode is used to limit the input signal level to
matic form. Everything is therefore restored to
approximately 3 V.
the way it was. As already briefly mentioned, ISE
has an RTL viewer that is able to portray VHDL
code in schematic form (more or less; see Figure
2), which emphasizes the underlying duality: a
schematic is the same as VHDL code, and VHDL
code is the same as a schematic.

Despite my efforts to keep things short, it has


been a long journey. I have tried to convey all
Figure 5. The test circuit being driven by an Arduino the essential information, but a bit of self-reliance
acting as a DCF77 simulator. The display shows the and determination to build this project yourself
simulated hours figure (‘17’). The FPGA board is powered are probably still necessary. Good luck!
from the Arduino board.
(130066)

Web links
[1] Part 1: www.elektor.com/120099
[2] Part 2: www.elektor.com/120630
[3] Part 3: www.elektor.com/120743
[4] Part 4: www.elektor.com/130065
[5] Part 5: www.elektor.com/130066

52 | June 2013 | www.elektor-magazine.com


Retronics
80 tales of electronics bygones
www.ezpcb This book is a compilation of about 80 Retronics installments published in
Elektor magazine between 2004 and 2012. The stories cover vintage test
equipment, prehistoric computers, long forgotten components, and Elektor
Professional PCB & PCBA Supplier blockbuster projects, all aiming to make engineers smile, sit up, object,
drool, or experience a whiff of nostalgia.

ISBN 978-1-907920-18-9
New Website Is Online! 193 pages • $40.00
NEW!
Better Design

Ez
More Powerful

PC
Easier to Use

B
Instant Quote & Pay
1 to 40 Layers
Prototype to Production
Amateur to Professional

order now

Prototype start at $10/ea 10% OFF


fo
GR EEN a r
2L 4"x4" each nd
G OLD Me
Free Shipping! mbe r s
http://w ww.ezp cb.com Further information and ordering at www.elektor.com/retronics

Take out a FREE


membership to
Elektor.POST
• The latest on electronics and
information technology
• Videos, hints, tips, offers and more
• Exclusive bi-weekly project for
GREEN and GOLD members only
• Elektor behind the scenes
• In your email inbox each Friday

Register today at www.elektor.com/newsletter


www.elektor.com/newsletter
•Projects

From BASIC to Python (2)


A field report

In the first part of this series we looked at how Python


differs from BASIC. We went over the installation
By
Jean-Claude Feltes process and got our first program running. Now we
(Luxembourg)
go a little further with graph plotting and Fourier
synthesis. Finally with not much effort we use a
graphical user interface.

The Python language is particularly suited to engi- functions. The second line shows three functions
neering environments. Often it is advantageous imported from the Numpy extension.
to represent data graphically. The saying that a The ‘linspace’ routine can be used with an interval
picture is worth a thousand words is also true (here from 0 to 7) divided into an equal number
in the world of mathematics; an engineer can of parts (1,000 here) and represented as a vector
interpret so much more from the plot of a curve (array). This enables a fast and simple calculation
compared to a column of sterile mathematical of the value of the function. Numpy functions can
values. As a rule popular programming languages also handle vectors. Using just the line:
already feature tried and tested library routines
to ease the writing process. Python is no excep- y= sin(5*x)*exp(-x)
tion to this rule.
Calculates all 1,000 values of the y vector.
Plotting graphs This relieves you of the more usual ‘For’ loop
In Python the standard library for 2D graph plot- constructs and makes the code both fast and
ting is ‘Matplotlib’. Part of the Python philosophy understandable.
is summed up in its motto ‘There is only one way’ The command ‘plt.plot(x,y)’ plots the data as a
suggesting that there should only really be one curve on the graph and ‘plt.show’ is used to show
obvious way to achieve something in Python. it on the graph. To display more than one curve
This does not unfortunately apply to the mod- on the chart as shown in Listing 2 it is necessary
ules written in the additional libraries, a discov- to call the plot function again.
ery that has already cost me many hours work. The graph window (Figure 1) automatically shows
Notably in Matplotlib there exist simple proce- a toolbar which allows you to zoom and save the
dural interfaces and complicated object orientated chart. Apart from this it also indicates the cur-
interfaces. Examples given in books and on the sor coordinates. Should you want to spice up the
Internet use either one method or the other so graph with some GUI elements then it will be
it is quite easy to get confused. necessary to proceed using an object oriented
The simple interface ‘pyplot’ facilitates very sim- approach.
ple programming. The program in Listing 1 pro-
duces a damped sine wave oscillation. The curve Example: frequency response
it describes is shown graphically in a display win- As an example we can plot the transfer function of
dow (Figure 1). a simple RC low pass filter. The transfer function
The first line of the listing imports the interface shown here is a result of an RC voltage divider
‘pyplot’ as the object ‘plt’. ‘Numpy’ is an exten- network consisting of a resistor and capacitor
sion to python providing support for mathematical which has a complex impedance:

54 | June 2013 | www.elektor-magazine.com


Basic to Python

F = 1 / (1 + j ω R C)
Listing 1: Sinewave.py
The frequency response is given by a plot of import matplotlib.pyplot as plt
the value of F as a function of frequency (Fig- from numpy import sin, exp, linspace
ure 2). This is a good example to demonstrate
how Python handles complex variables.
x=linspace(0.0, 7.0, 1000)
In this program (Listing 3) the Array ‘f’ is calcu-
y= sin(5*x)*exp(-x)
lated with frequency steps incremented logarith-
mically. For plotting against linearly incrementing
plt.plot(x, y)
values use ‘linspace()’. An array for the complex
F values is calculated along with an array of the plt.show()
absolute values ‘Fabs’. Numpy is useful here with
its vector functions. There is no requirement for a
‘For’ loop in the calculation and the code is both
short and understandable.
Finally the plot is displayed, showing a logarith-
mically scaled frequency axis. For a professional
looking result it is important to define the grid
lines:

ax.grid(True, which = “both”, linestyle


= “-”)
Figure 1.
The grid lines are defined with “both” indicating The plot of a damped
the same line style for both major and minor oscillation given in Listing 1.
subdivisions. Lastly a solid line style is selected.
By adding the following lines of code:
Listing 2: Multigraph.py

# plot phi = f(f) mport matplotlib.pyplot as plt


phi = angle(F)*180.0/pi from numpy import sin, exp, linspace
ax2 = fig.add_subplot(212)
ax2.plot(f, phi) x=linspace(0.0, 7.0, 1000)
ax2.grid(True, which = “both”, linestyle y1 = sin(5*x)*exp(-x)
= “-”) y2 = y1* 0.5
ax2.set_xscale (“log”)
ax2.set_xlabel(“f/Hz”) plt.plot(x, y1)
ax2.set_ylabel(“phi/degrees”) plt.plot (x, y2)
plt.show()
We can show the phase shift introduced by the
filter.

Example: Fourier synthesis


Engineers quite partial to some mathematics will
be pleased to learn that some of the more useful
advanced engineering concepts such as Fourier
synthesis are also catered for in Python.
The example given in Listing 4 shows how a
square wave can be synthesized by summing
30 weighted harmonics of a fundamental sine
Figure 2.
wave. Figure 3 shows quite an impressive output The frequency response of
waveform from what is a relatively short program an RC low pass filter given
listing. More or fewer harmonics can be used to in Listing 3.

www.elektor-magazine.com | June 2013 | 55


•Projects

make the plot by altering the number of harmon-


ics defined in the code.

To GUI or not to GUI?


Dyed in the wool Linux users will tell you that
any system with a GUI is not a serious operat-
ing system and that the computer mouse is in
fact the work of the devil. Despite this view there
are still many people who can appreciate easy to
use, well designed software. Surely the graphical
method of file selection is both convenient and
Figure 3.
these days almost indispensable?
Fourier synthesis of a
square wave, see Listing 4. Anyhow Python allows the combination of both
graphical and non-graphical elements in the same
program. The program in Listing 5 functions as a
data plotter. Input data is displayed as both text
in a terminal window using the Print command
and also as a plot in a graphic window (Figure 4).
Looking at the functions available in the GUI
libraries you really are spoilt for choice. I began
with the ‘Tkinter’ library because it was already
supplied with the Python interpreter and proved
easy to understand. However a problem occurred
copying a graph to the clipboard so I moved on
to use the ‘wxPython’ library in these examples.
There are also other alternatives available such
as ‘PyQt’ and ‘GTK’.
Figure 4. This data plotter program is a useful example of
Data plotter: Terminal the use of GUI elements in a program. It shows
window showing list of how measurement values stored in a text file
values and their XY plot. can be edited and then displayed. The values

Listing 3: RC.py
import matplotlib.pyplot as plt
from numpy import pi, linspace, log10, logspace # calculate F (complex) and absolute value Fabs
from numpy import complex, abs # these allow F = 1 / (1 + 1j* 2 * pi * f * RC)
vector operations Fabs = abs(F)

# EDIT # plot Fabs = f(f)


R = 10.0E3 fig = plt.figure()
C = 100.0E-9 ax = fig.add_subplot(111)
ax.plot(f, Fabs)
# END EDIT ax.grid(True, which = “both”, linestyle = “-”)
ax.set_xscale (“log”)
RC = R*C ax.set_xlabel(“f/Hz”)
ax.set_ylabel(“U2/U1”)
# create f values equally spaced on a log scale ax.set_title(“RC low pass frequency response”)
f = logspace ( 1, 4, 100) # 100 values from 10**1 plt.show()
to 10**4

56 | June 2013 | www.elektor-magazine.com


Basic to Python

are plotted on a two dimensional graph. The X of the App objects. Next a Frame object creates
and Y values are also displayed in the form of a window for the application. This window will
two columns. have a menu and text box to enable editing and
In this example I have abandoned pure ‘Pythonic’ display of the data. The Text-Box is essentially
object orientated style for the sake of simplicity. a small editor: here you can edit data or enter
After the necessary modules are imported all the new values, and the clipboard can be controlled
functions are defined and ‘main’ is at the end of using the standard key-sequence shortcuts. A
the program listing. right-click on the mouse pops up the classic edi-
The main program begins with an instance ‘app’ tor functions.

Listing 4: Fourier.py
“””FOURIER SYNTHESIS OF A SQUARE WAVE””” harmonics
#------------------------------------------------- ug = zeros(nb_points)
------- uharm = zeros((nb_points, n+1))
# EDIT HERE
# harmonics and total voltage
n = 30 # number of harmonics for i in range(1,n+1):
nb_points=1000 # horizontal resolution ai = calc_amplitude(amplitude, i)
frequency = 100.0 #Hz fi = frequency * i
amplitude = 2.0 #V uharm[:,i] = ai * sin(2 * pi * fi * t )
ug = ug + uharm[:,i]
# END OF EDIT AREA return uharm, ug
#------------------------------------------------- #-------------------------------------------------
-------- ----------
print “Importing modules” “”” Main program”””
import matplotlib.pyplot as plt
from numpy import sin, exp, linspace, pi T=1/frequency
from numpy import zeros
#------------------------------------------------- # equally spaced time array for 1 period
--------- t = linspace(0.0, T, nb_points)
def calc_amplitude(amplitude, i):
“”” Calculate amplitudes of harmonics””” # plot harmonics
# take only odd harmonics uharm, ug = calc_harmonics(nb_points, n)
if i % 2 == 0: for i in range(1,n+1):
ai = 0 plt.plot (t, uharm[:,i])
else:
ai = (4/pi)*amplitude / i # plot resulting voltage
return ai plt.plot (t, ug)
#-------------------------------------------------
-------- s=str(n)+” harmonics, “+str(frequency)+”Hz,
def calc_harmonics(nb_points, n): ampl.=”+str(amplitude)+”V”
“”” Calculate harmonics and resulting voltage plt.title(“Fourier synthesis RECT\n”+s)
returns plt.xlabel(“t/s”)
uharm = array nb_points * n plt.ylabel(“u/V”)
ug = array nb_points
“”” # make plot visible
plt.show()
# init arrays for resulting voltage and

www.elektor-magazine.com | June 2013 | 57


•Projects

Listing 5: Dataplot.py
#!/usr/bin/env python
“”” Plot data from file “””
import wx
import os.path
import matplotlib.pyplot as plt

def create_menu(frame):
# create menu
menubar = wx.MenuBar()
# main menus
mnuFile = wx.Menu()
mnuData = wx.Menu()
menubar.Append(mnuFile,”&File”)
menubar.Append(mnuData,”&Data”)
# submenus
m_Open = mnuFile.Append(-1,”&Open”)
mnuFile.AppendSeparator()
m_Exit = mnuFile.Append(-1,”&Exit”)
m_Plot = mnuData.Append(-1,”&Plot”)
# attach menu to frame
frame.SetMenuBar(menubar)

# bind menu events to procedures


frame.Bind(wx.EVT_MENU, OnExit, m_Exit)
frame.Bind(wx.EVT_MENU, OnOpen, m_Open)
frame.Bind(wx.EVT_MENU, OnPlot, m_Plot)
#-----------------------------------------------------------------------
# Event handlers
def OnExit(event):
frame.Close()

def OnOpen(event):
# ask for filename
dlg = wx.FileDialog(None,”Open data file”, os.getcwd() ,””, “*.*”, wx.OPEN)
dlg.ShowModal()
filename = dlg.GetPath()

# open file, get data and put it into textbox


try:
f = open(filename, “r”)
data = f.read()
f.close()
textbox.SetValue(data)
except:
wx.MessageBox(“Could not open file!”)

58 | June 2013 | www.elektor-magazine.com


Basic to Python

def OnPlot(event):
# plot data
x,y = fill_xy_with_values(textbox)
plot_xy(x, y)
#-----------------------------------------------------------------------
def fill_xy_with_values(textbox):
# “”” get values from textbox
# returns arrays x, y and number of data points”””
text=textbox.GetValue()
lines=text.splitlines()

x=[]
y=[]
for line in lines:
columns = line.split() #separator can be one or more “ “ or “\t”
x.append (float(columns[0]))
y.append (float(columns[1]))

return x,y
#-----------------------------------------------------------------------
def plot_xy( x, y):
“”” Plot arrays x, y with matplotlib”””
plt.figure(1)
plt.subplot(111) # 1 row, 1 col, plot nb. 1
plt.grid(True)
plt.plot(x, y)
plt.xlabel(“x”)
plt.ylabel(“y”)
plt.show()
#-----------------------------------------------------------------------
# Main
#-----------------------------------------------------------------------
app = wx.App()

# create frame
frame = wx.Frame(None, title=’PLOTTER’, pos=(350,300))

create_menu(frame)
# editor textbox for data
textbox=wx.TextCtrl(frame, style = wx.TE_MULTILINE)

# show frame and run event loop


frame.Show()
app.MainLoop()

www.elektor-magazine.com | June 2013 | 59


•Projects

The ‘frame.Show()’ function displays a window Internet Links & Literature


and ‘app.MainLoop()’ is used to begin an event
[1] Listings etc.:
loop. The program waits for an event (mouse
click or keyboard key press) and then branches www.elektor.com/120143
to the event handler (the function called when [2] The author’s homepage:
an event occurs). http://staff.ltam.lu/feljc/home.html
The first function defines the menu and binds
[3] Python documentation:
menu events to the ‘On’ prefixed event han-
https://pypi.python.org/pypi/RPi.GPIO
dling procedures. Functions ‘OnExit’, ‘OnOpen’
and ‘OnPlot’ are called from the menu or when [4] Python tutorials:
the corresponding key is pressed. ‘OnOpen’ calls www.awaretek.com/tutorials.html
the file selection dialog ‘wx.FileDialog’. This also [5] Introduction:
uses ‘os.getcwd’ (get current working directory)
J.M. Hughes: „Real World Instrumentation
to find the file in the current directory.
with Python“
When the file name is selected an attempt is
made to open the file. A ‘try – except’ statement [6] Modules available in the Python package:
is used to detect any file opening error. When the http://pypi.python.org/pypi
file can be opened the contents are read into the [7] Python for engineers:
variable ‘data’ and put into the text box.
Andrew Pratt: ‘Python Programming and
Now the values can be edited, copied or pasted.
GUIs for Electronic Engineers’
Other values can of course also be added instead
of storing them from a file. www.elektor.com
The ‘OnPlot’ function displays the data as a graph.
The functions ‘fill_xy_with_values’ and ‘plot_xy’
are also called here. The former reads data from
the textbox and splits it into an array of lines. The
‘for’ loop is next iterated on all the lines which
are split again using ‘line.split()’. The individual
values are then stored in the arrays ‘x[]’ and ‘y[]’.
These are then returned as the function values.
The function ‘plot_xy’ draws the graph (Figure 4).
This small program is of course still a little rudi-
The Author mentary, but an equivalent in Visual BASIC would
Jean-Claude require much more work. It would be quite easy
Feltes lectures in to add a menu option here to store edited data.
electronics at the
Lycée Technique Coming up
des Arts et Métiers By now you should have a basic appreciation
in Luxembourg. of how powerful Python is and also how easy
This college caters it can be to use. Python has a growing band of
for both arts and devotees, if you wish to explore there are many
technical students resources that will take you further than we have
and provides shown you in these examples. Python is well
professional suited for tasks such as classic data collection
qualifications for and processing. Things like filters and FFTs are
apprentices and really no obstacle for Python and you have the
technicians. He possibility to upgrade your own project with a
spends much of his graphical user interface.
free time pursuing In the next installment we look into the program-
his interests in ming intricacies of data acquisition and control
electronics and via the RS485 Elektor Bus.
programming [2].
(120143)

60 | June 2013 | www.elektor-magazine.com


See what’s brewing
@ Elektor Labs 24/7

Check out
www.elektor-labs.com
and join, share, participate!

www.elektor-magazine.com | June 2013 | 61


•Projects

Beefing up
DAC Resolution
By Olivier Schrevens
(France)
More accuracy on your 8-bit conversions
When you need resolution higher than 8 bits, the cost of mixed analogue/digital
devices increases sharply. I wanted to show how, at no additional cost, I’ve im-
proved the resolution of ordinary, cheap digital/analogue converters, by using the
output of one as a programmable voltage reference for the others.

The idea for this circuit came from the need to


Vref Vref
prog.
drive various types of moving-coil voltmeter,
1.235V

using a microcontroller, via digital/analogue con-


verters with a series resistor on each output. Con-
nected to an ATMega8, my initial circuit worked
okay, but with the most sensitive voltmeters,
the number of usable bits was not enough to
HR_OUT

achieve full scale deflection. Rather than use a


Figure 1. D/A x1 or x2 D/A x1 or x2

The principle of cascading specific output resistor for each voltmeter, I used
D/A converters: the circuit described here to increase the resolu-
the output of the first tion obtained using 8-bit converters. Instead of
converter is used as the using voltage amplification, the trick consists in
voltage reference for the
100510 - 12

obtaining different output voltage ranges from the


second converter. D/A converter by changing its reference voltage.

My main criterion in selecting the D/A converter


concerns the minimum 1.5 mA current per out-
+5V put, to avoid the use of external opamps; as a
secondary point, I felt that a single DIL pack-
age would make construction easier. I ended up
6
BUS SPI

VDD choosing a TLC5628 from Texas Instruments,


R1 DATA 4 2
DATA DAC-A
three standard
an 8-bit octal DAC in a DIP16 package, able to
LOAD 12 1 resolution
CLK 5
LOAD DAC-B
16 outputs provide an output current of 2 mA per chan-
CLK DAC-C
IC1 15 nel. Each converter channel includes a 256-step
DAC-D
DAC-E
7 potential divider. The TLC5628 offers an option,
8
DAC-F four high
resolution
crucial here, of doubling the gain by amplifying
14 9
REF-1 DAC-G outputs
11 10 the converter output voltage (Fig. 1).
REF-2 DAC-H
D1
TLC5628
Figure 2. LDAC
13 This device is controlled via a 3-wire serial pro-
Configured in this way, the GND gramming bus (SPI), readily compatible with cur-
1V235
TLC5628 makes it possible 3
rent microcontrollers. The command format
to cover three voltage
ranges, from 0 to 1.235 V,
consists of eight data bits, three bits for
0 to 2.47 V, and 0 to 4.94 V 100510 - 11
selecting each of the eight built-in con-
simultaneously, using 256 verters, and lastly one bit for selecting the
conversion steps. output voltage gain (×1 or ×2). Before

62 | June 2013 | www.elektor-magazine.com


More Accuracy

being validated all together by the LDAC What’s more, by virtue of its architecture, this
signal, the SPI commands received by digital/analogue converter is more like a pro-
each of the converters in turn can be first grammable potentiometer than a conventional
stored in a latch. This option is not used DAC based on an R2R network.
here. You can find further details in the As this trick works really well without the need
device datasheet. to add any extra devices, I wanted to share it
with Elektor readers. The test program [1] loops
As the circuit shows, the TLC5628 has two sepa- each of the three maximum output voltages onto
rate voltage reference inputs (pins 11 and 14), output E (pin 7) for four seconds. The SPI clock
one for each group of four converters. is 11.0592 MHz/4. The SPI bus is in mode 3. An
indication of the running of the program is pro-
The external voltage reference common to the vided via the serial port (38,400 baud, 8N1).
first four converters, here 1.235 V, provided
by D1, an LM385, is connected to one end of (100510)
the dividers, whose other ends are connected
Internet Link
to ground. Hence each of the divider positions
provides a voltage that is directly linked to the [1] www.elektor.com/100510
reference voltage.

Clearly, this is the feature we are going to be


exploiting by using one of the D/A converters
to programme the reference voltage for the
other group of converters, thereby increasing
the resolution.

The other three outputs from the first group can


still be used with their normal 8-bit resolution.
So ultimately, in combination with the output
gain doubling option on each of the TLC5628’s
converters, the 8-bit resolution covers three volt-
age ranges from an initial 1.235 V reference.
By combining the RNG (range) bits for the con-
verter providing the reference voltage and for
the channel being used, we obtain the following
three ranges:

0 to 1.235 V
0 to 2.47 V
0 to 4.94 V

This is indeed equivalent to an increase in reso-


lution. So in all we now have seven analogue
outputs: four ‘high resolution’ outputs and three
normal 8-bit outputs.

Of course, other types of converter may well be


perfectly suitable for this circuit, if they have
similar characteristics; for example, TLV5628,
Figure 3. Result of the test program, displaying Vref2 and Vout.
TLC5620, TLV5620, or TLV5604.
However, it should be noted that cascading two
On the left, Vout = 1.235 V and Vref2 = 1.235 V, Gain = 1
converters in this way has the disadvantage
that their respective precision errors may add Centre, Vout = 2.47 V and Vref2 = 2.47 V, Gain = 1
together. On the right, Vout = 4.94 V and Vref2 = 2.47 V, Gain = 2

www.elektor-magazine.com | June 2013 | 63


•Labs

LCR Meter Shootout


By Thijs Beckers • “Wouldn’t it be nice to compare our newest And finally, the Elektor 500 ppm LCR Meter [4],
(Elektor Editorial) 500 ppm LCR Meter with one we have on which should set you back less than $400 in
loan from Hameg?” parts.

• “Yes, that could be interesting.” I started off with the vintage GRC meter. Since
the apparatus is older than I am and ‘less than
• “I can bring a vintage meter from my intuitive’ in terms of operation — at least to me
Retronics stock, if you like.” — I first needed to take a look at the manual. It
took me quite some time to dial into the thing
• “Awesome. Let’s see how the three and get an accurate measurement readout. Here’s
compare!” a breakdown:

This recent coffee chat I had with a few col- • read the manual: 10 mins;
leagues at Elektor HQ resulted in me putting • figure out how to measure a capacitor
three LCR Meters with a completely different correctly: 5 mins;
background through a quick hands-on test. • taking the actual measurement (setting the
dials for ‘zero’ deflection): 3 mins.
The Hameg meter (HM8118 [1], courtesy of
Rohde & Schwarz Netherlands [2]) is a profes- To be fair, if you were to use the 1650-A on a
sional instrument with a price tag of $2,000+. daily basis, you would probably be able to shave
off 80 % of the time needed for a single mea-
The vintage meter from the Retronics dept. is surement. Still, that’s over half a minute per
a General Radio Company (GRC) type 1650-A measurement. I have to admit though, the looks,
Impedance Bridge manufactured in 1960, cost- touch and feel of the sturdy dials and switches do
ing a whopping $1,000 back then [3]. add to the character of this piece of equipment.

Comparison chart
DUT GRC 1650-A Hameg HM8118 Elektor LCR Meter
8.2458 Ω 8.2379 Ω
Resistor 8.2 Ω 8.22 Ω (Vx=31,86 mV, (Vm=31.13 mV,
Ix=3.862 mA) Im=3.779 mA)
102.03 nF 102.20 nF
D: 0.01205 D: 0.013
100 nF
Capacitor 100 nF Rs=19.20 Ω Rs=19,20 Ω
D: 0.0267
(Vx=364.9 mV, (Vm=398.1 mV,
Ix=233.9 µA, 1 kHz) Ix=256.0 µA, 1 kHz)
94.475 µF 92.400 µF
D: 0.10099 D: 0.090
92 µF
Capacitor 100 µF Rs=170.27 mΩ Rs=155.4 mΩ
D: 0.1
(Vx=7.301 mV, (Vm=7.076 mV,
Ix=4.312 mA, 1 kHz) Ix=4.091 mA, 1 kHz)
995.85 µH 993.2 µH
Q: 0.49189 Q: 0.492
1.255 mH
Inductor 1 mH Rs=12.722 Ω Rs=12.681 Ω
Q: 0.63
(Vx=52.60 mV, (Vm=51.18 mV,
Ix=3.711 mA, 1 kHz) Ix=3.621 mA, 1 kHz)

64 | June 2013 | www.elektor-magazine.com


LCR meter Comparison

Then there’s the HM8118. As a modern device, Summarizing, ease of use has improved a lot
this one is (more or less) plug-and-play. After since the 1960’s and looking at the measurement
the auto calibration sequence the DUT (Device results the Hameg and the Elektor LCR Meter
Under Test) is inserted into the test fixture kind of photo finished. Our little meter holds its
(Hameg HZ181) and the requested component own against the big gun (see the comparison
properties are instantly displayed on the blue chart). Of course it wouldn’t be fair to ignore the
backlit LCD. Estimated time: 40 seconds from extensive range of options on the Hameg and the
start to finish, without reading the manual. 0.05% basic accuracy is nothing to sniff at either.
Sequential measurements? Let’s assume swap- Surprisingly, after more than 50 years and oper-
ping the DUT takes three seconds, selecting the ated by a rookie, the GRC 1650-A isn’t even that
correct measurement unit another two, total- far off. Talk about a trusty lab companion. They
ing five seconds. don’t make them like that anymore! Or do they?

Last but not least: the Elektor 500 ppm LCR Care to share your experience with ‘vintage’ lab
Meter. With just an LCD, an on/off switch and five devices? Drop us an email at [email protected].
buttons this may be as far as plug-and-play can (130166)
take you. The calibration is a once only job that
had already been taken care of on the prototype Internet Links
I used for this test, so I could go straight to the [1] www.hameg.com/13.0.html
actual measurement and put the DUT between
[2] testenmeetwinkel.nl
the clips. Estimated time: 10 seconds.
Sequential measurements are probably a little [3] www.elektor.com/075064
more time demanding compared to the Hameg [4] www.elektor.com/110758
using the Kelvin clips, but the HZ181 test fixture
can also be used on the Elektor LCR Meter.

www.elektor-magazine.com | June 2013 | 65


•Industry

New Performance
Requirements for Resistors

in aeronautics
By
Dominique Vignolo

applications
(Vishay)

The designs of today’s aircrafts


are being driven by two primary
goals: increasing aircraft fuel
efficiency and conforming to
anti-pollution regulations.
The humble resistor can
be helpful, provided some
of its key specifications
are given close
consideration.

In order to increase fuel efficiency, the weight have used high-temperature parts in a number of
of the aircraft is decreased by reducing cabling, applications. One of these was landing and brak-
which can be achieved by moving electronics close ing monitoring systems, where brake tempera-
to their function. To comply with anti-pollution tures were measured, and Wheatstone bridges
regulations, electric engines are being used to were used to monitor hydraulic and tire pres-
move the aircraft on the ground. sure. In this type of application, the electronics
In addition to changing design, the new demands were located in the wheel, and high temperatures
placed on aircraft manufacturers have also cre- reached them within an hour.
ated new performance requirements for elec- In terms of performance, these systems required
tronic components, including resistors. In this components with operating temperature ranges
article, we will explore the required parameters from –55 °C to +175 °C, but this quickly needed
for different types of resistors, including high- to be expanded to +200 °C. Components with
temperature capabilities for stringent operating good long-term stability were also required, as
conditions and long-term stability. the measurements had to remain stable for the
life of the aircraft. The expected drift after several
A history of high-temperature thousand hours of life could not exceed a given
components in aeronautics applications percent. Finally, the components had to exhibit
Over the past eight years, aircraft manufacturers good behavior during acceleration, vibration, and

66 | June 2013 | www.elektor-magazine.com


R’s at High Temperature

harsh environments. SMD products were shown


Leads Film resistor Solder Tj
to be the best under such conditions.
Like the aircraft braking monitoring systems, this
Solder pad Rth(jsp)
sensor required components with an operating
temperature range from –55 °C to +200 °C, very
Rth(spa)
good long-term stability, and excellent behavior
during acceleration, vibration, and harsh environ-
Ta
ments. The application utilized SMD wraparound
chip resistors.
Figure 1.
New regulations PCB 130139 - 11 Thermal parameters for a
wraparound chip resistor.
With new regulations aimed at reducing pollution
and saving fuel, more and more high- tempera-
ture applications are showing up. For example, A poor thermal management might induce melt-
engine temperatures are monitored so they can ing or reduced reliability of the solder joints;
be regulated by a computer. This means electron- reduce PCB performance (even burn-out); and
ics can be found inside the engine, where tem- lower chip resistor performance.
perature can be very high. Taking into account
that the average life of an aircraft is 25 to 30 Rth(jsp) and experimental data
years, the load-life stability of the components To use the thermal model above, manufacturers
used at high temperatures is a key parameter for need to provide Rth(jsp) for standard termination
aeronautics applications. The goal is to find the parts, in addition to experimental data relevant
best compromise between handling the power to chip resistors of standard sizes mounted on
and enhancing long-term stability. various PCBs. These PCB should be chosen to
Likewise, sensors can be used to measure tem- represent the standard and best cases in terms
perature of helicopter turbines. of thermal resistance.
In the experimental data collected in Table 1,
Thermal management we have:
Referring to Figure 1, resistor manufacturers • PCB sCu — A PCB with a thickness of 1.6
need only take care of Rth(jsp), but must carefully mm, double sided, 35 μm thick copper
consider their choice of material, the resistor (minimum), at least 50 % copper coverage
pattern, terminations, etc. Manufacturers who both sides
also improve thermal stability can offer resistors • PCB MCu — A PCB with a thickness of 1.6
that can withstand higher and higher tempera- mm, double sided, 70 μm thick copper
tures without undergoing significant drifts. This (minimum), at least 80 % copper coverage
removes limitations on Tj. both sides
The control of all the others parameters — namely • Temperature versus drift was plotted against
Ta, Pd, and Rth(spa) — are addressed by the cus- time and appears in Figure 1.
tomer’s assembly designers. Designers must take
the PCB material, the thickness and layout of Derating curve
the copper tracks, the cooling system, and the of a basic thermal model
interaction between surrounding components into The derating curve in Figure 2 is a representa-
consideration. tion of a basic thermal model:

Table 1. Load-Life drifts after 15,000 hours at various temperatures (experimental data).
PCB sCu PCB Mcu
Size Rth(jsp) (°C/W)
Rth(ja) (°C/W) Rth(ja) (°C/W)
0603 27 200 67
1206 20 110 60
2010 12 95 52
2512 11 95 51

www.elektor-magazine.com | June 2013 | 67


•Industry

The first way to use the derating curve is to


2 check the maximum power rating that can be
1.8
1.6 applied at a given temperature. For instance, if
1.4 a customer uses the best assembly (52 °C/W),
1.2
Drift (%)

1
the maximum power at +200 °C will be 0.57 W.
0.8 The second way is to reduce drifts by limiting
0.6
the temperature at the surface of the resistor.
0.4
1.2 In this example, the best assembly is used, but
0 the customer limits the power to 0.32 W. This
0 2000 4000 6000 8000 10000 12000 14000
t (h) moves the 52 °C/W curve down and the junction
With Pd (Tj = 230˚C) T = 185˚C T = 200˚C T = 215˚C T = 230˚C temperature will be +215 °C instead of +230 °C
130139 - 12 as with the 52 °C/W curve.

Conclusion
Figure 2. Tc = Ta + Rth x Pd From an analysis of temperature-induced drifts,
High-temperature drift vs. we have pointed out some specific features of
time. where our thin film resistors that give them advantages
Tc = temperature to be controlled; for high-temperature applications.
Ta = ambient temperature;
Pd = maximum allowed power dissipation; The irreversible drifts other than load life are neg-
Rth = thermal resistance between the surface of ligible. The load-life drift depends on Tj, however
the resistor at temperature Tc, and the ambient. it is reached; by pure ambient temperature or the
sum of ambient temperature and power dissipa-
The model can be written as Pd = (Tc – Ta) / Rth. tion (Tj = Ta + Rthja x Pd). This is valid, provid-
Per Table 1 we get: Rthja = 52 °C/W for a P2010 ing some Pd limitations given in the datasheets.
chip on a MCu PCB, and Rthja = 95 °C/W for a From an analysis of actual stability data and drifts
P2010 chip on an sCu PCB. versus time for various temperatures, it is obvi-
ous that even for Tj as high as +230 °C, drifts
Using the derating curve are under control and rather predictable from
Providing Tj max = +230 °C, the maximum power manufacturing data processes.
dissipation of the resistor at Ta = +200 °C will be:
To help assembly designers we developed a ther-
• 0.57 W for Rthp = 52 °C/W — This is the best mal model showing thermal resistance figures
Figure 3.
assembly. necessary to use this model. The derating curves
Example of a derating curve • 0.32 W for Rthp = 95 °C/W — This is the illustrate how good thermal management leads
(P2010). standard assembly. to load-life drift minimization.

From the above derating curves, it is clear that


the load-life stability of the resistor or of the resis-
52˚C/W 95˚C/W 0.32/52˚C/W
tor network is enhanced by properly controlling
1.2
1.1 the temperature at the surface of the resistor,
1 thus increasing the life of the components in
0.9 extreme operating conditions. Such conditions
0.8
are becoming more common as electronics in
0.7
P (W)

0.6
aeronautics applications move closer to their
0.5 functions.
0.4 (130139)
0.3
0.2
0.1
0
165 170 175 180 185 190 195 200 205 210 215 220 225 230 235 240
Ta (˚C) 130139 - 13

68 | June 2013 | www.elektor-magazine.com


EAGLE V6 Getting Started Guide NEW
Learning to fly with Eagle BOOK
This book is intended for anyone who wants an introduction to the capabilities of
the CadSoft’s EAGLE PCB design software package. After reading this book while
practicing some of the examples, and completing the projects, you should feel
confident about taking on more challenging endeavors.

The book will quickly allow you to:


• obtain an overview of the main modules of EAGLE: the schematic editor; layout
editor and autorouter in one single interface;
• learn to use some of the basic commands in the schematic and layout editor
modules of EAGLE;
• apply your knowledge of EAGLE commands to a small project;
• learn more about some of the advanced concepts of EAGLE and its capabilities;
• understand how EAGLE relates to the stages of PCB manufacture;
• create a complete project (a proven design from
the engineering team at Elektor), from design
through to PCB fabrication.
10% OFF
fo
GR EEN a r
208 pages • ISBN 978-1-907920-20-2 • $47.60
Incl. CD-ROM containing EAGLE 6.4.0 for nd
MS Windows, Linux and Mac G OLD Me
mbe r s

Further information and ordering at www.elektor.com/eagle

powered by Eurocircuits

n e w E l e k t o r P C B s
2 5% Discount on
Benefit now: Elektor PCB Service offers a permanent
90-day launch discount on new Elektor PCBs!

Check www.elektor.com/pcb for an overview of all Elektor PCBs


•Industry

iFixit (!) admit defeat to Orange repairability

The guys at iFixit have been accused of favoring one Having no luck with our vast array of poking, prodding,
fruit above all others. Now, to show some apprecia- and prying tools, a little more heat might be neces-
tion towards other members of the fruit family, they sary... But it turns out keeping a heat gun on the same
decided to test the accessibility, repairability, and spot for too long will damage the outer layer of the peel
end-of-life design of the Orange. beyond repair. If you’re not extremely cautious, you will
find yourself in need of a new outer peel.
The Orange is a fickle fruit. Believed to be the hybrid
between a pomelo and a mandarin, the team at As an added bonus, the Orange comes with a free
iFixit had no luck opening it with a guitar pick, plas- accessory, the Orange Peel — an amusing, Slinky-like

tic opening tool, tech knife, ruler, pair of tweezers, contraption, guaranteed to deliver hours of fun.
or even an iSesamo! After almost losing all hope, a All ten major internal components of this device are
tool descended upon them from the repair heavens, easily removable. However, iFixit are worried that
with Morgan Freeman’s voice booming throughout our they might not go back together as easily as they
teardown room. They called it the oOpener! come apart, a common problem in fruit repair.
Though the Orange’s repairability is highly question-
The Orange received a first-ever 0 out of 10 Repair- able, iFixit do admire its end-of-life design. It is com-
ability Score for a variety of reasons, but mainly pletely recyclable, compostable, and delicious-able.
because it’s... an orange. Lest you think that IFixit We hope that devices like this will someday catch the
is biased against oranges, note that users will have attention of other device manufacturers and help keep
to break its outer case in order to open it, the device electronics out of landfills... unless they are composta-
is impossible to reassemble, and the internal com- ble, of course!
ponents are filled with acid. Sounds like a bad time Navel Oranges have small, sterile seeds that can-
all around. not be used to reproduce more Oranges — a cutting
Some people may have tried the teardown at home from an existing fruit-bearing tree must be grafted
with mild to moderate success. They can celebrate to another tree. This is the most advanced anti-piracy
their success with an Orange Teardown t-shirt! Or if DRM measure iFixit have seen, definitively ensuring
they’re having technical difficulties with their Orange, that Orange owners won’t be able to produce copies
they can make sure they’ve identified their Orange of their Orange to share with their friends.
correctly, and then visit iFixit’s Orange Troubleshoot-
ing Guide to figure out what’s going on. Or perhaps www.ifixit.com/Teardown/Orange+Teardown/13470/1
they just need the right tool for the job. (130028-IV)

70 | June 2013 | www.elektor-magazine.com


Advertisement
news & new products

Model car sector gets


processing power and
software flexibility
Nordic Semiconductor ASA announced that
Taiwanese original design manufacturer
(ODM), Relight Technologies, has selected
the nRF51822 Bluetooth® low energy and
2.4 GHz proprietary System-on-Chip (SoC)
and the nRF24LE1 SoC as the basis of a
high-end remote control model car radio
transmitter. Relight’s “Smart-Tx” is one of the
most advanced surface radio transmitters for
remote control model car drivers.
The nRF24LE1, a proven 2.4 GHz ULP SoC
used in millions of devices worldwide powers
the wireless link between the transmitter and
vehicle. Relight selected the chip because of its
robust RF performance and because it can be
programmed with the ODM’s own RF software
protocol that has been specifically designed to
cope with the demands of remote control cars
used by enthusiasts. These vehicles can reach
speeds approaching 60 mph and are often
surrounded by many other remote control
vehicles, so range, low latency, and interference
immunity are essential requirements for the
wireless link.

The remote control handset also employs Nor-


dic’s nRF51822 SoC. Apart from its superior RF
performance and ultra-low power consumption
(–92.5dB RX sensitivity in Bluetooth low energy
mode and sub-10mA peak currents when run-
ning off a 3 V coin cell battery), Relight selected
the chip for two key reasons: Seamless con-
nectivity with smartphones, and because the
device’s powerful 32-bit ARM® Cortex™-M0

based processor features ample computing overhead


to cope with the complex remote control algorithms.

In addition to providing the remote controller’s com-


puting capability, the nRF51822 powers the wireless
link between controller and smartphone that relays
the user’s set-up instructions after they have been
selected using the app. The iPhone is a Bluetooth
Smart Ready product, ensuring it is interoperable
with any Bluetooth Smart product. A Bluetooth low
energy radio — as integrated into the nRF51822 — is
a prerequisite for a Bluetooth Smart product.
www.nordicsemi.com
(130028-XI)

www.elektor-magazine.com | June 2013 | 71


•Industry

New industrial analog I/O server


Lantronix’® newest member of its xSensoTM analog sensor networking family
is designed specifically for use in rugged and harsh environments including
industrial automation, process control, manufacturing, chemicals, oil and
gas industries, and many more. The new analog and relay outputs provide
the ability to take action by instantly controlling industrial processes and
equipment based on the sensor readings and predefined thresholds to solve
real-time problems. The Lantronix xSenso product family comprises feature-
rich, low cost solutions for remote sensor monitoring and process control.
The new xSenso Controller is a compact, DIN-rail or wall mount solution that
enables analog sensors (voltage or current) to easily and transparently send
real-time data to any node on the Internet or to a cloud-based application.
In addition to its already robust feature set, the new xSenso can take action
when a condition is met (e.g., temperature threshold, pressure level, etc.),
triggering its internal relays or outputting voltage or current to control an
event in real time. In an existing control system, the xSenso can also be
placed in between the sensor and the controller to mirror the analog data
from its input to its output, while simultaneously presenting the data through
a web browser to computers or mobile devices.
The product family is compatible with some of the most popular off-the-shelf data acquisition systems such as LabVIEW™ and DASYLab™,
and its compact and efficient design enables it to be affordably installed in dispersed or remote locations.
www.lantronix.com (130028-VI)

RFICs flying in Globalstar communication satellites


Peregrine Semiconductor UltraCMOS® Phase Locked Loop (PLL) frequency synthesizer and prescaler devices are
designed into six Globalstar mobile communication satellites that were launched into orbit on February 6, 2013.
Built by Thales Alenia Space in France, the low-Earth orbit satellites transmit audio and data communications for
Globalstar’s mobile voice and data customers worldwide. Peregrine’s PLL and
prescaler enable communication in sixteen C- and S-band transponders in the
system, which connects end users with terrestrial communication networks via
vehicle-mounted mobile devices, as well as fixed terminals, such as those used
for rural telephony. The Peregrine devices feature extremely low phase noise
and Single Event Effect (SEE) immunity — attributes enabled by the insulating
properties of the UltraCMOS process.
Single Event Effects are errors that are caused by naturally-occurring space-
based radiation. There are two primary types of SEEs. Single Event Upsets
(SEUs) are non-destructive and can be corrected. Single Event Latchups (SELs),
on the other hand, are often catastrophic, resulting in permanent damage and
requiring, at a minimum, a power-down to recover. SELs can occur when a
high-energy particle strikes a semiconductor device, causing a short circuit
from power to ground within the device. RFICs manufactured using UltraCMOS
technology do not contain the bulk parasitics found in regular CMOS devices,
making latchup impossible.
Peregrine’s UltraCMOS technology is an advanced RF Silicon-On-Insulator process that utilizes a synthetic sapphire
substrate — a near-perfect electrical insulator. This substrate enables low parasitic capacitance, high signal
isolation, excellent broadband linearity, and inherent SEL immunity. These attributes make UltraCMOS well suited
for high-reliability applications, such as commercial satellites.
www.psemi.com (130028-X)

72 | June 2013 | www.elektor-magazine.com


Advertisement
Wide-temperature ARM system on module

EMAC, Inc. introduces the SoM-9X25, a wide temperature System on Module (SoM) based
on the Atmel AT91SAM9X25 processor. Designed and manufactured in the USA; this wide
temperature, fanless ARM9 400 MHz SoM has an Ethernet PHY included along with 6 serial
ports with auto RS-485 provision. It utilizes up to 1GB of NAND Flash, 8MB of serial data
flash, and up to 128MB of DDR2 RAM. A SoM is a small embedded module that contains the
core of a microprocessor system.

Using the same small 144 pin SODIMM form-factor (2.66” x 1.5”) utilized by other EMAC
SoM modules, the SoM-9X25 is the ideal processor engine for your next design. All of the
ARM processor core is included on this tiny board including: flash, memory, serial ports,
Ethernet, SPI, I2C, I2S audio, CAN 2.0B SDIO, PWMs, timer/counters, A/D, digital I/O lines,
video, clock/calendar, and more.
The SoM-9X25 is designed to plug into a carrier board that contains all the connectors and
any custom I/O required for the application. This approach allows the customer or EMAC to
design a custom carrier board that meets the customer’s I/O, dimensional, and connector
requirements without having to worry about the processor, memory, and standard I/O

functionality. With this System on Module approach, a semi-custom hardware platform can
be developed in as little as a month.
In addition to the option of the developing a Carrier board, one can be purchased off-the-
shelf from EMAC. EMAC provides off-the-shelf Carrier boards that feature A/D, D/A, MMC/SD
card, keypad, LCD, audio, and modem interfaces. The recommended off-the-shelf carrier
board for the SoM-9X25 is the SoM-150ES which allows the user to immediately start
coding their application using the powerful Linux or WinCE operating system and tools.
The System on Module approach provides the flexibility of a fully customized product at a
greatly reduced cost.
EMAC provides a Free Eclipse IDE for Linux development. All the compiling, linking,
downloading, and debugging inherent to software development can be done from one
easy to use high level interface. When developing for Microsoft Windows CE 6.0 applications,
Microsoft Visual Studio 2005/2008 can be utilized. Both Visual Studio and Eclipse provide
everything the user needs for developing SoM-9X25 applications. EMAC provides an SDK for
the SoM-9X25, which contains source examples and drivers. Quantity 1 price for SoM-9x25
starts at $180.
www.emacinc.com/som/som9x25.htm
(130028-IX)

www.elektor-magazine.com | June 2013 | 73


•Magazine

Konrad Zuse’s
Z1 through Z4, and Beyond
It all began with zeroes,ones
1 and algebra
Ever since the earliest days of mathematics and logical thought,
people have tried to find ways to simplify the repetitive work involved.
Based on an understanding of logical functions and relationships vari-
ous highly sophisticated calculating machines were developed. This
article takes a tour of Konrad Zuse’s impressive contributions to the
development of the computer.

By Peter Beil (Germany)


modern machines can only emulate such
One of the earliest calculating machines a feature indirectly.
is the one built by Gottfried Leibniz in Konrad Zuse had seen that the only way
around 1700 (Figure 1). However, a to make the required operations tech-
couple of hundred years passed before nically feasible in his computer design
calculating machines were able to carry was to use the binary system. This was
out logical operations directly. The in sharp contrast to the researchers and
resourceful thinker and inventor Konrad pioneers in the USA and in Great Britain,
Zuse (Figure 2) built his Z1 in 1938. This who initially preferred to use the decimal
3
was a fully-fledged (albeit mechanical) system.
computer. (The term ‘computer’ derives
from the Latin for ‘reckon together’ or Z2, 16 bit @ 10 Hz
‘calculate’.) The machine was freely pro- The mechanical problems with the Z1
grammable and calculated using binary prompted Zuse to try an experiment:
values. The original was destroyed in the in 1939 he designed the Z2, employing
war, but a replica has been made and is several hundred telephone relays (Fig-
on show in the Deutsches Technikmu- ure 4). It ran at a clock frequency of
seum (German Technology Museum) in approximately 10 Hz, and provided the
Berlin (Figure 3). four basic arithmetic operations on fixed-
point binary numbers. It sported sixteen-
4
Z1: a troubled start bit memory and weighed around 300 kg
The Z1 computer was based on logi- (660 lb).
cal functions such as ‘and’ and ‘or’,
these functions being computed purely Z3: data from filmstrip
mechanically! The machine had a consid- In May 1941 Zuse demonstrated his Z3,
erable number of infelicities arising as a the first viable digital computer (Fig-
result of mechanical tolerances, friction ure 5). This used 600 relays in the arith-
and so on, and the switching elements metic unit and a further 1400 relays in the
often jammed. One advantage the Z1 memory unit. Like the Z1, it used binary
had over more recent computers is that floating-point arithmetic, and it was the
5 its storage was completely non-volatile: first universal programmable computer.

74 | June 2013 | www.elektor-magazine.com


Reportedly Zuse had a friend working at operations it could calculate squares and
UFA (a large German film studio) who extract roots. The Z4’s instruction set
gave him the idea of using punched film- consisted of a total of 29 instructions.
strip as an input medium. An electric printing device was connected
Punching the filmstrip was done directly to it, but it was not what we would now
on the unit (Figure 6). There was also recognize as a ‘printer’ but rather was
of course an accompanying reader: used to produce logs of the machine’s
this used the sprocket holes in the film computations (Figure 15).
to obtain precise alignment with the Programs were again entered using
punched holes representing the input punched filmstrips (Figure 16). ‘Stor- 6
data (Figure 7). age’ in the modern sense was not pos-
The original of the Z3 was also destroyed sible, and interrupting the power supply
in the war, but a fully-functional replica resulted in the loss of all data. Ferrite
is on display at the Deutsches Museum core memory was not to appear on the
(German Museum of Science and Tech- scene until the middle of the 1950s.
nology) in Munich. The replica was made The Z4 was capable of about 30 opera-
by (now dissolved) company Zuse KG. A tions per minute: an addition took half
glance at its innards reveals a phenom- a second and a multiplication about 3.5
enal amount of wiring, a rotary switching seconds. Work had started on various
mechanism to generate clock signals, and refinements, such as program branches
stepping relays, as subsequently used in and index registers for address calcula- 7
telephone dialing systems (Figures 8, 9 tions, but these were lost in the chaos
and 10). The machine operated on 22-bit of war.
words, comprising a seven-bit exponent,
a 14-bit mantissa and a sign bit. It had Programming language and
relay-based storage for 64 words, and post-war developments
programs always ran in a loop. Num- It is not widely known that Konrad Zuse
bers could be entered using a keyboard was already at that time aware of the
(Figure 11), and results appeared in need for a high-level programming lan-
a display area using small lamps (Fig- guage. In 1945 and 1946 he developed
ure 12). As well as the four basic arith- ‘Plankalkül’ (‘formal system for plan-
8
metic operations, the Z3 also offered a ning’) but he was not able to publish
square root function. his results. The work foreshadowed more
modern programming languages such as
Z4: still all mechanical Fortran, ALGOL and COBOL.
In 1942 Zuse began work on the Z4, In the years immediately following the
which was first ready for use in 1945 war the Z4 went on something of an
(Figure 13). This machine was also odyssey through Germany, Switzerland
based on relays and found itself in and France. IBM (among others) was
competition with the American ‘Mark I’ interested in acquiring the intellectual
(1944) and ‘ENIAC’ (1946). However, property rights with the aim of hampering
these operated on different principles, further development of the machine. By
9
for example using valve technology and the 1950s the machine found itself at the
decimal representations (Figure 14, ETH (Swiss Federal Institute of Technol-
Einiac 1946). ogy) in Zurich where it was employed to
Like the Z3, the Z4 was very similar help with scientific research problems:
in many ways to today’s computers. It in 1950 it was the only computer oper-
could execute loops, offered floating- ating in continental Europe. In 1960 the
point arithmetic with a 24-bit mantissa, machine completed its travels, coming to
a 7-bit exponent and a sign bit (and rest in the Deutsches Museum in Munich.
hence a basic 32-bit word length), and The Zuse company continued to make
two simultaneously-operating arithme- scientific mainframe computers for
tic units. As well as the basic arithmetic several years, and in 1961 produced the 10

www.elektor-magazine.com | June 2013 | 75


•Magazine

How a computer like the Z3 ‘thinks’


Each operation ultimately
comes down to the addition or
subtraction or two integers.
Two floating-point numbers
are added as follows. First
the difference between the
exponents is calculated; then
this value is used to shift one
11
of the mantissas to align the
binary points; and then the
aligned mantissas are added.
Subtraction is performed K. Zuse (l) and H. Nixdorf
similarly, with an additional step
where the two’s complement of the second mantissa is taken.
Multiplication is done by adding the two exponents and then multiplying the
mantissas using an iterative addition method.
Division is similar to multiplication: the exponents are subtracted and the
mantissas then divided using an iterative subtraction method.
12 Square roots are calculated using an iterative method similar to division.
At a high level the arithmetic unit consists of two parts, one dealing with
calculations on the exponents and one with calculations on the mantissas.
Instructions that are implemented using an iterative algorithm require a
sequencer to drive the separate parts of the machine: this roughly corresponds
to the use of microcode in modern processors.

first ever fully-functional plotter in the Acknowledgements


form of the ‘Graphomat’. However, the
13 Photographs 4, 5, 6, 7, 8, 9, 10, 11, 12,
small company was unable to withstand 13, 15, 16 by the author, with the per-
the overwhelming competition from the mission of the Deutsches Museum in
United States and in 1964 was taken Munich:
over by BBC (Brown Boveri & Cie.) and
Photograph 14: wikipedia.de
then in 1967 by Siemens AG.
(130040) Photograph 3: German Technology Mu-
seum, Berlin
Photograph 2: Prof. Horst Zuse

14

Retronics is a monthly section


covering vintage electronics
including legendary Elektor designs.
Contributions, suggestions and
requests are welcome; please
telegraph [email protected]
15 16

76 | June 2013 | www.elektor-magazine.com


Spring into summer
savings event!

All books are now 15% off.


From assembly language to microprocessor design, embedded Linux to C programming,

these tools will help you master any engineering challenge.

For professionals, academia, and enthusiasts alike,

CC-Webshop’s collection of audio and electronics

engineering books will help take your ideas

from concept to creation.

Offer ends 6/30/13

www.cc-webshop.com
•Magazine

Hexadoku Puzzle with an electronic touch


This Hexadoku puzzle doesn’t require anything remotely resembling a Zuse “Retronics” computer to crack. Logic
reasoning, concentration and patience should do the trick and produce the solution. So go ahead entering the right
numbers or letters A-F in the open boxes, find the solution in the gray boxes, submit online, and you automatically
enter the prize draw for one of four vouchers.

The Hexadoku puzzle employs numbers in the hexadecimal black lines). A number of clues are given in the puzzle and
range 0 through F. In the diagram composed of 16 × 16 boxes, these determine the start situation.
enter numbers such that all hexadecimal numbers 0 through F
(that’s 0-9 and A-F) occur once only in each row, once in each Correct entries received enter a prize draw. All you need to do
column and in each of the 4×4 boxes (marked by the thicker is send us the numbers in the gray boxes.

Solve Hexadoku and win! Participate!


Correct solutions received from the entire Elektor readership Before July 1, 2013, supply your personal details and the solution
automatically enter a prize draw for one Eurocircuits PCB voucher (the numbers in the gray boxes) to the web form at
worth $140.00 and three Elektor book vouchers worth $60.00 each,
www.elektor.com/hexadoku
which should encourage all Elektor readers to participate.

Prize winners
The solution of the April 2013 Hexadoku is: 934CB. The Eurocircuits $140.00 voucher has been awarded to David Smart (USA).
The Elektor $60.00 book vouchers have been awarded to Joseph Reding (Luxembourg), Karsten Krummeich (Germany), and Paul Blaak (Netherlands).

Congratulations everyone!

9 C 2 4 B D E F 7 6 A 0 5 8 3 1
5 E B D 3 1 A 9 4 F 8 C 6 7 0 2
A F 3 0 8 4 6 7 D 1 2 5 E 9 B C
6 1 7 8 C 0 5 2 E 3 9 B 4 A D F
7 B 6 E 4 A F 1 9 8 0 3 C D 2 5
8 D 9 3 5 2 B 0 6 A C 1 7 E F 4
C 0 1 F 6 8 7 E 5 4 D 2 A B 9 3
2 A 4 5 9 C D 3 F 7 B E 8 0 1 6
3 2 8 1 A 5 0 D B C E F 9 6 4 7
B 4 5 7 E F 8 6 0 2 3 9 1 C A D
D 6 F A 2 7 9 C 1 5 4 8 B 3 E 0
E 9 0 C 1 3 4 B A D 6 7 F 2 5 8
F 3 E B 7 6 C A 2 0 5 4 D 1 8 9
0 5 C 6 D E 1 8 3 9 F A 2 4 7 B
1 8 A 2 F 9 3 4 C B 7 D 0 5 6 E
4 7 D 9 0 B 2 5 8 E 1 6 3 F C A

The competition is not open to employees of Elektor International Media, its business partners and/or associated publishing houses.

78 | June 2013 | www.elektor-magazine.com


Gerard's Columns•

In The Clouds
By Gerard Fonte (USA) data in case of a hardware failure. They have major assets in
place to prevent unauthorized access and infection from viruses
The Leading Edge and malware. After all, this is their business. And if they can’t
Everyone likes to be at the forefront of technology. Using all maintain security, they know that they will be quickly out
the latest gadgets and applying all the latest ideas. Unless of business. However, these companies are probably much
you’re a company and you have to rip up and throw away all larger targets for hackers than your company. And it’s hard
the old technology for the newest. That’s expensive. And will to protect against a virus that’s completely new. So, it’s really
it really give you the edge? Or is this just a fad that you’ll not a simple task to estimate your risk.
regret in a year or so? Like anything new, it will take time to determine the precise
Re-training the engineers and technicians and assemblers is characteristics of the cloud. It will probably take five to ten years
not cheap. And then there are all those technical issues. Your for the market to mature to a point where the uncertainties
engineers haven’t designed this type of system before. What are small, the weak companies disappear and standards are
problems will arise? Worse, what problems will go unseen set. For example, suppose you are late with a payment. Can
until the product has been marketed for a year or so? It’s the company withhold your data and cripple your company?
not called the “Bleeding Edge” for nothing. This is where What happens if they go bankrupt? There are many nightmare
the company hemorrhages capital and time for a perceived scenarios that are limited only by the imagination. Of course,
advantage somewhere in the future. If it works, it’s brilliant. it’s hard to say what’s realistic and what isn’t.
If it doesn’t, pass out the parachutes.
In the 1950’s atomic power was The Thing. Ford developed Change in Infrastructure
the 1958 concept car called the Nucleon that was to operate However, there is a somewhat subtle aspect that is not always
on a small atomic fission reactor (similar to those used on considered when employing Cloud Computing. Fundamentally,
submarines). Can you imagine the results of millions of the company is out-sourcing part of the Information Technology
unlicensed nuclear reactors tearing across the US, getting (IT) Department. This may be good or not. It depends on the
into accidents and spilling their nuclear fuel? The idea seems company and the IT Department. The problem is that the out-
mind-boggling today. In 1954 RCA considered an atomic battery sourcing is not obvious. What’s more, it starts the company
for use with hearing aids. What could possibly go wrong with down a path that is difficult to reverse.
strapping a radioactive device to your head for 12 hours a When a company out-sources product assembly or accounting,
day—for the rest of your life? the action is clear. Work is being shifted from inside the company
Today’s Thing is cloud computing. There’s all this “excess to a different company. But with the cloud, the IT department
hardware and software” that’s just sitting around and not being just orders some new software. Everything seems the same.
used. Why not take advantage of all these cheap resources? Yet, as time passes, more and more applications and data are
You don’t have to expand your own facilities. All you have to do being quietly shifted off-site. After a while, the on-site hardware
is rent them cheaply on the internet. No re-training costs, no and software requirements are significantly reduced. The IT
hardware costs, no added personnel. You get instant leading- department will shrink and personnel may be let go for lack
edge technology with no risk and fantastic benefits. It seems of work. Quite possibly, the IT department will morph into a
like a no-brainer decision. (For reference, atomic power was service department that interfaces the company to the cloud
billed as being “too cheap to meter.” That’s right—free energy.) supplier. Again, this may or may not be good for the company.
The important point is that all of the consequences of moving
The Fine Print to the cloud need to be foreseen and considered before any
Except you no longer have control of your data and software. action is taken. And it seems that it is often the case that the
Someone else does. If you are just playing a game on-line, IT department sows the seeds of its own dissolution without
control probably isn’t very important. The worst that could realizing it.
happen is that your avatar could face an untimely and Further, you can now see that trying to extract yourself from the
unexpected termination. But what about your proprietary design cloud is not an easy thing to do. You will have to invest heavily
information or financial records? You are now dependent on in hardware and software, hire and re-train IT professionals
another party to keep your data safe and sound. and basically re-invent the wheel. Once you’re in the cloud it’s
Of course the companies that supply cloud-computing resources hard to get back to earth.
take a great deal of effort to maintain the highest security for (130182)
their data. They usually make at least a second copy of your

www.elektor-magazine.com | June 2013 | 79


•Store

1 2

Limited Time Offer for GREEN and GOLD Members!


13% DISCOUNT + FREE SHIPPING
www.elektor.com/june

OS Hard- and Software for Electronics show how personal applications can be programmed. of PCB layouts at printer resolution, adapt PCB layouts
Applications A wide variety of applications is presented based using your favorite graphics program, zoom in / out
Open Source on a solid number of hands-on examples, covering on selected PCB areas and export circuit diagrams and
1
Electronics on Linux anything from simple math programs, reading illustrations to other programs.
If you have ever wanted to take advantage of the sensors and GPS data, right up to programming ISBN 978-90-5381-273-0 • $37.90
expanding field of open source software for electronics for advanced Internet applications. Besides writing
and everyday applications, this book is for you. Using applications in the Java programming language, this
the Linux OS, Warwick A. Smith guides you through the book also explains how apps can be programmed Display, buttons, real time clock and more
world of open source hardware and software, teaching using Javascript or PHP scripts. When it comes to
4
Elektor Linux Board
readers to use EDA tools and software that is readily personalizing your smartphone you should not feel Extension
available online, free to download. The hardware limited to off the shelf applications because creating This extension board was developed to further
projects inside can be built using easily obtainable your own apps and programming Android devices is propel our Embedded Linux series of articles and the
parts, in the comfort of your own home, on single sided easier than you think! matching GNUblin board. It has a display, buttons,
PCBs, or professionally manufactured with output files 244 pages • ISBN 978-1-907920-15-8 a real time clock and 16 GPIOs. Linux devotees,
generated by you. Open Source Electronics on Linux $56.40 switch on your solder irons. The Linux extension
is about changing today’s electronics enthusiast into board includes everything needed to provide the user
empowered, savvy, discerning engineers capable of interface for a wide variety of projects!
building and modifying their creations, be it solely on A whole year of Elektor magazine on a single disk Module, SMD-populated and tested board, incl.
Linux or in tandem with your current operating system. 3 DVD Elektor 2012 LCD1, X1, K1-K4, BZ1, BT1 for home assembly
272 pages • ISBN 978-1-907920-19-6 The year volume DVD/CD-ROMs are among the most Art.# 120596-91 • $50.20
$47.60 popular items in Elektor’s product range. This DVD-ROM
contains all editorial articles published in Volume 2012
of the English, American, Spanish, Dutch, French and Taming the Beast
Programming step-by-step German editions of Elektor. Using the supplied Adobe 5 FPGA Development Board
2 Android Apps Reader program, articles are presented in the same FPGAs are unquestionably among the most versatile but
This book is an introduction to programming apps layout as originally found in the magazine. An extensive complex components in modern-day electronics. An
for Android devices. The operation of the Android search machine is available to locate keywords in any FPGA contains a maze of gates and other circuit elements
system is explained in a step by step way, aiming to article. With this DVD you can also produce hard copy that can be used to put together your own digital circuit

80 | June 2013 | www.elektor-magazine.com


Books, CD-ROMs, DVDs, Kits & Modules

6 7

on a chip. This FPGA development board (designed in Sound Secrets and Technology but extremely powerful programming language for
the Elektor Labs) shows how easy it is for any electronics 7 Electric Guitar PIC microcontrollers. Assuming you have absorbed
enthusiast, whether professional or amateur, to work What would today’s rock and pop music be without all lessons you should be confident to write PIC
with these programmable logic devices. electric lead and bass guitars? These instruments microcontroller programs, as well as read and
Module, ready build and tested Art.# 120099-91 have been setting the tone for more than forty years. understand programs written by other people. You
See www.elektor.com/fpgaboard Their underlying sound is determined largely by their learn the function of JAL commands such as include,
electrical components. But, how do they actually pin, delay, forever loop, while loop, case, exit loop,
work? This book answers many questions simply, in repeat until, if then, as well as the use of functions,
LabWorX 2 an easily-understandable manner. For the interested procedures and timer- and port interrupts. You
Mastering Surface musician (and others), this book unveils, in a simple make an LED blink, build a time switch, measure a
6
Mount Technology and well-grounded way, what have, until now, been potentiometer’s wiper position, produce sounds,
This book takes you on a crash course in regarded as manufacturer secrets. suppress contact bounce, and control the brightness
techniques, tips and know-how to successfully The examination explores deep within the guitar, of an LED. And of course you learn to debug, meaning:
introduce surface mount technology in your including pickups and electrical environment, so how to spot and fix errors in your programs.
workflow. Even if you are on a budget you too that guitar electronics are no longer considered 284 pages • ISBN 978-1-907920-17-2
can jumpstart your designs with advanced fine highly secret. With a few deft interventions, many $47.60
pitch parts. Besides explaining methodology instruments can be rendered more versatile and
and equipment, attention is given to SMT parts made to sound a lot better – in the most cost-
technologies and soldering methods. Many effective manner. Further information and ordering:
practical tips and tricks are disclosed that bring 287 pages • ISBN 978-1-907920-13-4
www.elektor.com/store
surface mount technology into everyone’s reach $47.60
Elektor US
without breaking the bank. A comprehensive kit
111 Founders Plaza, Suite 300
of parts comprising all SMT components, circuit
East Hartford, CT 06108
boards and solder stencils is available for readers 10 captivating lessons
USA
wishing to replicate three projects described in
8
PIC Microcontroller Phone: 860.289.0800
this book. Programming Fax: 860.461.0450
282 pages • ISBN 978-1-907920-12-7 Using the lessons in this book you learn how to E-mail: [email protected]
$47.60 program a microcontroller. You’ll be using JAL, a free

www.elektor-magazine.com | June 2013 | 81


•Magazine

Next month in Elektor

Elektor Project Generator Edition 2013


Extra-thick edition with an extra bunch of circuits
Next month we publish the 37th edition of Elektor’s famed double edition for the months of July and August. This
loved & collected issue offers a bulk of ideas, projects and practical software in a mix of small and large articles.
Our editors and designers are now burning their midnight oil to make sure you can enjoy lots of pages with
detailed descriptions and inventive electronics applications.

Don’t miss it, this jumbo edition of Elektor packed with articles and projects like:
CAN-checker – ElektorBus-steppermotor control – CDI-ignition for mopeds – Inrush current limiter – Class-D
audio amplifier with 555 – Servo checker – ECG-monitor for Android – USB-power pack – Numitron
Arduino clock – Parking help – Multi-channel temperature logger – IR remote for Android – Extremely
accurate digital clock – Universal precision measurement interface – AVR-USB-keyboard-stick

Article titles and magazine contents subject to change; please check www.elektor-magazine.com
Elektor July & August 2013 edition published June 26, 2013

See what’s brewing


@ Elektor Labs 24/7

Check out
www.elektor-labs.com
and join, share, participate!

82 | June 2013 | www.elektor-magazine.com


Ordering Information

ORDERING INFORMATION TERMS OF BUSINESS


To order contact customer service:
Shipping Note: All orders will be shipped from Europe.
Phone: 860.289.0800 Please allow 3–4 weeks for delivery. Shipping and handling
Fax: 860.461.0450 via airmail: $20.00 per order.
Mail: Elektor US Returns
111 Founders Plaza, Suite 300 Damaged or miss-shipped goods may be returned for re-
East Hartford, CT 06108 placement or refund. All returns must have an RA #. Call or
email customer service to receive an RA# before returning
USA
the merchandise and be sure to put the RA# on the outside
E-mail: [email protected] of the package. Please save shipping materials for possible
On-line at www.elektor.com/store carrier inspection. Requests for RA# must be received 30
days from invoice.
Customer service hours: 8:30 AM-4:30 PM EST Monday-
Friday. Voice mail available at other times. When leaving a Patents
message please be sure to leave a daytime telephone num- Patent protection may exist with respect to circuits, devices,
ber where we can return your call. components, and items described in our books and maga-
zines. Elektor accepts no responsibility or liability for failing
PLEASE NOTE: While we strive to provide the best possible to identify such patent or other protection.
information in this issue, pricing and availability are subject Copyright
to change without notice. To find out about current pricing All drawing, photographs, articles, printed circuit boards,
and stock, please call or email customer service. programmed integrated circuits, diskettes, and software car-
riers published in our books and magazines (other than in
COMPONENTS third-party advertisements) are copyrighted and may not be
Components for projects appearing in Elektor are usually reproduced (or stored in any sort of retrieval system) without
available from certain advertisers in the magazine. If diffi- written permission from Elektor. Notwithstanding, printed
culties in obtaining components are suspected, a source will circuit boards may be produced for private and personal use
normally be identified in the article. Please note, however, without prior permission.
that the source(s) given is (are) not exclusive.
Limitation of liability
PAYMENT Elektor shall not be liable in contract, tort, or otherwise, for
Orders must be prepaid. We accept checks or money orders any loss or damage suffered by the purchaser whatsoever or
(in US $ drawn on a US bank only), VISA, Mastercard, howsoever arising out of, or in connection with, the supply of
Discover, and American Express credit cards. We do not goods or services by Elektor other than to supply goods as
accept C.O.D. orders. We also accept wire transfers. Add $20 described or, at the option of Elektor, to refund the purchaser
to cover fees charged for these transfers. any money paid with respect to the goods.

MEMBERSHIPS (US & CANADA ONLY)

Order memberships on-line at www.elektor.com/members

All memberships begin with the current issue. Expect 3–4 weeks for receipt of the first issue.
Membership renewals and change of address should be sent to:

Elektor US
P.O. Box 462228
Escondido, CA 92046

E-mail: [email protected]

Memberships may be paid for by check or money order (in US $ drawn on a US bank only). We accept Mastercard, VISA,
Discover and American Express credit cards.

For gift memberships, please include gift recipient’s name and address as well as your own, with remittance. A gift card will
be sent on request. Memberships may be cancelled at any time for a refund of all unmailed issues.

!
Does your membership expire soon?
Renew it on-line at www.elektor.com/members

www.elektor-magazine.com | June 2013 | 83


$25 off

You’ll have plenty of summer reading


with Circuit Cellar’s CC Gold issues archive.
A lifetime of electronics engineering projects, tips,
and analysis, packed onto a portable, USB flash
drive. Keep your archive current with a digital
subscription and download new issue PDFs directly
to the drive! Plus, with 32 GB of storage, there’s plenty
of room for your own notes and projects.
Offer ends 6/30/13

*Complete archive includes all issues in print through time of purchase.

Visit www.cc-webshop.com to purchase.

You might also like