www.elektor-magazine.com •magazine September 2013 * Q- Watt 200 watts Monoblock I Manchester coded rf LinkiGnublin Extension Boards lEiektor Cardioscope Software I From Basic to Python (3) • Dot- Labs Tips & Tricks • Blood pH/C0 2 /0 2 Meter us $9.00 - Canada $10.00 0 9 25274 24965 7 7 TAKE ADVANTAGE OF OUR WEEKLY SUMMER DEALS! '"A ^ A Register for our FREE Elektor.POST newsletter to receive our weekly Summer Deals* *lf you already receive Elektor.POST you don’t have to act. You’ll automatically receive our Summer Deals. THINK DISPLAY DESIGN IS DIFFICULT? JT 4)) P, /a' 600 ft) over-air data link between two PCs or microcontroller systems. This month we kick off with a description of the hardware side of things. 54 Using Libraries Neil Gruending continues his get- u-going advice for the DesignSpark electronics design software suite. This month he discloses quick ways to working with libraries. Projects 10 Q-Watt Audio Power Amplifier Audio fans, here's a fully analog, very powerful, very low distortion design from the famed Elektor Audio Labs. It's based on the LME49881 integrated circuit from Texas Instruments, and has complementary bipolar transistors in the power output stage. 28 Gnublin Extension Boards Thanks to Linux being used as the common abstraction layer, Raspberry Pi, the Elektor Embedded Linux Board and even the new BeagleBone Black can use the extension boards described in this article: Relay Module, Temperature Module, Display Module, Step Module, and I/O Expander. 34 Android Elektor Cardiyscope Much of the power and versatility of the Elektor Cardioscope is due to the clever software developed for the project. This month we describe how the PIC24 controller does just what the doctor ordered. 44 From Basic to Python (3) In this concluding part of the series we describe how Python can be used to provide a communication platform for the ElektorBus. As it turns out, the exercise is less complex than when using vintage Basic, with far better results though within easy reach. 4 | September 2013 | www.elektor-magazine.com Volume 39 No. 441 September 2013 • Labs 58 .Labs Tips & Tricks A Cheater's Guide to success at Elektor.Labs and from there on, towards publication in the magazine. 60 90 Degrees and Rising Components running hot to the touch can be a real hazard, and in some cases there's no way to avoid fitting them to a heatsink as one of our junior lab workers discovered the hard way. • Industry 62 News & New Products A selection of news items received from the electronics industry, labs and organizations. • Tech the Future 66 Internet @ the Physical Layer Concerns have been raised on the expansion rate of data versus that of the hardware structure supporting the Internet, particularly at the IXs. Are these concerns justified? • Magazine 70 Retronics: Radiometer PHM22 / PHA928a Blood pH / 0 2 / C0 2 Analyzer In the 1960s a cartload of equipment and a lot of patience were required to perform simple hematology related tests in hospital labs. Series Editor: Jan Buiting. 74 Hexadoku Elektor's monthly puzzle with an electronics touch. 76 Gerard's Columns: ConFused A column or two from our columnist Gerard Fonte. 82 Next Month in Elektor A sneak preview of articles on the Elektor publication schedule. www.elektor-magazine.com | September 2013 | 5 Community Volume 39, No. 441 September 2013 ISSN 1947-3753 (USA /Canada distribution) ISSN 1757-0875 (UK / ROW distribution) www.elektor.com Elektor Magazine is published 10 times a year including double issues in January/February and July/August, concurrently by Elektor International Media 111 Founders Plaza, Suite 300 East Hartford, CT 06108, USA Phone: 1.860.289.0800 Fax: 1.860.461.0450 and Elektor International Media 78 York Street London W1H 1DP, UK Phone: (+44) (0)20 7692 8344 Head Office: Elektor International Media b.v. PO Box 11 NL-6114-ZG Susteren The Netherlands Phone: (+31) 46 4389444 Fax: (+31) 46 4370161 USA / Canada Memberships: Elektor USA P.O. Box 462228 Escondido, CA 92046 Phone: 800-269-6301 E-mail: elektor@pcspublink.com Internet: www.elektor.com/members UK / ROW Memberships: Please use London address E-mail: service@elektor.com Internet: www.elektor.com/member USA / Canada Advertising: Peter Wostrel Phone: 1.978.281.7708 E-mail: peter@smmarketing.us UK / ROW Advertising: Johan Dijk Phone: +31 6 15894245 E-mail: j.dijk@elektor.com www.elektor.com/advertising Advertising rates and terms available on request. Copyright Notice The circuits described in this magazine are for domestic and educational use only. All drawings, photographs, printed circuit board layouts, programmed integrated circuits, disks, CD-ROMs, DVDs, software carriers, and article texts published in our books and magazines (other than third-party advertisements) are copyright Elektor International Media b.v. and may not be reproduced or transmitted in any form or by any means, including photocopying, scanning and recording, in whole or in part without prior written permission from the Publisher. Such written permission must also be obtained before any part of this publication is stored in a retrieval system of any nature. Patent protection may exist in respect of circuits, devices, components etc. described in this magazine. The Publisher does not accept responsibility for failing to identify such patent(s) or other protection. The Publisher disclaims any responsibility for the safe and proper function of reader-assembled projects based upon or from schematics, descriptions or information published in or in relation with Elektor magazine. © Elektor International Media b.v. 2013 Printed in the USA Printed in the Netherlands Red Fruits, Italian Heroes, Penguins, and Texan Bones Ever since Steve Wozniak assembled a 6502 based microprocessor system, and Steve Jobs literally created a market for it, we techno- inclined folks have delighted in creating and hearing product names with a disarming, if not charming, ring: apple, raspberry, acorn, pen- guin, Captain Zilog, KIM, Junior. I'm convinced a good number of the names given to micro- processor systems and platforms from the early days of computing have helped significantly to unnerdify the craft of programming and staring at command lines for hours on a 15-inch CRT screen propped up by pizza boxes. The Linux community in particular has set the bar in creative product naming with every new release of "their" operating system. Where the "men in suits" simply put the next higher number behind the product name, a letter "b", or a year, the follow- ers of Tux the Penguin came up with names you'd expect from a Tolkien book. The main embedded platforms with clearly defined entry levels and educational aims are Raspberry Pi and Arduino, and both are covered extensively in Elektor. Magazine and Elektor.POST. However, in good engineering tradition there's more to choose from in a diversified market. Elektor's Embedded Linux board is linked this month to a range of extension boards through its "Gnublin" connector (that'll be a young goblin running GNU's Not Unix). The same boards, we're proud to say, also connect seamlessly to the Raspberry Pi and— as we've just discovered— to the BeagleBone Black. Have a look at the article on page 28 to see how our modules for controlling relays, displays, stepper motors, I/O devices and temper- ature sensors can be connected to the latest embedded microcontroller systems running Linux as the abstraction layer. Keeping abstraction and fantasy apart was never easier though as Penguin, Beagle and Gnome seem to get along very well, at least in this edition of Elektor. Let's hope no unadapt, badly named creatures appear on stage, like T-Roll or CE02B. More creatures and creations in this issue! Jan Buiting, Editor-in-Chief The Team Editor-in-Chief: Associate Editor: Publisher / President: Membership Managers: International Editorial Staff: Laboratory Staff: Graphic Design & Prepress: Online Manager: Managing Director: Jan Buiting Thijs Beckers Hugo Van haecke Shannon Barraclough (USA / Canada), Raoul Morreau (UK / ROW) Harry Baggen, Eduardo Corral, Wisse Hettinga, Denis Meyer, Jens Nickel Ton Giesberts, Luc Lemmens, Tim Uiterwijk, Clemens Valens, Jan Visser Giel Dols, Jeanine Opreij, Mart Schroijen Danielle Mertens Don Akkermans 6 September 2013 www.elektor-magazine.com Our network USA Hugo Van haecke + 1 860-289-0800 h.vanhaecke@elektor.com United Kingdom Wisse Hettinga +31 46 4389428 w.hettinga@elektor.com Germany Ferdinand te Walvaart +49 241 88 909-17 f.tewalvaart@elektor.de France Denis Meyer +31 46 4389435 d.meyer@elektor.fr Netherlands Harry Baggen +31 46 4389429 h.baggen@elektor.nl Spain Eduardo Corral +34 91 101 93 95 e.corral@elektor.es Italy Maurizio del Corso +39 2.66504755 m.delcorso@inware.it Sweden Wisse Hettinga +31 46 4389428 w.hettinga@elektor.com Brazil Joao Martins +35 19 14 46 55 77 j.martins@elektor.com Portugal Joao Martins +35 19 14 46 55 77 j.martins@elektor.com India Sunil D. Malekar +91 9833168815 ts@elektor.in Russia Nataliya Melnikova +7 (965) 395 33 36 Elektor. Russia@gmail.com Turkey Zeynep Koksal +90 532 277 48 26 zkoksal@beti.com.tr South Africa Johan Dijk +31 6 1589 4245 j.dijk@elektor.com China Cees Baay +86 21 6445 2811 CeesBaay@gmail.com VOICE !*l COIL CIRCUIT CELLAR Ttaf! "Mi)) K>*rc r {■WXC4.0 Iii«: m&mCi c w.-v Connects you to Supporting Companies AP Circuits www.apcircuits.com 57 Beta Layout I www.pcb-pool.com 57 Cleverscope www.cleverscope.com 73 Crystalfontz ■ |; v rvyila'ftvV.j drnMca www.crystaifontz.com 61 ^ DLP Design &es igr. www.dlpdesign.com 61 ExpressPCB www.expresspcb.com 63 EzPCB www.ezpcb.com 73 eg ress pc b Fabstream FabSxrenm www.fabstream.com 27 FTDf FTDI www.ftdichip.com 3 [ Tm ' . T ftJ HuMANDATA www.hdl.co.jp/EL/. 65 t fr International SoC Conference ^ - S': .n www.socconference.com 84 SIPololu Pololu ijobofics * Ei&sinmici www.poioiu.com 69 E3Saeli| Saelig www.saelig.com 57 JcE VsVi IS Not a supporting company yet? Contact Peter Wostrel (peter@smmarketing.us, Phone 1 978 281 7708, to reserve your own space in Elektor Magazine, Elektor«POST or Elektor.com www.elektor-magazine.com September 2013 7 Community Compiled by Wisse Hettinga Elektor World Every day, every hour, every minute, at every given moment designers and enthusiasts are thinking up, tweaking, reverse-engineering and developing new electronics. Chiefly for fun, but occasionally fun turns into serious business. Elek- tor World connects some of these events and activities — for fun and business. I I The CAN Man Came In preparation of a project on CAN, Jan Visser, member of the Elek- tor Labs team, invited its developer, Hugo Stiers, onto our prem- ises to discuss some issues with the design. This visit ended up as an afternoon dedicated to the World of CAN! Hugo is an expert in the field of CAN and previous instructor with DAF Trucks. He is the type of technician who only believes what his hand can touch, so he brought in a truck \ oad of boxes, PCBs, cables and notebooks to assist in field testing. Watching Hugo and Jan work together on this project proved a great pleasure. In no time they created their own 'world of wires' where time does not seem to exist. The result of the many hours of tinkering: all is working as it should! Jan worked out the final details on the CAN project, which is published elsewhere in this issue. Thanks Hugo for visiting Elektor Labs. Get the Picture Are you still pondering on what you can do with Arduino? Huib Theunissen, partner of one of our sales team mem- bers, surprised us with a series of 'single shot' photo- graphs —all timed and triggered with an Arduino board. He uses all six outputs of the board to trigger drops of differently colored liquid, a gun firing a bullet, the flash light of his camera and the shutter release. After tim- ing these events meticulously down to a split second a beautiful photograph is taken. Huib selected this photograph for us, 'The Speed of Life', which won him first prize in a Nikon challenge. Congrats Huib! Find more of his work on www. face- book. com/druppelfotos. Now it is your turn to think up something nifty to do with Arduino. 8 September 2013 www.elektor-magazine.com All Around the World ... The Ghost in the Castle We were a bit surprised to find some people from LPI (League of Paranormal Inves- tigators) running around in Elektor House... on a ghost hunt! They were looking for unearthly remains of French soldiers who died in the castle and the spirit of Entgen Luyten, the last 'official' witch in Holland. The story goes that she hung herself in the castle's cellar. Mart, our in-house photographer, followed the ghost hunters around and shot some photographs... and they turned out a little unusual. Using the camera flash he has been able to capture the right hunting spirit... "there, right in front of you"! Draught Version 1.0 We are at The Kite in Oxford, UK, a local pub just near the railway station which offers some rooms upstairs for weary travelers. Chief Cli- ent Officer Johan Dijk and I had just wrapped up an enjoyable meeting with RS Components representatives and we were discussing how the draft proposal we sketched would end up in a signed contract. The lady bartender couldn't help overhearing us and offered to help us out: "I can fix you both up with a good draught (pointing at the beers on tap) and then take a picture of you holding it as proof". ...Happy to oblige! From the Pedal to the Saddle The Dutch are proud to be a bicycle loving nation. During the day everything is fine, but towards nightfall they struggle to get the lights of their beloved bikes going, or avoid the police and a hefty fine. Most bikes are equipped with small dynamos. That way pedal power is used to generate the electricity for your lights. But there's a big chance something is broken, and you are in constant fear of being stopped by the police. Wouter Eisema from Hanze Highschool for Engineering came up with a completely dif- ferent solution. The heat of your saddle (or more precisely: your butt) is converted to electricity by Peltier elements which drive LEDs mounted in the back of the saddle. Now isn't that clever!? We are planning a publication on the full project in the near future. ^ From DIY Plotter to JVE CNC In 1987 Elektor published a DIY three color plotter, called Mondriaan. Among the many people building this project was Jonas Vos, a young artist. It was his first project with Elektor and a first step in making art using machines. Now a teacher at the Jan van Eyck Academy in Maas- tricht he decided to build his own CNC machine— a big one! This machine mills all sorts of materials in an XYZ area of 70x94x31 inch (180x240x80 cm). Students are allowed to use this machine to mill huge objects. In the picture you can see Jonas with his machine, as he is operating it. More info on the Jan van Eyck academy: www.janvaneyck.nl www.elektor-magazine.com September 2013 9 •Projects Q-Watt Audio Power Amplifier Lots of power with low distortion Good news for all audio enthusiasts: we are proud to present yet another fully analog circuit developed entirely in house. Despite the simple design of this audio power amp with just one pair of transistors in the output stage, Q-Watt can deliver over 200 quality watts into 4 ohms with exceptionally low distortion thanks to the use of a special audio driver IC. By Ton Giesberts (Elektor Labs) Elektor has a long history with audio power ampli- fiers. A couple of examples of our "golden old- ies" are the Edwin, Ekwin and Crescendo ampli- fiers from the 1970s, which thousands of audio enthusiasts cut their teeth on. In recent years things have been quieter in this area, but that shouldn't be taken to indicate a lack of interest. Quite the opposite— many people are rediscover- ing the pleasure of soldering circuits themselves and putting together top-notch amplifiers with outstanding sound quality. Since it's hardly possible to come up with some- thing original in the realm of audio power ampli- fiers built with discrete components (except par- alleling a few dozen NE5532 opamps...), this time we decided to take the semi-discrete route. This Q-Watt Measured Performance (Measured with a power supply consisting of a 500 VA power transformer with two 40 V secondaries (Nuvotem type 0500P1- -2-040) and four external 10,000 pF, 100 V buffer capacitors) • Input sensitivity: 0.88 V (137 W/8Q, THD+N = 0.1%) 0.91 V (145 W / 8 ft, THD+N = 1%) • Input impedance: 15 kft • Continuous output power: 137 W into 8 ft (THD+N = 0.1%) 145 W into 8 ft (THD+N = 1%) 220 W into 4 ft (THD+N = 0.1%) 233 W into 4 ft (THD+N = 1%) • Peak/music power: 218 W into 8 ft (THD+N = 10%) (DC supply voltage ±56.8 V) 175 W (8 ft, THD + N = 1%) 165 W (8 ft, THD + N = 0.1%) 395 W (4 ft, THD + N = 10%) 316 W (4 ft, THD + N = 1%) 299 W (4 ft, THD + N = 0.1%) • Power bandwidth: 2.1 Hz to 125 kHz (50 W / 8 ft) • Slew rate: 26.7 V/ps • Risetime: 2.4 ps • Signal to noise ratio: > 94 dB (linear, B = 22 Hz to 22 kHz) (reference 1 W / 8 ft) > 97 dBA • Harmonic distortion plus noise: 0.0033% (1 kHz, 1 W / 8 ft) (B = 80 kHz) 0.0006% (1 kHz, 50 W / 8 ft) 10 September 2013 www.elektor-magazine.com Q-Watt Audio Power Amp • Intermodulation distortion: (50 Hz : 7 kHz = 4 : 1) • Dynamic IM distortion: ((3.15 kHz square wave) + 15 kHz sine wave:) • Damping factor: • Efficiency: (DC supply) • DC protection: • DC output offset: • Switch-on delay: 0.006% (20 kHz, 50W/8Q) 0.0047% (1 kHz, 1W/4Q) 0.0009% (1 kHz, 100 W / 4 ft) 0.009% (20 kHz, 100 W / 4 ft) 0.002% (1 W / 8 ft) 0.0009% (50 W / 8 ft) 0.003% (1 W / 4 ft) 0.0026% (100 W / 4 ft) 0.0033% (1 W / 8 ft) 0.0022% (50 W / 8 ft) 0.0045% (1 W / 4 ft) 0.0027% (100 W / 4 ft) 560 (1 kHz / 8 ft) 311 (20 kHz /8ft) 70.6% (8 ft, THD+N = 0.1%) 72.5% (8 ft, THD+N = 1%) 68.5% (4 ft, THD+N = 0.1%) 70.5% (4 ft, THD+N = 1%) + 0.55 V/ -0.86 V 0.2 mV (max. 0.6 mV) 6 s www.elektor-magazine.com September 2013 11 •Projects has the advantage of easy DIY construction, and it results in a very compact design. With a care- ful choice of components, it's possible to create a power amplifier with outstanding specs and sound quality with this approach. Background It all started with the Measurement Filter for Class-D (amplifiers) we published in our July/ August edition in 2011 [1]. We developed this filter at Elektor Labs so that we could measure Figure 1. Schematic of the Elektor Q-Watt audio power amplifier. Despite the simplicity of the design, the specs of this amplifier are truly excellent. K1 O0HHS R4_ 15k +v Q MG6330-R T6 ... Tio = 5 x 2N5550 110656 - 11 12 September 2013 www.elektor-magazine.com Q-Watt Audio Power Amp the output voltages of class-D amplifiers up to 70 V rms . However, we never managed to test the filter with voltages at this level due to the lack of a suitable power amplifier. When there's a prob- lem, you can always trust Elektor designers to come up with a solution, so they started work- ing on the design of a fully discrete high-volt- age amplifier with 23 high-voltage transistors (MJE340, MJE350, MPSA42 and MPSA92), which was intended to operate from a balanced ±110 V supply. The design turned out to be extremely complicated, and things got a bit out of hand. Although a PCB was designed for an initial pro- totype, we had to ask ourselves whether it was worth spending so much effort just to test a filter. The design specifications for the amplifier were truly impressive. It had to be able to deliver an output signal of 70 V rms up to 20 kHz with extremely low distortion. The minimum imped- ance of the measurement filter is 1 kft, resulting in peak output current requirement of 100 mA (preferably even more). We accordingly decided to look for a simpler alter- native, such as an IC that could deliver such a high output voltage with sufficient power. Our search turned up the LME49811 from Texas Instruments. The title of the datasheet, "Audio Power Amplifier Series— High Fidelity 200 Volt Power Amplifier Input Stage with Shutdown", sounded very promising. The stated specifications were excellent, but it wasn't clear to us whether the measured performance figures on the data- sheet were obtained with or without an exter- nal power stage. However, it certainly appeared to be worthwhile to develop an amplifier based on this IC. The right transistors The next step was to select the power transis- tors (T4 and T5) for the power amplifier. One of the key characteristics of power transistors for use in audio amplifiers is a large safe oper- ating area (SOA). We ultimately found a couple of very nice devices at Semelab: the MG6330-R (NPN) and the complementary MG9410-R. These devices can handle more than 600 mA collector current at a collector-emitter voltage of 200 V. This condition occurs when the amplifier is driven to maximum output amplitude with no load. This allows the amplifier to be configured for class-AB operation with a relatively large class-A region. The DC gain of these power transistors is fairly linear up to several amperes (slightly less with the PNP version), which is a good starting point for a linear output stage. Similar requirements apply to the driver transistors (T2 and T3). The selected types-MJE15032 (NPN) and MJE15033 (PNP)— are suitable for voltages up to 250 V, and here as well the DC gain characteristic is fairly lin- ear. The driver and output transistors have fairly high transition frequencies: 30 MHz for the MJE devices, 60 MHz for the MG6330-R and 35 MHz for the MG9410-R. The quiescent current setting is handled by an ordinary BD139. Audio version When one of our foreign editors saw the design, his first question was whether it could be adapted for use as a 'normal' audio amplifier. That would attract a much larger audience than a measure- ment amplifier for high output voltages. The answer was that it was certainly possible, and in fact it wouldn't require many changes to the original design. Some of the component values would have to be adjusted, and the supply volt- age would have to be reduced. The end result is the schematic diagram shown in Figure 1 . With a lower supply voltage (±56 V, provided by a transformer with two 40 VAC secondaries), the power amplifier can deliver a lot of power with just one pair of complementary output transis- tors— more than 300 watts of music power into 4 ohms. In addition to the LME49811 (IC1), the power amplifier consists of four transistors (T2-T5), a quiescent current control network with one tran- sistor (Tl), and a few glue components. The negative feedback network R4/R3 is dimen- sioned to provide an input sensitivity of approxi- mately 1 V rms for a maximum output amplitude of ±55 V with a supply voltage of ±60 V. This input voltage can easily be provided by any modern preamplifier. The resistor values are chosen to ensure that the dissipation of R4 remains just below 0.25 W at maximum output power. The values of resistors R1 and R2 are the same as those of R3 and R4 to maintain the best pos- sible common-mode rejection at the input of the LME49811. The resulting input impedance is approximately 15 kft. The bandwidth of the input signal is limited at the low end by capac- itor Cl (with a theoretical corner frequency of 2.2 Hz) and at the high end by C2. In addition to www.elektor-magazine.com September 2013 13 •Projects suppressing any HF noise that may be present, this limits the slew rate to prevent the ampli- fier from experiencing problems with excessively steep input signals. Only one capacitor (C3) is needed for the frequency compensation of the IC. To make it easy for users to experiment with the amplifier, we use a trimmer with PTFE (Teflon™) dielectric for this purpose (Teflon is an excellent choice for audio circuits). The PCB is also suit- able for silver mica capacitors with a lead pitch of 5.9 mm. During testing a trimmer setting of one- third of the rated value (approximately 18 pF) yielded the best measurement results. A feedback loop built around IC2 stabilizes the DC output voltage of the amplifier. It compares the output voltage to the ground reference and corrects it by injecting a very low current into the non-inverting input of the LME49811 (pin 4). The non-inverting input is used for this correction because the impedance at this input is higher than at the inverting input, whose impedance is largely dependent on the value of R3 (which is only 390 ft). The response time is a few hundred milliseconds. We choose an OPA177 for the con- trol amplifier on account of its outstanding DC specs (maximum bias current 1.8 nA, maximum offset 60 pV). The resulting maximum theoretical offset voltage at the output of the power amplifier is 0.6 mV, which is negligible for the connected loudspeakers. The output offset voltage of our prototype was just 0.2 mV. The opamp in the DC correction circuit has its own ±15 V supply voltages tapped off from the main supply rails with the aid of a few resistors and Zener diodes (R17, R18, D1 and D2). The values of R17 and R18 must be adjusted if a lower supply voltage is used. In this connection an additional current of 1.5 mA drawn from the + 15 V rail by pin 2 of IC1 must also be taken into account. A Zobel network (R13-C5) is included at the out- put of the amplifier. It ensures that the ampli- fier remains stable with an inductive load or no load. Coil LI provides additional protection against capacitive loads, and resistor R12 attenuates any oscillations or overshoots. On the PCB, R12 is fitted inside LI to save space. Two large buffer capacitors (4700 pF each) are also fitted on the circuit board. The selected types have low equivalent series resistance (ESR). The circuit additionally requires an external power transformer, bridge rectifier and four power sup- ply capacitors rated at 10,000 pF, 100 V each. We chose a transformer with two 40-V second- ary windings. For the prototype at Elektor Labs we used a low-cost 500 W transformer, with the result that the output voltage drops a fair amount with a relatively large load. Somewhat higher power output than stated in the specifications would be possible if you use a transformer with better voltage stability. Supply lines Very high peak currents occur in power amplifiers. To buffer the supply voltage, two electrolytic capacitors with low ESR are mounted on the PCB adjacent to the output transistors, in addition to the external capacitors in the power supply. With an audio amplifier, it is essential that the supply lines to and on the board do not cause magnetic field interference, which can increase distortion by inducing currents in the negative feedback loop and other parts of the amplifier. One way to suppress this undesirable effect is to route the supply lines as close together as possible and to decouple them as close as possible to the output stage. Due to the class AB configuration of this amplifier, only unidirectional currents flow through the supply tracks on the board. Routing the positive and negative supply tracks as close together as possible causes the resulting magnetic field to be nearly sinusoidal, so it causes less distortion. With a double-sided board, these two tracks can be placed on opposite sides of the board exactly aligned to each other. These design considerations are very important for power amplifiers with very low distortion figures. Single-point grounding is also very important in this regard. Here the ground point is located next to C5. The ground lines of the input, negative feedback, Zobel network, loudspeaker output and power supply all meet at this point. The PCB is specifically designed for use as a monaural amplifier (monoblock). For a stereo amplifier you can simply build two of the boards and mount them in an enclosure together with the power supply. You should preferably use two separate power supplies (one for each channel). 14 September 2013 www.elektor-magazine.com Q-Watt Audio Power Amp Protection We naturally hope that the amplifier will always work properly, but any electronic circuit can fail (especially audio power amplifiers, as we know from experience). Especially at full output power, the temperature of the output transistors can rise sharply (to above 70 °C), which can dramat- ically shorten the lifetime of these semiconduc- tor devices. Our experience is that when tran- sistors fail, they usually fail shorted. If a fuse doesn't blow somewhere in this case, a hefty DC voltage will be present at the amplifier out- put, which is naturally not the right way to treat your precious loudspeakers. For this reason, DC protection is actually indispensable in any audio power amplifier. After the amplifier is switched on, it takes a few seconds for the DC voltage at the output to sta- bilize. As usual, the loudspeaker is connected to the output through a relay. This relay may close only when the supply voltage for the amplifier is present, and there is no DC voltage at the output of the amplifier. In this design, only the positive supply voltage is monitored by using it as the supply voltage for the protection circuitry built around T6 to T10. If there is no supply voltage, it is simply impossible to energize the relay coil. DC protection is provided by a pair of transistors and a low-pass filter (R23/C15) with a time con- stant of 3.3 s. That may seem like a fairly long time, but the time required for T7 or T8 to start conducting and discharge C16 decreases with a decreasing DC voltage at the output. If there is a positive DC offset of more than 0.55 V at the output, T8 will conduct and disengage the relay via T9/T10. Transistor T7 responds similarly if there is a negative DC offset greater than 0.85 V. In addition, both transformer secondary voltages are monitored so that the relay can be disen- gaged immediately when the power transformer is switched off, or a fuse blows. To avoid creating a ground loop, the secondary transformer voltages are monitored using optocoupler IC3, which feeds its output signal to T6 in the protection circuit. Diodes D3 and D4 in combination with capacitor C14 act as a full-wave rectifier for the LED in the optocoupler. The voltage divider R4/R3 is dimen- sioned so that the LED goes dark immediately if either of the transformer voltages drops out. Capacitor C16 in combination with resistors R25 and R26 determines the time delay for engaging the relay after the supply voltage is switched on (approximately 6 seconds). The relay used here has a rated coil voltage of 48 V. It is connected to the 56 V supply rail via a 1 kft series resistor (R29). If you have trouble finding a 48 V relay, you can use a 24 V relay instead. In that case R29 must be a 1 W type with a value of 2.2 kft. The protection circuit is dimensioned for a supply voltage of ±56 V. If you use a lower supply volt- age, some of the resistor values will have to be Cooling Adequate cooling must be provided for the driver transistors, output transistors and IC1. For the IC this consists of a piece of 2-mm aluminum sheet metal measuring 2.5 x 8 mm, which is mounted on the IC with a pair of screws and nuts. This heatsink is sufficient to handle the 2 W or so dissipated by the IC with a supply voltage of approximately ±56 V. Choosing the heatsink for the output transistors involves a tradeoff between the size of the heatsink and the estimated average output power of the amplifier. A very large heatsink or forced air cooling would be necessary to handle continuous full output power, but this occurs very rarely in practice. We therefore decided to look for a heatsink that is big enough to handle the full output power for a short while (several minutes). We found a good match in a heatsink from Fischer Elektronik, Germany. It's not exactly small, but there's no getting around a low thermal resistance if you want to avoid overheating with high output power. The selected heatsink has a height of 10 cm and a thermal resistance of 0.7 K/W. To give you an idea of what this means, with a regulated supply voltage of ±56.8 V the amplifier can deliver nearly 300 W into a4Q load with 0.1% distortion. With an efficiency of 68.5%, this means that it must dissipate about 137 W. With a continuous sine-wave signal, at full output power the temperature would rise to more than 90 degrees above the ambient temperature. The emitter resistors R10 and Rll (5 W types) would also be on the ragged edge at this point. However, as already mentioned this will never happen in normal use with music signals. By the way, there is virtually no manufacturer of audio amplifiers that dimensions their heatsinks for continuous full power. www.elektor-magazine.com September 2013 15 •Projects Figure 2. The PCB holds the entire power amplifier, including buffer capacitors and protection circuitry. COMPONENT LIST Resistors (5%, 0.25W, unless otherwise stated) R1,R3 = 390ft R2,R4,R17,R18,R22,R23,R30 = 15kft R5 = 8.2kft R6,R20,R28 = 1.2kft R7 = 220ft R8,R9 = 100ft R10,R11 = 0.2ft 1% 5W, low inductance (Vishay Dale LVR05R2000FE73) R12,R13 = 3.9ft 5% 5W R14 = 220kft R15,R16 = lOMft R19 = 27kft R21 = 470kft R24 = lMft R25,R26 = 820kft R27 = 68kft R29 = lkft PI = 470ft trimpot, horizontal Capacitors Cl = 4.7pF 63V, MKT (metal/polyester), 5mm or 7.5mm pitch C2 = 1 nF/400 V, MKT (metal/polyester), 5mm or 7.5mm pitch C3 = trimmer 5-57pF 250V, horizontal (Vishay BC- components BFC280908003) C4,C6,C7 = lOOnF 100V, 5mm or 7.5mm pitch C5 = 47nF 400V, 5mm or 7.5mm pitch C8,C9 = 4700pF 100V, 10mm pitch, snap-in, 30mm diam. (Panasonic ECOS2AP472DA) CIO = 2.2pF 63V, 5mm or 7.5mm pitch Cll = 33nF 63V, 5mm or 7.5mm pitch C12,C13,C16 = lOpF 100V, 2.5mm pitch, 6.3mm diam. C14 = lpF 250V, 2.5mm pitch, 6.3mm diam. C15 = 220pF 16V bipolar, 5mm pitch, 10mm diam. Inductor LI = 450nH: 13 turns 14AWG (1.5 mm) enameled copper wire, 7mm inside diam. Semiconductors D1,D2 = 15V 0.5W zener diode D3,D4 = 1N4004 D5 = 1N4148 D6 = LED, red, 3mm T1 = BD139 T2 = MJE15032 T3 = MJE15033 T4 = MG6330-R T5 = MG9410-R T6-T10 = 2N5550 IC1 = LME49811TB/NOPB IC2 = OPA177GPG4 IC3 = 4N25 Miscellaneous K1 = 2-pin pinheader, 0.1" pitch K2-K6 = Faston (blade) plug, PCB mount, 0.2" pitch K7 = 3-way PCB screw terminal block, 5mm pitch RE1 = relay, PCB mount, SPCO, 16A, 48V coil, 5.52kft (TE Connectivity/Schrack type RT3 14048) TO-220 isolating washer for Tl, T2, T3, Kapton MT film, 0.15mm, 6kV TO-3P isolating washer for T4,T5, Kapton MT film, 0.15mm, 6kV TO-220 3-mm isolating bush forT2,T3 Heatsink, 0.7K/W (e.g. Fischer type SK 47/100 SA) Heatsink for IC1, dim. 25x 80 mm, 2 mm thick aluminum PCB # 110656-1, see www.elektor.com/1 10656 Power Supply (for one amplifier) Power transformer: sec. 2x40V, 500VA (e.g. Nuvotem 0500P1-2-040 for 230 VAC mains) Bridge rectifier: 200V, 35A (e.g. GBPC3502) (Fairchild) Four 10,000pF, 100V electrolytic capacitors (2 in par- allel on each supply rail) 16 September 2013 www.elektor-magazine.com Q-Watt Audio Power Amp adjusted. This also applies to the resistors in the negative feedback network if you want to main- tain an input sensitivity of around 1 V. Bear in mind that the gain factor of the LME49811 must be at least 20 (26 dB). Construction Figure 2 shows the circuit board layout designed for this amplifier. As promised by the title of this article, everything has been kept nice and compact. Building the board is certainly not difficult, but there are a few points that require attention. Most of the components can be soldered directly on the board, with the exception of T1-T5, IC1 and the supply capacitors C8 and C9. Blade connec- tors (Faston 6.3 x 0.8 mm) are soldered to the PCB for connecting the supply voltage and the loudspeaker. Coil LI consists of 13 turns of AWG #14 (approx. 1.5 mm) enameled copper wire wound on a 7-mm drill bit. Leave the ends long enough to allow the coil to be mounted a small distance above the board. The coil leads must be bent to point directly away from the middle of the coil. Place resistor R12 inside coil LI and bend its leads so they line up with the corresponding holes in the PCB. Fit these two components on the board at the same time, and when soldering the leads ensure that the coil is raised a bit above the board surface and the resistor is properly located in the middle of the coil (see Figure 3). Before going any further, you need to know what enclosure you will be using, so that you can deter- mine how to secure the heatsink and the circuit board in the enclosure. The most convenient solution is to attach two aluminum brackets to the heatsink and use them to secure the circuit board. This way you can still perform tasks on the PCB after the transistors have been mounted on the heatsink. The circuit board must be mounted on the heat- sink so that the leads of the transistors are as close as possible to the corresponding pads on the board. Using needle-nose pliers, form the leads of T1-T5 into shallow S shapes so that the leads project slightly and fit into the holes in the PCB without any mechanical stress. Make the first bend as close as possible to the package. Never bend the leads directly; always place a small metal plate against the pins next to the pack- age to prevent the formation of microcracks in Figure 3. Detail of output coil LI with power resistor R12 fitted co-axially. the package. Make the second bend at the level of the holes in the PCB. Figure 4 shows what it should look like. The insulator pads for the tran- sistors can be temporarily placed between the transistors and the heatsink to determine the exact position of the second bend. Actually this is not critical unless you use ceramic insulator pads. Secure the transistors firmly to the heat- sink (with the insulator pads in place) before soldering the leads to the board. Next comes IC1. Start by attaching a heatsink plate, consisting of a piece of 2-mm aluminum sheet metal measuring 2.5 x 8 mm, to the IC with a pair of screws and nuts. Mount the heatsink so that it is a bit above the board when the IC is fit- ted, to avoid contact with Rl, R4 and R5. Caution: Figure 4. The leads of all transistors mounted on the heatsink are formed with two bends so they fit precisely in the corresponding holes in the PCB without mechanical stress. www.elektor-magazine.com September 2013 17 •Projects Figure 5. There's just enough space on the circuit board for the heatsink that has to be mounted on IC1. the metallic rear surface of the IC is connected to the negative supply voltage. This means that if you do not use insulated mounting hardware, the heatsink will be at the negative supply volt- age. For safety, we recommend using insulating mounting hardware here. Then solder the IC to the PCB. Just enough space for the heatsink has been kept free on the board (see Figure 5). Bend LI slightly away from the heatsink. The final task is to mount the two large buffer capacitors C8 and C9. That way they don't get in the way of earlier activities. Q-Watt on test run Before you connect your Q-Watt amplifier directly to the power supply, you have to set the quies- cent current of the output stage. To do this, first connect two 47 ft, 5 W power resistors in series with the positive and negative supply voltage terminals. This prevents damage to the ampli- fier circuit if something is wrong, such as a short somewhere. The worst that can happen is that the two power resistors go up in smoke. Another option is to use a regulated power supply with current limiting, but most of us don't have this sort of supply available for ±56 V. Connect an ammeter in series with the positive supply line. Before switching on the supply voltage, turn PI fully counterclockwise, and remember to con- nect the secondary windings of the transformer to terminal block K7 on the circuit board. After the power is switched on, the current through the positive supply line should be approximately 30 mA when the output relay is engaged. Slowly turn PI to the right (clockwise) until the current increases by 30 mA (60 mA total). This relatively low quiescent current is more than adequate. The quiescent current will rise slightly as the heat- sink temperature increases. However, it will nor- mally remain below 90 mA. At very high output power levels, the junction temperatures of the two output transistors will rise much faster than the temperature of the heatsink, so the quiescent current transistor will not be able to fully track the change. This causes the quiescent current to rise briefly to several hundred milli-amps, but it declines quickly when the temperature drops again. That's actually a nice extra feature with this amplifier, since the class A range of the power amplifier effectively increases with the output power level. We hope you have a lot of fun building this com- pact power amplifier, and a lot of listening plea- sure afterwards. ( 110656 - 1 ) More details about this power amplifier are available at www.elektor-projects.com/project/110656- simple-audio-power-amplifier.l3247.html Internet Reference [1] Measurement Filter for Class D, Elektor July & August 2011, www. elektor. com/100540 18 September 2013 www.elektor-magazine.com Q-Watt Audio Power Amp Q-Watt Measured Characteristic Curves Test equipment: Audio Precision System Two Cascade Plus 2722 Dual Domain Plot A THD+N at output power levels of 1 W / 8 Q and 50 W / 8 ft, B = 80 kHz. The 1 W curve consists primarily of noise (THD+N = 0.0034%). The distortion does not rise above the noise until just before 20 kHz (THD+N = 0.0052%). At 50 W (which is exactly 20 V, so the results can be compared readily to the performance figures on the LME49811 datasheet) the noise floor is much lower relative to the output voltage. Here you can see that the distortion increases earlier at higher frequencies. At 1 W the distortion is still under the noise. The distortion above 10 kHz is nearly the same as the 1 W curve. The curve for 100 W is not shown here because it is virtually the same as the 50 W curve. The distortion is very low at all output power levels until just before the clipping level. Plot B THD+N versus output power (1 kHz / 8 Q, B = 22 kHz). The measurement bandwidth was reduced here to improve the visibility of the rise in distortion. Here again you can see that the distortion remains very low, while the noise floor drops as the output voltage rises. The clipping point is reached at 127 W, and the distortion rises rapidly above this point. At 137 W the THD+N reaches 0.1%, which is still a usable level for good sound quality. If you really overdrive the amplifier, it can deliver as much as 174 W with 10% distortion. Here it should be noted that with the low-cost power transformer used for the prototype, the supply voltage drops significantly at full output power (at 10% THD it falls to ±51.5 V). Even more output power would be possible with a transformer that provides a more stable supply voltage. Plot C FFT of a 1 kHz signal at 50 W / 8 ft (20 V rms). The levels of the residual harmonics in the supply voltage and the harmonics of the 1 kHz signal are very low, and in practice they would be inaudible. The third harmonic is at -113 dB, equivalent to just 0.0002%. The THD+N at this power level is 0.0006% (B = 80 kHz). 1 0.5 0.2 0.1 0.05 % 0.02 0.01 0.005 0.002 0.001 0.0006 J4P) 20 50 100 200 500 Hz A k 2k 5k 10k 20k 110656-12 1m 2m 5m 10m 20m 50m 100m 200m 500m 1 2 5 10 20 50 100 300 W 110656 - 13 B Hz 110656-14 www.elektor-magazine.com September 2013 19 r— i 1 r } DESIGNSPARK PCB i 1 i Clock Data Differential Manchester By Marcelo Maggi (USA) Modular RF Link using Manchester Code (1) When there is a need to send data to a distant point without using a wired con- nection, either because the location's infrastructure does not allow a twisted pair to link both extremes, or just because one or both of the connected circuits are intended to be portable, or simply wireless, there are several ways to solve this, each of them with its own pros and cons. Let's investigate, solve and solder. Part 1: Hardware In this article we will describe a method to send data via Radio Frequency (RF), in the 315 MHz or 433 MHz ISM bands, at a maximum bit rate of 5000 bps, using low cost but highly reliable components, and implement an RF-friendly pro- tocol, the Manchester Code, reaching distances in excess of about 600 feet (200 m). Two general purpose units have been designed, one for transmission (TX) and one for reception (RX), ready to be used in any application, just by adapting the code of the included microcontroller. Introducing TX, RX and antennas Creating an RF link involves hardware and soft- ware (or firmware), both at the TX and RX end. This first installment of the article will describe the hardware. Designing a reliable RF circuit with discrete com- ponents is not an easy job, and the results are usually far from the expectations— much worse, that is. Fortunately, Linx Technologies have already taken care of this difficult task by offer- ing complete RF modules encapsulated in a hybrid package. A wide range of used frequencies is available, but we will focus on the 315, 418 and 433 MHz bands for the purpose of this article, as these are the main free bands available, depend- ing on where you live. Figure 1 shows the transmitter module and its pin assignments, as shown in the part's data- sheet (available from [1]). Figure 2 is a mimic of the previous, but now depicting the receiver module. There are few active pins. The receiver has more pins, though most are not connected 20 September 2013 www.elektor-magazine.com Manchester-Code RF Link Transmit 5000 bps across >600 ft (NC). According to the datasheet you only need an antenna for basic operation, besides the obvi- ous regulated power supply. Speaking of antennas, this is another very important, but usually forgotten, element of a successful RF link. Once again Linx Technol- ogies provide a solution through its antenna division, Antenna Factor. We will use the V4 wavelength monopole reduced height antenna. Figure 3 shows the 315 MHz band antenna on top of its datasheet. Frequency optimi- zation is indicated by a colored band on the body of the antenna; a green band indi- cates 315 MHz, while blue and red represent 418 MHz and 433 MHz respectively. Designing the transmitter (TX) The TX module simply transmits whatever sig- nal is put onto the DATA pin, with a couple of restrictions of course, but there is no intelligence included, i.e. no data synchronization, no code protection, etc. The user needs to provide/imple- ment this. Have a look at the TX circuit's schematics, shown in Figure 4. The circuit is fairly simple; there's only one connection between the two main com- ponents, the microcontroller and the TX module: pin B0 (RB0/INT, pin 6) of the microcontroller connects to the DATA input of the TX module. The remainder of components is required for proper operation of the two main ones, but they play no active role in the actual data transmission. Components Cl, C2, C3, C7 and C8 for instance are ceramic 0.1 pF decoupling capacitors. R5 is intended to keep the microcontroller running (pin 4 is the reset pin). The oscillator is formed by a standard 20 MHz quartz crystal. The TX module works at 3 V, so the output of our (external) 5-V power supply is first applied to a fixed-voltage regulator type LP2950-30LPR, which provides a steady 3.0 volts to the module. Cl, C5, C6 and R4 are added for additional stabil- ity, as recommended in the module's datasheet. Two additional resistors are connected to the TX module. R3 connects the PD pin to the 3 V supply rail, keeping it High. If Low, this pin will put the TX in a low-current state, in which it is unable to transmit. R1 is a simple wire jumper (0 ft). However, when the transmit power is higher than you are allowed to use according to local regu- lations for ISM-band approved transmitters, it is possible to lower the transmit power by adjusting this resistor. With 0 ft the maximum transmit power is selected, but increasing the resistance GND PDN DATA VCC GND GND LADJ/VCC ANT 8 7 6 5 Figure 1. The Linx TX Module with its pinout from the datasheet. There's just a few connections needed to get this module to work. 33 JJ Q ? 2 H w o 3J zf- O 33 V* O G> — CO f— o ZD K> . i CO m 1 7 NC ANT 2 F NC GND 3 F NC NC 4 F GND NC 5 F VCC NC 6 F PDN NC 7 y RSSI NC 8 F DATA NC 16 15 14 13 12 11 10 9 Figure 2. The Linx RX Module with its pinout. A lot of pins aren't connected rETC^TST ACTOR. ANT-31 5-PW-LP DATA SHEET ’ Product Dimensions 1 i 1 32 (33 5) 1 99 (50 5 4- 0 67’ (17 0 )| 0 3V (8 0 ) 0 CO O LU CO ^ > > > a: o£ OT-CMCO"^-lO CO Q LU CO ^ > > > a: a: Ot— CMCO^lOtOI^- mmmmrnmmm QQQQQQQQCO +5V © ^C2 L C6 □ RIO 12 11 10 MOOn I 10u I I 25 V 12 13 ~Tr9 ^^1 C8 lOOn 14 PI / ^ 10k X 1r8 I RA5/MCLR/VPP RBO/INT RB2/TX/CK RB3/CCP1 VDD IC2 RB4/PGM RB5 RA0/AN0 RA1/AN1 RA2/AN2/VREF RB6/T 1 0SO/T 1 CK1/PGC RA3/AN3/CMP1 RB7/T10SI/PGD RA4/T0CK1/CMP2 RA6//OSC2/CLKOUT RB1 PIC16F628A -I/P RA7/OSC1/CLKIN VSS 10 11 17 18 15 XI i i 16 20MHz 4 5 8 +++ 10 K 2 | 66666666966666 11 12 13 14 15 16 R7 C3 1 NJOn^O C9 lOOn -@+5V 120049 - 12 from Atmel. Just take the PIC out of its socket and drive the TX module directly using K3 (remember to use 3 V swing). Be sure to provide the 5 V sup- ply needed for operation and everything has been taken care of to achieve reliable TX operation. A final note: anyone with a bare knowledge of RF circuitry avoids testing any 10+ MHz RF cir- cuit on a breadboard. The results— if any— will be wayward at best. However, this unit mounted on its PCB will be perfectly breadboard friendly, since all the RF related stuff is taken care of by the TX module. Designing the receiver (RX) Take a look at the schematic in Figure 6. Many already 'familiar' configurations can be seen; plenty of decoupling capacitors (C2, C3, C7, C8 and C9), a 3 V power supply similar to the one presented in the TX diagram (the RX module also works on 3 V), a noise canceling capacitor wired to the microcontroller's power pins (C6), RIO preventing the microcontroller from reset- ting, and a quartz crystal oscillating at 20 MHz. When we discuss the data handling program in the second installment, we will show the impor- tance of having the microcontrollers run at the same frequency on both the TX- and RX side. The connectors for accessing the circuitry from the outside have a similar layout. The only difference is that in the RX module an RSSI (received signal strength indicator) output is available. The ana- log RSSI signal (useful to implement a squelch circuit) is routed to the middle pin of K3 instead Figure 6. The receiver schematic resembles that of the transmitter a great deal. www.elektor-magazine.com | September 2013 23 DESIGNSPARK PCB Figure 7. Top copper layout of the TX PCB. Figure 8. Bottom copper layout of the TX PCB. Figure 9. Component layout of the TX PCB. of the transmit power adjustment pin (logically not available on the receiver module). Parts R9 and Dl, connected to pin 7 (RBI) of IC2, allow a quick check to be run whether the link is working or not. A very simple program lets the transmitter send the command to activate pin RB7 at the receiver side. If the command is transmitted and received correctly, the LED will light up. We will review this in detail when dis- cussing the software. Transistors T1 and T2 effectively form a non-in- verting level converter from the 3 V output of the RX module to the 5 V input of the microcon- troller. Two notes: • Yes, the microcontroller could have been operated at 3 V. But in order to keep the design universal, it is designed for 5 V microcontrollers, to enable the use of older PICs that run on 5 V only. • One transistor and a couple of resistors could have been saved had an inverting level converter been implemented, but then the signal inverting had to be dealt with in soft- ware. We didn't want to complicate things. COMPONENT LIST Transmitter Resistors R1 = Oft R2,R6 = 180ft R3 = 470ft R4 = 10ft R5, R9 = lkft R7 = 330ft R8 = 680ft PI = lOkft multiturn preset Capacitors C1,C2,C3,C7,C8 = lOOnF C4,C6 = lOpF 25V C5 = 3.3pF 50V Semiconductors Dl = LED red, 5 mm pitch IC1 = LP2950-30LPR IC2 = PIC16F628A-I/P IC3 = TXM-315-LR, Linx Technologies (418 or 433 MHz version as appropriate) Miscellaneous ANT = ANT-3 15-PW-LP, Linx Technologies K1 = 2-pin PCB screw terminal block, 5mm pitch K2 = 16-pin SIL connector, 0.1" pitch K3 = 3-pin SIL connector, 0.1" pitch LCD1 = 2x16 characters, DEM16217, Elektor Store #120061-71 XI = 20 MHz quartz crystal PCB #120049-3 24 ! September 2013 www.elektor-magazine.com Admittedly, if one were to design for mass production, the CFO would baulk at our solution. Like with the TX module, you may use whatever microcontroller you like, just by removing the original PIC from its socket and using the three RX module lines. The PCB is 100% breadboard friendly and connects to your other designs in a snap. Building the transmitter (TX) Linx Technologies manufactures the TX modules in three frequencies, which are pin-compatible, so they can easily be interchanged. As stated before, RF design requires special precautions in order to obtain the desired performance. Although Linx Technologies have made a big effort to provide reliable and very stable modules, we must follow their recommendations regarding the PCB layout in order to achieve maximum performance. There are three key instructions to follow: 1. A ground plane on the layer opposite to the module must be implemented. COMPONENT LIST Receiver Resistors R1 = not fitted R2 = 10ft R3,R5,R10 = lkft R4,R6 = lOkft R7 = 330ft R8, R9 = 180ft PI = lOkft multiturn preset Capacitors C1,C2,C3,C7,C8,C9 = 100 nF C4 = 3.3uF 50V C5,C6 = lOuF 25V Semiconductors D1 = LED red, 5 mm pitch IC1 = LP2950-30LPR IC2 = PIC16F628A-I/P IC3 = RXM-315-LR, Linx Technologies (418 or 433 MHz version as appropriate) T1,T2 = BC547B Miscellaneous ANT = ANT-31 5- PW-LP, Linx Technologies K1 = 2-pin PCB screw terminal block K2 = 16-pin SIL connector K3 = 3-pin SIL connector LCD1 = 2x16 character, DEM16217, Elektor #120061-71 XI = quartz crystal, 20 MHz PCB #120049-4 fl Manchester-Code RF Link Figure 10. Our first prototype still needs some changes. Figure 11. Component layout of the RX PCB. Figure 12. The LCD fits right onto the back of the Receiver Module prototype. www.elektor-magazine.com | September 2013 25 DESIGNSPARK PCB 2. No traces should run directly underneath the module, and no conductive items should be placed within a 0.15 inch (3.8 mm) radius of the module's top and sides. 3. The antenna path should be as short as possible. ponents, and an antenna path that's as short as possible (antenna screwed down and soldered). The PCB artwork of the complete RX circuitry as well as that of the TX module can be downloaded from the article web page [2]. The component layout of the receiver module is pictured in Fig- ure 11. The board size is identical to that of the transmitter. At 0.1 inch the lead pitch of the connectors is exactly the same as in the TX module and 100% bread- board compat- ible. As with the transmitters, Linx Technolo- gies offers the receivers geared to three different UHF-band ISM frequencies. In Figure 12 our first receiver prototype is shown, again with the microcontroller socketed for easy reprogramming. With these guidelines in mind, we started the PCB design around the TX module area, and the rest of the components got accommodated accordingly. Figure 7 shows the PCB layout for the complete TX circuit viewed from the component side, while Figure 8 shows the copper (solder) side view. Note the isolated position of the TX module, the ground plane on the copper side and only a few traces on the component side. As recommended, the antenna path is very short. The antenna itself is fixed onto the PCB with a screw. A touch of solder is a good practice to secure electrical and mechanical robustness. The lead pitch of K2 and K3 is 0.1 inch (2.54 mm), so the circuit is easily plugged onto a bread board. The component layout appears in Figure 9. The board measures 3.35 x 1.80 inch (85 x 46 mm). Figure 10 shows a first prototype of the circuit. The microcontroller is mounted in a socket for easy removal in order to be able to easily repro- gram it with updated firmware. Building the receiver (RX) All of the caveats stated during the assembling of the TX module apply to the RX module as well: a large ground plane at the copper side, reasonable separation of the module from the other com- Although it may seem obvious, it will do no harm to emphasize this: for an RF link to work, all RF components: TX module, TX antenna, RX mod- ule and RX antenna, MUST be tuned to the same frequency. The antenna obviously does not dis- criminate between transmission and reception, so the same model is used for the TX and RX modules. A note here: while these antennas are pretty good, they are not perfect. At the trans- mitting side you may want to limit the power (and sometimes the efficiency of the antenna) to stay at or below the level permitted by local regulations. At the receiver end you may want to boost efficiency as much as possible. So feel free to experiment with straight V4 wavelength mono- poles (i.e. rods) in case you need a larger range. This concludes the first part of this article. In next month's second and concluding part we will discuss the software, which has been developed as a true general-purpose solution. (120049) Internet Links [1] www.linxtechnologies.com [2] www.elektor.com/120049 26 September 2013 www.elektor-magazine.com Multi-mode placement Auto-nudge parts, Push and Shove trace editing, Multi-mode DRC, Blind/Buried vias, Auto split plane generation, i -16 layer autorouter, Jumpers and test points, Rules based copper pour SOLO PCB DESIGNJ Ttiis is not a "watered -down” version of another program, this s the ndustry’s best FREE PCB Design Software. Commercial Strength / Industry Proven * Unrestricted / Unlimited Database Manufacturing Driven S ftw D e s 9 n o a e 4# 5ok4l.ri plu r* . : Download the Free Softmare a ■< * V <1 i Order Online \\ - r- u FabStream A DownStream Technologies Solution ©2013 Downstream Technologies, LLC. All rights reserved, Fabstream Is a trademark of DownStream Technologies, LLC. •Projects Gnublin Extension Boards Plus command-line tools for the Elektor Linux board and Raspberry Pi By Benedikt Sauter [l] Previously we published details of a relay board that can be connected to the Elektor Linux board, the Raspberry Pi, and other microcontroller boards. That was but one example of a wide range of expansion boards developed by the Embedded Projects team. The family is complemented by handy command- line tools and a C/C++ API to help you develop your own applications. Figure 1. The Gnublin API spares you the need to deal with SPI, I2C and other device drivers. Once a connector specification has been agreed upon, it becomes possible to put together microcontroller boards and expansion boards in arbitrary combinations. We have previously described [2] the 14-way Gnublin connector on the Elektor Linux board, which will also feature as the 'Embedded Extension Connector' on the Xmega web server board that we will describe in the next issue. In this article we will describe a range of other expansion boards and in particular show how easy it is to control them under Linux. To allow for rapid testing the development team has written a small command-line program to accompany each module. A complete C/C++ API is also available to aid in application develop- GNUBLIN Tools GNUBLIN API User-Space Geratetreiber Kernel CL s_ CD _Q Q_ 0 03 cr CD z> 2 CD C/3 "0 03 O CD X 0 o c 03 □ p m £ 03 03 5 o o — o 2 CD CD CD 03 CD CD LU CD ment. The API sits on top of the standard device drivers for I2C, SPI, GPIO, ADC and so on, and the application developer is spared having to deal with these drivers directly. Instead, he can control a device (such as a stepper motor) using straightforward function calls (see Figure 1). The team is currently also working on a Python API: more information on this at [4]. The idea Linux provides a very good abstraction layer that allows applications to be developed in a way that is independent of the target processor: one simply writes an application 'for Linux'. The new expan- sion boards, which are available via www. elektor. com/gnublin, extend this idea to cover projects that use motors, displays, temperature sensors, relays and much more besides. The boards are connected to the Elektor Linux board using a simple flatcable. • Relay Module (controls eight relays) (130212-91, Figure 2) • Temperature Module (temperature sensor) (130212-95, Figure 3) • Display Module (4x20) (four-line text dis- play) (130212-92, Figure 4) • Step Module (stepper motor driver) (130212-93, Figure 5) • I/O Expander Module (16 digital inputs and 28 September 2013 www.elektor-magazine.com Gnublin Extension Boards outputs) (130212-94, Figure 6) • - Extension Module (display, buttons, real- time clock, buzzer and port expander) (120596-91, Figure 7) If you need to connect more than one expansion board you can use the Bridge Board (130212- 71, Figure 8). As we mentioned previously, an adapter board is also available to interface the expansion boards to the popular Raspberry Pi mini-computer (120212- 72). A new development is an adapter board for the BeagleBone Black (130212-74). Command-line tools The command line is the sine qua non of working with the Linux board. From the command line you can launch and stop applications, administer the Linux system, read system messages and much more besides. The development team has written a number of small command-line tools to help control the Gnublin expansion boards and some of the inter- nal functions of the Linux board. Typing gnublin- at the command line and then pressing 'Tab' will produce a list of these mini-programs. Table 1 shows a sample. The tools are very convenient for initial testing: you can easily determine whether the hardware is connected correctly. As many will know to their cost, it is easy to spend a long time fruitlessly hunting for bugs in software only to discover that the power supply is not connected! The C/C++ API After the module has been connected and tested we can get down to writing a real application. The C/C++ API mentioned above lets you use a range of easy-to-understand function calls, avoiding, for example, the use of pointers and structures. A separate software module is provided for each interface and expansion board (see Table 2). To use these functions with the Gnublin Elektor Linux board you simply need to include the header file gnublin. h: Listing 1 shows an example. Many more code examples can be found on the wiki [ 3 ] . The most recent version of the source code for the complete API can be inspected at [5]. The wiki also shows how a devel- opment environment can be cre- ated to simplify working with the API. Installing the tools and API In principle the API can be used with any embedded Linux board that has drivers for I2C and SPI. Most processors have these interfaces built in, and access to them is almost always imple- mented via a device driver. Below we will look at how the tools and API can be used in conjunction with the Elektor Linux board and the Raspberry Pi. Table 1. Gnublin command-line tools (sample) Tool Example invocation Description gnublin-lm75 (command takes no arguments) Display temperature gnublin-relay gnublin-relay -p 1- o 1 Switch on relay 1 gnublin-adcint gnublin-adcint -c 1 Read internal ADC, channel 1 gnublin-step gnublin-step -p 3000 Move stepper motor to position 3000 www.elektor-magazine.com September 2013 29 •Projects Listing 1. Controlling an I 2 C device #defi ne BOARD_GNUBLIN //#def i ne BOARD_RASPBERRYPI #include “gnubli n.h” int main() { gnubli n_i 2c i2c; i 2c . setAddress (0x42) ; //i2c slave address char buffer [8] ; char RxBuf [8] ; buffer [0] =0x22 ; i 2c . send (buffer , 5) ; i 2c . send (0x12 , buffer, 2); //send 2 bytes register 0x12 i2c. recei ve(RxBuf , 3); i 2c . recei ve (0x23 , RxBuf, 3); // read 3 bytes // read from register } The Elektor Linux board Since its first version the Elektor Linux board has had a suitable connector fitted. The red marking on the flat cable must be oriented towards GPAO (the key on its connector pointing towards the middle of the board). The first version of the board was shipped with an ELDK filesystem, but this was subsequently replaced by a complete Debian image. The procedure for updating older memory cards is described at [6]. Compiling the expansion board tools on the Linux board itself takes a good five minutes. We have therefore built a Debian package that makes installing the tools much simpler. First download the Debian package file on the PC. Then transfer the file to the SD card using the PC's card reader. If the board itself is connected to the Internet you can download the package file directly using the command line: wget https : / / g i thub . com/ embedded pro j ects/ gnubli n-api / r aw/master /gnu bli n- tools . deb The tools are installed as follows: root@gnubli n : ~# dpkg -i gnubli n-tools . deb To remove the package at a later date, use the following command: root@gnubli n : ~# dpkg -r gnubli n-tools Raspberry Pi The easiest way to use the software module on the Raspberry Pi is to connect directly to the source code repository. Boot up the Raspberry Pi and make sure it has an Internet connection. The repository is cloned using the 'git' command: if this is not already installed on your Raspberry Pi, install it as follows: 30 September 2013 www.elektor-magazine.com Gnublin Extension Boards pi@raspberrypi ~ $ sudo modprobe spi -bcm2708 pi@raspberrypi ~ $ sudo modprobe i 2c-bcm2708 pi@raspberrypi ~ $ sudo modprobe i2c-dev These drivers are already present in the most recent version of the Raspberry Pi distribution. As an alternative to the above commands, the module names can be entered permanently in the file '/etc/modules', one module per line: The API requires the following drivers to be activated: pi@raspberrypi ~ $ sudo apt-get install git Now fetch a copy of the repository pi@raspberrypi ~ $ git clone https:// gi thub . com/embeddedproj ects/gnubli n-api . git switch to the source directory pi@raspberrypi ~ $ cd gnublin-api and compile and install the code, examples and the API: pi@raspberrypi ~ $ make && sudo make i nstall spi -bcm2708 i 2c-bcm2708 i 2c-dev The tiny command-line tools can now be used to test any expansion board connected to the Raspberry Pi. ( 130212 ) Internet Links [1] sauter@embedded-projects.net [2] www.elektor.com/130157 [3] http://wiki.gnublin.org/index.php/API [4] http://en.gnublin.org/index.php/API_Python [5] https://github.com/embeddedprojects/ gnublin-api [6] http://en.gnublin.org/index.php/ GNUBLIN-Elektor Table 2. Software API objects (sample) Modul Interface Remarks gnublin_gpio Internal gnublin_adc Internal Currently only available on Elektor Linux board (not Raspberry Pi) gnublin_i2c i — i NJ n Standard I 2 C bus gnublin_spi SPI Standard SPI devices gnublin_pwm Internal Currently only available on Elektor Linux board gnublin_module_lm75 i — i NJ n Temperature sensor gnublin_module_relay i — i NJ n Relay board gnublin_module_pca9555 hH NJ n Port expander with 16 digital inputs and outputs gnublin_module_step u rsl i — i Stepper motor gnublin_module_lcd l-H NJ O Display, 4x20 characters www.elektor-magazine.com September 2013 31 Flowcode 5 is one of the world’s most advanced graphical programming languages for microcontrollers (PIC, AVR, ARM and dsPIC/PIC24). The great advantage of Flowcode is that it allows those with little to no programming experience to create complex electronic systems in minutes. www.elektor.com/flowcode ...for electronics E-Blocks are small circuit boards each of which contains a block of electronics that you would typically find in an electronic or embedded system. There are more than 40 separate circuit boards in the range; from simple LED boards to more complex boards like device program- mers, Bluetooth and TCP/IP. E-blocks can be snapped together to form a wide variety of systems that can be used for teaching/learning electronics and for the rapid prototyping of complex electronic systems. Separate ranges of complementary software, curriculum, sensors and applications information are available. MIAC (Matrix Industrial Automotive Controller) is an industrial grade control unit which can be used to control a wide range of different electronic systems including sensing, monitoring and automotive. Internally the MIAC is powered by a powerful 18 series PICmicro device which connects directly to the USB port and can be programmed with Flowcode, C or assembly. Flowcode is supplied with the unit. MIAC is supplied with an industrial standard CAN bus interface which allows MIACs to be networked together. ...for industrial control Flowkit provides In Circuit Debugging for a range of Flowcode applications for PIC and AVR projects: • Start, stop, pause and step your Flowcode programs in real time • Monitor state of variables in your program • Alter variable values • In circuit debug your Formula Flowcode, ECIO and MIAC projects New features in Flowcode 5 Flowcode 5 is packed with new features that make development easier including: • New C code views and customization • Simulation improvements • Search and replace function • New variable types and features, constants and port variables • Automatic project documentation • New project explorer makes coding easier • Implementation of code bookmarks for program navigation • Complete redesign of interrupts system allows developers access to more chip features • Compilation errors and warnings navigate to icons • Disable icons feature • Improved annotations • Improved links to support media • Support for MIAC expansion modules and MIACbus . . . f or USB projects Lf ■< I .jv ■ ‘I~l - t ...for robotics ■9 -u rsi ■* n e 1 D- Formula Flowcode is a low cost robot vehicle which is used to teach and learn robotics, and to provide a platform for competing in robotics events. The specification of the Formula Flowcode buggy is high with direct USB program- ming, line following sensors, distance sensors, 8 onboard LEDs, sound sensor, speaker and an E-blocks expansion port. The buggy is suitable for a wide range of robotics exercises from simple line following through to complete maze solving. E-blocks expansion allows you to add displays, connection with Bluetooth orZigbee, and GPS. ECIO devices are powerful USB programmable microcontrollers with either 28 or 40 pin standard DIL (0.6”) footprints. They are based on the PIC 18 series and ARM 7 series microcontrollers. ECIO is perfect for student use at home, project work and building fully integrated embedded systems. ECIO can be programmed with Flowcode, C or Assembly and new USB routines in Flowcode allow ultra rapid development of USB projects inclu- ding USB HID, USB slave, and USB serial bus (PIC only). ECIO can be incorporated into your own circuit boards to give your projects USB reprogrammability. More information and products at: www.elektor.com/eblocks •Projects Android Elektor (Part 2) Cardivscope Wireless, button-free: Bluetooth & touch screen Marcel Cremmel (France) in co-operation with Raymond Vermeulen (Elektor Labs) Following on from the description of the hardware for our new ECG interface on tablets or Android smartphones in the July & August 2013 double edition, we're coming back now to the PIC functions and how the program runs, before looking at the Android application. Without going into too much detail though— we're just going to say enough about this to encourage readers to get hold of the code and have a go at development under Android. What does the PIC24 do? Acquiring and transmitting the samples (Figure 5) Three hardware modules included within the microcontroller are used: • the 10-bit ADC and its analog multiplexer, • the UART ( Universal Asynchronous Recei- ver Transmitter) for communicating with the Bluetooth module (= BT), • Timerl for producing the P2HZ and CAL signals. 34 September 2013 www.elektor-magazine.com The ADC's analog multiplexer allows us to convert the three analog inputs DI, DII, and BATT_LEV. The latter signal is produced by a resistive divider (R16/ R17) that yields V 2 of the battery voltage. The ADC is configured in autoconversion and autoscan mode: it takes care of select- ing, sampling, and converting the three inputs without involving the processor. The 2 kHz sampling frequency is more than enough for an ECG signal. The results of the conversions are stored in three 16-bit variables: Channel_DI, Channel_DII and Vbatt. At the end of each of the three conversions, i.e. at a frequency of 2 kHz, an interrupt (_ADClInterrupt) performs the following processing : Cardiyscope Figure 5. Acquiring and transmitting DI and DII samples. Hearts are trumps - that's just the PIC AvgSampleDI AvgSampleDII AvgVbatt OxAA 0x55 Natural binary Natural binary Natural binary 12 ( 3107-16 Figure 6. UART data sequence format. • Every 8 samples, i.e. at a rate of 250 Hz: calculates the average values AvgSam- pleDI, AvgSampleDII, and AvgVbatt. This processing makes it possible to reduce the effect of occasional interference. • Construction and transmission of the asyn- chronous serial data sequence to the BT module. Figure 6 shows the format adopted for this 8-byte sequence. The data are framed by the bytes OxAA and 0x55. These will be used in the Android terminal to perform sequence synchro- nization and hence to identify and read out the samples. The sample values lie between 0x0000 and 0x03FF (10-bit conversion in natural binary), so mis-synchronization is impossible. Selecting the auto-zero time-constants (Figure 7) This software function constantly adapts the DI and DII signal alignment speed (see "Open-heart diagrams" paragraph in 1 st article) so as to stabi- lize each ECG on the screen as rapidly as possible. To achieve this, the MovingAverageCalc() function calculates the moving average of the AvgSampleDI and AvgSampleDII digital sig- nals over a period of 4 s. The DI_Average and Figure 7. Selecting the auto-zero time-constants. NB: The numbering for the illustrations and links follows on from that in the first part of this article. www.elektor-magazine.com September 2013 35 •Projects Figure 8. Receiving orders from the Android smartphone or tablet. DII_Average results are compared with the expected quiescent values in order to select, via AI and BI or All and BII, an auto-zero time-con- stant that is faster when the difference is greater. Let's remind ourselves what is meant by the expression "moving average". The AvgSampleDI and AvgSampleDII samples are stored in a 4 s circular buffer, i.e. here 4x250 = 1,000 words of 16 bits. The MovingAverageCalc() function then calculates the arithmetic mean of the last 1,000 samples from the buffer sufficiently fast. The last sample corresponds to the moment of the calculation and hence moves overtime. Receiving orders from the terminal (Figure 8) There are not many orders that come to the user from the terminal: • a Run/Stop command to enable or block transmission of the data sequences. • interface power-down Note that the interface can only be powered on via its On/Off button • the CALO and CALI commands to control production of the calibration signals. The UART module takes care of serial/parallel conversion for each byte of the message received. The byte reception functions provided in the Microchip libraries do not use interrupts. To avoid wait loops for these functions, which occupy the processor to no useful purpose, we are using the UART receive interrupt. The associated _U2RX- Interrupt function stocks received characters in a buffer of sufficient size (256 bytes). These characters are promptly read by the ReadMs- gRXD2() function. The character string variable AnswerRN42 is assigned as soon as a complete message is received (end sequence = CR-LF). The TestMes- sageRX_BT() function then compares this with one of the commands expected. It affects accordingly the ECG_Run indicator val- idating the transmission of the data sequences (Figure 5), the PowerOff signal, and the Calib indicator confirming the production of the cali- bration signal. Producing the calibration signals (Figure 9) The P2HZ and CAL signals act on the analog mul- tiplexer IC9 (Figure 3, F2) to periodically replace the voltages picked up by the electrodes with a calibration signal with an amplitude of 1 mV. The frequency of the P2HZ signal is 2 Hz with a duty cycle of 20 %, both close to those of an ECG signal. The signal produced by the micro- controller is attenuated by the network R21/R22/ Figure 9. Producing the calibration signals. _T1 Interrupt) ) Calib fc producing the > P2HZ ECG calibration 4 MHz > * 4000 messages > CAL CPU clock t 1 kHz 120107 - 19 36 September 2013 www.elektor-magazine.com Cardiyscope Record and view your own electrocardiograms on your smartphone or tablet! R65 to obtain an amplitude of 1 mV and a mean value of zero. The CAL signal goes high for 10 s every min- ute if the user has enabled it from the tablet or smartphone. These signals are produced by a sequencer built in to the microcontroller. This comprises: • a -f 4,000 frequency divider achieved using a hardware structure ( Timerl module) • a software interrupt function _TlInter- rupt activated 1000 times per second. If the Calib indicator is set, counting variables are incremented and compared with constants to produce the P2HZ and CAL signals. Bluetooth link status (Figure 10) If there is no BT link, there is no point convert- ing and transmitting the ECG signals. The STA- TUS signal produced by the BT module gives this information: link connected (1) or broken (0). The _CNInterrupt interrupt function is acti- vated whenever the STATUS state changes and accordingly affects the ECG_Run indicator and the ADON A/D converter validation bit (Figure 5). The choice made to use an interrupt function obviates the need to interrogate the STATUS sig- nal periodically and hence saves processor time. PIC program sequence The program architecture is conventional (unlike the Android application, as we'll be seeing). After initialization, the following operations are performed: • initialization of the variables, the input/out- put ports, Timerl for producing the calibra- tion signals (see above) and of the UART2 coupler for communicating with the BT module. • configuration of the BT module to 38,400 baud • initialization of the 10-bit ADC: sampling fre- quency 2 kHz, autoconversion and autoscan for the three analog inputs • validation of the CN interrupt the program then goes into an endless loop: ° call TestMessageRX_BT(): read and pro- cess any order received from the terminal ° call MovingAverageCalc(): calculate the DI_Average moving average ° call SetTimeAZ_DI(): selecting the auto- zero time-constants for the DI channel ° call MovingAverageCalc() and SetTi- meAZ_DII() for the DII channel. The average value calculation functions are placed in the endless loop, as the time to perform them is quite long (26,800 CPU cycles, i.e. 6.7 ms). In accordance with programming rules, one avoids using interrupt functions to handle lengthy pro- cessing. In point of fact, the other, lower-priority interrupt functions would not be executed during this time, which could lead to an error. The execution frequency of the endless loop is around 75 Hz, frequent enough for calculating the moving averages and selecting the auto-zero time-constants. Man/machine interface It would be hard to find a more user-friendly (and cheaper) MMI than an Android terminal (or an iPhone). Elektor has already published a great many articles on this subject and even a book, the success of which confirms the great demand: AndroidApps Programming Step by Step by Stephan Schwark [4]. We invite read- ers interested in this subject to explore, extend, and even critique the Elektorcardioscope code available on the Elektor website [3]. It's impos- sible to describe the 1,900 lines of code in just a _CNInterrupt Bluetooth > ECG_Run STATUS > link status detection > ADON 120107-20 Figure 10. Detecting the Bluetooth link status. www.elektor-magazine.com September 2013 37 •Projects Applications Home Contacts Phone Browser Application Framework Activity Window Content View Notification Manager Manager Providers System Manager Package Telephony Resource Location XMPP Manager Manager Manager Manager Service Libraries Android Runtime Surface Media SOLite Manager Framework Core Libraries OpenGL|ES FreeType WebKit Dalvik Virtual Machine SGL SSL libc Linux Kernel Display Camera Bluetooth Flash Memory Binder (IPC) Driver Driver Driver Driver Driver USB Keypad WiFi Audio Power Driver Driver Driver Drivers Management few pages, we're going to give here just enough information to encourage our readers to delve into the source code to find the functions described. Experienced programmers will be able to make any modifications or improvements to it they like. And maybe it will motivate others to start developing Android applications too. As the dynamic scrolling graph demands speed, but the graphic performance of applications devel- oped using Appln ven tor are only mediocre, I had to give up the idea of using this free environ- ment. But I would recommend it for other sim- pler applications, e.g. controlling a Mindstorms robot in BT, or for any of our readers who want to get a taste of programming. Here, I've used Android SDK from Google, also free. The SDK tools (on PC, Mac, or Linux) are included in a popular, free IDE: Eclipse. It takes a long time to install it complete, but it's easy enough if you follow the procedure described by Google. Figure 11. The Android system architecture (this image, reproduced here at small scale just for information, can be downloaded as a high resolution file). Figure 12. All you have to do is drag-and-drop selected elements from the graphic components library in the palette (on left) to the screen (on the right). You need to be pretty familiar with Java and object-oriented language (like C++). Anyone who already knows how to write programs in C will be able to learn it if they are curious and enjoy making a little effort. There are some excellent available [5] as well as my own document on my website [6]. Developing for Android Developing an application for an embedded oper- ating system like Android requires good knowl- edge of its architecture (Figure 11). End users only directly access the applications installed on their terminal (the top layer in the illustration). {h Mam Activity .java < Palette iSsi Palette Fern WViqets [Tj BluetoethSemcejava £ BtLtrtActr.it, .java Qj GraphtYIgava 41 42 43 for ch in c: b=hex (ord (ch) ) b=b . replace (“0x” , ””) b=b . upper ( ) if len(b)<=l: b=”0”+b h=h+b+” “ # iterate over all characters # get hex value # take away leading “0x for better overview” # all in upper characters # e.g. make “0A” out of “A” # separate bytes by space return h # test: if name == “ main s=”HELLO\n” print s, translate2hex (s) www.elektor-magazine.com | September 2013 | 45 •Projects Listing 2: G U It e m p I a t e . py import wx # GUI class MyFrame (wx . Frame) : def init (self, **kwargs) : # create frame wx. Frame. init (self, None, **kwargs) # text box with fixed width font for nice data representati on self . textbox=wx . TextCtrl (self , style = wx . TE_MULTILINE , pos = (5 , 5) , size= (300 , 200)) myfont = wx.Font(12, wx. MODERN, wx. NORMAL, wx.BOLD, False, u’Courier’) self . textbox . Set Font (myfont) self . button=wx . Button (self , -1, “TEST”, pos= (100 , 230) ) # Bindings self . Bi nd (wx . EVT_IDLE , self . On Idle) self . Bi nd (wx . EVT_WINDOW_DESTROY , self . OnDestroy) Listing 3: Serialthread class class Seri althread (seri al . Seri al) : def init (self, port, baud, **kwargs) : # Initialization of port + baudrate seri al . Seri al . i ni t (self) self.sCOM =seri al . Seri al (port) self . sCOM . set Baud rate (baud) # open port if not already open if self . sCOM . i sOpen () “False : self .sCOM.openQ if self .sCOM. isOpen ()“True: print „connected to“, self . sCOM . port else : print „Error opening port“ # Counter for received data blocks self. ctr=0 # Create stop event (to terminate endless receiving loop) # and message queue for thread (to transmit received text to TextCtrl) self . stopevent=th read i ng. Event () self . msgQueue=Queue . Queue ( ) def di sconnect (self ) : # set stop event so endless receiving loop can be interrupted self . stopevent . set ( ) def connect (self ) : # create a new thread object that runs serial thread 46 September 2013 www.elektor-magazine.com Basic to Python self . Bi nd (wx . EVT_BUTTON , self . On Button) def OnIdle( self, event): # if nothing else to do, update text from message queue pass def OnDestroy (self , event): print “Exit” def OnButton (self , event): self .textbox. AppendText (“Button pressed\n”) # # Main program if name == “ main ”: app = wx . App ( redi rect = False) frame = MyFrame (ti tle=”GUI” , size = (320,270)) frame . Show(T rue) frame . Centre ( ) app . Mai nLoop ( ) # to read serial characters self . seri althread = threading. Thread (target=self . readSerial) # clear stopevent and Connect thread self . stopevent . clear ( ) self . seri althread . start () def readSeri al (self ) : # endless receiving loop while not self . stopevent . i sSet () : data=““ # read from port c = self . sCOM . read (1) # synchronize if ord(c) == OxAA: self.ctr += 1 rest = self . sCOM . read (15) data=c+rest # format c to 16 bytes output datastri ng=str (self .ctr) + „\t“ + translate2hex (data) + „\n“ # update message queue self . msgQueue . put (datastri ng) wx . WakeUpIdle ( ) # wake up to update text # end serial thread print „di sconnected“ self . sCOM . close () www.elektor-magazine.com | September 2013 47 •Projects Figure 2. The window created by the code in Listing 2. eter or light-dependent resistor can be connected to the ADCO pin on the expansion connector, as described in [2a] and [2b]. Before proceeding it is necessary to identify the correct serial port on the PC: in the Windows device manager look to see which new COM port appears when the converter is plugged in. Linux users can use the following command Is /dev/tt*U* which will give a result similar to the following: ing functions to increase and reduce the size of the window, to move the window, and so on. The properties of the window are specified in the function ' init ()'. This is where the graphical elements are defined: in this case a text box and a button. In the interests of simplicity the sizes and positions of these elements are fixed. With the help of so-called 'sizers' it is possible to cre- ate a dynamic layout. The next step is to create three event handlers, although two of these will not be not needed until later. Traditionally the name of an event handler starts with 'On'. The 'Bind()' function attaches these functions to specified events: for example, 'OnButtonO' is called in response to a button press. With the class 'MyFrame' defined it can be used in the main program. This first creates a 'wx. App' object, which is mostly concerned with the processing of events. We then create an instance of our window, centered and made visible on the screen. Events are then handled in the infinite loop y app.MainLoop()'. When the program is run the window appears as shown in Figure 2. It already responds to the button being pressed and even supports exten- sive editing functions: pressing the right mouse button brings up a menu for selecting, copying, deleting and inserting text. The program framework can easily be extended, for example to include a function for storing text in a file. ElektorBus: read operations The experimental node is connected to the PC via the USB-to-RS-485 converter. We fit an ATmega328 microcontroller to the small printed circuit board and program its flash memory with the hex file downloaded from [4]. A potentiom- /dev/ttyUSBO The Python script for scanning the serial ports from part 1 of this series [3] can also be used. If any of the scripts given below fails to work, the first thing to check is that the serial port is configured correctly. While experimenting it is possible under some circumstances for the operating system to surreptitiously change the port number. For example, this can happen if a script is using /dev/ttyUSBO and the converter is unplugged and then plugged in again: the con- verter will then be assigned to /dev/ttyUSBl, and the script will not be able to receive data. In normal use this very rarely happens. We can now start to extend the GUI frame- work in Listing 2. First we have to load all the modules required and set the various interface parameters: COMport = “/dev/ttyUSBO” # adjust to suit Baud = 9600 import threading, Queue import serial import time The module 'threading' is needed because serial data reception is carried out in a separate thread from the main code. This in turn is because the receiver needs to run in an infinite loop and this would create a conflict with the main loop in 'wx'. Indeed, this is the most complicated aspect of the program. We create a special class called 'Serialthread' to access the serial interface (Listing 3). An object in this class opens the interface, reads the incoming data bytes, formats them and sends the result via a message queue to the other parts of the program. This runs in an independent infinite 48 September 2013 www.elektor-magazine.com Basic to Python loop until the thread is stopped. A 'Serialthread' object inherits all the proper- ties and methods of the base class 'Serial': the port name, baud rate, functions for reading and writing, and so on. The procedure ' init ()' creates a Serial object that implements all the port operations. The port is opened if it is not already open, and the baud rate is configured. The counter 'self.ctr' is not important for now, but later will be used to number the data blocks. There are two further objects of interest used by the serial thread: a stop event to cause the thread to terminate and a message queue to send data to the GUI. The external interface for starting and stopping the thread is via the methods 'connectQ' and 'dis- connect()'. The 'disconnectO' method simply sets the stop event. The 'connectO' method launches a new thread in which the function VeadSerial()' is executed. This function in turn continuously reads bytes from the interface in an infinite loop until the stop event is received. The thread then terminates and the port is closed. Within YeadSerial()' there is a mechanism for synchronizing to the incoming data. In the Ele- ktorBus protocol each data packet starts with an OxAA byte. When this value is seen, the data packet counter is incremented and a further fif- teen bytes are read in. These are then formatted into a string and placed on the message queue. The function 'wx.WakeUpIdleO' is then called to signal to the GUI part of the program that there is an entry in the message queue that can be read when there is no other work to be done. The 'Serialthread' class thus allows data to be read continuously without affecting the execution of other code. In effect it runs in parallel with the other parts of the program. The class must be instantiated and started from the main program, which means that we have to extend the code in 'MyFrame', which corresponds to the main win- dow, created in the GUI framework script, by adding the following code (after the bindings) to the procedure ' init ()': class MyFrame (wx . Frame) : def init (self, **kwargs) : 1 # T □ GUI 29 AA 00 00 OA 00 05 40 47 40 00 00 00 00 00 00 00 30 AA 00 00 OA 00 05 40 47 40 00 00 00 00 00 00 00 J 31 AA 00 00 OA 00 05 40 47 40 00 00 00 00 00 00 00 32 AA 00 00 OA 00 05 40 47 40 00 00 00 00 00 00 00 33 AA 00 00 OA 00 05 40 48 40 00 00 00 00 00 00 00 34 AA 00 00 OA 00 05 40 47 40 00 00 00 00 00 00 00 ?• 35 AA 00 00 OA 00 05 40 47 40 00 00 00 00 00 00 00 36 AA 00 00 OA 00 05 40 47 40 00 00 00 00 00 00 00 3 7 AA 00 00 OA 00 05 40 47 40 00 00 00 00 00 00 00 1 1 TEST Figure 3. # serial thread Received data displayed in self . seri alrecei ve = hexadecimal. Seri althread (COMport , Baud) self . seri alrecei ve . connect ( ) We now have an object called 'serialreceive' which is connected to the port specified by the variable 'COMport' and which writes all incoming data to the message queue. To see the results we have to extract the text from the message queue and write it to the text box. It is at this point that we make use of the function 'OnldleO' that we prepared earlier: class MyFrame (wx . Frame) : def init (self, **kwargs) : def OnIdle( self, event): # if nothing else to do, update text from message queue while not self . seri alrecei ve . msgQueue . empty ( ) : msg=self . seri alrecei ve . msgQueue . get ( ) self . textbox . AppendText (msg) The 'pass' command was simply a placeholder and can now be deleted. With these changes the incoming data should now be displayed in the text box with incrementing packet numbers as shown in Figure 3. To avoid the appearance of unsightly error mes- sages when closing the window, an extra touch is to add an 'OnDestroyQ' procedure: # Bindings def OnDestroy (self , event): self . seri alrecei ve . di sconnect ( ) ti me . sleep (1) www.elektor-magazine.com | September 2013 | 49 •Projects This will ensure that before the window closes the serial thread is forced to finish. This can take a moment, which explains the need for the 'time. sleep(l)' command. The end result of all the mod- ifications we have described is the new program 'Serialreceivel.py', which, as usual, is available for free download from the Elektor web pages accompanying this article [4]. In the interests of modularity and code clarity the definition of the class 'Serialthread' can be stored separately from the module 'Serialthread. py', as soon as no further changes are planned. It can then be imported into the main program. This requires a further small modification, as the modules required in turn by 'Serialthread' have to be imported from within that module rather than in the main program. The file 'Serialthread.py' therefore also needs to include the following code: import threading, Queue import serial import time from hexfunctions import * import wx class Seri althread (seri al . Seri al) : def init (self, port, baud, **kwargs) : # Initialization of port + baudrate seri al . Seri al . i ni t (self) • • • • # end serial thread print “disconnected” self . sCOM . close () The resulting main program 'Serialreceive2.py' now dispenses with the entire definition block for the class 'Serialthread'. The 'import' lines are also no longer required, as they now appear in 'Serialthread.py'. It must be admitted that this division of the code is not ideal, as the module 'Serialthread.py' is written in a way rather specific to the project rather than being aimed at more general use. ElektorBus: write operations The experimental node includes a red LED. We would like to be able to turn this LED on and off using two buttons on the PC. The byte sequences required on the ElektorBus are as follows: • Turn on: AA 00 00 05 00 0A 00 00 00 00 60 01 00 00 00 00 • Turn off: AA 00 00 05 00 0A 00 00 00 00 60 OO 00 00 00 00 We will need to add a second button and a sec- ond event handler to the GUI program, and give the buttons appropriate labels. To do this we edit ' init ()' in the 'MyFrame' class as follows: def init (self, **kwargs) : # create frame • • • • buttonOn=wx . Button (self , -1, “LED ON”, pos= ( 100 , 230) ) buttonOff=wx . Button (self , -1, “LED OFF”, pos= (200 , 230) ) # Bindings • • • • buttonOn . Bi nd (wx . EVT_BUTTON , self . OnButtonOn) buttonOf f . Bi nd (wx . EVT_BUTTON , self . OnButtonOf f ) The event handler calls the functions 'self.OnBut- tonOn()' and y self.OnButtonOff()'. These have to be expanded: def OnButtonOn (self , event): self . textbox .AppendText (“LED ON\n”) data=b”\xAA\x0O\x0O\x05\x0O\x0A\ X00\X00\X00\X00\X60\X01\X00\X00\X00\X00” self. seri al_thread . sCOM . wri te (data) def OnButtonOf f (self , event) : self . textbox .AppendText (“LED OFF\n”) data=b”\xAA\x00\x00\x05\x00\x0A\ xOO\xOO\x0O\xOO\x6O\xOO\xOO\xOO\xOO\xOO” self . seri al_thread . sCOM . wri te (data) If you look at the source code for the 'Serialthread' class, you might wonder where the function 'write()' is defined. What is happening is that the base class 'serial. Serial' defines this function which the derived class inherits: it therefore does not need to be defined explicitly in the derived class. The result of these changes is the program 'Receive_send.py', which allows the red LED on the experimental node to be turned on and off from the PC. The software is not yet perfect: in 50 September 2013 www.elektor-magazine.com Basic to Python particular it does not implement synchronization with the node. If the node and the PC happen to transmit at the same time, a collision occurs on the bus and data will be lost. This can be avoided by having the PC only transmit a message on the bus immediately after a packet has been received from the node (the ElektorBus 'direct mode': see the ElektorBus specification at [1]). For example, a flag could be set to indicate that a message is to be sent but the actual sending of the appro- priate byte sequence would be delayed until the next data packet is received. Graphs Next we would like to convert the incoming data from textual to graphical form, so that we can for example visualize the output of the A/D con- verter on the node. The standard library for creating graphical output is called 'Matplotlib', and you will need to install this library before proceeding. In the first part of this series we used the simple 'pyplot' interface which provides a quick and easy way to generate graphs. Things get more complicated if we want to embed a graph in a GUI as we have to use the object-oriented interface, which has rather more options. Indeed, the range of options offered can be overwhelming at first. The documentation for Matplotlib can be found at the project homep- age [5], and an example of embedding it in a 'wx' interface can be found at [6]. Before embarking on changes to the 'Serialthread' module make a copy of the code under a different name, for example 'Serialthread_diagram.py'. Now, the values from the A/D converter that we need are in bytes 5 and 6 of the received data packet. The values have to be extracted and then passed to the main program. There are several different ways this might be done: one approach is to add arrays 'x' and 'y' to the 'Serialthread' object as attributes to carry the values. The extra code in ' init ()' is then as follows: class Seri althread (seri al . Seri al) : def init (self, port, baud, **kwargs) : This sets up two empty arrays for the x and y values. The additional attribute 'starttime' allows the total run time so far to be calculated, so that the x-axis of the graph can be labeled in seconds rather than by packet counts. The receive function is modified to extract the A/D converter data, calculate the value and the time- stamp, and place these in the 'x' and 'y' arrays: def readSeri al (self ) : # infinite receiving loop while not self . stopevent . i sSet ( ) : # synchronize if ord(c) == OxAA: self.ctr += 1 rest = self . sCOM . read (15) data=c+rest *256 startti me output ## update x,y Ibyte = ord(rest[6]) hbyte = ord(rest[5]) & 7 adc = Ibyte + hbyte t=ti me . ti me ( ) -self . self . x . append (t) self . y . append ( adc) print t,adc # format c to 16 bytes wx . Wakellpldle ( ) # wake up to update text With these modifications the module provides the values for graphing in addition to the hexa- decimal output. Now let us turn to the changes in the main pro- gram. The name of the 'Serialthread' module has changed: from seri althread_di agram import * To draw the graph we have to import the neces sary libraries: ## init arrays and timer for data self . x= [] self . y= [] self. starttime=time . time() from matplotli b . backends . backend_wxagg import FigureCanvasWxAgg as FCanvas from matplotli b . figure import Figure www.elektor-magazine.com | September 2013 51 •Projects Take care with the indentation when copying from the listings: incorrect indentation will result in errors or strange program behavior. Matplotlib works with a number of 'back ends' which actually carry out the drawing commands. Different back ends plot graphs on the screen, for example with wx, or output to printers, or to files. The first line above creates an object 'FCanvas' for wx on which Matplotlib can draw. 'FCanvas' inherits methods and properties such as size and position from 'wxPanel'. The object 'Figure' is a container within which drawing occurs. However, 'Figure' is not the graph itself: instead, the graph is an 'Axes' object, and a 'Figure' object can contain one or more 'Axes' objects. This might seem bewildering, but it is all part of the power of Matplotlib. Some changes are also needed in the layout and in text sizes to obtain a satisfactory appearance: details can be found in the Listing. The graph window (see Figure 4) is constructed in the ' init ()' function of the 'MyFrame' class: class MyFrame (wx . Frame) : add_subplot (111) self. canvas = FCanvas (self , -1, self. figure) self .canvas. Set Posit ion ( (450,5) ) self .canvas. SetSize( (300,250) ) • • • • First we create a subplot within the 'Figure' instance. One 'Figure' can contain several sub- plots, for example if there are several time series to display. The syntax is as follows: figure. add_subplot (numrows , numcols, fi gnumber) In our case there is only one graph (fignum- ber = 1) and hence only one row (numrows = 1) and one column (numcols = 1). The last three lines above the drawing surface for the wx back end is created using the 'FCanvas' object. It is then positioned and its size set. We are now in a position to draw a graph. def init (self, **kwargs) : # create frame wx. Frame. init (self, None, **kwargs) The second change affects the function 'OnldleQ'. This is called whenever the program has nothing else to do, in particular when new data become available. # text box with fixed width font for nice data representati on self . textbox=wx .TextCtrl (self, style 200 )) wx . TE_MULTILINE , pos = (5 , 5) , si ze= (420 , myfont = wx.Font(10, wx. MODERN, wx. NORMAL, wx.BOLD, False, u’Courier’) self . textbox . Set Font (myfont) def OnIdle( self, event): # if nothing else to do, update text from message queue while not self . seri al_thread . msgQueue . empty ( ) : msg=self . seri al_thread . msgQueue . get ( ) self . textbox . AppendText (msg) buttonOn=wx . Button (self , -1, “LED ON”, pos= ( 100 , 230) ) buttonOff=wx . Button (self , -1, “LED OFF”, pos= (200 , 230) ) ## diagram self. figure = FigureQ self. axes = self. figure. ## display values in diagram self. axes . plot (self . seri al_ thread. x, self . seri al_thread . y) self .canvas. draw () This code plots the most recently received x and y values: recall that the 'x' array holds timestamps in seconds. The graph is finally displayed using the command 'canvas. drawQ'. 52 September 2013 www.elektor-magazine.com Basic to Python The changes described above lead to the pro- gram 'Diagram. py'. In this simple example we have not included code to fix the scaling of the graph: instead the scaling continuously changes to match the data displayed. Another side-effect of the simple implementation is the continually- changing color of the curve each time a new graph is plotted. If you wish to modify the presenta- tion to suit your particular requirements, you will need to immerse yourself in the Matplotlib documentation. Conclusion You should now have an initial impression of the basic principles involved in creating a GUI. The software we have described is far from perfect: error handling is rudimentary and if anything does go wrong the interpreter will simply report the error immediately. A further disadvantage is that the program can only run for a certain length of time. The prob- lem is that the experimental node will continue to deliver data twice a second and eventually the 'x' and V arrays will become full. Drawing the graph takes longer as more data points accu- mulate, and if new data points arrive while the graph is being drawn then Matplotlib will no lon- ger be able to keep up. The window will go gray, indicating that the GUI thread is overloaded. It is interesting to note that the terminal window still displays the activity in the receiver thread, since this continues to run independent of the GUI thread. It should be possible to work around this problem by modifying the program so that the graph is only redrawn every few seconds. Why not give it a try? ( 120744 ) The Author Jean-Claude Feltes is an electronics engineer teaching at the Lycee Technique des Arts et Metiers in Luxembourg, a specialist technology and arts school that offers courses leading a range of vocational qualifications. In his spare time he keeps himself busy with electronics and programming projects (see [7]). Internet Links and References [1] ElektorBus web site: http://www.elektor. com/elektorbus [2a] Here comes the bus! (6): http://www. elektor-magazine.com/1 10258 [2b] Here comes the bus! (8): http://www. elektor-magazine.com/1 10428 [3] From BASIC to Python (1): http://www. elektor-magazine.com/1 10483 [4] From BASIC to Python (3): http://www. elektor-magazine.com/1 10483 [5] Matplotlib documentation: http://matplot- lib.org/contents.html [6] Sandro Tosi: Matplotlib for Python Developers [7] Author's home page: http://staff.ltam.lu/ feljc/home.html [8] 'Python Programming and GUIs for Elec- tronic Engineers' by Andrew Pratt: http:// www.elektor.com/products/books/pro- gramming/python-programming-and-guis- for-electronic. 1320886. lynkx Figure 4. Terminal window with packet counts and a graphical display. www.elektor-magazine.com | September 2013 53 Using Libraries By Neil Gruending So far the previous DesignSpark Tips and Tricks (Canada) articles have discussed how to setup and con- figure DesignSpark from a new installation per- spective. In this installment we will look at how to use libraries to create a schematic and PCB design in DesignSpark. Component Figure 1 . What are libraries? Properties of a component When we created schematic title blocks we started the design software needs. by creating a schematic symbol in the schematic symbol library and then created a component in the component library that referenced that sche- matic symbol. That was an example of a sche- matic documentation component that didn't need any PCB design information associated with it. But normally you would probably want to create components that would incorporate the informa- tion as shown in Figure 1. design information in multiple components. For example, you could make multiple resistor com- ponents by creating one schematic symbol and then reusing it in the other components. Because all the components refer to the same symbol, any changes to it automatically propagate to the components that use it. The same is also true for PCB footprints and the 3D CAD models. The DesignSpark website has a good tutorial about libraries and how they're used, see [1]. Organizing them The libraries that come with DesignSpark are usu- ally installed into 'C:\Users\Public\Documents\ DesignSpark PCB 5.0\Library' and are a good example of how to organize a large component library organized by manufacturer. I prefer to organize my libraries by component type because I also use the libraries as a component part num- ber database. For example I have a 2N3904 in my transistor library, but I have multiple man- ufacturer part numbers associated with it so I don't have to remember which transistor man- ufacturers I've used previously. I also try and reuse schematic symbols and PCB footprints so those go into generic libraries which make my library structure like this: • Grouped component libraries (transistors, resistors, capacitors, etc) • A generic schematic symbol library (resistor symbol, capacitor symbol, etc) • A generic surface mount PCB footprint library (0603 footprint, LQFP footprints, etc) • A generic through hole PCB footprint library (DIP footprint, 1/4W resistor footprint, etc) The schematic symbol is stored in a schematic symbol library file (*.ssl), the PCB footprint is stored in a PCB symbol library and the 3D CAD model is stored in a 3D view library file (*.pkg). The top level component is stored in a component library (*.cml) along with the part number and all the technical information. The component library also stores the references to the other libraries needed to complete the component. DesignSpark uses different files for the different types of library data so that it's easy to reuse the So now that we've talked about libraries, let's learn how to use them starting with Modelsource. ModelSource If you haven't heard, Modelsource is an online database of components that's available to use in many different PCB software packages includ- ing DesignSpark. I like that DesignSpark directly connects to Modelsource so you can find compo- nents without leaving the application (a tutorial is available at [2]). It's also a great resource to find 54 | September 2013 | www.elektor-magazine.com Tips & Tricks IPC compliant PCB footprints which meet stan- dard manufacturing guidelines. To open Model- Source in DesignSpark, click on the ModelSource button or go into the 'View->ModelSource Bar' and you will see the ModelSource screen shown in Figure 2. Let's search for a surface mount MMBT3904 NPN transistor using the parametric search engine. Click on 'CLICK TO CHOOSE' and login if neces- sary. To find a list of the available bipolar tran- sistors by choosing 'Semiconductors->Discrete Semiconductors^ Bipolar Transistors', which lists 740 different transistors like in Figure 3. Now let's narrow down the search results by adding some filters to the columns of data. For 'Transistor Type' select 'NPN', 'Mounting Type' to 'Surface Mount', 'Package Type' to 'SOT-23' and 'Maximum Collector Emitter Voltage' to '40V'. The second transistor listed is an MMBT3904 which is exactly what we were looking for. After pressing the 'Load Preview' button you will get the follow- ing screen where ModelSource will show you the schematic symbol, PCB footprint and some key component design parameters (see Figure 4). You can also find components using the 'Part Number Quick Search' field if you already know a portion of the part number. Now that we've found our transistor click on 'Use Component' to use the component in your design and DesignSpark will download the component to a library in the downloaded libraries directory (you can find the full path in the Folders tab in the Library Man- ager). DesignSpark will tell you the name of the library after the component is downloaded. You can now add the transistor to your design by dragging it from the ModelSource window into your design or you can use the usual 'Add Com- ponent' toolbar button. But what do you do when ModelSource doesn't have the part you want or you want to change something about the component? For example, I would change the MMBT3904 component we found to have a more conventional schematic symbol that shows the emitter. That's when it's time to use your own custom libraries. Custom libraries I always like to create my own set of libraries but that can be a lot of work. So I like to copy com- ponents from other sources when possible and DesignSpark PCB 5.0 wired by RS - [Schematic Design: temp *] a] File Edit View Add Settings Qutput look y^rdow Help BOM Quote PC8 Quote D0HO iiUfffliSS* <9 - & x % J 15 A • G=m . ModelSource ■a x K l I m CLICK TO CHOOSE... 15 ! Logm Clear Help Part Number Quick Search: Go Load Preview View Datasheet! Use Component m [<] [>][ ModelSource Abs 33030.88 34115.24 thou then modify them. For our MMBT3904 example that would mean copying the downloaded com- ponent information into our own libraries using the Library Manager and then editing the com- ponent as required. This is also a good time to double check everything in case there's an error. The most important part of setting up your own libraries is to use common attributes for every component, so that it's possible to generate Figure 2. The ModelSource screen just after opening it. Figure 3. The ModelSource screen displaying search results. www.elektor-magazine.com | September 2013 | 55 DESIGNSPARK PCB Figure 4. Detailed information of a transistor in ModelSource. jlj DesignSpark PCB 5.0 wired by R$ - [Schematic Design: temp *] ^ File Edit View Add Settings Output Tools Window Help BOM Quote PCB Quote m ■U! OESICNSPARK PCB L - 6> X io *i • ^ ModelSource (Logged in as neilg) A o ■0 x Semiconductors L D iscr ete S emiconductor s A i3 n ED Bipolar Transistors Logout Clear Help Part Number Quick Search: Go MPN=MM8T3904LT1G RS Number=5450343 Ptice=0.099 Qly«50 RoHS-Y Manufacturer=ON Semiconductor Package Type=S0T -23 Mounting Type=Surface Mount Pin Count=3 Transistor Type=NPN Maximum Collector Emitter Voltage=40 V Number of Elements per Chip=1 Conf iguration-S ingle Load Preview View Datasheet Use Component MPN RS Number Price Qty RoHS Manufacturer Package Type E Mounting Type Surface M... ’ r Pin Count SELECT SOT-23 SELECT MMBT2222AL... 5449400 0.080 1 MMBT3904LT... 5450343 0.099 50 ON Semicond... SOT-23 BJy OT-23 Surface Mount 3 nr ki [«i u\ [>1 ® r>n Products per page: 30 - Page 1 of 1 Viewing 1 • 6 of 6 products ’‘fc ModelSource (Logged in as neilg) AbS 18815.14 23286.58 thou — reports like bill of material (BOM) reports. For example, I prefer to store all of a component's manufacturing information in the component library. This means that I usually have multiple manufacturer part numbers, so I use the attri- butes as shown in Figure 5 where I've added three additional manufacturer part numbers. Note that the other attributes are required if you want to use the DesignSpark BOM quoting function. Conclusion ModelSource and DesignSpark's libraries are a great resource when creating our own set of libraries and they can save a significant amount of time. At this point we can create a schematic and next time I will talk about some tricks when editing a schematic and how to generate a bill of materials. ( 130207 ) Component Package Gate Values }' Vendor«ON Semiconductor FI Manuf act urer_Part _Number ■ M M B T 3904 LT 1 C Q Manufacturer_Name=ON Semiconductor QRS Part Number* 5450343 AJIied_Number= Manufacturer! =On Semiconductor Manuf actunerl _Part = M M BT3904LT 1 G Manuf actuner2 = Fairchild [H Manuf acturer2_Part = M M BT3904 PI Manufacturer3=NXP Manufacturer3_Part =MMBT3904.21 5 Delete Edit... Up Down All Packages Internet References [1] www.designspark.com/tutorial/ components-library-structure-library-manager [2] www.designspark.com/eng/tutorial/compo- nents-downloading-from-modelsource-build- ing-up-libraries Figure 5. Useful attributes of a component. \ 7 \ New Values are added to all other Packages OK Cancel Apply Help 56 | September 2013 | www.elektor-magazine.com FREE CIRCUIT BOARDS Send your email address to elektof :3apcir cuits. com for a chance to WIN a 2 or 4 -layer circuit board order] {wp to a S5Q0.0O value) DID YOU KNOW? Basic 2 layer boards arc ready for pickup by 2pm the nsxr day and masked 2“layer boards are ready tine second day. Custom board aliasing options can a' so inc lude piated slots and internal cutouts www.apcircuits.com I.877.APC-1PCB [877.272.1722] IPHONE SCOPE 5MHz mixed signal scope adapter for the iPhone, iPad and iPod Touch! The weeimsq- 104 app is available for download from the Apple App Store. (MSO-loH $296.99 30MHz SCOPE 2-Ch, 250MS/S sample rate 30MHz scope with 8" color TFT- LCD, AutoScale & waveform mathmatic functions. Quality FREE carry case included. SDS5032E $299 60MHz SCOPE 60MHz 2-ch scope wren S0GM5a/s rate & huge lOMSa memory! S w color TFT-LCD & FREE carry case! SDS6062 $349 fOOMHz SCOPE High-end ioomhz 2-ch * losa/s Dencnscope with IMSa memory and use port * free scope carry case super low prices DS1I02E $399 tOOMHz SCOPE IOOMHZ 2-ch scope with tGS/s sample rate and 8" color TFT lcdl Huge amounts 1 ^ of memory *■ "PEE scope carry case. SDS7102 $429 O iCV 100MHz MSO 2 -cn too ms a/s scope * 3-ch logic analyzer usb 2.0 ana 4M samples storage per channel with advanced triggering & math functions* CS328A $1359 20MHz HANDHELD Fast & accurate handheld 20MHz 1-ch oscilloscope. - loo m/s sample rate - 3.5 in. color TFT-LCD - 6 hour battery life free rugged, impact -resistant case! HDS1021M $269.95 WtVW.SAEUS.COM ,Jj & cam fi1 5 ? aEll uni qua aladmnics •Labs .Labs Tips & Tricks By Clemens Valens (Elektor.Labs) Summer is over, projects have been wrapped up, now is the time to document it all on Elektor.Labs. Here are some tips and tricks to get more out of your online publications. Proposals Finished In Progress Active Popular Mains Gate: Programmable Relay & Enerqy Monito... 4,540 views Active Popular Clektor.POST No. 12 (Low-cost Allergy Fiqhter) 1,154 views ★ ★★★★ Intelligent Cuclight System for Theatres and Event... 758 views EDITOR'S CHOICE efficient solenoid valve [13U258-1] 810 views Active Popular Wireless battery charger (Receiver POQlRX) [ 130168 ... 165 views ★ ★★★★ Icons We keep enhancing the Elektor.Labs website by adding useful features. It is an evolutional process, and features are added as soon as we discover that we need them. One of the latest additions is in the form of icons that you probably have noticed on the homepage. Currently there are four icons available for drawing attention to a project. Two of these icons, the blue Post icon and the yellow Editor's Choice icon are controlled by Elektor editors. The Dead End and SOS icons are available to all posters. They can be activated to let other users know that you need help or that you are stuck. Please note that when you activate the Dead End icon, your project may be moved to the Finished column, so use it with care. The Elektor.Labs homepage now boasts icons. View Edit Speed Projecting Display for Car Save Help wanted: (ft) N/A O Help warded O Deadend Main project picture: Remove Title: Soeed Proiectina DisDlav for Car Here is where you activate an icon for your project. 58 September 2013 www.elektor-magazine.com elektor labs Project visibility Even though project header illustrations are optional, I highly recommend that you upload a photo or drawing anyway for the simple reason that nicely illustrated projects have a higher priority and end up higher in the lists. Every time you update your project— when you click the Save button— it is moved to the top of the list if it has a project header photo. The website provides a nice default picture of a dirty scribbled-on coaster (or "beer mat" if you prefer), but it is ignored by the rating mechanism. Make sure to replace the default project header photo by a nice photo of your own project. It will improve the visibility of your project. www.elektor-labs.com Active users Some people are really prolific on Elektor.Labs and we like that a lot. Because these users are important to us, we have devised a scoring mechanism that allows us to identify active posters in an objective manner. Every once in a while Elektor staff have some hardware, books or other goodies to give away and the active users will be first in line to receive these freebies. The scoring system is simple: posting a project is worth four points, a contribution is two points and every comment earns you one point. The next step is of course to make the scores visible on the website— we are working on it. P.S. Note that scoring is not completely automated, real people are involved, so posting rubbish projects, contributions or comments - spam in short - will not get you anywhere. We may even decide to block your access. Passwords and email addresses This is an awkward subject and, understandably, we keep receiving questions about it. The main thing for you to know as an Elektor Member is that, for historical reasons, we currently have two independent systems with two different login domains. We are working on unifying it all, but, unfortunately, that takes time. Your Elektor.com, Elektor.Post and Elektor.Store account is not the same as your Elektor.Labs and Elektor.Magazine account. You can make things simple for yourself by using the same email address and password for both accounts, but that's not mandatory. If you want to change your email address just contact us by sending your old and new email addresses to service@elektor.com or labs@ elektor.com and we will do it for you. Two accounts require two sets of login credentials. elektor labs I ogin Email: Password: | Login * Fornnt password? “Participating on Clektor LADS is reserved to Clektor members, an Clektor account Is required to sign on. Elektor member;.: please use your account details to enter Uie Elektor LABS website. I wont to become an Elektor member * PAcewrvrri fnrgnfTpn? r Register Shoppinq cart Vr 1 blektor Credits : U www.elektor-magazine.com September 2013 59 •Labs 90 Degrees and Rising By Thijs Beckers (Deputy Editor) It wasn't just the temperature outside that rose significantly this summer @ Elektor House. While testing his prototype of the soon to be published battery testing circuit, lab worker Tim Uiterwijk was surprised to measure the temperature of a 7-watt series resistor (the big white one in the picture with the thermometer sensor held on it) at well over 90 °C! This wasn't expected, as the calculated dissi- pated energy (P djss ) was well below the 7 watts the power wire wound resistor is allowed to dis- sipate according to its specifications. The dissi- pated power could be calculated using the well- known formula: ^cliss X R. While the upper limit of the current through this resistor was calculated to be 8 A, during a test it had been limited to 4.5 A. So in this case (with I = 4.5 A and R = 0.1 ft), with just (4.5 2 x 0.1 x) 2 watts this relatively big ceramics clad resistor got very hot fast. Too hot, actually. In general, any component exceeding a body temperature of 80°C is regarded bad practice in our labs, so a solution had to be found. As can be seen in the pictures, the circuit is mounted on a heatsink. This heatsink is a 'stan- dard' CPU cooler (with fan) intended for an Intel P4 processor. Mostly due to their active air flow, this type of heatsink boasts a very low ther- mal resistance to air; of the order of 0.40 K/W. So they're excellent for dissipating lots of heat — depending on the model a PC CPU can easily generate 125 W or so — so the heatsink obvi- ously has to be able to "digest" that. Another shunt resistor has already been mounted on the heatsink (on top in the top photo), but there's enough room for a second one. Tim swapped the ceramics covered resistor with an aluminum housed wirewound power resis- tor rated at 50 W, and he mounted both power resistors on the sides of the heat sink where the airflow was highest, see the bottom photo. This solution proved adequate, with the previ- ously hot headed power resistor now reaching only 33°C under identical circumstances. With a maximum (software limited) current of 8 A, the resistor now heats up to about 50 degrees C, satisfying the Nothing-Hotter-Than-80 rule and even providing a little headroom. Theoretically, the 50-W resistor should be able to withstand currents of up to 22 A and temperatures of up to 250 °C(!), but those extremes will never be met in our application. Problem solved. Now keep an eye on our upcom- ing editions— an article with the full schematic and description of the circuit will be published soon. ( 130055 ) 60 September 2013 www.elektor-magazine.com C \ ■ ■ ^ rj Add USB to your next project. VJOD It's easier than you might think! DLP-USB1232H: USB 2.0 UART/FIFO HIGH-SPEED 480Mb/s • Multipurpose: 7 interfaces • Royalty-free, robust USB drivers • No in-depth knowledge of USB required Throw off the 8-bit ball and chain! CFA10036 ARM9 + Linux SOM • Standard 18-pin DIP interface; 0.6x1 .26-inch footprint DLP-I08-G 8-Channel Data Acquisition Only $29.95/ • 8 I/Os: Digital I/O Analog In Temperature • USB Port Powered • Single-Byte Commands DLP-IOR4 4-Channel Relay Cable DLP-THIb Temp/Humidity Cable DLP-RFID1 HF RFID Reader/Writer DLP-FPGA USB-to-Xilinx FPGA Module www.dlpdesign.com * fa st: 454MHz A R M9 * ^rS D: 4GB to 64G B * Li rrux mai nli ne kernel * dee p 1 28/256MB - USB/lMRT/SPl/I^C - 6xAPC/8xP vmCAN * wide: 9-1/1 26 GRID * debug/stetus DIED » *7 iSQi to M8©G500 Get your project to market fast: lay down a standard SO DIMM connector, snap an a CFA10036 System-On- Module and you instantly have access to tons of GPIO and the power of Linux Leave the 8-bit dark ages behind CFA920-TS This tiny touch-enabled embedded Linux PC es powered by the CFA1 0036 * 800x480 color TFT * resistive touch screen * 10/100 Ethernet + USB *24 GPIO on 0.1" * 79 more GPIO on 1 mm * 6 -channel aocei+gyro * &140@Q1 to$105©Q50D 1Q8mmJ4,25” 18.5mm 0.73” thick Crystalfontz www.crystalfontz.com +1 509 892 1200 RFID MIFARE and Contactless Cards in Application it I ii f A NEW BOOK MIFARE is the most widely used RFID technology, and this book provides a practical and comprehensive introduction to it. Among other things, the initial chapters cover physical fundamentals, relevant standards, RFID antenna design, security considerations and crypto- graphy. The complete design of a reader’s hardware and software is described in detail. The reader’s firmware and the associated PC software support programming using any .NET language. The specially developed PC program, “Smart Card Magic.NET”, is a simple development environment that supports sending commands to a card at the click of a mouse, as well as the ability to create C# scripts. Alternatively, one may follow all of the examples using Visual Studio 201 0 Express Edition. Finally, the major smart card reader API standards are introduced. •Industry The new 868 MHz NT Series RF transceiver module from Linx makes it simple to send and receive digital data in the 863 to 870 MHz band. The module offers the option of UART or True Transparency™ interfaces which lets the user create a wireless wire for use with nonstan- dard data rates, custom protocols, or encodings such as PWM and Manchester. The module features best- in-class receive sensitivity (up to -113 dBm) and low power consumption (only 19.2 mA in receive mode and 16 mA in transmit mode at 0 dBm). Unlike so-called transparent modules that require a UART interface and buffering scheme, the True Trans- parency™ feature of the NT Series reduces latency by transmitting raw data. All the user has to do is con- nect circuitry to the input line of the sending trans- ceiver and the output line of the receiving trans- ceiver. The module is completely hardware-config- urable up to 8 channels. Although programming is NT Series Transceiver now Available in 868MHz for European Market not required, the NT Series has a UART interface that enables more advanced configuration with a micro- controller, RS-232 interface or USB interface. The 868 MHz version offers 68 channels, which lets the user implement a frequency agility scheme such as frequency hopping or listen before talk. The module has a maximum output power of +12.5 dBm and a receiver sensitivity of -113 dBm. This gives the module a typical line of sight range of up to 2.5 miles (4 kms) at the maximum output power with typical monopole whip antennas. Regu- lations in the country of operation dictate the maxi- mum legal output power, so the final system range may be less depending on the country of operation. Typical range at 0 dBm is up to 3,000 feet. To aid rapid development, the NT Series transceiver is available as part of a master development system. The system comes with two development boards for bench- marking and prototyping, each of which is populated with a transceiver. The boards include lights that show you which areas are active as well as other enhance- ments that simplify the development experience. To help you get started, the system also includes antennas, a daughter board with a USB inter- face, demonstration software, extra modules and connectors. www.linxtechnologies.com (130285-11) Mini-ITX-board for Intel Atom The HB131 is a small form factor mini-ITX board based on low power Intel Atom Cedar Trail platform. The dual-core Atom D2550 processor, which is offered with Intel's NM10 chipset, is primarily known for its lower power consumption & graphics enhancements compared to earlier Atom processors. The Mini-ITX board is equipped with dual Gigabit LAN ports and rich I/O. This environmentally responsible embedded mini-ITX board exceeds its predecessors in both performance speed and graphics capability all to offer greater scalability in a smaller footprint fanless PC solutions. The mini-ITX board features rich I/O interfaces: 8 USB 2.0, 6 COM ports, 2 LAN, 1 VGA up to 1920x1200, 1 LVDS up to 1440x900 (24bit). On board are 1 PCI and 1 mini-PCIe slots for richer connectivity, lx SO-DIMM supports DDR3 800/1066MHz RAM up to 4GB, 2 SATA II. It is designed to be a high performance, reliable, secure and easy to manage board. Making it an ideal platform for point of sale, self-service terminals, queue machines and digital signage. Utilizing the small footprint of 170mmxl70mm, the HB131 offers greater connectivity with dual Gigabit Ethernet with options of expansion via one Mini PCIe slot. www.habeyusa.com (130285-IV) 62 | September 2013 | www.elektor-magazine.com 0-120ml/min Liquid Flow Sensor The newest liquid flow sensor from Swiss sensor manufacturer Sensirion excels thanks to its ultra-pure materials and outstanding precision. The small SLQ-QT500 sensor is designed for the needs of the semiconductor industry specifically. The SLQ-QT500 covers flow rates from 0 - 120 ml/min. As with all Sensirion liquid flow sensors, its flow channel is absolutely straight and has no moving parts. The sensor is based on the patented CMOSens® Technology. The microthermal flow measurement is performed through the flow channel wall, which separates the chip from the measured liquids. Therefore, only the PFA tubing and the quartz flow channel are in direct contact with the liquid. This guarantees that the sensor has a superb chemical resistance. Thanks to these features as well as the RS485 digital interface, the sensor is able to achieve an exceptionally reliable measurement with a sample rate of up to 1 ms. With this unique technology even liquids with a very high viscosity (100,000 cP and more) are not a problem. Andres Laib, Director of Sales Liquid Flow Products says: "The sensor is suitable for measuring hydrocarbon-based solvents such as photoresists, as well as water- based liquids such as TARC and FI202. With the SLQ-QT500, liquids with virtually any viscosity as well as liquids which contain particles can be measured. This makes the sensor unique in the liquid flow sensor industry." www.sensirion.com/slq-qt500 (130285-III) CD E CD LD CD > “O < *l i — cu > “O n U u a ana l ■T t +-»t-i*j I*.. i.w * -as «r ^ t>M ■* » , 4 b “'*f AlLJIUU ALSO AVAILABLE: The all-paperless GREEN Membership, which delivers all products and services, including Elektor.MAGAZINE, online only. ■ UUtft, Tl, a. 1. 'mBfitfr JW, . J*w I FJHM l« ’T" 5 .17 M.J ,4 „ „ L , rt ' " nr'i' i.i J-— ---Wi ta.--.r>iTvr u.., ■ , M - t. -j, ..... M 4144. f-MT. >TD liH Uli .J, .. Take out your Membership now at www.elektor.com/membersS Gerard's Columns ConFused By Gerard Fonte (USA) The lowly fuse (or circuit breaker) is an important part in the safety of any electrical device. Primary fuses (for the AC mains) protect against fire, shock and destroyed equipment. Secondary fuses (in the DC power supply) are generally used to safeguard the device. Unfortunately, there seems to be considerable confusion about these basic parts. Ratings There are two numbers associated with a fuse: a current and a voltage. Nearly everyone knows the current controls the fuse. More current than specified and the internal link melts and the fuse blows. The fuse is a current device, so it doesn't matter what the voltage is. It could be one volt or 100 volts (as long as it is below the rated voltage). However, it can take a couple of hours for slow-blow fuse types to open at 135% of rated capacity. At 200%, it's typi- cally a couple of minutes. The fast-acting fuses may still take up to an hour at 135% of rated current but only a few seconds at 200%. Most people are quite surprised at this much delay. At ten times the current, the blow times are about 0.1 seconds (slow) and 0.01 seconds (fast). For modern electronics, this is still plenty of time to do significant internal damage. (The speed specification is provided in the data sheet as Ft. The lower the value, the faster the fuse.) The voltage specification is the confusing one. It means that the blown fuse will present an open circuit at the rated voltage. That is: the gap in the link will be physically large enough so that there will be no arcing between the internal remains. Obviously this is a very important consideration. If there is arcing between the fuse elements, then the fuse is not really protecting anything. Current is still flowing into the device. from shock and vibration. Mounting your fuse on a thin panel next to a big motor is just asking for trouble. The fuse is also a thermal device. If you are using sur- face-mount fuses, or soldering fuses directly into your circuit (instead of using fuseholders) you must be very careful with the application of heat. It is quite possible to blow the fuse with improper assembly. Sizing (mains power) If you are wiring a house the fuses (actually circuit-break- ers) are sized according to the appropriate building code. This code is often based on the thickness of the down- stream wire rather than the actual current the circuit is expected to handle. Unfortunately, for electronic projects there does not appear to be a real standard. My old ARRL Radio Amateur's Handbook says to add 10% to 20% more than the expected maximum current draw and then use the fuse with the next largest current rating. So, if your project is expected to draw one amp (of AC mains current) you would probably choose a 1.25 amp fuse. However, 200 pages later, the book says to fuse at 150% to 200% of maximum. It is my suspicion that no one wants to be too specific because of legal concerns. If someone publishes a 'standard' (or even a suggestion) and someone else gets hurt using that standard or suggestion— lawsuits will flow. (I'm certainly not going to make any suggestion or define a standard!) I also suspect that many products that include stand-alone AC power supplies ('wall-wart') do so to eliminate AC safety testing and certification. It may be a bit more expensive to do so but there is much less legal exposure. Of course, if you are making a project for your own use, you only have to consider your own risk. You can do whatever you want. But as soon as you start selling your device, you must consider the risk to the users. Application For AC mains, it is absolutely essential that the fuse be placed in the hot lead rather than the neutral lead. This makes sense when you stop and think (always a good idea). A blown fuse in the hot lead stops the current before it gets any farther into the device. If the fuse is in the neutral lead, there is still voltage present in the device, even if the fuse is blown. So if a different ground path is available— like a test lead or your finger— current will flow. What's more, if the fuse is in the neutral lead and there is a short to ground (rather than neutral), the fuse won't blow at all. In this case, the fuse is not in the current-carrying circuit and is useless. A fuse in the secondary of a transformer can be in either lead. If there are multiple transformer windings, or if the transformer has a center-tapped winding, several fuses may be required. The standard fuse is a mechanical device and is susceptible to damage PTC PTC (Positive Temperature Coefficient) devices are very different from fuses. They are also thermal devices that operate about the speed of slow-blow fuses. However, one huge difference is that they do not actu- ally interrupt the power. Rather, they change to a higher resistance and limit the current. Thus, some current still flows. The second big differ- ence is that they 'self-reset' when they cool down. Usually, this requires the removal of AC mains power. However, if the short-circuit goes away when the current is reduced (fairly common for some solid-state designs), the power can come back on unexpectedly. This can be very shocking. Choose wisely when you select your protection. ( 130231 ) 76 | September 2013 | www.elektor-magazine.com prir.tf (" A t"gur:En - * Vi SPONSORED BY Each week, you’ll find a new snippet of „C 5 . U Mr H - 4 4 j V i* SOUPC6 COCle that contains one error , /jj If you can find the error, you could be a winner! Follow Circuit Cellar on Facebook and Twitter for information about each week’s challenge, prizes, and winners announcements @circuitcellar ©editor cc circuitcellar MasaooSaHa EEODQ[ilgO§CQ0[p ftD The latest on electronics and information technology Videos, hints, tips, offers and more Exclusive bi-weekly project for GREEN and GOLD members only Elektor behind the scenes In your email inbox each Friday The beginning of a teauiifur friendship f. * ***** Silicon based life forms of the World. unite! I nm»m i»*fc£nB!Ma Piumxss WB fwpi, Owl ^ ^ ^ „ _ ’ ' ' ‘ u ’ 4 ' 1 cf Flotria 1 Mmatni wm um ju* *■«*=•* Wu* * MBV ™>T» wi*n*i* „ „ ^ N r.^jp ir.ii F:»kto>'?q^t %ii opiHi J „ Kl0 ^rant^anoi,-, El«Wwi Cr,- tffte EM v. r w- WrtVf doanr Elektor. TV goes Linux ***** term, jm Butng ■, , . WMCH IT QN ftEKTOft.TVa-j-j; H tone at*,.-, r, ■ in* ft iektor Register today at www.elektor.com/newsletter.k Fascinated by technology’s impact on the future? BDOfSORiSW .\jntf ticicrofc **w MW' -ipi-1^1 V-. - m, W'WiJfVtf "Witnr, Itch I hthirtuTB Vrr,r H, ll» t, Jtmlrr m >di, V* in riw ***"* >' ... . « . ■ <*.i II :Wtia 1 ■M'slr!, i; W 4 rjl n r mjj-ch; Check out Tech the Future! Computing power and global interconnectivity are pushing tech innovation into overdrive. Pioneering technologies and creative workarounds affect even the couch potato 24/7. Tech the Future reports on technology strides that shape the future — yours included. www.techthefuture.com Follow Tech the Future _ 3 ^^ sv CIRCUIT CELLAR ADuC841 Microcontroller Design Manual: From Microcontroller Theory to Design Projects If you’ve ever wanted to design and program with the ADuC841 microcontroller, or other microcontrollers in the 8051 family, this is the book for you. With introductory and advanced labs, you’ll soon master the many ways to use a microcontroller. Perfect for academics! Q Buy it today! www.cc-webshop.com •Store Limited Time Offer for GREEN and GOLD Members! 170/0 DISCOUNT + FREE SHIPPING www.elektor.com/tubeamplifiers Concept, implementation and assessment E Designing Tube Amplifiers This book looks at tube amplifiers from more than just a theoretical perspective. It focuses primarily on the design phase, where decisions must be taken with regard to the purpose and requirements of the amplifier, and it addresses the following questions: How do these aspects relate to subjective and objective criteria? Which circuits sound the best, and why? If you want to develop and market an amplifier, what problems should you expect? What are the significance and meaning of measurements? Are they still meaningful, or have they lost their relevance? Thanks to the enormous processing power of computers, we can now measure more details than ever before. How can these new methods be applied to tube amplifiers? Menno van der Veen will give you all the answers! 188 pages • ISBN 978-1-907920-22-6 £29.50 • € 34.50 • US $47.60 Display, buttons, real time clock and more [ Elektor Linux Board Extension This extension board was developed to further propel our Embedded Linux series of articles and the matching GNUblin board. It has a display, buttons, a real time clock and 16 GPIOs. Linux devotees, switch on your solder irons. The Linux extension board includes everything needed to provide the user interface for a wide variety of projects! Module, SMD-populated and tested board, incl. LCD1, XI, K1-K4, BZ1, BT1 for home assembly Art.# 120596-91 £31.10 • € 34.95 • US $50.20 Learning to fly with Eagle ( EAGLE V6 Getting Started Guide This book is intended for anyone who wants an introduction to the capabilities of the CadSoft's EAGLE PCB design software package. This book will quickly allow you to obtain an overview of the main modules of EAGLE: the schematic editor; layout editor and autorouter in one single interface. You will apply your knowledge of EAGLE commands to a small project, learn more about some of the advanced concepts of EAGLE and its capabilities and understand how EAGLE relates to the stages of PCB manufacture. After reading this book while practicing some of the examples, and completing the projects, you should feel confident about taking on more challenging endeavors. 208 pages • ISBN 978-1-907920-20-2 £29.50 • € 34.50 • US $47.60 140 Minutes video presentation and more DVD Feedback in Audio Amplifiers In this Masterclass we address several aspects of feedback in audio amplifiers. The focus of this Masterclass, although not entirely math-free, is on providing insight and understanding of the issues involved. Presenter Jan Didden provides a clear overview of the benefits that can be obtained by feedback and its sibling, error correction; but also of its limitations and disadvantages. Recommended to audio designers and serious audio hobbyists! ISBN 978-907920-16-5 £24.90 • € 29.95 • US $40.20 Ultrasensitive wideband E-smog detector E TAPIR Sniffs it Out! Attention boy scouts, professionals and grandfathers! This ultrasensitive wideband E-smog detector offers you two extra senses to track down noise that's normally inaudible. TAPIR — short for Totally Archaic but Practical Interceptor of Radiation — also makes a nice project to build: the kit comprises everything you need. Even the enclosure, ingeniously consisting of the PCB proper! Using the TAPIR is dead easy. Connect the headphones and an antenna and switch it on. Move it around any electrical device and you'll hear different 80 | September 2013 | www.elektor-magazine.com Books, CD-ROMs, DVDs, Kits & Modules Open Source Electronics inirh gfektor Technology Vjiiir nt, Hin-fJ " j ^ektor LabWorX 1 Poetical Digital ^ u^rvg MtCiocc-rrtroflwrs S X X, f~r~ D&pn Ibrahim ©ekt or CIRCUIT CELLAR noises with each device, depending on the type and frequency of the emitted field. Kit of parts, incl. PCB Art.# 120354-71 £13.30 • € 14.95 • US $21.50 OS Hard- and Software for Electronics Applications . Open Source * Electronics on Linux If you have ever wanted to take advantage of the expanding field of open source software for electronics and everyday applications, this book is for you. Using the Linux OS, Warwick A. Smith guides you through the world of open source hardware and software, teaching readers to use EDA tools and software that is readily available online, free to download. The hardware projects inside can be built using easily obtainable parts, in the comfort of your own home, on single sided PCBs, or professionally manufactured with output files generated by you. Open Source Electronics on Linux is about changing today's electronics enthusiast into empowered, savvy, discerning engineers capable of building and modifying their creations, be it solely on Linux or in tandem with your current operating system. 272 pages • ISBN 978-1-907920-19-6 £29.50 • € 34.50 • US $47.60 LabWorX 2 Mastering Surface * Mount Technology This book takes you on a crash course in techniques, tips and know-how to successfully introduce surface mount technology in your workflow. Even if you are on a budget you too can jumpstart your designs with advanced fine pitch parts. Besides explaining methodology and equipment, attention is given to SMT parts technologies and soldering methods. Many practical tips and tricks are disclosed that bring surface mount technology into everyone's reach without breaking the bank. A comprehensive kit of parts comprising all SMT components, circuit boards and solder stencils is available for readers wishing to replicate three projects described in this book. 282 pages • ISBN 978-1-907920-12-7 £29.50 • € 34.50 • US $47.60 UK /ROW Elektor International Media 78 York Street London - W1H 1DP United Kingdom Phone: +44 20 7692 8344 E-mail: service@elektor.com Ideal reading for students and engineers , Practical p Digital Signal Processing using Microcontrollers This book on Digital Signal Processing (DSP) reflects the growing importance of discrete time signals and their use in everyday microcontroller based systems. The author presents the basic theory of DSP with minimum mathematical treatment and teaches the reader how to design and implement DSP algorithms using popular PIC microcontrollers. The author's approach is practical and the book is backed with many worked examples and tested and working microcontroller programs. The book should be ideal reading for students at all levels and for the practicing engineers who may want to design and develop intelligent DSP based systems. 428 pages • ISBN 978-1-907920-21-9 £44.90 • € 49.90 • US $72.50 USA / CANADA Elektor US 111 Founders Plaza, Suite 300 East Hartford, CT 06108 USA Phone: 860.289.0800 E-mail: service@elektor.com Further Information and Ordering: WWW. elektor. COm/store or contact customer service for your region www.elektor-magazine.com | September 2013 | 81 •Magazine NEXT MONTH IN ELEKTOR MAGAZINE 8x8 Two-color LED Matrix with an ATmega328P This project aims to explain programming for Atmel microcontrollers in an easy way. The use of an 8x8 array of 2-color LEDs is mainly for the fun of it. Hopefully it also helps you understand the way the "bitshift" operation works for the purpose of LED driving. Plus we have a go at game programming! Some elementary knowl- edge of C/CT+ programming is helpful here. Xmega Webserver Due to lack of space in the current edition, we've had to reschedule publication of this AVR powerhouse to the October 2013 magazine. In terms of I/O we have 4 LEDs, 4 pushbuttons and a (separately installed) display. For inter- facing, you can choose between RS485 and various UART/TTL connectors, allowing our BOB USB-TTL converter to be connected, for exam- ple. The Embedded Extension Connector makes the board pretty versatile. The board also has a Micro SD connector, and there is room for a TCP/IP module that allows web server and other network applications to be realized. Wind Speed and Direction Meter The most widespread way to measure wind speed and direction is with a wind vane and an anemometer. In this project we take a dif- ferent approach— without moving parts and using a circuit based on a thermal mass flow meter. A heating element heats the air, which depending on the wind direction and speed gets directed across sensors fitted around the element. Measured values are interpreted in software, which is no easy task. Article titles and magazine contents subject to change; please check the Magazine tab at www.elektor.com. Elektor October 2013 edition is published to Members on September 10, 2013. See what's brewing @ Elektor Labs 24/7 Check out www.elektor-labs.com and join, share, participate! elektor@labs aring Electronics Projects | Home get started ^ with the LPC800 Proposals In Progress Finished Popular Active Popular Active Popular ll % T‘H : 3D Printer Head and BLiVIT - A feature-rich Android style capacitive Mat Temperature LI+ battery charger / sensing pattern lock controller - u... mana... [120... 38 views iririririr i.84o views iririr irit 3,224 views + * + ★ ★ elektor post About Elektor. LABS Create a Project Create a new project or enter a proposal Get help, feedback & votes from other visitors, and maybe you will get Elektorized too! Not a member? You want to post a project but you are not a member? %)QQ (Sttfl Click here to send a description of your project including a circuit diagram and a photograph for evaluation and mayt>e you will be granted 82 | September 2013 | www.elektor-magazine.com Ordering Information ORDERING INFORMATION To order, contact customer service for your region: USA / CANADA Elektor US 111 Founders Plaza, Suite 300 East Hartford, CT 06108 USA Phone: 860.289.0800 E-mail: service@elektor.com Customer service hours: Monday-Friday 8:30 AM-4:30 PM EST. UK / ROW Elektor International Media 78 York Street London W1H 1DP United Kingdom Phone: (+44) (0)20 7692 8344 E-mail: service@elektor.com Customer service hours: Monday-Thursday 9:00 AM-5: 00 PM CET. PLEASE NOTE: While we strive to provide the best possible information in this issue , pricing and availability are subject to change without notice. To find out about current pricing and stock , please call or email customer service for your region. COMPONENTS Components for projects appearing in Elektor are usually available from certain advertisers in the magazine. If difficulties in obtaining components are suspected, a source will normally be identified in the article. Please note, however, that the source(s) given is (are) not exclusive. TERMS OF BUSINESS Shipping Note: All orders will be shipped from Europe. Please allow 2-4 weeks for delivery. Returns Damaged or miss-shipped goods may be returned for replacement or refund. All returns must have an RA #. Call or email customer service to receive an RA# before returning the merchandise and be sure to put the RA# on the outside of the package. Please save shipping materials for possible carrier inspection. Requests for RA# must be received 30 days from invoice. Patents Patent protection may exist with respect to circuits, devices, components, and items described in our books, magazines, online publications and presentations. Elektor accepts no responsibility or liability for failing to identify such patent or other protection. Copyright All drawings, photographs, articles, printed circuit boards, programmed integrated circuits, discs, and software carriers published in our books and magazines (other than in third-party advertisements) are copyrighted and may not be reproduced (or stored in any sort of retrieval system) without written permission from Elektor. Notwithstanding, printed circuit boards may be produced for private and educational 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 connection 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 with respect to the goods. MEMBERSHIPS Membership renewals and change of address should be sent to the Elektor Membership Department for your region: USA / CANADA Elektor USA P.O. Box 462228 Escondido, CA 92046 Phone: 800-269-6301 E-mail: elektor@pcspublink.com UK / ROW Elektor International Media 78 York Street London W1H 1DP United Kingdom Phone: (+44) (0)20 7692 8344 E-mail: service@elektor.com O Do you want to become an Elektor GREEN or GOLD Member or does your current Membership expire soon? Go to www.elektor.com/member. www.elektor-magazine.com | September 2013 | 83 International System-on-Chip Conference 11 th International System-on-Chip (SoC) Conference, Exhibit & Workshops October 23 & 24, 2013 - University of California, Irvine - Calit2 www.SoCconference.com Early Bird Registration Is Now Open! Don 't Miss Out! • FinFET Technology & Applications • Analog & Mixed-Signal Designs • Sub 14nm Designs & Beyond • 3-D ICs Designs • IC Security & Challenges • Terahertz Power in CMOS • SoC Design & Verification • Biologic Battery • SiGe Technology Trends • Low-Power Design Techniques • Charge-Trap Flash Memory • Table-Top Exhibit (Free Passes) Platinum Sponsors LOkyine Extension Calit2 • FinFET & Mixed-Signal SoC • SOI vs. CMOS & Beyond CMOS • Electromagnetic & CKT Co-Design • FPGAs -Trends & Designs • EDA for High-Speed Interconnects • Smarter Mobile Devices • Fully Depleted SOI Devices • Network on Chips (NoCs) • Informative Panels • IEEE Student Design Contest • Networking Opportunities • And Much More. . . Keynote Speakers Xilinx, Inc. Dr. Kees Vissers Distinguished Engineer. Nokia Dr. John Paul Shen, Nokia Fellow, Founding Head of Nokia Research North America Lab. IBM Dr. David Harame Chief Technical Executive. University of Pennsylvania Dr. Nader Engheta H. Nedwill Ramsey Professor of Electrical and Systems Engineering. Microsemi Jim Aralis, Chief Technology Officer (CTO), and Vice President of R&D. Promote Your Company, Technology, Products & Services at The Most Informative, Targeted & Affordably Priced Chip Design Conference, Exhibit & Workshops of the Year! UC San Diego m t Joftec BROAD COM Selected Participating Companies & Universities XPenn ALDEC ) Microsemi (Intel) Savant r. n i— ■ Afj v imT- ntt DOOR wram rowr s / >X< FAB synopsys h ^ ms m m H XILINX. NOKIA NEC ^Sjektor e UC DAVIS 1 Vh i kSITVril ( Al IRHtNfA B ■_ D BAl FDU kDRI EE 1 Princeton * University Breker Twr CnC Vr nihRAfiflN Cummat UCLA FUJITSU UCI iWaiMviK aavia*. Ir*v OPEN ALLIANCE Is! CIRCUIT CELLAR TEXAS j r ■ ■ j i j UNIVERSITY OF ttXTWF.RX CALIFORNIA AMDJI SPANSION CRC Press For More Information or Questions, Please Contact the SoC Conference Organizing Committee at: SoC@SoCconference.com or (949) 851-1714 www.SavantCompany.com & www.SoCconference.com