www.elektor.com AUS$ 14.90 - NZ$17.90 - SAR 105.95 " NOK102 £4.90 + Embedded Linux Made Easy and the hardware too ^ Computer-driven Heliostat Servos track the sun or the stars + Dual Hot-wire Anemometer Pitot tube reduces energy loss 770268 451 73 0 6 lektor Brought to you by Eurocircuits rvice The European reference for PCB prototypes and small series Speed up your design cycle and keep costs down using our fast, easy-access online PCB pooling services. We deliver: • Top quality PCBs at low pooling prices • Fast deliveries to suit your requirements • Comprehensive technology support • No set-up or tooling charges • No minimum order charge - order from 1 PCB • Online ordering without pre-payment • Stencil service PCB proto - dedicated engineering prototype service , fast and low-cost • 1 or 2 PCBs in 2, 3, 5 or 7 working days • DRC-checked and fully finished with 2 soldermasks and 1 legend, 150pm technology • 1 x 100 x 80mm in 7WD - 2 layer 47,02 € - 4 layer 95,52 € • 2 x 100 x 80mm in 7WD - 2 layer 36,89 € each - 4 layer 74,76 € each Prices quoted include 2 1 % Belgian VAT but exclude transport costs STANDARD pool - widest choice of Eurocircuits pooling options • 1-8 layers 150pm technology PCBs • from 2 working days TECH pool - all the benefits of pooling for high-density PCBs • 2-8 layers 100pm technology PCBs • from 4 working days IMS pool - aluminium-backed PCBs for high heat-dissipation (LED) applications • Single layer Insulated Metal Substrate PCBs • 1.5mm aluminium base with 75|jm thermally conductive dielectric and 35pm Cu foil • from 3 working days On demand - multi-option non-pooling service for specialist needs • 1-16 layers down to 90pm technology • RF and high Tg materials • from 2 working days www.elektorPCBservice.com a perfect circle. Easily create GLCD or TFT user interfaces using Visual TFT™ and Visual GLCD™ software. Just focus on design and code will be created for you automatically. / / ^VISUAL TFT Iiglcd \ mikroC PRO tor ARM lM COMPLETE DEVELOPMENT SOLUTION for Stellaris® and STM32® Experience the powerful mikroC™, mikroBasic™ and mikroPascal™ compilers for ARM® Cortex™-M3 and M4 devices. Over 500 library functions with examples and a comprehensive help file will help you get your project done quickly. mikroProg™ for Stellaris® and mikroProg™ for STM32® are fast programmers and hardware debuggers. Each of them supports the entire family range of both Cortex m -M3 and Cortex™ v M4 microcontrollers from their respective N vendors. Both mikroProgs are supported N with MikroElektronika N ARM® compilers. / Over 200 IDC10 and mikroBUS™ compatible Click™ additional boards are here to meet your development ideas. EasyMx PRO™ v7 for Stellaris® is a full-featured development board for Stellaris® ARM® Cortex™-M3 and Cortex™-M4 microcontrollers. It contains many on-board modules including multimedia, Ethernet, USB, CAN and other. Board is delivered with MCU socket containing LM3S9B95. We supported all STM32® microcontrollers with EasyMx PRO™ v7 for STM32® development board. It features mikroProg™ hardware debugger and contains many on-board modules including multimedia, Ethernet, USB, CAN, two mikroBUS™ sockets and many other. mikromedia™ boards for Stellaris® and STM32® are real Swiss army knives for multimedia developers. They are packed with lots of multimedia peripherals. Mikroilektronika DEVELOPMENTTOOLS I COMPILERS I BOOKS GET IT NOW www.mikroe.com Unexpected Triggering Enabled Typically, yet much appreciated, most of the emails and letters I receive every month start with the odd compliment on Elektor’s “wide range of interesting subjects”, and then go on to describe a problem of a technical or linguistic nature. When replying and sup- plying the information desperately needed by the correspondents, I am always curious to know their preferences in electronics, as well as what they mean by “wide”. Those few readers replying to me typically wish to have a magazine that covers all of the fol- lowing: simple as well as complex projects, theory alongside practice, expensive along- side cheap, scientific & kitchen table, SMD & leaded, kit & 100% home assembly, PIC & AVR, Windows & Linux, hardware & software, tubes & transistors, more NE555S, and so on. I believe the underlying request is for diver- sity and inspiration — if these parameters can be upheld by the magazine then the exact coverage is a secondary (yet terribly important) concern. Philosophy aside, this month’s Nixie Thermometer / Hygrometer cheerfully combines vintage tube technol- ogy with analogue sensors and a microcon- troller. Also, although you may not have an immediate need for a Heliostat (p. 38) or a Double Anemometer (p. 46) these articles provide useful thinkware for your own appli- cations. Retronics and Hexadoku hopefully put a mild smile on your face, and the AVR SDR (p. 54) proves that you don’t need the latest ARM Cortex-xyz for a profound under- standing of digital radio. Trigger(s) Success- ful! And that’s just six of them. Let me know how many of your personal trigger condi- tions were satisfied by this month’s highly miscellaneous content. Happy reading, Jan Buiting, Managing Editor 6 Colophon Who’s who at Elektor. 8 News & New Products A monthly roundup of all the latest in electronics land. 14 Nixie Thermometer / Thermometer Nixie tubes are eye catchers for sure; here we use them in a retro-look temperature & humidity meter that’s a gem on your desktop. 20 Preamplifier 2012 (3) This month we wrap up the article series with discussion of the LLLL board, the switch boards and the power supply board. 28 Flexible Stepper Motor Driver If you have concerns about connecting a stepper motor driver to your PC, consider building this one with full electrical isolation. 32 Embedded Linux made Easy (2) Before you start programming away you need to know which component on the Elektor Linux board is doing a specific task. 38 Computer-driven Heliostat Here’s software and some electronics to enable you to use cheap servos to track the sun 44 E-Labs Inside Summer mag @ full steam 44 E-Labs Inside Stabistor: zener in reverse 45 E-Labs Inside Echoes from BOB 46 Dual Hot-wire Anemometer A combination of a Pitot tube and some clever electronics allows those elusive draughts in your home or office to be traced. 4 06-2012 elektor CONTENTS Volume 38 June 2012 no. 426 14 Nixie Thermometer / Thermometer Measuring temperature and humidity with a modern sensorand displaying the values on a retro display — it’s all described in this article. A calibrated, ‘digital’ sensor provides data via its l 2 C interface to a microcontroller driving four Nixie tubes and automatically alternating between temperature and humidity, while providing a nice fading effect. It’s a must-have! 28 Flexible Stepper Motor Driver To enable the control of a stepper motor from, say, a parallel port of a PC, Elek- tor Labs have designed a compact driver PCB using the A3979 chip made by Al- legro Microsystems. This chip has been specifically designed to control bipolar stepper motors in full-, half-, quarter- and sixteenth-step modes at currents of up to 2.5 A. The circuit is provided with optocouplers for electrical separation between the control inputs and the driver module 38 Computer-driven Heliostat This project shows an example for a heliostat, built using two servo motors. The position of the sun with respect to time and the location on Earth is cal- culated using a mathematical model. The result is used to drive the servos and make them point in the direction of the sun or the stars. 54 AVR Software Defined Radio (4) This month we turn our attention to something practical: using our DIY SDR to receive signals from DCF77 and other time reference transmitters, as well as the German weather service. We also investigate SDR-based time and weather signal decoding. lOOkl 200! u: 4 2 54 AVR Software Defined Radio (4) Just when you thought that longwave and shortwave were old skool, we cover digital services received in these bands and decoded using our advanced DSP board. 60 Platino Controlled by LabVIEW (2) UFA was introduced last month and gets explored in depth now. Combined with LabVIEW it makes a pretty powerful product. 66 Electronics for Starters (6) This month the flip-flop or bistable is seen in various guises. 70 PIC Programmer for Emergencies Help! It’s weekend, my PIC project has to be ready in time, how can I build a makeshift programmer? 72 2-Wire Interface for Illuminated Pushbuttons Look at this circuit if you want a doorbell pushbutton and the in-built light to operate on the same two-wire connection to the controller. 73 Component Tips Raymond’s Pick of the Month: MOSFETs + Extras (2); BTS432E2 74 Retronics Intersil IMS6100 Vintage Dev Kit Series Editor: Jan Buiting. 76 Hexadoku Elektor’s monthly puzzle with an electronics touch. 84 Coming Attractions Next month in Elektor magazine. elektor 06-2012 5 ELEKTOR The Team Managing Editor: International Editorial Staff: Design staff: Membership Manager: Graphic Design & Prepress: Online Manager: Managing Director: Jan Buiting (editor@elektor.com) Harry Baggen, Thijs Beckers, Eduardo Corral, Wisse Hettinga, Denis Meyer, Jens Nickel, Clemens Valens Thijs Beckers, Ton Giesberts, Luc Lemmens, Raymond Vermeulen, Jan Visser Raoul Morreau Giel Dols, Mart Schroijen Carlo van Nistelrooy Don Akkermans The Network Tech the Future explores the solutions for a sustainable future provided by technology, creativity and science. CIRCUIT CELLAR i hi f ouk' -• ! '-'v-! -:.i : ; l : ihonics l isSit.l i ki»C m "fwation VOICED COIL Our international teams United Kingdom Wisse Hettinga +31(0)464389428 w.hettinga@elektor.com Spain Eduardo Corral +34 91101 9395 e.corral@elektor.es India Sunil D. Malekar +9 1 9833168815 ts@elektor.in USA Hugo Vanhaecke +1 860-875-2199 h.vanhaecke@elektor.com Italy Mauriziodel Corso +39 2.66504755 m.delcorso@inware.it Russia Nataliya Melnikova 8107(965)3953336 Elektor.Russia@gmail.com Germany Ferdinand te Walvaart +31 46 4389417 f.tewalvaart@elektor.de Sweden Wisse Hettinga +31 46 4389428 w.hettinga@elektor.com Turkey Zeynep Koksal +90532 2774826 zkoksal@beti.com.tr U France Denis Meyer +31 46 4389435 d.meyer@elektor.fr Brazil Joao Martins +551141950363 joao.martins@editorialbolina.com South Africa Johan Dijk +27 78 2330 694 / +31 6 109 31 926 j.dijk@elektor.com Netherlands Harry Baggen +31 46 4389429 h.baggen@elektor.nl Portugal Joao Martins +351 21413-1600 joao.martins@editorialbolina.com China Cees Baay +86 21 6445 2811 CeesBaay@gmail.com Volume 38, Number 426, June 2012 ISSN 1757-0875 Publishers: Elektor International Media, Regus Brentford, 1000 Great West Road, Brentford TW8 9HH, England. Tel. (+44) 208 261 4509, fax: (+44) 208 261 4447 www.elektor.com The magazine is available from newsagents, bookshops and electronics retail outlets, or on subscription. Elektor is published 11 times a year with a double issue for July & August. Subscriptions: Elektor International Media, Regus Brentford, 1000 Great West Road, Brentford TW8 9HH, England. Tel. +44 208 261 4509, fax: +44 208 261 4447 Internet: www.elektor.com/subs Email: subscriptions@elektor.com Rates and terms are given on the Subscription Order Form. Head Office: Elektor International Media b.v. P.O.Box 11 NL-6114-ZG Susteren The Netherlands. Telephone: (+31) 46 4389444, Fax: (+31) 46 4370161 Distribution: Seymour, 2 East Poultry Street, London ECiA, England. Telephone:+44 207 429 4073 UK Advertising: Elektor International Media b.v. P.O.Box 11 NL-6114-ZG Susteren The Netherlands. 6 06-2012 elektor ELEKTOR Take out a free subscription to Elektor Weekly Do you want to stay up to date with electronics and information technology? Always looking for useful hints, tips and interesting offers? Subscribe now to Elektor Weekly, the free Elektor Newsletter. Your benefits: ■ The latest news on electronics in your own mailbox each Friday 1 Free access to the News Archive on the Elektor website ■ You’re authorized to post replies and new topics in our forum Register today on www.elektor.com/newsletter Supporting Companies Bete tACLE [l3 EzPCB AudioXpress www.audioamateur.com 53 Beta Layout www.pcb-pool.com 27 Cadsoft www. element 1 4. com/eagle-competition 43 Eurocircuits www.elektorpcbservice.com 2 EzPCB www.siliconray.com 27 * Jackaltac Jatfaitac' www.jackaltac.com 41 Labcenter www.labcenter.com 88 , 4 . 4i MikroElektronika www.mikroe.com 3 [Tico Pico Technology www.picotech.com/PS145 13 fi*t; icvn Erctp Renesas Contest rlth Qulbmpi: www.circuitcellar.com/RenesasRL78Challenge. ... 19 Not a supporting company yet? Contact Johan Dijk (j.dijk@elektor.com, +31 6 109 31 926) to reserve your own space for the next edition of our members' magazine Telephone: +31 46 4389444, Fax: +31 46 4370161 Email: j.dijk@elektor.com Internet: www.elektor.com Advertising rates and terms available on request. Copyright Notice The circuits described in this magazine are for domestic use only. All drawings, photographs, printed circuit board layouts, programmed integrated circuits, disks, CD-ROMs, 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 transmit- ted in any form or by any means, including photocopying, scan- ning and recording, in whole or in part without prior written per- mission 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 submission of designs or articles implies permission to the Publisher to alter the text and design, and to use the contents in other Elektor International Media publications and activities. The Publishers cannot guaran- tee to return any material submitted to them. Disclaimer Prices and descriptions of publication-related items subject to change. Errors and omissions excluded. © Elektor International Media b.v. 2012 Printed in the Netherlands elektor 06-2012 7 NEWS & NEW PRODUCTS Design the next innovation for Microchip in EAGLE V6 and win prizes (and glory!) From May 1 to August 31 , 201 2 CadSoft and Premier Farnell are inviting design engineers to submit their design projects and win prizes with an overall value of around $7,000 in the EAGLE Design Challenge. The competition is powered by Microchip and hosted on element14, the most innovative design engineer community for sharing electronic engineering solutions. Elektor and Circuit Cellar are acting as media partners. Entering the competition is simple. To participate, applicants must ensure that all designs use EAGLE Version 6 and that a Microchip MCU or DSC will be integrated in the design. After registering on the elementl 4 community users can submit a screenshot of their layout and add a description of their project on the competition page. Don’t worry if you don’t have an EAGLE license, to participate in the contest you can download a free 30-days trial version on www. elementl 4.com/eaqle-freemium . CadSoft EAGLE PCB design software is strongly established in the engineering community, recently awarded ‘Product of the Year — Engineer Software 2012 Award’ by German Elektronik magazine for the seventh time. EAGLE version 6.1 , released in January 201 2 offers enhanced flexibility and enables users to save time through optimised and new features such as BGA escape routing, differential pair routing, automatic meanders and undo/redo logs. Additionally, the latest software provides automatic layout dimension, assembly variants, cut-out polygons, and a design reuse feature to merge board/ schematic pairs using the PASTE function with full consistency. The Prizes: 1. DELL Alienware M17x r3 + EAGLE version 6 Professional incl. all three modules. 2. MICROCHIP DV1 64037 Kit, Eval, ICD3 w/ Explorer-1 6 & DM1 63022-1 8-Bit development board + EAGLE Version 6 Professional incl. all three modules. 3. EAGLE Version 6 Standard incl. all three modules. 4 IK Microchip elements The outcome of the competition will feature peer-voting from the elementl 4 community. Members of the world’s leading technology community can ‘like’ Fife tdc Dra^ Vibv* Tooi-s L 'bra Qpfteni Winder Help suss r ^ ■ ss ■? # Left - 1 lif fc fr icImI obi to nio-.e- entries and comment on the submission. Based on the community’s ‘likes’ and comments, a panel of judges consisting of CadSoft, Premier Farnell and Microchip representatives along with independent EAGLE expert Prof. Dr. Francesco Volpe from the University of Applied Sciences in Aschaffenburg will pick the winners. Judging criteria include clarity in description of the submission, its electronic concept, design complexity, design quality, and functionality. For more details and terms and conditions please visit the link below. www.element 14 .com/eagle-competition (120355-I) 8 06-2012 elektor NEWS & NEW PRODUCTS 36 V, 5 A uModule Linear Technology’s new LTM8026 is a 36 V input, 5 A step-down pModule® regula- tor with an adjustable and precise (±10%) accurate current limit. The current limit enables designers to set the maximum amount of power drawn from the supply, preventing input voltage droop caused by overcurrent conditions. When multiple LTM8026 are configured with the outputs tied together, each converter can be pro- grammed with a unique maximum current rrum limit to meet its specific input supply limi- tations for greater output power, a tech- nique known as asymmetric power shar- ing. In contrast, common regulators must current share, a feature where each input supply contributes equally to the load, which is restricted by the least powerful input rail. Applications for the LTM8026 include point of load regulation in systems with 24 V and 12 V supplies such as VXI bus, for automotive, medical and indus- trial end-markets. Like other Linear Technology ^Module reg- ulators, the LTM8026 includes the DC/DC controller, power switches, power induc- tor, compensation and a modest amount of input and output capacitance in a sur- face mount package. The current limit is adjustable by applying a voltage or resistor divider and can be automatically decreased with rising junction or ambient temperature using a thermistor to prevent the LTM8026 or load from overheating. The LTM8026 operates from an input volt- age between 6 V to 36 V and regulates an output voltage between 1 .2 V and 24 V set by a single resistor. In a 1 2 V to 3.3 V output application, the LTM8026 achieves an operating efficiency of 89% at 2 A. For noise-sensitive applications, the pModule regulator can be synchronized to an exter- nal clock frequency in the range of 1 00 kHz to 1 MHz. Additional features include Small CD player with lots of useful extras Parasound, a San Francisco-based manufacturer of high-end audio components, has introduced the Zed Compact Disc Player as part of its popular Z Custom line of rack- mountable components that are half the width of a standard 19-inch equipment rack. While small in size, the Zed has a high-performance Cirrus Logic DAC and a fully inde- pendent power supply for the analog circuits. With its built-in preamplifier functions, the Zed and included remote control can be teamed with Parasound’s Zamp v.3 class AB stereo amplifier and a pair of speakers to make a compact, high-performance audio system. The Zed plays conventional Compact Discs as well as MP3 files from a CD-R. It also func- tions as a basic DAC-preamplifier with a USB input for MP3 files on a flash drive. It has an analog 3.5 mm stereo line-input jack for portable players and other line-level sources. The Zed has fixed and variable line outputs as well as coaxial and optical digital audio outputs. The source selection, track and MP3 file selection, and variable outputs are all operated via the supplied remote control. The Zed volume adjustments are controlled by an independent analog volume control 1C, not digitally inside the DAC. The Zed uses a 24-bit, 1 92 kHz-capable Cirrus Logic CS4353 DAC with a Cirrus Logic CS841 6 digital receiver. The circuitry boasts fifth-order multi-bit delta-sigma architec- ture with low latency digital filtering. It also includes analog filtering and ideal differ- ential linearity along with very high tolerance to clock jitter. The Zed delivers excellent low frequency performance without external DC blocking capacitors. The analog cir- cuits are powered by an entirely independent analog power supply with its own power transformer. For custom installers, the Zed has a rear-panel IR input and one-way RS232 serial con- trol port. There are three turn-on options: manual, automatic when AC is supplied, and 1 2 V trigger. There is even a 1 2 V trigger output to turn on a Zamp v.3 amplifier automatically. Like all Parasound Z Custom components, it is one rack-space high and 9-1 /2-inches wide; half of a standard rack width. It can be used with Parasound’s SBS side-by-side bracket to link two Z Custom units together, or Zblank for mounting across one rack space. Parasound also offers its half-width Zrack for mounting up to five Z Custom components. The Parasound Zed is now available with a manufacturer’s suggested retail price of $400. www.parasound.com (120332-X) externally adjustable soft start, adjust- able switching frequency and thermal shutdown. The LTM8026 is packaged in a thermally efficient 1 1 .25 mm x 1 5 mm x 2.82 mm LGA package. Two temperature grades, E and I for the -40°C to +1 25°C temperature range, are available for immediate delivery from stock. www.linear.com/product/LTM8026 (120332-VII) Integrated 8-bit MCU with RF transmitter on a single chip Microchip’s new PIC12LF1840T48A 8-bit microcontroller (MCUs) offers a single- chip solution for developing low power wireless designs. The combination of an extremely low operating voltage and com- pact 14-pin TSSOP package, make the PIC1 2LF1 840T48A ideal for developing elektor 06-2012 9 NEWS & NEW PRODUCTS low cost and extremely low power wireless applications such as remote keyless entry, security systems and remote monitoring. The first in a family of single-chip devices for wireless applications, the PIC1 2LF1 840T48A microcontroller combines nanoWatt XLP power-saving technology with a 41 8/434/868 MHz RF transmitter. The PIC1 2LF1 840T48A maximises battery life with a power-saving operating voltage of 1.8 V and extremely low current con- sumption in sleep mode. Efficient integra- tion with the transmitter gives you fast wake-up and allows you to make full use of the microcontrollers 8 MIPS operation. Designers may also add Microchip’s propri- etary, royalty free KEELOQ® code hopping technology, an industry proven technology used worldwide by leading manufacturers, to provide additional security to their appli- cations. The relatively small code size is highly configurable and can easily be scaled to pro- vide secure solutions to various markets. In terms of development Tools, the fol- lowimgt ate available: MPLAB® PM3 Uni- versal Device Programmer (DV007004); MPLAB ICD 3 In-Circuit Debugger (DV1 64035); MPLAB REAL ICETM PROBE KIT (DV244005); PICkitTM 3 In-Circuit Debug- ger (PG1 641 30). www.microchip.com/get/eut48a (120304-I) Automotive-grade universal receiver and front end amplifier Maxim’s new MAX2769B and MAX2670, next-generation high performance solu- tions specifically designed to address Global Navigation Satellite System (GNSS) applica- tions. These flexible receiver solutions are capable of operating over the navigation standards, GPS, GLONASS, Galileo, and Compass and have completed PPAP and Pico USB Dr DAQ serves up a real 'tweet’ for Wildlife Whisperer An unusual collaboration between an online wildlife com- munity and a technology com- pany is giving people across the world an opportunity to wit- ness the nesting habits of Brit- ish birds. Wildlife Whisperer, an online community created by TV pre- senter Simon King OBE and Jason Alexander, and Pico Tech- nology, a test equipment manu- facturer based in Cambridgesh- ire, have installed cameras, temperature and light sensors in bird boxes in a Suffolk garden. Images from the cameras, and data from the sensors, are streamed live to the Wildlife Whisperer website where the public can witness the day to day activities of nesting Great Tits and Blue Tits. “Linking the temperature and light data with the images gives a different view on the birds nesting habits” said Jason Alexander, “particularly with the variations in tempera- ture we have seen so far this year”. Pico’s resident ornithologist, Hitesh Mistry, added “Watching the day to day activity of the birds is very interesting, and a unique use of one of our products”. Each bird box is fitted with a DrDAQ data logger, to measure temperature and light lev- els, and a video camera. Software running on a local PC collects all the data and streams this across the internet to the website where users can log on to see the live action. For budding ornithologists who wish to set up their own bird box monitoring stations kits are available from the website. Summing up the collaboration Jason said “I must just say how thoroughly impressed I am with the help Pico have given so far and the way in which they keep their word with regards to getting back to me with updates etc. It’s rare these days to find a company that consistently exceeds my expectations**. www.picotech.com www.drdaq.com www.wildlifewhisperer.tv (120304-IV) AEC-Q100 approval. The MAX2670 is a dual stage low noise amplifier typically located in or close to the antenna module, while the MAX2769B nAilc-Tintiw Clr.^li'UniiViN^.i! fiP 1 ! I'ivw.vilh Fri>nh Cud Ani|iMi>.-i -£>- ■nw row iuc-i 1 wij y" j ai/Xiai incite 1 J ii£>J resides within the dashboard as the receiver. The MAX2769B boasts the industry’s lowest noise figure of only 1 .4 dB, a critical element that dominates the overall receiver sensitiv- ity and enables faster satellite locking. The MAX2670 is a highly versatile design that allows external filtering between first and second stage, providing flexibility for system optimization. Its high integration eliminates large, expensive, discrete transistor solu- tions. Combining these two parts delivers a highly flexible, high performance and robust system solution for navigation applications. The MAX2769B and MAX2670 are designed on Maxim’s advanced, low-power SiGe BiC- MOS process technology to offer the high- est performance and integration at the low- est cost. It is compatible with virtually all GNSS baseband hardware and GNSS soft- ware-based receiver designs. The MAX2769B completely eliminates the need for external IF filters by implementing on-chip monolithic filters and requires very few external components to implement a low-cost GNSS RF receiver solution. In addi- tion, its integrated ADC, which is program- mable from 1 to 3 bits, makes it highly con- figurable and the most flexible receiver on the market. www.maxim-ic.com (120304-II) 10 06-2012 elektor NEWS & NEW PRODUCTS Signal generators meet the future wireless test challenges The wireless industry is moving at its fast- est ever pace with the rapid introduction of LTE, and now the fast pace for LTE-Advanced and new technologies in WiFi. To match this pace and provide effective test solutions designers must keep ahead so that they can effectively test new technologies such as MIMO, carrier aggregation (CA), multi band radio, and co-ordinated multi point transmissions. Achieving this requires a new generation of signal generator to create all of the required new reference signals in a compact and manageable integrated envi- ronment. This is needed to meet the tech- nology and measurement challenges of Multi Standard Radio, Carrier Aggregation, and MIMO with multi-carrier transmissions. Anritsu is the first test equipment supplier to release the new generation equipment that is following these market demands. The MG3710A is the newest product on the market, and supports unique new mea- surement techniques to support these lat- est wireless transmission standards. It is fully able to meet these challenges, and so it enables RF designers to verify that their products are also able to meet the challenges of next generation wireless technology. The unique features include ‘waveform combining’ to enable an engi- neer to quickly create more complex signal combinations from libraries of signals, and the dual RF capability that addresses the future needs of Carrier Aggregation and multi-carrier transmissions that are being developed for higher speed data links. The architecture allows for multiple units to be locked together in RF phase and signal clock, enabling the effective and simple implementation of test systems for high order MIMO configurations that are cur- rently in development (e.g. 8x8 MIMO). www.anritsu.com (120304-III) Ambient light sensor for intelligent daylight harvesting Recently, at the Light+Building exhibition in Frankfurt, Germany, austriamicrosystems introduced their TSL4531 ambient light sensor device family, which enables sophisti- cated daylight harvesting for intelligent lighting systems and luminaires. The sensor family — developed by TAOS, the leading global supplier of intelligent light sensors acquired by austriamicrosystems in 201 1 , offers a wide sensitivity range from 3 lux to 220,000 lux, preventing saturation even in direct sunlight, while implementing a photopic response model that spectrally matches light per- ception in the human eye. The TSL4531 ambient light sensor provides a simple, direct lux output and a 1 6-bit digital interface. Sophisticated filters automatically reject the 50-60Hz ripple typically produced by a building’s fluorescent lighting systems, enabling the sensed light levels to more accurately measure the daylight that is entering the building. Daylight harvesting is the next major step in the development of integrated lighting systems, enabling luminaires to dim in response to the amount of outside light that is entering a building through windows or sky- lights. By supplementing the working space with only the amount of light needed to maintain a uniformly lit environment, energy savings of 30% or more can be \ ~~ — _ realized when compared to existing installations which do not respond to changes in ambient light. Being fully aware of the lit environ- ment also allows optimization that extends beyond energy savings. In integrated building management and control systems, the combination of proximity/motion and light sensing pro- vides an abundance of data concern- ing the interior environment. Addi- tionally, daylight sensing/harvesting combined with precise control mech- anisms enable the lighting system to deliver not just the needed amount of light, but also offers the ability to tune the type of light to suit the activity and users in a particular space. Envi- ronmentally aware, decision-directed, multi-sensor networks and optimized light will enhance not only the productivity of the built space, but also worker and group pro- ductivity, as well as increasing the health and well-being of individuals. TSL4531 Features: Direct lux output Approximates the human eye’s spectral response in diverse lighting conditions Three user-selectable integration times: 400 ms, 200 ms, and 1 00 ms Wide dynamic range: 3 lux to 220,000 lux Low active current: 1 1 0 pA typical Powerdown mode: 2.2 pA typical 1 6-bit digital output compatible with l 2 C interface Ultra-small 2mm x 2mm ChipLED package 2.5 V supply voltage with 1 .8V logic interface Rejects 50 Hz/60 Hz lighting ripple The TSL4531 ambient light sensor 1C is available now in volume production. www.austriamicrosystems.com www.taosinc.com (120304-VI) elektor 06-2012 11 INFO & MARKET RL 78 Green Energy Challenge Renesas’ true Low Power MCU platform By Mohammed Dogar (Germany) In our Green Energy world many electronic designs are driven by requirements for reduced size, improved scalability, intelligent func- tionality and most importantly low power consumption. The Renesas RL78 microcontroller (MCU) family is specifically designed to meet these demands by incorporating the highest peripheral integration, intelligent CPU architecture and advanced power-management capabilities to enable ‘True Low Power Design’. In addition to excellent general low power characteristics RL78 MCUs incorporate special functions to minimise operating current. Major sections of the MCUs can be turned off, while key peripheral blocks of the device continue to function. This smart low power operation is achieved with the unique ‘Snooze Mode’ capability. Snooze Mode dramatically reduces the power con- sumption of many typical MCU functions. The power savings are accomplished by allowing common data acquisition or data-trans- mission functions to operate without the need to wake up the CPU. This operational flexibility is a significant advantage over other low- power modes in which the CPU must remain active and assist with common peripheral functions. In a system that periodically measures an analogue signal, the Snooze Mode enables an RL78/G13 MCU to achieve over 30% reduction in the system’s average power dissipation compared to an implementation without this mode. Besides Snooze Mode, RL78 MCUs have other important low-power characteristics that are valuable for power-constrained designs. Their wide operating range, from 1 .6 V to 5.5 V, suits battery-based applications where the voltage (V cc ) drops over time as the battery gradually discharges. RL78 MCU — reducing power consumption over 30% In extreme applications some battery operated equipment must run off a battery for their entire operating lifetime, without any recharges whatsoever. Such designs require the lowest operating current possible. It is absolutely critical to turn-off functions in the system whenever they aren’t needed and wake-up functions only when they’re required. The ability to wait in a very low power state until action is required and then wake up to take necessary action and do so while using as little current as possible is one that can dramatically extend useful lifetimes. Renesas’ RL78 MCUs are recommended solutions for embedded systems that mandate low-power operation requirements because they provide advanced power-management capabilities. These functions allow the MCU to operate as follows: 1 ) run with exceptional power efficiency in the normal Run Mode; 2) disable CPU operation, saving power in Halt Mode (allowing fast CPU wake-uptime); 3) disable more of the MCU functions in the Stop Mode to save the most power (at the expense of a longer CPU wake-up time); 4) Snooze Mode delivers even greater power savings. Figure 1 shows an operational flow diagram for these three modes. RL78 MCU — Snooze Mode operation The Snooze Mode lets some peripheral functions wake up and exe- cute simple operations while the rest of the MCU is stopped. This saves a significant amount of power compared to the Run or Halt Modes because in Snooze the CPU is off and only the peripherals that must operate are enabled. Data reception from the synchronous serial port, the UART or a data conversion by the A/D converter can operate in the Snooze Mode by waking up the associated port, but not the CPU. The A/D converter can ‘wake up’ when the RTC or the Interval Timer generates interrupt signals to start a conversion. Similarly, the syn- chronous serial port can ‘wake-up’ when the Serial Clock input pin edge is detected, and the UART can ‘wake up’ when an edge on the RxD input is detected. After any data reception opera- tion in Snooze Mode is completed, a ‘match condition’ is checked. If the condition is a match, then the Mohammed “Mo” Dogar works for Renesas Europe as a product marketing manager, focused on promoting and selling microcontroller devices into major OEMs and distributors. Mo’s group defines and develops MCU product roadmaps and development support infrastructure for wide range of Industrial and Consumer electronics applications. 12 06-2012 elektor CD E CD CD > TD < Snooze Mode red u ees power co ns i.i mp[ ion try OvOr 30% MCU exits the Snooze Mode and enters the Run Mode. If the condi- tion isn’t a match, operation returns to the Stop Mode. Thus, the CPU can be activated only when the data received requires action from the CPU. Figure 2 illustrates Snooze Mode using the ADC trig- gered by timer. For example, A/D conversion uses only 0.5 mA in Snooze Mode, rather than 5 mA in Run Mode, hence dramatic power consump- tion advantages are obtained. Thus, an A/D conversion can be performed in Snooze Mode using only 0.5 mA, 90% less than the 5 mA required to make a conversion in Run Mode. Now it’s your turn We’ve discussed the ultra low power features of the RL78 MCUs, now what can you do with it? How will you use the energy sav- ing features of the RL78 in your project for the RL78 Green Energy Design Challenge? Even more, how can you take these features into your everyday design and project pushing to green energy envelope to the next level and working to shape the future? (120294) www.drcuitcellar.com/RenesasRL78Challenge Analog input UpperLimit Lower Limit ADC values out of range: Wake up ADC with trigger by timer Time the CPU and process the resutls 2 Technology GET MORE WITH THE CLASS LEADING OSCILLOSCOPES PicoScooe 6000 Series MORE MODELS • MORE CHOICE MORE FEATURES AS STANDARD ALL MODELS INCLUDE PROBES, CARRY CASE, FULL SOFTWARE AND 5 YEAR WARRANTY. SOFTWARE INCLUDES. MEASUREMENTS, SPECTRUM ANALYZER, FULL SDK, ADVANCED TRIGGERS, COLOR PERSISTENCE, SERIAL DECODING (CAN, LIN, RS232, PC, SPI), MASKS, MATH CHANNELS, ALL AS STANDARD. FREE UPDATES. www.picotech.com/PS145 Highest sampling rate and deepest memory of any scope for this budget >1 !^h _ 4 ^ «— y. ■ ; * V I Ma jllT h - *** 1 "I [« H I 1 1 1 L 19 |cn U jcj Inj CO □ > M.M. oj 5 5 5 5 W M -i O > > > > co ro VSS^ < m m 0SC1/CLKIN 0SC2/CLK0UT VSSg > 5 1 z SSI 2 o cd ~n oo -vl cd ■ o c/5 30 73 O O O O CO CO o j 3 S 73 73 O O 4k CO CO CO cj o CO s o “ ■c. O o T3 T3 O CO VDD 73 CoS o CJl n « ^ — cj cd O 7C 73 -0 0 30 30 30 73 03 03 03 CJ 03 O 30 03 30 03 co TO CD 30 03 30 03 go to CD to 0 — 1 —1 ho S -fk cn CD CJ O dl f 1 | | 1= in- 1N4004 <£> io -* CJl CD <£> ID o CJl □ -fk -vl OO o CO II o CT> o CD o oo CJ cn cn 0 0 O GND CO -tk 0 O VCC CD — i W C/> 0 0 m dl ■"J a "a o co II 3 co O ho ■ cn « -ID O co 5 4^ ■OED — | z 5 & "a C/3 > 4»» IO 73 riO CO CO ro ,00 •ro cd io oo T3 03 > 45k ro 20 CO IO ro OX II o cn CD z □ AO < o o A1 A2 A3 — j 4: O 00 01 02 03 04 05 06 07 08 09 u o CT> CD z CJ AO < o o A1 A2 A3 — j 45:: o ro 00 01 02 03 04 05 06 07 08 09 I 0 _ _o i = li t 1 ' ir ho CJl CD < C 0 00 AO 01 02 03 A1 2 p 04 CO -pk 05 A2 — * 06 A3 07 08 09 I § --0 r 3 H i 1 1 nr ho CJl CD z CJ AO < o o A1 A2 A3 —J -c*. O -tk 00 01 02 03 04 05 06 07 08 09 16 15 8 _ 9_ 11 14 11_ 10 1 _ 2 f 9 9 9 9ls C/3 ro c/> CJ > cn o cn cn 0 0 > I - vss VDD z z 0 0 T^l II O oo o IO +5V +5V 2 16 12 15 3 8 4 9 5 13 6 14 7 11 8 10 9 1 10 2 11 13 +5V S 2 16 12 15 3 8 4 9 5 13 6 14 7 11 8 10 9 1 10 2 11 13 \ +5V i 2 16 12 15 3 8 4 9 5 13 6 14 7 11 8 10 9 1 10 2 11 OCD oro OCO O-t^ Ocn OO o-^j OOO OO X M o' o -tk OO oro Oco O-i^ Ocn 003 o--j OOO Oo < CO 13 OO oro Oco O-^ Ocn 003 o--j OOO OO O x o' < -Pk CD ho Figure 1 . Clearly, the circuit resembles the earlier Nixie Thermometer project. There are a few differences, though. elektor 06-2012 15 TEST & MEASUREMENT Figure 2. The PCB can be ordered via the Elektor Shop or an artwork PDF can be downloaded from the project web page [2]. COMPONENT LIST Resistors R1-R4 = 22k£l R5,R1 1 ,R12 = 10l<£2 R7 = 47kn R 8 = not used R9 = 820I<£1 R10 = 330Q R13 = 5.6I<^ R14 = 470k£l R15 = 4.7kn R1 6 = 1 50L2 Capacitors Cl -C4 = 1 0OpF 2000V, 1 0%, radial, 5mm pitch (Farnell #1141797) C5-C8,C1 1 , Cl 2, Cl 6-C1 8 = 1 0OnF 50V, 20%, pitch 5mm C9, Cl 0 = 33pF 1 00V, 5%, 2.54mm pitch Cl 3 = 1 0juF 250V, 20%, radial, 5mm pitch Cl 4, Cl 5 = 1 00pF 25V, 20%, radial, 2.5mm pitch Cl 9 = 470pF, 1 00V, 1 0%, 5mm pitch Inductors LI = 330pH 1 A, 20%, axial, Dx|_= 1 1 x 32.5 mm (0.43”x1 .28”) max. Semiconductors D1 = BYV26 D2-D4 = 1 N4001 IC1-IC4 = 74141 or l<1 55ID1 (K155Mfl1) IC5 = PIC16F876-20/SP IC 6 = 7805 IC7 = MC34063 IC 8 = SHT2 1 PC humidity and temperature sensor [1 ] (Farnell #1 855468) T1 ,T2 = MPSA42 for powering the microcontroller and the 74141 decoder ICs. The high voltage sup- ply required for the Nixie tubes is gener- ated with IC7. This PWM controller switches MOSFET T3 in order to step up the voltage, using inductor LI and Schottky diode D1 . The output voltage is given by V 0 = V re f x R9 / R1 3 which, with the given values results in V 0 = 1 .25 V x 820 ka I 5.6 k& = 1 83 V. R1-4 take the high voltage supply to the anodes of the IN-1 4 tubes, giving an oper- ating voltage of around 143 V. With this relatively high voltage the tube filaments will light up brightly. If less brightness is needed, R9 may be replaced by 680 k£l, resulting in a voltage of about 1 52 V at the supply output. The high voltage supply line to the Nixie tubes can be controlled by the microcon- troller via T1 and T2. Reducing the duty T3 = IRF820 Miscellaneous XI = 6 MFIz quartz crystal VI = IN-1 9A, Nixie Tube (symbols) V2-V4 = IN-14, Nixie Tube (numeric) cycle of the PWM signal applied to the base of T2 results in a higher voltage at the base of T1 , which in turn results in a higher volt- age supplied to the Nixie tubes and thus a brighter lighting display. This way the switching between humidity and tem- perature display can be done quite nicely by slowly increasing the PWM duty cycle, resulting in dimming of the filaments and, after applying the new settings for the Nixie drivers, slowly decreasing the duty cycle of the PWM signal again, increasing the brightness of the newly selected filaments. The sensor used for measuring temperature and humidity differs from the one used in the earlier Elektor Nixie Tube Thermometer. In this circuit a Sensirion SHT21 [1 ] is used. This calibrated sensor emits its data digi- tally via an l 2 C interface. It requires a 3.3 V supply, which is generated using the volt- age drop across two diodes (D2, D3). Con- necting SCLand SDAwith a pullup resistor to 3.3 V on the sensor side prevents the upper voltage limits to be exceeded by the K1 = 2-way PCB terminal block, 5mm pitch PCB # 1 1 0321-1 , available via www.elektor. com/110321 PIC powered at 5 V. The Low level of SDA and SCL is ‘generated’ by tying the pins to ground, while the High level signal is ‘gen- erated’ by floating the PIC output pins. Pull- ups R1 1 and R1 2 then define the SDA and SCL levels as High (3.3 V). At the core we find the PIC1 6 microcon- troller. Its 6 MHz clock is generated by exter- nal quartz crystal XI. Since this circuit func- tions stand alone, it requires no controls or other interfaces. The software runs by itself and alternates between the displayed meas- ured values automatically. Software Designed in C using the MPLAB IDE, the software is quite straightforward. Temper- ature and humidity are periodically read out from the SHT21 sensor via its digital l 2 C interface and received at the corresponding ports of the PIC. Sample codes for interfac- ing the sensor are freely available in C from the Download Center on the Sensirion web- site, which makes it very easy to implement these functions in our firmware. 16 06-2012 elektor TEST & MEASUREMENT For clarity’s sake, the output to the decod- ers is generated using a lookup table. Since there is no ‘F* filament in the IN- 19A, a Fahrenheit indication option is not implemented. Construction The PCB (see Figure 2) can be ordered via the project web page [2] or a .pdf with the layout can be downloaded from the same page in case you want to etch the board yourself. The sensor should be positioned a minimum of about 15 cm (5 inches) away from the cir- cuit. The heating of the components, espe- cially the 74141 decoder ICs, may impair an accurate temperature measurement. The sensor is connected to the controller board using a four-wire cable and SIL headers (l<2, l<3). In one corner of the PCB there is a sepa- rate section for mounting the sensor, Cl 2 and connector K3. This section can be cut off and located away from the main board. Mounting the components on the PCB is a breeze. As usual, start with the low profile ones like resistors and place the ones with the tallest ones last. Guiding the leads of the Nixie tubes through the PCB might try your patience. However, there is a trick to this, as described in last month’s E-labs Inside sec- tion [3]: cut the leads in a ‘staircase’ fashion, each one a little shorter than the one next to it. Now they can be easily guided through the PCB holes one at a time. Pay close atten- tion to its orientation. An arrow on the bot- tom of the tube indicates pin 1 (see also the datasheet). An electrically insulated enclosure should be used, since the circuit generates high voltages. It’s important that no metal parts are exposed. Nylon screws and insulating sockets should also be used or other insu- lating measures should be taken. Nixie tubes Nixie tubes and 741 41 decoder ICs are read- ily available on Ebay. Especially from the for- mer USSR several large (ex military?) quan- tities are offered at affordable prices. Pro- duction of tubes lasted well into the 1 980s; some say because of technological back- wardness, others argue the tube’s superior immunity to EMP made it the best choice for active components. In this design especially the IN-19A is remarkable. This tube is especially con- Advertisement Lb Tarh Ih, feehThtFiilbfe Mri>. |«Tij I vT fatvmy-n •’ br ,h ' luiyinp/u ■ Inlvjor.! -j it-wlKp ** K»ii ICii * mnCMTII Fascinated by technology s impact on the future? Check out Tech the Future! www.techthefuture.com 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. Follow Tech the Future elektor 06-2012 17 TEST & MEASUREMENT structed to display symbols of units. Our circuit only uses two of them: *%’ and ‘°C’. Note the suffix ‘A’! See also the head illus- tration. For those having trouble reading Cyrillic characters, here’s the ‘translation’ of the table: IN-19A IN-igB IN-19V % S — M F A/B P H m V n l< T < n A > P Hz dB °C a + Pay close attention: the Cyrillic ‘B’ translates to our ‘V’. The ‘E’ would be pronounced as the ‘B’ of our Western character set. Nice to know: notice how the ‘2’ and ‘5’ filaments in the IN-14 number tubes are actually the same, only one is upside down. Budget cuts or just clever engineering? To round up Once assembled and fully connected, the circuit should work right away. No cali- brations or other setup procedures are required. The accuracy tolerance of the sen- sor is +0.3 °C typical (between 5 and 60 °C), while the resolution can reach 0.01 °C. Consequently, with a displayed tempera- ture of 25.0 °C the real temperature can be between 24.7 and 25.3 °C. A side note on the sensor: the humidity measured by the sensor can be quite off the mark. That’s a little strange for a cali- brated sensor, don’t you think? Perhaps it has something to do with mounting the sensor on the main PCB, as was done with our prototype. A logging circuit published last year in Elektor also showed these symp- toms. Some investigation may be in order here. At the time of writing the author is working on a wireless solution where the sensor is fitted in a separate enclosure together with the PIC and an RFM-1 2. A short impression of the circuit and the fading effect can be found on the Elektor YouTube channel [4]. (110321) About the author Hans Oppermann was educated as a radio and television engineer between 1 963 and 1 966, followed by a degree in Physical Engineering. Until his retirement in 2006, he worked as a Software Engineer with several software developing companies. He stayed loyal to his hobby and kept designing electronic circuits throughout his career, often related to elec- tric model airplanes. Since the arrival of microcontrollers, he built one into almost all of his circuits — mostly resorting to the PIC variety — time and again staggered by the absence of the need for complicated wiring. Among others, he also developed a weatherstation with long-term data logging and wireless transmission, a measurement circuit for domestic power usage, also with a wireless read out option, an infra-red readout of long-term values for PDA and a twilight switch for outdoor lighting. His preferred programming language is tcl/TK, which he also uses on his PDA to bypass op- erating elements on electronic devices, such as the GUI on a PDA. Internet Links [1 ] www.sensirion.com/sht21 [2] www.elektor.com/ 1 1 0321 [3] www.elektor.com/ 1 20229 [4] www.youtube.com/ElektorlM Elektor Products & Resources • Source code and hex files • Printed circuit board Available via www.elektor.com/ 1 1 032 1 . 18 06-2012 elektor green energy energy efficient low power hydropo solar . ... _ __ metering contro Renesas RL78 utom ore vl erforma win big The RL78 Green Energy Challenge It's time to turn those big ideas into great, green solutions! Join the Renesas RL78 Green Energy Challenge today and show the world how your design solutions will revolutionize the way we experience energy efficiency. The competition ends on August 31, 2012. Submit your Green Energy Project Entry today for your chance to win a share of a $17,500 cash grand prize and a trip to Renesas DevCon in October where winners will be announced. ANALOG DEVICES fl Renesas ii jf x SYSTEMS f In association with Elektor and Circuit Cellar Follow Renesas on Twitter and Facebook for your chance to win prizes from official partners throughout the competition. Answer weekly challenge questions correctly and you'll be en- tered into drawings to win free development tools, Pmods, Wi-Fi modules, books, and more! GainSpan ©JAR SYSTEMS Micri|im @Renesas_Europe • www.facebook.com/renesaseurope » * prizes Participation in Weekly Challenges and receipt of partner prizes is not a factor in selecting winners for the Grand Cash Prize from Renesas. Remember, a complete Project Entry is your Abstract, Complete Documentation, Photos and all supporting Source Code, zipped in one compre- hensive file, labeled with your unique Project Registration Number, and uploaded to the contest Dropbox. See web- site for complete rules and details. Void where prohibited by law. For complete details, visit www.circuitcellar.com/RenesasRL78Chall 4 OKAYA TOTAL PHASE r- & A, AUDIO & VIDEO Preamplifier 2012 (3) Part 3: level indicator, source selector, power supply By Douglas Self (UK) This month we close off the discussions of the individual boards that make up the preamplifier, both in terms of theory of operation and construction. The Log-Law Level LED (LLLL) stage The Log Law Level LED, or LLLL, is to the best of my knowledge, a new idea. A normal sin- gle-LED level indicator is driven by a com- parator, and typically goes from fully-off to fully-on with less than a 2 dB change in level when fed with music (not sinewaves). It therefore does not give much informa- tion. The LLLL, on the other hand, incorpo- rates a simple logarithmic converter so the range from LED-always-off to LED-always- on is extended to 10 dB. The preamplifier internal level is correct when the LED is on about 50% of the time. This gives a much better indication as you can judge the level approximately from the on/off ratio. Referring to the circuit diagram in Fig- ure 1 , IC1 A with R1 , R2, D1 , D2 is a preci- sion half-wave rectifier circuit. Its output when combined with the feed through R3 provides a full-wave rectified signal to IC1 B; this is another precision rectifier that establishes the peak level of the signal on C2. This is buffered by IC2Ato prevent load- ing by the next stage, and the peak voltage is applied to the very simple log-law con- verter IC2B. For low level signals the gain is set to unity by R6 and R7. As the input volt- age increases, first D5 begins to conduct, reducing the gain of the stage by increased negative feedback through R8. At a higher voltage set by divider R9 and R1 0, D6 also conducts, reducing the gain further by neg- ative feedback through R9. This simple cir- cuit clearly gives only a very approximate version of a log law but it transforms the operation of the indicator. The processed voltage is applied to compar- ator IC5A, and if the threshold set by R21 , R22 is exceeded the open-collector output of IC5A goes Low and the output of IC5B, which simply acts as a logical inverter, goes High, removing the short across the LED connected to pinheader l<6 and allowing it to be powered by current source T1 . There are two channels for stereo operation and 20 06-2012 elektor AUDIO & VIDEO LLL Led Phono R — D> K6 PHONO PCB 120231 - 11 ■17V' Figure 1 . Schematic of the Log-Law Level LED (LLLL) board. the outputs of comparators IC5A and IC5C are wire-OR’d together to pull-up resistor R23 so that a signal on either channel will make the LED illuminate. IC5D is not used. The LLLL can be switched to read either the phono input directly (so the switched-gain stage can be set up correctly) or the signal after the input select relays and balanced line input stage, where it can be used to check the incoming level of any input. This switching is done by relay contacts RE1 B, RE1C. Series relay contacts RE2B, RE2C allow the LLLL to be disabled when its job is done and the flickering LED may become irritating. The LLLL is built on circuit board no. 1 1 0650-6 shown in Figure 2. It contains through-hole components only, hence nothing should hinder you from producing a working board straight off if you are care- ful about placing and soldering the parts. The same applies to the other three (four) boards discussed below. The finished LLLL board is pictured in Figure 3. elektor 06-2012 21 AUDIO & VIDEO COMPONENT LIST LLLL board (#110650-6) Resistors (0.25W, 1%) R1 ,R2,R3,R5,R1 1 ,R1 2,R1 3,R1 5 = 20I<£1 R4,R6,R7,R1 4,R1 6,R1 7=1 Oka R8,R9,R18,R19 = 1kn R10,R20 = 100I<^ R21 =91 0^ R22,R23,R25 = 22kn R24 = 100n R26,R27 = 220n Capacitors Cl -C4 = 2.2|iF 20% 1 00V, diam. 6.3mm, 2.5mm pitch C5-C9 = 1 0OnF 1 0% 1 00V, 7.5mm pitch Cl 0,C1 1 = 1 0OpF 20% 25V, diam. 6.3mm, 2.5mm pitch Cl 2, Cl 3 = 220nF 1 0%, 1 00V, 7.5mm pitch Inductors LI ,L2 = 1 mFI 3.6n 370mA, axial Semiconductors D1-D14 = 1 N4148 T1 = BC557B IC1 -IC4 = NE5532 IC5 = LM339 Miscellaneous K1 -K4,l<6 = 2-pin pinheader, 0.1 ” pitch (2.54mm) Socket headers for K1 -K4,l<6 l<5 = 3-pin pinheader, 0.1 ” pitch (2.54mm) Socket header for l<5 l<7 = 3-way PCB terminal block, 5mm pitch RE1 ,RE2 = V231 05-A5003-A201 , 1 2V/960n, 230V/3A, DPDT PCB # 1 1 0650-6 (www.elektorpcbservice. com) Figure 2. The combined metering and driver circuitry of the Log-Law Level LED indicator is built on this board. Board available through www.elektorpcbservice.com. Figure 3. Prototype of the LLLL board built by Elektor Labs. The input PCBs The input circuit boards (one per channel) carry the input and output connectors plus the relays that select which input is in use. Their circuit diagram appears in Figure 4. The four line-level inputs can work in either unbalanced or balanced mode, though of course balanced mode is strongly recom- mended because it rejects electrical noise on the ground paths. Bear in mind this is true even if the source is unbalanced. In this case the cold (phase-inverted) balanced input must be connected to ground at the source end of the cable — a 3-way cable is still required. There is therefore no techni- cal reason to provide RCA connectors but they are included for convenience. If they are to be used the jumpers JP1 -JP4 must be installed. For Input 1 , relay contacts RE1 B, RE1 C con- nect to the preamplifier input when relay coil RE1 A is energised, and the signal goes to the main preamplifier board via connec- tor K1 5. Facilities are also provided for using the XLR inputs in unbalanced mode; in this case the jumper SI is set so that RE1 B connects to ground rather than pin 3 of the XLR. The same applies to Input 2 and Input 3. How- ever, if you have spent the money for an XLR you really should make proper use of it by employing balanced mode. Input 4 is the phono input if the phono facil- ity is included in the preamplifier. Input 4 is used for either MM or MC mode, as this selection is made on the phono PCB dis- cussed in part 2. In this case l<7 and l<8 are not fitted. If the phono PCB is not used Input 4 can be used as another Line input, with l<7 and l<8 fitted. In this case there is no connection to K1 3. There is no facility for using the MC and MM cartridge inputs in balanced mode so only RCA connectors are provided for these inputs. This circuit is constructed on circuit board no. 110650-3 pictured in Figure 5; the assembled board appears in Figure 6. The front panel PCB The front panel board of which the sche- matic is shown in Figure 7, carries the input select switch, the LLLL source select switch, the three mode switches, and the power 22 06-2012 elektor AUDIO & VIDEO Figure 4. Circuit diagram of the input section of the preamplifier. COMPONENT LIST Input board (#110650-3) Resistors R1,R2 = 0£1 Capacitors Cl -C4 = 220nF 1 0% 1 00V, 7.5mm lead pitch Miscellaneous K1 ,K3,K5,I<7 = XLR socket, PCB mount, horizontal, 3-way K1 1 = XLR plug, PCB mount, horizontal, 3-way K2,K4,K6,K8-K1 0,l<1 2 = RCA/Phono socket, PCB mount, Pro Signal type PSC01 545 (red) (R) or PSG01 546 (white) (L) K1 3,JP1 -JP4 = 2-pin pinheader, 0.1 ” pitch (2.54mm) Socket header for K1 3 K14,K15,I<16 = 4-pin pinheader, 0.1” pitch (2.54mm) Socket headers for K1 4,l<1 5,l<1 6 K1 7 = 1 0-way boxheader, straight, 0.1 ” pitch (2.54mm) SI -S4 = 3-pin pinheader, 0.1 ” pitch (2.54mm) Jumpers for SI -S4,JP1 -JP4 RE1 -RE4 = V231 05-A5003-A201 , 1 2V/960ft, 230V/3A, DPDT PCB # 1 1 0650-3 (www.elektorpcbservice. com); 2 pcs required Figure 5. The preamplifier’s input board (here at 75% of its real size). Two of these are required for stereo operation. Board available through www.elektorpcbservice.com. Figure 6. Fully assembled Input board. elektor 06-2012 23 AUDIO & VIDEO Figure 7. This sub circuit of switches, LEDs, resistors and connectors forms a separate board intended for fitting to the inside of the preamplifier front panel. and LLL LEDs. S5A is the input select switch, controlling the relays on the input boards Only the first four positions are used, the other two being blocked off by a mechanical stop. S5B is not used. The switching between MM/MC and Line input is done by a separate switch S2 on the front panel board. S4A and S4B control the operation of the LLLL indicator. In the first position the LLLL is fed from after the input select and balanced input stage and can be used to check any input. In the second position it is fed from the phono stage only, whichever input is selected. The third position removes the signal fed to the LLLL and so disables it. Only the first three positions of the switch are used (Line— Phono— Off) and the other three are blocked off by a mechanical stop. Switch SI controls the tone-control defeat relay. When SI is closed the tone-control is bypassed completely. Switch S2 selects between moving-mag- net (MM) and moving-coil (MC) opera- tion, using relay contacts RE1 B, RE1 C on the phono PCB. When S2 is closed the MC input is active. S3 selects the IEC amendment, which is a largely unwanted extra roll-off at 20 Hz that COMPONENT LIST Front panel board (#110650-4) Resistors (0.25W, 1%) R1 = 2200 . R2 = 3.3I<£1 Semiconductors D1 = LED, green, 3mm, through hole D2 = LED, red, 3mm, through hole Miscellaneous K1 = 1 0-way boxheader, straight, 0.1 ” pitch (2.54mm) K2,K5,D1 ,S1 -S3 = 2-pin pinheader, 0.1 ” pitch (2.54mm) Socket headers for K2,K5,D1 ,S1 -S3 K3,K4 = 3-pin pinheader, 0.1” pitch (2.54mm) Socket headers for K3.K4 l <6 = 2-way PCB terminal block, 5mm pitch SI ,S2,S3 = switch, SPDT (On-On) S4,S5 = 2-pole, 6 -position rotary switch, PCB mount, e.g. Lorlin type Cl<1 050 PCB# 110650-4 (www.elektorpcbservice.com) Figure 8. The front panel circuit board. Board available through www.elektorpcbservice.com. Figure 9. The Front Panel board, ready for use. 24 06-2012 elektor AUDIO & VIDEO was later added to the RIAA spec. When S3 is closed the IEC amendment is applied. The small board no. 1 1 0650-4 for securing to the front panel of your preamplifier case is pictured in Figure 8, along with the Com- ponent List. Check Figure 9 for the assem- bled board. The power supply PCB The power supply is fairly conventional as the preamplifier does not require ultra-low noise on the supply rails to give its best per- formance. Referring to Figure 10, a centre- tapped 18-0-18 V power transformer, a bridge rectifier D3-D6 and reservoir capac- itors C8, Cl 0 produce the unregulated sup- ply voltages. Snubbing capacitors Cl 4-C1 7 prevent RF being generated by the rectifier diodes. LEDs D7 and D8 are mounted on the PCB and indicate that the unit is powered and both unregulated supplies are present. The ±1 7 V supplies for the opamps are gen- erated by regulators IC1 and IC2. The net- works R1 , R2 and R3, R4 set the voltage required while C5 and C6 improve the rip- ple performance of the regulators. D1 and D2 prevent the stored charge on C5 and C6 damaging the regulators if the output is short-circuited. Capacitors C1-C4 reduce the output impedance of the supply at high frequencies. A separate +1 5 V regulator IC3 is used to power the relays. This is powered from the unregulated positive supply that also feeds the +1 7 V regulator. Note that the audio ground and the relay ground must be connected together at one point only, right back at the power supply; otherwise relay currents flowing in the audio ground will cause unpleasant clicking noises in the preamp output. Number 1 1 0650-5 is the last board you’ll be building to construct the Preamplifier 2012; it’s shown in Figures 1 1 (PCB only) and 12 (assembled board). IC3 18V c v “H0| K6 1 C13 lOOn IC1 LM317 0 ♦ adj V II D5 C16 D8 47 n D6 HI C17 4700u 35V CIO 4700u 35V C7 lOOn C12 lOu 63V C11 lOOn Vre K4 K6 FRONT PCB +17V O 1N4004 C5 47u 25V C9 lOOn 1 47n D3 ...D6 = 4x MBR1045 C6 47u 25V T C2 Cl lOOu lOOn 25V < adj ■> ♦ LM337 1N4004 C4 lOOu 25V C3 lOOn Y N IC2 6 -i7v 120231 - 14 Figure 1 0. The circuit diagram of the power supply holds common-or-garden components hence few surprises. Note that the relays have their own 1 5 V voltage regulator. Wiring Comprising a total of seven boards, the Preamplifier 201 2 is quite an intricate job to wire up. For your convenience the con- nectors (‘Kx’) in this month’s schemat- ics have been given what/where/to labels. Most of the board interconnections consist of short runs of 2, 3 or 4 light duty, flexible elektor 06-2012 25 AUDIO & VIDEO Figure 1 1 . The power supply board. Board available through www.elektorpcbservice.com. Figure 1 2. Preamplifier PSU board assembled by Elektor Labs. COMPONENT LIST Power supply board (# 110650-5) Resistors (0.25W, 1%) R1 ,R3 = 1 00£1 R2,R4 = 1.3kn R5 = 1£2 R6,R7 = 12kn Capacitors Cl ,C3,C7,C9,C1 1 ,C1 3 = 1 0OnF 1 0% 1 00V, 7.5mm pitch C2,C4 = 1 OOjiF 20% 25V, 6.3mm diam., 2.5 mm pitch C5,C6, = 47pF 20%, 25V, 6.3 mm diam., 2.5 mm pitch C8,C1 0 = 4700jiF 20% 35V, 22mm diam., 10 mm pitch C12 = IOjiF 20% 63V, 6.3mm diam., 2.5mm pitch Cl 4-0 7 = 47nF 50V, ceramic, 5mm pitch Semiconductors D1 ,D2 = 1 N4004 D3-D6 = MBR1 045 D7 = LED, red, 3mm, through hole D 8 = LED, green, 3mm, through hole IC1 = LM317 IC2 = LM337 IC3 = 781 5 Miscellaneous K1 ,K2,I<3 = 3-way PCB terminal block, 5mm pitch K4,K5,K6 = 2-way PCB terminal block, 5mm pitch HS1 ,HS2 = heatsink, 50.8 mm, Fischer Elek- tronik type SK 1 29 50,8 STS HS3 = heatsink, 50.8 mm, Fischer Elektronik type SKI 04 50,8 STS PCB # 1 1 0650-5 (www.elektorpcbservice. com) Not on PCB: Trl = AC power transformer, 1 1 5/230V prima- ry, 2x1 8V/50VA secondary, e.g. Multicomp # MCTA050/1 8, Farnell (Newark) # 9530380 FI (230VAC) = fuse, 0.31 5A antisurge, 5x20mm, panel mount FI (1 1 5VAC) = fuse, 0.63A antisurge, 5x20mm, panel mount 51 = 1 1 5/230V AC line voltage selector, e.g. Arcolectric Switches type T22205BAAC 52 = AC power switch wires of different colours (agree on black for ground though) twisted together and their ends soldered to the socket for plugging on the pinheader. Look at the symbol with the mating pinheader on the PCB to identify the bevelled edge, this will help you get the pin- to-pin connections right. The 1 0-way connection between the front panel PCB and the input PCB is the only one requiring a length of flatcable (a.k.a. ribbon cable) with IDC sockets pressed on at the ends. All wiring and components ‘ahead of and including power transformer Trl is at AC powerline potential hence should comply with safety regulations and recommenda- tions in place for electrical safety. When in doubt, ask for help or advice from a quali- fied electrician. At the time of writing the Preamplifier 201 2 is fully wired up on the audio test bench at Elektor House, but not yet fitted in a case. The two input boards are mounted like a sandwich using four PCB pillars. Depending on your response to the project we may do a final article laterthisyearon installing the boards in a high quality enclosure. For now we leave that part of the project to you, as well as enjoying the superb sound quality of the Preamplifier 201 2. ( 120231 ) 26 06-2012 elektor Create complex electronic systems in minutes using Flowcode 5 Design -Simulate Download Flowcode is one of the World’s most advanced graphical programming languages for micro- controllers (PIC, AVR, ARM and dsPIC/PIC24). The great advantage of Flowcode is that it allows those with little experience to create complex elec- tronic systems in minutes. Flowcode’s graphical development interface allows users to construct a complete electronic system on-screen, develop a program based on standard flow charts, simulate the system and then produce hex code for PIC AVR, ARM and dsPIC/PIC24 microcontrollers. Convince yourself. Demo version, further information and ordering at www.elektor.com/flowcode elektor 06-2012 27 STEPPER MOTOR DRIVER Flexible Stepper Motor Driver With electrically isolated interface By Chris Vossen (Elektor Labs) To enable the control of a stepper motor from, say, a parallel port of a PC, Elektor Labs have designed a compact driver PCB using the A3979 chip made by Allegro Microsystems. This chip has been specifically designed to control bipolar stepper motors in full-, half-, quarter- and sixteenth-step modes at currents of up to 2.5 A. The circuit is provided with optocouplers for electrical separation between the control inputs and the driver module. Stepper motors are used in many mechatronics projects to implement some kind of motion. Applications such as robots, scanners, milling machines and 3D printers come to mind. There is often the desire to keep the accompanying electronics as sim- ple as possible. In particular with hobby pro- jects, the legacy Centronics port of a PC is still freguently used to control a few motors by way of power drivers. For all those enthusiasts unable or unwill- ing to develop such a driver themselves, the guys at Elektor Labs have developed a universal board based on a special stepper motor driver 1C and featuring full electrical isolation for the control signals. The supply voltage for the electronics is derived from the stepper motor’s power supply using a small switch-mode power supply regulator, which ensures that the power dissipation is kept to a minimum. The A3979 Allegro Microsystems’ type A3979 is a so- called microstepping motor driver with integrated DMOS bridge and level shifter. This tiny 1C (it measures only 6.5 x 1 0 mm in size) can control stepper motors in full-, half-, guarter- and sixteenth-step modes with the aid of an integrated PWM con- troller. The internal FET bridge can supply a maximum current of 2.5 A at voltages up to 35 V. Thanks to the built-in ‘trans- lator’ all manner of controlling a stepper motor with this 1C is easy. After establish- ing the mode in which the motor is to be controlled, using inputs MSI and MS2, a pulse at the STEP input is sufficient to make the attached motor rotate a full-step, half- step, etc. Figure 1 shows the block diagram of the A3979, together with the necessary external components. The datasheet for the A3979 is available from [1 ]. Apart from the selection of a few of these external components, which we will return to shortly, there are very few things you need to consider. There are only three sig- nals that need to be supplied for the control of the motor: step pulses, direction signal and enable signal. Optical drive In the complete schematic shown in Fig- ure 2 you can see that the A3979 is con- nected according to the design already encountered in the block diagram. The windings of the stepper motor and the power supply voltage for the motor are connected to connector l<4. The inputs MSI and MS2, which are used to set the size of the microsteps of the motor, are connected to l<1 and l<2 in the schematic. In reality these ‘connectors’ are solder pads on the circuit board. The user can decide with two drops of solder across the appropriate pads which type of microsteps will be used. Table 1 shows the different options that are available. To allow as much electrical separation as possible between the controlling part (PC or a microcontroller board) and driver board, a four-way optocoupler is added in the form of an ACPL-847 made by Avago Technolo- gies (IC1 ). When one of the inputs DIR, STEP or ENABLE is set to a Low level, the corre- sponding LED in the optocoupler will turn on and as a conseguence the accompany- ing transistor will conduct. When changing the level at the DIR input the direction of rotation of the attached motor will change. With every rising edge at the STEP input the 28 06-2012 elektor STEPPER MOTOR DRIVER motor will perform one microstep. Finally, the motor driver is activated when the ENA- BLE signal is set to a Low level. The A3979 checks this level at every rising edge of the STEP input. Technical characteristics • Suitable for most small bipolar stepper motors • Integrated DMOS-bridges, maximum voltage/current: 30 V / 2.5 A • Default current limit: 1.5 A • Electrically isolated control lines using optocouplers • Full-, half-, quarter- and sixteenth-step mode settable using solder bridges • PWM control for minimal dissipation • Built-in translator for controlling the motor • Built-in blanking function for the DMOS bridges • Various protection features built in (current and temperature, among others) The driver circuit is completed with a small switching power supply, which is designed around an LM2594M-5.0. This step-down regulator derives a regulated 5 V rail from the motor supply voltage. The input voltage can be between 5 V and 30 V. LED D4 func- tions as the power-on indicator. Component sizing Parts R1 0 and R1 1 are the current sensing resistors for the two motor windings. They define the maximum current that is per- mitted to flow through the stepper motor coils. These resistors must have a very small self inductance. Any additional inductance in the measuring resistor will effectively appear in series with the winding of the motor. This increases the reactance (AC resistance) of the total circuit and results in a measuring error of the pulsewidth modu- lated signal. According to the datasheet, R sense has to sat- isfy the condition ^sense <0.5 j /trip where / trip is the maximum permissible cur- rent for each coil in the motor. Here we set this to 1.5 A, which is an excellent value for the commonly used Nema-1 7 type of motors. When we enter this value into the formula we arrive at a value for R sense of < 0.33 a The datasheet for the A3979 gives a sec- ond requirement that needs to be satisfied: V re f has to be equal to, or less than, 4 V. This voltage is determined by using the formula Figure 1 . Block diagram of the A3979 from Allegro Microsystems. Kef =8>< /trip X Ksense ^ 4 V. Here a value of 1 .5 A was chosen for / trip , and a resistance of 0.1 Q for R sense . This results in a maximum V ref of 1 .2 V. The motor current through each sense resistor results in a rel- atively high power dissipation. This power dissipation amounts to P =/ 2x Ksense = 0.225 W. K1 l<2 Table i. Microstepping configuration. K1 l<2 K1 l<2 full step half step quarter step K1 l<2 sixteenth step elektor 06-2012 29 STEPPER MOTOR DRIVER +30V Q +VIN Q 110018-11 =1= PMEG6030EP GND Figure 2. The complete schematic for the circuit, optocouplers provide full electrical isolation of the control signals. The combinations of R12/C9 and R1/C8 determine the duration of the off-time for the one-shot timer in the PWM generator, which sets the amount of time when the internal MOSFETs are switched off. Accord- ing the datasheet these need to have a value somewhere between 12 l<^ and 100 for Rj and between 470 pF and 1 500 pF for C T . Bipolar stepper motors have a rela- tively low self-inductance, which means that the blanking time for the comparator does not have to be very long. That is why capacitors of 470 pF and resistors of 1 2 kQ. were selected. The purpose of the blank- ing function is to avoid incorrect measure- ments across the current sense resistors at the instant that the outputs are switching. When a step results in a lower current than the previous step, the circuit will change decay mode. This can be a slow, fast or mixed decay. The voltage across the P FD pin determines the decay- mode of the circuit. If the voltage at P FD is greater than 0.6 V DD , then slow-decay- mode is used. When the voltage is smaller than 0.21 V DD , fast-decay mode is used. In this circuit we chose for mixed -decay-mode because this provides optimal performance for most stepper motors. The voltage at pin 5 is set to 2 V (0.4 V DD ) here using R5 and R13. Miniature circuit board The entire circuit is accommodated on a circuit board measuring only 43 x 47 mm (Figure 3), thanks to the use of SMD com- ponents. This does however require a cer- 30 06-2012 elektor STEPPER MOTOR DRIVER tain amount of SMD soldering experi- ence or a small SMD oven. The A3979 is provided with an ‘exposed thermal pad’ to help dissipate the heat. This has been taken into account when designing the circuit board. Underneath the 1C is a sol- der pad with a number of vias that ensure sufficient conduction to the underside of the board, which contains a large copper plane. The thermal pad of the 1C therefore has to be soldered to this solder pad at the same time as soldering the other connec- tion pins. To be able to do this properly, the use of a hot-air solder station or SMD oven is recommended. To be on the safe side, the top of the 1C is also provided with a small heatsink with the aid of thermally conductive double- sided adhesive tape. The only two through-hole components are the connectors l<3 and l<4. The types shown in the parts list are suitable for larger cur- rents of several amps; in addition, the cor- responding plugs are provided with screw connections to terminate the wires. Current limiting The maximum current that will flow through the windings of the stepper motor can be set with the aid of trimpot PI . This is done as follows: Using a multimeter meas- ure the reference voltage (\/ re f) at the test point next to the trimpot on the board. The voltage that is set determines approximately what the maximum current will be: Note that the maximum input voltage is not allowed to be higher than 30 V. With this the universal stepper motor driver is ready for use. Thanks to the small dimen- sions several of these boards can easily be mounted inside a printer or robot frame. Kef(V) 0.4 0.6 0.8 1 1.2 ^trip (A) 0.5 0.75 1 1.25 1.5 ( 110018 -I) COMPONENT LIST Resistors (SMD 0603) R1.R12 = 12k£2 R2,R3,R4,R6,R7,R8,R14 = 1 k£l R5 = 3.3ka R9 = 22ki2 R1 0,R1 1 = 0.1 00£2 (SMD251 2, e.g. Bourns CRA2512-FZ-R100ELF; Farnell # 1435952) R13 = 2.2I<£2 PI = 1 0I<£2 trimpot (e.g. Vishay TS53YJ1 03MR1 0; Farnell # 1 141485) Capacitors 0,03 = 220nF (SMD0603) C3 = 220nF (SMD0805) C4 = 1 OOpF (case F, e.g. Panasonic EE- EFK1H101P; Farnell #9695958) C5,C6,C7 = 1 0OnF (SMD0805) C8,C9 = 470pF (SMD0603) 00,04 = 100nF(SMD0603) 02= 47pF (SMD 6032, e.g. Vishay 593D476X901 0C2TE3; Farnell # 6844626) Inductor LI = lOOpH (SMD5750, e.g. Epcos B82442H1 104K, Farnell# 158896) Semiconductors D1 ,D2,D3 = LL4148 (SOD80; Farnell #9843710) D4 = LED, green, 20 mA (SMD 0603) D5,D6 = PMEC6030EP Schottky diode (S0D1 28; Farnell #1829207) IC1 = ACPL-847-30GE (S0P1 6; Farnell #1339045) IC2 = A3979SLP-T (Farnell #1521716) IC3 = LM2594M-5.0 (S08, Farnell #9779841 ) Miscellaneous K1 ,l<2 = solder jumper on board l<3 = 4-pin plug, right angled, 8 A, 3.5mm pitch (e.g. Phoenix Contact 1 844236 MC1 .5/4-G-3.5; Farnell #1 843622) Mating 4-way socket with screw terminals l<4 = 6 -pin plug, right angled, 8 A, 3.5mm pitch (e.g. Phoenix Contact 1 844252 MC1 .5/6-G-3.5, Farnell #1 843648) Mating 6 -way socket with screw terminals Heatsink for IC2 (Fischer ICK SMD A 1 3 SA; Farnell #4302199) Matching double-side adhesive tape 6x1 0 mm PCB #11 001 8-1 (see www.elektor. com/110018) Figure 3. Thanks to the use of SMA components the dimensions of the board are only 43 x 47 mm. + 5 V DIR STEP ENABLE Internet Links [i] www.allegromicro.com/Products/Motor-Driver-And-lnterface-ICs/ Bipolar- Stepper-Motor-Drivers/ ~/media/Files/Datasheets/A3979-Datasheet.ashx elektor 06-2012 31 MICROCONTROLLERS Embedded Linux made Easy (2) Hardware Choosing a suitable microcontroller and supporting ICs is an essential step at the beginning of many a project. In this part of our course we will examine the circuit diagram of our board and look more closely at the most important components. We will then boot it for the first time and study what happens. We shall see how easy Linux can be! By Benedikt Sauter [ 1 ] In the first part of this series we looked at the history of the free GNU/Linux operating system and its most important elements. We now want to look at our hardware in detail: the Elektor Linux board. The main components The circuit has deliberately been kept sim- ple: we have included only the most impor- tant components. The idea is that any reader should be able to understand the system from end to end: from applying power to launching complex applications. Running the GNU/Linux operating system requires the standard components of a computer architecture: a processor, RAM (working memory) and ROM (non-volatile memory): see Figure 1 . How do these all work together on our board? When power is applied a mini-bootloader (roughly the equivalent of the BIOS in a PC) is started, which copies the kernel from ROM into RAM. The kernel is then started: this in turn also has access to the ROM, from which it can copy any application into RAM as needed. We will now look at these compo- nents in more detail. The processor We start with the processor. It is located in the centre of the board, in a 12 mm-by- 12 mm BGA package. The Linux kernel was originally developed for the x 86 archi- tecture, which is rather a different beast from that of a typical embedded proces- sor. Because of the open way in which the programmers work and the well-thought- out structure of the software, however, it is possible to port the kernel to a range of different processors. Essential to porting Linux to a new architecture is the availa- bility of the GNU GCC toolchain [2], which was briefly described in the first article in this series. The processor must have a hard- ware timer and a 32-bit architecture. An MMU (memory management unit) is not absolutely necessary, but it does help the operating system to allow different appli- cations to run stably and independently of one another. Each application is assigned its own virtual memory space and does not have access to the memory of other applica- tions. The project uclinux.org [3] provided patches (see the text box) to the kernel to allow use with a processor lacking an MMU. Recently, however, these patches have been integrated into the ‘mainline’ kernel. In any case, we will take advantage of the MMU in our LPC3131 processor and will therefore not need to use these patches. The LPC3131 [4] processor by NXP uses an ARM9 core (to be precise, an ARM926 run- ning the ARMv5 instruction set). It runs at 180 MHz and has 192 Kbytes of inter- nal SRAM; an integrated DRAM controller allows external memory to be attached. All the usual microcontroller interfaces, such as l 2 C, SPI and a UART, are included. There are 21 GPIO pins, four analogue inputs, an LCD interface, an l 2 S audio interface and a high-speed USB (480 Mbit/s) interface, which open up a wide range of application possibilities from within the Linux operat- ing system. The Elektor Linux board is only double-sided, and so not all the signals can Elektor products and services • Elektor Linux board, ready built and tested: 120026-91 All products and downloads are available via the web page for this • Free software download article: www.elektor.com/ 1 20146 32 06-2012 elektor EMBEDDED LINUX be brought out: however, all of the impor- tant ones are available. The processor we have chosen is ideal for an introduction to the world of Linux as it includes only the absolutely essential facili- ties and peripherals, falling decidedly in the ‘low cost’ and ‘low power’ categories. Other ARM9-based microcontrollers might offer a more comprehensive range of features, but tend to be correspondingly harder to use. Nevertheless, once the basics are under- stood, it is relatively easy to progress to more complex devices. Working memory The processor itself includes just 192 Kbytes of RAM, which we will need to expand with external memory to allow us to run the ker- nel, the other operating system compo- nents and applications. The internal RAM is used only to run the bootloader program. Once the bootloader has configured the external memory appropriately (which includes setting up the timing parameters on the integrated memory controller and initialising the memory contents), the inter- nal RAM is only used for speed reasons, for example as a cache for the operating sys- tem or for applications. The external mem- ory takes the form of SDRAM (synchronous dynamic memory): these are very low-cost devices offering large storage capacities. A quick glance at the LPC3131 datasheet [4] suffices to identify find a suitable 1C. We also discover that the device supports a 16-bit external data bus and a maximum address range of 1 28 Mbytes. A special fea- ture is support for so-called ‘low-power’ SDRAM devices, which are optimised for current consumption. On our board we use an 8 Mbyte device; a 32 Mbyte device can be substituted if desired. Since the world of RAMs is standardised by JEDEC [5], a suit- able device can be obtained from a wide choice of manufacturers. In the circuit we have shown the AMIC A43E261 61 [6]: this is a low-power device that needs a 1 .8 V supply. The ‘hard drive’ The ‘hard drive’ of our board is a common- or-garden microSD card (Figure 2), as used these days in practically every digi- tal camera and many mobile phones. The Non- volatile memory ROM *J1:U5S 1 ELEKTOR . - J 120026 -J RAM USB Serial console Processor LPC3131 EEv-klcir Linu* Ha-ii'C vi.B I,, X - Power supply ^ Figure 1 . The main components of the Elektor Linux board. card essentially consists of a NAND flash memory and a simple controller. Unlike NOR flash memory, NAND flash is always addressed by block and sector. Our stand- ard microSD card has a capacity of 1 Gbyte, although larger cards can of course be used. As well as being readily available, microSD cards have the advantage that no special programming equipment is needed for the board: all programs and data files can sim- ply be copied to the card using an ordinary card reader connected to a PC. The circuit We now turn to the circuit diagram (Fig- ure 3), starting with the power supply. One possibility is to power the board using a USB cable at connector X2. The same con- nection can be used to talk directly to the serial console of the Linux system over USB, the CP21 02 (IC7) functioning as a USB-to- serial converter. If the system is being used without a con- sole (for example if the UART interface is being used for a different purpose) exter- nal power can be applied at connector X6. This allows higher voltages to be applied, as an MC7805ABDT linear regulator appears between this source and the regulators for the processor proper. We suggest using a DC supply of between 7 V and 1 2 V. Jumper J4 is used to select whether external power or USB power is used. The internal 5 V rail is taken directly to the inputs of switching regulators IC1 to IC3. These have a maximum permissible input voltage of just 6 V. Resistors R4, R6 and R7 determine the output voltages of these regulators. The voltages we need are 3.3 V for the LPC3131 , 1 .8 V for the SDRAM, and 1 .2 V for the ARM9 core in the processor. When power is applied the ‘enable’ signals of the regulators (pin 1 in each case) are immediately taken high and they immedi- ately start to produce their output voltages. Some of the more sophisticated ARM-based processors have rather onerous power sequencing requirements. r i— — ■ SarDlsk 2GS * A * , ■ Adapter ■ Figure 2. A microSD card and an SD card adaptor. With the board now powered up we can turn our attention to the LPC3131 in the circuit diagram. It is device IC6, split up in the diagram into three parts labelled IC6.A to IC6.C: splitting the pins of the device into logical groups like this makes the diagram easier to understand. Block IC6.A covers all the important interfaces and I/Os of the processor; block IC6.B includes the data and address buses; and block IC6.C contains the power supply pins. elektor 06-2012 33 EMBEDDED LINUX +1V2 +3V3 C37 ^Ou f , JC35 ^C36~ © +5V C14 f t ^C16 JciT ^ 20p ^Ou ^^00n^ 47n LPC_VBUS L2 9pc DM N2 9pc DP P2 ^USB_ID Ml J5 R11 1 % K4 L3 N1 I2C SDA CIO DIO E12 I2C_SCL El 3 +3V3 9 | R1 TP3 o- SPLSCK G14 F14_ F13_ M10 N10_ P11_ A7 A8 ^SPLMISO C8 / TP4 Q B8 splmosT B7 M13 M12 Ml 1_ N14 F12_ E14 TP1 TP2 G1 5h LPC_RXD I LPC_TXD P12 N12 TP50- TP60- N13 P14 PWM DATA B9 A +3V3 © Tr26 +3V3 9 jnTJci ^3n3 ^^ 0 lOu < Q Q >, m c/> USB_VBUS USBJ3M USBJ3P USBJD USBJTREF USB_VSSA_REF USB_VSSA_TERM USBJ3NDA I2C_SDA0 I2CJ5CL0 I2C_SDA1 I2C SCL1 I2SRX_DATA1 I2SRX BCK1 I2SRXJ/VS1 I2SRX_DATA0 I2SRX BCKO I2SRX WSO o' □ < □ a >, ca co < o a JTAGSEL RSTIN_N IC6.A TRST_N TDI TMS TCK ARM_TDO SCAN_TDO BUF_TRST_N BUF.TCK BUF.TMS CLK„256FS_0 CLOCK_OUT SYSCLK 0 Nil H14 RESET PI 3 TRST_ N K9 TDI P10 TMS M14 TCK Ell TDO LPC313XFET180 SPI_CS_OUTO SPI SCK SPLMISO SPI CS IN SPLMOSI MI2STXJ3ATA0 MI2STX_BCK0 MI2STXJ/VS0 MI2STX_CLK0 I2STX_DATA1 I2STX_BCK1 I2STXJ/VS1 UART_RXD UART_TXD MUART_CTS_N MUART_RTS_N PWM_DATA i — co < GPIOO GPI01 GPI02 GPI03 GPI04 MGPI05 MGPI06 MGPI07 MGPI08 MGPI09 MGPIO10 GPI011 GPI012 GPI013 GPI014 GPI015 GPI016 GPI017 GPI018 GPI019 GPIO20 ADC10B-GPA0 ADC10B-GPA1 ADC10B-GPA2 °, ADC10B-GPA3 I— CO < GPI015 /" 1 H 1 Q2 C30 Hih ■ 12MHz “ 22p F10 _F1 1 D13 D14 H12 J4 G13 +3V3 © Tr2 \ \ \ \ \ K10 J10 SYSCLKO GPIOO L14 GPI02 B11 LED1 ^ \ C11 B6 LPC MCI CLK A6 LPC MCI CMD^ A A5 LPC_MCI_DATO B5 LPC_MCI_DAT1 C5 LPC MCI DAT2 \ \ A4 LPC MCI DAT3^ N H13 GPI011 H10 _J12 J14 GPI014 J13 GPI015 J11 K12 K14 \ GPI018 H11 K13 B14 GPI019^ \ GPAO A14 B13 C14 GPAI^ \ GPA3 +3V3 © TR17 C29 22p S3 _ r RESET / C11 * ? nToon RESET I I +3V3 (+ X7 X4 © 3.3 V GND © © 1 GPA1 / 2 GPIQ11 y 3 GPIQ14 / 4 GPIQ15 / 0 O CO ID I CM CM CO CM CTl Cd Cd Cd rJ LPC MCI DAT2 / LPC MCI DAT3 / LPC MCI CMP / LPC MCI CLK / LPC MCI DATO / LPC MCI DAT1 / LPC_MCI_CD SD-CardSocket LPC_D0 G2 ^LPC_D1 F2 ^LPC_D2 FI ^LPC D3 El ^LPC_D4 E2 ^LPC D5 D1 ^LPC D6 D2 ^LPC_D7 Cl ^LPC_D8 B1 ^LPC_D9 A3 ^LPC_D10 A1 ^LPC_D11 C2 ^LPC_D12 G3 ^LPC_D13 D3 ^LPC_D14 E3 ^LPC D15 F3 / LPC DQMO HI / LPC_WE J2 J1 _ J 3_ K1_ K2_ E6_ E7_ LPC_MC1_CD B4 D4 EBI_D_0 MLCD_DB_0 EBI_D 1 MLCD_DB_1 EBI_D_2 MLCD„DB_2 EBI_D_3 MLCD_DB_3 EBI_D_4 MLCD_DB_4 EBI_D_5 MLCD_DB_5 EBI D 6 MLCD DB 6 IC6.E EBI_D_7 MLCD_DB_7 EBI_D_8 MLCD_DB_8 EBI_D_9 MLCD_DB_9 EBI_D 10 MLCD^DBJO EBI_D_11 MLCD_DB_11 EBLDJ2 MLCD_DB_12 EBI_D_13 MLCD_DBJ3 EBI_D 14 MLCD_DB_14 EBI_D 15 MLCD_DB_15 LPC313XFET180 EBI_DQM_0_NOE EBI A 0 ALE EBI_A_1_CLE EBLNWE EBI_ NCAS_BLOUT_0 NAND_NCS_0 EBI_ NRAS_BLOUT_1 NAND^NCSJ NAND_NCS_2 MLCD^RS NAND_NCS_3 MLCD_RW_WR MNAND_RYBNO MLCD_E_RD MNAND_RYBN1 MLCD_CSB MNAND_RYBN2 MNAND RYBN3 N8 LPC_CLK P9 N6 LPC A2 P6 N7 LPC A3 ^ LPC_A4 P7 LPC A5 \ K6 LPC A6 ^ \ P5 LPC_A7 N5 LPC A8 \ L5 K7 LPC A9 ^ LPC_A10 N4 LPC_A11 K5 LPC A12 \ \ P4 P3 LPC A13^ LPC_A14 N3 LPC A15 \ B3 LPC_A0 A2 LPC A1 \ A G1 LPC CAS H2 LPC_RAS \ P8 LPCJ3S N9 LPC_DQM1 LPC CKE ^ L8 K8 \ LPC AO H7 +3V3 © v LPC_A1 H8 LPC A2 J8 v LPC_A3 J7 >. LPC_A4 J3 LPC_A5 J2 v LPC_A6 H3 >. LPC_A7 H2 v LPC A8 HI >. LPC A9 G3 ^ LPC_A1 0 H9 ^ LPC_A11 G2 ^ LPC_A15 G1 v LPC_A14 G7 ^ LPC_A1 3 G8 LPC_DQM0 E8 v LPC_DQM1 FI LPC.CLK F2 \LPC_CKE F3 h- CO t -- CO < < CD O Q —} AO A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 All A12 BAO BA1 LDQM UDQM CLK CKE o o o o o o o o o o o o jjj UJ UJ LLj UJ UJ Q O Q O O O □ Q O Q Q O >>>>>> IC5 DRAM A43E26161 O 0 O 0 O 0 0 O 0 O g g g g LU LU UJ LU UJ LU LU CO CO CO CO CO CO CO CO CO CO CO CO CO CO > > > > > > > DQO DQ1 DQ2 DQ3 DQ4 DOS DQ6 DQ7 DQ8 DQ9 DQ10 DQ11 DQ12 DQ13 DQ14 DQ15 CAS RAS1 WE CS CO r-~ CO r-'- CO < < CO O O A8 LPC DO / B9 LPC A1 / B8 LPC D2 / C9 LPC D3 / C8 LPC_D4 / D9 LPC D5 / D8 LPC D6 / E9 LPC D7 / El LPC D8 / D2 LPC D9 / D1 LPC DIO / C2 LPC_D11 / Cl LPC D12 / B2 LPC_D13 y B1 LPC D14 / A2 LPC D15 / F7 LPC CAS / F8_LPC_RASy F9 LPC_WE / G9__LPC_CSy +5V (±> J3 R9 1 m U— K1 VCC O' D- O D+ O' GND O' USB RIO Tri7 J-X LPC VBUS / ^C18 ^C19~ lOn H3 L7 LI 2 C12 C6 ^C33 ^C3l" lOn ^C26 ^C5 C25 lOn A9 C9 E10 B2 E5 F5 G5 H5 L4 M5 M7 ^C22 JcV lOn R19 10R M9 C13 D5 D7 E8 i G12 i L10 A13 VDDI VSSI VDDI VSSI VDDI VSSI VDDI VSSI VDDI VSSI VSSI VPP A VPP_B IC6.C VDDA12 VSSA12 VDDA12 LPC313XFET180 VDDE_IOA VSSEJOA VDDE_IOA VSSEJOA VDDE_IOA VSSEJOA VDDE_IOA VSSEJOA VDDE_IOA VSSEJOA VSSEJOA VDDEJOB VDDEJOB VSSEJOB VDDEJOB VSSEJOB VDDEJOB VSSEJOB VSSEJOB VDDEJOC VDDEJOC VSSEJOC VDDEJOC VSSEJOC VDDEJOC VSSEJOC VDDEJOC VSSEJOC VDDEJOC VSSEJOC VSSEJOC VDDE^ESD VSSEJOC ADC10B VDDA33 ADC10B GNDA All C7 D12 G4 L6 L11 E9 C3 C4 E4 F4 H4 K3 M3 M4 M6 M8 B12 D6 D8 D9 G11 L9 LI 3 > ro ( 1 1 X X ra=7 ^ ZV BAT54 13 f 7 \ ® 1 » G6D-1A-ASI5VDC .04 LPC DM / \GPI018 LPC^DPy LJ S^USBJD CIO lOOn JP1 lol £ R18 120146 - 13 T BSS123 +5V GND X6 — 1 © 2 J DC 7 -12V Relay MC78M05ABDT +5Vext h-© C20 47u Figure 3. Circuit diagram of the Elektor Linux board. 34 06-2012 elektor EMBEDDED LINUX In the bottom left-hand corner of the circuit diagram is U1 , the SD card socket. Normally this will hold an SD card from which the Linux system firmware will be loaded. The LPC31 31 is in fact capable of booting from a range of storage devices and interfaces. The options available on the Elektor Linux board can be chosen from using header SV1 (see Figure 4). For example, it is possible to boot from the SD card or over the USB-to-serial bridge at X2 mentioned above. A further possibility is to boot over the second USB interface at XI (see below), for which a DFU (device firm- ware update) programmer is needed. LED1 lights when power is present on the board; also, for simple experiments or as a status indicator we have LED2. Button SI can be used as an input device: its state can be polled on GPIOI 5. We have also provided a relay to control external eguipment via XI . We will look in more detail at this possibility later in the series. The overall current consumption of the board is around 85 mA to 1 00 mA, which corresponds to a power consumption of around half a watt. Interfaces Things really start to get interesting when we use Linux to access directly the various microcontroller-style interfaces provided by the processor, including digital inputs and outputs, PWM, l 2 C and SPI. The relevant pins are brought out to 1 4-way header J5 and connector X4. GPIO The 3.3 V-compatible inputs and outputs GPIO1 1, GPIOI 4 and GPI015 are availa- ble on screw terminals at X4. GPIOI 4 and GPIO1 1 are simultaneously available on the 14-way header J5. A/D channels Three of the four channels are made availa- ble for simple analogue measurements. The 3.3 V supply is used as a reference voltage. GPAO, GPA1 and GPA3 are available on J5, with GPA1 also being available on a screw terminal. I 2 C The LPC3131 can act as an l 2 C bus master or bus slave. In our case the most likely option is master: this gives us an easy way to con- trol external devices, such as a PCA9555 I/O expander). The SDA and SCL signals are available on J5. SPI SPI peripherals can be controlled in exactly the same way as l 2 C devices. The MOSI, MISO and SCK signals are available on J5, while the chip select signal OUTO and (in the case where the LPC3131 is operating as an SPI slave) the CSJN signal are available on test points TP3 and TP4. PWM A PWM output is ideal for driving a servo or for generating an analogue voltage. The LPC3131 has a hardware PWM output, and the corresponding pin is brought out to J5. UART The UART protocol is a particularly conveni- ent way to implement simple communica- tions, especially between two microcon- trollers. Unfortunately the processor has only one UART, which in the normal con- figuration is used for the root console. If we subsequently add a network interface (see below) then it is possible to run the root console over this interface as well, freeing up the UART for other applications. The RX and TX signals are available at test points TP1 and TP2. USB The USB interface at K1 opens up a wide range of expansion possibilities for the Elektor Linux board. Not only do there already exist Linux drivers for a wide range of USB devices (including audio and video interfaces, 3G modems, wireless LAN, wired LAN and so on), but also many simple 8-bit microcontrollers can these days be con- trolled over USB. A semi-autonomous con- troller or coprocessor of this kind makes an ideal extension to the Linux system. Network It is also possible to implement a network connection, either to a wired LAN ora wire- less LAN, using USB connector l<1. This SD/MMC UART DFU c O 6 0 0 1 c O 6 0 □ I 6 /I ;v [1 CQ csi L=ki CQ cnJ □ —i 4 —> 4 —> 4 111 Figure 4. Bootloader jumper. interface can be operated in ‘host’ mode or in ‘device’ mode (USB OTG, or ‘on-the- go’). In host mode any USB stick LAN or WLAN adaptor can simply be plugged into the socket. In device mode the Linux board plays the role of a USB device, for example behaving as a virtual USB network interface. We will of course describe later how this all works. Das Boot Before we boot the board for the first time let us take a quick look at what happens during the boot process. In order to see what is happening on the board, we need to connect it to a computer over USB and use a serial terminal program. Under Win- dows suitable options are Tera Term and HyperTerminal; if a Linux PC is available, you can use picocom, microcom or a simi- lar program. Using a standard Ubuntu system, at the Linux PC console type sudo apt-get install picocom and then picocom -b 7 15200 /dev/ttyUSBO to connect to the Elektor Linux board. Under Windows things are (of course) dif- ferent. The VCP driver for the USB-to-serial converter has to be installed manually [7]. Using Tera Term [8] or HyperTerminal it is then possible to select the newly-created COM port. The settings are shown in the screenshot in Figure 5. Once the correct interface is selected the output from the bootloader and from the kernel should be visible in the terminal pro- gram on the PC. elektor 06-2012 35 EMBEDDED LINUX lV-t Ttm *' pjrt tt'vp Part emi -^1 | ff j 1 RaluI itfe. • « Dalt: a bH - Cancel '( PirJlyl none ■ Slop; \ tid Help flaw control: none * s Tr^ncmil delay n mittjltbr H ms critic AKM 3 m t L*f#-r If fla fitfritfa Hi f»l K« Sm#» rsn l#i rif fiw*i TPIPOm i- HH Sep H Ui»iH Wl Mil JM DTIli hei PAWW^ n ta Its nh^-T Mri fH j,*f rf l r«w i.i r#dntrih«frp : r .f*t iprfBiJt fL^raa-rf jh'#fl fv i»lir tft Mu- If If lb Ip# pngrai uirrr qmu :»* m lilUHAMBlftil Villi b^i h| VT>I ■ » IBM I ll»-H4fc L*J | Hw Itav ^owijd n'^i SbI* it pp| kta l vi d vblL | t cqpjjf mu?uuimm m m mmm Llfc/li* tries I rdrhEi rrnf # |naE AADi IBn mil |flL7HB| »« itMlI AIAL »IP; atin UMHH iltt ItJlHHMQ AlACa mzti m Iflnl ' eBrrurlB-li-fUi.ll^eM P!Kl-i ir«. l wrbl ii3pl rv rnbMI I ' llic_M tvl fi irinpl ftalrtMPtM. . Figure 5. Tera Term terminal program. Figure 7. The APEX bootloader. H |frr hr •‘ill-’ 4 1.1 ;Ua| 4 «i 11 ? hHflri tarrnrl *¥ !■' ■TWfniiiir^ i i a Llm rttfklM P 4 IT |Ue.H- wt jiu C«J 1 [ 41BMLh!> J .| lTi.91 >■* l! IM^TTO I I , on ■n't a. 1 . iMW. n.T iMirdcUM tdt>< »*».'■ NUlSli kmii it: ijmiitj « ■ **> •mLt | jw.iii.ii ii aid*r. ■fetUtp ■ ■*! n "M- TtfiL mn lx'p«k >:n^v-4 Ll"« f p i -i Lit- I U fill. ill. IFF- ■ rivl- Vdr-wUtLfc'ftaiL rr -k- 1 *|n tWI* Mtrapi » |nir -V LSI nr»| Dmfii ra-hr Mi IMr Fwlrkra 1EU4 iBrtr- F, IM lf!rl| (iBwir "ktiv ui rii'j gvrrum iui |irvr ■, -mm i§| Mu Pit ltd *.ti-i im pirrup iL'Ka l< i"Ml **r 1^1. OH^ Tr'llPlT II II I '■ ■> !«■ L uL lHt.ipi^t.lil r k LLtl ■ | )|i:i Ilniii'bM a PP:Mi«l PE 3*it. Ill: .hi ^B.r Si.m. 1 •• »l. «.■.. V.Mli lb. C ipn ' itr.iluO'1: %. urn. E L Li a. di-m.L«rp i,i:b tlM* ii: ..l:« Ik4 i» ■■ mb Iiu Jit I H.N H Hr in vp rr n n f un am •..j'.r.;- m '. ^rrr i I -.nt nw 11 n? nrun alura V ui: tb I l|a . . 1 rifct aid acS tf-c he ul rite . r d I iT-rtar ■ u.M ildti iM.Ird i IlIH 1 Mu () H.F:H f^C 1*1], □ Pi^lira priLCiii »( taL .n inlnrlaLH. ■' nd Ehll 1 l.i.i; ,b,U^.. 1 IEi Lit; I ■ & -'A -1 M 111 * ILI'Hn lilfllT Wf ■>«( > “I >.* Itl+T*! 1 ' ■ EEp.lJH. .Fiet^lh.llfl ill" iti|-n itdiF- llni ■ Figure 8. Messages from the Linux kernel during boot. Figure 9. The login prompt. If the boot process is already complete, sim- ply press the reset button (RST) to repeat the process. Figure 6 illustrates what hap- pens during booting. • A power-on reset interrupt is triggered. • The internal bootloader in the LPC31 31 looks for the bootloader firmware and copies it into internal RAM. Where the bootloader looks depends on the setting of the bootloader jumper: in our case we arrange for it to look on the SD card. • The firmware that has been loaded into the internal RAM is launched. • The firmware (the APEX bootloader) initialises the external SDRAM and copies the kernel from the SD card into the SDRAM (see Figure 7). • The firmware calls the kernel. • The kernel unpacks itself and then automatically starts up (Figure 8). • The kernel initialises the hardware (including the UART for the root console). • During the boot process the kernel mounts the root file system (which is stored on the SD card). • The kernel launches the first process, / sbin/init. • The kernel starts the root console on the UART interface. The system now waits at the login prompt (Figure 9) for input. You can log in as the ‘root’ user: simply type root and press the Enter key. You can now try some simple experiments using the commands that we have listed in Table 1 . For example, you can create a test file and edit it. It is equally easy to create a new directory. With a little practice using the file system will become second nature. As a very simple taste of what is possible, we will show how to switch the red LED on the board on and off. To do this we exploit a fundamental principle of Unix operating systems: everything is a file! Every device is represented in the file system as a file, which can be read from and written to. This even applies to our LED! First enter the following commands. cd /sys/class/gpio 36 06-2012 elektor EMBEDDED LINUX Source code terminolo Patch A ‘patch’ is a file that can be used to make changes to original source code with the help of a suitable utility program. If, for example, you make an extension to a program, you can use a utility to determine the differences between your new version and the original and generate a patch file to represent them. Members of a development team can also use patches to help ensure that they are all working with the same version of the source code. Patch files form the backbone of open source development, where all large-scale projects are worked on simultaneously by many developers. Mainline The development of large-scale open source projects is organised in various ways. In general there is a single maintainer who looks after the source code, applies patches from other developers, and regularly releases new versions of the software to users. In the case of the Linux kernel there is the so-called ‘mainline’, which is maintained by Linus Torvalds and his team. Since there is an enormous number of patches being offered to extend the kernel it often takes some time before a new feature will appear in the mainline. Before this point it is possible to obtain patch files directly from their developers (for example via their home pages) and apply the patches to the kernel yourself. The aim, however, is to get everything into the mainline. Maintainer The maintainer is usually a single person (often the founder of the project). He or she looks after the master version of the source code, applies patches, and regularly releases new versions of the source code. In the case of Linux the various subsystems such as network, drivers, file system and so on each have their own maintainer, who is responsible for the source code and who helps ensure its stability and availability. echo 3 > export cd gpio3 echo out > direction These configure the relevant port pin as an output. Then enter echo 1 > value easy as we can for readers by providing a ready-made image for download, which can be used in a virtual machine. (120146) Internet Links [1] sauter@embedded-projects.net [ 2 ] http://gcc.gnu.org [3] www.uclinux.org [4] http://ics.nxp.com/products/lpc3000/ datasheet/lpc31 30.lpc31 31 .pdf [5] http://www.jedec.org [ 6 ] www.amictechnology.com/pdf/ A43E26161.pdf [7] www.silabs.com/products/mcu/Pages/ USBtoUARTBridgeVCPDrivers.aspx [8] http://ttssh2.sourceforge.jp to switch the LED on, and echo 0 > value to switch it off again. See how simple Linux can be? Before we finish, we should explain how to power the board down safely (like a PC). As Table 1 shows, the relevant command is called halt. As soon as the system replies with the message ‘System halted.’ power can be removed. What the future holds In the next article in this series we will download some source code for the first time and write a small program. A some- what longer part of the course will cover the installation of a development environment. Here too, however, we will make things as Table 1 : Important Linux commands Command Description ps ax Display all processes free Show memory use date Show current time and date touch test.xt Create empty file called ‘test.txt’ rm test.txt Delete file ‘test.txt’ nano test.txt Open file ‘test.txt’ in an editor (use control-0 to write the file, control-X to leave the editor) df Show partitions mkdirtest Create a directory called ‘test’ cd test Descend into the directory called ‘test’ cd .. Move one level up in the directory structure rmdirtest Delete the directory ‘test’ cat /proc/cpuinfo Display the contents of the file ‘/proc/cpuinfo’ halt Bring Linux system to an orderly halt elektor 06-2012 37 Computer-driven Heliostat the stars Follow the sun or A heliostat is a device that tracks moving objects in the sky. This way you are able to extract the maximum amount of sunlight, take a series of photos of a moving planet or track a satellite for the best radio or TV reception with a dish. In this article we describe a simple heliostat that uses two servo motors. The servos are controlled via a PC program. By Zeno Otten (The Netherlands) This project shows an example for a helio- stat, built using two servo motors. The posi- tion of the sun with respect to time and the location on Earth is calculated using a mathematical model. The result is used to drive the servos and make them point in the direction of the sun. The prototype described here can be easily expanded to a larger and more robust sys- tem so it would be able to position an actual solar panel for it to receive the maximum possible amount of light and hence absorb as much energy as possible. Positioning with motors When an object needs to be positioned using a computer or microcontroller it is often the case that stepper motors or servo motors are used. A stepper motor can be set to its required position using a relatively simple pulsed control signal. On top of that, they tend to have a high torque. The stepper motor can therefore hold its position fairly easily when it is at rest. The disadvantage is that with a directly driven drive-shaft the minimum rotation is usually 1 .8 degrees or more, due to the motor’s stepping angle. Another disadvantage is that there is no feedback between the position of the drive-shaft and the number of pulses sent to the motor. A servo motor has less torque, but has the advantage that the drive-shaft can be set steplessly to almost any position because of the use of a proportional control circuit and a potentiometer built into the motor. This circuit also makes it possible for the servo to correct any change in position caused by external forces. A servo is also controlled using a pulsed sig- nal, where the pulsewidth determines the angle of rotation of the servo arm. The choice for the type of motor for our project isn’t very important. Since Elektor has had several articles on stepper motor control circuits, we thought it was time for a change and decided on a servo con- troller. Besides, this project also serves as an introduction to the graphical program- ming environment of Profilab. This can be used with little effort to control things like the serial port, which we’ll use here to drive the servos. Servo control We’ve used two modeller’s servos in the heliostat [1], one for the control of the azi- muth and one for the elevation. The azi- muth is the angle in degrees in the horizon- tal plane; the elevation is the position in the vertical plane. To make a servo turn you need a control signal which has a pulsewidth that varies between 1 ms and 2 ms, with a frequency of about 50 Hz. The pulsewidth determines the position of the drive shaft. A pulsewidth of 1 .5 ms, for example, will cause the servo to move to a central position. A pulse of 1 .25 ms will make the servo turn 90 degrees anti-clockwise, whereas a pulse of 1 .75 ms will turn the drive shaft 90 degrees clock- wise. All values in between will cause the drive shaft to turn by a proportional angle. However, these values could deviate by a few percent, depending on the type of servo. The control signal for the servo should be +5 V, whereas the supply voltage to the motor may vary between 4.8 V and 6 V. In Figure 1 you can see the schematic for the ‘circuit’ to drive two servos via the serial port. Two PC81 7 optocouplers optically iso- 38 06-2012 elektor HELIOSTAT late the DTR and RTS signals of the serial port from the supply voltage and control signals for the servos. The circuit converts the signal level of the serial port (±1 2 V) into the 0/5 V required by the servo. With a com- puter program that generates the pulses it becomes a simple matter to control the two servos. The advantage of this simple interface is that we can also control the servos via a USB port when we add a USB/serial converter. The next step is to generate the pulses with a pulsewidth between 1 ms and 2 ms and frequency of about 50 Hz. Graphical programming with Profilab Programming can be fun, but for many computer enthusiasts it is often too high a barrier to overcome and successfully com- plete an electronics project. In this project use is made of the graphi- cal programming environment called Pro- filab [2]. Programming in Profilab could hardly be any simpler. By connecting pre- programmed functional blocks together, the programmer can create a complete program without writing a single line of code. The way it works reminded us a bit of LabVIEW. For communications with the outside world it’s possible to directly drive the serial and parallel ports from within Pro- filab. Profilab also supports many hardware interfaces made by various manufacturers. In the programming environment offered by Profilab it is possible to compile the pro- ject into a standalone program. This pro- gram can then run on any (Windows) com- puter without the need of the programming or development environment. As an example, Figure 2 shows a simple Pro- filab program. The value of the slider con- trol (SRI ) varies between 1 0 and 20. These values have been set in the parameter sec- tion of SRI . The slider control is shown on the front panel of the program. Block ADD1 adds this to the value of block FV2, although here it is set to zero. Block GAIN 1 multiplies output A by 0.0001 , which results in a signal with a value between 0.001 and 0.002. This signal is presented to function block PG1 , which is a pulse generator where the high- time and low-time (TH and TL) can be set independently. DTR GND ©©0 RTS GND ©©© Servo 1 Servo 2 100204 - 11 Figure 1 . The electronics for driving the two servos is very simple. Figure 2. A straightforward example of a Profilab program. The TH signal is also fed to block SUB1. The value of 0.02 from block FV1 is then reduced by this amount. This difference is then fed to the TL input of block PG1 . The unit of simulation time in Profilab is one second. While the program runs there will therefore be a pulsed signal on the DTR pin of the serial port with a pulsewidth between 1 ms and 2 ms (depending on the setting of SRI ) and a frequency of about 50 Hz. This is exactly what’s required to drive a servo. The possibilities offered in the program- ming environment of Profilab are very extensive. However, things get much more interesting when we add a custom-written functional block. Profilab supports this and lets you import a dynamic link library (DLL). We use this facility in Profilab to include the calculations needed to make the heliostat track the path of the sun. The heliostat model There are many mathematical models avail- able that return the position of the sun with respect to any position on Earth at anytime. The mathematical model used here [3] is very accurate and it can calculate the sun’s position in the horizontal plane (azimuth) and the height of the sun (elevation), given in degrees. There is not much point in this elektor 06-2012 39 HELIOSTAT Figure 3. A specially written DLL takes care Figure 4. The complete program for calculating the position of the sun of the calculations for the position of the and driving the servos. sun. SI H Figure 6. With the help of an extra PIC you can add manual control. 40 06-2012 elektor HELIOSTAT Figure 7. A practical implementation of the heliostat. One servo is mounted on a case, the second is on a CD. The ‘arm’ on the servo points in the direction of the sun. Figure 5. A view of the front panel. You can choose between real-time calculations or manual control. application to position the heliostat with an accuracy of tenths of a degree, but since we’re using a computer with ample process- ing power it won’t do any harm either if we do the calculations very accurately. There is an example in the help-files of Profilab that explains clearly how you can include your own programming in a DLL file. All you have to do is to define all inputs and outputs of the block and then write the pro- gram code that defines the relation between the inputs and outputs. Both Pascal and C++ are supported. The model used here was written and compiled in Borland C++. In Figure 3 the file heliol .dll is used in Pro- filab to calculate the position of the sun. This block has eight inputs and two out- puts, QO (the azimuth of the sun) and Q1 (the elevation of the sun). Four inputs of heliol .dll get their informa- tion from the standard functions for the date and time in Profilab. Block DTI sup- plies the year (Ye) and the day (Dy). Block TM1 supplies the time of day as the hours (Hr) and minutes (Mn). The other informa- tion required is the location on Earth. This is input with the help of PT1 and PT2. PT1 supplies a value between 0 and 90 degrees north. PT2 supplies a value between -1 80 and +1 80 degrees east. G1 is a pulse generator that makes sure that a new calculation will be carried out every second by heliol .dll. The complete Profilab program is shown in Figure 4. Several other functions have been added so that the program can carry out simulations with regard to the position on Earth and the time. REL3 and REL4 are used to switch between manual operation of the servos (with the help of slider con- trols SR4 and SR5) and automatically via the mathematical model. Furthermore, an interface has been added to drive the two servos via the serial port. After pressing push button PB1 the calcu- lated pulses are sent to the serial port for the next two seconds. If you want to drive the servos continuously then this push but- ton should be replaced with a continuous signal. Every program in Profilab has an accompa- nying front panel. This acts as the control interface for our program. The control panel belonging to Figure 4 is shown in Figure 5. Two analogue meters are used to show the azimuth and elevation of the sun. Imme- diately below these the position is shown numerically in degrees. When the servo control is set to ‘Manual’ the servos can be controlled using slider controls. When it is set to ‘Real Time’ the true solar position is shown. The indication is with respect to the north. When the switch ‘Show position’ is pressed the pulses will be sent to the servos for two seconds and the heliostat will move to the calculated direction. Advertisement m ( «:f pcbs *7$* Muuuuch Cheape ,v--f * No-frills policy 17.22 EURO 5 pcbs, 1 00 mm x 1 00 mm *per piece, incl. UHT (23%) + shipping costs e. g. Germany 1 0.89 EURO * JadCaltac imuuj.jackaltac.com elektor 06-2012 4i HELIOSTAT +5V Figure 8. If you want to be less dependent on the timings under Windows you could drive the servos with analogue signals via this circuit. Expansion i: Manual control Up to now we needed a computer to carry out the calculations and to drive the ser- vos via the serial port. In order to drive the servos in situations where a computer isn’t available the circuit from Figure 1 has been extended with a small microcontroller, a PIC 1 6F628A (Figure 6). This inexpensive con- troller is provided with a simple program that can generate pulses for the servos. The program was written using the (free) Proton BASIC Compiler and was then programmed into the PIC using a PIC programmer from Velleman (K8048). Of course, you can also use any other suitable programmer. The BASIC program for the PIC 16F628A can be found in the software suite that can be downloaded from [5]. When S5 is switched to ‘manual’ the supply for the computer interface is turned off and the PIC is connected to the supply. LED1 will then flash a few times to indicate that the controller is now active. Switches SI to S4 can now be used to generate the pulses that make the servos turn to their required posi- tion. Extra 10 Q resistors have been put in series with the supply to the servos so that they operate from a slightly lower voltage than the PIC. Figure 7 shows the prototype of the heli- ostat. On the first servo a disc (an old CD) was mounted, on which a compass rose was glued. The second servo was then glued on top of this disc. An ‘arm’ was then mounted to the drive-shaft. It’s this arm that points in the direction of the sun. In the photo you can also see push buttons SI to S4 and switch S5 (computer/manual control). Expansion 2: Analogue control Accurately generating pulses with a pulsewidth between 1 ms and 2 ms is quite tricky to achieve in a multitasking environ- ment such as Windows. The result of this is that the heliostat sometimes jitters a bit when the operating system is particu- larly busy. To get round this, we have also designed a servo controller that can be driven by an analogue voltage. Since the PC itself cannot generate ana- logue voltages directly, we’ve resorted to a USB interface card (K8061) from Vel- leman [4]. This is able to output analogue voltages between 0 and 5 V and is fully supported in Profilab. We also made our life easier by using a standard ‘pan & tilt’ kit made by Lynxmotion. This kit is supplied inclusive of two Hitec servos [6]. To drive these two servos with analogue signals we’ve made use of a PIC1 2F674. This small controller is able to read in two analogue voltages at a resolution of 1 0 bits. In the cir- cuit diagram in Figure 8 you’ll see that the analogue voltages are connected to pins 6 and 7. SI and S2 are used to switch between the voltages set by P3 and P4, or the volt- ages coming from the external interface. The servos are driven by pins 3 and 5. The two LEDs make the output signals visible. The program for reading the analogue inputs and driving the servos is also written in Proton IDE BASIC and is also included in the download suite from [5]. In order for the heliostat program to use the circuit in Figure 8 several changes had to be made to the program in Figure 4. The posi- tion of the sun is now converted to a value that’s translated to an analogue voltage between 0 and 5 V by the K8061 . And finally, there’s one thing we’d like to mention about the servos used. They can turn through an angle of only 180 degrees. This is not a problem for the elevation where the servo has to turn through a maximum of 90 degrees. (In the UK the maximum ele- vation of the sun varies from 63 degrees in the south to 53 degrees in the north.). The positioning of the azimuth is limited to the position of the sun between due east and due west. This means that the sunrise (NE) and the sunset (NW) on the longest day of the year can’t be tracked. The mathematical model for the heliostat can also be used for several other applica- tions, such as the automatic opening/clos- ing of curtains or blinds, or the turning on and off of lights. ( 100204 ) Internet Links & Literature [1] www. h itecrcd .co m [ 2 ] www.abacom-online.de/uk/html/profil- ab-expert.html [3] R. Walraven: Calculating the position of the sun. Solar Energy Vol. 20, 1 978 [4] www. velleman. eu/products/view/?count ry=gb&lang=en&id=36491 0 [5] www.elektor.com/ 1 00204 [ 6 ] www.lynxmotion. com/Product. aspx?pro ductlD=287&CategorylD=61 Available from Antratek: http://www.an- tratek.com/Servo-assemblies.html or http://robosavvy.com/store/product_ info.php/products_id/1 1 82 42 06-2012 elektor EAGLE Do you have a great idea for a board? You have a great idea for a board and want to win a DELL Alienware M17xr3 computer, an EAGLE Pro license or a MICROCHIP - DV1 64037 & DM1 63022-1? Participate in the EAGLE design competition, powered by Microchip and hosted by element! 4! To get a chance to win include an MCU or DSC in your design made with EAGLE version 6 describe your project on one page, make a screenshot of your layout and post it on www.element14.com/eagle-competition Visit www.elementl 4.com/eagle-competition for terms and conditions In Association with A Farnell element iu Microchip www.farnell.com www.element14.com/eagle www.microchip.com www.cadsoft.de E-LABs INSIDE By Thijs Beckers (Elektor Editorial & Labs) Elektor Lab workers are finishing up the last loose ends of their lab duties related to Elektor’s upcoming enhanced double sum- mer edition — the Project Generator Edition, PGE. Extra attention is paid to the quality of this year’s projects, after upping the stand- ards already in the selection process. We set an ambitious goal for all of us, lab workers and editors alike, to bring you articles and circuit ideas from the utmost quality, with crystal clear details and lots of PCB layouts. All of this would of course be unfeasible without our highly respected free- lance contributors and experts, who we are grateful for their efforts in supporting this year’s extra-thick magazine with fresh and exciting projects and circuits. As you are reading this, editors at Elektor are finalising their texts and articles and probably look forward to a hopefully nice summer recess, after a very busy period. We hope you enjoy our upcoming PGE! (120395) Stabistor: zener in reverse By Thijs Beckers (Elektor Editorial & Labs) Every electronics enthusiast should know how a zener diode works and in what situations it comes in handy. But my bet is that ‘stabistor’ sounds a bit more exotic to most of you. So what does it do? First, let me elaborate on how my attention was drawn to this component. Working on a circuit to drive an electric motor, former lab worker Chris Vossen decided to use a 2 V zener diode, which happened to be handy in our component drawer. Its label said ‘BZV46-2V0’. When checking his circuit, Chris had to conclude that it didn’t function properly. It was not long before he found the problem... Take a close look at the curves below reproduced from the datasheet. Do you notice any differences between them (except for the scaling and the number of curves)? If you don’t see it, have a closer look at the x-axis designation in both diagrams. In the diagram of the zener diode ‘V r ’ (reverse voltage) is given as the description (left diagram), while in the stabistor diagram ‘V F ’ (forward voltage) is written as the x-axis designation. So... a zener diode and a stabistor are essentially the same, except for their orientation! Since on the BZV46 the cathode is marked (just like a zener diode), it is rather tricky to get the orientation right once you find it in the ‘zener’ drawer and don’t have a datasheet available. Once it transpired that the BZV46-2V0 is actually a stabistor and has to be soldered exactly the other way around as you would solder a zener diode, the whole circuit came to life and worked a treat. So as a reminder to all who happen to use ‘lost & found’ zener diodes for low voltages from time to time: mind the polarity! (120313) 44 06-2012 elektor Echoes from BOB By Antoine “Grand Chef” Authier (Elektor Labs) Besides our normal design work, our daily lab duties include helping out with technical questions (TQs). Some queries are a piece of cake to answer, others require a little more attention and time, and a few may be stamped “nice to know for every- one involved”. The following question from M. Da Silva should fit the last category: I bought four of your BOB USB converters ([1 ], published Septem- ber 2011; Ed.) and with each one I experience the same communi- cation problems. When I send a message from my PC to the BOB , the LED blinks and I receive a correct message at the serial output of the board. When trying to send a signal in reverse — i.e. send a message to the PC via the BOB’s input pin — neither the LED is blink- ing nor the message gets through to my PC. Can you please point me to the solution to my problems ? It’s highly unlikely that all four PCBs are faulty. In order to check the BOB’s functionality, the following actions are recommended: First, check that only one of the two GPIO supply voltages (3.3 V or 5 V) is connected. Also, do not solder all the SMD jumper pads together. Instead, connect only one of the outer pads (associated with the required voltage) to the one in the middle by dropping a little blob of solder on them. See the first two photographs. Then perform an echo test. No canyon required. Just connect the TX and RX pins together. This is conveniently done using an ordinary jumper, as shown in the third photograph. Now con- nect the BOB to your computer. In your terminal emulation soft- ware, disable the Local Echo option and send a message to the BOB. Your message should be returned instantly and appear in the terminal window. Now remove the short (jumper) between TX and RX. Sending something to the BOB should now leave the receiving window empty. For terminal emulation you can use software like Tern Term Pro, which is available free from [2] and very easy to use. It also fea- tures a lot of useful functions (which allows you to make things complicated). On a contemporary computer (with no serial ports built in anymore) and with your BOB recognised correctly (always plug it in before starting the software), you will find the serial converter assigned as the default port in the New Con- nection window. The local echo is configurable via the Setup -> Terminal menu item by ticking or unticking a simple check box. If this little test produces positive results, it’s likely you have to look for errors elsewhere. If it doesn’t, check your settings and soldering again to make sure they are all correct before contact- ing Elektor Customer Services. (120230) Internet Links [1 ] www.elektor.com/ 1 1 0553 [2] http://en.sourceforge.jp/projects/ttssh2 elektor 06-2012 45 TEST & MEASUREMENT ual Hot-wire Anemometer calibrated using a Pitot tube anemometer The slightest air leak in the shell of a building and poor adjustment of its ventilation will ruin the costly efforts made to insulate it. If your home is fitted with a dual- flow ventilation system with heat exchanger, but the sight of your heating bill sets you shivering; if you’re suffering from noise pollution; if you’re worried about the balance between fresh air input and extraction of humidity and pollutants — then try tracking down the north wind and other unwelcome air currents. By Marc Gerin (France) To measure how well a building is sealed, we go about it a bit like a inner tube: we pressurize the building so as to then meas- ure the escaping air flow. This infiltrometry involves fitting an adjustable fan hermeti- cally into one of the building’s openings - for example, the entrance door - with all the other openings kept shut. And then we blow. The pressure difference between inside and outside the building allows an engineer equipped with a hot-wire ane- mometer (or a smoke generator) to hunt down the slightest leaks. I’m offering you my toolbox for experiment- ing yourself in order to improve the sealing of your building and adjust its ventilation: • a dual hot-wire anemometer for meas- uring small air leaks and balancing the dual-flow ventilation, • a Pitot tube for measuring higher air speeds and calibrating the dual hot- wire anemometer. This system can also measure pressure differences up to 2 kPa. Let’s start at the end: the Pitot tube, the detector, and the display. Pitot tube anemometer The pressure created by a fluid moving around a solid is a function of its speed. The Pitot tube (see inset) exploits this principle for measuring the dynamic pressure of a fluid. Since June 2009, when the Air France Rio to Paris flight crashed over the Atlantic, everyone is now aware that Pitot tubes are used on aircraft. Now our Pitot tube anemometer here isn’t of course designed for aeronautical use, but it is nonetheless suitable for air speeds up to 200 km/h (125 mph), i.e. a pressure differ- ence of 1 ,882 Pa at the tube outlet (see the Excel spreadsheet available from [3]). Without making a habit of it, we’re going to start by doing some soldering even before we take a closer look at the electronics I’m suggesting. To make our Pitot tube (Fig- ure 1 ), drill four holes about 0.8 mm diam- eter peripherally around the middle of an 8 cm length of 5 mm diameter brass tube, as used in modelling. Flatten one of the ends a bit, just enough to be able to insert two 2.5 mm diameter brass tubes. To avoid its getting blocked when you solder it, have the longer tube that passes all the way through the main tube protrude by at least 1 cm at the far end. For the soldering, using a plumber’s blowlamp and flux paste, make sure you keep the pre-assembled Pitot tube vertical. Solder just the bottom end, to avoid the solder running down into the tube by gravity. Now turn the whole thing upside down to solder the other end. It is vital that these two ends are soldered in such a way as to completely close the gaps between the small tubes and the main tube, otherwise the static pressure measurement will be affected by the dynamic pressure. To finish off, cut off the excess inner tube at the front end of the probe - and there you have your Pitot tube. Pressure and accuracy For low pressures, the data sheet for the pressure detector chosen, the MP3V5004G from Freescale, gives an accuracy of 1 .5 % of the output voltage at 2 / 3 FSD, i.e. 27 mV for around 30 km/h. This accuracy depends on the temperature, the linearity of the detector, hysteresis phenomena, and mechanical stresses. Unfortunately, the most interesting parameter, the ran- dom output deviation at low pressures, is 46 06-2012 elektor TEST & MEASUREMENT for tracking down draughts, adjusting a dual-flow ventilation system, or just for experimenting not specified. So the data sheet does not enable us to deduce the behaviour at low pressures (i.e. at low speed). Fortunately, in practice we’ve found that if all mechan- ical stresses are eliminated and we allow the detector to stabilize, the random out- put deviation is only of the order of a mil- livolt or so. This is reasonable enough for measuring speeds above 1 5 km/h. Standard precaution: it is vital to power the pressure detector from a separate 3.3 V rail, as any noise on its supply shows up on the output signal. This 3.3 V rail will also be the reference voltage for the separate ADC used to convert the detector output to a digital value. In this way, the analogue measuring circuit is totally separate from the rest of the circuit. For precision of the order of a millivolt, we need at least a 1 2-bit ADC. I chose the ADS1 1 00, a 1 6-bit ADC with l 2 C interface that provides eight samples per second. To improve stability, we’ll be using the aver- age of five samples per measurement, i.e. one measurement roughly every 3 A sec- ond. If necessary, to improve speed, the conversion could be limited to 14 bits. The ADC’s l 2 C address is hard-coded on the chip. I chose the label ADO with the address bOI 001000. Other addresses are possible by modifying the adc.h file and recompiling. To make it easier to re-use it in other appli- cations (modelling, level measurement, and so on), the detector is a self-contained module (Figures 2a & 2b). A solder bridge between pads 2 and 3 on SJ1 connects the l 2 C bus pull-up resistors to the 5 V rail. To use 3.3 V, you need to make the bridge between pads 1 and 2 instead. Don’t forget the via underneath the pressure detector; use fine wire, very discreetly, and flatten out the solder while it is still hot. dsPIC for the display For displaying the speed, I’ve recycled a good old general-purpose board (Figure 3) fitted with a dsPIC30F401 1 , developed for another project. It has the advantage of having a serial port, a liquid crystal display, connectivity, and can be powered via an Figure 1 . Used in conjunction with the pressure detector and the converter in Figure 2, this home-made Pitot tube will allow the dual hot-wire anemometer (Figure 6) to be calibrated. Figure 2a. Along with the Pitot tube, this pressure detector, the pressure/voltage converter, and the display (Figures 3 & 4) form an easily-calibrated anemometer. • • EJR12 EJR13 II C40 IV cr VO cr sms . U$2 of Figure 2b. I’ve designed this double-sided PCB for the Pitot tube anemometer. elektor 06-2012 47 TEST & MEASUREMENT Figure 3. Circuit diagram of the dsPIC display board for the Pitot tube anemometer. FTDI TTL-232R-5V USB cable [1 ] or by an external 9-1 2 V PSU. For this article, I built a second prototype (Figure 4). The dsPIC program is in two parts. First of all, it handles the calibration and storage in EEPROM of the reference parameters (value from the detector at atmospheric pressure and with the pressure from a 200 mm column of water). Then, in nor- mal operation, the program’s primary loop interrogates the pressure detector, then calculates and displays the speed. It also adjusts the reference atmospheric pressure value when the button is pressed. For greater portability, the program is writ- ten using the C compiler from Microchip and the code for each peripheral is imple- mented in a separate file. Display for the Pitot tube anemometer On the double-sided PCB, the display and push-button are on the solder side. If you don’t have a through-hole plated PCB, the dsPIC and the LCD will have to be mounted using individual pin sockets that can be sol- dered on both sides of the board. If you’re unsure about doing this, here’s a little tip for soldering underneath this type of pin socket. Coat the PCB pads using a flux pen [2] and insert the contact, leaving it stand- ing 0.25 mm above the surface of the PCB. Then apply the soldering iron tip to the socket, and apply the solder on the other side of the board in the 0.25 mm gap between the socket and the copper pad: the solder will be drawn in by capillary action (a photo of this operation is available [3]). In order to insert the LCD into the sockets we’ve just soldered, it’s best to first mount it in a male-male socket. Implementation and configuration The MP3V5004G detector is quite noisy, as it is very sensitive to handling. The sim- ple fact of connecting a pipe to it and in so doing applying mechanical strain on the package will change the value measured. I recommend using silicone tubing, as used 48 06-2012 elektor TEST & MEASUREMENT Figure 4. The second prototype for my Pitot tube anemometer. for model aircraft hoses, carefully fixing the tubes solidly so that there are no changes in the mechanical stresses throughout the life of the project. Leave the circuit running for around 1 0 min- utes for the MP3V5004DP to stabilize. Then you can start the calibration (at the tempera- ture you will later be using the Pitot tube at). For the calibration, turn the power off and on again, keeping the button pressed until the message ‘config mode’ is displayed. The system leaves the detector around 20 s to stabilize, then reads the atmospheric pres- sure value that is going to be used as a ref- erence. Then the message ‘Put Column 200mm’ will prompt you to connect up a 200 mm column of water (Figure 5). The next step is to arrange the pipe with respect to the bottle in such a way that the air/water boundary in the pipe is exactly 200 mm below the level of the water in the bottle. Once the column of water has sta- bilised, the message ‘Push SW when Rdy’ will prompt you to press the button again to confirm the configuration and store the parameters in the EEPROM. In operation, the button can be used to recalibrate the pressure detector zero. These parameters are sent via the serial port (38400 baud) when the circuit is powered up or following calibration. In operation, the measurements are sent. By now, you have your Pitot tube for meas- uring the air speed. Now let’s move on to the dual anemometer proper. Dual hot-wire anemometer In a sealed building fitted with dual-flow ventilation, a proper balance between the incoming and outgoing air flows is essential, indeed obligatory. This can only improve the heat-exchanger efficiency, as well as avoiding problems of over- or under-pres- sure in the building. Sadly, in most cases, people make do with a single balancing when the installation is first commissioned, and without any meas- urement, if you please — just by adding together the theoretical flow-rates for the various inlets and outlets. Now over time, any ventilation system goes out of balance, as the supply and extract filters get blocked to a different extent. This is especially true where the external air inlet filter is a pol- len filter and the extract filter is an ordinary one. As the diameter of the ducts is the same for both supply and extract, all we have to do to find out the flow-rate is to measure the average speeds. It is then possible to bal- ance the flow-rates simply by adjusting the motor speeds in the ventilation system’s configuration menu. The dual anemometer suggested here (Fig- ure 6), based on the ‘hot wire’ principle, will let you perform this adjustment successfully or track down air leaks. The two anemom- Figure 5. Calibrating the pressure detector. Figure 6. My prototype for the dual hot-wire anemometer for dual-flow ventilation, with its two probes and the corresponding displays. elektor 06-2012 49 TEST & MEASUREMENT Figure 7. Circuit diagram of the dual hot-wire anemometer. eter probes are inserted into the supply and extract ducts via small holes. My choice of a 1 00 % analogue circuit is justified more by nostalgia and the intellectual pleasure of it than by cost or performance factors. A microcontroller would do the job just as well — possibly better... Thermistor probes Our ‘hot wire’ is in fact a 68 Q negative tem- perature coefficient (NTC) thermistor wired in a resistive Wheatstone bridge and self- heated by the current passing through it. Temperature compensation is achieved in the second branch by another thermistor, this time with quite a high value (6,800 Q) so it will not be heated up by the current through it. The Wheatstone bridge output voltage will reflect the speed of the air cool- ing the 68 Q thermistor. The thermistor’s operating point @ 50 °C and the thermal compensation of the whole system has been calculated using a little program [3] written using Mathcad. In addi- tion to selecting the values for the bridge bias resistors so as to ensure the 50 °C for the ‘hot wire’, we also need to select values for R2, R24 and R1 0, R23 to ensure the best possible temperature stability. I did this by successive approximation in Mathcad. Op amp IC3A performs air-flow measure- ment and temperature compensation for the first anemometer. Its inputs are con- nected to the Wheatstone bridge formed by R2, R3, and the 6,800 £1 and 68 Q ther- mistors (Figure 7). The values of R2 and R3 are chosen such that the bridge is balanced with just the 68 Q thermistor at 50 °C. If the 68 Q thermistor is cooled down by a draught, the Wheatstone bridge becomes unbalanced and the op amp reacts by vary- ing the supply to the resistive bridge via T1 . The current in the bridge increases and the 68 Q thermistor returns to its temperature of 50 °C. Hence the bridge supply voltage reflects the speed of this draught. Clearly the same goes for the second anemome- ter, which uses IC1 A. Resistors R1 7 and R1 8 are used to maintain sufficient current in the 68 Q thermistor, while reducing the heating in T1 and T3. The 68 Q and 6,800 Q thermistors can be seen in the photo of the anemometer probe 50 06-2012 elektor TEST & MEASUREMENT Figure 8. Use a piece of plastic tubing to insert the thermistors, the wires, and the balsa disc into the tube. at the top of this article. They are connected up using fine insulated wire, long enough to minimize any thermal coupling. For the probes, I chose to use professional micro- phone cable that matches the diameter of the brass tube. The thermistors are fitted into little pieces of 8 mm diameter brass tube, with two holes for the air to circulate. They are each held firmly in place by a little disc of balsa, as thin as possible to reduce thermal conduction. You can use a piece of plastic tubing as a guide to help you insert the thermistors with their discs (Figure 8). sate for the voltage offset introduced by the preceding stage (IC1 A and IC3A) and to feed the potentiometers (PI and P5) that define the overall gain of the circuit. one in your bathroom! Zero adjustment is by way of potentiometers P2 and P6, depending on the input. Put the thermistor anemometer probes in a closed box to pro- Tracking down those draughts! I fixed the whole lot together by injecting hot-melt glue via a hole near the small piece of breadboard. Here, the primary cause of errors is undoubt- edly the thermal conduction of the wires connected to the thermistors. Fine adjust- ment was done by successive approximation on the prototype by modifying R2 and R1 0. The honour of the electronics engineer, sol- dering iron in hand, is intact. Two displays To display the air speed, I decided to use Velleman LCD voltmeter/display mod- ules, which are ready-to-use, elegant, and cheap. However, the downside is that they are tricky to incorporate into a circuit where we need to measure a voltage with respect to the 0 V rail. Their differential input IN- has to be maintained at least 1 V above the display’s V- rail. T2 and T4 are wired as a current source to provide a floating supply for the voltmeter, allowing their IN- to be connected to the 0 V rail (GND). As these voltmeters are fitted with a configurable input voltage divider, R A will be 1 00 k Q and R b , 1 0 MCL A potentiometer is used for fine adjustment of this divider. The DC/DC converter IC2 provides the nega- tive voltage required to produce the supply for the voltmeters, as well as the negative voltage for the op amps. IC1 B and IC3B make it possible to compen- Calibration and conclusion We now have our double anemometer and our Pitot tube; all we need to calibrate all this is a hair-dryer. We’re not going to build this ourselves - you should be able to find tect them from any possibility of draughts. Next, to calibrate the speed, place the Pitot tubes and the anemometer probe at the same height, so they all receive the same air-flow (Figure 1 0). Turn the hair-dryer on elektor 06-2012 5 i TEST & MEASUREMENT Anemometer About the author Already as a baby, awoken in the mid- dle of the night by the rumbling of my father’s windmills, I had realized that the north wind and I would never be friends. As an adolescent, my teachers criticized me for preferring a soldering iron to a biro. Only my science teacher thought I set a good example. I studied as an elec- tronics engineer, then in management, and latterly as an energy consultant. Married, 48, the father of two magnifi- cent adolescents, and working for Belga- com, I am now getting my own back and recruiting allies among Elektor readers so as to conquer this north wind! Figure 1 0. For the calibration, make sure you place the Pitot tube inlet at exactly the same height as the thermistors, so that the air-flow is the same for both anemometers. (‘cold’ position). Set PI and P5 so that the twin displays indicate the same speed as the Pitot tube. Tweak the voltmeter gain poten- tiometers if necessary. So here you are now, armed with the means to track down that chilly north wind and easily balance up your ventilation system. Ventilating a building represents around 25 % of the energy expenditure. With a lit- tle experience, preferably on a very windy day, you’ll find that the north wind’s best friends are the joins between walls and window-frames, mainly in the higher parts of the building and around the roof. But this Mr North Wind also likes your sockets, switches, skirting-boards, and so on. And he hates you with your dual anemometer and your silicone mastic gun! (110343) Links [1] www.ftdichip.com/Products/Cables/US- BTTLSerial.htm [2] http://be01 .rs-online.eom/web/p/ products/2513637/ [3] www.elektor.fr/ 1 1 0343 Pitot tube fluid -► vH> Pitot tube dynamic pressure . + differential N stat ic pressu re pressure i sensor static pressure conversion of pressure at speed 110343 - 11 Principle for measuring speed using a Pitot tube and a pressure detector. The Pitot tube is used for measuring the flow speed of a fluid by performing two pressure measurements. One opening at the end of the tube makes it possible to measure the total pressure, i.e. the sum of the atmospheric pressure plus the pressure resulting from the flow of the fluid (static and dynamic pressures). Another opening on the periphery of the tube makes it possible to measure just the atmospheric pressure (static pressure). From these two measurements, it is possible to calculate the flow speed of the fluid using this equation: V = 2 (p,-p s ) V: speed; Ps: static pressure Pt: total pressure p: density of the fluid The equation is in exponential form: it will be difficult to measure low speeds because the pressure variations are very small. 52 06-2012 elektor Tube, Solic State Loudspealter Tech or a combination of both for maximum accessibility. Subscribe to audioXpress at ij www.audioamateur.com today! ^ to you? Are the words music to your ears? Then you should be Recently acquired by The Elektor Group. audioXpress has been providing engineers with incredible audio insight, inspiration and design ideas for over a decade, li you're an audio enthusiast who enjoys speaker building and amp design, or if you're interested in learning about tubes, driver testing, and vintage audio, then audioXpress is the magazine What will you find in audioXpress ? Audio motour • In-depth interviews with audio industry luminaries • Recurring columns by top experts on speaker building, driver testing, and amp construction Accessible engineering articles presenting inventive, real-world audio electronics applications and projects Thorough and honest reviews about products that will bring your audio experiences to new levels n $ bmw man *v*'„ ihii ?lh edican r! 5, i “,in no kG<».n««dio bewncn !V- desh^i'cr *"h :j new v '*vSeil ■ no^' Ifvljdfit H.I.PPO’ arjfysrf at drrvC^, • • li Vrtiri VMtng, artz-ce gp ■'i' -’HI ar-d crossover cr-anges, ard hs 1 ■ 1 h mofc' &; os complete v^iiP. fcxiui CD . txnativng ow IDO BddrtKxwiJ Twerps ,3rd oi -jd 01 gutfepeaker deatqp [00*5 4 £35 tidlue! Vqurs today for just $39, £5, this book, and many ■M-". ■ F ' ■ : - : 1 1 AVR SDR AVR Software Defined Radio Part 4: Digital radio reception: DCF77, weather service and more ^SLuJJLKU By Martin Ossmann (Germany) The aim of this series of articles is to show that the popular AVR microcontrollers are also suitable for digital signal processing. This time we turn our attention to something practical: using our DIY SDR to receive signals from DCF77 and other time reference transmitters, as well as the German weather service. We also decode the time and weather signals. In the previous instalment [3] we described a test transmitter and an active ferrite antenna, which we can put to good use in this instalment. Now we dedicate our efforts to expanding the scope of our digi- tal receiver. We have already described the digital l/Q mixer. Now it’s time for the filters downstream of the mixer. In order to imple- ment narrow-band reception, we need low- pass filters after the mixer, and more spe- cifically the same filters for the in-phase and quadrature components. The filters located directly after the mixer operate at the same sampling rate as the front end — e.g. 1 0 kHz for DCF77. The filters need to be simple to allow the AVR to compute them in realtime. In the front end we use what are called CIC filters for this purpose. Now it’s time for a description of how these simple filters work. Moving-average and CIC filters CIC filters are based on the moving-aver- age principle. Figure 1 shows a filter that calculates the moving average of a set of five samples. A series of delay stages stores the past sam- ples, which are summed for each average value. When this filter is implemented as an algorithm, the samples are stored in a ring buffer. Each time a new sample is added, it replaces the oldest sample and the buffer pointer is incremented. All samples in the ring buffer are added together each time to calculate the output value (four addition operations). This takes N - 1 addition opera- tions for a filter with N samples. A large N requires a lot of computation time. It can be shown that the filter depicted in Figure 2 does the same thing as the one in Figure 1. Linear time-invariant filters are fully characterised by their impulse response. The impulse response is the out- Elektor products and support • Signal Generator kit with PCB and all components: #100180-71 • Universal Receiver kit with PCB and all components: #100181-71 • Active Ferrite Antenna kit with PCB and all components: # 100182-71 • Combo kit with all three component kits plus BOB FT232 USB to TTL converter: #100182-72 • BOB FT232 USB to TTL converter, fully assembled and tested: # 110553-91 • USB AVR programmer; PCB pre-assembled with SMD components plus all other components: # 080083-71 • Free software download (hex files and source code) All products and downloads are available on the web page for this article: www.elektor.com/ 1 20088 54 06-2012 elektor AVR SDR 1 sample delay Figure 1 . A moving-average filter. Figure 2. A five-stage delay line and integrator, which is equivalent to the circuit in Figure 1 . Figure 3. Filter sections in reverse order compared with Figure 2, but with the same effect. put signal resulting from a single ‘1 ’ at the input (in the series 0, 0, 1 , 0, 0, 0, 0, 0, 0, 0, ...). The series 0, 0, 1 , 1 , 1 , 1 , 1 , 0, 0, 0, ... is the impulse response of a moving-aver- age filter, due to the fact that the single ‘1 ’ passes through the five summing nodes. Now let’s look at what happens to a ‘1’ that enters the filter shown in Figure 2. This filter consists of two parts: a delay line with five stages, followed by an integrator (accumulator). The integrator simply sums all incoming val- ues and outputs the sum. When a single ‘1 ’ enters the filter, it passes through the delay line. However, it also reaches the integrator via the direct path. The ‘1 ’ remains stored in the integrator, which outputs a ‘1 ’ until the ‘1 ’ from the delay line also reaches the integrator. The latter is multiplied by -1, and after five steps the resulting ‘-1 ’ neu- tralises the ‘1 ’ that arrived previously, with the result that the output from the integra- tor consists of a string of zeros. This means that the impulse response of this filter is exactly the same string of five ones. The first section of the filter (the delay line followed by the subtractor) is called a comb filter because its frequency response looks like a comb. This means that our filter con- sists of a comb filter followed by an inte- grator. This type of filter needs only two addition operations per time increment, regardless of the number of delay stages (N). This implementation considerably sim- plifies matters for microcontrollers. Here again, the delay line is implemented as a ring buffer. As the sequence of several linear time-invar- iant filters may be swapped, the filter in Fig- ure 3 also has the same effect, but in this case the integrator is located before the combfilter. Now let’s work out whether this filter does in fact have the right impulse response. After a single ‘1 ’ enters the filter, the inte- grator constantly outputs a ‘1 ’. The ques- tion now is how this filter responds when it receives only a series of ‘1* values. At some point the integrator must overflow, but if you use the right floating-point arith- metic in the implementation, the filter works properly despite this. This behav- iour is essential for the usability of this filter version. Filters and downsampling Due to the high sampling rate, the front end does not have much time for compli- cated filter algorithms. If the signal to be processed is sufficiently narrow-band, the signal can be downsampled (decimated) by a factor R after pre-filtering. This means that only every Rth sample is kept and pro- cessed. If you want to use a moving-average filter, you can use the especially efficient CIC structure shown in Figure 4. Here integration is still performed at the elektor 06-2012 55 AVR SDR Figure 4. The CIC architecture is especially efficient. Listing i: In-phase channel if (sampleTime & 1) { if (sampleTime & OblO) { Ilintegratorl += ADCv ; } else { Ilintegratorl -= ADCv ; } IIintegrator2 += Ilintegratorl ; } sampleTime++ ; if ( sampleTime==Md) { sampleTime=0 ; IntFifoII [IntFif olnPtr] =IIintegrator2 ; IntFif oInPtr= ( IntFif olnPtr+l ) & IntFifoMask ; } fast data rate. The comb filter, which has a length of R , 2 R or NR here, does not need to operate at the fast data rate, but only at the date rate reduced by the factor R after decimation. This significantly reduces the load on the fast interrupt routine that has to process the ADC values. Here the routine for the in-phase channel takes the form shown in Listing 1 , where Md is the downsampling factor. The front end stuffs the samples into a FIFO buffer, from which they are fetched by the following stage. If the following stage is momentarily too slow to process the samples immediately, one or several samples remain in the buffer until they are fetched. This technique makes it easier to program the subsequent stages. Listing 2 shows the finished code for this. The result after double filtering is held in the variable llcomb2out. As you can see, the CIC filter needs only a few addition operations. As the bandwith after the two cascaded fil- ters is still not sufficiently narrow, a third fil- ter is added. This filter does not decimate the signal, but instead leaves the sampling rate unchanged. The associated code shown in Listing 3. Here again, only a few opera- tions are necessary, and the number of operations does not depend on the length of the filter. Listing 2 : FIFO filter IIsample=IntFif oil [IntFif oOutPtr] ; IntFif oOutPtr= ( IntFif oOutPtr+1 ) & IntFifoMask ; // do 1 . st comb-step of two stage downsampling CIC filter IIcomblout=IIcomblstore- Ilsample ; IIcomblstore=IIsample ; // do 2.nd comb-step of two stage downampling CIC filter IIcomb2out=IIcomb2store- Ilcomblout ; IIcomb2store=IIcomblout Listing 3 : Third filter stage // integration step of smoothing CIC filter I-channel IIintegrator3 += IIcomb2out / P ; // comb step of smoothing CIC filter IIcic3out = IIintegrator3 - Ilf if o [CICf if oPTR] ; // FIFO update of smoothing CIC filter Ilf if o [CICf if oPTR] = IIintegrator3 ; / / advance pointer and bump around CICf if 0 PTR++ ; if ( CICf if oPTR==Mc ) { CICfifoPTR=0 ; } This concludes our discussion of the filter- ing of the I and Q signals. Figure 5 shows the resulting architecture of the front end with the filters. Timer 1 generates the ADC sampling rate clock Fs, which has a fre- quency of (20 MHz)//Vs. Downsampling of the input signal with frequency fyields a sig- nal with frequency f, F . This frequency must be exactly one-quarter of the sampling fre- quency, so that it can be mixed with the sig- nal from the local oscillator to obtain the baseband signals. Each of the resulting sig- nals is filtered by a triple low-pass filter. The first two filters, which are also used for deci- mation, are of order Md. The final filter is of order Me. The limit frequencies of the filters decrease with increasing values of Me and Md. The X and Y signals are available at the outputs of the filters for further processing. Receiving frequencies In order to apply the concept described above, the quotient of f/Fs must differ from 56 06-2012 elektor AVR SDR an integer value by exactly 0.25. As you can see from Table 1 , this requirement can be fulfilled for a large number of receiving frequencies. If necessary, this requirement is only needs to be approximately fulfilled. In such case the signal is not mixed down to abso- lute baseband, but instead to a very low frequency. l-channel Figure 5. Block diagram of the front end with filters. CORDIC concept for phase and amplitude The aim of our first experiment is to receive the DCF77 signal in the same was as described in the previous instalment [3]. For this we use the software EXP-Sim- ple-DCF77-RX-IQ-V01 [4]. DCF77 is a time standard transmitter in Mainflingen, Ger- many, and operating at 77.5 kHz. It controls millions of clocks in Europe. The input signal, decomposed into the I and Q components, is available after low-pass filtering. However, in may cases what you need is the amplitude, phase or frequency. This corresponds to a conversion from rec- tangular coordinates to polar coordinates. With floating-point numbers the phase can be determined using the atan2 function, but floating-point computations take a lot of processing power. For this reason, we propose a method that manages with pure integer computations. Let’s start by looking at about Figure 6. Here the objective is to determine the phase of point P with coordinates X0 and Y0. The basic idea is to rotate the position of the point in the clockwise direction until the point is located on the positive X axis. This is done in a manner similar to that of an ADC that uses the successive approxi- mation method. First we try a 1 80° rota- tion. If the Y1 coordinate of the resulting point is negative, we have rotated too far. If Y1 is positive (as in the example shown here), we next rotate by 90°, then by 45°, and so on. We keep a running total of all the rotation angles. If we rotate too far in one of these steps, we reverse the rota- tion. At the end the point is located on the X axis within a specific margin of error, and the total rotation angle corresponds to the original phase. Table 1: Receiving frequencies and parameters Receiving frequency f Divisor Ns Fs (20 MHz/Ns) f/Fs Name 60.0 kHz 2250 8.888... kHz 6.75 MSF 75.0 kHz 1800 11. 111. ..kHz 6.25 HBG 77.5 kHz 2000 10.0 kHz 7.75 DCF77 125.0 kHz 1800 11. 111. ..kHz 11.25 Test 162.0 kHz 2500 8.0 kHz 20.25 TDF 198.0 kHz 2500 8.0 kHz 24.75 BBC 648.0 kHz 1875 10.666... kHz 60.75 BBC Figure 6. Operating principle of CORDIC rotation. Listing 4: CORDIC rotation c=iCordicCosTab [k_cordic] ; s=iCordicSinTab [k_cordic] ; // rotate (x0,y0) by phi into (xl,yl) xl= ( c*x0 + s*y0) / 65536L ; yl= ( - s*x0 + c*y0 ) / 65536L ; elektor 06-2012 57 AVR SDR l-channel U ■> Uin S&H CHrfc 1-Filter X Phase Cordic > P-l-control Y V Q-channel Q-Filter ? <■ Local oscillator 20 MHz VCXO Figure 7. PLL block diagram. ■> Uin o-^ S&H l-channel U 1-Filter sin cos X Frequency Local oscillator Cordic Phase >1 V Q-channel Q-Filter Y r-1 CIC H> s Figure 9. Block diagram of RTTY decoding. For the implementation, the coefficients of the rotation matrices are multiplied by a factor of 65,536 and stored in a table. For an angle of 22.5 (for example), this gives: 65,536 xcos(22.5°) = 60.547 65,536 xsin(22.5°) = 25,080 The routine for computing the rotation of a point at (X0,Y0) to a new point at (XI, Y1) is shown in Listing 4. This method is very similar to an algorithm called the CORDIC algorithm [6] [7]. After the point has been rotated to the X axis, its X coordinate corresponds to the amplitude, which makes it very easy to determine the amplitude. Our CORDIC routine delivers the angle scaled such that a full rotation (360°) corresponds to exactly 256. This means that range of CORDIC values for a phase range of 0 to 360° is the same as the range of values of a single byte. High frequency accuracy with a PLL For this we use the software EXP-Simple- DCF77-RX-V01 [4] to display the amplitude and phase. If you examine the signal received from the DCF77 time reference transmitter, you will see that its phase drifts slowly. The reason for this is that the frequency of our crystal oscillator is not exactly 20 MHz. You can try to calibrate the oscillator by adjusting the trimmer to minimise the phase drift, but this sort of adjustment will naturally not remain constant for a long time. A better option is to put together a phase-locked loop (PLL). This involves applying the phase signal to a control amplifier and feeding the amplifier output to the control input of the VCXO, as shown in Figure 8. If everything is correctly dimensioned and aligned, the PLL will lock and the signal from the crystal oscillator will be held tightly in phase with the received signal. You can use this to build your own frequency standard by tuning the radio to receive a signal broadcast as a fre- quency standard. References: DCF77, France Inter and BBC The receiver can be adapted to various transmitters by simply altering a few param- eter values. This only requires activating the corresponding options with ‘#define’ statements in the source code. First let’s try receiving the DCF77 signal. This signal can be received everywhere in continen- tal Europe. In the western part of Europe, signals from BBC Droitwich (at 198 kHz) and France Inter (at 162 kHz) can also be received. The same approach can be used in other countries with suitable local transmitters. Putting the PLL into operation The receiver must be suitably aligned in advance to enable it to lock onto the received signal. Use the following proce- dure for this purpose. First adjust the active ferrite antenna. To do this, use the signal generator to generate a sinewave signal at the desired frequency. Weakly couple this signal into the antenna by connecting the output signal from the generator through a 1 -pF capacitorto the hot end of the tuned circuit. Then adjust the rotary capacitor to maximise the signal level at the output of the active antenna. Of course, the active antenna must be connected to the receiver during this process, to provide it with a source of power. You can use the previ- ously described RMS voltmeter to measure the signal amplitude. Next, load the program ‘EXP-VCXO-PLL- V01’, compiled for the right frequency, into the ATmega88. Put jumper JP1 in position A so that the PLL can be adjusted with trim- pot P2. Start by setting P2 to its midpoint. If you now orient the receiving antenna, the lit LED in the LED circle should rotate more or less quickly. Use the trimmer capacitor C8 to adjust the VCXO frequency until the LED point remains stationary or rotates only very slowly. If you now adjust PI , the direc- 58 06-2012 elektor AVR SDR 0 111 : i * armor art Figure 1 . UFA always sends fixed-format 1 5 -byte long packets to the slave device (top) which will respond in most cases with something to satisfy the receiving VI (bottom). Figure 2 . Inside the Digital Write Pin VI. All the clever stuff is done in the blocks labelled ‘Arduino’. MUltt f E CuIIl Rud Bufftr ■H" ^ - Ardim fcjMUTO! ■ * _-JJ *rr « «JI Figure 3 . Inside the Send Receive VI. Shown here are the paths that are taken when an error occurs. For normal operation the black case structures are almost empty. Firmata, a UFA alternative As you may have gathered by now UFA uses a serial server on the Arduino to talk to the I/O. This is not a new idea and actually, instead of developing their own protocol, the UFA team could have used an existing alternative. The first one that comes to mind is Firmata, which has been included in the Arduino distribution for many years. According to the Firmata website, the official Uno board even comes pre-pro- grammed with Firmata 2 . 2 . Firmata is a MIDI-based protocol (borrowed from the music industry) intended for controlling a microcontroller by a PC and many host implementations can be found on the internet. The protocol is well defined and widely used in robotics and multime- dia applications. A VI implementing Firmata exists under the name of labviewduino (http://code.google.eom/p/labviewduino/). elektor 06-2012 61 MICROCONTROLLERS Figure 4. This is the 8-channel relay board with synchronous serial interface that I want to control from LabVIEW. As an example I will use this nice 8-channel relay board with serial interface (Figure 4, Elektor Shop # 071035-72) that I have at my disposal. It has a 2-wire custom serial interface that is a bit peculiar so I did the slave side implementation first. I based my code on the original BASCOM example, available at [1 ] that I ported to C. I will not go into details here, have a look at my code that is included in the download for this article [2]. To use the relay board from within LV two functions are needed, one to set up Platino [3] (Arduino) ports so that it can talk to the relay board and a second function to (de)activate relays at will. The Vis that go with this are similar to UFA’S Set Digi- tal Pin Mode and Digital Write Pin Vis so I used those as templates. Actually, my Vis can be simpler because I don’t need the Check For Pin Out Of Range VI. Here is how you do it. If you don’t have one in your VI already, put a Digi- tal Write Pin VI in your block diagram. Double click on it to open it, then click File -> Save As.... Now click Open addi- tional copy followed by Continue. Specify a name for your VI and save it somewhere, preferably not in the UFA folder. Close the Digital Write Pin VI so you will not accidentally modify it. In your new VI click File -> vi Properties. In the win- dow that opens you can set some basic things like the title and the icon for the VI. As Category select General and click the Edit Icon... button to create you r own icon. In the Documenta- tion category you can write a short description of the VI, and in the Window Appearance category you can set the Vi’s title. All the other parameters can be left as they are. Open the block diagram (Ctrl-E) of your VI (if not already opened) and remove the Check For Pin Out Of Range VI together with its Pin Type constant. Connect the Arduino Resource and error in blocks to the Send Receive VI. Rename the pin and mode constants by double-clicking on them. One last thing now remains to be done: defining a new command. As you will see this turns out to be the hard part. The easy solution is to reuse a command that you don’t need like maybe sevenSegment_Configure (click the Command drop-down list to select it). This will work, but is not really recommended as you may run into conflicts later when you have forgotten all about this Figure 5. The Relay init VI is used to define which Platino pins will be used for communicating with the relay board. hack. Also it is not very user friendly since the name does not cor- respond to its function. Another solution is to replace the drop-down list by a byte constant with an unused value. To find out which values are used you can right-click the list and open its properties. On the Edit items tab the values that are already in use are listed. The last one in my list is Finite Sample Start which has the value 45. So 46 should be free, right? Well, actually it is, but that’s pure luck. Because when you look closely at the serial server code (in the file LabVIEWInter- face.pde), you cannot but notice that there are four commands here that are not in the drop-down list. True, they can be config- ured away by commenting out a define, but it shows that some UFA developers used the same approach as us, hard-coding commands in the stepper motor Vis without adding them to the commands list. Ooh, that’s so gross. The proper solution is of course to add your own commands to the commands list. I did this by right-clicking the drop-down list and selecting Advanced -> Customize.... In the windowthat opens you can create a copy of the Type Def (File -> Save As...) which you can edit. Right-click the edit box with setArduinoMode in it and select Edit items.... Now you can add commands and reorder them. Make sure to add the stepper motor commands too. In your VI replace the original Command drop-down list by your extended copy. To be totally honest, I do not know if this is the right or recom- mended way to do things, but it worked for me. As you can see from Figures 5 and 6 the command arrays that are constructed do not have the same size. You can change the size of an array (and of many other complex objects) simply by resizing it with the mouse. Dragging the bottom line downwards will increase the size, pulling it up makes it smaller. Good for documentation and ease of understanding of Vis is using labels. Do a right-click on the item for which you want to add a label and select Visible Items -> Label. Finally, I coded the relay states as bits in a byte using a 1 D Boolean array that I cast to a byte. Tinkering this way I created a whole bunch of Vis to control the peripherals of Platino like the buzzer or the rotary encoders. The most important VI is the Platino Configure VI that lets you setup the LCD and the solder jumpers. UFA issues As mentioned before, UFA has some quality issues that you may want to be aware of. I already mentioned the hard-coded stepper motor commands and if the UFA development team continues extending the library in such a manner, we will be in for trouble. 62 06-2012 elektor MICROCONTROLLERS ^RalH^tata "h Refay 5ta4es 1 f t rjf — |q»lg| ArduflOFteMurcef ; l iSrrOr i*i I: ByteST&Re4d{0) -•^T flrduflo R&Ssrca >NT]«nrCr ftJt Figure 6. The Relay State VI allows toggling the state of the relays. Each relay takes up one bit of the command’s data byte. But there is more. When you look closely at the commands that pass values that do not fit in one byte you will notice that they do not do this in a con- sequent way. Some Vis will use big-endian formatting where oth- ers prefer little-endian. This is of course confusing and may quickly lead to errors. On the serial server side the main problem is sloppy coding. This not only leads to wasting precious program memory, it is also rather hard to maintain. Also, when you compile it you may see warnings (if you activated them in the Arduino IDE preferences) that can be fixed easily. The commands are not implemented using defines with understandable names but instead coded directly as hexadecimal values in a large illegible switch-case structure. For my own use I decided to recode this properly and while doing this I added con- figuration options allowing me to leave out the bits I didn’t need, saving lots of program memory. Finally I came across a difficult issue probably due to the inher- ent parallelism of LabVIEW and the weak communication proto- col. When I tried to create a VI that would display the value gen- erated by a rotary encoder and allow setting of the relays at the same time I noticed that the respective Vis did not receive the right data. It seemed that one VI was receiving the data intended for the other. I finally managed to fix this by adding a serial port flush to Send Receive VI. You can see it in Figure 3, it is the VISA block with a little microwave oven and a Wii game console in it (funny icon, isn’t it?), just left of the one with abc written in it. This one was added by me and is not part of the official UFA distribution. What it does is flushing the serial input buffer right after sending a command to Platino. Since Platino will handle only one command at a time this flush should insure synchronisation between LV and Platino. An extra sync byte added to the protocol would have been useful here. Cutting the umbilical cord I hate wires and cables. They are always too short; never have the right connectors at the end and forever create spaghetti knots. Today there are solutions to get rid of some of those cables and one of them is called Bluetooth. My computer has Bluetooth (BT), and if yours doesn’t just stick a BT dongle in it. Adding BT to Platino is very easy if you only need a serial cable replacement. In Elektor we have used several Rayson BT modules that can do this. They are inexpensive and badly documented, but that doesn’t stop me [4]. To connect a BTM220 (BTM222, BTM1 12, etc.) you only need a level shifter for the RX and TX signals because it is a 3.3 V module. We already showed you how to do this in Elektor [5], but you can use Figure 7 as a reminder. I quickly built an extension card in Arduino ANTI Figure 7. Level-shifting the Rayson Bluetooth module. You can use any Bluetooth module that can handle the Serial Port Profile (SPP) (most, if not all, do). shield format on which I put two level shifters, the BT module and a 3.3 V voltage regulator (Figure 8). You could also use module [6]; it already has a voltage regulator on it. Before you can actually use the BT module you have to configure it. Several ways are possible, but the simplest is probably hooking it up to a serial port on your PC. If you are using Platino to follow this article you probably already have what it takes: the FTDI USB serial adapter cable. Connect it to the level shifter BT shield you just made and launch a serial port terminal program on the PC. Configure it to use the right serial port and set the communication parameters to 1 9,200 baud, 8 data bits, 1 stop bit, no parity bit, and no hardware flow control. Connect and press Enter to send a new-line character to the BT module. It should respond with OK. If it does, you’re ready to configure: • Tell the module to stop sending result codes. In the terminal type atqi followed by Enter. This is needed because otherwise the BT module will output something like connect '1234- 56-789012' (with a real network address) when a BT connec- tion is established, but since the serial server does not handle that, unpredictable behaviour may result. • Set the baud rate to 1 1 5,200. In the terminal type ATL5 fol- lowed by Enter. Strictly speaking this is not necessary as you could adjust the communication speed in the VI. After this com- mand you must of course reconfigure your terminal for the new speed. • Set the BT module’s friendly name. This step is optional, but it helps identifying the connection. In the terminal type atn=platino (or another name, no more than 16 characters long) followed by Enter. That’s it; you can now connect the BT shield to Platino. When done, power on Platino and, if needed, the BT interface of your PC, then make the PC scan for BT devices. It should quickly find Platino (you know when it does, because you gave it a friendly name). Select it and enter the default password 1234 when asked for it. This should be enough to establish the connection. Normally you have to do this only once as the BT module and the PC remember their settings. To finish replacing the USB cable by a wireless Bluetooth connec- elektor 06-2012 63 MICROCONTROLLERS Figure 8. The Bluetooth shield I cobbled together on an old board with the Arduino form factor (Elektor ref. 090527-1 , October 2009). You can also use the OBD-2 NG BT module published in April 201 0 (Elektor ref. 09091 8-71 ). The dangling connector is for connecting the FTDI USB serial cable to configure the module. The antenna wire is supposed to be 31 mm long. tion you have to configure the BT connection on the PC as a vir- tual serial port. This is pretty straightforward on Windows — I don’t know about other operating systems. The last step now is to select the new virtual serial port in your VI as the one to use by the Arduino InitVI. There you go. As soon as you start your VI it will first (automatically) establish the wireless link before doing its normal business and eve- rything should work exactly the same as with a wired connection. Platino can now move around unhindered by cables while staying in touch with LV. Going World Wide Ever since you bought that tablet computer because you wanted to own one, you are desperately looking for things to do with it. Here is an idea. National Instruments (Nl) has released a free application for Android and iPad tablets called Data Dashboard. With this app you can visualise shared variables that are published by your VI. For now you cannot control anything with Data Dashboard, but maybe Nl will add that functionality in a future version. So how do you pub- lish a variable? Here is how. First of all you have to use a project. You cannot do this simply in a VI, the VI has to be part of a project. Create an empty project, click right on My Computer, then click Add -> File... and navigate to your VI in order to add it to the project. Double click the VI to open it and then open its block diagram view. To add a shared variable again do a right-click on My Computer and select New -> Variable. In the Shared Variable Prop- erties window that pops up give the variable a name and make sure that the Variable Type is set to Network-Published. As Data Type select the type that you need. But be careful here as not all data types are supported by Data Dashboard, so you’d better stick to Double or Boolean. More types may be added in the future. When you close the window you will see that the newly created vari- able was added to a new library in your project. You can rename the library if you like. To add the shared variable to your VI, simply drag it to the block diagram (or to the front panel if you need it there too) and drop it. Since you can only monitor this variable you have to change its Access Mode to Write (right-click on it) so that you can connect it to the signal of your choice. Add as many shared variables as you need. Once you’re done, you will have to deploy them. Normally this is done automatically when you start the VI, but it does not hurt to do it manually too. It is done by right-clicking the new library in your project and then selecting Deploy All. If all is well you will briefly see a Deploy Progress window that you will see again when you launch the VI. Your VI is now ready (Figure 9) and sharing variables, the next step is to setup Data Dashboard. Message to dsjJ ay iFMfrpliLaWlEWl 'j Frequency (0 He) IMPS — Dufafcfan (] ra) | 3-Jt A U «r cetufUtf A "J, Pt^B5haadVdriaU£i.lvtb FtelayL Relay? ^ Relaya- - RekM - Jdj - jta -Stfl - ^ Relays £1 Relays - Jfe. Rotar-yEiKodef j r '■V' DepsndHXBi ±> Bu ld Skrarf tot Ions f ill! E> l^°1 0 j,pooo.pp,ppcigt]gpo;pDO.n,og,o : ' * P |m | | [ Ffa Cnradrr pmh button Relay 3 R.ttoy 6 Pday S I .J , 7k_ — l M 'M J M Relay l ft el ay 2 Relay 3 Relay a U* i : P Mji .¥ J rsi if t 4 - t m 'il Figure 9. The relay controlling VI including shared variables accessible from Data Dashboard. 64 06-2012 elektor MICROCONTROLLERS + Add + Add Relays Retayl Rslay2 Relays # / \ m ( ) \ / W ! / \ ^ jr Relayfl Relay? RelayS O A f \ / \ '.w i \ Jr [ 6 m m m Figure 1 0. The server selection window in Data Dashboard on an iPad. If your server is listed, tap it, if not tap Connect to shared variable. Figure 1 1 . Data Dashboard showing the status of six relays. So where are relays 4 and 5? They are on the next page, because you can have no more than 6 indicators on one page. I wanted the same layout as the LEDs on my relay board so relays 4 and 5 fell off this page. Get the Data Dashboard app from the market that suits you best. I used an iPad so I downloaded it from the Apple Store. Launch the app and select a page layout (1 , 2, 4 or 6 indicators per page). Give the page a name (tap Untitled 1), then tap Add in the indi- cator of your choice. This will bring up the Select a server window (Figure 10). Since you don’t have a server yet, tap Con- nect to shared variable... and enter the server’s name or IP address (192.168.0.2 in my case) and tap Connect. (If you don’t have a server you can try the app with the Demo variables.) If the server was found, you will now see the Select a variable window listing the shared libraries available on the server. You will probably see the System library that you get as soon as you install LabVIEW. Tap your Vi’s library and then tap the variable that you want to display. You will be presented with a few options for the hhmm; eee HHHQB to depkjy Rjdflv l Relay 2 Relay 4 t J J J RflflayS Fteliy? Relays RvfltoyS J J * J Ertodw pushbutton STO^ The front panel and the project tree are also visible. indicator. A numeric variable can be shown as a string, a gauge or a chart; a boolean can be a string, an LED or a chart. When you pick a chart or a gauge you have to enter the minimum and maximum values too. Once you have set up all the indicators you can tap Run to start monitoring (Figure 1 1 ). Of course the VI should be running too. In case of connection problems the indicators show a yellow warn- ing triangle. That’s it, now you’re all set to let Platino ride around on a wirelessly controlled robot communicating over Bluetooth with a VI running on your laptop, collecting data that you can monitor on your tablet from anywhere in the world. As I said in the introduction: pretty exciting, huh? Maybe in a future article I will introduce LabVIEW web services to take the concept even further. ( 120227 -I) Internet Links and References [1 ] 8-channel relay board with synchronous serial interface: www.ele- ktor.com/080357 [2] Code examples for this instalment: www.elektor.com/ 1 20227 [3] Platino: www.elektor.com/ 1 00892 [4] Experiments with Rayson Bluetooth modules: http://elektorem- bedded.blogspot.com/201 0/08/rayson-btm222-btm1 1 2-blue- tooth-modules. html [5] Bluetooth with the ATM1 8: www.elektor.com/080948 [6] Bluetooth for OBD-2: www.elektor.com/09091 8 elektor 06-2012 65 ELECTRONICS FOR STARTERS Electronics for Starters (6) Flip-flops To understand the basics of electronics, you have to go beyond high-level block diagrams — now and then you need to look at the details inside the blocks. For example, a microcontroller consists of a large number of functional blocks, each of which is composed of just a few transistors. The best way to learn how these subunits work is to conduct simple, hands-on experiments. By Burkhard Kainka (Germany) On or off, one or zero: welcome to the world of digital logic! Along with analogue tasks, transistors can also be used for digital tasks. In the past there were even full-fledged computers built entirely from discrete tran- sistors. One of the most important basic digital circuits is the flip-flop. Even a single flip-flop can be put to good use in practical applications. The flip-flop A flip-flop is a circuit with two stable states. Flip-flops are important basic elements of digital computer technology, particularly for use in counters and memories. Flip-flop circuits use positive feedback of an in-phase, amplified signal. This can be implemented using two inverting amplifier stages (Figure 1 ). As each stage inverts the signal, the input and output signals of the overall circuit are in phase. The feedback from the output to the input causes the output signal to go to one of two states. A rising voltage on the output, for example, is amplified by the circuit and drives the out- Figure 1 . Functional block diagram of an amplifier with feedback. put voltage even higher. As a result, the cir- cuit switches to the fully ‘on’ state. In the other direction, a falling output voltage causes the output to be quickly switched to the ‘off’ state. The amplifier can be built as a two-stage, directly coupled transistor circuit (i.e. without coupling capacitors). Each com- mon-emitter stage (Figure 2) inverts its input signal. This simple circuit is effec- tively a bistable flip-flop, which means that the output voltage can be either low (nearly 0 V) or high (nearly the same as the supply voltage), and it remains in the given state for an indefinite length of time. The state can only be changed by some sort of external action. When the output voltage is low, the left- hand transistor does not receive any base current and is therefore cut off. As a result, its collector voltage is high and the right- hand transistor receives full base current, causing it to be driven hard on. This causes the output voltage to stay low. When the output voltage is high, the situations of the two transistors are exactly reversed. It is impossible to predict which state the circuit will assume after being switched on — it’s simply a matter of chance. RS flip-flop Now let’s add a pair of LEDs our circuit, along with two pushbutton switches that can be used to change the state as desired (Figure 3). After switching on the power, you will see that one of the two LEDs is lit. You can’t say in advance which one of the two will light up. Which way the circuit goes when it is powered on (i.e. which state it assumes) usually depends on the difference in the current gains of the two transistors. If they happen to have identical character- istics, noise (which is always present in elec- tronic circuits) plays a role. Accordingly, it may happen that the circuit sometimes ends up in one state after being switched on, and sometimes in the other state. However, it’s possible to set the circuit to either state as desired. To do so, simply press one of the two pushbuttons, each of which shorts out the base current of the associated transistor. This circuit is called a reset/set (RS) flip-flop. Figure 2. A bistable flip-flop with two transistors. Figure 3. An RS flip-flop. 66 06-2012 elektor ELECTRONICS FOR STARTERS Thvristors Thyristors are bistable switching de- vices with three electrodes: a cathode (l<), a gate (G) and an anode (A). The gate electrode is used to trigger (switch on) the thyristor, which remains con- ductive until the circuit is interrupted. The structure of a thyristor is similar to that of a transistor, but it has four semiconductor layers (NPNP). The gate electrode operates in a similar man- ner to the base of an NPN transistor. If the gate current rises above a specific threshold value, the thyristor is trig- gered and starts conducting. It remains conducting until the current stops +6V flowing through the device. This can be done by switching off the supply voltage or by briefly shorting out the thyristor. Another technique that is of- ten used is to operate the device with an AC voltage. In this situation, the thyristor stops conducting each time the voltage passes through zero. The circuit diagram here also shows an equivalent circuit with bipolar transis- tors. This equivalent circuit can also be switched on (triggered) or off in the same manner. Both circuits can be used in the same way as an RS flip-flop. An RS flip-flop can be used as a 1-bit data memory. It can save states such as ’red’ of ‘green’ (if you use LEDs with these colours), ‘on’ or ‘off’, ‘yes’ or ‘no’, etc. You could use this sort of device at home to leave a mes- sage, such as “Back right away” or “Out for a while”. Your message remains present until it is changed. Reset buttons and reset inputs are com- monly found on computers and microcon- trollers. This is hardly surprising, since com- plex systems of this sort contain a large num- ber of flip-flops, some of which are used to store data. When the power is first switched on, all static flip-flops initially assume a ran- dom state. To bring order to this chaos, you need a reset function. A short reset pulse is all it takes to set everything nicely to zero. Now the work can begin. Incidentally, modern microcontrollers use MOSFETs instead of bipolar transistors, and things are even easier with MOSFETs. An RS flip-flop using two BS170 MOSFETs (Figure 4) can manage without the base resistors needed by the version with bipo- lar transistors. Triggering and clearing A flip-flop can be built with an NPN tran- sistor and a PNP transistor wired as shown in Figure 5. Here the collector current of each transistor is the base current of the other one. As a result, both transistors are either cut off or conducting. After power is switched on, the circuit is initially in the non-conducting (‘off’) state. Briefly actuating the switch puts the circuit in the conducting (‘on’) state. The transis- tors remain in the conducting state until the supply voltage is switched off. This circuit therefore acts the same way as a thyristor (see inset). Incidentally, the capacitor in the circuit prevents the circuit from accidentally triggering by itself when the supply voltage is applied. Monostable flip-flops In many situations what is wanted is a flip- flop circuit that changes to a different state fora defined period instead of indefinitely. For example, this could be used to build a timer that is triggered by a pushbutton and switches off automatically after a certain time. This behaviour can be achieved by including a capacitor in the feedback path. The capacitor starts charging when the timer is triggered. When it is fully charged, no more current flows in the feedback path and the circuit returns to the stable quies- cent state. The timeout period (‘on time’) of the circuit shown in Figure 6 is approxi- mately 10 seconds. Schmitt trigger A Schmitt trigger is a circuit that converts a variable input signal into two distinct states I ! c 5 Figure 4. An RS flip-flop with MOSFETs. Figure 5. A bistable circuit with complementary transistors. — > ( ? i i £ 1 - lOOu ! 9V > 10k 1 1 0 ? ( > A |_ioc*J BC54/B — q j ^ B Uu547B Figure 6. A monostable flip-flop. elektor 06-2012 67 ELECTRONICS FOR STARTERS Twiliaht switch It’s quite easy to implement a Schmitt trigger function using a microcontroller. You simply measure the input voltage and compare it with pre-defined threshold values. The output is either switched on or switched off, depending on the results of these comparisons. The two switching thresholds are defined independently. This gives you complete control over the amount of hysteresis. In addition, you can build a defined delay into the program. A one- second wait loop also helps prevent undesirable switching jitter. We implemented a twilight switch using the Tinyl 3 and a few additional components. 'Twilight switch $regfile = M attinyl3 . dat " $crystal = 1200000 $hwstack = 8 $swstack = 4 $framesize = 4 Dim U As Word Config Adc = Single , Prescaler = Auto Start Adc Config Portb = 1 'Output B.O Do U = Getadc ( 3 ) If U < 400 Then Portb. 0 = 0 If U > 600 Then Portb. 0 = 1 Waitms 1000 Loop End (High or Low). It has two threshold levels separated by a hysteresis zone. For exam- ple, with threshold levels of 2 V and 1 V, the output changes to the ‘off’ state when the input signal rises above 2 V and remains in that state until the input signal drops below 1 V. The current state remains unchanged as long as the signal level remains in the hys- teresis zone. The classic Schmitt trigger circuit (Figure 7) employs feedback over a common emitter resistor. The thresholds and the amount of hysteresis can be set as desired by selecting suitable resistor values. As a diversion, you can try a little RF experi- ment with this circuit. Connect a length of wire to the input to act as an antenna, and < » < c — C => •3 [> ( — | 100k | — c ; 9V -C 10k BC547B ) BC547B c c $ l => h “ ^ £ 3 t < 1 1 t-J Figure 7. A classic Schmitt trigger. then adjust the potentiometer very close to one of the switching points. Now flip a light switch. You may hear some static on the radio, and at the same time the circuit will be triggered and its state will change. Here the Schmitt trigger effectively acts as a broadband radio receiver, with the light switch acting as the associated radio transmitter. An illustrative example of a Schmitt trigger application is a twilight switch (Figure 8). Here the idea is to switch on a lamp when it gets dark outside. An important consid- eration is that the lamp should not flicker near the switching point. This means that the circuit should switch off only after the light level rises significantly. In other words, there must be some hysteresis between the two switching points. The voltage at the input of the Schmitt trig- ger here depends on the resistance of the LDR. This resistance increases with deceas- ing ambient light level, which causes the LED to switch on. When the ambient light level rises, the LED is switched off. There is noticeable hysteresis between the two switching points. It should be sufficient to prevent the circuit from responding to the flickering of artificial lighting. Simplified Schmitt trigger A simpler implementation of a Schmitt trigger is shown in Figure 9. Here two NPN transistors in common-emitter configu- ration are directly coupled. An additional < ► < 0 < 1 1 £ 3 - 1 — | 100k | < c ; 9V s < -c LDR VJ n ) BC547B ttt L BC547B — Figure 9. A simplified Schmitt trigger. 68 06-2012 elektor ELECTRONICS FOR STARTERS Quiz The circuit diagram shows the Schmitt trig- ger from Figure 7 with slightly different compo- nent values and two test points. The transistors are C versions (with the highest possible current gain), so the base cur- rents can be ignored in your calculations. Volt- ages U1 and U2 are both measured to ground (i.e. relative to the minus terminal of the battery). The potentiometer should initially be adjusted fully anti-clockwise (wiper at the bottom end). As a result, the left-hand transistor is cut off. A high voltage is present on its collector, so the right-hand transis- tor receives enough base current to drive it fully on. In the ‘on’ state a voltage U2 is present across the common 470-ft emitter resistor, due to the sum of the two emitter currents. Next we raise U1 until the cir- cuit changes state. Voltage U2 is now less lower before, because less current flows through the left-hand transistor when it is conducting than through the right-hand transistor when the latter is conducting. The difference between the collector currents produces the hysteresis. Note: It’s easier to quickly build the circuit and make measurements on it than to calculate everything exactly. 1 ) U1 = 0 V. The LED is lit. What value do you measure for U2? A) Approximately 0.47 V B) Approximately 1 V C) Approximately 2.3 V 2) U1 is increased slowly. At what voltage U1 does the output change state? D) Approximately 2.9 V E) Approximately 4.5 V F) Approximately 6 V 3) U1 is decreased slowly. At what voltage U1 does the output change state? G) Approximately 1 .4 V hi) Approximately 2 V I) Approximately 2.5 V If you send us the correct answers, you have a chance of winning a Minty Geek Electronics 101 Kit. Send you answer code (composed of a series of three letters corre- sponding to your selected answers) by e-mail to basics@elektor . com. Please enter only the answer code in the Subject line of your email. The deadline for sending answers is June 30, 201 2. All decisions are final. Employees of the publishing companies forming part of the Elelctor Inter- national Media group of companies and their family member are not eligible to participate. The correct solution code for the quiz in the April 2012 edition is * CDH \ Here are the explanations: Answer 1 : Unfortunately, there were three decimal-place errors in the first question. We apologise for these errors. Instead of: A) 100 £2 B)47ft C) 22 ft the potential answers should have been: A) 10n B) 4.7 ft C) 2.2 ft R x = 0.7 V/ 0.35 A R x = 2 ft Result: 2.2 ft; answer C is the closest (the current is 1 0 % less than the allowable current). Note: We ignored the answer to this question, due to our errors in the question. Answer 2: The voltage over the three LEDs together is 1 0.2 V. Efficiency = U tota |/U usefu i = 10.2 V /12.6 V = 81% Option D is correct. Answer 3: U CE = 1 4 V - 1 0.2 V - 0.7 V = 3.1 V P = U x I R = 3.1 V x 0.35 A P = 1 .085 W Option H is therefore correct (approximately 1 W). £ 9V 5 f 100k D-i / 10k D / BC547C -€> BC547C U2 I — T resistor from the output to the input pro- vides the necessary feedback for the switch- ing hysteresis. For this experiment we again use the LDR as a variable resistor. However, in this case the LED switches on when the light level rises and switches off when the light level falls. This circuit switches cleanly, even with a slowly decreasing light level. It has the typi- cal Schmitt trigger characteristic of convert- ing a gradual change into a step change. The sensitivity of the circuit can be adjusted over a wide range to suit various lighting condi- tions by modifying the voltage divider at the input. With a 10-kft fixed resistor, it switches at a relatively high light level (e.g. close to a lamp). With a 1 00-kft resistor, it is suitable for sensing typical light levels in residential rooms. ( 120006 -I) elektor 06-2012 69 DESIGN TIP PIC Programmer for Emergencies Instructions • Compile the program, so that a hex file for the PIC1 6F1 827 is generated. • Convert this ihex file with ihex2pic (available via [1 ]). • Open SimpProg.asm in MPLAB and check whether the correct ‘include’ file is called. • Place the PIC1 6F88 in the powered-down evaluation board and then connect the PIC1 6F1 827 according to the schematic of Figure 1. • Program the PIC1 6F88 using the programmer supplied with the evaluation board. • When programming is complete LED D1 will turn on. The 8-V programming voltage can now be switched on. • LEDs D2 and D3 will now also turn on. Wait until both LED D1 and D2 turn off. If all goes well LED D3 will still be on; otherwise a programming error has been detected. • Switch off the 8-V programming voltage and the power supply voltage to the evaluation board. The PIC1 6F1 827 is now ready. (110359-1) [1 ] www.elektor.com/ 1 1 0359 1 On-board programmer for Android The RF & Microwave Toolbox contains 34 calculation and conversion tools for RF, microwave and electronics in general. Whether you are an RF professional, radio-amateur, astronomer or hobbyist, this app puts some of the most impor- tant tools right at your fingertips. Literally! ■h—Xfrs. jlthL 1 1 > i IJ II W iJH *] 1 ] la ■ 1 15 M III » II Q. :ii.m Oitral! MP Swall &n » PI-S& f+ul MriD Iluci-iil OirralillPJ foarriuntt Cranll I3H1 tonditilFl Eg 14 oy li UQF17 ea-i IT.D1P7 kin* Highlights: • Amplifier cascade (NF, Gain, PI db, 0IP2.0IP3) • Field intensity and power density converter (W/m2, V/m, A/m, Tesla, Gauss, dBm, W) • PCB Trace calculator (impedance/dimensions) • PI andT attenuator • Antenna temperature (Kelvin) • EMC (EIRP, ERP, dB(iV/m) • Filter Design (Butterworth, Chebyshev, prototype) • And much more Further information at www.elektor.com/rf-app sr jownload your app now! AM 3*010 A.P# OH ^ Coogle pfay 70 06-2012 elektor :::c355‘* '3::a:cc atccecec ccceecec :ccc:ccf reeccccc ;::ccct ‘C8CCCC 3f 8098CC JCfl8C3CC CCCC3t3s 1 16 3 C C 3 C C 3' Read Elektor with the cut-rate PLUS membership! Join now or upgrade: www.elektor.com/member DESIGN TIP 2-Wire Interface for Illuminated Pushbuttons Cut down on cabling to improve reliability By Klaus Jurgen Thiesler (Germany) Reducing the number of interconnections in a design improves sys- tem reliability. There are fewer problems of unreliable contacts and cable failures. This design shows how you can get away with just two wires instead of the more usual three when connecting an indi- cator pushbutton. Engineers are no friends of a wiring rat’s nest. More cables means more connections means more chance of an unreliable system. For this reason the trend is for serial in preference to parallel interfaces, even when the serial interface requires processing power to refor- mat information. The same is true for connections between a micro- controller system and a remote user- interface: the fewer the wires the better. With this in mind the author set about optimising the interface to a common type of input device: a pushbutton with an LED illuminator/indicator. The resultant circuit uses just two wires instead of the more usual three. As more switches are needed, the benefits begin to add up. Cutting down When connecting an indicator pushbutton to a microcontroller it is usual to use one wire from the pushbutton contact to an input port pin and another from an output port to drive the LED. Both use a common earth return making three wires altogether. To reduce the wiring to just two wires it is necessary to wire the LED in paral- lel to the pushbutton contacts as shown in the left hand side of the diagram in Figure 1 . In principle the LED can be connected in series with the contacts but a normally-closed contact would be neces- sary (or the normally-closed contacts of a changeover pushbutton) otherwise the LED cannot light without the button being pressed. Parallel wiring is however the simplest configuration. The trick used here is to always have current flowing through the LED, even when it is not illuminated (and the pushbutton not pressed). The LED in this state passes a current level of just a few tens of microamps to create a forward voltage drop but not suf- ficient to produce any visible light. When a few mA are passed through the LED it lights and the forward voltage drop increases slightly but always remains between 1 .2 V and 1 .9 V until the push- button is pressed which shorts out the LED. The resultant voltage changes can be processed. The LED goes out when the pushbutton is pressed to give a visual indication of a key press. The circuit R1 provides a continuous low level current through the LED (around 20 pA at V cc = 3.3 V). To make the LED light up the microcontroller output port pin Port.1 is switched to Low. In this state T1 operates as a simple constant current source with a voltage drop across R3 of approximately 1 V. Subtracting the \/ be ‘ON’ voltage of T1 leaves around 0.33 V across R2 which gives a constant current of the order of 10 mA through R2 and the LED. When the Port.1 pin is High’ the LED does not illuminate. For the pushbutton the voltage divider ratio ensures that transistor T2 conducts when the voltage at K2.1 exceeds 0.85 V. In its quies- R1 --0 R2 R3 T1 R4 R5 H 10k |- BC560C K2 R6 -| 100k |- CN 1 ■ CM 22 n L_ 1 1 4 V. (110572) 72 06-2012 elektor COMPONENT TIPS MOSFETs + Extras (2) / BTS432E2 By Raymond Vermeulen (Elektor Labs) BTS432E2 In last month’s column I discussed a MOSFET that allows the current through the FET to be measured efficiently. This time I will deal with an intel- ligent switch, that is, a MOSFET with built in logic and diodes. Such a component often offers functionalities such as safeguards against reverse-po- larity, switching of inductive loads and protection against high currents and high temperatures, and ESD protection. Such features are particularly relevant in industrial and automotive environments. The clever switch below has all these features and even a few more. ( 120226 ) BTS432E2 The BTS432E2 is an intelligent high-side switch. It contains an N-channel MOSFET plus a charge pump for the gate and many protec- tion measures. This switch is mainly intended for use in automotive power systems (1 2 V or 24 V) to control all kinds of resistive, induc- tive and capacitive loads (when used with inductive loads it is recommended to use a diode in parallel). This component can also be used at higher voltages; refer to the table. Designers experienced with MOSFETs and inductive loads are aware that the transients generated when the MOSFET is turned off can destroy the device and the logic connected to it. Thanks to all the protection measures built in, the BTS432E2 does not have any problems with this and it can therefore replace a relay in many applications. Very handy is the ability to control this switch using a microcontroller which is operating at 2.7 V. A level shifter is built in specifically for this purpose, so that the gate will receive a proper drive signal despite the low voltage. There is also a status output; this open-drain output supplies a low level when the output is open circuit, there is a short-circuit to GND or V bb , or when the temperature is too high. When the voltage is too low or too high the MOSFET will restart automatically, in this case the status pin is not activated. In addi- tion there is protection against an incorrectly Figure 1 . Block diagram and connection details. ¥ Figure 2. Currents and voltages. connected voltage source and an open circuit ground connection. The current limit is set to a much higher value for the first 400 jus compared to the continu- ous current. This is very useful when switch- ing capacitive loads or lamps. To limit the current when the voltage source is reversed it is possible to connect resistors in series with pins 1 , 2, and 4. The current flowing through the so-called body diode will be limited by the load connected. But just how long this can be sustained depends on the amount of cooling of the component. If the switch in normal use becomes hotter than 1 50 °C, then it will switch off. Once the tempera- ture has dropped sufficiently it will restart automatically. Despite all the advantages there are also a number of drawbacks with these types of switches. The biggest is the on/off switching speed. Often, this is over 1 000 times slower than a ‘plain’ MOSFET. Consequently the BTS432E2 is not suitable for applications that require fast switching. But generally speaking this type of MOSFET is an excellent electronic alternative fora relay. Datasheet: www.infineon.com, search for BTS432E2 Parameter Condition Value On resistance R on / L = 2 A 30 m £1 (typ.) Turn-on time t on 90% \/out 1 60 jus (typ.) Input turn-on voltage V| N ( T+ ) Tj = -40 to +1 50 °C 2.4 V (max.) Input turn-off voltage \7| N ( T .) Tj = -40 to +1 50 °C 1.0 V(min.) Undervoltage shutdown, \7 bb ( U nder) 7j = -40 to +1 50 °C 4.5 V (max.) Overvoltage shutdown \/ bb ( over ) Tj = -40 to +1 50 °C 42 V (min.) Thermal overload trip temperature T jt 1 50 °C Nominal load current / L (| S0 ) T c = 85 °C 9 A (min.) Repetitive short circuit current limit / L ( SCr ) Tj = 1 50 °C 35 A (typ.) Initial peak short circuit current limit /qscp) 7j = 25 °C 44 A (typ.) Output clamp, voltage under V bb / L = 30 mA 58V Reverse battery -\/ bb Pin 3 to 1 -32 V (max.) elektor 06-2012 73 fR,et>iania& Intersil IM6100 Vintage Dev Kit By Geoff Newton (UK) This Dev kit was real state of the art stuff in 1977, but you had to be fairly dedicated to do much with it. There was no assembler or com- piler. You had to write the program on paper, hand compile it and then load the memory with the required data using the keypad — not that there was all that much memory, only 256 words of 1 2 bits. The keypad and 7-segment display is in the bottom left of the board. The address of the selected memory cell and its contents is displayed by a set of eight 7-segment displays. The Keypad is 4 rows of 3 columns and most keys have several functions. Because of the 1 2-bit format you had to use Octal as opposed to Hex which we mostly use today. There were no Up/ Down arrow keys so to get to the next memory location you had to go through the whole cycle of entering the address, etc. There is a 1 l<* 1 2 bit ROM which contains a “micro code interpre- ter” (sic) that deals with the keypad commands etc. and three edge connectors for the expansion boards. For the power supply there is a clip at the top of the board that takes four A type batteries stuffed into a cardboard tube to keep them in line. I have only one option card, and that has a speaker and switch reg- ister, a row of LEDs and four 7-segment displays. There was also an option card which gave you a whole 1 K (1 024 words) of RAM, it also had a ROM card and an interface card with a UART and a parallel interface. All the latest accessories! The Dev kit PCB is really quite well done and looks as it may have been done with a PCB design package. Memory This kit has to have three chips each 256x4 bit to get its memory. The previous version had 1 2 256x1 bit chips. This was early days for memory chips and this emphasizes the problems they had with memory capacity, A main frame would only have 64 I K ■: ttr* CPU m m“i *"-d t* JSLBiHIT r.* rv» Own.** *£■ «n TTTT.nti f R£EET L IYXHL l£)M mti ,D ■ n w. H 11 5CT c H IE OSCOJT u OSCi'l H o** ElM fhcCPUdiAH V*,W- r* *di cn-:*i iiMprit } iHpa rt»nd tM MIMS i l+~QSC'0uTi.iM (•(T#*nH i art Comparison with the Z80, which is more or less contemporary, shows up something else. The folks at Zilog made a quantum leap and designed the Z80 as a complete microprocessor with only the data, address and relevant control lines brought out to pins. In con- trast the IM61 00 appears to be much more like part of a bit slice system integrated into a single chip, and in fact that that’s what it is. History Museum in Mountain View, CA [2]. It was once Princeton’s and NASA’s delight. Sort of perversely some IMS6100 pins are dedicated to certain functions like reading a 1 2-bit latch from the keypad. Strange to us, but in the context of the PDP8 completely natural. The PDP8 did not have an operating system as such (to start with) and had to be booted by using switches on the front panel. Other pins form part of the I/O, when an I/O cycle is started c0,c1 ,c2 along with the skip pin Carry information from the I/O device back into the CPU and determine which type of operation is to happen. The Skip input pin causes the next instruction to be skipped. Rivet- ing stuff! A ‘link’ output pin seems to be the Carry flag. The IM6100 uses the PDP-8 instruction set and so is very much a design that is halfway between the bit slice technology and the fully integrated (modern) processor. Rather primitive really and awkward to program, but the PDP8 was popular in its time and so a single chip version seemed a good idea. The IMS61 00 did find its way into some military applications. There was even a version of FORTRAN for it, but it was all killed off in 1 982 when the IBM PC was produced based on Intel’s 8088. (120161) [1 ] http://en.wikipedia.org/wiki/PDP-8 [2] www.computerhistory.org/ Bit Slice In a bit slice system the Central Processor Unit is a whole circuit board (i.e. 1 5 inches x 1 8 inches) full of dual in line (DIL) chips. Each element of the processor is implemented as separate chips, so for instance a 1 6-bit ALU (arithmetic logic unit) would be 4 off 74LS1 81 4-bit slices, likewise the State Machine was made up from LS74 D-type latches, and so on.. The circuit board had an edge connector which was the equivalent of pins on a micropro- cessor chip. Other circuit boards provided the memory, the I/O, the tape drive interface, etc. and the whole caboodle was mounted in a 1 9” rack frame with its own power supply. PDP8 legacy The IMS61 00 is a single chip version of DEC’S legendary PDP8 mini computer from the 1 960s, also pictured here for your amusement (rare / E version; source: WikiMedia Commons). Go check out the PDP8 on Wikipedia [1 ] and even better at the awesome Computer When colour monitors came along that created another great box full of circuit boards and another power supply. I had a Data General Eclipse for a while and it needed 1 5 amps at 240 volts to run it! elektor 06-2012 75 INFOTAINMENT Hexadoku Puzzle with an electronics touch We’re happy to present yet another Hexadoku for the puzzle fans among our readers (and their spouses/ girlfriends — hi there!). With 16x16 cells to look at a Hexadoku is a real challenge to solve. Enter the right numbers or letters A-F in the open boxes, find the solution, send it to us and you automatically enter the prize draw for one of four Elektor Shop vouchers. The instructions for this puzzle are straightforward. Fully geared to electronics fans and programmers, the Hexadoku puzzle employs the hexadecimal range 0 through F. In the diagram composed of 16x16 boxes, enter numbers such that all hexadecimal numbers 0 through F (that’s 0-9 and A-F) occur once only in each row, once Solve Hexadoku and win! Correct solutions received from the entire Elektor readership automati- cally enter a prize draw for one Elektor Shop voucher worth £80.00 and three Elektor Shop Vouchers worth £40.00 each, which should encour- age all Elektor readers to participate. in each column and in each of the 4x4 boxes (marked by the thicker black lines). A number of clues are given in the puzzle and these determine the start situation. Correct entries received enter a draw for a main prize and three lesser prizes. All you need to do is send us the numbers in the grey boxes. Participate! Before July 1 , 201 2, send your solution (the numbers in the grey box- es) by email, fax or post to Elektor Hexadoku - 1000, Great West Road - Brentford TW8 9HH United Kingdom. Fax (+44) 208 2614447 Email: hexadoku@elektor.com Prize winners The solution of the March 201 2 Hexadoku is: 78BE0. The Elektor £80.00 voucher has been awarded to Wolfgang Kallauch (Germany). The Elektor £40.00 vouchers have been awarded to Luis Fernando Fox Gonzalez (Spain), Francis Biette (France), and Bruno Couillard (Canada). Congratulations everyone! B 0 1 E 9 3 1 D 4 A E 2 8 C B 4 6 F i D C E 0 7 8 6 A 1 8 E C 5 1 A 8 3 B C i 3 E F 2 7 9 2 A 3 4 1 D B E F D 6 5 E 4 C 7 1 3 A E 1 0 B C 9 C 7 0 8 9 3 E 6 9 5 c A F 8 C 9 b 1 2 1 E 9 0 D 6 B 3 4 1 7 D F 9 E 9 7 2 E F 1 8 3 7 4 3 A E F 6 1 2 8 0 D 5 9 C B 8 5 9 E 2 0 C D B 6 3 1 A 4 7 F 2 6 D C 3 4 7 B 9 5 A F 0 1 8 E B F 0 1 9 A 5 8 4 C 7 E 2 3 D 6 5 8 1 2 0 9 D 3 7 A C 6 F B E 4 E 7 4 B A 5 1 2 3 D F 8 6 c 9 0 0 9 A D F 6 4 C E 1 2 B 7 5 3 8 C 3 F 6 7 8 B E 0 4 5 9 D 2 1 A 4 0 B 8 6 D 2 9 5 3 1 A E 7 F c D 2 c 3 1 B 8 4 F 0 E 7 9 A 6 5 9 E 7 F 5 3 0 A 6 2 D C B 8 4 1 1 A 6 5 C E F 7 8 9 B 4 3 D 0 2 F 1 2 0 4 C 9 5 A 7 6 3 8 E B D 3 D E 7 8 2 A 6 C B 4 0 1 F 5 9 6 c 5 9 B 1 3 F D E 8 2 4 0 A 7 A B 8 4 D 7 E 0 1 F 9 5 C 6 2 3 The competition is not open to employees of Elektor International Media, its business partners and/or associated publishing houses. 76 06-2012 elektor Buy it today! www.cc-webshop.com 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 IC841 ELEKTOR SHOWCASE NEW: ELEKTOR PREFERRED SUPPLIERS • now on www.elektor.com 365 days per year preferred suppliers online with up to date and relevant information, To become a preferred supplier contact Johan Dijk by j.dijk@elektor.com COAST ELECTRONICS www.coastelect.com Our site links to our E-Shop for Components, Gas Analyzers, Industrial parts, Kits, PICs, Development tools, Valves, Pneumatics, Short-range radio, REPRAP, LED lighting. ...and more. We offer contract design, programming, PCB layout. LCD Displays 2 line x 16 character LCD’s with Backlight £4.00 each + p&p 4 line x 16 character LCD’s with Backlight £3.50 each + p&p www.cstech.co.uk/elektor EASYSYNC LTD. www.easysync-ltd.com/ Supplier of communications and instrumentation products with specialist expertise in serial connectivity solutions based on USB, CAN and RS232/RS422/ RS485 interfaces. • USB to Serial RS232/RS422/RS485 converter cables. • CANbus solutions • Ethernet to Serial Adapters or to USB hubs. • USB based Logic Analysers, Oscilloscopes & Data Loggers. • OEM & ODM design services. ELNEC www.elnec.com Europe’s leading device \ programmers manufacturer: • reliable HW: 3 years warranty for most programmers • support over 69.000 devices • free SW updates • SW release: few times a week • excellent technical support: Algorithms On Request, On Demand SW • all products at stock / fast delivery 9 First Technology Transfer Ltd. FIRST TECHNOLOGY TRANSFER LTD. http://www.ftt.co.uk • Training and Consulting for IT, Embedded and Real Time Systems • Assembler, C, C++ (all levels) • 8, 16 and 32 bit microcontrollers • Microchip, ARM, Renesas,TI, Freescale • CMX, uCOSII, FreeRTOS, Linux operating systems • Ethernet, CAN, USB, TCP/IP, Zigbee, Bluetooth programming FLEXIPANEL LTD www.flexipanel.com TEAclippers - the smallest PIC programmers in the world, from £20 each: • Per-copy firmware sales • Firmware programming & archiving • In-the-field firmware updates • Protection from design theft by subcontractors FUTURE TECHNOLOGY DEVICES INTERNATIONAL LTD. www.ftdichip.com FTDI specialise in USB silicon, hardware and software solutions. • USB WHQL complaint drivers. • USB host and slave solutions. • Free firmware development tools. • USB IC’s, modules, cables and turnkey custom solutions. • World renowned FOC application support. USB MADE EASY & HEXWAX LTD www.hexwax.com World leaders in Driver-Free USB ICs: • USB- U ART /S PI/I 2 C bridges • TEAleaf-USB authentication dongles • expandlO-USB I/O USB expander • USB-FileSys flash drive with SPI interface • USB-DAQ data logging flash drive SCOPES and more Instruments A Rohde &Schwarz Company www.hameg.com Great Value in TEST & MEASUREMENT THE NEXTfr GENERATION OF a? IVAXSONAR The HRLV - MaxSonar Sensors •Amazing One-Millimeter Resolution •Simultaneous Multiple Sensor Operation •Superior Noise Rejection •Target Size Compensation for Accuracy •Temperature Compensation ($4.95) •Outputs now include TTL Serial $3495 (msrp) f www.MaxBotix.com ROBOT ELECTRONICS http://www.robot-electronics.co.uk Advanced Sensors and Electronics for Robotics • Ultrasonic Range Finders • Compass modules • Infra-Red Thermal sensors • Motor Controllers • Vision Systems • Wireless Telemetry Links • Embedded Controllers 3 ■r- ROBOTIQ http://www.robotiq.co.uk Build your own Robot! Fun for the whole family! Now, available in time for X-mas • Arduino Starter Kits *NEW!!* • Lego NXT Mindstorms • Affordable Embedded Linux Boards • Vex Robotics (kits and components) • POB Robots (kits and components) email: sales@robotiq.co.uk Tel: 020 8669 0769 www. elektor. com 78 06-2012 elektor products and services directory TYDER http://www.tyder.com • ONEoverT Digital Filter Design Software (Full version for only £30) • Design FIRs, HRs, NCOs, FFTs for DSPs and FPGAs • VHDL Code Generators • Makes DSP design simple • Download demos from website ELEKTOR Preferred Suppliers • Coast Electronics • CS Technology • Easysync • • Elnec • FTDI Chip • Robot Electronics • Surf to www.elektor.com 365 days per year preferred suppliers online with up to date and relevant information. Elektor OSPV [ S Open Source Personal Vehicle Last year we launched the Elektor Wheelie, a self-balancing personal transport device. Our new Elektor OSPV is based on the same concept, but with the difference that it’s for indoors, it’s easy to steer, it’s light and foldable and... it’s open source. You can configure or modify it to suit your wishes! The OSPV is primarily intended for moving people, but it doesn’t have to be limited to that. A variety of other uses are conceivable, ranging from an electric wheelbarrow to a handy motorised shopping cart. This is where the advantages of the open source approach come to the fore! Price Slashed! Important specifications: Size: 1 20x47x47 cm / 47.2x1 8.5x1 8.5 inch (HxWxD) Weight: 25 kg (25lbs) Maximum load: 90 kg (200 lbs) Motors: DC 2 x 200 W Wheels: Polyurethane, 1 4 cm dia. (5.5 inch) Drive train: HDT toothed belt Max. speed: 1 5 km/h (9.3 mph) Range: 8 km (5 miles) The kit comprises two 200-watt DC drive motors, two 1 2 -V lead-acid AGM batteries, battery charger, two wheels Polyurethane 14 cm wheels, casing, control lever and fully assembled and tested control board with sensor board. Take out a free subscription to Elektor Weekly Do you want to stay up to date with electronics and information technology? Always looking for useful hints, tips and interesting offers? Subscribe now to Elektor Weekly, the free Elektor Newsletter. -> Hdii'.T Erittor AesdBfiW ptitwnh^.. • ?..-ine-ihip wilh i nur iif I ii ill I riuit nun i lObilHil s-wdin S* p TfPI P“* ! ■ -'T r '■ » * '«■*»■- r *'J| r F -Mil fc !-»<*■ ►* *-**-■ ■+ ■— » r f ■*•— « ■-* ; t— - i jit-: j it:tJ rf rktinn hiik 1 ihrri Your benefits: The latest news on electronics in your own mailbox each Friday Free access to the News Archive on the Elektor website You’re authorized to post replies and new topics in our forum Register today on www.elektor.com/newsletter elektor 06-2012 79 SHOP BOOKS, CD-ROMs, DVDs, KITS & MODULES Limited Period Offer for Elektor Subscribers 1 5% DISCOUNT elektor.comliune WWW A world of electronics from a single shop! Associated 60-piece Starter Kit available Fun with LEDs This booklet presents more than twenty exciting projects covering LEDs, aimed at young & old. From an Air Writer, a Party Light, Running Lights, a LED Fader right up to a Christmas Tree. Use this book to replicate various projects and then put them into practice. To give you a head start each project is supported by a brief explanation, schematics and photos. In addition, the free support page on the Elektor website has a few inspiring video links available that elaborate on the projects. A couple of projects employ the popular Arduino microcontroller board that’s graced by a galaxy of open source applications. The optional 60-piece Starter Kit available with this book is a great way to get circuits built up and tested on a breadboard, i.e. without soldering. 96 pages • ISBN 978-1-907920-05-97 • £16.95 • US$38.00 Creative solutions for all areas of electronics 31 1 Circuits 31 1 Circuits is the twelfth volume in Elek- tor’s renowned 30x series. This book con- tains circuits, design ideas, tips and tricks from all areas of electronics: audio & video, computers & microcontrollers, radio, hob- by & modelling, home & garden, power supplies & batteries, test & measurement, software, not forgetting a section'miscel- laneous’ for everything that doesn’t fit in one of the other categories. 31 1 Circuits of- fers many complete solutions as well as use- ful starting points for your own projects. 420 pages • ISBN 978-1-907920-08-0 £29.50 • US $47.60 UkibanE h-Tirp* □ le,,,0, LabWorX 1 LabWorX: Straight from the Lab to your Brain Mastering the l 2 C Bus Mastering the l 2 C Bus is the first book in the LabWorX collection. It takes you on an exploratory journey of the l 2 C Bus and its applications. Besides the Bus protocol plenty of attention is given to the practical applications and designing a solid system. The most common l 2 C compatible chip classes are covered in detail. Two expe- rimentation boards are available that allow for rapid prototype development. These are completed by a USB to l 2 C probe and a software framework to control l 2 C devices from your computer. 248 pages • ISBN 978-0-905705-98-9 £29.50 • US $47.60 8 o Prices and item descriptions subject to change. E. & O.E 06-2012 elektor Processor design in the real world Microprocessor Design using Verilog HDL This book is a practical guide to processor design in the real world. It presents the Verilog HDL in an easily digestible fashion and serves as a thorough introduction about reducing a computer architecture and instruction set to practice. You’re led through the microprocessor design pro- cess from the start to finish, and essential topics ranging from writing in Verilog to debugging and testing are laid bare. 337 pages • 978-0-9630133-5-4 £27.90 • US $45.00 Controller Area Network Projects Free mikroC compiler CD-ROM included Controller Area Network Projects The aim of the book is to teach you the ba- sic principles of CAN networks and in addi- tion the development of microcontroller based projects using the CAN bus. You will learn howto design microcontroller based CAN bus nodes, build a CAN bus, develop high-level programs, and then exchange data in real-time over the bus. You will also learn how to build microcontroller hard- ware and interface it to LEDs, LCDs, and A/D converters. 260 pages • ISBN 978-1-907920-04-2 £29.50 • US $47.60 n. ywju wn PC Visual Processing Ml if Recognition System in C* PP-bK - AO Bestseller! A comprehensive and practical how-to guide Design your own PC Visual Processing and Recognition System in c# This book is aimed at Engineers, Scientists and enthusiasts with developed program- ming skills or with a strong interest in im- age processing technology on a PC. Written using Microsoft C# and utilizing object-oriented practices, this book is a comprehensive and practical how-to guide. The key focus is on modern image processing techniques with useful and practical application examples to produce high-quality image processing software. Analysis starts with a detailed review of the fundamentals of image processing. It progresses to explain and explore the practical uses of two highly sophisticated and freely downloadable, open source im- age processing libraries; AForge.NET and Emgu.CV, utilizing dotnet technology within the Microsoft Visual Studio en- vironment. All code examples used are available - free of charge - from the Elek- tor website; you can easily create and develop your own results to demonstrate the concepts and techniques explained. 307 pages • ISBN 978-1-907920-09-7 £35.50 • US$57.30 isihbi More information on the Elektor Website: www.elektor.com Elektor Regus Brentford 1 000 Great West Road Brentford TW8 9HH United Kingdom Tel.: +44 20 8261 4509 Fax: +44 20 8261 4447 Email: order@elektor.com r 1 1 0 issues, more than 2,1 00 articles dvd Elektor 1990 through 1999 This DVD-ROM contains the full range of 1 990-1 999 volumes (all 1 1 0 issues) of Elektor Electronics magazine (PDF). The more than 2,100 separate articles have been classified chronologically by their dates of publication (month/year), but are also listed alphabetically by topic. A compre- hensive index enables you to search the entire DVD. What’s more, this DVD also contains the entire The Elektor Datasheet Collection 1 ...5’ CD-ROM series. ISBN 978-0-905705-76-7 £69.00 • US$111.30 A whole year of Elektor magazine onto a single disk DVD Elektor 201 1 Theyear volume DVD/CD-ROMs are among the most popular items in Elektor’s product range. This DVD-ROM contains all editorial articles published in Volume 201 1 of the English, American, Spanish, Dutch, French and German editions of Elektor. Using the supplied Adobe Reader program, articles are presented in the same layout as originally found in the magazine. An extensive search machine is available to locate keywords in any article. With this DVD you can also produce hard copy of PCB layouts at printer resolution, adapt PCB layouts using your favourite graphics program, zoom in /out on selected PCB areas and export circuit dia- grams and illustrations to other programs. ISBN 978-90-5381-276-1 £23.50 • US$37.90 elektor 06-2012 81 SHOP BOOKS, CD-ROMs, DVDs, KITS & MODULES More than 70,000 components cd Elektor’s Components ! Database 6 This CD-ROM gives you easy access to de- sign data for over 7,800 ICs, more than 35,600 transistors, FETs, thyristors and triacs, just under 25,000 diodes and 1 ,800 optocouplers. The program package consists of eight databanks covering ICs, transistors, diodes and optocouplers. A further eleven applications cover the calcu- lation of, for example, zener diode series re- sistors, voltage regulators, voltage dividers and AMV’s.Acolour band decoder is includ- ed for determining resistor and inductor values. All databank applications are fully interactive, allowing the user to add, edit and complete component data. ISBN 978-90-5381 -258-7 £24.90 • US $40.20 Circuits, ideas, tips and tricks from Elektor cd 1001 Circuits This CD-ROM contains more than 1000 circuits, ideas, tips and tricks from the Summer Circuits issues 2001 -201 0 of Elek- tor, supplemented with various other small projects, including all circuit diagrams, descriptions, component lists and full- sized layouts. The articles are grouped alphabetically in nine different sections: audio & video, computer & microcontroller, hobby & modelling, home & garden, high frequency, power supply, robotics, test & measurement and of course a section miscellaneous for everything that didn’t fit in one of the other sections. ISBN 978-1 -907920-06-6 £34.50 • US $55.70 Embedded Linux Made Easy (May 2012) Today Linux can be found running on all sorts of devices, even coffee machines. Many electronics enthusiasts will be keen to use Linux as the basis of a new microcon- troller project, but the apparent comple- xity of the operating system and the high price of development boards has been a hurdle. Here Elektor solves both these problems, with a beginners’ course accom- panied by a compact and inexpensive populated and tested circuit board. This board includes everything necessary for a modern embedded project: a USB inter- face, an SD card connection and various other expansion options. It is also easy to hookthe board up to an Ethernet network. Art.# 120026-91 • £57.80 • US$93.30 RS-485 Switch Board (April 201 2) Our ElektorBus series has shown how much interest there is in home automa- tion applications. This small circuit board can switch two AC (230 VAC) loads. Also, two of the inputs to the on-board micro- controller are brought out to terminals so that the state of two switches can be read back. The board works with the Elektor- Bus and so is an ideal building-blockfora home automation system controlled from a PC, tablet or smartphone. RS485-Relay board, assembled and tested Art.# 11 0727-91 • £40.00 • US$56.00 AVR Software Defined Radio (March 201 2) This package consists of the three boards associated with the AVR Software Defined Radio articles series in Elektor, which is built around practical experiments. The first board, which includes an ATtiny231 3, a 20 MHz oscillator and an R-2R DAC, will be used to make a signal generator. The second board will fish signals out of the ether. It contains all the hardware needed to make a digital software-defined radio (SDR), with an RS-232 interface, an LCD panel, and a 20 MHz VCXO (voltage-con- trolled crystal oscillator), which can be locked to a reference signal. The third board provides an active ferrite antenna. Signal Generator + Universal Receiver + Active Antenna: PCBs and all components + USB-FT232R breakout-board Art.# 100182-72 • £99.90 • US$133.00 AndroPod (February 2012) With their high-resolution touchscreens, ample computing power, WLAN support and telephone functions, Android smartphones and tablets are ideal for use as control centres in your own projects. However, up to now it has been rather difficult to connect them to exter- nal circuitry. Our AndroPod interface board, which adds a serial TTL port and an RS485 port to the picture, changes this situation. Andropod module with RS485 Extension Art.# 11 0405-91 • £53.35 • US$74.70 82 Prices and item descriptions subject to change. E. & O.E 06-2012 elektor June 201 2 (No. 426) L + + + Product Shortlist June: See www.elektor.com + + + May 201 2 (No. 425) Embedded Linux Made Easy (1 ) 1 20026-91 .... PCB, populated and tested Elektor Linux Board 57.80 93.30 Platino Controlled by LabVIEW (1 ) 1 00892-1 Printed circuit board www.elektorpcbservice.com Preamplifier 201 2 (2) 1 1 0650-2 Printed circuit board www.elektorpcbservice.com Lossless Load 1 1 0755-1 Printed circuit board www.elektorpcbservice.com AVR Software Defined Radio (3) 1 001 82-1 Printed circuit board www.elektorpcbservice.com 1 001 82-71 .... Kit of parts Active Antenna PCB plus all components, 24,5 meter brass wire included 25.15 33.20 1 001 82-72 .... Signal-Generator + Universal Receiver + Active Antenna: PCBs and all components + USB-FT232 breakout-board 99.90 1 33.00 April 201 2 (No. 424) Preamplifier 201 2(1) 110650-1 Line-ln/Tone/Volume board www.elektorpcbservice.com LED Touch Panel 070558-1 Controller board www.elektorpcbservice.com 070558-2 LED board www.elektorpcbservice.com AVR Software Defined Radio (2) 100181-1 Receiver board www.elektorpcbservice.com 100181-71 .... Universal Receiver: PCB and all components 49.90 65.90 100182-72 .... Signal-Generator + Universal Receiver + Active Antenna: PCBs and all components + USB-FT232R breakout-board 99.90 1 33.00 Thermometer using Giant Gottlieb® Displays 1 1 0673-1 Printed circuit board www.elektorpcbservice.com 1 1 0673-41 .... ATTINY231 3-20PU, programmed 8.85 1 2.40 RS-485 Switch Board 1 1 0727-1 Printed circuit board www.elektorpcbservice.com 1 1 0727-91 .... RS485-Relay board, assembled and tested 40.00 56.00 110727-92 ....Set of 3 RS485-Relay boards 106.75 149.50 March 201 2 (No. 423) AVR Software Defined Radio (1 ) 080083-71 .... USB-AVR Programmer: SMD stuffed board and all components 23.50... ....47.00 100180-71 ... Signal Generator kit; PCB and all components 25.15... ....33.20 100181-71 ... Universal Receiver: PCB and all components 62.95... ....83.10 100182-71 ... Active Antenna: PCB and all components 25.15... ....33.20 100182-72... Signal Generator + Universal Receiver + Active Antenna: PCBs and all components + USB-FT232R breakout-board 99.90... ..133.00 110553-91 ... Populated and tested BOB 12.90... ....19.99 AndroPod (2) 110258-91 ... USB/RS485 Converter: ready assembled module 22.20... ....35.70 110405-91 ... Andropod module with RS485 Extension 53.35... ....74.70 110553-91 ... Populated and tested BOB 12.90... ....20.90 120103-92... 1 .8m USB 2.0 A male to USB micro-B 5 pin black cable . 3.50... 4.90 120103-94... 5V / 1 A (5W) PSU with micro-USB connector ..8.00... ....11.20 February 201 2 (No. 422) AndroPod (1) 1 1 0258-91 .... USB/RS485 converter, ready-made module 22.20... ....35.70 110405-91 ... Andropod module with RS485 Extension 53.35... ....74.70 110553-91 ... USB-FT232R breakout board, assembed and tested .. 12.90... ....20.90 120103-92... 5-way cable USB 2.0 A male to USB micro-B, black ..3.50... 5.70 120103-94... 5V / 1 A (5W) PSU with micro-USB connector ..8.00... ....12.90 V y Bestsellers f Design your own PC Visual Processing A o o CO O Q£ I O Q Q U od V/) 1 2 3 4 5 1 2 3 4 5 1 2^ 3 4 5 and Recognition System in c# ISBN 978-1 -907920-09-7 .... £35.50 US $57.30 Mastering the l 2 C Bus ISBN 978-0-905705-98-9.... £29.50 US $47.60 Microprocessor Design using Verilog HDL ISBN 978-0-9630133-5-4.... £27.90 US $45.00 Controller Area Network Projects ISBN 978-1 -907920-04-2 .... £29.50 US $47.60 31 1 Circuits ISBN 978-1 -907920-08-0 .... £29.50 US $47.60 DVD Elektor 201 1 ISBN 978-90-5381 -276-1 .... £23.50 US $37.90 CD 1001 Circuits ISBN 978-1 -907920-06-6.... £34.50 US $55.70 DVD Elektor 1 990 through 1 999 ISBN 978-0-905705-76-7 .... £69.00 ...US $1 1 1 .30 Masterclass DVD High-End Valve Amplifiers ISBN 978-0-905705-86-6.... £24.90 US $40.20 CD Elektor’s Components Database 6 ISBN 978-90-5381 -258-7 .... £24.90 US $40.20 AVR Software Defined Radio Art. #1001 82-72 £99.90 ...US $1 33.00 Embedded Linux Made Easy Art. # 1 20026-91 £57.80 US $93.30 Improved Radiation Meter Art. # 1 1 0538-71 £35.50 US $57.30 FT232R USB/Serial Bridge/BOB Art. # 1 1 0553-91 £1 2.90 US $20.90 AndroPod Art. # 1 1 0405-91 £53.35 US$74.70 J Order quickly and securely through www.elektor.com/shop or use the Order Form near the end of the magazine! Elektor Reg us Brentford 1 000 Great West Road Brentford TW8 9HH • United Kingdom Tel. +44 20 8261 4509 Fax +44 20 8261 4447 Email: order@elektor.com elektor 06-2012 83 COMING ATTRACTIONS NEXT MONTH IN ELEKTOR COMING ATTRACTIONS Elektor Project Generator Edition 2012 The annual extra-thick edition with an extra bunch of circuits Next month we publish the 36th (say, thirty-sixth) edition of Elektor’s famed annual double edition for the months of July and August. Our readers love & collect the PCE — our competitors dread it and never managed to publish anything remotely similar. Our editors and designers are now burning their midnight oil to make sure you can enjoy lots of pages with detailed descriptions and inventive electronics applications. Don’t miss it, this jumbo edition of Elektor packed with gem articles & projects ... like: Programmable Power Switch Versatile AVR I/O Module Square Wave Generator Inrush Current Limiter Arduino’d Laser Beam LED Dimmer Shoo Heron! ATM18 Hygrometer USB Power Monitor Motorbike Alarm Loudspeaker Test System Knitting Rev Counter Battery Rejuvenator Arduino’d LCD RJ45 Cable Tester Special Summer Project Lap Counter for Swim Athletes Accelerometer for accurate personal lap counting Elektor UK/Europeon July & August 2012 edition: on sale June 27, 2072. Elektor USA July & August 2012 edition: published June 18, 2012. w.elektor.com www.elektor.com www.elektor.com www.elektor.com www.elektor.com wv Elektor on the web All magazine articles back to volume 2000 are available individually in pdf format against e-credits. Article summaries and compo- nent lists (if applicable) can be instantly viewed to help you positively identify an article. Article related items and resources are also shown, including software downloads, hyperlinks, circuit boards, programmed ICs and corrections and updates if applicable. In the Elektor Shop you’ll find all other products sold by the publishers, like CD-ROMs, DVDs, kits, modules, equipment, tools and books. A powerful search function allows you to search for items and references across the entire website. Also on the Elektor website: • Electronics news and Elektor announcements • Readers Forum • PCB, software and e-magazine downloads • Time limited offers • FAQ, Author Guidelines and Contact Qfektor ■I""' . Mujin’i ghdg- FVb'tnfei -.fliH Fw-urr. (4 n*r * M Ml Chat. V £ ElMl L r - j L'l-L-C l^fllrtu bun 15'HOfS'COlJWT AND FREE SHIPPING I 9 &Hi EdHGUHT rn c*i ■ inn rairvavnfip *r i pri E fa m Diuntar jtiLf (a. m« ***** 0 Rinesas RUB Green Energy Chsllenge m2 L-.r .-.±r ir-M «±mj 84 06-2012 elektor Description Price each Qty. Total Order Code Fun with LEDs £ 16.95 Starter Kit Fun with LEDs fflSEl £22 - 2 ° Design your own PC Visual Processing and Recognition System in C# £ 35.50 Microprocessor Design using Verilog HDL £ 27.90 Controller Area Network Projects £ 29.50 LabWorX - Mastering the PC Bus £ 29.50 DVD Elektor 2011 £ 23.50 Prices and item descriptions subject to change. The publishers reserve the right to change prices without prior notification. Prices and item descriptions shown here supersede those in previous issues. E. & O.E. Sub-total P&P Total paid Name Address + Post code Tel. Email Date Signature EL06 Yes, I am taking out an annual membership to Elektor and receive the E-book Microcontroller Basics totally free!* (Please fill in your emailaddress below) I would like: Microcohirolur Basics Standard Membership (1 1 issues) I I Plus Membership (1 1 issues plus the Elektor Volume 201 2 DVD-ROM + exclusive access to www.elektor-plus.com ) * Offer available to people who have not held a membership to Elektor during the last 12 months. Offer subject to availability. See reverse for rates and conditions. Name Address + Post code Tel. Email Date Signature EL06 METHOD OF PAYMENT (see reverse before ticking as appropriate) □ Bank transfer | Cheque (UK-resident customers ONLY) n visa □ EUROCARD MasterCard Expiry date: Verification code: Please send this order form to* (see reverse for conditions) Elektor Reg us Brentford 1 000 Great West Road Brentford TW8 9HH United Kingdom Tel.: +44 20 8261 4509 Fax: +44 20 8261 4447 www.elektor.com order@elektor.com *USA and Canada residents should use $ prices, and send the order form to: Elektor US 4 Park Street Vernon CT 06066 USA Phone: 860-875-2199 Fax: 860-871-0411 E-mail: order@elektor.com METHOD OF PAYMENT (see reverse before ticking as appropriate) □ Bank transfer | Cheque (UK-resident customers ONLY) n visa □ EUROCARD MasterCard Expiry date: Verification code: Please send this order form to Elektor Regus Brentford 1 000 Great West Road Brentford TW8 9HH United Kingdom Tel.: +44 20 8261 4509 Fax: +44 20 8261 4447 www. e I e kto r. co m service@elektor.com ORDERING INSTRUCTIONS, P&P CHARGES All orders, except for memberships (for which see below), must be sent BY POST or FAX to our Brentford address using the Order Form overleaf. Online ordering: www.elektor.com/shop Readers in the USA and Canada should send orders, except for memberships (for which see below), to the USA address given on the order form. Please apply to Elektor US for applicable P&P charges. Please allow 4-6 weeks for delivery. Orders placed on our Brentford office must include P&P charges (Priority or Standard) as follows: Europe: £6.00 (Standard) or £7.00 (Priority) Outside Europe: £9.00 (Standard) or £1 1 .00 (Priority) HOW TO PAY All orders must be accompanied by the full payment, including postage and packing charges as stated above or advised by Customer Services staff. Bank transfer into account no. 4027021 1 held by Elektor International Media BV with The Royal Bank of Scotland, London. IBAN: CB96 ABNA 4050 3040 2702 1 1 . BIC: ABNAGB2L. Currency: sterling (UKP). Please ensure your full name and address gets communicated to us. Cheque sent by post, made payable to Elektor Electronics. We can only accept sterling cheques and bank drafts from UK-resident customers or members. We regret that no cheques can be accepted from customers or members in any other country. GCredit card VISA and MasterCard can be processed by mail, email, web, fax and telephone. Online ordering through our website is SSL-protected for your security. COMPONENTS Components for projects appearing in Elektor are usually available from certain advertisers in this magazine. If difficulties in the supply of components are envisaged, a source will normally be advised in the article. Note, however, that the source(s) given is (are) not exclusive. TERMS OF BUSINESS Delivery Although every effort will be made to dispatch your order within 2-3 weeks from receipt of your instructions, we can not guaran- tee this time scale for all orders. Returns Faulty goods or goods sent in error may be returned for replacement or refund, but not before obtaining our consent. All goods returned should be packed securely in a padded bag or box, enclosing a covering letter stating the dispatch note number. If the goods are returned because of a mistake on our part, we will refund the return postage. Damaged goods Claims for damaged goods must be received at our Brentford office within 10-days (UK); 14-days (Europe) or 21 -days (all other countries). Cancelled orders All cancelled orders will be subject to a 1 0% handling charge with a minimum charge of £5.00. Patents Patent protection may exist in respect of circuits, devices, components, and so on, described in our books and magazines. Elektor does not accept responsi- bility or liability for failing to identify such patent or other protection. Copyright All drawings, photographs, articles, printed circuit boards, programmed integrated circuits, diskettes and software carriers published in our books and magazines (other than in third-party adverti- sements) are copyright and may not be reproduced or transmitted in any form or by any means, including photocopying and recording, in whole or in part, without the prior permission of Elektor in writing. Such written permission must also be obtained before any part of these publications is stored in a retrieval system of any nature. Notwithstanding the above, printed-circuit boards may be produced for private and personal use without prior permission. Limitation of liability Elektor shall not be liable in contract, tort, or otherwise, for any loss or damage suffered by the purchaser whatsoever or howsoever arising out of, or in connexion with, the supply of goods or services by Elektor other than to supply goods as described or, at the option of Elektor, to refund the purchaser any money paid in respect of the goods. Law Any question relating to the supply of goods and services by Elektor shall be determined in all respects by the laws of England. January 2012 MEMBERSHIP RATES FOR ANNUAL MEMBERSHIP MEMBERSHIP CONDITIONS United Kingdom & Ireland Standard £54.00 Plus £66.50 Surface Mail Rest of the World £68.50 £81.00 Airmail Rest of the World £86.00 £98.50 USA & Canada | See www.elektor.com/usa for special offers HOW TO PAY Bank transfer into account no. 4027021 1 held by Elektor International Media BV with The Royal Bank of Scotland, London. IBAN: GB96 ABNA 4050 3040 2702 1 1 . BIC: ABNAGB2L. Currency: sterling (UKP). Please ensure your full name and address gets communicated to us. Cheque sent by post, made payable to Elektor Electronics. We can only accept sterling cheques and bank drafts from UK-resident customers or members. We regret that no cheques can be accepted from customers or members in any other country. Credit card VISA and MasterCard can be processed by mail, email, web, fax and telephone. Online ordering through our website is SSL-protected for your security. The standard membership order period is twelve months. If a permanent change of address during the membership period means that copies have to be despatched by a more expensive service, no extra charge will be made. Conversely, no refund will be made, nor expiry date extended, if a change of address allows the use of a cheaper service. Student applications, which qualify for a 20% (twenty per cent) reduction in current rates, must be supported by evidence of studentship signed by the head of the college, school or university faculty. A standard Student Membership costs £43.20, a Student Plus Membership costs £55.70 (UK only). Please note that new memberships take about four weeks from receipt of order to become effective. Cancelled memberships will be subject to a charge of 25% (twenty-five per cent) of the full membership price or £7.50, whichever is the higher, plus the cost of any issues already dispatched. Subsciptions cannot be cancelled after they have run for six months or more. January 2012 i f »v9- ou urtwci ci>«AHivy nr in tapK niMti^u 1 Iwuhi iKa ’ iH . jLh ^ tUj LOCATION U'MdSMrt pj»u a t'Jt-jC ii DECEMBER: 20ii ISSUE 257 Build a cl MCU-Based Sleep-Stage Checkout Ana | ysis Hardware with a usi DIY Smart Electronic Electronic Load Design Thermal a Embedded Linux System Platforms AnMCU-E Network c interference Immunity for Electronic Designs M hCMt 1 DK9 AOV pWifi hhnrsrt M«.ji Joystick Control with I Bluetooth Connectivity ^ ■ ivuerc Design Inside I ho Mind qS a Microprocessor Devs lopcf .7 Analog Gipolar T*ch la Oigjtad Design !i Tftfe Uwf,*Mi * 01 Vtnbg HDL U DrtJgr. Lli-iva RrOflrArr.m«li Loflk K And Ww* Sfimwaw S unpliTtiKt AvtanWiyi Khkafirt K?ji«Miv* r««Aa Subscribe now to the leading computer applications magazine specializing in embedded systems and design! 1 2 issues per year for just Digital: $50 : : Print: $75 : : Combo (Print + Digital): $110 Select your personal subscription at ROUTE WITH PROTEUS PCB DESIGN Our completely new manual router makes placing tracks quick and intuitive. During track placement the route will follow the mouse wherever possible and will intelligently move around obstacles while obeying the design rules. All versions of Proteus also include an integrated world class shape based auto-router as standard. PROTEUS DESIGN SUITE Features: ■ Hardware Accelerated Performance. ■ Board Autoplacement & Gateswap Optimiser. ■ Unique Thru-View™ Board Transparency. ■ Direct CADCAM, ODB++, IDF & PDF Output. . Over 35k Schematic & PCB library parts. ■ Integrated 3D Viewer with 3DS and DXF export. ■ Integrated Shape Based Auto-router. ■ Mixed Mode SPICE Simulation Engine. ■ Flexible Design Rule Management. ■ Co-Simulation of PIC, AVR, 8051 and ARM7. . Polygonal and Split Power Plane Support. ■ Direct Technical Support at no additional cost. Prices start from just £150 exc. VAT & delivery Electronics Labcenter Electronics Ltd. 53-55 Main Street, Grassington, North Yorks. BD23 5AA. Registered in England 4692454 Tel: +44 (0)1756 753440, Email: info@labcenter.com Visit our website or phone 01756 753440 for more details