Professional Documents
Culture Documents
10
electronics worldwide
... super computers ... fm stereo decoder ... c display ... led drivers spiced ... avr macros ...
Automotive
CANtroller
explore car electronics
Automatic
Run-in
for model
Bench
internal combustion engines
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
visit.
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 www.elektor.com/china 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.
CONTENTS
Volume 35
April 2009
no. 388
24
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
English
German
Dutch
French
Chinese
Portugal
Italian
Spanish
Swedish
Finnish
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 (secretariaat@elektor.nl)
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 (w.hettinga@elektor.nl)
Publishers: Elektor International Media, Regus Brentford, Marketing: Carlo van Nistelrooy
Editor: Jan Buiting (editor@elektor.com)
1000 Great West Road, Brentford TW8 9HH, England. Tel. (+44) 208 261
4509, fax: (+44) 208 261 4447 www.elektor.com 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: www.elektor.com/subs
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.
REGISTER NOlimWite!d
Places are strictly
4/2009 - elektor
info & market mailbox
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
www.ak-modul-bus.de. The If not, I hope it will appear
direct link is: www.ak-modul- sometime. I still have a pristine
bus.de/stat/kapazitaetsdi- 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 (www.hidato.com), spinning top with a rotating LED
up and down. Dear Editor I have been an KenKen (www.kenken.com). 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- www.doo-bee-toys.com 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
editor@elektor.com 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- www.peakelec.co.uk
ket, a new UK distribution partner (081108-IX)
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 www.planarenergy.com.
life from its rechargeable nature. is ideal for many applications current-time schemes of the appli- (091069-II)
4/2009 - elektor 11
info & market news & new products
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 www.lighttape.co.uk
effect. bon coated in Sylvania phosphor a 100w light bulb. (091069-VI)
4/2009 - elektor 13
info & market news & new products
14 elektor - 4/2009
4XDVDU(OHFWURQLFV/LPLWHG 3RVWDJH 3DFNLQJ2SWLRQV8SWR.JJURVVZHLJKW8.6WDQGDUG
32%R[%LVKRSV6WRUWIRUG 'D\'HOLYHU\8.0DLQODQG1H[W'D\'HOLYHU\
(XURSH(85HVWRI:RUOGXSWR.J
&0:38QLWHG.LQJGRP
2UGHURQOLQHIRUUHGXFHGSULFH8.3RVWDJH
7HO :HDFFHSWDOOPDMRUFUHGLWGHELWFDUGV0DNHFKHTXHV32VSD\DEOH
)D[ WR4XDVDU(OHFWURQLFV3ULFHVLQFOXGH9$7
(PDLOVDOHV#TXDVDUHOHFWURQLFVFRP 3OHDVHYLVLWRXURQOLQHVKRSQRZIRUGHWDLOVRIRYHUNLWV
:HEZZZTXDVDUHOHFWURQLFVFRP SURMHFWVPRGXOHVDQGSXEOLFDWLRQV'LVFRXQWVIRUEXONTXDQWLWLHV
&UHGLW&DUG
6DOHV
7KH(OHFWURQLF.LW6SHFLDOLVWV6LQFH
7KH(OHFWURQLF.LW6SHFLDOLVWV6LQFH
,QIUDUHG5&5HOD\%RDUG
0RWRU'ULYHUV&RQWUROOHUV &RQWUROOHUV /RJJHUV ,QGLYLGXDOO\FRQWURORQ
ERDUGUHOD\VZLWKLQFOXGHG
+HUHDUHMXVWDIHZRIRXUFRQWUROOHUDQG +HUHDUHMXVWDIHZRIWKHFRQWUROOHUDQG LQIUDUHGUHPRWHFRQWUROXQLW
GULYHUPRGXOHVIRU$&'&8QLSRODU%LSRODU GDWDDFTXLVLWLRQDQGFRQWUROXQLWVZHKDYH 7RJJOHRUPRPHQWDU\P
VWHSSHUPRWRUVDQGVHUYRPRWRUV6HH 6HHZHEVLWHIRUIXOOGHWDLOV6XLWDEOH368 UDQJH[PP6XSSO\9GF$
ZHEVLWHIRUIXOOUDQJHDQGGHWDLOV IRUDOOXQLWV2UGHU&RGH368 .LW2UGHU&RGH.7
$VVHPEOHG2UGHU&RGH$6
&RPSXWHU&RQWUROOHG6WDQGDORQH8QLSR &K6HULDO,VRODWHG,25HOD\0RGXOH
ODU6WHSSHU0RWRU'ULYHU &RPSXWHUFRQWUROOHG
'ULYHVDQ\9GFRU FKDQQHOUHOD\ERDUG$ 3,& $70(/3URJUDPPHUV
OHDGXQLSRODUVWHSSHU PDLQVUDWHGUHOD\RXWSXWV
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-
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
sbit
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);
SPI1_Write(address);
// send WRITE command
data before it has been sent. In other words, it is necessary to wait until SPI1_Write(data_in >> 8);
SPI1_Write(data_in);
// Send High byte
// Send Low byte
decoders data request signal (DREQ) is set to logic one (1). RC1_bit = 1;
Delay_us(5);
// 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
SPI1_Write(start_address);
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;
Delay_us(5);
// 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
SW_SPI_Write(data_);
}
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();
SPI1_Init_Advanced(MASTER_OSC_DIV64, DATA_SAMPLE_MIDDLE, CLK_IDLE_LOW, LOW_2_HIGH);
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
PRO
i n
} tten
Wri
roC
GO TO
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
IC
for P
MP3_SDI_Write(BufferLarge[i]);
well as the programs written for dsPIC and AVR microcontrollers can be found }
on our web site: www.mikroe.com/en/article/ }
}
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
1 2
18 elektor - 4/2009
ality requires an HTTP server that can be made with Apache. The other
3
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).
(080995-I)
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 www2.isec.pt/~nunomig/internationalconference_files/AEC_nunomig_
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 www.youtube.com/watch?v=n3ufmoKu36o&feature=channel_page
to all robots. Authors websites:
www2.isec.pt/~nunomig/
Two types of video transmission are incorporated. The first was created
http://micaelcouceiro.07x.net/
for the internal LAN to get video frames using HTTP commands, mainly to
provide independency of video and data communications. This function- http://carlosfigueiredo.07x.net/
Advertisement
4/2009 - elektor 19
technology automation
Fully
Automated
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.
4/2009 - elektor 21
technology automation
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.
4/2009 - elektor 23
projects modelling
Automatic Running-
for internal combustion model engines
Part 1: the hardware
24 elektor - 4/2009
-in Bench 10
0
70
110
.2
50
68
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
throttle control
engine
run-in board
standard
servo
portable terminal
engine
stepper speed optical
motor sensor
engine to run in
portable PC
USB
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
5V
power supply regulator LED issues[1][2].
I/O port
jumpers
JTAG
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
emergency
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
Direct
engine (LPC2106) Servo
temperature battery, which modelling enthusiasts
sensor analogue/digital I2C bus Control
converter will be familiar with.
ambient
temperature Rx
sensor Tx USB/Serial PC The throttle servo is controlled quite
interface (USB) conventionally by way of a PWM sig-
fuel
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
plug
supply SPI, UART1,
off-the-shelf model servo.
GPIO, I2C
supplies
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
28
+3V3 +5V
projects
47k
47k
47k
47k
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
DBG P0.19/TCK
P0.7/SSEL K1_7 K2_7 P0.20/TDI
20
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
VCC
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
modelling
47k
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
D2
3 4 P0.5/MISO/MAT0.1 C4 C3 C5
X = 14.7456 MHz
AGND
GND
GND
GND
GND
10k
25
18
21
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
R8
13 14 P0.26 RUN 100n 100n 100n
+5V GND
2k2
15 16 P0.27 R10 GND GND GND +3V3
17 18 SCL0B D12
220R
VHV 1N5822
19 20 SDA0B
P0.22
C7 C9 C8 C10 R9
C6
5
EXT. IC5
47k
100n 100n 47u 100n P0.23
VHV LM2940CT-5.0 +5V 100n
16V INT0 K12
JP4
VCC
3 D11
1 1 3 IC2 GND
+3V3 CONF. RST 3 4
GND 2 R24 RST MR
1N5822 LM3724-3V08
LM3724-3V08 K4
2
S1 2
220R
R58 R48 +5V EXTERNAL
GND
GND
47k
47k
D13 RESET
470u 100n 100n 47u 47u
P0.11/CTS1/CAP1.1 25V 16V 10V JP12
POWER
T5 green GND
R49 R11
K20 2k2 P0.7/SSEL
1 220R
GND K5
BC547B 3
2 2
SERVO
D5 1 +3V3 VHV VGP
DSC C14 C15
K11
3V9 47u 100n R25
GND +5V 16V D15
R36 R37 R42 R43
2k2
22k
1k
1k5
390R
180R
GND
220u IRL3502 T1
16V R41 R27 SPBF
T3 2 5
R38 R39 1k
1 7 P0.10
220R
1k
1k
QED222 IC7
10k
GND
BPW96C 4 100n
1V4
GND
elektor - 4/2009
adapting the voltage swing of the
080253 - 14
microcontroller (3.3V) to the levels
RJ11
of the external bus (5V);
K9
1
2
3
4
5
6
M1
JP10
B
4
SDA1B
R20
5V6
D7
buffering the signals from the micro-
1k
R19
5V6
controller, thereby making it possible
D6
1k
RJ11
K8
A number of 100 series resistors, in
C21
16V
47u
1
2
3
4
5
6
association with 5.6V zener diodes,
GND
100n
C20
JP9
or not the peripherals connected
SDA1B
470u
25V
C37
R55
1
2
3
4
5
6
GND
22R
7
5
K10.
100n
C36
R54
1W
SDAB
SCLB
22R EN
VCCB
8
GND
GND
IC4
VCCA
1
18
IC8 OUT2 17
16
15
14
13
12
11
10
SDAA
SCLA
which.
100n
C19
OUT1
OUT3
OUT4
OUT5
OUT6
OUT7
OUT8
COM
GND
ULN2804A
3
R18
5k6
expansion board using HE-10 connec-
GND
R17
IN1
IN2
IN3
IN4
IN5
IN6
IN7
IN8
SDA1A
SCL1A
GND
2k2
on 2.54mm (0.1) breadboard. This
R52
2k2
JP11
VHV
10
2
4
6
8
3
2k2
(via JP8).
HE10
K10
R50
2k2
+5V
VHV
JP7
1
3
5
7
9
P0.28
P0.29
P0.30
P0.31
SCL0B
eral, with master and slave modes,
and is capable of a maximum speed
AD7417ARZ
11
12
13
4
2
3
SDA
OTI
K7
GND
VDD GND
14 6
JP6
100n 47u
REFIN
GND
AIN1
AIN2
AIN3
AIN4
IC6
1k
15
7
8
9
10
1k
3V9 100n
R14
R31
39k
SDA0B
10k
SCL0B
associated components.
3V9 100n
C31
IC Bus 1
R30
0W5
D18
RJ11
90k9
K6
10k
1
2
3
4
5
6
C18
16V
GND
3V9
R23
R21
R22
JP5
5V6
D8
SCL0B
USB bus. This is particularly useful
5V6
SDA0B
1k
1k
D10
R29
3V3
R34
R28
+5V
GND
GND
5k6 5k6
SDAB
SCLB
EN
2
1
2
1
PCA9517A
+3V3 +5V
K17
8
GND
GND
IC3
4
1
VCCA
from the USB bus is not recommended,
K16
SDAA
K14
SCLA
100n
GND
2
1
2
1
5k6
MOTOR TEMP.
AMB. TEMP.
R12
KTY81-210
KTY81-210
5k6
SDA0A
SCL0A
INT0
R57
R56
-T
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
LCD1
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.
+5V
LED+A
LED-C
VDD
VSS
R/W
The Direct Servo Control (DSC) input
RS
VL
D0
D1
D2
D3
D4
D5
D6
D7
E
is particularly simple, as a single NPN
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
transistor is all it takes to interface P1
C2 C3
with the microcontroller. The resistor
values in the circuit have been tested 100n 47u
16V
using a Graupner MX16s transmitter. If
+5V GND
your transmitter is a different type, you
may need to adjust some values. C1
R1
100n R2
The stepper motor driver output allows GND
10k
4R7
you to drive a stepper motor with gear-
9
1W
+5V 8
VDD
box with a rated voltage of 5V or 12V. K1 18
GPB7
7 T1
RESET GPB6
The values of resistors R54 and R55 1
GPB5
6
2 13 5
may need adjusting, depending on the 3 12
SDA GPB4
4 +5V
motor youre using. If youre not plan- SCL IC1 GPB3 ZMX61
4 20 3
INTA GPB2 P02F
ning to use a stepper motor in your 5 19
INTB GPB1
2
6 1 +5V C4
application, these four open-collector D1 D2 D3
GPB0
MCP23017
outputs can be put to other uses, such GPA0
21 S5
100n
22
as driving lamps, LEDs, DC motors, or 5V6 5V6 5V6 GPA1
23 D E
GND
BZ1
relays. GPA2
24
GND GPA3
17 25 A B
+5V A2 GPA4
16 26
Pocket terminal 15
A1 GPA5
27
C
A0 GPA6
The electrical circuit of the pocket ter- JP1 JP2 JP3 GPA7
28
VSS
3
4/2009 - elektor 31
projects modelling
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.
Advertisement
Elektor
Jan Buiting MA, Editor
Regus Brentford, 1000 Great West Road, Brentford TW8 9HH, United Kingdom
Email: editor@elektor.com
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.
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 www.timloto.org.
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
ler
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 www.timloto.org/ 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
330R
+5VA
R8 LED1
330R
R1
R7 LED2 C1 C2
10k
330R
R6 100n 100n
LED3
62
64
21
52
330R
R5 AREF AVCC VCC VCC GND
LED4
330R 51 20 RESET
(AD0)PA0 RESET
R4 LED5 50
(AD1)PA1 S8 C3
330R 49 19 PG4
(AD2)PA2 PG4(TOSC1)
R3 LED6 48 18 PG3
(AD3)PA3 PG3(TOSC2) RESET 100n
330R 47 43 PG2
(AD4)PA4 PG2(ALE)
R2 LED7 46 34 PG1
(AD5)PA5 PG1(RD) GND
330R 45 33 PG0 +5V
(AD6)PA6 PG0(WR)
44 1 JP1
GND (AD7)PA7 PEN P1
PF0
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
AT90CAN32
PE7 9 54 PF7 MOSI
GND (ICP3/INT7)PE7 PF7(ADC7/TDI)
PE6 8 55 PF6
+5V (T3/INT6)PE6 PF6(ADC6/TDO) K6
GND
PE5 7 56 PF5
(OC3C/INT5)PE5 PF5(ADC5/TMS)
PE4 6 57 PF4 PG0 1 2 PG1
(OC3B/INT4)PE4 PF4(ADC4/TCK)
K2 R11 PE3 5 58 PF3 PG2 3 4 PG3
(OC3A/AIN1)PE3 PF3(ADC3)
3
(T0)PD7 (SCL/INT0)PD0
2
5 PE3 21 22 PE2
AGND GND GND XTAL1 XTAL2 RXD1 23 24 TXD1
PF0 25 26 PF1
63
53
22
23
24
SUBD9 X1
GND PF2 27 28 PF3
K4
PF4 29 30 PF5
C4 C5
TXD1 PF6 31 32 PF7
RXD1 22p 12MHz 33 34
22p
+5V GND
+5V K3 GND
IC3
+Vin LD1117S50CTR
GND D1 +5V +5VA +5V +VCore
MBRS130 L1 L2
K5 3 2
3
R13
1
330R
2 C6 C8 C7 C9 C10 C11
1
6..12V LED8
47u 100n 10u 100n 100n 100n
080671 - 11
GND GND GND
36 elektor - 4/2009
Stepper motor control .DEVICE AT90CAN32
.INCLUDE can32def.inc;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.
OUT SPH,R16
LDI R16,low(RAMEND)
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
resistors
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)
NOP
K6
PG0 1 2 PG1
PG2 3 4 PG3 /* MAIN PROGRAM*/
+10V
PG4 5 6 PD0
PD1 7 8 PD4
D1
PD7 9 10 PB7 BEGIN: LDI R17,0b00100010 ;0101 step 1
PB6 11 12 PB5
OUT PORTF,R17
PB4 13 14 PB3 R1
PB2 15 16 PB0
OUT PORTA,R17
RCALL WAIT1
82R
PE7 17 18 PE6
+5V
PE5 19 20 PE4 K4
PE3 21 22 PE2 LDI R17,0b10000010 ;1001 step 2
RXD1 23 24 TXD1 OUT PORTF,R17
9
I1 O1
PF2 27 28 PF3 2 15 RCALL WAIT1
I2 O2
PF4 29 30 PF5 3
I3
IC1 O3
14
PF6 31 32 PF7 4 13
I4 O4 LDI R17,0b10001000 ;1010 step 3
33 34 5
I5
ULN2003 O5
12
6 11 OUT PORTF,R17
I6 O6 OUT PORTA,R17
7 10
GND
GND I7 O7
+5V RCALL WAIT1
8
RJMP BEGIN
The example program is available as a free download from the
/*DELAY SUBROUTINE*/
Elektor website filed under number 080671-11.zip.
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 name: TESTPORTF.ASM BRNE LOOP
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
Programming
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-
COMPONENT LIST IC2 = PCA82C251/N4 (SO8)
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.
Miscellaneous
R12 = 1k (SMD0805) JP1,JP2 = 2-way SIL pinheader + jumper
(080671-I)
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
Capacitors
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] www.atmel.com/dyn/resources/prod_doc-
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] www.atmel.com/dyn/Products/tools_card.
S8 = pushbutton
Kit of parts, contains SMD-prestuffed board asp?tool_id=2725
Semiconductors and all through-hole components. Elektor [3] http://winavr.sourceforge.net/
D1 = MBRS130 (SMB) Shop # 080671-91.
IC1 = AT90CAN32-16AU (TQFP-64) [4] www.mcselec.com
[5] www.hpinfotech.ro/html/cvavr.htm
38 elektor - 4/2009
tel. 01298 70012
fax. 01298 70046
www.peakelec.co.uk
sales@peakelec.co.uk
VAT Reduction AND Special Offers!
7
Atlas DCA was49 Atlas ESR 7!
includes new premium probes! 5
5
! wa
s
85
www.pcb-pool.com 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: sales@pcb-pool.com 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!
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
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.
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
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].
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.
www.ps3cluster.org
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- www.flashmobcomputing.org
nect them onto a network.
4/2009 - elektor 43
technology super computers
computer computer
Conclusion
central Quite apart from the technological feats that supercomputer
computer
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?
chip
card
Well find out the answer when the new official list of the
Figure5. 500 fastest computers in the world is published in June
casing
The principle of a 090067 - 12
2009 [9].
supercomputer.
(090067-I)
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.
[2]www.ps3cluster.org
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 www.deshawresearch.com
44 elektor - 4/2009
projects microcontrollers
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
VCC VCC
U$2
R5 1 JP5
D1 DIL64
100k
MD1
1N4148
S1 R12
C7
4M7
VCC
10k
220n
RESET 1 1 64 64 VCC
VDC1 VDC0
2 2 63 63
NSD TB3IN/P93
3 3 62 62 1 SJ1
CNVSS AVCC
C9 C12 4 4 61 61 1
XCIN/P87 VREF C8
C5 C6 C13 5 5 U$1 60 60 SJ8
XCOUT/P86 AN0/P100
100n 10M
6 6 59 59 1
RESET AVSS 100n
100n 100n 100n
7 7 58 58 SJ2
XOUT AN1/P101
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
VDD_33A
VDD_33
V0_33
VDD_325
220k
220k
220k
100k
100k
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
1k
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
47k
080928 - 11
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
automatically.
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.
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.
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
DA0E
DA0 R
1
R R R R R R R R
2R 2R 2R 2R 2R 2R 2R 2R
MSB LSB
DA0
Register
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
AVSS
VREF
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
256
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 www.glyn.de/r32c
controller you can connect an oscillo- http://eu.renesas.com/fmwk.jsp?
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.
Advertisement
Sensors
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
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
1u
sary because it can be flashed very
simply via the RS-232 interface. Even 16V
better, the Elektor website contains a +5V
2
K1
VDD
project page [4] plus a well frequented C2
1
C1+ VCC
16
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
T2IN T2OUT
7 8 12 13 3
R1OUT R1IN
9 10 9 8 8
Software C4
4
R2OUT
C2+
R2IN C3
4 10
1u 9
Pain always precedes pleasure so we MAX232CPE 16V
1u 5 15 5
C2- GND
must first install the software before 16V
VEE
we can start to enjoy the delights S1
6
C5
of programming. This means stick-
ing rigidly to the prescribed order of 1u
tasks. First we must install the Moni- 16V
[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-
IC1
C5
S1
tion manual.
Your first project
C4
C1
4/2009 - elektor 53
praxis controller
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
(080422-I)
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] www.elektor.com/products/kits-
the menu via Options/New modules/modules/display-compu-
Settings). Next, select the ter-(070827-91).426130.lynkx
Controller type (M30291) and [2] www.tinybasic.de
the upper of the two Kernel [3] www.m16c.de
protocols offered (see Fig-
[4] www.elektor.com/maga-
ure4). The next window is
zines/2006/january/the-r8c-fam-
for selecting the interface to ily.58011.lynkx
be used. The third window
requires you to enter a Baud [5] www.elektor.com/forum/
elektor-forums/archive/r8c-16-
rate for the link to the Con-
bit-micro-starter-kit-(february-
troller (select 9,600 baud).
2006).164479.lynkx
Now we link up the M16C
Display Board to the pro- [6] www.glyn.de (click on English
flag)
gramming interface and to
the interface with the COM [7] www.elektor.com/080422
port indicated. Insert jumper [8] http://en.wikipedia.org/
JP1 and give the Reset but- wiki/M16C (M16C); http://
ton a short push. The micro- en.wikipedia.org/wiki/R8C (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)
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.
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
3V
R6
33R
C10
C1
R8
Pin 14 220u IC2
8
16V
22k
TDA7021T 270p C2
P1 R1 Vp
C11
4
47k 2
Vp C7 R7 100u
50k 220n 8 6 7
MPX
IC1 L OUT 33R K4
K1 1
7
TDA7040T 5
C6 220n 25V L
BLEND R OUT P3A
10n 22k TDA7050T
3V LF GND OSCA
4 C12 R
R2 2 R9
3
S1 6
4k7 33R
Mono/ R4 R5 3
100u
Stereo C9 25V R10
BT1
120k
4k7
GND
22k
Pin 9 3V 220n
5
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
Calibration
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
4/2009 - elektor 57
projects led driver in pspice
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
V IN
R SENSE L
designers would like to maximize in
order to minimize external component
IN REGULATOR VCC
Basic principles
CS
CSN COMPARATOR
GATE
DRV
DRIVER
C VCC REF
IN VCC
shown in Figure1 is based on the UVLO
GND
CSN MAX16819 DRV of LEDs using an external inductor and
MAX16820 DIM
a power MOSFET. However, the same DIM
BUFFER MAX16819
MAX16820
DIM GND
analysis will hold true for any vendors 080888 - 12
58 elektor - 4/2009
ivers
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.
R1
4/2009 - elektor 59
projects led driver in pspice
5V
VDRV
V DIM V DIM
2V/div 2V/div
0V 0V
I LED I LED
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.
The only clear difference is the fall time 10s/div 1s/div 080888 - 17
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
[1] www.maxim-ic.com/MAX16819
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] www.maxim-ic.com/tools/other/software/
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] www.cadence.com
tor that is much smaller, say, 5.1 H, cept of hysteretic LED drivers. By var- [4] www.maxim-ic.com/MAX16820EVKIT
the result looks like the graphs in ying parameters, such as input volt-
[5] www.maxim-ic.com/tools/spice/led_driv-
Figure 6. age, sense resistor, and inductance,
ers/macro/MAX16820.LIB
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)
Advertisement
Call us: 020 8816 7005 Email: euro@eurocircuits.com *excluding transport and VAT
www.eurocircuits.com
4/2009 - elektor 61
projects microcontrollers
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
Digital
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
M18
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
Loop
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
Config Timer2 = Pwm , Pre- board and receive 500 data bytes.
ATmega88
1k
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
22n
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
Tim1_isr:
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
application.
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
1 DC
0...+5V
ADC0
measurement session with the current Listing 7
10k
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
10k
10k
7V5...+7V5 End If
it is never satisfied. For this reason, End If
1 AC 10k ADC0
100
its always a good idea to first make Return
a measurement without triggering.
10k
66 elektor - 4/2009
100
AC
10k
10k
10k
10k
10k
10k
10k
10k
1 AC CH1
10k DC
1 DC 100
PC5
PC4
PC3
PC2
10k 100
AC
2 AC
CH2
PC2
PC3
PC4
PC5
PC1 10k DC
2 DC 100 PC0
10k ADC0 AD7
CH4
ADC1 AD6 10k DC
3 DC ADC6
10k ADC7
CH3
ATmega88 10k DC
4 DC
10k
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.
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
U0+
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
interface.
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
connector.
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
VCC
L1
VCC
JP1
10H
C16
R8 R6
C8 C12
1k
10k
1
2 K2
100n 100n
16 V+ 1
C1+ C13 1
20 7
IC5 6
AVCC VCC 3
C1 1
VCC 2
1 2 12 13
PC6(RESET) PD0(RXD) R1OUT R1IN 7
28 3 11 14
6 PC5(ADC5/SCL) PD1(TXD) T1IN T1OUT 3
27 4 9 8
OUTPUT PC4(ADC4/SDA) PD2(INT0) R2OUT R2IN 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-
+VS RG IC2 PD7(AIN1)
10k 6
IN +IN ATmega8-P C17
14
2 3 PB0(ICP)
C18 15 K4
PB1(OC1A) 1
16 1 2
VCC PB2(SS/OC1B)
100n 17 3 4
VCC PB3(MOSI/OC2)
3
K1 4 18 5 6
PB4(MISO)
21 19 7 8
2 1 AREF PB5(SCK)
9 10
AGND XTAL1 XTAL2 GND VCC
22 9 10 8
D1 X1
C4
1N4148 22
VCC C5 C11 C7 C10 C9
IC1 8
S1 7805T 47n 100n 100n 18p 18p VCC
2 6
R7 CAP+ VREF
C6 IC4
2k7
BT1 1 5
FB/SHDN VOUT
9V C1 C2 C19 100 LT1054 VCC
4 7
D2 CAP OSC
470n 100n 1 C3
3
100
080027 - 11
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] www.analog.com/static/imported-files/
ple with the STK200 AVR starter kit data_sheets/AD620.pdf
made by Kanda [3]. While many pro- [2] www.elektor.com/080027
Construction gramming adapters use this ISP con- [3] www.kanda.com/products/kanda/STK200.
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
[4] www.keyspan.com
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] juergen.giersch@physik.uni-muenchen.de
4/2009 - elektor 71
projects design tips
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
r20,200,nxloop
When a macro is called the set of instructions are often found in higher-level languages.
lsl
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-
@0,low(@1+1)
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
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
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
Elektor SHOP PRIZE WINNERS
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
Advantages to subscribers
e
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
g
S B Stick der
U
Reco
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
1 2
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] www.justradios.com
selectivity. But here, a nasty sur- tys sake, two fuses were added resources were a sheet of paper, [2] www.oldradioworld.de
prise was awaiting me the into the power line cables. Fol- a pencil, their slide-rule and
[3] www.tubedata.info
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] www.tubesworld.com
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-
(1)
. 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 editor@elektor.com
7 8
4/2009 - elektor 77
ELEKTORSHOWCASE
To book your showcase space contact Huson International Media
Tel. 0044 (0) 1932 564999 Fax 0044 (0) 1932 564998
78 elektor - 4/2009
products and services directory
ROBOTIQ USB INSTRUMENTS
www.elektor.com http://www.robotiq.co.uk
Build your own Robot!
http://www.usb-instruments.com
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
http://www.obd2cables.com 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 www.virtins.com
Guaranteed lowest prices email: sales@robotiq.co.uk 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: http://www.scantool.net analyzer, signal generator,
sales@obd2cables.com ScanTool.net 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
http://www.robot-electronics.co.uk Compatible with a wide range http://www.cananalyser.co.uk
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 sales@scantool.net 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
www.elektor.com 2.0a/2.0b compliant
Rugged IP67 version available
4/2009 - elektor 79
SHOP BOOKS, CD-ROMS, DVDS, KITS & MODULES
Going Strong
A world of electronics From LED to graphical LCD
!
flash LEDs, and eventually by stages to use
W
other display indicators such as the 7-seg-
E
ment and alphanumeric liquid crystal dis-
N
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.
er
Limited Period Off
for Subscribers!
5 DISCOUNT
pril
www.elektor.com/a Silent alarm, poetry box, night buzzer and more
PIC Microcontrollers
Fully elaborated electronics projects
Learn by doing
309hands-on
This Circuits
book covers a series of
C Programming for Embedded Microcontrollers exciting
The presentand tenth
fun projects
editionwithof the PICpopular
micro-
Books
New microcontrollers become available every year and old ones become redundant. The one controllers.
30x CircuitsYouseries
canofbuilt
books more oncethan
again
50
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
and pictures
tricks and
of each
de-
this book is for you. No programming experience is necessary! Youll start learning to program project
sign ideason afor
breadboard
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
topics,background
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
each
wellproject
presented
explainsin thiswhy
book:
the
software and sample programs and exercises can be downloaded from the Internet. Although project
test & measurement;
is set up the wayRF it is,(radio);
includingcom-
the
this book concentrates on ARM microcontrollers from Atmel, the C programming language ap- use
puters
of datasheets.
and peripherals;
Even afteraudio youve
& video;
built
plies equally to other manufacturers ARMs as well as other microcontrollers. This is an ideal all
hobby
the and
projects
modelling;
it will still
microcontrollers;
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!
446
432 pages ISBN 978-0-905705-70-5
978-0-905705-69-9
324 pages ISBN 978-0-905705-80-4 32.50 US $52.00 27.95
19.95 US $55.90
$39.95
80 elektor - 4/2009
Bestseller!
45 projects for PIC, AVR and ARM A DIY system made from recycled components 110 issues, more than 2,100 articles
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
TW8 9HH
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: sales@elektor.com 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
SHOP BOOKS, CD-ROMS, DVDS, KITS & MODULES
CD/DVD-ROMs
Bestseller!
LED Top
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
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)
82 elektor - 4/2009
April 2009 (No. 388) US $
Bestsellers
Product Shortlist
Books Books
080253-71 ....Kit of parts incl. PCB-1 with SMDs prefitted ............... see www.elektor.com
090146-91 ....ARMee plug-in board mk. II ......................................see www.elektor.com
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
CD-ROMs
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
4/2009 - elektor 83
info & market coming attractions
Article titles and magazine contents subject to change, please check Magazine on www.elektor.com 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.
84 elektor - 4/2009
Order Form
04-2009
Description
C Programming
Price each Qty. Total Order Code
METHOD OF PAYMENT
(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
NEW
DVD Elektor 2008 17.50
NEW
DVD Elektor 1990 through 1999 69.00
Phone: 603-924-9464
Fax: 603-924-9467
EL04 E-mail: custservus@elektor.com
Order Form
04-2009
Subscription-Plus
(11 issues plus the Elektor Volume 2009 CD-ROM)
Elektor
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
www.elektor.com
EL04 subscriptions@elektor.com
ORDERING INSTRUCTIONS, P&P CHARGES
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: www.elektor.com/shop
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)
HOW TO PAY
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
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.
TERMS OF BUSINESS
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
Further information
tion and ordering at www.elektor.com/shop
INDEX OF ADVERTISERS
Avit Research, Showcase. . . . . . . . . . . . . . www.avitresearch.co.uk . . . . . . . . . . . . . . . . . 78 MikroElektronika. . . . . . . . . . . . . . . . . . . . . www.mikroe.com . . . . . . . . . . . . . . . . . . . 16, 17
4/2009 - elektor 87