You are on page 1of 88 April 2009 AUS$ 12.90 - NZ$ 15.50 - SAR 88.70 4.


electronics worldwide
... super computers ... fm stereo decoder ... c display ... led drivers spiced ... avr macros ...

explore car electronics

for model
internal combustion engines

The 32-bit Machine

develop & program
with our R32C starter kit R17
Automatic R
If you want to understand electron-
ics, you read Elektor, and if you
want to understand the electronics
market, you have to visit China.
Over the New Year, I was in Shen-
zhen for the testing of the new batch
of Elektor SMD ovens. If you really
want to know how the electronics
market is developing, not only in
China but also in the rest of the
world, theres no substitute for being
there, looking around, and talking to
the people.

Everything that the world has to offer

in the way of way of electronics is
available in Shenzhen, as well as
everything that China supplies to the
rest of the world. In our March issue,
our lab manager Antoine Authier
described his impressions during
a visit to this hotbed of electron-
ics, such as thousands of people
working and (literally) living amidst
boxes, stacks, and whole floors full

Come see us at
of electronic components and other
hardware. You can see the same
picture in the electronics high street
of Shanghai. Embedded Systems Conference Silicon Valley, San Jose USA,
However, the electronics market March 30April 3, 2009.
is more than just hardware and
components. To make a deal work,
especially in China, you need a
good knowledge of the culture,
banking matters, transportation,
and logistics. Doing business in
China takes a completely different
approach. It works well if you know
how to do it right, but otherwise you
shouldnt try. 34 Automotive CANtroller
The people who have joined us on
the China tours organised by Elektor
in the past years can say a thing
or two about this. In order to form
a realistic picture of the possibili-
ties, you have to see the factories
from the inside, shake hands with
the people there, and discover that
they share your fascination with the
electronics market. Things can go so
fast there that some of our tour par- This universal
ticipants managed to put together microcontroller
specific business deals during their board was
designed, in the first
Elektors next get acquainted tour instance, for use by students
to China is scheduled for the 3rd to studying automotive
the 11th of April. For more informa- technologies, but it can
tion, surf to also be used for other
. applications, of course.
The heart of this board is
Wisse Hettinga
International Editor an Atmel AT90CAN32
with a fast RISC core.
Volume 35
April 2009
no. 388

Running-in Bench projects

24 Automatic Running-in

While an electric motor can be used at full power 34 Automotive CANtroller
immediately it is brought into service, an internal
combustion engine needs a period of running in 46 The 32-bit Machine
before it is capable of delivering its maximum 52 C Display
power. The idea of the project described here is
55 FM Stereo Decoder
to automate this important operation.
58 Get a Grip on LED Drivers
62 Scoping with the ATM18
68 Rocket Engine Test Rig
72 Design Tips:
Macros for AVR programming
Protection for voltage regulators
Maybe soon, owning
a supercomputer at
home will no longer
be just a dream.
Indeed, inventive technology
solutions enabling a
wider public to have 20 Fully Automated
access to enormous
40 A Supercomputer
computing powers do
already exist on your Desk

40 A Supercomputer on your Desk

info & market
6 Colophon
8 Mailbox
10 News & New Products
18 okisec:
multiplayer online
46 The 32-bit Machine
33 See your project in print
73 New Annual DVD 2008
These pages will familiarise 80 Elektor SHOP
you with the tools required
for programming and 84 Coming Attractions
debugging the R32/C111
micro. Those of you already
familiar with the R8C/13
from Renesas will recognise
plenty of similarity in the
way all this is handled. 74 Hexadoku
76 Retronics:
An old radio
brought back to life
elektor electronics worldwide

elektor international media

Elektor International Media provides a multimedia and interactive platform for everyone interested in electronics.
From professionals passionate about their work to enthusiasts with professional ambitions.
From beginner to diehard, from student to lecturer. Information, education, inspiration and entertainment.
Analogue and digital; practical and theoretical; software and hardware.


Volume 35, Number 388, April 2009 ISSN 1757-0875 Elektor is also published in French, Spanish, German and Dutch. Together with franchised Editorial secretariat: Hedwig Hennekens (
editions the magazine is on circulation in more than 50 countries.
Elektor aims at inspiring people to master electronics at any personal level by Graphic design / DTP: Giel Dols, Mart Schroijen
presenting construction projects and spotting developments in electronics and
International Editor: Managing Director / Publisher: Paul Snakkers
information technology.
Wisse Hettinga (
Publishers: Elektor International Media, Regus Brentford, Marketing: Carlo van Nistelrooy
Editor: Jan Buiting (
1000 Great West Road, Brentford TW8 9HH, England. Tel. (+44) 208 261
4509, fax: (+44) 208 261 4447 International editorial staff: Harry Baggen, Thijs Beckers,
Eduardo Corral, Ernst Krempelsauer, Jens Nickel, Clemens Valens. Subscriptions: Elektor International Media,
The magazine is available from newsagents, bookshops and electronics retail Regus Brentford, 1000 Great West Road, Brentford TW8 9HH, England.
outlets, or on subscription. Design staff: Antoine Authier (Head), Ton Giesberts, Tel. (+44) 208 261 4509, fax: (+44) 208 261 4447
Elektor is published 11 times a year with a double issue for July & August. Luc Lemmens, Daniel Rodrigues, Jan Visser, Christian Vossen Internet:

 elektor - 4/2009
Visit China with Elektor
combine electronics
and culture
Elektors third Study Trip to China is planned for During this 9-day trip we will visit the China
Electronics Fair in Shenzhen, a professional
311 April 2009. And you can join us! Check
industrial electronics fair with an area of no
your diary today and visit the Elektor website for less than 60,000 m. We will also pay at
least one visit to the well-known electronics
more detailed information.
high street in Shanghai. As the name
suggests, this street is entirely dedicated to
electronics shops, each vying to be the
largest. In addition, a variety of interesting
company visits are on the itinerary (with a
tour of the production department). We are
also organising a business conference
where you can obtain a wealth of infor-
mation about doing business (and how not
to do business) in China. Naturally, theres
also time for culture. We will visit the Bund,
French Confession and the Shanghai TV
tower. Theres also a Shanghai sightseeing
tour planned.

Places are strictly

More info, programme and registration at
Email: Email: publication is stored in a retrieval system of any nature. Patent protection may ex-
Rates and terms are given on the Subscription Order Form. Internet: ist in respect of circuits, devices, components etc. described in this magazine. The
Advertising rates and terms available on request. Publisher does not accept responsibility for failing to identify such patent(s) or other
Head Office: Elektor International Media b.v. protection. The submission of designs or articles implies permission to the Publisher
P.O. Box 11 NL-6114-ZG Susteren The Netherlands to alter the text and design, and to use the contents in other Elektor International
Telephone: (+31) 46 4389444, Fax: (+31) 46 4370161 Copyright Notice Media publications and activities. The Publisher cannot guarantee to return any mate-
The circuits described in this magazine are for domestic use only. All drawings, photo-
rial submitted to them.
Distribution: Seymour, 2 East Poultry Street, London EC1A, England graphs, printed circuit board layouts, programmed integrated circuits, disks, CD-ROMs,
Telephone:+44 207 429 4073 software carriers and article texts published in our books and magazines (other than Disclaimer
third-party advertisements) are copyright Elektor International Media b.v. and may Prices and descriptions of publication-related items subject to change.
UK Advertising: Huson International Media, Cambridge House, not be reproduced or transmitted in any form or by any means, including photocopy- Errors and omissions excluded.
Gogmore Lane, Chertsey, Surrey KT16 9AP, England. ing, scanning an recording, in whole or in part without prior written permission from
Telephone: +44 1932 564999, Fax: +44 1932 564998 the Publisher. Such written permission must also be obtained before any part of this Elektor International Media b.v. 2009 Printed in the Netherlands

4/2009 - elektor 
info & market mailbox

A boxful of Dekatrons and the hunt for Trochotron

In response to the publication of our article The Dekatron decimal counter valve in
Elektor March 2008, Mr Roger Ellis of London, UK, kindly offered to send some of these
rare counter tubes to the author of the article, Mr Jean Herman in Belgium.
The shipment was arranged to go by way of Elektor and your Editor took the liberty
of photographing the contents of the
box for all readers to admire. Thanks
are due to both correspondents for
allowing us to publish about these rare
components dating back to the dawn of
digital electronics.
Apart from ZM1020 tubes and a dozen
unused sockets (originally intended for
the Belgian national railway Authority
SNCB), the box also contained an
interesting leaflet from a French compo-
nent distributor. It lists Decatron types
Z303C, Z502S, the E1T (also covered
in Retronics) and a device called Tro-
chotron ET51 which immediately aroused our curiosity. Can anyone help with further
information, aiming of course, at a short article for the Retronics section in Elektor? Does
anyone have real life specimens of Trochotrons lurking in a drawer or a lab cabinet?

Replacement type for when I worked as a designer brochure for this kit, which has US clock speaks German
BB112 500-pF varicap and member of the editorial a picture of a class with sev- Dear Editor I am a new
diode staff of Elektor (April1976 to eral students including Karel subscriber to Elektor USA and
Dear Editor an alternative July1979). and myself. I would like to find someone
to the BB112, which is no to help with a project. I was
longer readily available, is the To the best of my knowledge, However, the Games Com- particularity interested in
1SV149, which is compatible the picture of the little train at puter was not the first article the articles on the Tri-state
and has similar specifications. the top of page76 is one of involving microprocessors to Time and the Model Railway
The BB112 has a capacity my creations. It was a nice appear in Elektor. It was pre- Car Lighting Decoder in the
range of 20 to 500pF and is design ahead of its time ceded by a series of articles 2/2009 issue of Elektor.
mainly used in tuned circuits actually but I think it was on the SC/MP computer 30
for the low and medium a bit on the expensive side years ago now to which I
short-wave bands, such as the for the hobbyists of that time, also made a major contribu-
automatically tuned preselector especially the younger ones. tion. I dont know whether you
for the DRM receiver described have already mentioned it
in the November 2004 issue under this topic, since I dont
of Elektor Electronics. The see every issue of Elektor.
1SV149 is available from The If not, I hope it will appear
direct link is: www.ak-modul- sometime. I still have a pristine example of the SC/MP, the
ode_1sv149.html. first Elektor computer, which is
Burkhard Kainka available for taking photos if
(Germany) desired. I also have one of the
I maintained many contacts blue gramophone records for
with the technical specialists the SC/MP. It wasnt especially
at Philips at that time, and reliable, but it did work!
Games Computer in there may be someone on your Andr Pauptit (France)
Retronics editorial team who can still Back in the early 80s I worked
Dear Jan I would like to remember this. During those Its nice to hear from a former for Diehl Research Center in
comment on the Retronics days I attended a course on colleague, and its especially Stamford. I am now a retired
instalment on the Games the 2650 microprocessor at rewarding to be able to publish electronic engineer. This com-
Computer in the October Philips, along with one of my this in our Mailbox. As regards pany was part of Diehl GmbH
2008 issue of the magazine. co-workers, Karel Walraven. the SC/MP, I already described based in Nrnberg, Germany.
I found it especially interest- We used a 2650 development it Retronics, April2005; other- The director and I went to the
ing because it was one of my kit in the course, the Instructor wise I would be pleased to German Language School in
main jobs during the period 50. I still have the marketing accept your offer. Westport to learn German.

 elektor - 4/2009
I can understand more than 2003 by Dr. Gyora Benedek, proposal received. The author
speaking as my parents were Avi Olti, Shai Seger and of the Spinning Top project was
German. Robert Fuhrer. (US Pat. no. not aware of the inventor or his
We used a book called Deut- 7037169). Itop was and patent(s).
sch 2000 and on page 156 still is sold worldwide with a The US patent mentioned by Dr
they have Die Uhrzeit (the new model coming soon. The Benedek was awarded in 2006
Time of Day). At the time I was design presented in the article and has a very broad content.
working for a clock company looks like a perfect copy of our We were unable to find details
and said why not put this into product except for the double of practical circuit implementati-
digital format. I did make a row of LEDs. ons or indeed control software,
prototype which is still working Our group together and which, from our experience, is
to this day. This prototype is a separately invented and devel- the crux of the development. The
done the old fashioned way by oped several hit games such patent does however describe
wiring the hardware counters, as Lights Out (video game), the operating principle of a
CD4029s since they can count When SMD was young Hidato (, spinning top with a rotating LED
up and down. Dear Editor I have been an KenKen ( bar, as well as synchronization
enthusiastic reader of Elektor I hope you will find a way to by detection of a magnetic field
I would to make a new version for about 30 years and I correctly attribute this toy and (as an example, the earths mag-
using a microprocessor and eagerly await the new edition mention us in your next issue. netic field is mentioned) using
perhaps a VF display. I would every month. I have built a fair Dr Gyora Benedek (Israel) rotation data measuring means
like to find someone who number of your projects. I par- including an induction coil.
would like to do a program ticularly like the mix of unortho-
and help make this a joint dox ways to tackle problems,
project for Elektor. I could give circuit development and the
hardware support and the odd page of nostalgia.
other person could write the Prompted by your articles on
write a program and together the SMD Oven in the October
we could build a sample. 2008 issue Id like to add
My prototype has two digits a little something to the
for the minute, two digits for above theme: a photo-
the hours and four indicators copy of an article from
lights for the words nach, vor, Siemens Component
viertel, and halb, but this new Information, edition
version could be a 16-digit VF 1968, and an origi-
display. nal SMD integrated
circuit from the early
There could be a lot of poten- 1970s.
tial for this. As a learning tool I wish your team every
we could combine it with an success.
analog clock so the viertel Fritz Lackner (Germany)
vor, viertel nach, vor halb,
and nach halb fit in. I have Many thanks for responding
mine next to an analog clock. Fritz and for the rare example of Dr. Benedeks
Perhaps in a German class it an antediluvian SMD chip from email was copied to the Ger-
would be useful.
I have my prototype with LED
Siemens. It proves that the con-
cept of SMD is older than some
man author and editors respon-
sible for the Messaging Spin MailBox Terms
digits and HP light bars for readers complaining about the Top project. Publication of readers orrespondence
the words. A 16-digit vacuum technology being used in DIY is at the discretion of the Editor.
fluorescent display might be projects. In reply, they would certainly Viewpoints expressed by
nice, as the digits and words have mentioned Dr. Gyora correspondents are not necessarily
are all in line. Benedek, Avi Olti, Shai Seger, those of the Editor or Publisher.
Robert Fuhrer and the relevant Correspondence may be
I hope you can put me in touch LED Spinning Top patent(s) if such information had translated or edited for length, clarity
with a programmer who would Dear Editor I was very been available to them. When and style.
like this project. Maybe we can pleased to see the Messaging publishing contributions about When replying to Mailbox
get a company to produce it. spin Top article in the 2008 developments in electronics, a correspondence,
George Fischer (USA) December issue of Elektor (pp trade journal like Elektor has please quote Issue number.
16-21). no legal obligation to identify
Please send your MailBox
A cordial welcome to the Elektor However, when I read the arti- patent(s) or other protection
correspondence to:
experience, George and hope cle I was very disappointed to describing similar approaches
you continue to enjoy Elektors find out that the original inven- (see also the Copyright Notice or
new USA edition. tors of this striking gadget on page7). In practice, it is
Elektor, The Editor,
Anyone willing and able to help were not mentioned. impossible for the Elektor team
1000 Great West Road,
George, please contact the Please note that iTop was to do extensive patent research
Brentford TW8 9HH, England.
Editor. invented and patented in work for every circuit or article

4/2009 - elektor 
Peak: more distributors
Peak Electronic Design have has also come on board with Peak.
recently expanded their sales net- JPR Electronics Ltd in Dunstable
work with the appointment of five offer the full range of Peak prod-
new distribution partners. ucts as well as many other prod-
Now the famous Peak Atlas range ucts aimed at hobbyists, education
of automatic component identifi- and industry.
cation and measurement tools are To find your nearest distributor in
easier to get hold of in Australia, the UK or overseas, simply visit the
Holland, Germany, USA and the website below and click on the dis-
UK. This is in addition to a world- tributors tab. If you cant find a dis-
wide network of established dis- tributor near you then you can of
tributors, so buying Peak products course order from Peak directly.
is even faster and easier.
To assist with the UK hobbyist mar-
ket, a new UK distribution partner (081108-IX)

Montavista: Google Android support

MontaVista Software, Inc. recently Embedded Technology 2008 in handsets, MontaVista Linux: Semiconductor, Intel, Texas Instru-
announced that it will support Yokohama, Japan. is the only Linux to demonstrate ments and others
developers running MontaVista support of and integration with was awarded Best Software
Linux for use with the Google MontaVistas advanced power all major Linux mobile software Innovation of the Year for 2007
Android platform. The company management, fast startup, and stacks by EDN.
demonstrated the Android mobile advanced connectivity provide the is the only mobile Linux certified
platform running on a TI OMAP3 features mobile device manufac- as being ready for IPv6
processor, one of the processors tures require. In addition to pow- provides support for new mobile (081108-X)
supported by MontaVista Linux at ering a majority of todays Linux device processors from Freescale

16-bit micro draws 400 nano-amps

Maxim Integrated Products intro- ity of its life inactive, only waking power-saving operating modes. needs of the application, the inte-
duces the MAXQ2010, a 16- up once every few minutes to take A key feature of the device is grated LCD controller and real time
bit mixed-signal microcontrol- measurements. Typical examples its industry-leading stop mode, clock (RTC) can optionally remain
ler with a unique power-saving include many types of sensors, which allows the microcontroller active during stop mode.
stop mode. Stop mode reduces data acquisition systems, or envi- to reduce power consumption to
power consumption to 370nA ronmental data-loggers. less than 400nA (typ.) by halting For additional power savings,
typical and 6.5A maximum The MAXQ2010 offers multiple code execution. Depending on the the MAXQ2010 consumes only
at +85C, thus extending the 3.1mA (typical) at 10MHz oper-
life of battery-powered devices. ation in active mode.
Designed on a RISC architecture,
the MAXQ2010 balances high- The MAXQ2010 provides addi-
speed execution (up to 10 MIPS tional features critical for portable,
at 10MHz) and data sampling battery-powered applications. For
(up to 312ksps ADC conver- a user interface, an integrated LCD
sion at 12 bits) with a low-power controller can drive up to 160 seg-
active-mode current (3.1mA, typ- ments directly in a -muxed con-
ical, at 10MHz). An integrated figuration. A supply-voltage moni-
regulator allows direct operation tor measures the power supply
from a single lithium coin cell at against a programmable threshold
2.7V to 3.6V. from 2.7V to 3.5V in 0.1V incre-
ments, enabling an application to
With its many integrated analogue detect low power and notify the
and digital capabilities and its user to replace the battery.
multiple power-saving modes, the
MAXQ2010 is an optimised sin- For rapid application development,
gle-chip solution for battery-pow- a MAXQ2010 evaluation (EV) kit
ered data acquisition applications. is available.
The devices low-power stop mode
makes it especially valuable in
equipment that spends the major- (081028-VI)

10 elektor - 4/2009
Worlds smallest, high capacity, rechargeable thin battery
Planar Energy Devices that require compact geom- cations, the PowerPlane MX
announced their PowerPlane etry, mAh capacities can provide a solution that lasts
MX lithium ion battery. The bat- and longer term duty over 30 months in operation.
tery, available in a demo kit cycles. The battery, The PowerPlane MXE demo
which includes an on-board when integrated with kit will include a charge sta-
wireless RF harvesting/charg- Planars RF wireless tion pad and one PowerPlane
ing system, delivers the ultimate charging module MX mounted on a charging cir-
solution for applications that cuit board combining a planar
require self-sufficient milli-amp- antenna coil and charge/dis-
hour (mAh) energy storage. charge control circuitry. The sys-
Planar combines advanced bat- tems control circuitry provides
tery technology with integrated under/over voltage protection,
RF wireless charging technol- charge control, and a charge
ogy. The combined battery and indicator light. The charge
wireless charging system, called station pad can accommodate
the PowerPlane MXE, features more than five battery boards
charge circuitry that requires a simultaneously. The battery can
footprint only slightly larger than The battery has an operating volt- be trickled charged continuously
that of the battery, making the age range of 3 to 4.2V. Users of or entirely charged in under 3
entire power source extremely the PowerPlane MX can expect hours. The PowerPlane MXE
compact. over 500 full cycles. In a pulsed (PowerPlane MXE), is an ideal can be directly connected into
scenario, thousands of cycles can solution for wireless sensor sup- the required applications.
The PowerPlane MX battery be expected with negligible deg- pliers seeking power sources for
is the first rechargeable battery radation in the capacity. The Pow- systems or networks where con- The accompanying battery is
of its kind to host a high capac- erPlane MX has a proven 1 sec- stant maintenance is undesired. protected in a laminated pack-
ity within its thin form factor. ond pulse capability of up to 50 Similarly, active RFID tag suppliers aging, adding further to the rug-
With a capacity of 10 mAh in mA. The only power solutions in a find these attributes appealing for ged nature of the system. The
a 29250.5mm package, it thin, similar geometry and capac- applications in medicine, wander demo kit can be purchased for
is ideal for many applications ity available in the market today prevention, remote toll payment or $350 from Planars website.
seeking both power from a are primary cells. security that have service lifetimes
small form factor and long cycle The PowerPlane MX battery of over 1 year. Depending on the
life from its rechargeable nature. is ideal for many applications current-time schemes of the appli- (091069-II)

RoboThespian: lifelike movement from Festo-fluid muscles

recently been expanded to enable
higher levels of audience interac-
tion. The robots siblings are now
much in demand at science and
technology centres as animated
public orators, tireless front-of-
house presenters, and generally
all-round benevolent funsters.
The first generation of RoboThes-
pian robots was developed in Jan-
uary 2005, and the first interactive
RoboThespian was exhibited in
Los Angeles in November 2007.
The robots repertoire included
a series of song and dance rou-
tines, and for the first time, it could
respond to its audience vocally
and by reactive physical move-
Engineered Arts Ltd, a UK-based ment. This wowed the audience additional axis in each arm, and power-to-weight ratio and essen-
company which specialises in hi- but of course, after a while peo- feedback sensors on all movement tially consist of a flexible tube with
tech multi-media, has created an ple wanted even more, such as axes, with a total of 31 powered a mesh of reinforcing fibres. They
interactive robot named RoboThes- shaking hands with RoboThespian axes, each featuring full propor- contract when they filled with com-
pian capable of lifelike movement or having the robot perform their tional control. The robot contains pressed air and elongate when the
using Festo fluidic muscles. Initially own routines. six dc motors, but all its major air is removed.
developed to provide entertaining movements are controlled by Festo
theatrical performances, the life- The robot has now been upgraded DMSP fluidic muscles. These pneu-
sized robots capabilities have to include articulated hands, an matic actuators boast a very high (091069-III)

4/2009 - elektor 11
info & market news & new products

New Parallax sensor - infrared thermometer Module (10 FOV)

The new Parallax MLX90614 coprocessor over a digital SMBus, SIP module for-
Infrared Thermometer Module which Parallax has programmed mat fits easily in
(10 FOV) is an intelligent non- to simplify an otherwise fairly com- breadboards or
contact temperature sensor with plex communication protocol. through-hold proto-
a 10 degrees field of view and a Features: type areas
serial interface for easy connec- Outputs continuous data flow Multiple modules can defaults
tion to host microcontrollers. The with an active alarm running in be connected from a sin- 10 Field Of View
MLX90614 sensor is designed for background gle I/O processor pin for serial
non-contact temperature measure- 16-bit digital temperature out- data flow Parallax also carries the
ments of objects placed within the put data, ranging from 70C to Module can act as a stand alone MLX90614 Infrared Thermometer
sensors cone of detection. The sen- 380C sensor for alarm control Module with 90 FOV.
sor is comprised of an integrated Auto-baud detection (2400, Sleep setting for low power
ASIC and infrared sensitive ther- 4800, 9600, 19.2K, 38.4K) consumption
mopile detector. The sensor com- for microcontroller-to-MLX90614 Starts up active without pre-pro- (search: 28042, 28040)
municates with an SX20AC/SS-G communications gramming using preset writeable (091069-I)

HF SPECTRAN revision V4 claims 170 dBm world record

Aaronias SPECTRAN V4 plifier, switchable via a TRUE RF ory (128K) Further new features include:
RF spectrum analyser is by no switch (Option 020) improved IF filters PEAK/RMS detector, audio
means a revised Rev.3 SPEC- vastly improved dynamic range significantly increased demod- sniffer for detecting bugs /
TRAN, but a fully redeveloped thanks to a 14-bit Dual ADC ulator bandwidth, listening to wire taps, EMC filter (9kHz,
instrument which utilises the full significantly improved phase broadcast stations is no problem 120kHz etc.), enhanced limits
potential of Aaronias patented noise (jitter) thanks to a new anymore... display, new logger options,
spectrum analysis algorithm. improved and enhanced demod-
The V4 is claimed to surpass ulation modes and more.
even the most modern and most Pricing starts at 999.95 for
expensive handheld analyzers the HF-6060 V4 (10MHz
in terms of sensitivity not just 6GHz, 150dBm(1Hz), min.
by a few dB, but by leaps and RBW=10kHz) incl. HyperLOG
bounds (up to 20dB). 7060.
Compared to the Spectran HF- Options & accessories include
6060 Rev.3, the new HF-6060 a 0.5ppm TCXO time base, an
V4, HF-6080 V4 and HF-60100 internal ultra-low noise 15dB
V4 instruments deliver many pre amplifier, 1MB memory
improvements and new features, expansion, 10GHz peak power
depending on model: meter (3 versions). Further acces-
frequency range extended by sories are under development.
3.4GHz, up to 9.4GHz The new SPECTRAN V4 range
sensitivity increased by up 0.5ppm TXCO time true switched attenuator with comes with a 10 year warranty
to 80dB, down to 170dBm base developed specifically for improved IP3 (switchable in 0.5dB and the right to return the instru-
(1Hz) SPECTRAN (Option 002) steps) ment for up to 30 days after
vastly improved sample time, razor-sharp DDC hardware filter, improved LCD display with more purchase.
up to 100x faster, down to 1ms as used on the LF models room for markers among other
(new, super-fast PLL) much faster DSP (150MIPS) improvements
super low-noise 15dB pream- with significantly enhanced mem- faster battery charger (090169-IV

A New Intelligent 2.4 GHz Transceiver

mation, health- requirement of only 5 kBytes for a connection is interrupted.
care applica- node and 8 kBytes for a hub. The When operating with two AA bat-
tions, remote con- highly effective CYFi Star Network tery cells, the typical lifetime is 4
trols and wireless Protocol recognizes the optimal years due to the power saving pro-
sensor networks. data transfer rate and output power. tocol and technical parameters of
With its volt- In case of interruptions, it switches the transceiver.
age range from automatically from the highest data The associated demo kit no.
1.8V to 3.6V transfer rate of 1 Mbps in Gaussian CY3271 is from available from
the device is ide- Frequency Shift Keying to the safe Cypress online or authorised
The new low-cost 2.4 GHz trans- ally suited for battery powered sys- Direct Spread Spectrum transmis- distributors.
ceiver type CYRF7936 from tems. A special feature protocol sion method at 250 kbps. Output
Cypress Semiconductor Corp. is was developed based on the PSoC performance is increased to the
specially designed for home auto- microcontroller. It has a memory maximum +4dBm as soon as the (091069-V)

12 elektor - 4/2009
A fresh approach to edge lit acrylic signs
Edge lit acrylic signs have tra- Also, because the light Tape can and encapsu-
ditionally been illuminated with be fixed to all sides of the acrylic lated in a Hon-
bulky fluorescent tubes which lim- the light is contained within the eywell laminate.
ited their application and were sheet concentrating the effect and The products
expensive to run and maintain. not spilling out on the bottom and has no glass, no
Now with Light Tape you can pro- sides like the traditional methods gas, and no mer-
duce stunning edge lit acrylics and of illumination. cury/heavy met-
have the viewers asking where is Light Tape is available in a wide als and so is user
the light coming from? range of colours and widths go and environment
Light Tapes flexibility and ultra thin to. The products is not limited to f r i e n d l y, p r o -
profile mean it can be adhered to square or oblong panels ether, it viding 85-90%
the edges of an acrylic sign allow- can light circles, ovals and com- energy saving against other light Development kits for Light Tape
ing the Light Tape to flood the plex shapes just as easily. Light sources such as Neon and Cold enabling systems to be easily
acrylic sheet with light, any text, Tape is also becomingpopular Cathode. Light Tape uses 1watt developed, tried and tested are
logo or shape engraved into the as a source to edge light acrylic per meter at 25mm (1) wide, a now available.
surface of the acrylic is instantly shelves in retail stores. 100m length of 25mm wide Light
illuminated producing a stunning Light Tape is made up of metal rib- Tape only uses the same power as
effect. bon coated in Sylvania phosphor a 100w light bulb. (091069-VI)

mikroPascal PRO for AVR 2008

mikroElektronika have MikroPascal PRO for AVR
recently launched a new comes with plenty of prac-
PASCAL compiler for AVR tical examples and a com-
microcontrollers: mikroPas- prehensive documentation
cal PRO for AVR 2008. which allows a quick start
The IDE features project- in programming AVR. AVR
based design and supports hardware development
an impressive range of tools, that completely sup-
AVR microcontrollers. ports the mikroPascal PRO
for AVR 2008, are also
mikroPascal PRO for AVR available. A fully functional
2008 offers a set of librar- demonstration version (hex
ies which simplify the ini- output limited to 2k of pro-
tialisation and use of AVR gram words) is available
MCU and its modules. The on the mikroElektronika
libraries comprise ADC, web site.
CANSPI, Compact Flash, EEP- Media Card, OneWire, Port soft-UART, sound, SPI, SPI Ether-
ROM Librar y, Flash Memor y, Expander, PS/2, PWM, PWM net, TWI, UART, Button, Conver-
LCD, Manchester Code, Multi 16 bit, RS-485, soft-I2C, soft-SPI, sions, String, and more. (091069-VII)

LED lighting for largest commercial lighting market

Cree, Inc. announces to the Cree family of recessed els at only 0.5 to 0.75 watts per
the volume avail- LED fixtures and delivers the uni- square foot.
ability of the LR24, form, high light levels required
a 24-inch square, for offices, schools, hospitals and With an elegant 24-inch square
recessed LED lumi- retail environments while consum- form, the LR24 offers architects
naire. The LR24 ing less electricity than most linear and designers a modern lighting
delivers high-qual- fluorescents. aesthetic, freeing them from the
ity, energy-efficient design constraints of linear-fluores-
light for suspended- The LR24 features superior colour cent technology.
ceiling applica- rendering, with a colour-rendering
tions traditionally index (CRI) of 92 compared to he innovative lens is recessed
addressed by linear a CRI of 70 to 80 for fluorescents. above the ceiling reducing
fluorescents, also It is also dimmable to 5 percent glare and creating an attractive
known as lay-ins or with standard protocols provid- and comfortable environment.
troffers. ing additional design flexibility and
The LR24 is the further energy-saving potential.
newest addition The LR24 delivers high light lev- (091069-IX)

4/2009 - elektor 13
info & market news & new products

conga-ARkit, a reference platform for automation

congatec AG presents the conga- port. This makes the well-priced interfaces through standard con- application-oriented basis, comes
ARkit, a complete solution pack- conga-QA the ideal platform for nectors. Manufacturer-specific I/ pre-installed on a bootable USB
age for the implementation of PLC the majority of control and visuali- O components can then be flex- stick. This device uses hypervi-
functions. sor software to boot a Microsoft
This comprehensive package was Windows XP operating system
developed in conjunction with 3S- and a real-time capable OSADL
Smart Software Solutions GmbH, Linux. The system resources of
Real-Time Systems GmbH and the Qseven module are assigned
OSCAT (Open Source Commu- exclusively to each of the operat-
nity for Automation Technology). ing systems. These two subsystems
It addresses PLC manufacturers communicate with each other via a
and companies that intend to inte- virtual Ethernet port.
grate PLC functionality in their
applications. On the real-time side of things (the
OSADL Linux system), a CoDeSys
The conga-QA, a Qseven Com- SP is operated as the PLC runtime
puter-On-Module with the Intel system. The complete and real-time
Atom Processor Z530, was cho- capable virtualization means that
sen as the hardware basis. Due the PLC handler is entirely inde-
to its compact dimensions of just pendent of the Windows system.
77cm, this module can be easily Even a Windows Blue Screen of
integrated via top-hat rail housing. Death or a fatal application error
Additionally, it provides capable, zation tasks. ibly configured and controlled via cannot affect the reliability of the
future-oriented interfaces and can The kit includes a suitable evalu- Ethernet/Ethercat or another suit- control.
simultaneously run two separate ation carrier board to facilitate able field bus.
operating systems thanks to hyper- the use of the Qseven module. The software package, which
threading and virtualization sup- This provides access to all Qseven has been compiled on an entirely (091069-X)

MIAC industrial control

The Matrix Industrial Automotive operate off 12V or 24V. It has 8 surface using the 4 screw holes MIAC is a fully specified industrial
Controller (MIAC) is an industrial analogue or digital inputs, 4 high provided. controller suitable for a wide vari-
grade control unit which can be current relay outputs and 4 motor ety of system control applications
used to control a wide range of outputs. The MIAC is housed in automation, manufacturing, test,
different electronic systems. It has in an attrac- and control.
a number of applications in indus-
try and learning. The physical characteris-
MIAC is flexible and tics allow for mounting
expandable, easy to pro- on industry standard
gram with flowcharts, DIN top hat rails
C or Assembly code, or the device can be
and physically and mounted directly onto
electrically rugged. any surface. The input
output circuitry has
MIACs main features been developed
include: with industrial
control in mind,
Programmable from taking into account
USB the noisy electrical
Shipped with a free copy environments and
of Flowcode the rugged physical
Compatible with third party C and electrical require-
compilers ments of the shop floor. The flex-
8 digital or analogue inputs The ibility of the unit make it a useful
4 relay outputs, 4 motor outputs MIAC unit has addition to the industrial engineers
with speed control screw terminal connec- standard toolbox kit.
4 line LCD display and control tor inputs across the top and bot-
keys tive, rugged, tom of the unit, has several input MIAC is certified to DVE0631 and
Lab View and Visual Basic anthra- cite grey plastic mould- buttons for user control, and also EN50178/EN60068.
compatible ing. It has two physical mounting has a 4 line by 16 character
options: it can be mounted onto alphanumeric display on the top
MIAC is a fully specified industrial a 30mm top hat DIN rail, or it of the unit to display system status (091069-VIII)
electronic controller designed to can be mounted directly onto any and assist users.

14 elektor - 4/2009





$VVHPEOHG2UGHU&RGH$6 9GFP$ /'& 86% /'& 


OK. MP3 player

Now you need an ...

By Milan Rajic SmartMP3 module connected to

MikroElektronika - Software Department EasyPIC5 Development System

The adoption of the MP3 format caused a revolution in digital sound compression technology by enabling audio
files to become much smaller. If you want audio messages or music to be part of your project then you can easily
make it happen. You just need any standard MMC or SD memory card, a few chips and a little time...

Before we start, it is necessary to format over a small audio amplifier. Step 1: Initialization of the SPI module
the MMC card and save the sound1. Considering that MMC/SD cards use of the microcontroller.
mp3 file on it (the card should be for- sections of 512 bytes in size, a micro- Step 2: Initialization of the compilers
matted in FAT16, i.e. FAT format). controller with 512 byte RAM or more Mmc_FAT16 library, which
The quality of sound coded in MP3 is needed for the purpose of control- enables MP3 files to be read from
format depends on sampling rate and ling MP3 decoding process. We have MMC or SD cards.
bitrate. Similar to an audio CD, most chosen the PIC18F4520 with 1536 byte Step 3: Reading a part of the file.
MP3 files are sampled 44.1 kHz. The RAM. Step 4: Sending data to the MP3 decod-
MP3 files bitrate indicates the quality er buffer.
of the compressed audio compared to Software Step 5: If the end of the file is not
the original uncompressed one, i.e. its The program controlling the operation reached, jump to step 3.
fidelity. A bitrate of 64 kbit/s is suffi- of this device consists of five steps:
cient for speech reproduction, while it Testing
has to be 128 kbit/s or more for music It is recommended to start testing the
reproduction. In this example a music device operation with low bitrate and
file with a bitrate of 128 kbit/s is used. increase it gradually. The MP3 decod-
er buffer has a size of 2048 bytes. If the
Hardware buffer is loaded with a part of MP3 file
The sound contained in this file is coded with 128 kbit/s bitrate, it will contain
in the MP3 format so that an MP3 decod- twice the number of sound samples
er is needed for its decoding. In our ex- than when it is loaded with a part of
ample, the VS1011E chip is used for this file with 256 kbit/s bitrate. According-
purpose. This chip decodes MP3 records ly, if the bitrate of the file is lower it will
and performs digital-to-analog conver- take twice as long to encode the buf-
Figure 1. Block diagram of Smart MP3 module fer content. If we overdo the bitrate of
sion of the signal in order to produce a connected to a PIC 18F4520
signal that can be fed to audio speakers the file it may happen that buffer con-

Advertising article by MikroElektronika

mikroC and mikroC PRO are registered trademarks of MikroElektronika. All rights reserved.

Schematic 1. Connecting the Smart MP3 module to a PIC18F4520 Example 1: Program to demonstrate operation of Smart MP3 module
char filename[14] = sound1.mp3; // Set File name
tent is encoded before the microcontroller can manage to read the next unsigned long i, file_size;
const BUFFER_SIZE = 512;
part of the file from the card and write it in the buffer, which will cause char
data_buffer_32[32], BufferLarge[BUFFER_SIZE];
Mmc_Chip_Select at RC0_bit;
the sound to be discontinuous. If this happens, we can reduce the MP3 sbit Mmc_Chip_Select_Direction at TRISC0_bit;
// Writes one byte to MP3 SDI
void SW_SPI_Write(unsigned data_) {
files bitrate or use a quartz-crystal 8MHz or more. Refer to Schematic 1. RD1_bit = 1; // Set BSYNC before sending the first bit
RD2_bit = 0; RD3_bit = data_; RD2_bit = 1; data_ >>= 1; // Send data_ LSB, data_.0
Anyway, you dont have to worry about this as our program has been RD2_bit = 0; RD3_bit = data_; RD2_bit = 1; data_ >>= 1;
RD1_bit = 0;
// Send data_.1
// Clear BSYNC after sending the second bit
tested on several microcontroller families with different crystal values RD2_bit = 0; RD3_bit = data_; RD2_bit = 1; data_ >>= 1;
RD2_bit = 0; RD3_bit = data_; RD2_bit = 1; data_ >>= 1;
// Send data_.2
// Send data_.3
and it is capable of decoding MP3 files of average and high quality. On RD2_bit = 0; RD3_bit = data_; RD2_bit = 1; data_ >>= 1;
RD2_bit = 0; RD3_bit = data_; RD2_bit = 1; data_ >>= 1;
// Send data_.4
// Send data_.5
the other hand, a low bitrate means that buffer decoder is filled with RD2_bit = 0; RD3_bit = data_; RD2_bit = 1; data_ >>= 1;
RD2_bit = 0; RD3_bit = data_; RD2_bit = 1; data_ >>= 1;
// Send data_.6
// Send data_.7
sound of longer duration. It may happen that the decoder doesnt de- }
RD2_bit = 0;
// Writes one word to MP3 SCI
code the buffer content before we try to reload it. In order to avoid this, void MP3_SCI_Write(char address, unsigned int data_in) {
RC1_bit = 0; // select MP3 SCI
it is necessary to make sure that the decoder is ready to receive a new SPI1_Write(0x02);
// send WRITE command

data before it has been sent. In other words, it is necessary to wait until SPI1_Write(data_in >> 8);
// Send High byte
// Send Low byte
decoders data request signal (DREQ) is set to logic one (1). RC1_bit = 1;
// deselect MP3 SCI
// Required, see VS1001k datasheet chapter 5.4.1
// Reads words_count words from MP3 SCI
Enhancements void MP3_SCI_Read(char start_address, char words_count, unsigned int *data_buffer) {
unsigned int temp;
RC1_bit = 0; // select MP3 SCI
This example may also be extended after being tested. The DREQ sig- SPI1_Write(0x03); // send READ command
nal can be periodically tested. A routine for volume control or built-in while (words_count--) { // read words_count words byte per byte
temp = SPI1_Read(0);
Bass/Treble enhancer control etc. may be incorporated in the program temp <<= 8;
temp += SPI1_Read(0);
as well. The MMC library enables you to select a file with a different *(data_buffer++) = temp;
name. In this way it is possible to create a set of MP3 messages, sounds RC1_bit = 1;
// deselect MP3 SCI
// Required, see VS1001k datasheet chapter 5.4.1
or songs to be used in other applications and send appropriate MP3 }
// Write one byte to MP3 SDI
files to the decoder depending on the needs. void MP3_SDI_Write(char data_) {
while (RD0_bit == 0) ; // wait until DREQ becomes 1
Below is a list of ready to use functions contained in the Mmc_FAT16 // Write 32 bytes to MP3 SDI
void MP3_SDI_Write_32(char *data_) {
Library. This library is integrated in mikroC PRO for PIC compiler. char i;
while (RD0_bit == 0) ; // wait until DREQ becomes 1
for (i=0; i<32; i++) SW_SPI_Write(data_[i]);
// Set clock
void Set_Clock(unsigned int clock_khz, char doubler) {
clock_khz /= 2; // calculate value
if (doubler) clock_khz |= 0x8000;
MP3_SCI_Write(0x03, clock_khz); // Write value to CLOCKF register
Mmc_Fat_Append() Write at the end of the le }
void Init() {
Mmc_Fat_Assign()* Assign le for FAT operations ADCON1 |= 0x0F; // set all AN pins to digital
RD2_bit = 0; RD3_bit = 0; // Clear SW SPI SCK and SDO
Mmc_Fat_Delete() Delete le TRISD2_bit = 0; TRISD3_bit = 0; // Set SW SPI pin directions
RC1_bit = 1; // Deselect MP3_CS
Mmc_Fat_Get_File_Date() Get le date and time TRISC1_bit = 0; // Configure MP3_CS as output
Mmc_Fat_Get_File_Size() Get le size RC2_bit = 1; // Set MP3_RST pin
TRISC2_bit = 0; // Configure MP3_RST as output
Mmc_Fat_Get_Swap_File() Create a swap le TRISD0_bit = 1; // Configure DREQ as input
RD1_bit = 0; // Clear BSYNC
Mmc_Fat_Init()* Init card for FAT operations TRISD1_bit = 0; // Configure BSYNC as output
Mmc_Fat_QuickFormat() // Software Reset
Mmc_Fat_Read()* Read data from le void Soft_Reset() {
MP3_SCI_Write(0x00,0x0204); // Write to MODE register: set SM_RESET bit and SM_BITORD bit
Mmc_Fat_Reset()* Open le for reading Delay_us(2); // Required, see VS1001k datasheet chapter 7.4
while (RD0_bit == 0) ; // wait until DREQ becomes 1
Mmc_Fat_Rewrite() Open le for writing for (i=0; i<2048; i++) MP3_SDI_Write(0); // feed 2048 zeros to the MP3 SDI bus:
Mmc_Fat_Set_File_Date() Set le date and time void main() { // main function
Mmc_Fat_Write() Write data to le Init();
Spi_Rd_Ptr = SPI1_Read;
Set_Clock(25000,0); // Set clock to 25MHz, do not use clock doubler
* Mmc_FAT16 functions used in program Soft_Reset(); // SW Reset
if (Mmc_Fat_Init() == 0) {
if (Mmc_Fat_Assign(&filename, 0) ) { // Assign file sound1.mp3
Mmc_Fat_Reset(&file_size); // Call Reset before file reading
while (file_size > BUFFER_SIZE) { // Send file blocks to MP3 SDI
Other mikroC for PIC functions used in program: for (i=0; i<BUFFER_SIZE; i++)
Mmc_Fat_Read(BufferLarge + i);
// Read file block
for (i=0; i<BUFFER_SIZE/32; i++) // Send file block to mp3 decoder r
Spi_Init_Advanced() Initialize microcontroller SPI module MP3_SDI_Write_32(BufferLarge + i*32); pile
file_size -= BUFFER_SIZE; // Decrease file size com

i n
} tten
for (i=0; i<file_size; i++) // Send the rest of the file
Code for this example written for PIC microcontrollers in C, Basic and Pascal as
Mmc_Fat_Read(BufferLarge + i);
for (i=0; i<file_size; i++)
m i k
for P
well as the programs written for dsPIC and AVR microcontrollers can be found }
on our web site: }

Microchip, logo and combinations thereof, PIC and others are registered trademarks or trademarks of Microchip Corporation or its subsidiaries.
Other terms and product names may be trademarks of other companies.
info & market robotics

okisec: multiplayer online robohockey

For manoeuvring around on
the hockey field, the speed and
direction of the motor on each
wheel is controlled individually.
This setup gives an easy control
of the robots movements and,
at the same time, is efficient and
easy to implement. The robot
has a small turning radius and
its top speed is only dependent
on the maximum drive power of
the motors.

As opposed to other robots built

with a static hockey stick, each
okisec robot has a (remote) con-
trolled stick to allow it to drive
the ball in front of it. Actuation
is by means of a servo motor so
the player can shoot easily.
The hockey field (Figure3)
is made of a resistant canvas
that can be shaped to an extent
thanks to its texture. The field
dimensions are 2.40 1.38m
(8 4.6ft) with 3cm (1.2inch)
high sides.
Each robot has three servo
motors, one actuating the stick;
Micael S. Couceiro, Carlos M. Figueiredo, the other two for motion. The
J. Miguel Luz, N. M. Fonseca Ferreira (Portugal) two drive motors have been modified without too much trouble to act as
common DC motors.
Here we report briefly on a project for real-time robot hockey played A clear advantage of the use of a microcontroller is to be able to detect
over the Internet, developed at isec, the Higher Institute for Engineering malfunctions easily. Also, allowing for their characteristics, sensors or
of Coimbra. other actuators are easy to connect up without much work because all
Each robot player has a height of about 30cm (10 inch) (including the in/out pins of the PIC18F2580 microcontroller are enabled.
antenna) and a maximum width of 20cm (7.8 inch). Figure1 shows the The communication circuit receives information from the okisec games
team players being charged up for the game. The model was designed server through 433MHz (ISM band) radio control or RS-232 (serial)
using AutoCAD (Figure2). The overall weight of the structure is a pri- by flipping a local switch. The control information received over the
mary concern to ensure a long battery life. The power source for all air does not require any kind of hardware conversion or adaption, the
electronics and actuators is carried on-board and to comply with com- receiver module being directly connected to the PIC.
petition rules, no external power may be used. The entire robot weighs For the battery, the designers went for a Graupner 9.6V, 1.5Ah type;
1.12kg (2.5lbs). for servos the HS-311 from HITEC was used.
The hockey playing robot has two wheels, each one connected with the
help of two gears and a drive belt to a separate servo motor acting as The user interface for online hockey playing was written in Delphi. The
an electric DC motor. PIC firmware for the robot was coded in C. The user interface is divided

1 2

18 elektor - 4/2009
ality requires an HTTP server that can be made with Apache. The other
one is optimized for Web communications and based on an ActiveX
controller for video transmission. The disadvantage of the latter is that it
requires additional software to enable fast video acquisition to be per-
formed by an ActiveX controller.

The additional software used was Active Webcam that provides utilities
and functions for video transmission over Internet for ActiveX controllers,
applets and others. The web software can also be used in the internal
LAN but the need to have ActiveX plug-ins installed on the central server
is reason enough to have one piece of software implemented just for
LAN connected players and another for web connected players. The
frame rate of the video stream will depend on the remote players ISP
connection and other conditions but can reach up to six frames per sec-
ond. The webpage was made in HTML, JavaScript and CSS (Cascade
Style Sheets).

in client and server software. The client part comprises separate timers
Internet Links
for various functions like keyboard or gamepad reading, refreshing of Robotic application for multiplayer online game:
the video frame acquired by the server and sending information over
TCP about the robots movement. The server software comprises an inter- 2008_paper2.pdf
rupt structure to receive each clients data through TCP, an algorithm to Youtube movie:
adapt data from all clients, and a timer to send information over radio
to all robots. Authors websites:
Two types of video transmission are incorporated. The first was created
for the internal LAN to get video frames using HTTP commands, mainly to
provide independency of video and data communications. This function-

4/2009 - elektor 19
technology automation


Process control with PLCs

R.A. Hulsebos (The Netherlands)

Mass production is an important part of our modern society. Every production process
involves actions that are repeated innumerable times, and these actions are often controlled
by PLCs. What exactly are PLCs, and how are they used?

Programmable logic controllers (PLCs) are the workhorses NIOS, and so on. Although PLCs are industrial equipment
of industrial automation. Originally developed as software instead of consumer products, there is considerable price
simulations of relay control circuits, PLCs have developed pressure, so suppliers devote a lot of attention to cost-effi-
into a platform that forms the basis for control applica- cient development.
tions generated using structured programming languages Some suppliers take a different approach. They start with
(IEC61131), including high-speed motion, machine vision, a PC, install a PLC OS, add some I/O, and the result is a
networking, and integration with databases and logistics PLC. This is called a software PLC. The difference between
systems. this and a real PLC is that it also has all the capabilities of
a normal PC. However, from a hardware perspective a PC
From an electronics perspective, a PLC is simply a pro- is not entirely the same as a real PLC. Some of the specific
cessor with memory, I/O channels (digital, analogue, and/ features are discussed below.
or serial), some counters and logic circuitry, and a network
interface. What transforms this into a PLC is the PLC oper-
ating system (OS). Using a programming package running Fast up and running
on a PC, programmers generate PLC application software A PLC must operate all the time, 24/7. If a PLC fails, the
to control machines and production lines. result is usually dramatic: production grinds to a halt. In
most companies, the maintenance department has only one
The electronic configuration of a PLC varies from one sup- priority when this happens: getting production up and run-
plier to the next. A wide variety of processor types can ning again. If power cycling (off/on) doesnt help, the PLC
be used for the processing function, such as ARM, X86, is replaced by a spare unit. It must be possible to install and

20 elektor - 4/2009
connect this unit quickly.
Software installation is often a tricky problem in this situ-
ation. It is increasingly common practice for controllers to
fetch their software from a central server. However, central
servers are not always available, so some suppliers use
memory sticks instead. Memory sticks resemble USB sticks,
but they are different. An example of a memory stick is the
C-Plug (Figure1) for the Siemens S7 family of PLCs. A
memory sticks holds all the required software and configura-
tion data, and it can simply be unplugged from the old PLC
and plugged into the new one. This technique is also being
used more and more often with peripheral equipment.
A problem with Ethernet is that the new controller has a new
MAC address, since the Ethernet standard requires every
device in the world to have a unique MAC address. This
creates difficulties in an industrial environment, because the
Ethernet network address depends on the MAC address. In
a network environment, this means that the new controller
is invisible until the other network devices have been con-
figured to use the new MAC address. Naturally, this is very Figure 1.
inconvenient in an industrial environment. For this reason, A Siemens C-Plug with a
many suppliers allow customers to configure the controllers capacity of 32MB. Source:
with their own MAC addresses. This increases flexibility, Siemens
but it also creates responsibility: since every MAC address
must remain unique worldwide, the old controller must never
again be used with its original MAC address. lems due to software errors. If a controller fails due to a bug
in its application software, theres little point in switching to
another one, since the other processor has the same soft-
No more battery backup ware with the same bug. There is only one way to avoid
PLCs rarely have hard-disk drives. In the first place, hard this problem, which is to develop all software redundantly
disk drives are far too expensive, and the vast majority of using teams that are not allowed to communicate with each
their storage capacity would remain unused. The moving other. The idea here is that the two versions of the software
parts of hard disk drives also make them too vulnerable, will have completely different designs, so it is unlikely that
and they are very sensitive to hard shocks and strong vibra- the same conceptual error, and thus the same bug in the
tions. As a result of rapid technological evolution, hard same routine, will be present both versions. This approach
disks are quickly replaced by newer models with even more is used in the control systems of Airbus aircraft, among
capacity. other examples.

Most PLCs need only a few megabytes of memory, and until

a few years ago many of them used static RAM (SRAM) Windows
for this. However, static RAM requires a battery, and bat- The enormous popularity of Windows makes it a natural
teries have a limited operating life. The situation changed candidate for use as the internal operating system of con-
with the advent of flash memory, which is now more or trollers. This is entirely hidden from users because the PLCs
less standard for program code storage. However, it is not control application completely conceals the OS. Microsoft
always practical for data storage because it does not sup- provides two products for this purpose: WindowsCE6 and
port write transactions for individual bytes. Ferromagnetic WindowsXPEmbedded (XPe). Windows CE is primarily
RAM (FRAM) is much more suitable for this purpose. intended for embedded applications, such as small PLCs. It
has a very low licence fee (a few pounds) and can run on
all sorts of processors. XPEmbedded is more suitable for rel-
Its always possible for an application program to hang
or the underlying core routines to stop working. In order
to prevent the entire system or machine from coming to a
halt when this happens, a watchdog is always present. A
watchdog is nothing more than a simple timer that resets
the processor if it times out, which causes the controller to
execute a restart. The watchdog is reset periodically by the
application code or a core routine, so it never times out
under normal conditions.

Dual processors are used in applications where controller

failure is intolerable. One of the processors is the active
or hot processor, while the other one is the standby pro- Figure 2.
cessor. Both processors execute the same code and receive A DiskOnChip flash disk
the same input data, but only the hot processor drives the with wear levelling, which
outputs. If the hot processor fails, the standby processor can can be plugged directly
seamlessly take over control. into an IDE connector.
Naturally, dual processors cannot eliminate the risk of prob- Source: Coresolid Storage

4/2009 - elektor 21
technology automation

transactions. For this reason, Microsoft has an option for

XPe called Embedded Write Filter (EWF), which stores
disk transactions in RAM. The disk appears entirely normal
to the application software, but all changes are lost when
XPe restarts. For many applications, this does not pose a
serious problem. In fact, it can be an advantage to always
start with a clean slate.

For applications where EWF is too restrictive, flash disks

that spread write transactions over the entire disk must be
used. This is called wear levelling, and it is available from
a variety of suppliers. One example is DiskOnModule from
Coresolid Storage, which can be fitted directly to an IDE
Figure 3. connector (Figure2). Even if an application constantly
A Siemens ERTEC 200 writes data to a disk of this sort, wear levelling provides an
processor with a built-in acceptable service life. Windows sees a DiskOnModule as
ARM processor and two a normal hard disk, and no special driver is necessary.
Ethernet interfaces. If you wish, you can experiment with XPEmbedded free of
Source: Siemens charge. All of the software can be downloaded from the
Microsoft website, and applications will run for 90days
without a licence.
atively large PLCs with networking capability, video, image
processing and data handling capability, but it requires a
more powerful processor (500MHz minimum) and more Copy exactly
memory (at least 256MB of RAM), and it is much more Some industries demand copy exactly from their suppliers.
expensive (around 100 / $145 per licence). On the other This means that a controller that they buy today must be
hand, with XPe you can do everything you can do with a exactly the same as one they bought several years ago. In
normal PC, because XPe is essentially the same as XPPro- this way, customers are not repeatedly confronted with new
fessional. The only difference is that you can choose which controllers that require the installation of different software
parts to leave out, which yields major savings in storage or make it necessary to revise drawings, modify connect-
space: an XPe installation can fit into 100MB. Up until a ing cables, rewrite documentation, and so on. There are
few years ago, this was ideal for working with flash disks, also companies that put together a production line in one
although their capacity has increased enormously in recent country and then want to copy it in other countries, so that
years to the point that a few megabytes more or less are the same product can be made everywhere in the world in
no longer a major issue. the same way.
Naturally, copy exactly places heavy demands on logis-
However, flash memory suffers from the limitation of a finite tics chains. It prevents the use of components with short
number of write cycles per sector. For example, many flash market lives, which is a frequent phenomenon in the PC
chips can only be written 1million times. This is too little world. Industrial PCs also suffer from this phenomenon. If
for WindowsXP, especially in areas of the file system that you want to avoid it, you must explicitly look for a PC sup-
are written very often, such as folders and the Registry. plier that can guarantee long-term deliverability. As this is
The NTFS file system is also very active source of write requested relatively often by industrial customers, there are

Figure 4.
Developers kit for the
Digi/ME controller. The
controller is fitted in the
middle of the PCB.
Source: Digi

22 elektor - 4/2009
in fact suppliers (such as Advantech) that can do so. Intel This requires special Ethernet interfaces. The idea here is to
can also provide long-term delivery guarantees for some execute the entire Ethernet protocol in hardware so that it is
processors, including Celeron. very fast and real-time (deterministic).
If you want long-term deliverability, youre looking in the Siemens supplies an ARM-based ERTEC-400 controller (Fig-
wrong place if you constantly focus on the leading edge of ure3) for its ProfiNet protocol, and Beckhoff supplies spe-
industrial PCs. Instead, you should be thinking in terms of a cial ASICs for its Ethernet protocol. This makes it possible to
500-MHz Intel Celeron processor. Although this may sound drive Ethernet I/O directly without processor involvement.
rather archaic, it isnt. Many industrial applications do not The author managed to do this at a frequency of 30kHz
require especially high processing power, and 500MHz is using a standard desktop PC. There is ongoing develop-
already more than enough for such applications. Another ment activity in the Ethernet world, and gigabit industrial
helpful factor is that industrial IT programmers are often Ethernet is expected to be available fairly soon.
used to working with controllers that have limited resources.
This is quite different from the situation in business IT, where
nobody thinks twice about another gigahertz or an extra USB
gigabyte. Due to the popularity of USB on PCs, this interface is also
being used more and more in industrial applications. Much
longer distances than the usual 5metres can be bridged by
Networks using USB extenders. This means that keyboards and mice
A modern PLC is equipped with suitable interfaces, includ- can be located much further away than usual, which makes
ing network interfaces. This naturally includes Ethernet, it considerably easier to install a PC (or an industrial PC) in
which makes it very easy to use a PC to download program a system. USB is hardly used for I/O. With its short cable
code and correct bugs in the software. Ethernet can also be
used for quick, inexpensive linking to a supervisory control
and data acquisition (SCADA) system. Operators can use a
SCADA system to run the machine or system, check the cur-
rent status, enter production orders, collect statistical data,
and analyse error messages.

Many PLCs also have an RS232 interface, although this

interface is being used less and less often. RS422 and
RS485 are also quite common because they can be used
over much longer distances (up to 1200metres). In top-end
units, these interfaces always have galvanic isolation with
short-circuit protection. This is often missing in inexpensive
controllers, or they may only be able to withstand a one-
second short circuit. As it is very easy to cause a short cir-
cuit, especially with 9-way D-Sub connectors, inexpensive Figure 5.
controllers often turn out to be a costly choice. On top of A Lantronix XPort/AR
this, you will be faced with a failed controller, and thus pos- controller, which is scarcely
sibly a production shutdown. if the short circuit causes the larger than an RJ45 plug.
transceiver to fail. Source: Lantronix.

In addition to the RSxxx interfaces, there are all sorts of

fieldbus interfaces available. The fieldbus market is highly lengths and star topology, it is not a good fit with typical
fragmented, with more than 500 different bus systems. A industrial applications. However, it is used in instrumenta-
few of them are very well known, such as Profibus, CANbus tion systems, such as with Matlab or Labview.
and ASInterface, but there are also many systems with only
a small market share. As each system has not only its own
cabling and connectors but also its own range of products, No PLC
including I/O modules, motor controllers, dampers, valves, Despite the popularity of PLCs, there are a fair number of
serial interfaces, repeaters (amplifiers) and so on, the mar- automation specialists that prefer not to not use them. Lim-
ket can be regarded as highly fragmented. Consequently, ited memory capacity, the low-level programming languages
before you buy a PLC you must carefully consider which specified by IEC61131 (which among other things do not
fieldbus you want to use and whether all of the necessary support object-oriented programming), and strict encapsu-
functionality is actually available for it. lation in typical application architectures make them unsuit-
able for use as high-end machine controllers. Instead of
PLCs, such applications employ several small embedded
Ethernet controllers linked to an industrial PC by a network. In this
A trend toward using only Ethernet instead of the hundreds arrangement, the non-real-time portions of the application
of different fieldbus systems has developed in recent years. are executed on the PC. Two examples of small embedded
As certain adjustments are made to make this interface controllers are the XPort from Lantronix and the Digi/ME
suitable for control applications, it is also referred to as from Digi (Figures4 and 5). Actually, these devices are
industrial Ethernet. small only with respect to their dimensions (the size of an
Two different philosophies can be seen here. Some com- RJ45 connector) and their prices (a few dozen pounds);
panies use the TCP/IP protocol as much as possible with they both have a powerful processor, lots of memory, ample
standard Ethernet, while other companies want to use Eth- I/O, and networking capabilities. They also come with a
ernet in high-speed motion control systems to drive as many (hard) real-time kernel. Program code can be downloaded
motors (servos) as possible and run them as fast as possible. via the Ethernet interface or the JTAG port.

4/2009 - elektor 23
projects modelling

Automatic Running-
for internal combustion model engines
Part 1: the hardware

Michel Kuenemann (France)

Even though brushless electric motors have largely

replaced internal combustion engines in small- and
medium-sized radio-controlled model aircraft, many model
enthusiasts are still attached to internal combustion (i/c) engines.
But while an electric motor can be used at full power
immediately it is brought into service, an i/c engine needs
a period of running in before it is capable of delivering its
maximum power. The idea of the project described here is to automate
this important operation.

ers recommendations, and individual

Technical specifications habits. The key parameters to be man-
aged are:
32-bit ARM7 processor running at 59MHz, 128kB flash memory
and 64kB RAM.
Engine speed
Throttle control by standard model servo. Configurable travel
and direction of movement.
Engine temperature
Richness of the air/fuel mixture
Microcontroller-driven glow plug heating.
Engine speed measurement from 0 to over 30,000rpm.
Traditionally, the speed is controlled
Engine temperature measurement from 0160C.
by using the throttle, often operated
Ambient temperature measurement by hand when running-in on a test
Mixture adjustment managed by the on-board software. bench. The engine speed is monitored
Mobile pocket terminal with 4-line/ 20character alphanumeric LCD display, using a hand-held rev counter, or just
push buttons and encoder knob. by ear. The engine temperature is often
USB link monitored by feel and the richness of
Direct Servo Control (DSC) interface the mixture adjusted by hand. Under
Emergency stop push button these conditions, the running-in opera-
Power supply: 715Vdc. tion is performed 100% manually with
little objective feedback about how the
process is progressing.
A miniature i/c engine can be run in tion and deceleration. These alternat- The idea of the board described here
either in the model it is destined for, ing high and low speeds cause con- is to offer automation and repeatabil-
or on a test bench dedicated to this trolled wear (particularly of the pis- ity in this phase, by managing the
purpose. ton and cylinder wall) that enables an main parameters of the running-in
Running-in consists of running the accurate fit to be achieved between
engine, loaded with a propeller of suit- these components. The way these
able pitch and diameter, and putting it cycles are achieved depends on the
through controlled cycles of accelera- engine specifications, the manufactur- Figure 1. Running-in bench block diagram.

24 elektor - 4/2009
-in Bench 10


automatically. thrust, the power supplied, fuel curves, Block diagram
The board also offers or torque and power curves. The board
extended possibil- can also be helpful for adjusting the The block diagram of the running-in
ities for testing needle-valve level (acceleration). bench is given in Figure1. At the heart
and adjusting i/c of the system is a 32-bit microcontrol-
engines (already run in) The software and the functions of this ler board which manages the engine
or electric motors for which project will be described in detail in and gathers the engine parameters
we want to measure, estimate, Part 2 of our article to be published required for the running-in.
or compare characteristics like static next month. The throttle is operated by way of

temperature ambient temperature emergency

sensor stop

temperature engine temperature DSC

sensor (direct servo control)
glow plug heating

throttle control
run-in board
portable terminal

stepper speed optical
motor sensor
engine to run in

float valve/needle control

portable PC

power supply

080253 - 11

4/2009 - elektor 25
projects modelling

Table 1.
obligatory these days, lets you pro-
Microcontroller specifications and resources used for the application. gram the board, control it, and read off
the recorded data.
Resource Specification Notes The bench has a DSC (Direct Servo
Control) interface, which lets you con-
ARM7-TDMI, 32-bit central RISC-type central unit, one instruction per nect a remote-control transmitter and
Central unit
unit. clock pulse. control the servo by means of the throt-
Clock 60MHz
Clock frequency used in the application: tle control. This is also how you access
58.9824MHz the functions associated with optimis-
RAM 64kB ing the fuel curve.
Flash memory 128kB
Provision has been made for an emer-
Used for programming and communication gency stop button in order to stop the
UART0 16C551 compatible
with a PC
engine quickly in the event of an criti-
UART1 16C551 compatible
Available on expansion connector Multi- cal problem.
plexed, with PWM generation
SPI Available on expansion connector With these facilities; the board lets you
IC #2 Up to 400kbps Available on expansion connector
control the running-in of all types of 2-
or 4-stroke, single- or multi-cylinder
Used for the pocket terminal and tempera- i/c engines, running on methanol or
bit bang IC Up to 400kbps ture detector. Expandable.
petrol, with glow or spark (electronic)
3 connectors available ignition.
I/O port 3 ports available on expansion connector
Block diagram of main board
a standard servo. The engine speed ambient temperatures. The board, the block diagram for which
reached is measured using an opti- A pocket terminal comprising an LCD is given in Figure2, is designed around
cal detector. The board also man- display, a coding button, a few push- a microcontroller that may already be
ages the heating of the glow-plug buttons and a sounder, to let you con- familiar to Elektor readers, the LPC2106
and adjusts the mixture needle via a trol the running-in bench without need- from NXP. This 32-bit processor using
stepper motor. To complete the task, ing a computer. RISC ARM7 architecture has ideal char-
the board monitors the engine and The USB link (full speed @ 12Mbps), acteristics for this project (see Table1).
Since the LPC2106 is only available in a
0.5mm (0.02) pitch SMD package, we
thought it advisable to use a module
user interface that readers will be able to buy ready-
on board
made, in this case, the ARMee board
I/O port run described in our April and May 2005
power supply regulator LED issues[1][2].
I/O port
On the left of Figure2 we find the sys-
JTAG probe Reset tem interfaces and the interfaces with
reset SW
PWM and the engine to be run in.
throttle supply
servo The board works correctly with a
data capture OFF switch power supply from 715V. So the board
engine signal input
speed can be powered from a mains adaptor,
sensor conditioning
ARMee a car cigar lighter, or a 7-cell NiCd,
microcontroller board NiMH or even 2S or 3S lithium polymer
engine (LPC2106) Servo
temperature battery, which modelling enthusiasts
sensor analogue/digital I2C bus Control
converter will be familiar with.
temperature Rx
sensor Tx USB/Serial PC The throttle servo is controlled quite
interface (USB) conventionally by way of a PWM sig-
mixture Driver
I/O port nal. Naturally, the board supplies the
control power for the servo, and the connector
I2C bus,
glow interrupt signal used is the same type as is found on
plug and 5V supply portable all radio-control receivers. Hence the
I/O port
MOSFET terminal
glow throttle control can use any standard
supply SPI, UART1,
off-the-shelf model servo.
The engine speed detector comprises a
extension phototransistor and an LED. The signal
connectors 080253 - 12 from the phototransistor is processed
before being fed to one of the micro-
Figure 2. Running-in bench driver board block diagram. controllers data capture inputs.

26 elektor - 4/2009
As the microcontroller doesnt have Circuit diagram of main board 1.8V for the microcontroller core), all
any analogue inputs, it was necessary the microcontrollers unused I/O pins
to make provision for an external ana- Its only a small step from the block (including an SPI bus, a UART, a PWM
logue/digital convertor for inputting diagram to the real circuit diagram generation port and two I/O ports) and
the temperature data. A type with an of the controller board (Figure3). The the #1 IC bus with interrupt.
IC interface was chosen. large number of connectors and pro-
tection components make the circuit The #1 IC bus is a bit bang type, i.e.
The single-pole stepper motor plus pretty impressive, but its still rela- the pulse trains required by the IC
gearbox for adjusting the mixture is tively easy to pick out the elements protocol are generated in software by
governed by an open-collector driver, of the block diagram. Pride of place the driver. This has the advantage of
controlled in turn by four of the micro- right in the middle of the circuit goes being able to convert any pair of the
controllers I/O port lines. to the ARMee module fitted with an microcontrollers ports into an IC bus.

Glow-plug heating is taken care of LPC2106/01 microcontroller and a However, this type of bus represents a
by a power MOSFET, driven again 14.7456MHz crystal. Do note that not inconsiderable load on the micro-
from one of the microcontrollers I/O these components are different from controller if the bus is used intensively,
port lines. the ones on the board described in and even more so if we want to use the
2005 [1][2]. If you want to use the 2005 bus in slave mode.
On the right of the board block dia- board, all you have to do is change the To get round these drawbacks, we
gram we find a few LEDs that tell you original crystal. The ARMee module is operate the #1 IC port in master mode
the status of the board, a few jumpers, powered from 5V only, as the 1.8V and only, and weve added an interrupt
a reset button, the USB port and the 3.3V rails required by the core and the signal (INT0) to this bus so as to avoid
DSC interface. inputs/outputs respectively are gener- scanning the push buttons and coder
ated on the ARMee board itself. The in the pocket terminal. This reduces
A pocket terminal 3.3V supplied by the ARMee board the transactions on the IC bus to the
for controlling the board is con- is used (sparingly) by certain compo- strict minimum.
nected to the main board via a 6-way nents on the main board.
cable with RJ11 connectors. This To finish, it may be noted that this
cable carries a 400kbps IC bus, an A 20-pin expansion connector (K3), interface includes one active device
interrupt signal, and the power for the unused for the moment, carries all the (IC3), a PCA9517A . This device serves
terminal (5V). boards supply voltages (except the three functions:

4/2009 - elektor 27
+3V3 +5V

SDA1A K1_1 Y1 K2_1 P0.14

P0.3/SDA P0.14
P0.4/SCK/CAP0.1 K1_2 K2_2 INT0
R1 R2 R3 R4 JP3 P0.4/SCK P0.15
P0.5/MISO/MAT0.1 K1_3 K2_3 SDA0A D1 C1 C2
P0.5/MISO P0.16
P0.6/MOSI/CAP0.2 K1_4 K2_4 P0.17/TRST


P0.6/MOSI P0.17/TRST 47u
RTCK K1_5 K2_5 P0.18/TMS R5 1N5822 100n
RTCK P0.18/TMS P0.25 16V
DBG K1_6 K2_6 P0.19/TCK 10k
P0.7/SSEL K1_7 K2_7 P0.20/TDI

K1 P0.7/SSEL P0.20/TDI GND
DBG P0.8/TXD1/PWM4 K1_8 K2_8 P0.21/TDO
P0.8/TXD1 P0.21/TDO 19 4

2 1 P0.9/RXD1/PWM6 K1_9 K2_9 RST RESET VCCIO
P0.9/RXD1 RST 17
4 3 P0.17/TRST K1_10 K2_10 P0.27 3V3OUT
GND VSS P0.27 P0.1/RXD0 1
6 5 P0.20/TDI P0.22 K1_11 K2_11 P0.28 TXD 28 K2
P0.22 P0.28 P0.0/TXD0 5 OSCO
8 7 P0.18/TMS P0.23 K1_12 K2_12 P0.29 RXD IC1 27

P0.23 P0.29 3 OSCI 1

10 9 P0.19/TCK P0.24 K1_13 K2_13 P0.0/TXD0 RTS
P0.24 P0.0/TXD0 11 16 2
12 11 RTCK P0.10 K1_14 K2_14 P0.1/RXD0 +3V3 CTS USBDM
P0.10 P0.1/RXD0 2 15 3
14 13 P0.21/TDO P0.11/CTS1/CAP1.1 K1_15 K2_15 P0.30 DTR USBDP
P0.11 P0.30 R7 JP1 JP2 6 4
16 15 RST P0.12/DSR1/MAT1.0 K1_16 K2_16 P0.31 RI 23
P0.12 P0.31 9 CBUS0
18 17 P0.25 K1_17 K2_17 SCL1A DSR 22

P0.25 P0.2/SCL 10 CBUS1
20 19 P0.26 K1_18 K2_18 DCD FT232RL 13
K3 P0.26 +5V +5V CBUS2
K1_19 K2_19 PROG. 14
+3V3 +3V3 +3V3 +3V3 P0.14 ENABLE CBUS3 USB-B
JTAG 1 2 P0.4/SCK/CAP0.1 SCL0A K1_20 K2_20 26 12
GND P0.13 LPC2106/01 VSS TEST CBUS4 R6
3 4 P0.5/MISO/MAT0.1 C4 C3 C5
X = 14.7456 MHz


GND 5 6 P0.6/MOSI/CAP0.2 +3V3 +3V3 +3V3 +5V


7 8 P0.8/TXD1/PWM4 100n 100n 3V9 100n
9 10 P0.9/RXD1/PWM6 D3 C12 C13 C11
11 12 P0.12/DSR1/MAT1.0 red
13 14 P0.26 RUN 100n 100n 100n

15 16 P0.27 R10 GND GND GND +3V3
17 18 SCL0B D12

VHV 1N5822
19 20 SDA0B
C7 C9 C8 C10 R9

100n 100n 47u 100n P0.23
VHV LM2940CT-5.0 +5V 100n
16V INT0 K12

3 D11
1 1 3 IC2 GND
+3V3 CONF. RST 3 4
1N5822 LM3724-3V08
LM3724-3V08 K4

S1 2


GND C22 C23 C24 C25 C26 1 RESET



470u 100n 100n 47u 47u
P0.11/CTS1/CAP1.1 25V 16V 10V JP12
T5 green GND
R49 R11
K20 2k2 P0.7/SSEL
1 220R
BC547B 3
2 2
D5 1 +3V3 VHV VGP
DSC C14 C15
3V9 47u 100n R25
GND +5V 16V D15
R36 R37 R42 R43

C33 R40 red GLOW PLUG




220u IRL3502 T1
16V R41 R27 SPBF
T3 2 5
R38 R39 1k
1 7 P0.10

1k 5k6 IC7A IC7B K13

RPM 3 6 T2
K18 K19 D14
3 3 BC557A T4 P0.24
2 2 IC7 = TLC272 +5V 9V1 (1V5 ... 2V)
1 1 BC547B
T6 R45 C35
D20 BC547B
R46 100n D4 R44 R47
8 C34


QED222 IC7

BPW96C 4 100n


elektor - 4/2009
adapting the voltage swing of the

080253 - 14
microcontroller (3.3V) to the levels

of the external bus (5V);


offering a protective barrier against


onslaughts from the outside

SCL1B world;



buffering the signals from the micro-


controller, thereby making it possible


to get round the 400pF limit speci-

fied for the IC bus.

A number of 100 series resistors, in


association with 5.6V zener diodes,

round off the protection for this bus.

K21 K22

SCL1B The jumpers (JP5JP8) let you power

or not the peripherals connected

to the three connector K6, K7, and







22R EN

The pocket terminal can be connected

+3V3 +5V



to either K6 or K7, it doesnt matter

IC Bus 2

IC8 OUT2 17







K10 makes it possible to connect an



expansion board using HE-10 connec-


tors, far more practical than RJ11 con-



nectors when the board is hand-wired


on 2.54mm (0.1) breadboard. This

connector supplies a 5V rail, along




with the unregulated board supply




(via JP8).








The #2 IC bus is connected to the

microcontrollers official IC periph-

eral, with master and slave modes,
and is capable of a maximum speed


of 400kbps. From a hardware point




of view, it is just like the #1 IC bus,



14 6

except without the interrupt signal


100n 47u



and HE-10 connector. Given the pos-




sibilities, this bus offers for expand-


3V9 100n

ing the system, weve opted to keep it



free and make do with just the #1 IC



bus. Readers may leave out IC4 and its


associated components.
3V9 100n

IC Bus 1


The 12Mbps full-speed USB inter-




face is achieved using a device that




may already be familiar to Elektor

3V9 100n



readers, the FT232RL from FTDI, con-



nected directly to the microcontrollers


UART0 interface. Diode D1 allows the


boards power to be derived from the







USB bus. This is particularly useful

during programming or when recover-




ing the data stored on the board when




no other power source is available. In




5k6 5k6



+3V3 +5V

normal operation, powering the board





from the USB bus is not recommended,



as this power source is not powerful




enough. Port P0.25 makes it possible to








Figure 3. Circuit diagram of main board.



4/2009 - elektor 29
projects modelling

detect if the USB bus is connected and as little as 7V, which means the board the subject of the project Rev counter
active. Jumpers JP1 and JP2 work in can be powered from a battery of dual- for models [4]. The optical detector,
tandem: if they are fitted, the program- element lithium polymer accumulators, a phototransistor, works by reflection
ming mode is active. In this mode, it delivering a nominal voltage of 7.4V. and should be positioned a few cen-
is possible to easily and quickly load Diode D11 protects the circuit against timetres from the propeller. The LED
new software into the microcontroller possible reverse polarity. The VHV volt- built into the detector provides a lit-
through the intermediary of the (free) age is tapped off at the regulator input tle local light source. Depending on
flashing by NXP [3] (see box). Without and used to power the stepper motor the ambient lighting, the conduction of
these jumpers, the USB link operates (see below). this device varies considerably, and it
as a simplified conventional serial link, is impossible to detect the movement
but with a markedly higher transmis- The engine and external ambient of the propeller unless the process-
sion speed (3Mbps maximum). temperature measurements are made ing stage allows for these variations.
using KTY81-210 linear two-terminal To do this, operational amplifier IC7A
Management of the microcontrollers detectors in TO-92 packages. These holds the voltage at the emitter of T4
reset is entrusted to a specialized detectors, whose active element is at an average value of 1.4V, which
device, the LM3724 from National Sem- made of silicon, have the advantage of sets the phototransistors operating
iconductor. This ensures correct start- exhibiting a virtually linear variation in point and compensates for the varia-

up when the their resistance. Biasing resistors R28 tions in ambient lighting. If the volt-
board is pow- and R34 linearise their values over a age at the emitter of T4 falls, the con-
ered up and huge temperature range. Since the duction of T3 increases, which causes
allows addi- microcontroller doesnt have any ana- the voltage on the detector terminals
tional reset push-buttons to be added; logue inputs, it was necessary to resort to increase, and hence likewise on the
a feature that we have made use of, to an external convertor. The convertor emitter of T4, as it is connected as a
since the board has two reset buttons chosen for this task is an AD7417 from follower. The low-pass filter formed by
(one on the board, the other external Analog Devices (IC6). This convertor, R39 and C33 slows down this control
one connected via K4). with four 10-bit inputs, and connected loop to avoid the short pulses associ-
to the #1 IC bus, has an internal 2.5V ated with the movement of the propel-
The throttle servo is controlled by the reference. The device has an internal ler in front of the detector moving the
microcontrollers P0.7/SSEL/PWM2 temperature detector that provides operating point. These pulses, present
output. R11 and D5 protect this pin in the device temperature which is at the emitter of T4, are picked off by a
the event of an external voltage being also the prevailing ambient tempera- high-pass filter C35/R47 which elimi-
injected onto the control line. The ture around the board. This convertor nates the 1.4V DC component and any
servo is powered from the boards 5V is kind enough to return this tempera- slow voltage variations. IC7B, wired
rail or via a jumper (JP12). This jumper ture directly in degrees Celsius, with- as a comparator, looks after shaping
lets you choose not to power the servo out needing any scaling or calibration. these analogue pulses to make them
socket, so as to avoid an external volt- The interrupt line to which the conver- microcontroller-compatible.
age being injected. This can occur if tor is connected makes it possible to
the user connects an electric motor warn of any possible overheating. The A logic-controlled power MOS transis-
speed controller with a BEC (Battery remaining two inputs are used to mon- tor has the job of controlling the heat-
Eliminator Circuit) function to this itor the supply voltages to the board ing of the glow plug. The transistor
output. In this way, either a servo or a (VHV) and the glow plug (VGP). gate is biased with the board input
speed controller with BEC can be con- voltage in order to take advantage of
nected to this output. The engine speed detector is one of the its high value. However, zener diode
Powering of the board is entrusted to key elements of the circuit. The signal D14 prevents this voltage reaching
a low voltage drop linear regulator. processing circuit for this detector was 10V, the maximum gate voltage. When
Thus the board works correctly from designed by Paul Goossens and was heating of the glow plug is activated,

30 elektor - 4/2009
a red LED lights to warn the user. The
power source for the glow plug can be
either a NiMH cell (1.2V), a lead-acid
cell (2 V), or the glow plug heating out-
4 x 20
put of a model power panel.


The Direct Servo Control (DSC) input


is particularly simple, as a single NPN

transistor is all it takes to interface P1
C2 C3
with the microcontroller. The resistor
values in the circuit have been tested 100n 47u
using a Graupner MX16s transmitter. If
your transmitter is a different type, you
may need to adjust some values. C1
100n R2
The stepper motor driver output allows GND


you to drive a stepper motor with gear-

+5V 8

box with a rated voltage of 5V or 12V. K1 18
7 T1
The values of resistors R54 and R55 1
2 13 5
may need adjusting, depending on the 3 12
4 +5V
motor youre using. If youre not plan- SCL IC1 GPB3 ZMX61
4 20 3
ning to use a stepper motor in your 5 19
6 1 +5V C4
application, these four open-collector D1 D2 D3
outputs can be put to other uses, such GPA0
21 S5
as driving lamps, LEDs, DC motors, or 5V6 5V6 5V6 GPA1
23 D E
relays. GPA2
17 25 A B
+5V A2 GPA4
16 26
Pocket terminal 15
The electrical circuit of the pocket ter- JP1 JP2 JP3 GPA7

minal (Figure4) is very simple, thanks

2 2 2 S1 S2 S3 S4

to the high level of integration in the

devices used. The heart of this board is

an MCP23017 port expander with IC 080253 - 15

bus from Microchip, which provides no GND

fewer than 16 I/Os, ideal for producing

a handy user interface.
Figure 4. Circuit diagram of pocket terminal.
The 6-way RJ11 input connector pro-
vides the MCP23017 with power, the
IC bus, and an interrupt signal. The
IC is protected from electrostatic dis- Pushbuttons S1S4, along with the Building the pocket terminal board
charge and over-voltage by three zener pushbutton on S5, employ the same is quick and easy and doesnt call for
diodes (D1D3). type of event-driven processing. No any special remarks. Depending on the
pull-up resistors are needed, as they type of display youve chosen, it may
The MCP23017s three address select are built into the MCP23017. be necessary to adjust the value of R2
lines have been connected to the same And lastly, the terminals sounder to suit the backlight current for it. At
number of jumpers, which means you is controlled by a P-channel MOS the end of building, fit the three jump-
can select the terminals bus address. transistor. ers JP1JP3 in the 5 check position.
The alphanumeric display is interfaced
in 4-bit mode and it takes up the whole
of the MCP23017s portB.
Construction Testing the boards
To make building the boards easier, Testing takes place in four steps:
Incremental encoder S5 gives the user weve chosen traditional through-hole
the impression of an analogue control, components wherever possible. Start Power up for the first time to check
arguably much more ergonomic than by soldering the SMD devices IC1 supply rails;
a pair of +/ buttons when youre IC6, IC8, and T1. Take care not to over- Fit the ARMee module and flash-in
driving a servo. The MCP23017 has heat them, and to remove any shorts the test firmware;
an interrupt-on-change mode, which between pins using desoldering braid Operating test of the main controller
means that a change of state on any once soldering is finished. Then fit the board (CBRM);
of its 16pins generates an interrupt. through-hole components and end Operating test of the pocket termi-
Hence the incremental coder doesnt with the connectors. Check the orienta- nal (GMMI)
have to be scanned: the software will tion carefully for all the polarised com-
only launch a read cycle on the IC ponents like the ICs, electrolytic and Powering up for the first time
bus after receiving such an interrupt, tantalum capacitors, and diodes. The Do not connect any peripherals to
which reduces the load on the bus to ARMee module is fitted with the help the board connectors, remove all the
a strict minimum. of the boards component overlay. jumpers and the ARMee module, then

4/2009 - elektor 31
projects modelling

Firmware flashing procedure

First install the free LPC2000 Flash Utility from NXP [3] on your
Power up the controller board and connect it to the PC via a USB
cable. Check that the operating system has correctly recognised the
new USB serial port. If the number assigned to the port is higher than
COM5, change it.
Start LPC2000 Flash Utility In Connected To Port, select the COM
port to be used and select a speed of 115,200baud. Check the Use
DTR/RTS for Reset and Boot Loader Selection box.
In the box Device:, select the LPC2106 and enter the value 14745 in
the XTAL Freq. [kHz]: box.
On the controller board, fit jumpers JP1 and JP2 and remove jumper Figure 5. How to configure the LPC2000 Flash Utility programming utility.
Click the Read Device ID button. The Part IDand Boot Loader ID
should get filled in. If not, go back through the procedure step by step JTAG
it is vital to get through this stage successfully, otherwise it wont be If you have a JTAG probe, youll be able to program the microcontrol-
possible to program the controller. ler after connecting your probe to K1 (Keil Ulink compatible connec-
Use the button alongside the Filename box to select the .hex file to tor) and fitting JP3. Dont forget to remove JP3 afterwards. If JP3 is
load into the controller. Click the Upload to Flash button and wait for fitted while the JTAG probe is disconnected, the program will work,
the operation to finish. but ports P0.22 and P0.31 will remain in Embedded Trace Macrocell
(ETM) mode and so wont be accessible to the program.
Exit the tool to free up the serial port and remove jumpers JP1 and
All this seems very long-winded, but as the software saves the selected This will mean that the RUN LED, the user jumper, the glow plug
options, flashing is very quick after the first time. drive, USB status reading, and the stepper motor driver wont work.

power the board up from a bench sup- to the box for this operation. Once the Term Pro[5] freeware on your PC.
ply set to 8V/ 200mA. The current board has been programmed, unplug Connect the board to one of the USB
consumption should not exceed 70mA. the USB cable and check that there are ports on your PC. The green power
The green power LED should light, and no jumpers fitted. Power the board up LED should light and the red RUN
you should check with a multimeter again. The current consumption should LED should flash. Run TeraTerm and
the value of the 5V supply to pin 3 now settle at around 100mA. Pressing in the Setup -> Serial port menu, con-
of IC5, which must be between 4.9V the reset button causes the current to figure the port to which the board is
and 5.1V. If all is well at this stage, drop to around 60mA. The red RUN connected as follows:
move on to the next; if not, check once LED should be flashing regularly. Now
again for solder bridges or reversed disconnect the power. Baud rate: 115200
components. Data: 8bits
Testing the main CRBM board Parity: none
Now lets add the ARMee board If not already there, install the Tera- Stop: 1bit
The next step is going to consist of Flow control: none
powering down the board and fitting
the ARMee module, taking care not to Close the configuration window and
get it the wrong way round. Check that press the Escape key on the PC key-
it is correctly fitted with a 14.7456MHz board in order to get the screen in
crystal. If not, it is vital to change it Figure6.
before proceeding. Power the board
up again and check the presence of Select the parts to be tested in turn by
the 3.3V rail on pin1 of IC3. The cur- pressing the corresponding letter on
rent consumption should remain under the PC keyboard. The software is self-
70mA if the microcontroller has never documented and explains what should
been programmed or while the reset be happening with the hardware as
button is pressed. Thats the hardest each element is tested. An oscilloscope
part over! and multimeter are required.
Now we need to test that all the stages For the time being, dont activate the
on the board are working correctly and tests for the GMMI board (pocket
check that the microcontroller is able to terminal).
communicate with the outside world.
To do this, the microcontroller needs Testing the pocket terminal (GMMI)
to be flashed with the CBRMtest.hex Unplug the USB cable and power the
software, available by download. Refer Opening screen for CBRMtst_v200.hex. CBRM board up again using the bench

32 elektor - 4/2009
supply set to 8 V / 500 mA. Fit jumper
JP8 and connect a ribbon cable fitted A few words about
with 6/6 RJ11 connectors to K7 and the
GMMI board. The current consump-
the author
tion should not increase significantly. A graduate from the National Institute of
Adjust the contrast pot P1 until lit- Applied Sciences at Lyon, France, Michel
tle dark rectangles appear on lines 1 Kuenemann has been an independent
and 3 of the display. Check that the electronics consultant for about 20 years.
three jumpers JP1JP3 are in the 5 V Michel currently works on electrical supply
position. Connect the board to the PC systems for a large transport aircraft and
again under TeraTerm and now run the enjoys building much smaller ones in his
tests devoted to the GMMI board and spare time.
follow the instructions. It will prob-
ably be necessary to adjust the con-
trast and possibly R2 which sets the
backlight current. References and com/024111.

Internet Links [5] TeraTerm:

The rest [1] LPC210x ARMee Development Board (1),
Elektor Electronics March 2005. Online: www.
You now have a powerful 32-bit ARM7
microcontroller board and a handy
[2] LPC210x ARMee Development Board (2),
data entry terminal. In Part 2 of this
Elektor Electronics April 2005. Online: www. Note: in view of the length of
article, well be looking in detail at the components list, this is being
how to connect the board to its detec- offered as a free download from
tor and actuators, together with the [3] LPC2000 Flash Utility:
products/microcontrollers/support/software_ the website for this article [6]. That
application software for this project. way, you can download it at the
In the meantime, good luck with the same time as the software youll
construction! [4] Rev counter for R/C Models, Elektor Elec-
need to make the board work.
tronics November 2003. Online: www.elektor.


See your project in print!

Elektor magazine is looking for
Technical Authors/Design Engineers
If you have
D an innovative or original project youd like to share with Elektors 140 k+
readership and the electronics community
D above average skills in designing electronic circuits
D experience in writing electronics-related software
D basic skills in complementing your hardware or software with explanatory text
D a PC, email and Internet access for efficient communications with Elektors
centrally located team of editors and technicians
then dont hesitate to contact us for exciting opportunities to get your project or feature article published.
Our Author Guidelines are at:

Jan Buiting MA, Editor
Regus Brentford, 1000 Great West Road, Brentford TW8 9HH, United Kingdom

4/2009 - elektor 33
projects automotive electronics

Automotive CANtrol
Car electronics exposed
Chris Vossen (Elektor Labs) and Ep Gernaat (Timloto, The Netherlands)

This universal microcontroller board was designed, in the first instance, for use by
students studying automotive technologies, but it can also be used for other applica-
tions, of course. The heart of this board is an Atmel AT90CAN32 with a fast RISC core.

Since cars contain an ever increas-

Technical Specifications ing amount of electronics, students
learning about motor vehicle tech-
Microcontroller: Atmel AT90CAN32 nology also need to know more
Fast RISC -architecture with 133 instructions about electronics and microcontrol-
Clock speed: 12MHz lers. In collaboration with the Timloto
32KB flash, 2KB RAM and 1KB EEPROM available o.s. Foundation in the Netherlands,
53 programmable I/O lines Elektor designed a special controller
Integrated CAN2.0 controller
PCB, which will be used in schools
8-channel 10-bit A/D converter
in several countries for teaching stu-
SPI interface
dents about automotive technologies.
JTAG interface
Particular attention was paid to issues
Two-Wire interface such as universal design, cost, con-
8 DIP switches and 8 LEDs available for experimental applications nection options, expandability and the
Power supply: 5V availability of free development soft-
ware for various platforms.

Cars and electronics The TIM working group evolved into the Timloto o.s. foundation, a wor-
king group of teachers which sets itself the purpose of closely monito-
About 20 years ago, teachers of the subject of motor vehicle techno- ring the technical developments in cars and make these available as
logy introduced the topic of microcontrollers into the curriculum of teaching resources to other teachers and students as soon as possible
automotive technicians. In those days they used a teaching kit that was and at no cost. New times, new opportunities: the Timloto website with
based on the Z80, which was appropriately named the Microprofessor. open-source licence became a fact. See
This kit has been used intensively for at least 10 years, at the higher In the meantime the CAN bus became common and car computers
grades of technician training and teachers united in the TIM working started receiving Flash memory upgrades while the cars were being
group (TIM = Technical Informatics Motor Vehicles) have made many serviced. Again there was a call for a new(er) controller and this time
automotive applications over the years. the editors at Elektor were approached for advice. The choice for the
Atmel AT90CAN32 was quite quickly made because of its reasona-
ble purchase price, the many features and the programmability under
However, at some stage a real automotive microcontroller was selec- Windows and Linux (Ubuntu). Thanks to the ingenuity of the Elektor
ted, the Motorola 68HC11, which at that time was frequently used in designers all the requirements from the Timloto specifications could be
various automotive computers. The educational programs which were met. The demands were considerable. Because Timloto works together
originally developed for the Z80 were ported across and expanded. An with another automotive teachers initiative (the GoforAfrica founda-
engineering consultant developed a 68HC11 controller board based tion) it also had to be possible to use the controller in technical schools
on the specifications from the TIM group. One of the prerequisites was in Senegal and Gambia. The computers there run the Ubuntu opera-
that the already developed Z80 hardware applications could be used ting system so that a Linux development environment was an absolute
again. A textbook was written and the teachers were given further trai- requirement.
ning. Even now the 68HC11 is still used successfully as an educational
controller within the context of motor vehicle technology. Costs also play an important role. The approach was to keep the cost
of the controller board as low as possible so that it could be added to

34 elektor - 4/2009

A significant amount of teaching has 32KB of Flash memory and 2KB The AT90CAN32 is available in both
material is already available, which of RAM. An EEPROM of size 1KB is 64-pin TQFP and QFN packages. For
is freely available to anyone via the also available. In addition to a 10-bit this design we choose the TQFP
Timloto website. You can therefore A/D-converter with eight channels, version. This package type has all
also use this project at home. But the the controller also has multiple timers, the pins accessible around the out-
design of this circuit is so universal an SPI interface and two USARTS (one side edge of the package, which
that it will also be excellent for all of which is used as the programming makes it much easier to solder by
kinds of other home, or should we say, interface). hand.
garage, projects.
There is also a TWI interface and a Finally we would like to mention that
CAN2.0 controller. The latter makes this controller is completely com-
Choice of microcontroller this controller eminently suitable for patible with its bigger siblings the
When searching for a suitable micro- applications in an automotive environ- AT90CAN64 and AT90CAN128. For a
controller we soon arrived at the ment. The core of this controller has a detailed description of all its features
AT90CAN32 made by Atmel. This con- RISC architecture with an instruction (such as the TWI) we refer you to the
troller is packed with many features. It set consisting of 133 instructions. datasheet [1].

the book list of the automotive science stu- In the spring and autumn Timloto will or-
dents and in this way each student also has ganise training courses for automotive
the opportunity to practise in his or her own technology teachers in Gambia, Senegal
time. The switches in particular were a hurdle and the Netherlands to show them the
initially. Eight toggle switches would increase educational use of the AT90CAN32. Tim-
the price of the design considerably. A clever loto aspires to international cooperation
Elektor solution was found by using a sepa- between all (automotive) technical educa-
rate expansion board for use in class, which tion and would like to see as many people
contains the switches. The module is plugged as possible supporting this Elektor-Tim-
into the expansion board. In this way, during loto project. Help is required to translate
classes at school the robust switches on the programs (comments and questions) into
expansion board are available. English and French. Program ideas and
Using the first Elektor prototypes, members new applications are also very welcome.
of the Timloto working group could translate Consideration can also be made to use the
the first (educational) 68HC11 programs into C programming language instead of as-
AT90CAN32 assembly language. For this sembly language.
purpose, use was made of AVR Studio 4 and
gcc-avr, avrdude and kontrollerlab for Linux. We would like to appeal to teachers, elec-
The lesson materials are now organised in a tronics and information technology experts
matrix and can be found at to cooperate and develop things further, all
nl/matrix/matrix_atmel.html in the spirit of open-source.

4/2009 - elektor 35
projects automotive electronics

R9 LED0 +VCore
R7 LED2 C1 C2

R6 100n 100n




330R 51 20 RESET
R4 LED5 50
(AD1)PA1 S8 C3
330R 49 19 PG4
R3 LED6 48 18 PG3
(AD3)PA3 PG3(TOSC2) RESET 100n
330R 47 43 PG2
R2 LED7 46 34 PG1
330R 45 33 PG0 +5V
(AD6)PA6 PG0(WR)
44 1 JP1
S0 35 17 PB7
16 15 14 13 12 11 10 9
1 2 3 4 5 6 7 8

(A8)PC0 (OCA0/OC1C)PB7
S1 36 16 PB6
(A9)PC1 (OC1B)PB6
S2 37 15 PB5 10k
(A10)PC2 (OC1A)PB5
S3 38 14 PB4 GND +5V
(A11)PC3 (OC2A)PB4 K1
S4 39 13 PB3
(A12)PC4 IC1 (MISO)PB3
S5 40 12 PB2 MISO 1 2
(A13)PC5 (MOSI)PB2
S6 41 11 SCK SCK 3 4
(A14)PC6 (SCK)PB1
S7 42 10 PB0 RESET 5 6
(A15)PC7 (SS)PB0
PE7 9 54 PF7 MOSI
PE6 8 55 PF6
+5V (T3/INT6)PE6 PF6(ADC6/TDO) K6
PE5 7 56 PF5
PE4 6 57 PF4 PG0 1 2 PG1
K2 R11 PE3 5 58 PF3 PG2 3 4 PG3

1 PE2 4 59 PF2 PG4 5 6 PD0



6 K7 6 5 MISO 3 60 PF1 PD1 7 8 PD4

2 1 2 1 MOSI 2 61 PF0 PD7 9 10 PB7

7 3 4 IC2 TXD (RXD0/PDI)PE0 PF0(ADC0)
PB6 11 12 PB5
11 3 5 6 J1 PCA82C251 4 PD4 29 28 TXD1 PB4 13 14 PB3
8 7 8 30 27 RXD1 PB2 15 16 PB0
10 4 R12 31 26 PD1 PE7 17 18 PE6
9 PD7 32 25 PD0 PE5 19 20 PE4


5 PE3 21 22 PE2
PF0 25 26 PF1





GND PF2 27 28 PF3
PF4 29 30 PF5
C4 C5
TXD1 PF6 31 32 PF7
RXD1 22p 12MHz 33 34

+5V K3 GND

+Vin LD1117S50CTR
GND D1 +5V +5VA +5V +VCore
MBRS130 L1 L2
K5 3 2

2 C6 C8 C7 C9 C10 C11

6..12V LED8
47u 100n 10u 100n 100n 100n

080671 - 11

Figure 1. The schematic for automotive CANtroller module.

Schematic provides the option of manually reset- mum frequency.

ting the circuit. A crystal of 12MHz To enable the CAN controller to com-
The schematic for this module is a is used for generating the clock fre- municate with a real CAN bus a CAN
relatively simple design (Figure1). quency. To use this crystal the con- transceiver is required. This can be
The heart of the circuit is formed by figuration fuses of the microcontroller found on the schematic in the form of
the AT90CAN32 (IC1). The Reset pin have to be programmed with the cor- a PCA82C251 (IC2). This IC is quite
is connected to an RC network (R1/ rect settings. Using AVR Studio, the well known by now and conforms to
C3) which provides a reset when the SUT_CKSEL bits can be configured for the ISO11898-24V standard. This trans-
power supply voltage is turned on. S8 an external crystal with 8MHz mini- ceiver can therefore be used with both

36 elektor - 4/2009
Stepper motor control .DEVICE AT90CAN32
.INCLUDE;definition of ports
are in a separate file
The example below shows how a bipolar stepper motor can be
connected to the control module. Bipolar stepper motors contain a RJMP RESET ;jump to starting address
number of windings which need to be driven according to a certain
pattern. In our example this is the following continuously repeating /*INITIALISATION*/
pattern : 0101 1001 1010 0110.
RESET: LDI R16,$FF ;set all pins of Ports A and
In the initialisation routine of this example, Ports A and F are con- F to outputs
figured as outputs. The stack pointer is initialised before any subrou- OUT DDRF,R16
tines are used. Port C is entirely configured as inputs, because this is OUT DDRA,R16
where the switches are connected. The switches are not used in this
LDI R16,high(RAMEND)
example, however.
In the main program the four steps, one at a time, are continuously OUT SPL,R16 ;stack pointer initialisation is
written to Port F, with a small pause between each one. The stepper necessary for subroutine
motor will rotate as a result. When step 4 is completed the software
will begin again with step 1. The controller will repeat this pattern ;is not yet used here
over and over again.
LDI R16,$FF ;activate the pull-up
The stepper motor is connected to the microcontroller using the fa- OUT PORTC,R16 ;by writing ones the the
miliar ULN2003A (see schematic). This IC contains a number of Dar- output port
lington transistors which can deliver sufficient current to get a small LDI R17,$00 ;set all pins of Port C to
stepper motor to turn. inputs
OUT DDRC,R17 ;not really necessary
(default value)
PG0 1 2 PG1
PG4 5 6 PD0
PD1 7 8 PD4
PD7 9 10 PB7 BEGIN: LDI R17,0b00100010 ;0101 step 1
PB6 11 12 PB5
PB4 13 14 PB3 R1
PB2 15 16 PB0

PE7 17 18 PE6
PE5 19 20 PE4 K4
PE3 21 22 PE2 LDI R17,0b10000010 ;1001 step 2

PF0 25 26 PF1 1 16 OUT PORTA,R17


I1 O1
PF2 27 28 PF3 2 15 RCALL WAIT1
I2 O2
PF4 29 30 PF5 3
IC1 O3
PF6 31 32 PF7 4 13
I4 O4 LDI R17,0b10001000 ;1010 step 3
33 34 5
ULN2003 O5
6 11 OUT PORTF,R17
7 10



080671 - 12 LDI R17,0b00101000 ;0110 step 4


The example program is available as a free download from the
Elektor website filed under number
WAIT1: LDI R20,0x0F ;0F (01 for debugger)
WAIT: LDI R18,0xFF ;0x77 (01 for debugger)
AGAIN: LDI R19,0xFF ;0xFF (01 for debugger)
LOOP: SUBI R19,0x01
Program for de AT90CAN32 Elektor-Timloto board SUBI R18,0x01
Port F output BRNE AGAIN
Port A output and drives LEDs SUBI R20,0x01
This program uses AVR Studio 4 BRNE WAIT
The program runs from flash memory RET ;return to main program

4/2009 - elektor 37
projects automotive electronics

from the USB-connection or from volt-

age regulator IC3.
The PCB layout for the circuit is shown
in Figure2. We wont discuss the
details of assembling the PCB. Experi-
enced electronics enthusiasts are cer-
tainly capable of assembling this board
by hand, but most users would prob-
ably order the ready-made board from
Elektor instead.

In order to program the microcontroller
you need to have a programmer. You
can do this by, for example, connecting
the Elektor USB AVRprog to K1. This
Figure 2. Component layout for the PCB that was designed for this circuit.
programmer was featured in the
May 2008 issue. This pro-
grammer is still
12-V as well as 24-V systems. available from
Using sub-D9 connector K2 the Elektor Shop
or pin header K7 it is poss- (no. 080083-71).
ible to connect the board to For the program-
the CAN-bus. The pinout ming software you
of this connector cor- can use AVR Studio
responds with that of from Atmel [2]. This
the USB-CAN adapter is available as stand-
which was published ard with an assem-
in our October 2008 bler. Those of you who
issue. are fond of C can use the
Considering the educa- WinAVR open-source toolset
tional character of this [3]. Bascom AVR [4] and Code-
project, the board is also vision [5] are a couple of com-
provided with eight switches (S0 mercial alternatives. These have
to S7) and eight LEDs (LED0 to LED7) K4 is the familiar header for the USB- evaluation versions available that you
which can be used when doing pro- TTL cable which we have used in sev- can download.
gramming exercises. There is also a eral earlier Elektor projects (080213-71,
potentiometer (P1) on the board. You see Elektor Shop). The Automotive CANtroller module is
can, for example, let the microcontroller The power supply for the circuit is available from the Elektor Shop and
read the position of the potentiometer built around a classic design using a has the catalogue number 080671-91.
and depending on the measured value LD1117S50. This is a linear low-drop All SMD parts are already fitted on the
turn on a number of LEDs. You need to 5-V regulator which requires very few board. Only the through-hole parts
fit jumper JP1 to connect the potentio- external components. With K3 you can and the connectors still need to be
meter to the microcontroller. choose whether the circuit is powered soldered.
Finally, a comment about the power
supply for the module. As you will
have noticed already, this can be pow-
IC3 = LD1117S50CTR (SOT223)
ered from either the USB connection or
LED1-LED9 = SMD LED (SMD0805) from a mains adapter. Make sure you
Resistors X1 = 12MHz quartz crystal have the correct setting for the jumper
R10 = 120 (SMD0805)
R2-R9,R13 = 330 (SMD0805) on connector K3.
R12 = 1k (SMD0805) JP1,JP2 = 2-way SIL pinheader + jumper
R1,R11 = 10k (SMD0805) K1,K7 = 6-way DIL pinheader
P1 = 10k potentiometer K3 = 3-way SIL pinheader + jumper
(RK09K11310KB) K6 = 34-way DIL pinheader
K4 = right angled 6-way SIL pinheader Internet Links
K5 = DC adapter connector
C1,C2,C3,C8-C11 = 100nF (SMD0805) K2 = right angled 9-way sub-D plug [1]
C4,C5 = 22pF (SMD0805) (male), PCB mount uments/doc7682.pdf
C6 = 47F 20V (CASE D) S0-S7= one 8-way DIP switch
C7 = 10F 16V (CASE B) [2]
S8 = pushbutton
Kit of parts, contains SMD-prestuffed board asp?tool_id=2725
Semiconductors and all through-hole components. Elektor [3]
D1 = MBRS130 (SMB) Shop # 080671-91.
IC1 = AT90CAN32-16AU (TQFP-64) [4]

38 elektor - 4/2009
tel. 01298 70012
fax. 01298 70046
VAT Reduction AND Special Offers!
Atlas DCA was49 Atlas ESR 7!
includes new premium probes! 5
! wa

Specialising in Prototype PCBs

Instant online Quotations & Ordering Special Offer AND Reduced VAT ! Special Offer AND Reduced VAT !
Atlas DCA Model DCA55 Atlas ESR Model ESR60
From Singlesided to 6 layers ML
Semiconductor Analyser ESR and Capacitance Meter
Leadtimes from 48 hrs Identifies type and pinout! Resolution of 0.01 ohms!
Atlas SCR was8 7!
Full DRC included on all orders
No Tooling or Set-up Charges Atlas LCR wa
7 includes new premium probes! 99

Simply send your layout les

and order online Better than 2 % VAT Reduction! Special Offer AND Reduced VAT !
Atlas LCR Model LCR40 Atlas SCR Model SCR100
Free Phone UK: 0800 389 8560 Email: Inductor, Capacitor, Resistor Analyser Triac and Thyristor Analyser
Automatic part identification. Auto gate test current up to 100mA
UK: Please add 2 p&p to your order. Prices include UK VAT.
Please see website for overseas pricing.

Articial Intelligence
23 projects to bring your microcontroller to life!

This book contains 23 special and exciting articial intelligence machine-

learning projects, for microcontroller and PC. Learn how to set up a neural
network in a microcontroller, and how to make the network self-learning.
Discover how you can breed robots, and how changing a tness function
results in a totally different behavior. Find out how a PC program exposes
your weak spots in a game, and ruthlessly exploits them. Several articial 256 pages ISBN 978-0-905705-77-4
intelligence techniques are discussed and used in projects such as expert 32.00 US $46.00
system, neural network, subsumption, emerging behavior, genetic algorithm,
cellular automata and roulette brains. Every project has clear instructions and Elektor
pictures so you can start immediately. Even after you have built all the projects Regus Brentford
contained within, this book will remain a valuable reference guide to keep 1000 Great West Road
next to your PC. Brentford TW8 9HH
United Kingdom
Tel. +44 20 8261 4509

Further information at

4/2009 - elektor 39
technology super computers

A Supercomputer
Dream or Reality?
Franck Bigrat (France)

1105Teraflops! Behind this strange term there hides a record, one thats been held
by Roadrunner, the worlds fastest computer, since June 2008. Built by IBM for the US
Department of Energy at the National Laboratory in Los Alamos, it beats the previous record
of 839 Teraflops held by the NEC SX9 since late 2007. Maybe soon, owning a supercomputer
at home will no longer be just a dream. Indeed, inventive solutions enabling a wider public
to have access to enormous computing powers do already exist

Flops! Tera! What on earth? Why Supercomputers?

FLOPS is the acronym for Floating Point Operation Per Sec- How can we define a supercomputer? Its a computer
ond. Perhaps wed better just explain that floating-point designed to achieve very high performance in terms of cal-
numbers are used in computing to represent values that are culation speed and power. They are used in scientific and
not whole numbers. And Tera is a multiplier corresponding engineering applications that require enormous calculat-
to 1012, i.e. a trillion. ing powers.
Armed with this information, we can say that Roadrun- Simulating the behaviour of aircraft structures, determining
ner[1] (Figure1) is capable of performing a little over a the shapes and profiles for aircraft wings so as to obtain
thousand trillion floating-point operations in one second! So maximum lift, designing engine turbines, simulating defor-
the legendary bar of the Petaflops has been crossed (Peta mations in car bodywork, meteorological forecasting, cli-
corresponds to 1015). mate changes, predicting earthquakes, research in biol-
ogy, particularly on the human genome, simulating nuclear
To give a concrete idea of Roadrunners speed, lets make a explosions, research into nuclear fusion, or decoding secret
simple comparison: the IBM computer can perform, in one codes
day, calculations that would take 6 billion people (i.e. the
entire population of the world) working 24/7 on an ordi- The list of their uses is a long one. Here are two examples
nary scientific calculator 46 years to perform! of applications in the field of scientific research:

A fierce competition 839Teraflops.

-Blue GeneL: held the record in 2005 with a speed of
The current record is held by Roadrunner [1] with its 20,000 367Teraflops. Built by IBM, it comprises 131,072 Power PC
or so processors (12,960 IBM PowerXCell8i + 6,480 AMD ASIC processors, 16TB of RAM and 400TB of storage capacity.
Opteron dual-core, running at 3.2GHz and 1.8GHz respec-
tively), but lets just mention a few other recent technological -Tera10: Brought into service in 2006 by Bull for the French
feats that illustrate the competition between the major manu- Commissariat lEnergie Atomique (Atomic Energy Commis-
facturers of large-scale computer systems (IBM, Bull, NEC, sion). It is made up of 602 Bull NovaScale servers using 8 Intel
etc.) to create the fastest supercomputer in the world. Montecito dual-core processors. This represents a total of 8,704
cores enabling a speed of 64Teraflops. The RAM capacity is
-NEC SX9: based on vector floating-point processors 30TB!
and a memory of 1TB (Terabytes), it can reach a speed of

40 elektor - 4/2009
on your Desk
1. The Blue Brain project, the ambition of which is to model Although perhaps an odd choice at first sight, this turns out
the human brain by simulating the operation of the billions to be entirely appropriate, since the PS3s CELL processor
of neurons it comprises using IBMs BLUE GENE L. (Figure2), designed by IBM and Toshiba, is identical to
the one used in Roadrunner.
2. The Horizon project which allows simulation of galaxy
formation, thus making it possible to verify the validity of This eight-core processor is capable of amazing feats. Judge
the models astronomers develop to describe the evolution for yourself: 200Gigaflops in single precision (32bits) and
of the universe. 20Gigaflops in double precision (64bits). The computing
power obtained by the cluster (well explain this term later)
One of the main motivations for developing these high-per- of PS3s is equivalent to around 400 computers.
formance computers is simply the fact that developing a This example shows that it is possible provided of course
reliable computer simulation model and using a high-per- you possess the appropriate knowledge in electronics and
formance computer to run it cost infinitely less than carrying computing to put together a supercomputer for yourself;
out incredible numbers of tests or scientific experiments in with modest performance, certainly, but adequate for cer-
the laboratory. tain applications.
But above all and the Horizon and Blue Brain projects
are good illustrations of this they make it possible to Repurposing graphics processors
simulate phenomena that are difficult, if not utterly impos- A different solution is offered by NVIDIA, well known for
sible, to reproduce in the laboratory. This is often referred its graphics processors. It has announced the marketing
to as in silico testing, just as we speak of testing in vivo of the Tesla (Figure3), a product intended for scientists.
or in vitro. Here, a new generation of graphics processors (GPUs), the
G80 (better known under the name GeForce 8800 Ultra),
made up of 128 cores working in parallel, is repurposed
A games console converted into a supercomputer! from its original function (generating images), via dedicated
Certain scientists, limited by their budgets and so unable software, CUDA, to exploit all its computing power and
to have access to a supercomputer (one simple simulation convert workstations into personal supercomputers. In this
may cost several thousand euros), have found a solution way, it is the manufacturers intention to rival the current
that is radical to say the least: putting together their own supercomputers by offering powerful calculating solutions
supercomputer. at affordable cost.
A team of researchers under Gaurav Khanna from the Uni-
versity of Massachusetts (USA) carrying out astrophysical NVIDIA will be offering its products in three forms:
research into gravitational waves and black holes have
used eight Play Station 3 games consoles connected to a 1. The Tesla C870: a PCI Express format card with a GPU
network in order to create a supercomputer at a reason- using 128parallel processors, and 1,500MB of memory,
able cost [2]. allowing a power of 500Gigaflops.

-Mare Nostrum (see photo): Built by IBM for the Barcelona

Supercomputing Center. It reaches a speed of 94Teraflops.
-Dawning5000: China has entered the field with this com-
puter using 7,680 AMD Opteron quad-core processors running
at 1.9GHz This is the fastest computer running under Windows
HPC 2008.

The official list of the 500 fastest computers in the world is main-
tained by the TOP500 project [9].

4/2009 - elektor 41
technology super computers

flops), depending on version.

However, the prices said to be between $1,300 and
$12,000 mean these products are still very much con-
fined to large companies or research laboratories.

Lastly, lets just mention Cray [4] which is coming back onto
the scene by marketing the CX1 at a price of $25,000. This
is a workstation fitted with 16 Intel Xeon 4-core processors
and running under the WindowsHPC (High Performance
Computing) Server2008 operating system [5].

The secret of supercomputers

Figure1. speed: their architecture
Roadrunner, the fastest Modern supercomputers are based on a parallel architec-
computer in the world.
ture that can be regarded as several powerful computers
working at the same time, each performing one small part
of the final calculation and linked together in a group by a
communication network. Network specialists use the term
cluster to describe this type of organization. At the end of
the line, one computer centralizes the results (Figure4).

This type of architecture has been made possible thanks to

increased mastery of microprocessor manufacturing proc-
esses, performance improvements, and reducing costs due
to massive production. The architecture found in the most
recent dual- and four-core processors fitted to the latest gen-
eration of PCs is comparable, on a more modest scale.

The communication network needs to have characteristics

Figure2. that match the performance of the system in order to trans-
A CELL processor in a fer the incredible quantity of data processed quickly and
natural setting. without loss. For example, the Blue Gene L network is made
up of 1,024 1GB/s Ethernet adaptors. In addition, the
operating system for these machines obviously needs to be
2. The Tesla D870: this external unit houses two C870 powerful and multi-tasking. This is why supercomputers usu-
cards and is connected to a workstation by way of a PCI ally operate with a UNIX operating system, or its general
Express card. Power: 1,000Gigaflops. public version Linux [6]; but Windows too is beginning to
make a place for itself [5].
3. The Tesla S870: this is a server with either four GPUs
(i.e. a power of 2,000Gigaflops) or eight (4,000Giga- Internal structure
The vast majority of supercomputers are based on the fol-
lowing principle (see Figure5):
- Several processors are integrated onto the same chip;
- Several chips are fitted onto one board;
- Several boards are built into the same cabinet.

But the engineers designing these machines found them-

selves confronted with one problem that is simple enough
to solve for an office computer, but takes on gigantic pro-
portions in this type of machine: cooling. Lets look at one
concrete example. The TERA 10 supercomputer consumes
around 1.8MW! Since consuming this much power inevi-
tably involves very significant heating of the circuitry, so as
not to affect system performance and to avoid malfunctions,
the engineers have quite simply added a 2MW refrigera-
tion unit so a total consumption of almost 4MW for a
single computer!

Calculation grids and distributed calculation

The growing number of computers being sold around the
world, whether they are PC or Mac types, has given the
engineers the idea for an original solution to the need to
have access to substantial computing power: to get geo-
graphically-separated computers to work in tandem, linked
Figure3. together by a super communication network.
Nvidias racing model. This virtual infrastructure is called a calculation grid and

42 elektor - 4/2009
Building your own
PS3 cluster
For highly-motivated DIY-ers who want to build their own
machine, the ps3cluster website shows the various steps that
will let you create a cluster based on the PS3 games console.
The software needed is free, so all you have to do is get hold
of a few PS3 consoles. Heres a summary of these steps:
1. Download, burn to DVD-ROM, and install the Linux-based
Fedora operating system.
2. Install the MPI (Message Passing Interface). This interface
makes it possible to run remote computers running parallel
programs in distributed-memory systems.
3. Install the CELL SDK (Software Development Kit) which pro-
vides the resources needed to develop and compile programs
for the CELL processor operating under Linux.

FlashMob Supercomputer
A flash mob is the gathering of a group of people in a public
place to perform actions agreed in advance, before quickly
dispersing. In the case of a flash mob supercomputer, the
action agreed upon is to set up a cluster using computers
brought along by the participants and measure its speed. In
this way, the first flash mob supercomputer was set up in San
Francisco in the USA in April 2004. Within a few hours, 150
computers (out of the over 700 computers available) were net-
worked to achieve a sustained speed of 77Gigaflops. This is
still a long way from the performance of real supercomputers,
but it did demonstrate the validity of the principle.
The software used is available free from the website of the
inventors of this game, all you have to do is burn it onto a
CD-ROM (230MB), boot up the computers using it, and con-
nect them onto a network.

The Beowulf cluster

A Beowulf cluster is a calculation grid made up of cheap PCs.
The system was originally developed by Donald Becker at
NASA, but is now regularly used around the world in applica-
tions requiring a large number of calculations.
The computers usually operate under Linux or other free
operating systems. A Beowulf cluster does not involve the use
of special software, only the system architecture is defined
[source: Wikipedia].
So it is possible to use any hardware platform to create a
Beowulf system. One good example of this is the Furbeowulf,
a cluster built around Furbies. A Furby is a little moving furry
toy, fitted with detectors that enable it to hear sound, feel
when you touch it, and see light; whats more, they can com-
municate between themselves. The Furbeowulf runs under
Linux Furby and doesnt really have particularly high perform-
ance. Another handicap of this system is the fact that you have
to feed the Furbies, regularly, otherwise they fall asleep

4/2009 - elektor 43
technology super computers

trying to spot a possible message coming from an extra-ter-

communication restrial intelligence within the incredible quantities of radio
signals (generated by the stars) coming from space.
computer computer
- GIMPS (Great Internet Mersenne Prime Search) [8] which
is researching Mersenne prime numbers: prime numbers
computer computer
equal to a power of 2 minus 1 (2x 1).

computer computer
central Quite apart from the technological feats that supercomputer
Figure4. 090067 - 11 represent, the competition between the big companies to
Block diagram of a cluster. design the most powerful computer reflects some important
scientific stakes. Scientists around the world are counting a
great deal on the capacities of these machines in order to
advance their work. For the manufacturers, this competition
is a fantastic showcase for their know-how and their skill
card processor
in designing and producing powerful machines. Although
chip chip processor the winner for the moment is IBM with its Roadrunner, a
card new claimant to the title has entered the race: is the Cray
chip chip XT5 Jaguar (Figure6, the name chosen by its designers
card processor speaks for itself) going to be able to push the current limit
still further?
Well find out the answer when the new official list of the
Figure5. 500 fastest computers in the world is published in June
The principle of a 090067 - 12
2009 [9].

References, Notes,
Internet Links
[1] Roadrunner is the common name of the Greater Roadrunner
(Geococcyx Californianus), a species of running bird that lives
in the arid regions of North America (Texas, Nevada, Utah, etc.)
Figure6. It was made popular in the character of Beep-Beep, the hero of
The Jaguar from Cray. the cartoons produced by the Warner Bros studios.

makes distributed calculation possible, where each compu- [3]

ter performs one small part of a complex calculation. [4]
Via the Internet (the super network in question), inter-soft-
ware manages the exchanges between the various units,
thus giving the appearance of a supercomputer at work. [6]
Some very serious scientific programmes are using this [7]
resource. Lets mention principally:
- SETI (Search For Extra-Terrestrial Intelligence) [7] which is [9]

Anton whats been done at the D.E. Shaw Research lab (New York,
USA) in order to produce a specialized computer for molecu-
Instead of using lar dynamics simulations. The system, based on a home-
standard hard- made 888 3D grid of ASICs christened Anton in honour
ware to solve a of the 17th-century scholar Anton van Leeuwenhoek, contains
complex prob- around 100 billion transistors and consumes a mere 100kW.
lem, it is also It seems that a prototype of Anton is operational, but has not
possible to adapt yet achieved its maximum performance: it is intended to be
the hardware up to 200 times faster than a supercomputer working on the
to the problem. same problem.
This is exactly

44 elektor - 4/2009
projects microcontrollers

The 32-bit Machine

Program development
with the R32C starter kit

Marc Oliver Reinschmidt (Germany)

Having introduced the R32C/111 32-bit microcontroller in our previuous issue, its time to roll up
our sleeves for some practical experiments. A keenly priced starter kit is the basis for our work
with this controller. These pages will familiarise you with the tools required for programming and
debugging. Those of you already familiar with the R8C/13 from Renesas will recognise plenty of
similarity in the way all this is handled.

The starter kit consists of an R32C ments with the new 32-bit controller. P3_0 is switched low. The two LEDs
carrier board (a microcontroller mod- The power supply is drawn from your can be uncoupled from these functions
ule equipped with the R32C/111 chip) computer via the USB connection, if you open the solder bridges SJ3 and
and a software CD-ROM containing the which simplifies things rather nicely. SJ4. At the centre of the PCB is the
necessary development tools. As with Figure1 shows the circuit of the R32C R32C/111 positioned by its 64 pins. All
the earlier R8C/13 Tom Thumb project carrier board, with the printed circuit connections are taken out to the con-
in Elektor Electronics (November 2005 board (PCB) in Figure2. Placing the nector strips along the edges of the
through March 2006), the R32C car- components on the PCB (upper photo) board. Once you have soldered in the
rier board is one of Glyns in-house is pretty straightforward. pin-arrays provided the board can then
developments. Glyn Jones GmbH & On the left side are two LEDs (LED1 plug into a standard 64-pin IC socket.
Co as the company is officially called and LED2 on the circuit diagram). The PCB is also equipped with two
is an authorised distributor for Rene- LED1 (green) indicates that power sup- crystals. The 12MHz crystal is needed
sas in Germany. With the attractively ply is present. LED2 can be made to for the USB serial transceiver module
priced starter kit (available through respond by software, being connected from Prolific. This IC (PL-2303X) ena-
the Elektor Shop) you get everything to the port P3_0. Being tied to VCC, this bles the use of a virtual USB port on
you need for your first hands-on experi- LED can be made to light up when pin the PC for debugging or for simple

46 elektor - 4/2009

R5 1 JP5
D1 DIL64


S1 R12

RESET 1 1 64 64 VCC
2 2 63 63
3 3 62 62 1 SJ1
C9 C12 4 4 61 61 1
C5 C6 C13 5 5 U$1 60 60 SJ8
XCOUT/P86 AN0/P100
100n 10M
6 6 59 59 1
100n 100n 100n
7 7 58 58 SJ2
Q1 8 8 57 57
VSS AN2/P102
9 9 56 56
4 8 17 24 XIN AN3/P103
10 10 R32C111 55 55
VCC AN4/P104

R11 R3 R7 R14 R16 R17 8MHz 11 11 54 54

20 19 C2 C1 NMI/P85 AN5/P105
VDD_5 RST 12 12 53 53





SJ7 2 100k R8 INT2/P84 AN6/P106 VCC

DTR 13 13 52 52
1 3 13 22p 22p INT1/P83 AN7/P107

RTS EE_CLK 14 14 51 51
9 14 INT0/P82 AN00/P00
DSR EE_DATA 15 15 50 50 SJ3
10 U/TA4IN/P81 AN01/P01
DCD 1 16 16 49 49
X1 11 TXD U/TA4OUT/P80 AN02/P02
CTS U$3 5 17 17 48 48 1
1 R2 RXD TA3IN/P77 AN03/P03
VBUS 16 18 18 47 47 R9
2 27 7 DM 12 VCC TA3OUT/P76 INT3/P15
D SHTD 1 1 VCC 19 19 46 46

3 R10 22 W/TA2IN/P75 INT4/P16
D+ 15 PL2303X GP0 20 20 45 45
4 27 7 DP 23 W/TA2OUT/P74 INT5/P17
GND GP1 SJ6 SJ5 C15 21 21 44 44 LED1
6 26 V/TA1IN/P73 AN20/P20
RI PLL_TST 22 22 43 43
USB-A 7 25 V/TA1OUT/P72 AN21/P21
GND GND_A 100n 23 23 42 42 POWER
21 18 TB5IN/P71 AN22/P22
GND_3 GND2 24 24 41 41
TA0OUT/P70 AN23/P23
25 25 40 40
OSC1 OSC2 TXD1/P67 AN24/P24
26 26 39 39
27 28 RXD1/P66 AN25/P25
R15 Q3 27 27 38 38
VCC R6 CLK1/P65 AN26/P26
28 28 37 37

10k CTS1/P65 AN27/P27

C11 C10 29 29 36 36
12MHz LED2 30 30 35 35
10p 10p
31 31 34 34
R13 TA3OUT/P31 TB2IN/P62
PE15 1 32 32 33 33
1k TA0OUT/P30 TXD0/P63

080928 - 11

Figure 1. Circuit diagram of the R32C/111 carrier board.

inputs and outputs. lific IC mentioned, connected to the demanding a project is formed, the
The second crystal is provided for the Mini-USB connector. The push-button more necessary it is for the developer
R32C. In fact an actual crystal is not directly next to the connector is the to be able to see whats actually going
crucially necessary, given that the Reset switch (S1). on inside the system. Its often inter-
R32C contains its own internal 50MHz esting to see which values the varia-
oscillator, but for best stability over bles have assumed or which registers
wide temperature ranges a crystal is
Monitor and debugger have been set, which way the program
inevitably better, particularly for appli- As supplied, the R32C carrier board is going following a polling request or
cations where time-critical accuracy is comes with a monitor program already branching or simply where every-
vital. loaded into flash memory. What does thing is hiding out.
Right next to the crystals is Jumper this mean in reality? If we were to burn our program
JP5, which is used to switch between Lets take a look at the various straight into the chip, we would have
programming mode and run mode. methods of getting a project up and very little access to these parameters,
Like all other Renesas microcontrollers, running. The more complicated and for which reason we use a so-called
the R32C is equipped with an internal
boot loader, which makes program-
ming via the serial interface possible.
This mode is always operational when
this jumper is set, meaning that the
CNVSS pin is at VCC level and a Reset
has been called. When you remove the
jumper, the CNVSS pin is taken down
to GND via a pull-down resistor. Fol-
lowing a Reset or Power-up the pro-
gram that has been loaded is executed
To the right of the jumper is the Pro- Figure 2. Component placement and track layout of the PCB.

4/2009 - elektor 47
projects microcontrollers

using a monitor program and KD100 either the vector table of the monitor
software. or that of the application program.
Since it is provided on the CD in the The debugger requires the interrupt of
starter kit, the KD100 software debug- the UART1, to make debugging poss-
ger from Renesas is worth close inspec- ible at all. As a result this interface
tion. Fans of the R8C13 should pay is unfortunately unavailable for other
attention here. In its time the R8C13 uses. We shall put up with this sacri-
used the old KD30 debugger, which fice and turn our attention to the other
bears a strong visual resemblance to UART interfaces. The only way we can
the KD100. Skill sets built up with the make all of our UARTs available with-
KD30 can be re-used with the KD100. out restriction is if we flash our appli-
In contrast to hardware debuggers, cation program directly and do without
the KD100 requires a monitor program any debugging.

Figure 3. The Windows control panel reveals the number of the

virtual COM port.
The E8a debugger
The E8a is a hardware tool for all microcontrollers of the M16 family from Renesas (R8C,
M16C, and R32C), with which you can both flash and debug microcontrollers. The E8a is
hooked up to a PC using the USB link plus a 14-conductor flat cable connected to the appli-
cation. The 14-way connector provides the interface to your hardware. Apart from a few
resistors no other components are needed. For applications that do not require much current
the E8a can supply up to 300mA via the USB port. The voltage can be set at your choice of
5V, 3.3V or 1.8V.
The E8as debugging software is integrated in the Renesas development environment HEW,
meaning that throughout production of a project only one development environment is used.
This makes operation extremely simple and fast to learn.

Key characteristics:
Usable across a broad voltage range from 1.8 to 5V.
Debugging with HEW.
Ideal programming tool with the gratis Flash Development Toolkit.
Figure 4. Setting the COM port and the baud rate in the Hardware and software break points.
KD100s initialisation window. Software tracing available.
Compact, cost-effective and convenient.
Usable also for on a production basis.

to be loaded separately into the con- First signs of life

troller. This monitor program takes
over the complete debug function Thats enough of theory for now. Lets
and, as with the R8C/13, controls data hook up the board to the PC the sim-
exchange via the serial interface. The ple way, using the USB connection.
application itself then runs as a kind The Prolific transceiver announces its
of sub-program of the monitor. At this presence with the Windows message
point we should explain that we have New Hardware Found and once we
resorted to using some special pro- have loaded the driver from the CD
gramming techniques to deal with the supplied, Windows provides a virtual
vector tables. COM port. At this stage it is important
to note which number is assigned to
The reason is this. Operating the KD100 the port. The simplest way of check-
means that two programs are running ing this is to look in Windows Control
Figure 5. This window indicates that the debugger is linked to
in parallel within the controller: the Panel under the heading Hardware
the carrier board.
monitor and also our application pro- (Figure3). This done, we can now
gram. Both programs operate with vec- launch KD100 (assuming you have
tor tables, which are necessary for exe- already installed this on the PC). In
debugger (debugging software). There cuting the interrupts. As a rule these the initialisation window (Figure4) we
are a number of approaches, according tables exist only once, but not in our select the COM port and the baud rate.
to the budget available. Here we shall situation. We therefore need to shift or Under MCU you can select the corre-
look at the simplest solutions: the E8a displace the vector table of our appli- sponding microcontroller family.
Debugger, a low-cost hardware tool cation program so that after each inter- Now we should check once again
(see inset), and the software solution rupt, the microcontroller can access whether jumper JP5 on the carrier

48 elektor - 4/2009
board is open-circuit and press enthu-
siastically on the reset button. Follow-
ing a click on OK, the debugger now
links up to the carrier board. We can
confirm this is happening in the fol-
lowing window (Figure5), in which
the debug parameters remain to be
defined and the microcontroller unit
status can be read.
After a further click on OK the KD100
signs on (Figure6). This confirms that
the controller is functioning properly
and can be activated, also that the
monitor file can now be loaded.
Only one further program needs to be
loaded and tested for now. For speed
and simplicity we will use a ready-
made sample project for taking our first
steps with KD100. We can experiment
with a project of our own afterwards.
All necessary files are provided on the
starter kit CD. For debugging we need
to load a debug file into the controller.
With the KD100 the protocol is File ->
Download -> Load Module, at which
Figure 6. The KD100 on the screen. The monitor file is loaded and the controller is ready to respond.
stage we look for the file X30 in the
Debug folder of the Workspace Project
and load it using the KD100.
The tension mounts as the code is of modern operating systems it still R32C/111. The other parameters on the
loading and when this is complete, makes sense to avoid the use of special following pages can be re-used with-
the yellow cursor halts at the address symbols and long path names. These out alteration.
FFFF00D8h (see Figure7). And when can confuse the compiler on occasion,
you click on the control panel Go making the hunt for errors afterwards Now comes the programming of the
(upper left), the red LED on the board extremely slow and tedious. simple sine wave generator, for which
starts to flash the program works! In the next step you need to select the the D/A converter included with the
precise type of microcontroller accu- R32C is extremely handy.
rately. Here this is the R32C/100 and The D/A converter employs a simple 8-
SineWave the Group is 118. This includes the bit R-2R network (Figure9), in which
Now its time to write a program of our
own. Our mission is to use the R32C as
a simple sine wave generator which
is why we have named our first appli-
cation program SineWave.
All necessary resources are integrated
in the Renesas development environ-
ment known as the High-perform-
ance Embedded Workshop or HEW
for short. The HEW is a top level ele-
ment, a so-called front end combining
project management, Editor, Compiler,
Assembler and Debugger. The benefits
are clear: theres only one top-level ele-
ment to come to terms with and this
does not take very long really.
If you have installed HEW from the CD
and launched it by hitting Start -> Pro-
gram -> Renesas -> High-performance
Embedded Workshop, you are offered
the choice of opening an existing
project or else creating a new one.
Well opt for starting a new project.
Using the Create new workspace
command we will shape this project
for the R32C (Figure8). A quiet word
in your ear (sirrah): even in this era Figure 7. A click now on Go and the red LED on the R32C board flashes!

4/2009 - elektor 49
projects microcontrollers


2R 2R 2R 2R 2R 2R 2R 2R


0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1


080928 - 18

Figure 8. Workspace set-up for the sinewave generator project. Figure 9. The integrated D/A converter uses a simple 8-bit R-2R network.

a digital value is transformed into an Now for the programming. To make use is set out in the annexe below.
analogue output voltage. The output of the D/A converter we first need to To produce a variable frequency, the
voltage can lie within the range from activate the output. We do this by set- frequency output is executed within
AVSS to VREF. The AVSS pin (pin59) is ting the register bit da0e=1. Now we a Timer Interrupt Routine. The period
linked via SJ2 to GND and the VREF pin can connect up the scope to the out- duration is calculated using the short
(pin 61) via SJ8 to VCC. put pin, in this case being pin 63 on the function void set_frequency(unsigned
Depending on how the DA0 register is carrier board. So that our output signal int fre) and passed to the timer for use
defined the output voltage on the DA0 can represent a sine wave curve, its as the timebase. Calculation of the sine
pin varies according to the following necessary to integrate the <math.h> values takes place in increments of 0.2.
formula: library (see Listing1). This is a compromise to achieve fine
signal resolution without being forced
VREF n The file sfr111.h integrates the Spe- to calculate an unreasonable number
V= cial Function Register with the code of values. With the floating point unit
written in C. The function hwsetup.h (FPU) enabled a frequency of up to
(n = 0 to 255) embraces all the functions that are nec- 3kHz can be produced, which is quite
VREF = reference voltage essary for configuring the clock-unit of impressive for this number of sampling
the microcontroller. The actual program points. The default values run from 0

Listing 1 // +++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++ set_frequency ++++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++
#include sfr111.h void set_frequency(unsigned int fre)
#include hwsetup.h {
#include <math.h> speed= 24000000/(fre*30.75); //
timer base div output frequency
// Interrupt declaration } // divided by DAC steps
#pragma INTERRUPT TimerA0_int
// +++++++++++++++++++++++++++++++++++++++++++++++
// functions // ++++++++++++++++++ Init_timer +++++++++++++++++
void Init_timer(void); // +++++++++++++++++++++++++++++++++++++++++++++++
void set_frequency(unsigned int fre); void Init_timer(void)
// globals ta0mr=0x00; // Timer mode, f8 @ 20MHz PClock
float y; ta0=speed; // Timer reload register
unsigned int speed; asm ( FCLR I); // Disable all interrupts
ta0ic=0x03; // Set timer interrupt level to 3
// main function asm(FSET I); // Enable all interrupts
void main(void) ta0s=1; // start Timer A0
{ }
ConfigureOperatingFrequency(); //
init oscillator and pll // +++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++ Interrupt ++++++++++++++++++
da0e=1; // enable DA0 converter // +++++++++++++++++++++++++++++++++++++++++++++++
set_frequency(2500); // set sine frequency (Hz) void TimerA0_int(void)
Init_timer(); // init timer for {
frequency calculation y+=0.2; // sine signal steps
while(1); // endless while loop if (y>=6.28) y=0; // set to 0 if 2pi reached
} da0=(128*sin(y))+128; // calculation
of sine (offset by 128)

50 elektor - 4/2009
to 2 (0.628) and are then reset once set is achieved by adding +128 to the
more to zero. In this way a complete resulting value.
Internet Links
sine wave period is calculated. After loading the program into the
controller you can connect an oscillo-
All that needs be done now is to shift scope to DA0 (pin 63) and if you do, the cnt=r32c111_root.jsp&fp=/products/
the sine wave upwards, as we dont result is the sine wave signal shown in mpumcu/m16c_family/r32c100_series/
want any negative values to be out- Figure 11. r32c111_group/
put by the D/A converter here. This off- (080928-I)

Figure 10. Test set-up with the carrier board. No additional parts are needed for this sine Figure 11. The sinewave signal produced on the scope.
wave generator; just make the USB connection and hook up the probe to pin 63.


Bring your project to life with
Parallax sensor modules. Collect
data, detect objects and motion,
navigate autonomously, respond to
environmental changes, enhance
human interaction, and more.

4/2009 - elektor 51
praxis controller

C Display
Programming the
M16C graphic board
in C

Development by Chris Vossen

Our May 2008 issue featured a very straightforward graphical control and measurement device using
the compact M16C Display Board and its built-in BASIC interpreter. Readers who prefer programming in
C can also use the design if they build this mini circuit and download some free software from the Web.

To begin: The M16C Display-Board for this project is really just a kind of grated with a DMA Controller.
[1] (Figure1) from Elektor comes big brother of the R8C. In fact the M16C Consequently the powerful advan-
preloaded with a TinyBasic Interpreter is nothing more than a beefed-up ver- tages of the smaller 16-bit devices,
[2]. Readers who are happy to carry on sion of the R8C, sharing the same core. which we have already discussed in
using TinyBasic for educational and In contrast to the R8C, however, the the context of our major R8C project
experimentation purposes or perhaps M16C uses a 16-bit wide Bus between [4], apply equally to the M16C.
because they have already developed core and peripherals, being also inte- Even better, theres a cost-free, yet
some handy programs for the board
need not read the rest of this arti-
cle. Thats because flashing the micro-
controller with a compiled C program
(as we shall do) overwrites the BASIC
interpreter. No worries if you do this by
accident, because we can reprogram
the Interpreter as part of our after-sales
service (for a modest charge).
Coming back on-topic, this article is
aimed at the readers who do not need
the TinyBasic-Interpreter and prefer to
program in C. We have a shortcut for
these readers as well!
Many of you are already familiar with
the well-known R8C microcontroller
and the M16C version [3] were using Figure1. The M16C Display Board is an entry-level solution for monitoring, control and measurement with a graphic output.

52 elektor - 4/2009
extremely powerful C compiler. No
extra programming device is neces- C1 +5V
sary because it can be flashed very
simply via the RS-232 interface. Even 16V
better, the Elektor website contains a +5V


project page [4] plus a well frequented C2
K2 1
forum [5] thats full of listings, answers
1 2 1u 3 6
to queries, and tips and tricks for this JP1
C1- IC1
3 4 16V 11 14 2
popular controller! T1IN T1OUT
5 6 10 7 7 11
7 8 12 13 3
9 10 9 8 8
Software C4
4 10
1u 9
Pain always precedes pleasure so we MAX232CPE 16V
1u 5 15 5
must first install the software before 16V

we can start to enjoy the delights S1

of programming. This means stick-
ing rigidly to the prescribed order of 1u
tasks. First we must install the Moni- 16V

tor/Debugger (KD30) and after this the

GND 080422 - 11
C Compiler (NC30) with the develop-
ment environment (HEW). Installing
the Debugger first enables the HEW to Figure2. Just a handful of components is all you need for our programming interface.
tie in with it properly. The next instal-
lation task is the Debugger package,
in order to integrate the Debugger the Processor starts up in program- message: Build Finished 0 Errors, 1
into the IDE. After this, all you need ming mode. If the CNVss pin is low, Warning.
do is boot up the HEW and youll have the application software licks into The alert message Warning (ln30):
everything visible on the screen. Last action (we use a jumper plug to set the License has expired, code limited to
of all we must install the Flash Devel- CNVss pin to either logic High or Low). 64K (10000H) Byte(s) is nothing to
opment Toolkit (FDT) from Renesas, Without the jumper, the input is taken worry about, by the way. Although
used for loading finished programs to ground via a 10 k resistor. To put the free version of the compiler is lim-
into the Controller. the device into programming mode the
The Renesas software can be down- jumper JP1 must be in place and then
loaded conveniently from the Elektor the Reset button pressed. After the
website the noted distributor Glyn application software has been flashed,

[6] has kindly compiled this package the jumper is removed again. Follow-
especially for this project. The project ing a second push of the Reset button (C)Elektor JP1
page for this article [7] contains not the program will begin. 080422-1
just downloads but also an installa-


tion manual.
Your first project

When you start up the High-perform-

Circuitry ance Embedded Workshop a selec-
C2 K1

The M16C contains an integrated tion window appears, with a choice of 5 1

Debugging interface that handles starting a new project or loading and

both synchronous and asynchronous existing one. The command File/Open 9 6

Ports. The asynchronous mode is par- Workspace opens an existing project.

ticularly simple to use because all we To try this out you can use our test pro-
need do is match this to RS-232 levels. gram, which you can download from
For this we use a couple of transistors, the project website [7]. Opening this
with our old friend the MAX232 also displays all the files that belong to the
making an appearance in this circuit. project. The source text is in the file COMPONENTS LIST
The CLK input of the ICs must be tied that ends in .c (see Figure3). Capacitors
to ground whenever asynchronous Before compiling you are asked C1-C5 = 1F 16V
mode is employed. The hook-up (see whether you wish to produce a Debug
Figure2) is really very simple. The version or a Release version. For the Semiconductor
PC is connected to K1 and the Display Release version choose Build/Build
Board to K2. A piece of 10-way flat Configurations and select Release. Miscellaneous
ribbon cable is ideal for this purpose, You can now start the conversion K1 = 9-way sub-D socket (female)
equipped with the necessary connec- with Build/Build All. The C source K2 = 10-way AMP Micro-MaTch connec-
tors (pins connected like-for-like or code is translated, linked and written tor, PCB mount
JP1 = jumper
1:1). The CNVss and CE pins deter- as a .mot file in the example directory S1 = press-button switch
mine what the processor does after \Release. The whole process is listed PCB, ref. 080422-1 from www.thepcb-
applying operating voltage or a Reset below in the Build window. After all
command. If both are logic High, then this you will hopefully see the desired

4/2009 - elektor 53
praxis controller

Figure3. Heres a shot of the development environment HEW.

ited to 64kB, this should be more than and waits for you to give it some data. jumper JP1 and operate the Reset but-
enough for most projects! Programs in Motorola-Hex-Format (note ton briefly. And thats it your pro-
the .mot file suffix) can be loaded into gram is up and running!
the Controller direct. Having indicated
Time to fire it up! the path to these files, you can start

The Flash Development Toolkit is the the loading process with the com- Note
way to load a completed program into mand Program Flash. The whole thing The M16C Display Board Display-Computer
the Controller. The program comes in takes just a couple of seconds. First the is available in the Elektor Shop as item no.
both a complete version and also in Flash is cleared, then the new program 070827-91 [1].
a compact Basic Version, which will is transferred. If all goes well, a suc-
suit most purposes. Starting the first cess notification will appear. Remove
time you will need to enter
the necessary settings (you
Web Links
can alter these later using [1]
the menu via Options/New modules/modules/display-compu-
Settings). Next, select the ter-(070827-91).426130.lynkx
Controller type (M30291) and [2]
the upper of the two Kernel [3]
protocols offered (see Fig-
ure4). The next window is
for selecting the interface to ily.58011.lynkx
be used. The third window
requires you to enter a Baud [5]
rate for the link to the Con-
troller (select 9,600 baud).
Now we link up the M16C
Display Board to the pro- [6] (click on English
gramming interface and to
the interface with the COM [7]
port indicated. Insert jumper [8]
JP1 and give the Reset but- wiki/M16C (M16C); http://
ton a short push. The micro- (R8C).
controller is now in Boot mode Figure4. The free-of-charge Flasher FDT enables you to set the type of Controller device.

54 elektor - 4/2009
mini project projects

FM Stereo Decoder
For our Mini FM Receiver
Ton Giesberts (Elektor Design Labs)

In February 2009 we published a monaural mini FM

receiver. A matching stereo decoder will naturally
make this receiver complete. In this mini project
we deploy an IC for this purpose. This IC has
been available for quite a few years
already and has by now amply proven
its capabilities.

The VHF FM radio published last to make a stereo version and that we intended to be used in combination
month (Elektor February 2009) has would describe the details in a future with our FM radio to make a stereo FM
a mono output only. At the time we mini project. Promise is debt, so hereby receiver a kind of upgrade, if thats
mentioned that it was also possible we present a stereo decoder which is okay with you.

Old but not yet worn out

The stereo decoder we use here is a
TDA7040T made by NXP (formerly
Philips Semiconductors). The design
of this chip has not changed since
1986 (!). This IC, just like the chip in
the receiver, is now only available in
an SMD version. The old, familiar DIP
package is no longer produced.
Just as with the FM radio, we have
also designed a miniature PCB for this
circuit to make building much easier.
We have attempted to make the PCB
as small as possible. The result of this
is that SMD parts have been used as
much as possible. The only through-
hole components are a few electro-
lytic capacitors. As a consequence
the dimensions of this PCB are only
2.5 by 4 centimetres (approx. 1 by 1.6

Signal processing
The decoder works according to the
Figure 1. In this block diagram we see the internal design of the TDA7040. PLL (phase locked loop) principle and

4/2009 - elektor 55
projects mini project

Pin 14 220u IC2


TDA7021T 270p C2
P1 R1 Vp

47k 2
Vp C7 R7 100u
50k 220n 8 6 7
IC1 L OUT 33R K4
K1 1
TDA7040T 5
C6 220n 25V L
10n 22k TDA7050T
4 C12 R
R2 2 R9

S1 6
4k7 33R
Mono/ R4 R5 3
Stereo C9 25V R10



Pin 9 3V 220n

TDA7021T R3 C3 C4 C5 P2 C8
270k 100k P3B
100n 100n 220n 10n 22k

K3 080907 - 11

Figure 2. The schematic of the decoder does not differ much from the test circuit in the data sheet.

hardly requires any additional compo- only slightly from the example in the headphones are plugged in.
nents. Figure1 shows the block dia- data sheet, and just like the circuit for The output power of the TDA7050 is
gram. You connect the output from the the receiver, there is not much scope inadequate for serious use with loud-
tuner (via a filter) to the MPX input of for improvement here either. speakers, and it would be better in
the chip. After amplification and filter- that case if you used an additional
ing the signal is split into three. K1 of the decoder is connected to K1 power amplifier. The stereo potenti-
First, theres with the pilot tone detec- of the receiver, and K3 is connected to ometer for the volume control (P3) is
tor. This determines whether we have K2 (the circuit also works without this connected to a 6-way pinheader. If the
a stereo signal and operates the (inter- connection). The mono/stereo switch wires are kept short there is no need to
nal) mono/stereo switch accordingly. S1 is connected to K2 (even though use screened cable.
Switching to mono can also All connections are imple-
be done manually, with S1, but mented as pinheaders. But
thats an aside. you can also insert the wires
From the filter the signal also directly into the correspond-
goes to the PLL, which con- ing holes and solder them.
sists of a phase detector, a Because the use of pinhead-
voltage controlled oscillator ers also allowed the use of
(VCO) and a divider. The out- other through-hole compo-
put of the divider comprises nents, we used ordinar y
the frequencies that are used radial electrolytic capacitors.
to decode the stereo informa- These use a little less space
tion. This decoding is done and are generally of a better
in the third and final block to quality than their SMD coun-
which the filtered signal is terparts. Make sure you take
sent. The (stereo) audio signal note of their maximum diam-
Figure 3. The decoder PCB is not much bigger than the receiver PCB.
finally leaves the chip via two eter (is shown in the parts
buffers. list). The component overlay
To make the signal suitable for is shown in Figure3 and the
driving headphones or two small loud- the schematic only shows S1, this is copper track layout can be down-
speakers, we use a TDA7050T. This is actually K2). Output K4 is intended to loaded from the Elektor website.
a small amplifier IC that, at a power drive headphones with an impedance
supply voltage of 3V, can deliver two of 32 or more, but for testing you can At 6V the total current consumption
times 5mW into 32ohms . also connect a couple of small loud- of the receiver and decoder together
speakers. Output resistors R7 and R9 is a little higher than at 3V: 17.3mA
protect the outputs of IC2 against over- instead of 12.5mA. For testing we
Circuit loading. R8 and R10 ensure that C11 connected two 8 loudspeakers to
The entire schematic for the circuit can and C12 are always charged so that a the outputs. The current consumption
be seen in Figure2. The design differs switch-on plop is prevented when the at highest volume peaked at 70mA.

56 elektor - 4/2009
The average was a lit- the filter is changed to
tle over 40mA. You will a second-order low-pass
have to decide for your- type with a bandwidth
self whether you would of about 53kHz. This
like to use two or four bandwidth is necessary
penlight batteries. If to pass the entire multi-
you use four you will get plex signal (AM modula-
more from the batteries tion at 38kHz with a sup-
because together they pressed carrier) to the
will only have to sup- stereo decoder.
ply a minimum of 2V
(minimum power supply
voltages for the stereo
decoder and receiver are In the stereo decoder
1.8V and 1.6V respec- the multiplex signal is
tively). During testing accentuated with a pas-
it was found that the sive network (P1/R1/C1)
tuning is a little more and must be adjusted for
dependent on changes of optimal channel separa-
the supply voltage when tion (the first of two cali-
the voltage is low than bration points). An incor-
when it is high. rect setting for P1 means
either a mono sound-
ing sound or the effect
Correction of a stereo base width
To ensure that the FM control. With the latter
radio works correctly the mono information is
with the decoder mod- Figure 4. A few changes have to be made to the receiver board, suppressed more and
ule, a small correction such as fitting a capacitor between the pins of the TDA7021T. the stereo effect sounds
needs to be carried out: somewhat exaggerated.
C15 and C16 must be The best setting (with-
removed and a 100pF out test equipment) is
capacitor must be con- somewhere in between.
nected between pins 14 This, of course, requires
and 15 of the IC. If you a good stereo broadcast
use a 0603 size SMD signal and ditto music.
capacitor for this, it can
be soldered directly The second calibration
between these two pins is also easy to do. With
(see Figure4). a strong signal, the cor-
rect setting for the VCO
The reason for this modi- can be found by turning
fication which is nec- P2, midway between
essary because without the positions where the
it the decoder wont work decoder switches to
is that the output filter mono.
in the receiver no longer (080907-I)
needs de-emphasis (C15)
and also requires less
gain (C16). In its place

COMPONENT LIST Semiconductors

P3 = 6-way pinheader and stereo 22k IC1 = TDA7040T, SMD SO8 case
Resistors (25k) logarithmic potentiometer IC2 = TDA7050T, SMD SO8 case
(all SMD shape 0805)
R1 = 47k Capacitors Miscellaneous
R2,R4 = 4k7 C1 = 270pF, SMD 0805 case K1,K3 = 2-way pinheader
R3 = 270k C2,C5,C7,C9 = 220nF, SMD 0805 case S1 (K2) = 1 make contact with 2-way
R5 = 120k C3,C4 = 100nF, SMD 0805 case pinheader
R6,R7,R9 = 33 C6,C8 = 10nF, SMD 0805 case K4 = 3-way pinheader
R8,R10 = 22k C10 = 220F 16V, radial, lead pitch BT1 = 2-way pinheader and 3-6V battery
P1 = 50k preset, SMD, e.g. Vishay Sfernice 2.5mm, diameter 6.5mm max. (pack) and battery holder
TS53YJ503MR10 (Farnell # 1557940) C11,C12 = 100F 25V, radial, lead pitch PCB ref. 080907-1, available from www.
P2 = 100k preset, SMD, e.g. Vishay Sferni- 2.5mm, diameter 6.5mm max.
ce TS53YJ104MR10 (Farnell # 1557934)

4/2009 - elektor 57
projects led driver in pspice

Get a Grip on LED Dr

Simple SPICE model predicts
hysteretic LED driver behaviour
Fons Janssen (The Netherlands)

In the process of designing a LED driver circuit, various things can go amiss. To help the designer
understand what is happening, a simple SPICE model helps out to pinpoint the effect of different
individual component values upon the circuit operation.

Hysteretic High-Brightness (HB) LED put voltage, and inductance. The rela- lar shaped current is fed through the
drivers offer simple and low-cost tion between these system parameters LEDs.
implementations requiring a mini- and the switching frequency is often To facilitate the circuit design, you can
mum of external components. They dif- not clearly understood by electronics calculate the component parameters
fer from fixed frequency drivers by the designers. by creating a spreadsheet similar to
Owing to this lack of understanding,
they have trouble defining the right
components to obtain the desired
switching frequency, which most
designers would like to maximize in
order to minimize external component

C IN size (especially for the inductor).

Basic principles

The hysteretic HB LED driver circuit BANDGAP



shown in Figure1 is based on the UVLO

MAX16820 [1], which is driving a string


CSN MAX16819 DRV of LEDs using an external inductor and
MAX16820 DIM
a power MOSFET. However, the same DIM
analysis will hold true for any vendors 080888 - 12

080888 - 11 hysteretic driver.

On start-up, the controller switches
on the N-channel MOSFET, so that the
Figure 1. A typical hysteretic HB LED driver solution based on Figure 2. Block diagram of the type MAX16820
current is ramping up through Rsense, hysteretic LED driver.
the MAX16820 driver chip requires only
a few external components.
the HB LEDs, and the inductor. As
soon as the current reaches the upper
trip point (sensed by Rsense), the FET
is switched off and the current ramps
absence of a local oscillator that sets down via the rectifier diode. When the the Excel-based example developed by
the switching frequency. The hysteretic lower trip point is reached, the FET is Maxim Integrated Products [2]. In such
circuit actually forms a self-oscillating switched on again, causing the current a spreadsheet you would enter the sys-
system and the switching frequency to ramp up. The hysteresis defined by tem specs such as input voltage, LED
is determined by a number of system the upper and lower trip point makes current and LED forward voltage, and
parameters such as input voltage, out- the system oscillate and a triangu- the spreadsheet would calculate the

58 elektor - 4/2009

values as well as create a list of recom- The basic function of the MAX16820 sense (CS) comparator the gate driver,
mended component values. Although is to switch on a MOSFET if the LED UVLO (Under Voltage Lock Out) com-
it is a useful tool, it does not actually current is below a certain value, and parator, regulator, and DIM (dedicated
clarify how the different specifications switch it off again if the current is above PWM dimming input) buffer are left out
relate to each other. To see the rela- the desired value. The built-in hystere- to keep the analysis simple.
tionships, its best to go back to SPICE
and examine the circuit model.

Simplified PSPICE model

0.2 D1 D2 D3 D4 L1
1 2

D1N4002 D1N4002 D1N4002 D1N4002 56uH

To help understand the circuit better, a V1 D5

simple SPICE model was developed at D1N914
Maxim to simulate the basic function- 0
ality of the MAX16820. With the model, IN E1

the designer can vary system param-

LIMIT(10*V(%IN+,%IN-),5,0) LIMIT(1MEG*V(%IN+,%IN-),5,0)
IN+ OUT+ +
eters with the click of a mouse and IN+ OUT+ IN- OUT- -
R5 C1
IN- OUT- 100 10p S
0 0
immediately see the effect it has on the T1
Z0 = 1
1 R4
VOFF = 2.0V
0 VON = 3.0V
TD = 82n 24k
LED current, switching frequency, etc. R3
RON = 0.06
ROFF = 1e6
This will help the designer understand 0 1k

how the system parameters relate to DIM V2

- -
each other, which makes the circuit V1 = 0V V3
VOFF = 3.0V

design much easier. V2 = 5V

TD = 20us 0
VON = 2.0V
RON = 0.06
TR = 10ns ROFF = 1e6
TF = 10ns
PW = 50us
The model is simple enough to be PER = 0

simulated on the demo version of

Cadence PSPICE, which is available
Figure 3. Simplified PSPICE model of MAX16820 hysteretic LED driver circuit.
from Cadence free of charge after
registration [3]. The demo version of
PSPICE is a fully functional version
with limitations in circuit complexity sis allows the circuit to achieve stable, In the model, the voltage-controlled
only. These limitations allow the use predictable oscillation. Figure2 shows voltage source E1 is configured as a
of standard SPICE circuit elements the block diagram of the MAX16820 and current sense amplifier that ampli-
including some popular semiconduc- Figure3 shows the simplified model fies the voltage across current sense
tor components such as the 1N4148, including the external components. resistor R1 by a factor of 10. Trans-
2N3904, uA741, etc. The model only includes the current- mission line T1 introduces a delay of

4/2009 - elektor 59
projects led driver in pspice


2V/div 2V/div

0V 0V

500mA/div 500mA/div

0V 0A 0A

0.19V 0.21V
VIN VCSN 080888 - 14
10s/div 10s/div 080888 - 15

Figure 4. Hysteretic transfer function sub-circuit Figure 5. Simulation (left) and measurement (right) results.
(DIM = High). The blue graphs show the dimming signal and the red graphs, the LED currents.

82ns, which is the actual propagation

delay of the MAX16820. E2, V2, R3, and
R4 form a hysteretic comparator with
trip levels at 1.9V and 2.1V (R5 and V DIM

C1 were added to prevent signal dis-

continuities creating conversion prob- 0V 0V

lems during simulation). The cascade I LED I LED

of these three building blocks creates 500mA/div 500mA/div

the transfer function depicted in Fig- 0A 0A

ure4. Switch S2 models the DIM func-

10s/div 1s/div
tionality. If DIM is logic High, S2 shorts
080888 - 16

the DRV signal to ground.

The rest of the circuit is pretty straight-
Figure 6. Simulation result with too small inductor. The right graph has a decreased time scale to show more detail. Clearly the 10%
forward. Switch S1 represents the
extinction ratio (indicated by the green dotted lines) is no longer met due to the severe under- and overshoots.
switching MOSFET and L1 the induc-
tor. It is perfectly possible to define a
diode model for the HB LED and the
rectifier diode, but one can also pick
a standard diode such as the 1N4002
and 1N914, whose models are included
in the PSPICE demo version. Since the
forward voltage of an HB LED is of the
order of 3.5V, several silicon diodes (D1
to D4) need to be cascaded (to form an
equivalent to the HB LED) to match
this forward voltage.

Simulations versus measurements

A 100s transient response simulation
was done with the circuit in Figure3.
The results can be found in Figure5. To
compare the results to actual measure-
ments, a measurement was done using
a MAX16820 evaluation kit [4]. This kit
has a 56H inductor and a 200m
sense resistor, so it matches the values V DIM VDIM
2V/div 2V/div
used in the simulation. The measure-
ment results are also in Figure5. 0V 0V

It is good confirmation to see how well

the simulated and measured results I LED

match. Both results have the exact

same amount of 21 switching pulses.
0A 0A

The only clear difference is the fall time 10s/div 1s/div 080888 - 17

of the current after DIM goes Low.

A good example to understand the
impact of the 82ns propagation delay Figure 7: Measurement result with 5.1H inductor. The severe under- and overshoots predicted by the simulation are clearly present.
is to use an inductor that is much The right graph has a decreased time scale to show more detail.

60 elektor - 4/2009
smaller than it should be. A circuit Conclusion Internet Links
that needs to drive three LEDs from The simple SPICE model is a very easy
12 V with 1 A of LED current requires way to predict the basic behaviour of
an inductor that is at least 36 H. This the MAX16820. It is not intended to [2]
value is calculated by the Excel tool. If very accurately simulate the chip, but MAX16819_CALC.XLS
the simulation is done with an induc- it can be used to understand the con- [3]
tor that is much smaller, say, 5.1 H, cept of hysteretic LED drivers. By var- [4]
the result looks like the graphs in ying parameters, such as input volt-
Figure 6. age, sense resistor, and inductance,
Since the total forward voltage comes the model shows how this impacts
close to the input voltage, the current for instance the switching frequency.
ramp-down is much steeper than the The circuit can easily be adapted to
ramp-up. Secondly, due to the low model the MAX16819, which has 30%
value of the inductor the slopes are so hysteresis vs 10% for the MAX16820.
fast (i.e. steep) that due to the propa- Simply change R4 to 7.333 k and V2 to
gation delay of 82 ns, over and under- 1.9318 V.
About the author
shoots occur. Due to the difference in If conversion problems occur during
slope, the undershoot is much more simulation, the best remedy is to skip Fons Janssen studied Electrical Engineer-
severe than the overshoot, resulting the initial transient bias point calcula- ing at Eindhoven University of Technol-
ogy (The Netherlands) and graduated in
in a downshift of the nominal 1 A LED tion and to reduce the total simulation
1993. Post-graduate studies at the same
current. In other words: the accuracy time (SKIPBP and TSTOP parameters
university led to a master degree in tech-
is heavily compromised and the cur- in simulation settings). nological design in 1996.
rent variation is much higher than the The OrCAD project files including the
Prior to Maxim Fons worked at ThreeFive
intended 10%. simple SPICE model can be down-
Photonics from 2001 to 2003, develop-
Again, this simulation was veri- loaded from the project page on Ele-
ing integrated optical circuits, and prior
fied with an actual measurement ktor website. A detailed version of the to that, from 1997 to 2001 he was em-
and the results are shown in Fig- MAX16820 SPICE model can be down- ployed by Lucent Technologies, working
ure 7. Again, there is a high degree of loaded from Maxim [5]. on optical access networks.
resemblance. (080888-I)


Prototype & small series PCB specialists

e ser
- 2 boards in 5 days
Instant online pricing and ordering - No tooling charge
Low order-pooling prices - 18 layers - Low PCB-Proto prices
Full options service On demand - 1-16 layers E.g. 2x 160x100 mm: 2 layers 49 each*
Deliveries from 3 days - 4 layers 99 each*
Stencil service - Immediate online ordering
- No minimum order charge

Call us: 020 8816 7005 Email: *excluding transport and VAT

4/2009 - elektor 61
projects microcontrollers

Scoping with the ATM

A digital storage oscilloscope
based on the Mega88
Wolfgang Rudolph and Burkhard Kainka (Germany)

Although oscilloscopes are less expensive now than a few years ago, we
can devise something even more economical. Our ATM18 project gives you
everything you need for a simple oscilloscope, and even if you already have a
scope, the ATM18-digiscope is a welcome addition.

Many of our readers can doubtless signal, for example, a simple voltage no more than 10% of the bandwidth of
remember how EEGs and ECGs were measurement is not of much use. We the oscilloscope are represented faith-
recorded not all that long ago, using an have to see the course of the signal fully. Another important factor is the
instrument fitted with moving pens to over time in order to decide whether triggering capability. Here you can
trace curves on a sheet of paper trav- it is OK. Even signals at relatively low chose a positive or negative level for
elling at a constant speed. This instru- frequencies, in the audio range, can starting the display. With a variable
ment made it possible to observe time- only be viewed with an oscilloscope. time base, you can display the signal
varying electrical signals. As electron- When youre used to working with a stretched in time. Analogue oscillo-
ics specialists, we have something in scope, you also use it to measure DC scopes are best suited to displaying
common with medical specialists: we voltages, and in many cases you notice periodic signals, which means signals
cannot see or hear currents or volt- that your DC signal also has some sort that constantly repeat themselves and
ages, although we can feel them if of AC component. thus appear as an essentially static
they arent too weak. Our problem is Nowadays there are basically two image.
that we work with something we can- types of oscilloscopes: beside the tried
not perceive with our five senses. and true analogue instruments, we
The first attempts to display and encounter digital oscilloscopes more
record voltages date back more than and more often. A digital storage oscilloscope, or DSO,
150 years. The earliest oscilloscope uses an analogue-to-digital converter
was an electromechanical instrument. to digitise the input signal and stores
It was coarse, insensitive and slow, but
Analogue the digital values. It can thus display
it could make voltages visible. With the With an analogue oscilloscope, the instantaneous samples of a signal and
invention of the cathode ray tube by signal is first amplified by an adjust- one-time events. Especially with dig-
Karl Ferdinand Braun, the mechanical able amount and then used directly to ital circuitry, it is often helpful to be
oscilloscope yielded to the electronic deflect an electron beam. The simplest able to study the stored signals after-
version, which embarked on a trium- types have only one channel and can wards at your leisure. Nowadays the
phant career that only now, after more thus display only one signal. However, stored signal is presented on a liquid-
than 100 years, is slowly coming to an we often need to compare two or more crystal display, and it can be edited
end. signals. A dual-channel oscilloscope is and printed out as desired.
currently the most common type, and An important factor with digital oscil-
such instruments are affordable even loscopes is the sampling rate, which
The seventh sense for electronics hobbyists. specifies how often the signal is dig-
Voltmeters are unquestionably useful The bandwidth of the instrument is itised. For good representation of
instruments. However, in most cases important. It specifies the maximum the measured signal, the sampling
we are dealing with AC voltages or signal frequency that can be displayed. rate should be ten times the signal
time-varying signals. With a video Time-varying signals with a frequency frequency.

62 elektor - 4/2009

The storage depth and A/D converter scope. A project of this sort always
resolution are also important factors.
An oscilloscope with a resolution of
arouses the desire for more channels,
more bandwidth, better triggering, the
Listing 1
8bits and a 10248-bit storage capac- ability to record slowly changing sig- Basic code for an M88 scope.
ity can store 1024 samples. This corre- nals, long-term recording, and so on
Bascom ATmega88, Scope
sponds to a display with a resolution a long list. You might also ask yourself Speed Test
of 1024256 pixels. whether its worth the effort of devel- $regfile = m88def.dat
Various methods are used for conver- oping a microcontroller project when $crystal = 16000000
sion and storage. Simple (older-model) you can use a PC sound card instead. Baud = 115200
oscilloscopes use CCD memories. With This is a valid question; some sound Open com1: For Binary As #1
this arrangement, the measured signal cards can even manage a higher sam- Dim D As Word
Dim B As Byte
is first stored in analogue form and pling rate than the ATmega88. How- Dim Ram(500) As Byte
then digitised. This results in a high ever, the input voltage range is very Dim Adr As Word
noise level, limited storage depth, and limited with a sound card, and excess
dead times, since converting the meas- voltages at the input can damage not Config Adc = Single , Presca-
ured signal from the analogue memory only the sound card, but also the entire ler = 32 , Reference = Off
to digital form takes longer than stor- computer. In addition, true DC meas- ADC clock = 500 kHz
Start Adc
ing the signal. urements are not possible with a sound
Config Portb = Output
More expensive (and more recent) card, and you are limited to two chan-
models convert the measured signal nels. The microcontroller scores better Do
to digital form in real time and store in this regard. With this issue out of the Get #1 , B
the measured data directly in work- way, we can get started with building If B = 1 Then
ing memory. With this arrangement, our own digital oscilloscope. Portb.0 = 1
For Adr = 1 To 500
the storage depth is only dependent
D = Getadc(0)
on the amount of memory available.
Especially fast DSOs use A/D convert-
ATM18 DSO Shift D , Right , 2
Ram(adr) = D
ers with sample-and-hold stages. Sig- Speed is good, and more speed is bet- Next N
nal samples can be stored in several ter. How fast can an ATmega88 sample Portb.0 = 0
sample-and-hold stages and then digi- signals? To answer this question, we For Adr = 1 To 500
tised by slower A/D converters. can run a simple program (Listing1) D = Ram(adr)
Put #1 , D
that does nothing more than sample Next N
a single channel as fast as possible. It
DIY stores 500 samples and then transmits
End If
The ATmega88 can be used to put the data at 115,200baud. Each meas- End
together a nice little digital oscillo- urement series is initiated by a start

4/2009 - elektor 63
projects microcontrollers

Listing 2 command from the PC. All we need to

run this test is a terminal emulator pro-
Pulse generator (1kHz on PD3)
gram. We send a single byte (1) to the PD3

Config Timer2 = Pwm , Pre- board and receive 500 data bytes.

scale = 32 , Compa- The test program uses port B.0 to indi-
re B Pwm = Clear Down cate the measuring time. With an oscil- ADC0
Start Timer2 loscope, we measure a pulse length
Ocr2b = 128 of 17ms here. In this time interval, a
total of 500 samples are acquired, con- 080944 - 11
verted into bytes (shifted left by two
Listing 3 bits), and stored in RAM. This corre-
sponds to 34s per sample, or a sam-
Interrupt-driving measurement Figure 1. Generating a rounded sawtooth waveform.
pling rate of approximately 29kHz. If a
Config Timer1 = Ti- signal with a known frequency is con-
mer , Prescale = 8 nected to the analogue input, the sam-
Start Timer1 pling time can also be seen from the
On Ovf1 Tim1_isr measurement results.
Enable Timer1 The crucial factor here is the setting
Enable Interrupts
of the prescaler for the A/D converter
Timebase = -20 clock signal. The following command
Oneshot = 0 sets the prescaler to 32:
Channels = 1
Trigger = 0 ConfigAdc=Single , Pres-
Saveram = 1 caler=32 , Reference=Off

50 s
With this setting, the A/D converter
Timer1 = Timebase clock rate is 16MHz32= 500kHz.
Portb.0 = 1 The data sheet recommends a clock Figure 2. A measurement made at the highest sampling rate.
Chan 0 rate in the range of 50kHz to 200kHz
D = Getadc(0) when high resolution is important.
Shift D , Right , 2 However, a higher clock rate can
If Saveram = 1 Then
be used if the resolution is less than
Ram(adr) = D
Adr = Adr + 1 10bits. Consequently, we used a
Else 500kHz clock for our initial tests
Put #1 , D with the scope project. Each sample
End If requires 13A/D clock cycles, which
yields a sample time of 26s. As we
previously measured a sample time of
Listing 4 34s, apparently 8s is taken up by
Sending the measured data processing the sample.
If Adr > 501 Then However, the data sheet also speci-
For Adr = 1 To 501 fies the conversion time as 13260s.
D = Ram(adr) From this, we can conclude that an A/
Put #1 , D D converter clock rate of 1MHz should
Next Adr not cause any problems. A test with
Adr = 1
If Oneshot = 1 Then
a prescaler value of 16 shows that a Figure 3. Two-channel measurement.
Stop Timer1 sampling rate of approximately 50kHz
End If can be achieved with this setting, with
End If the result that it takes around 10ms to
acquire 500samples.
Maybe it can go even faster? Theres
Listing 5 no harm in trying, so we ran a test with
The second measuring channel the prescaler set to8, which yielded
an A/D clock rate of 2MHz. With this
If Channels > 2 Then setting, we did not see any signs of
Chan 2 degradation of the 8-bit results. The
D = Getadc(2) measurement time for 500 samples
Shift D , Right , 2
was reduced to 6.5ms, corresponding
If Saveram = 1 Then
Ram(adr) = D to approximately 13s per sample. A
Adr = Adr + 1 sampling rate of up to 77kHz is noth-
Else ing to sneeze at, so lets do it!
Put #1 , D Not everyone has all the instruments
End If on hand that are actually necessary for
End If Figure 4. A triggered measurement.
developing an oscilloscope. Here the

64 elektor - 4/2009
Mega88 can be of further service. In
addition to its main task, it can quite Karl Ferdinand Braun was born on June 6,
easily and without affecting the com- 1850 in Fulda (Germany) and attended upper secondary school
putation time generate a square- there. In 1865, he began a course of study in the sciences and
wave signal at around 1kHz (List- mathematics, at first in Marburg and then (after one year) in Berlin.
ing2). For this purpose, we use Timer2 There he worked in the private laboratory of Heinrich Gustav
as a PWM unit with the PWM2b sig- Magnus, and after the death of Magnus he continued his studies
nal on PD3. The exact frequency is as the assistant of the physicist Hermann Georg Quincke. Among
other things, he studied vibrations of strings, and he was awarded
977.6Hz (16MHz(322562)),
a PhD degree in 1872. In Marburg, Braun sat the state exam for
which is reasonably close to1kHz. To upper secondary school teachers, and in 1873 he accepted a
get a better idea of the performance of Karl Ferdinand Braun
position as a teacher at the Thomasschule in Leipzig. In his free time,
the oscilloscope, we pass this signal (1850-1918).
he pursued scientific studies of the conduction of vibrations and
through a low-pass filter (Figure1). electricity. He discovered the semiconductor effect in metallic sulphur
This converts the square-wave signal compounds, although this did not especially interest him or his scientific contemporaries.
into a rounded sawtooth waveform
In 1877, Braun was appointed to the position of extraordinary professor of theoretical phys-
(Figure2). ics in Marburg. In 1880 he moved to Strasbourg, and in 1883 he was appointed to the posi-
As with the R8C/13 Tom Thumb arti- tion of regular professor of physics at the University of Karlsruhe. In 1887 he was called to
cle published in the April2006 issue Erberhard-Karls University in Tbingen, where he was active as one of the leading found-
of Elektor Electronics, the PC software
for the oscilloscope is written in Visual
Basic. We borrowed the simple Fou-
rier analysis routine from the previ-
ous application for our present scope
What we have now is only a single-
channel oscilloscope. For each meas-
urement, we send it a single byte (1)
and receive 500bytes, which are then
plotted on the screen. In this case
approximately seven cycles of the
waveform are plotted, which means
that the measuring time is approxi-
mately 7ms. Construction of a cathode ray tube.
There are still several features that we
want to have in the final version of the
ers of the Physical Institute. In 1895 he was appointed director of the Physical Institute and a
ATM18 oscilloscope: regular professor at the University of Strasbourg.
- More input channels
- Variable input range Braun is presently known as the inventor of the cathode ray tube (CRT), which is often named
after him in German-speaking countries. He developed one of the first functional proto-
- Adjustable time base
types in Karlsruhe in 1897. This early model had a cold cathode and a weak vacuum, and
- Triggering it required an acceleration voltage of 100,000V to produce a visible trace on the screen us-
ing a magnetically deflected beam. Magnetic deflection was used in only one direction, with
The actual sampling process runs in a deflection in the other direction provided by an externally mounted rotating mirror. In 1899,
timer interrupt routine (Listing3). This Brauns assistant Zenneck added magnetic deflection in the Y direction using a sawtooth
gives it the required timing accuracy waveform. This was subsequently followed by a heated cathode and the Wehnelt cylinder,
and allows the sampling rate to be and the tube was further developed into a high-vacuum version. In this form, the cathode ray
adjusted. For this purpose, Timer1 (a tube formed not only the basis for oscilloscopes, but also for television sets (after 1930).
16-bit timer) is clocked at 2MHz. Each After the invention of his tube, Braun began research on wireless telegraphy. He replaced
time the timer overflows, the timer reg- the coherer commonly used at that time with a crystal detector. Crystal detectors were used
ister is first loaded with the timebase for a considerable time after this, until they were replaced by thermionic valves. Braun also
value. The time increment is 0.5s, researched transmitter technology and made major contributions to the progress of radio en-
so with a timebase value of 40 the gineering. In the area of antenna technology, he was one of the first to succeed in achieving
interrupt occurs every 20s. This cor- directional radiation.
responds to 10ms for a full set of 500 In 1909, Braun and Guglielmo Marconi were jointly awarded the Nobel Prize in Physics for
samples, or 1ms/div on the screen. the development of wireless telegraphy. In 1898, Braun was one of the founders of Funken-
In theory, the time increment can be telegrafieGmbH in Cologne (Germany), and 1903 he was one of the founders of the Ge-
extended to approximately 16ms. For sellschaft fr Drahtlose Telegrafie Telefunken (the Telefunken Wireless Telegraphy Company)
in Berlin. He died on 20April 1918 in New York (USA) as a result of an accident.
this purpose, the main routine must set
the Timebase to the appropriate value
and then start Timer1. In addition, val-
ues must be assigned to the following
variables: Channels (the number of are transmitted immediately, while if mits the data via the serial interface
channels desired; range 1 to 4), One- it is set to 1, the samples are stored (Listing4).
shot (record a single event), and Sav- in memory. The timer is then stopped The timer routine provides almost all
eram (intermediate storage). as soon as 500 samples have been the desired features. If more than one
If Saveram is set to 0, the samples taken. In addition, the program trans- channel is configured, the samples

4/2009 - elektor 65
projects microcontrollers

important command is 1. It starts a

1 DC
measurement session with the current Listing 7
set of parameters. The samples are first
acquired and then transmitted. The Triggering
timer is then disabled, so that a new Tim0_isr:
1 DC 10k ADC0 measurement session can be started D = Getadc(0)
by the next 1 command. Shift D , Right , 2

Another command (10) is used to con- If Trigger = 1 Then

figure the sampling interval. The pro- If D < Triggerle-
0...+15V gram receives an integer value in two vel Then Trigger = 11
End If
1 DC 10k ADC0 bytes (high byte and low byte) and If Trigger = 11 Then
assigns it to the Timebase variable as If D >= Triggerlevel Then


a negative number. Finally, there is the Stop Timer0

command 20, which is used to set the Timer1 = -1
desired number of channels. Start Timer1
End If
End If
Triggering If Trigger = 2 Then
If D > Triggerle-
Youre probably familiar with the trig-

vel Then Trigger = 12

gering functions of analogue oscillo- End If
scopes. They have lots of knobs and If Trigger = 12 Then
+5V buttons that you can play with, and If D <= Triggerlevel Then
usually you get it wrong and the screen Stop Timer0
Timer1 = -1
remains blank. This is because the trig- Start Timer1
gering condition can be set such that

7V5...+7V5 End If
it is never satisfied. For this reason, End If
1 AC 10k ADC0
its always a good idea to first make Return
a measurement without triggering.

After this, you can select the appropri-

080944 - 15 ate trigger slope and adjust the trigger The main routine now recognises two
level to obtain a visible signal. additional start commands (2 and 3)
In the worst case, a software oscillo- for triggered measurements, as well
Figure 5. Five measuring ranges.
scope can wait forever if the trigger as a command (30) for passing the
conditions are set incorrectly, with- setting of the trigger level parameter
out giving you any opportunity to cor- (Listing8). Incidentally, the first chan-
are acquired sequentially and stored rect the situation. This is certainly not nel is always used for triggering.
(Listing5). what we want, so it must be possible
All we need now is a suitable main to interact with the program while the
routine (Listing6). Its function is to microcontroller is waiting for a trigger
Measuring range
receive commands from the PC, inter- event. The obvious way to achieve this Have you noticed that theres still
pret them, and execute them. The most is to use another interrupt. No sooner something missing? Thats right
said than done: the triggering proc-
ess runs as an interrupt routine with
Timer0 (one timer was still free see
Listing 6 Listing7). Now you can adjust the trig- Listing 8
The Start command and parameters ger level live in the main routine until Trigger commands
you get it right.
Do Heres how it works: when the pro- If Command = 2 Then
Get #1 , Command gram is supposed to look for a trig- Oneshot = 1
If Command = 1 Then Adr = 1
ger, the main routine starts Timer0.
Oneshot = 1 Saveram = 1
Adr = 1 Timer0 in turn starts Timer1 when Trigger = 1
Saveram = 1 the desired event occurs. The Trigger Start Timer0
Start Timer1 control byte is set to 1 for triggering on End If
End If a positive slope (rising edge). The first If Command = 3 Then
If Command = 10 Then time that a measured value below the Oneshot = 1
Get #1 , Hi trigger threshold is found, the value of Adr = 1
Get #1 , Lo Saveram = 1
Timebase = 256 * Hi
Trigger is changed to 11. This arms Trigger = 2
Timebase = Timebase + Lo the routine for the next trigger edge. Start Timer0
Timebase = 0 - Timebase As soon as a measured value above the End If
End If trigger level occurs, the trigger timer If Command = 30 Then
If Command = 20 Then is stopped and the measuring session Get #1 , B
Get #1 , B is started. If you want to trigger on a Triggerlevel = B
Channels = B End If
negative slope (falling edge), Trigger
End If
Loop is assigned an initial value of 2 and
changes to 12 when it is armed.

66 elektor - 4/2009







1 AC CH1
10k DC
1 DC 100

10k 100
2 AC

PC1 10k DC
2 DC 100 PC0
10k ADC0 AD7
ADC1 AD6 10k DC
10k ADC7
ATmega88 10k DC
4 DC
080944 - 17

080944 - 16

Figure 6. The four inputs of the ATM18 DSO. Figure 7. Wiring diagram of the circuitry connected to the ATM18 module.

three usable states:

1. High-impedance
2. Low-impedance connection to GND
3. Low-impedance connection to VCC

They can thus be used to control a volt-

age divider. Figure5 shows the poss-
ible combinations with three resistors
and two I/O pins if the A/D analogue
input has a range of 05V. A coupling
capacitor is also necessary for true AC
measurements. Figure6 shows the
implementation using portC. The third
and fourth channels are connected to
Figure 8. AC measurement using two channels. Figure 9. Plot of the frequency spectrum
the ADC6 and ADC7 inputs and oper-
of a square-wave signal.
ate with a fixed input voltage range of
The program can be used to perform
a normal scope has several input one-shot (Single) or repetitive (Auto) single-channel measurements. By con-
ranges. One way to select input ranges measurements with a repetition rate of trast, the normal oscillograms show
is to use relays or analogue switches, two measurements per second. It also the signals plotted versus time (Time
but another option is to use the regular includes a frequency analysis (Spec- display).
I/O pins of the ATmega88 as analogue trum display) function. For meaning- (080944-I
switches. This is because they have ful results, this can only be used with

4/2009 - elektor 67
projects modding & tweaking

Rocket Engine
Test Rig
Kitchen scales make
thrust measurement a
piece of cake
Dr. Jrgen Giersch (Germany)

Electronic kitchen scales are now reasonably priced and are good
for accurately measuring cake ingredients but add this ATmega8
equipped interface card and you have a model rocket engine test
rig which displays the engines static thrust profile on a PC.
Figure 1. The test rig in operation.

Those of you who dabble in the hobby an offence to try and make one yourself. ity of model rocket engines currently
of model aircraft construction will be Commercial rocket motors are how- on the market. As a rule, a standard
aware of how important it is to know ever widely available in hobby shops set of kitchen scales will not be fitted
how much thrust an engine can gen- but they are generally supplied with with a connector to allow a PC to take
erate. This is even more true for model very rudimentary technical data, often readings but it is not be too difficult to
rocket design and construction. Model just quoting the average thrust, burn make the required modifications. With
rocket motors develop their thrust by duration and time delay to ejection. screwdriver in hand it was necessary
burning a solid propellant material Rocket constructors are sure to appre- to dismantle a low-cost set of scales
within an engine casing, the resulting ciate the test rig suggested here, com- to try to identify a point in the circuit
hot gases and combustion particles plete with PC interface it will answer where a voltage proportional to the
are expelled at high speed through an any questions they may have about the measured weight is generated.
exhaust nozzle producing thrust (Fig- burn characteristics of a model rocket
ure1). The characteristics of thrust are motor. After looking at several different mod-
not linear during the burn phase; the els it became clear that they do not all
type of fuel, the shape of the exhaust use the same measurement method.
nozzle and combustion path all con-
Thrust measurement One of the most common techniques
tribute to the thrust profile. Apart from Fortunately we do not need to look uses a bending beam type of load cell
the rocket body aerodynamics and the too far to find a suitable sensor/trans- with strain gauges bonded around a
shift in the centre of mass which occurs ducer to measure thrust. A stand- cut-out in the beam to measure bend-
during burn, the thrust characteristics ard set of electronic kitchen scales is ing (compression and extension)
have the greatest influence on a rock- able to measure a maximum weight caused by a weight placed on the
ets trajectory. of a few kilograms. 1kg here on earth scale. The electrical resistance of the
exerts a downward force of approxi- strain gauges alter as the beam bends.
In law, model rocket motors are classed mately 10Newtons. This measurement This method of measurement is ideal
as explosives so in most countries it is range will be sufficient for the major- for our application; all we need now is

68 elektor - 4/2009
a circuit to form the interface between tally mounted motor would have the
the strain gauge and PC. It was not advantage that the change in mass
possible to find a point on the existing caused by the propellant being used
circuitry to tap off measured values. up is effectively added to the thrust,
The scales use custom ICs so that all unlike our inverted engine test rig.
signals are totally encapsulated except
for the wiring to the gauge. It is there-
fore necessary for our interface circuit
Data Flow
to connect directly to the strain gauge In principle it is only necessary to
wiring. connect a DC supply across U0 of the
measurement bridge and hook up
Figure 2. The bending beam with strain gauges.
a storage scope probe across UB to
Bridge configuration record the thrust measurement. Not
The use of four strain gauges and a everyone however has access to such
bending beam is probably the most equipment and it would then be nec-
common arrangement of weight meas- essary to calibrate the display to get
urement transducer (Figure2). Two any meaningful results which can be
of the strain gauges are cemented quite laborious. A better solution is to
on the surface above a cut-out in the build this relatively simple interface
- +
beam and two along the lower surface. card which converts the kitchen scales
When a weight is placed on the scales into a thrust measurement test rig with
the beam bends, putting the top gauge a serial PC interface (Figure7). The UB+ UB-
under tension () and the bottom gauge card supplies a reference voltage U0
under compression (). The four strain to the bridge while a microcontroller,
gauges are wired in a full bridge con- together with an instrument amplifier
figuration to help compensate for tem- and an on-board A/D converter sam- + -
perature effects and give good meas- ples the voltage at UB and sends the
urement accuracy (Figure3). digitised values to a PC over a serial U0-
080027 - 12
A DC supply voltage is applied to The circuit diagram is shown in Fig-
opposite corners of the bridge (U0+ ure8. The microcontroller at the heart Figure 3. Four strain gauges arranged in a full bridge
and U0) while the voltage difference of the circuit is an ATMEL ATmega8, configuration (+ = tension, = compression).
measured between the other two cor- which reads the analogue signal on its
ners (UB+ and UB) is proportional to ADC4 input pin. The value is contin-
the beam loading. In the kitchen scales ually sampled and digitised with 10-
the wires to these four points are bit resolution. The hexadecimal value
brought out to a connector (Figure4) of each sample is sent over the serial
so that they can be connected to an interface and the ASCII value for car-
external interface circuit. A four-pole riage return (CR) is appended to each
switch connected in between enables sample. This process repeats in a con-
the scales to be switched back to their tinuous loop achieving a sample rate
normal operational mode (Figure5) for of approximately 3kSamples/s. RS232
mom to use. to TTL signal level conversion for the
serial interface is performed (as ever)
It is possible to purchase a bending by a MAX232 interface driver.
beam type load cell from a special-
ist transducer supplier (try Googling
strain gauge, load cell and bending
Boosting the signal Figure 4. Mounting the 4-pole switch and 4-pin mini DIN
beam). However the cost of these com- It is often said that any piece of test
ponents individually is more than buy- equipment is only as good as its
ing a complete set of kitchen scales. signal amplifier. Any non-linearity
The advantage would be that you can means that you are not just meas-
use the technical data sheets to select uring the signal under test but also
a load cell better suited to your par- imperfections in the test equipment
ticular application. Better temperature signal path. The design of the ampli-
stability, linearity or higher load capac- fier between the strain gauge bridge
ity may all be important considera- and the A/D converter is therefore
tions. A high-quality commercial exam- important. It is required to boost the
ple which can measure up to 300N is small signal generated by the change
shown in Figure6. The shape of the in resistance of the bridge up to the
sensing beam positioned between the input voltage range of the A/D con-
upper and lower plates allows meas- verter (a few volts). The change in
urement of both vertical and horizon- gauge resistance caused by typical
tal forces. Measuring thrust with this beam deflections is in the order of Figure 5. The switch allows the scales to revert back to normal
type of load cell and with a horizon- a few parts per thousand. Using a weighing duties.

4/2009 - elektor 69
projects modding & tweaking

bridge supply voltage of a few volts corresponding change in the value of

this means that the bridge output the filter capacitor.
signal will be in the millivolts (mV)
range. Before the sensor signal can A second low-pass filter formed by
be digitised in the A/D converter it R8 and C5 on the output of the instru-
will therefore need to be amplified by ment amplifier has a cut-off frequency
a factor of three orders of magnitude. of approximately 3kHz and serves to
Anyone wishing to measure smaller further attenuate any noise signals.
values of thrust more accurately Again any change in the sampling rate
would require additional amplifica- will require the filter to be changed
tion. With this high level of amplifica- accordingly.
Figure 6. This commercial bending beam strain gauge
tion it is important to pay attention to Use shielded wiring such as S-video
measures both horizontal and vertical force.
reducing noise in the circuit. Capaci- cable between the scales and interface
tor C18 at the circuit input together card. Keep the cable length to a mini-
with the internal impedance of the mum to reduce electrical noise pickup.
strain gauge bridge form a low pass The cable is terminated with mini DIN
filter. A typical value of bridge resist- connectors. The pin layout for this con-
ance is a few hundred ohms which nector is given in Figure9 shown from
together with C18 (100nF) gives the soldering-side.
an upper cut-off of several kilohertz
which is suitable for the sample rate Amplification of the strain gauge signal
used here. To check the strain gauge is performed by an instrument ampli-
impedance short together points U0+ fier type AD620AN. This IC is specifi-
and U0- and measure between UB+ cally designed to operate with a bridge
and UB- with an ohmmeter. When for sensor and has a low-noise figure. The
any reason a different sampling rate is amplifier gain is set with just a single
Figure 7. The finished test rig.
used it would be necessary to make a resistor (see data sheet). A charge-


R8 R6
C8 C12


2 K2
100n 100n
16 V+ 1
C1+ C13 1
20 7
IC5 6
C1 1
1 2 12 13
28 3 11 14
27 4 9 8
4 8 R4 S2 26 5 10 7
VS RG 12 PC3(ADC3) PD3(INT1) C15 T2IN T2OUT 4
R3 25 6 4
IC3 27 PC2(ADC2) PD4(XCK/TO) C2+ C14 9
P1 5 R2 24 11
REF 56 PC1(ADC1) PD5(T1) 100n MAX232 5
R1 23 12 15 5
AD620 120 PC0(ADC0) PD6(AIN0) C2 1
7 1 13 V-
10k 6
IN +IN ATmega8-P C17
2 3 PB0(ICP)
C18 15 K4
PB1(OC1A) 1
16 1 2
100n 17 3 4
K1 4 18 5 6
21 19 7 8
9 10
22 9 10 8
D1 X1

1N4148 22
VCC C5 C11 C7 C10 C9
IC1 8
S1 7805T 47n 100n 100n 18p 18p VCC
2 6
C6 IC4

BT1 1 5
9V C1 C2 C19 100 LT1054 VCC
4 7
470n 100n 1 C3


080027 - 11

Figure 8. The circuit diagram.

70 elektor - 4/2009
tem. Jumper JP1 allows both types of
pump IC type LT1054 is used to pro- adapter to be accommodated.
duce the negative supply rail for the 3 4
amplifier. Preset P1 is used to null any
quiescent voltage offset in the bridge
2 1 Software
output. Measurement data is sent over a serial
1 = UB+ 3 = U0- interface cable to a PC (or to a USB
2 = UB- 4 = U0+
port if a suitable USB/RS232 adapter
Measurement range is used, e.g. the Keyspan High Speed
The signal amplifier IC uses four resis- USB Serial Adapter USA-19HS [4]). A
tors R1 to R4 selected by the four-posi- conversion program running on the PC
Figure 9. Pinouts of the mini DIN connector (viewed from
tion switch S2 to select one of four lev- reads the ASCII characters. The author
solder side).
els of gain. The resistor values chosen has written the program in LabView
give switchable values of amplification and the .exe file can be downloaded
in the range from 400 to 4000 times from the Elektor website (Figure10).
(these values proved useful for meas- authors PCB layout files are available The digitised measurement values
uring standard rocket motors with the for download from the Elektor web- have an accuracy based on the resolu-
OTC KV 2001 model of kitchen scales site [2]. The PCB dimensions and posi- tion of the A/D converter and must be
used in the prototype by the author). tion of the mounting screw holes are scaled to take into account the bridge
The resistor values can of course be designed to fit in a translucent plas- supply voltage and the constant of
changed if you require some other gain tic enclosure type 2515KL made by proportionality of the strain gauge.
values. Metal-film resistors are recom- Strapubox. In practice it will be necessary to null
mended throughout to help minimise All of the project files can be freely any offset caused by manufacturing
noise. downloaded from the Elektor website tolerances in the bridge strain gauge
In order for the analysis software run- [2]. The same for a free supplementary resistance and the mass of the weigh-
ning on the PC to be aware of the document covering the operation of the ing platform itself. The offset can be
position of the amplification selector analysis software. The connector K4 nulled with preset P1; each change
switch the second pole of this switch allows in-system programming (ISP) in range requires readjustment. The
is used to ground one sof tware includes a
of the port pins of PC0 method of calibrating
to PC3. These four pins the scale using known
are configured in soft- reference weights. This
ware as inputs with allows any zero offset to
pull-up resistors; only be nulled, and also the
one pin will be pulled constant of proportional-
low depending on the ity for the load measure-
measurement range ment transducer to be
selected. ascertained.
The ATmega8 generates
a 10-bit digital value for After calibration the soft-
each sample then adds ware can plot the entire
two bits to indicate the burn phase of the engine
selector switch position. showing force against
This is converted into time. The results of each
three hexadecimal val- test can be stored for
ues which are then sent more detailed analy-
over the serial interface sis later on. A descrip-
to the PC as ASCII char- tion of this software can
acters. Together with be downloaded from
the CR character which the project pages [2] (a
terminates each sample LINUX version is also
this gives four ASCII available on request from
characters for each Figure 10. The authors analysis program. the author [5]).
sample. An advantage (080027-I)
of using ASCII coding is
that the values can be displayed on a of the controller firmware. The connec-
PC by running a simple terminal emu- tor pin definitions follow the standard
Internet Links
lator program. layout which is compatible for exam- [1]
ple with the STK200 AVR starter kit data_sheets/AD620.pdf
made by Kanda [3]. While many pro- [2]
Construction gramming adapters use this ISP con- [3]
For the sake of simplicity and ease of vention their use of the Vcc connection html
construction a single-sided PCB has is not consistent. Some adapters are
been developed which does not use powered by the target system while
any SMD packaged components. The others supply power to the target sys- [5]

4/2009 - elektor 71
projects design tips

Macros for ASM programming

Gert Baars (The Netherlands)

Through the use of directives found in the in- has to be called a number of times, where Enxt:
tegrated assembler (version2) of AVR Studio they can be replaced by a macro using an .endm
we can create instructions using macros that explanatory name. When there is a larger ;********************************
make it possible to have structured program- number of instructions, a subroutine is nor-
ming similar to that found in C or Basic. In mally used instead. The macros can be used in the following
computer science a macro is a set of instruc- manner:
tions that can be assigned a unique name. It becomes possible to make your own instruc-
In the program this set of instructions can be tion with the help of macros, as weve done For r16,0,movedata
called using this name (this is not the same in the previous example. It is also possible lpm r0,Z+
as a sub-routine where a set of instructions is to define other instructions, such as Repeat- st Y+,r0
called by jumping to its address). Until or if-then-else constructions, which For
When a macro is called the set of instructions are often found in higher-level languages.
following the name of the macro is inserted Here well give an example of the construc- r21
at the location where the macro is called. A tion of a For-Next macro. The For macro re- eor
macro can only be called during the assem- quires three parameters: a register for use as r21,r18
bly of the source and never during the execu- a counter, a constant for the initial value of Next
tion of the program. The following example the counter and a label with a unique name. r20,245,nxloop
illustrates this. This label has been added to enable the nest- Next r16,255,movedata
ing of macros. The macro assigns the initial
First we define the macro: value to the counter and gives the address of Because of the additional labels the instruc-
the next instruction to lbl. tions can be nested in combination with other
.Macro swap macros. Indenting the lines creates a clearer
push @0 ;******************************** structure as is often seen in for example Pas-
mov @0,@1 ; FOR cal and C. It is somewhat unusual to add
pop @1 ; structure to assembly language in this way,
.endm ; Usage: FOR <reg>,<k>,<lbl> but it almost becomes second nature when
; reg = r16..r31
you use these macros.
; k = initial value
The terms @0 and @1 used here are mac- ; lbl = any name (but the Another example of a macro where a clear
ro parameters that are passed to the macro same as that used in Next) structure appears is the if-then-else macro.
when it is called. In this case they are two The following example illustrates that the use
registers. The macro can now be called from ;******************************** of indentations with nesting also creates a
anywhere in the programs source code to clear structure, as is often found in higher-
swap the contents of two registers. As an .Macro For level languages.
example: ldi @0,@1
.set @2 = PC if r17,he_,19
lsr r17 .endm begin label
; first a few arbitrary ;******************************** nop
lines of the source nop
add r17,r18 nop
The accompanying Next macro has the same
swap r17,r16 end label
parameters as the For macro, but here the
; and this is where the macro
is called with registers constant holds the final value of the counter. else lz2
r17 and r16 This macro increases the counter by one and if r17,eq,r18
then compares it with the final value. As long begin nxt_
When the code is assembled the macro defi- as the value of the counter is smaller, the pro- nop
nition is put in place of the macro. Once its gram jumps back to the address immediately end nxt_
been interpreted, the source code where the following the For macro.
macro was now looks as follows: else nn12
;******************************** mov r17,r18
lsr r17 ; Next inc r16
; first a few arbitrary ; end nn12
lines of the source ; Usage Next <reg>,<k>,<lbl>
add r17,r18 ; reg = r16..r31 nop
push r17 ; k = final value nop
; swap r17,r16 has ; lbl = any name (but the end lz2
been replaced according same as that used in For)
to the macro definition We cant really think of any disadvantages,
mov r17,r16 ;******************************** except that labels have to be used with the
pop r16 begin and end instructions. Although these
.Macro Next labels can be given any name, if we use
The reason for using macros is that they inc @0 names that are appropriate to the function of
make the source code easier to read, espe- cpi the code, theyll even improve the readabil-
cially because the name given can identify ity of the code when it is referred to again
breq Enxt
their purpose. Macros are particularly useful rjmp @2 at a later date.
in cases where a small number of instructions (070888-I)

72 elektor - 4/2009
design tips projects

Protection for voltage regulators

Ton Giesberts age of a voltage regulator to drop
(Elektor Design Labs) VI VO D1 quicker than the output voltage, for
In many cases, the load con- example when there is a protec-
nected to a voltage regulator is not D1
A78Lxx tion circuit which shorts the input
returned to ground but to an even VI VO
power supply voltage as a result of
lower voltage or perhaps even the an overvoltage at the output.
negative power supply voltage
(here we make the assumption If the output voltage of the regula-
of using positive voltages; when tor is more than 7V higher than
using voltage regulators with neg- the input voltage then the emit-
ative output voltages the reverse is ter-base junction of the internal
080943 - 12
080943 - 11
true). 1 2 power transistor can break down
and cause the transistor to fail.
Opamps, level-shifters, etcetera Polarity inversions which could (well, minus 0.7V, to be accurate). To prevent this condition a shunt
come to mind. In such cases, a occur, for example, during power A short-circuit proof voltage regu- diode can be used (see Figure2).
diode (1N4001 or equivalent) on or during a short circuit could lator (such as the 78xx series) sur- This ensures that any higher volt-
connected across the output of the prove fatal for the regulator IC, but vives such a situation without any age at the output of the regulator
regulator IC usually provides suf- such a diode prevents the output problems. is shorted to the input.
ficient protection (see Figure1). of the IC going lower than ground It is also possible for the input volt- (080943-I)

elektor 2008 dvd news

New Annual DVD 2008 Harry Baggen (Elektor Netherlands Editorial)

Elektor annual vol- another operating system, find the sub folders that now appears there
ume is published file index.html in the root of the will be the folder named \articles.
on a DVD instead DVD file structure and double-click This folder contains a number of
of the usual CD. this file. The default browser will sub folders with are named 1998
Up till now all open and display the start page. through 2008. The folder named
the articles were First select the desired language. 2008 is already filled with the
published in four By ticking the box at the bottom articles from last year. If you have
languages: Dutch, of the page, the selected language older annual CDs then you can
German, Eng- will be stored in a cookie and the copy the pdf files from those CDs to
lish and French. next time the program is started up the folders with the corresponding
Beginning last it will start automatically with the year. For the 2005 annual CD you
year a Span- selected language. Should you go to sub folder articles and then
ish version was want to change the language after to sub folder E. In this folder select
added. All of this that, then click on the Elektor logo all files that have the pdf exten-
together no longer to return to the start page. sion and drag these to the folder
Elektors new annual DVD 2008 fits on a disk with a capacity of The features and usage of the DVD C:\Elektor\uk\articles\2005. If
appeared at the same time as the 650MB. Because changing to a are identical to last years version, the question pops up whether to
March 2008 issue. The DVD con- DVD immediately increases the so we do not need to say much overwrite the existing files, answer
tains all the articles published dur- available capacity to 4.7GB, this about that. There is also an index with Yes (to all). This is because all
ing the previous year in pdf for- also gave us a great opportunity to function for older annual volumes, these annual folders already con-
mat. Since our magazine is pub- improve the quality of the pdf files so that you can easily find older tain a number of dummy pdf files,
lished in an increasing number of compared to those of last year. The articles. It is possible to copy all which will now be overwritten with
languages, the capacity of a CD result is a disk, containing Elektor the articles from the annual CDs the actual articles.
is now insufficient to store them all in 5 languages, with a total file since 1998 to the hard disk. This
on one disk. size of about 2.2GB. saves you from having to change In this way you can combine the
The structure of the annual DVD is the CD all the time. contents of the older annual CDs
The annual CDs from Elektor are unchanged from last years CD. starting from 1998 into the new
a very convenient way of storing You only need and Internet browser From the hard-disk system. If, when you are search-
all the issues of Elektor and search which can use ActiveX or a compu- Make a folder on you hard disk ing for an old article, you arrive
through all of them quickly, without ter which has the Java environment (for example C:\Elektor). Copy the at an article that you do not have,
the need to store stacks of paper installed. Also make sure that these entire contents from the 2008 DVD then you will have the opportu-
and thumbing through many pages. are enabled in your browser. to this folder on your hard disk. nity to click through to the Elektor
Any particular article is located The folder \Elektor now contains website where you will have the
very quickly and displayed on the The DVD has an auto-start func- five sub folders. Click the folder option of buying and download-
screen using Adobe Reader. tion for Windows computers. for the desired language (in our ing the article.
This is the first time that the entire If this doesnt work, or you use case \uk). At the top of the list of (090170-I)

4/2009 - elektor 73
infotainment puzzle

Hexadoku Puzzle with an

electronics touch
Sure, weve said it before: puzzle solving is good for brain stimulation. A Hexadoku is just the ticket
its free, fun and represents a mental challenge if solved the hard way. So put your grey matter to
work! All correct solutions we receive enter a prize draw for an E-blocks Starter Kit Professional and
three Elektor Shop vouchers. Have fun!
The instructions for this puzzle are straightforward. number of clues are given in the puzzle and these determine the
start situation.
In the diagram composed of 1616 boxes, enter numbers All correct entries received for each months puzzle go into a
such that all hexadecimal numbers 0 through F (thats 0-9 and draw for a main prize and three lesser prizes. All you need to
A-F) occur once only in each row, once in each column and in do is send us the numbers in the grey boxes. The puzzle is also
each of the 4x4 boxes (marked by the thicker black lines). A available as a free download from the Elektor website

Solve Hexadoku and win! PARTICIPATE!

Correct solutions received from the entire Elektor readership Please send your solution (the numbers in the grey boxes) by email to:
automatically enter a prize draw for an - Subject: hexadoku 04-2009 (please copy exactly).

E-blocks Note: new email address as of this month!

Include with your solution: full name and street address.
Starter Kit Alternatively, by fax or post to: Elektor Hexadoku

Professional Regus Brentford - 1000 Great West Road - Brentford TW8 9HH
United Kingdom - Fax (+44) 208 2614447
worth 300 The closing date is 1 May 2009.

and three
Vouchers worth The solution of the February 2009 Hexadoku is: 3097D.
40.00 each.
The E-blocks Starter Kit Professional goes to:
We believe these prizes Davy Van Belle (Belgium).
should encourage An Elektor SHOP voucher worth 40.00 goes to:
all our readers to participate! Andrs Tabernero Garca (Spain); Hans-Jrg Bning (Ger-
many); Dudley Nichols (UK).
The competition is not open to employees of Elektor International Media,
its business partners and/or associated publishing houses. Congratulations everybody!

74 elektor - 4/2009
Elektor? Prescribed reading for
our R&D staff because thats where
we need professional guidance for
microcontroller technology.
Frank Hawkes, 39, development engineer

Electronics at all the right levels

Secure a head start in electronics

with a subscription!

Advantages to subscribers

Cheaper than 11 issues from the newsstand

lcom With every issue subscribers get up to 40% discount
- i n - 1 we yer,
3 la

FREE B MP3 p on selected Elektor products
i f t : 2G a n d
S B Stick der
r As a welcome gift you get a free 2GB MP3 player
Voice worth 31.50
No queues, travelling, parking fees or sold out;
Elektor is supplied to your doorstep every month
Always up to date read your copy before
everyone else
ING-UK-2 Tel. +44 (0) 20 8261 4509

electronics worldwide
Or use the subscription order form near the end of the magazine.
infotainment retronics

1 2

An old radio brought back to life

Joseph Kreutz (Germany) far from being exhaustive. A used for these markings usually shock, and you really cant take
few hours spent exploring the becomes sticky or fragile as it any risks! In the case of the Tel-
A two page instalment of Retron- Internet is bound to turn up a ages, and any attempt to clean efunken T33BRFS, the valve
ics this month, originally written lot more information, and will it ran the risk of destroying them heater voltage is tapped off the
in French. Ed. get you in touch with a fraternity for good. The turntable fitted to primary of the transformer (!)
marked by cheerful comradeship the receiver was also given a whose secondary provides the
My colleague Giancarlo came and old fashioned gentlemanly thorough cleaning. The original HT supply.
into my office telling me hed behaviour for the most part. rubber belt had gone hard and
picked up an old valve radio was unusable. Luckily enough, I The first operation was to replace
that had been sitting for ages After several decades in the was able to find a substitute for all the electrolytic capacitors.
in his parents kitchen. It wasnt kitchen, the inside of the radio it. I couldnt find out the make These components dont last
working any more, and he was covered with a thick layer of and type of the crystal cartridge long, and typically fail after 20
asked me if it was possible to dust (photos1, 2, 3) and the fitted, and we werent able to or 30 years owing to degenera-
get it going again. I asked him varnish on the cabinet had been find any replacement styluses. tion, deformation or drying out
to bring it to me. The patient I dulled by a film of grease. So the Once Id finished these cosmetic of the electrolyte inside. The dial
had to revive was a Telefunken first thing I had to do was dust operations, I was able to turn to lamps were changed and the
model T33BRFS in a wooden out the receiver using a paint- the electronics (photo5). receiver powered up. The glow
cabinet, fitted with a turntable, brush and a vacuum cleaner of the valve heaters showed
and made in Italy around 1953. (photo4) Once this had been As always, safety first! Valves typi- they were working but there
Lots of Internet sites offer circuits done, I removed the turntable cally operate at voltages between was no sound coming out of
for these old receivers [1][2], so and withdrew the chassis so I 150 and 300V, and instead the loudspeaker. The voltmeter
I had no trouble getting hold could clean it carefully, taking of having power transformers, showed the HT supply to be at
of one for it. The Internet also care not to rub off the mark- many of these old receivers are its nominal value. Closer inves-
enabled me to download the ings on the components. I also supplied directly from the AC tigation revealed that one of the
datasheets for the valves it was cleaned the grease off the cabi- power line. Even with the ones power resistors in the supply rail
fitted with [3]. Surprisingly, cer- net using isopropyl alcohol. I left that do have a transformer, you was open-circuit. Replacing this
tain firms still sell hardware for the glass dial bearing the names never know if it may not have brought the receiver back to life.
valve radios, among them [4]. of the stations and frequency an insulation fault. So theres a The UM35 magic-eye tuning
Of course, these websites are indications well alone. The paint real danger of getting a nasty indicator had lost its brightness,

5 6

76 elektor - 4/2009
3 4

so a new tube was fitted. All that the receiver supply in those developed it based themselves Internet Links
now remained to be done was days, such a precaution was not on an intimate knowledge of the and References
to re-align the IF stage for best considered necessary. For safe- laws of physics, and their sole [1]
selectivity. But here, a nasty sur- tys sake, two fuses were added resources were a sheet of paper, [2]
prise was awaiting me the into the power line cables. Fol- a pencil, their slide-rule and
adjustable cores of the IF trans- lowing this rejuvenation, the lots of bright ideas. A long way
formers were secured using receiver is now sitting in my col- from the digital methods now- [4]
a little strip of rubber, which leagues flat, where I trust it will adays that mean our computers [5] Electronics Classics, Collect-
had hardened with age. It was continue to give good, loyal ser- can find the solutions to complex ing, Restoration and Repair (sec-
impossible to loosen the cores vice for several more years yet. problems in just a few minutes. ond edition). Andrew Emmerson,
with causing damage, so the Newnes (ISBN 0-7506-3788-9).
adjustment could not be made These old broadcast receivers Finally, this story covers the way [6]: Valve Radio & Audio Re-
. As the receiver was already have just as much of the charm the radio was made to operate pair Handbook. Chas E. Miller,
functioning very satisfactorily, of objects steeped in history as again no attempt was made Newnes (ISBN 0-7506-3995-4).
we left things as they were. All old items of furniture. And restor- to do a full restoration job. Sev-
that remained was to adjust the ing them can be very educational eral excellent books are avail-
RF and local oscillator stage to too. When they were made, the able on restoring vintage radios
maximize the sensitivity and to engineers had to come up with and other venerable audio (1)
Editors note: apply a drop of
make sure that the dial indica- an optimum but economically- equipment; [5] and [6] are highly baby oil to the top of each ferrite
tions corresponded to the fre- viable result using just five or recommended. core and allow the oil to travel
quency actually being received. six active components. A far (081140-I) down along the core thread. When
cry from todays MP3 players the oil emerges at the underside,
Now it was time to reassemble with tens of millions of transis- heat up the core gently with a blow
the receiver (photos6, 7, 8). tors that fit in your pocket dryer and attempt to loosen it with
The chassis and turntable were Of course, valve technology is two non-metallic adjustment
fitted back into the cabinet and obsolete but dont think of tools accurately fitting the slots
the connections re-made. The it as being more primitive than provided, turning simultaneously
manufacturer hadnt provided transistor technology. Quite the at the top side and underside of
any short-circuit protection for reverse the engineers who the core.

Retronics is a monthly column covering vintage electronics including legendary Elektor designs. Contributions, suggestions and requests are
welcomed; please send an email to

7 8

4/2009 - elektor 77
To book your showcase space contact Huson International Media
Tel. 0044 (0) 1932 564999 Fax 0044 (0) 1932 564998

USB has never been so simple... USB powered, 4 relays + 4 DIO channels FTDI designs and sells
with our USB to Microcontroller Interface cable. Will switch 240VAC @ 10 amps USB-UART and USB-FIFO
Appears just like a serial port to both PC and Screw terminal access interface i.c.s.
Microcontroller, for really easy USB connection to LabVIEW, VB, VC Complete with PC drivers,
your projects, or replacement of existing RS232 Free shipping these devices simplify the task of designing or
interfaces. From 38 upgrading peripherals to USB
See our webpage for more Design & supply of USB, USB Wireless,
details. From 10.00. Ethernet & Serial, DAQ, Relay & DIO card

EASYSYNC World leaders in Driver-Free USB ICs:
Beta layout Ltd Award-
EasySync Ltd sells a wide USB-UART/SPI/I2C bridges
winning site in both
English and German range of single and multi- TEAleaf-USB authentication dongles
offers prototype port USB to RS232/RS422 expandIO-USB I/O USB expander
PCBs at a fraction of the cost of the usual and RS485 converters at competitive prices. USB-FileSys flash drive with SPI interface
manufacturers prices. USB-DAQ data logging flash drive
BYVAC device programmer manufacturer
USB to I2C selling through contracted
Microcontrollers distributors all over the world Vocational training and education
Forth universal and dedicated device programmers for national qualifications in
Serial Devices excellent support and after sale support Electronics Engineering and
free SW updates Information Technology (BTEC First National,
reliable HW Higher National NVQs, GCSEs and GCEs). Also
C S TECHNOLOGY LTD once a months new SW release Technical Management and Languages. three years warranty for most programmers
Low cost PIC prototyping kits, PCB's and
GPS/GSM, radio equipment and manuals.
PCB design and PIC program development.
Microchip Professional C LCDMOD KIT
and Assembly
Worldwide On-line retailer
Programming Courses.
Electronics components
DECIBIT CO.LTD. The future is embedded.
SMT chip components Microchip Consultant / Training Partner developed
Development Kit 2.4 GHz USB interface LCD
Transceiver nRF24L01 Kits & Accessories
Distance learning / instructor led
AVR MCU ATmega168 PC modding parts
Assembly / C-Programming of PIC16, PIC18,
LCD modules
PIC24, dsPIC microcontrollers
Foundation / Intermediate
Professional product development services. FLEXIPANEL LTD MQP ELECTRONICS
Marine (Security, Tracking, Monitoring & control)
Automotive (AV, Tracking, TEAclippers - the smallest Low cost USB Bus Analysers
Gadget, Monitoring & control) PIC programmers in the world, High, Full or Low speed captures
Industrial (Safety systems, from 20 each: Graphical analysis and filtering
Monitoring over Ethernet) Per-copy firmware sales Automatic speed detection
Telecoms (PSTN handsets, GSM/GPRS) Firmware programming & archiving Bus powered from high speed PC
AudioVisual ((HD)DVD accessories & controllers) In-the-field firmware updates Capture buttons and feature connector
Tel: +44 (0)1872 223306 Protection from design theft by subcontractors Optional analysis classes

78 elektor - 4/2009
products and services directory
Build your own Robot!
USB Instruments specialises
Fun for the whole family! in PC based instrumentation
MeccanoTM Compatible products and software such
Computer Control as Oscilloscopes, Data
OBD2CABLES.COM Radio Control Loggers, Logic Analaysers Tank Treads which interface to your PC via USB.
Thousands of OBD cables and connectors in Hydraulics
stock Internet Technical Bookshop,
Custom cable design and manufacturing 1-3 Fairlands House, North Street, Carshalton, VIRTINS TECHNOLOGY
OBD breakout boxes and simulators Surrey SM5 2HW
Guaranteed lowest prices email: Tel: 020 8669 0769 PC and Pocket PC based
Single quantity orders OK virtual instrument such
Convenient online ordering as sound card real time
Fast shipping SCANTOOL.NET oscilloscope, spectrum
Visit our website, or email us at: analyzer, signal generator, offers a complete line multimeter, sound meter,
of PC-based scan tools for under 50. distortion analyzer, LCR meter.
1 year unconditional warranty Free to download and try.
90 day money back guarantee
For use with EOBD compliant vehicles
ROBOT ELECTRONICS Fast shipping CANDO CAN BUS ANALYSER Compatible with a wide range
Advanced Sensors and Electronics for Robotics of diagnostic software USB to CAN bus interface
Ultrasonic Range Finders Visit our website, or email us at: USB powered
Compass modules FREE CAN bus analyser S/W
Infra-Red Thermal sensors Receive, transmit & log.
Motor Controllers CAN messages
Vision Systems ISO11898 & CAN
Wireless Telemetry Links
Embedded Controllers 2.0a/2.0b compliant
Rugged IP67 version available


Elektor Electronics has a feature to help For just 242 + VAT (22 per issue for image - e.g. a product shot, a screen shot
customers promote their business, eleven issues) Elektor will publish your from your site, a company logo - your
Showcase - a permanent feature of the company name, website address and a choice
magazine where you will be able to showcase 30-word description
your products and services. For 363 + VAT for the year (33 per Places are limited and spaces will go on
issue for eleven issues) we will publish a strictly first come, first served basis.
the above plus run a 3cm deep full colour So-please fax back your order today!

I wish to promote my company, please book my space:

Text insertion only for 242 + VAT Text and photo for 363 + VAT
NAME: ..................................................................................................... ORGANISATION: .......................................................................................
JOB TITLE: ......................................................................................................................................................................................................................
ADDRESS: .......................................................................................................................................................................................................................
................................................................................................................... TEL: ..............................................................................................................
COMPANY NAME .........................................................................................................................................................................................................
WEB ADDRESS ..............................................................................................................................................................................................................
30-WORD DESCRIPTION .............................................................................................................................................................................................

4/2009 - elektor 79

Going Strong
A world of electronics From LED to graphical LCD

from a single shop! Universal Display Book

for PIC Microcontrollers
This book begins with simple programs to

flash LEDs, and eventually by stages to use

other display indicators such as the 7-seg-

ment and alphanumeric liquid crystal dis-

plays. As the reader progresses through the
book, bigger and upgraded PIC chips are
introduced, with full circuit diagrams and
source code, both in assembler and C. A
tutorial is included using the MPLAB program-
ming environment, together with the PCB
design package and EAGLE schematic to
enable readers to create their own designs.

192 pages ISBN 978-0-905705-73-6

23.00 US $46.00

Limited Period Off
for Subscribers!
pril Silent alarm, poetry box, night buzzer and more

PIC Microcontrollers
Fully elaborated electronics projects
Learn by doing
This Circuits
book covers a series of
C Programming for Embedded Microcontrollers exciting
The presentand tenth
fun projects
editionwithof the PICpopular

New microcontrollers become available every year and old ones become redundant. The one controllers.
30x CircuitsYouseries
books more oncethan
thing that has stayed the same is the C programming language used to program these micro- projects
containsfor a comprehensive
your own use. The variety
clear expla-
of cir-
controllers. If you would like to learn this standard language to program microcontrollers, then nations,
cuits, sub-circuits,
schematics, tips
and pictures
tricks and
of each
this book is for you. No programming experience is necessary! Youll start learning to program project
sign ideason afor
electronics.make Among thismany
a fun
from the very first chapter with simple programs and slowly build from there. Initially, you pro- activity.
other inspiring
The technical
the followinginfor- cat-
gram on the PC only, so no need for dedicated hardware. This book uses only free or open source mation
egories in are
explainsin thiswhy
software and sample programs and exercises can be downloaded from the Internet. Although project
test & measurement;
is set up the wayRF it is,(radio);
this book concentrates on ARM microcontrollers from Atmel, the C programming language ap- use
of datasheets.
and peripherals;
Even afteraudio youve
& video;
plies equally to other manufacturers ARMs as well as other microcontrollers. This is an ideal all
the and
it will still
be a valuable
book for electronic enthusiasts, students and engineers wanting to learn the C programming reference
home & garden;
guide toetcetera.
keep next to your PC.
language in an embedded environment!
432 pages ISBN 978-0-905705-70-5
324 pages ISBN 978-0-905705-80-4 32.50 US $52.00 27.95
19.95 US $55.90

Prices and item descriptions subject to change. E. & O.E

80 elektor - 4/2009

45 projects for PIC, AVR and ARM A DIY system made from recycled components 110 issues, more than 2,100 articles

Microcontroller Design your own DVD Elektor 1990

Systems Engineering Embedded Linux through 1999
This book covers 45 exciting and fun Flow- control centre on a PC This DVD-ROM contains the full range of
code projects for PIC, AVR and ARM This book covers a do-it-your-self system 1990-1999 volumes (all 110 issues) of
microcontrollers. Each project has a clear made from recycled components. The Elektor Electronics magazine (PDF). The
description of both hardware and software main system described in this book re- more than 2,100 separate articles have
with pictures and diagrams, which explain uses an old PC, a wireless mains outlet been classified chronologically by their
not just how things are done but also why. with three switches and one controller, dates of publication (month/year), but
As you go along the projects increase in and a USB webcam. All this is linked to- are also listed alphabetically by topic.
difficulty and the new concepts are ex- gether by Linux. This book will serve up A comprehensive index enables you to
plained. You can use it as a projects book, the basics of setting up a Linux environ- search the entire DVD. The DVD also con-
and build the projects for your own use. ment including a software develop- tains (free of charge) the entire The Elek-
Or you can use it as a study guide. ment environment so it can be used as tor Datasheet Collection 15 CD-ROM
a control centre. The book will also guide series, with the original full datasheets of
329 pages ISBN 978-0-905705-75-0
you through the necessary setup and semiconductors, memory ICs, microcon-
29.00 US $58.00
configuration of a webserver, which will trollers, and much more.
be the interface to your very own home
ISBN 978-0-905705-76-7 69.00 US $109.00
control centre. All software needed will
be available for downloading from the
Elektor website.

234 pages ISBN 978-0-905705-72-9

24.00 US $48.00

More information on the

Elektor Website:
Connect your mouse into new embedded applications Bestseller!
Mouse Interfacing All articles published in 2008
This book describes in-depth how to con- Elektor
nect the mouse into new embedded ap- DVD Elektor 2008
Regus Brentford

plications. It details the two main interface This DVD-ROM contains all editorial arti-
methods, PS/2 and USB, and offers ap- 1000 Great West Road cles published in Volume 2008 of the
plications guidance with hardware and Brentford English, Spanish, Dutch, French and Ger-
software examples plus tips on interfacing man editions of Elektor magazine. Using
the mouse to typical microcontrollers. Adobe Reader, articles are presented in
A wide range of topics is explored, includ- United Kingdom the same layout as originally found in
ing USB descriptors, a four-channel, Tel.: +44 20 8261 4509 the magazine. The DVD is packed with
millivolt-precision voltage reference and features including a powerful search en-
Fax: +44 20 8261 4447
a variety of examples all with fully docu- gine and the possibility to edit PCB layouts
mented source-code. Email: with a graphics program, or printing hard
copy at printer resolution.
256 pages ISBN 978-0-905705-74-3
26.50 US $53.00 ISBN 978-90-5381-235-8 17.50 US $35.00

4/2009 - elektor 81

Modern technology for everyone
M16C TinyBrick with Special Effects
FPGA Course (March 2009) (December 2008)
FPGAs have established a firm position in
the modern electronics designers toolkit. A TinyBrick is a small self-contained mi- If you fit a line of LEDs on a circular PCB
Until recently, these super components crocontroller module fitted with a power- and power them on continuously, they
were practically reserved for specialists in ful Renesas 16-bit M16C microcontroller. generate rings of light when the board is
high-tech companies. The nine lessons A BASIC interpreter is installed in the spun. If you add a microcontroller, you
on this courseware CD-ROM are a step module to simplify software develop- can use the same set of LEDs to obtain a
by step guide to the world of Field Pro- ment. Beginners will find it an ideal start- more interesting effect by generating a
grammable Gate Array technology. Sub- ing out point while more experienced virtual text display. The article also de-
jects covered include not just digital logic users will appreciate its power and con- scribes a simple technique for using the
and bus systems but also building an venience. With this evaluation board (to- Earths magnetic field to generate a syn-
FPGA webserver, a 4-channel multimeter gether with a TinyBrick) you can build an chronisation pulse. The potential appli-
and a USB controller. The CD also con- intruder alarm that sends SMS texts. cations extend from rotation counters to
tains PCB layout files in pdf format, a an electronic compass.
Quartus manual, project software and Kit of parts incl. TinyBrick-PCB with SMD
various supplementary instructions. parts and microntroller premounted plus Kit of parts incl. SMD-stuffed PCB and
all other parts programmed controller
ISBN 978-90-5381-225-9 14.50 US $29.00
Art-Nr. 080719-91 54.00 US $87.50 Art-Nr. 080678-71 39.00 US $59.00

Software Tools & Hardware Tips

Ethernet Toolbox CapSense Buttons Elektor SMT Reflow Oven

This CD-ROM contains all essential in- Evaluation Kit (October 2008)

formation regarding Ethernet interfaces! (January 2009) The Elektor SMT reflow oven will faithfully
Ethernet Toolbox includes a collection of handle most if not all your soldering of
datasheets for dedicated Ethernet inter- This kit is for learning about touch sens- projects using surface mount devices
Kits & Modules
face ICs from many different manufac- ing buttons. The PSoC device used on the (SMDs). The oven is particularly suited for
turers. It provides a wealth of information evaluation board has up to 10 I/Os for use not just in Colleges, workshops, clubs
about connectors and components for the buttons, LEDs and general-purpose I/O and R&D laboratories, but also by the ad-
physical layer (PHY) and specific software devices. The kit contains the CY3218- vanced electronics enthusiast. This pre-
tools for use with the Ethernet (Software). CAPEXP1 evaluation board, a retractable cious workbench tool is at home where
To help you learn about the Ethernet in- USB mini cable (A to mini B), a PSoC SMD boards have to be produced to a
terfaces, we have compiled a collection CY3240-I2 bridge board and an AA bat- variety of requirements on size, compo-
of all articles on this topic that have ap- tery. Also included is the kit CD which nents and soldering materials.
peared in Elektor and complemented contains PsOC programmer, .NET
them with additional documentation and Framework 2.0, PSoC Express 3, Size: 418 x 372 x 250 mm
links to introductory articles on Ethernet CapSense Express Extension Pack and (16.5 x 14.6 x 10 inch)
interfaces. The documents are PDF files. the CapSense Express documentation.
Art. # 080663-91 962.00 (Excl. VAT)
ISBN 978-90-5381-214-3 19.50 US $39.00 Art-Nr. 080875-1 27.50 US $39.95 US $1665.00 (Excl. VAT)

Prices and item descriptions subject to change. E. & O.E

82 elektor - 4/2009
April 2009 (No. 388) US $

Product Shortlist

RGB LED Driver

080178-41 ....Programmed controller ......................................................8.90........13.75
The 32-bit Machine
080928-91 ....R32C/111 Starterkit
1 Microcontroller Systems Engineering
(32-bit-Controllerboard & CD-ROM) ................................27.00........42.50 ISBN 978-0-905705-75-0 ............... 29.00 .....US $58.00
Automotive CAN Controller
080671-91 ....Kit of parts, incl. PCB with SMDs prefitted .........................52.00........79.00
2 Mouse Interfacing
Automatic Running-in Bench ISBN 978-0-905705-74-3 ............... 26.50 .....US $53.00

Books Books
080253-71 ....Kit of parts incl. PCB-1 with SMDs prefitted ............... see
090146-91 ....ARMee plug-in board mk. II ......................................see
3 Embedded Linux Control Centre
ISBN 978-0-905705-72-9 ............... 24.00 .....US $48.00
March 2009 (No. 387)
M16C TinyBrick
4 PIC Microcontrollers
080719-91 ....Kit of parts: TinyBrick-PCB with SMD parts and ISBN 978-0-905705-70-5 ............... 27.95 .....US $55.90
microntroller premounted; plus all other parts ................54.00........87.50

Universal Display Book
February 2009 (No. 386) 5 ISBN 978-0-905705-73-6 ............... 23.00 .....US $46.00
Model Coach Lighting Decoder
080689-1 ......PCB, long (l = 230 mm) ....................................................7.30........10.95 DVD Elektor 2008
080689-2 ......PCB, medium (l = 190mm) ...............................................7.30........10.95 1 ISBN 978-90-5381-235-8 .............. 17.50 .....US $35.00
080689-3 ......PCB, short (l = 110mm) ....................................................5.80..........8.95
080689-41 ....PIC12F683, programmed ...................................................6.20..........9.50
Kits & Modules Elektor 1990 through 1999
Transistor Curve Tracer
CD/DVD-ROMs 2 ISBN 978-0-905705-76-7 ............... 69.00 ...US $109.00
080068-1 ......Main PCB ..........................................................................26.50........42.00
080068-91 ....PCB, populated and tested ...............................................55.00........82.50 FPGA Course
January 2009 (No. 385)
3 ISBN 978-90-5381-225-9 ............... 14.50 .....US $29.00

Radio for Microcontrollers

Ethernet Toolbox
071125-71 ....868 MHz module ................................................................7.20..........9.95
ATM18 on the Air
4 ISBN 978-90-5381-214-3 ............... 19.50 .....US $39.00
071125-71 ....868 MHz module ................................................................7.20..........9.95
Meeting Cost Timer
080396-41 ....ATmega168, programmed .................................................8.50........12.50
5 ISBN 978-90-5381-159-7 ............... 17.50 .....US $35.00
Capacitive Sensing and the Water Cooler
LED Top with Special Effects
080875-91 ....Touch Sensing Buttons Evaluation kit ...............................27.50........39.95
080875-92 ....Touch Sensing Slider Evaluation kit ..................................27.50........39.95
1 Art. # 080678-71 ..........................39.00 .... US $59.00
Three-Dimensional Light Source
Transistor Curve Tracer
Kits & Modules

080355-1 ......Printed circuit board ........................................................24.90........39.90

Art. # 080068-91 ........................... 55.00 .....US $82.50
Moving up to 32 Bit
080632-91 ....ECRM40 module ...............................................................32.00........46.50
Evaluation Kit CapSense Buttons
December 2008 (No. 384)
3 Art. # 080875-91 ........................... 27.50 .....US $39.95
Elektor SMT Oven
071129-1 ......Printed circuit board ...........................................................5.80..........9.50
Hi-fi Wireless Headset
4 Art. # 080663-91 ........................962.00 US $1665.00
080647-1 ......Printed circuit board: Transmitter.......................................7.90........15.80
Evaluation Kit CapSense Sliders
080647-2 ......Printed circuit board: Receiver............................................7.90........15.80
LED Top with Special Effects
5 Art. # 080875-92 ........................... 27.50 .....US $39.95
080678-71 ....Kit of parts incl. SMD-stuffed PCB
and programmed controller .............................................39.00........59.00

November 2008 (No. 383) Order quickly and securely through

Motorised Volume Pot
071135-41 ....Programmed controller ATMEGA8-16PU ..........................5.90........11.80
Speed Camera Warning Device
080615-1 ......Printed circuit board .........................................................15.50........31.00
080615-41 ....Programmed controller PIC16F876A-I/SO .......................11.80........23.60 or use the Order Form near the end
Remote Control by Mobile Phone
080324-1 ......Printed circuit board .........................................................17.80........35.60 of the magazine!
080324-41 ....Programmed controller ATMEGA8-16PU ..........................5.90........11.80
080324-71 ....Kit of parts ........................................................................54.00........99.00
Tracking Hot Spots Elektor
080358-1 ......Printed circuit board ..........................................................9.10........18.20 Regus Brentford
ATmega meets Vinculum 1000 Great West Road
071152-91 ....VDIP1 module ..................................................................22.50........45.00 Brentford TW8 9HH United Kingdom
Tel. +44 20 8261 4509
Fax +44 20 8261 4447

4/2009 - elektor 83
info & market coming attractions

next month in elektor

MSP430 Low-cost Development System

Together with Rotterdams Technical College Elektor developed a low-cost development system that should appeal
to those of you just starting out into microcontroller land. The basis of the system is the MSP-eZ430 USB-stick from Texas
Instruments, a chip graced by a free development platform and a programming language (C). The associated experiment-
ers board easily accommodates the hardware for the project examples like a buzzer, a 7-segment display, some LEDs and
pushbuttons. I2C and SPI connectivity is also provided.

True-rms Voltmeter with Frequency Meter

Test and measurement equipment for home construction is among our all-time favourites. Next month we present a digital voltmeter with four ranges covering 0.1 to 100V. The
instrument can show the rms value of sinewave inputs signals up to 1MHz, while the frequency meter reaches up to 30MHz. The circuit consists of a screened instrumentation am-
plifier and a readout section based on an R8C/13 micro linked to a 2-line LCD and an RS232 interface.

Mini PWM Audio Amplifier

Admit it you too have one or more MP3 players idling about. Although these are great for train journeys or jogging
tracks, you sometimes want to play that MP3 stuff out loud without having to use the headphones, or linking the player
to the PC. A small amplifier is then called for, preferably one with high efficiency so why not go for state of the art PWM
(pulsewidth modulation). The circuit is extremely simple and marked by sound reproduction not unlike that of a small
tube amp. Battery-powered, this little amp can supply up to 1.5 watts into 4 ohms.

Article titles and magazine contents subject to change, please check Magazine on The May 2009 issue comes on sale on Thursday 23 April 2009 (UK distribution only).
UK mainland subscribers will receive the issue between 17 and 20 April 2009. www.elektor.

Elektor on the web
All magazine articles back to volume 2000 are available online in pdf format. The article summary and parts list (if applicable) can
be instantly viewed to help you positively identify an article. Article related items are also shown, including software downloads, circuit
boards, programmed ICs and corrections and updates if applicable. Complete magazine issues may also be downloaded.
In the Elektor Shop youll find all other products sold by the
publishers, like CD-ROMs, kits and books. A powerful search
function allows you to search for items and references across
the entire website.

Also on the Elektor website:

Electronics news and Elektor announcements
Readers Forum
PCB, software and e-magazine downloads
Surveys and polls
FAQ, Author Guidelines and Contact

84 elektor - 4/2009
Order Form

C Programming
Price each Qty. Total Order Code

(see reverse before ticking as appropriate)
for Embedded Microcontrollers 32.50
NEW Bank transfer
Artificial Intelligence 32.00
NEW Cheque
Mouse Interfacing 26.50
NEW (UK-resident customers ONLY)
Microcontroller Systems Engineering 29.00 Giro transfer
DVD Elektor 2008 17.50
DVD Elektor 1990 through 1999 69.00

Expiry date: _________________________

Verification code: _____________________

Free Elektor Catalogue 2009
Sub-total Please send this order form to*
Prices and item descriptions subject to change.
The publishers reserve the right to change prices P&P (see reverse for conditions)
without prior notification. Prices and item descriptions
shown here supersede those in previous issues. E. & O.E. Total paid Elektor
Regus Brentford
1000 Great West Road
Brentford TW8 9HH
United Kingdom
Tel.: +44 20 8261 4509
Address + Post code
Fax: +44 20 8261 4447
*USA and Canada residents should use $ prices,
and send the order form to:
Tel. Email Elektor US
PO Box 876
Peterborough NH 03458-0876
Date Signature

Phone: 603-924-9464
Fax: 603-924-9467

EL04 E-mail:
Order Form

Yes, I am taking out an annual subscription

to Elektor and receive a free METHOD OF PAYMENT
(see reverse before ticking as appropriate)
2GB MP3 player*.
Bank transfer
I would like: (UK-resident customers ONLY)

Standard Subscription (11 issues) Giro transfer

(11 issues plus the Elektor Volume 2009 CD-ROM)

* Offer available to Subscribers

cribers who have not held a subscription
to Elektor during the last 12 months. Offer subject to availability.
See reverse for rates and conditions.
Expiry date: _________________________

Name Verification code: _____________________


Address + Post code

Please send this order form to

Regus Brentford
1000 Great West Road
Tel. Email Brentford TW8 9HH
United Kingdom
Date Signature Tel.: +44 20 8261 4509
Fax: +44 20 8261 4447

All orders, except for subscriptions (for which see below), must be sent BY POST or FAX to our Brentford address using the Order Form overleaf.
Online ordering:
Readers in the USA and Canada should send orders, except for subscriptions (for which see below), to the USA address given on the order
form. Please apply to Elektor US for applicable P&P charges. Please allow 4-6 weeks for delivery.
Orders placed on our Brentford office must include P&P charges (Priority or Standard) as follows: Europe: 6.00 (Standard) or 7.00
(Priority) Outside Europe: 9.00 (Standard) or 11.00 (Priority)


All orders must be accompanied by the full payment, including postage and packing charges as stated above or advised by Customer Services staff.

Bank transfer into account no. 40209520 held by Elektor Electronics with ABN-AMRO Bank, London. IBAN: GB35 ABNA 4050 3040 2095 20.
BIC: ABNAGB2L. Currency: sterling (UKP). Please ensure your full name and address gets communicated to us.
Cheque sent by post, made payable to Elektor Electronics. We can only accept sterling cheques and bank drafts from UK-resident customers or
subscribers. We regret that no cheques can be accepted from customers or subscribers in any other country.
Giro transfer into account no. 34-152-3801, held by Elektor Electronics. Please do not send giro transfer/deposit forms directly to us, but instead
use the National Giro postage paid envelope and send it to your National Giro Centre.
Credit card VISA and MasterCard can be processed by mail, email, web, fax and telephone. Online ordering through our website is
SSL-protected for your security.


Components for projects appearing in Elektor are usually available from certain advertisers in this magazine. If difficulties in the supply
of components are envisaged, a source will normally be advised in the article. Note, however, that the source(s) given is (are) not exclusive.


Delivery Although every effort will be made to dispatch your order within 2-3 weeks from receipt of your instructions, we can not guarantee this
time scale for all orders. Returns Faulty goods or goods sent in error may be returned for replacement or refund, but not before obtaining our
consent. All goods returned should be packed securely in a padded bag or box, enclosing a covering letter stating the dispatch note number.
If the goods are returned because of a mistake on our part, we will refund the return postage. Damaged goods Claims for damaged goods
must be received at our Brentford office within 10-days (UK); 14-days (Europe) or 21-days (all other countries). Cancelled orders All cancelled
orders will be subject to a 10% handling charge with a minimum charge of 5.00. Patents Patent protection may exist in respect of circuits,
devices, components, and so on, described in our books and magazines. Elektor does not accept responsibility or liability for failing to identify
such patent or other protection. Copyright All drawings, photographs, articles, printed circuit boards, programmed integrated circuits, diskettes
and software carriers published in our books and magazines (other than in third-party advertisements) are copyright and may not be reproduced
or transmitted in any form or by any means, including photocopying and recording, in whole or in part, without the prior permission of Elektor
in writing. Such written permission must also be obtained before any part of these publications is stored in a retrieval system of any nature.
Notwithstanding the above, printed-circuit boards may be produced for private and personal use without prior permission. Limitation of liability
Elektor shall not be liable in contract, tort, or otherwise, for any loss or damage suffered by the purchaser whatsoever or howsoever arising out of, or in
connexion with, the supply of goods or services by Elektor other than to supply goods as described or, at the option of Elektor, to refund the purchaser
any money paid in respect of the goods. Law Any question relating to the supply of goods and services by Elektor shall be determined in all respects
by the laws of England.
January 2009


The standard subscription order period is twelve months. If a
Standard Plus permanent change of address during the subscription period means
United Kingdom 44.00 53.00 that copies have to be despatched by a more expensive service,
no extra charge will be made. Conversely, no refund will be made,
Surface Mail nor expiry date extended, if a change of address allows the use of
Rest of the World 58.00 67.00 a cheaper service.
Student applications, which qualify for a 20% (twenty per cent)
Airmail reduction in current rates, must be supported by evidence of stu-
Rest of the World 74.00 83.00 dentship signed by the head of the college, school or university
USA 59.95 See faculty.
for special offers A standard Student Subscription costs 35.00, a Student
Canada 70.95
Subscription-Plus costs 44.20 (UK only).
Please note that new subscriptions take about four weeks from
HOW TO PAY receipt of order to become effective.
Cancelled subscriptions will be subject to a charge of 25%
(twenty-five per cent) of the full subscription price or 7.50,
Bank transfer into account no. 40209520 held by Elektor Electronics.
whichever is the higher, plus the cost of any issues already
with ABN-AMRO Bank, London. IBAN: GB35 ABNA 4050 3040 2095 20.
dispatched. Subsciptions cannot be cancelled after they have
BIC: ABNAGB2L. Currency: sterling (UKP). Please ensure your full name
run for six months or more.
and address gets communicated to us.
Cheque sent by post, made payable to Elektor Electronics. We can only
accept sterling cheques and bank drafts from UK-resident customers or
subscribers. We regret that no cheques can be accepted from customers
or subscribers in any other country.
Giro transfer into account no. 34-152-3801, held by Elektor Electronics.
Please do not send giro transfer/deposit forms directly to us, but instead
use the National Giro postage paid envelope and send it to your National
Giro Centre.
Credit card VISA and MasterCard can be processed by mail, email,
web, fax and telephone. Online ordering through our website is SSL-
protected for your security. January 2009
Elektor 2008
All articles in Elektor Volume 2008
This DVD-ROM contains all editorial articles published in
Volume 2008 of the English, Spanish, Dutch, French and German
editions of Elektor magazine. Using Adobe Reader, articles are
presented in the same layout as originally found in the magazine. ISBN 978-90-5381-235-8 17.50 US $35.00
The DVD is packed with features including a powerful search
engine and the possibility to edit PCB layouts with a graphics Elektor
Regus Brentford
program, or printing hard copy at printer resolution. 1000 Great West Road
Brentford TW8 9HH
United Kingdom
Tel. +44 20 8261 4509

Further information
tion and ordering at

Avit Research, Showcase. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 MikroElektronika. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16, 17

Beijing Draco . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 MQP Electronics, Showcase. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

Beta Layout, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39, 78 Netronics, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

ByVac, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Newbury Electronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

CS Technology Ltd, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Nurve Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

Decibit Co. Ltd, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

Parallax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

Designer Systems, Showcase . . . . . . . . . . . . . . . . . . . . . . . 78

Peak Electronic Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

EasyDAQ, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

Pico. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Easysync, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Quasar Electronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Elnec, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Robot Electronics, Showcase . . . . . . . . . . . . . . . . . . . . . . . . 79
Eurocircuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Robotiq, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
First Technology Transfer Ltd, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
ScanTool, Showcase . . . . . . . . . . . . . . . . ., . . . . 79
FlexiPanel Ltd, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78, 79
FTDI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
USB Instruments, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Future Technology Devices, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Virtins Technology, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
General Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Hexwax Ltd, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

Advertising space for the issue of 21 May 2009
may be reserved not later than 21 April 2009
Labcenter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
with Huson International Media Cambridge House- Gogmore Lane-
Lcdmod Kit, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Chertsey, Surrey KT 16 9AP England Telephone 01932 564999
Fax 01932 564998 e-mail: to whom all
London Electronics College, Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 correspondence, copy instructions and artwork should be addressed.

4/2009 - elektor 87