www.elektor.com AUS$ 14.90 - NZ$17.90 - SAR 105.95 " NOK102 £4.90 * I April 2012 Parti line-in *tonei* volume* output board RS-485 Switch Board - ElektorBus Relay Modul Automation application switches two AC powered loads Lab PSU for Power to the microcontroller circuits! RFID Deep into Mifare/Oyster and i< 770268 451 73 0 4 9 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, 150|jnn 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 We are PIC freaks. Just like you. Easily create GLCD or TFT user interfaces using Visual TFT Tm and Visual GLCD™ software. / ^ Just focus on design and code will be created for you automatically. / / / / GUI design made easy Choose the compiler in programming language you love the most - mikroC™, mikroBasic™ or mikroPascal™. With over 500 library functions, lots of examples, a great help file, you will get the job done quickly. mikroProg™ is a fast USB 2.0 programmer with rnikrolCD Tm hardware In-Circuit Debugger. It supports over 570 PIC®, ‘ N dsPIC® and PIC32® N devices. \ \ \ COMPLETE EasyPIC PRO™ v7 is the best place for 3.3V and 5V high-pin count PIC18® devices. It features on-board ICD, three rnikroBUS Tm sockets, and lots of modules. / mikromedia™ / for PIC® 18FJ 7 is a real swiss army knife for multimedia developers. It is packed with lots of multimedia peripherals. EasyPIC™ v7 is the seventh generation of our famous PIC development board. With 3.3V and 5V dual power supply it supports over 250 PIC microcontrollers, and features on-board ICD, two rnikroBUS Tm sockets, and lots of modules. Over 200 IDC10 and mikroBUS™ compatible Click™ additional boards are here to meet your development ideas. Mikroilektronika DEVELOPMENTTOOLS I COMPILERS I BOOKS GET IT NOW www.mikroe.com In the beginning was the noise One of the naturally evolved missions of Elektor magazine is to present a mix of analogue and digital electronics, with and without microcontrollers, for beginners and professionals alike. Every month, every electronics fan on our readership should be captured, triggered, surprised, impressed or irritated by at least one article he or she can explore for educational or professional use. In this month’s edition the article that attracts me most is the new high-end audio preamp called Preamplifier 2012. Old time Elektor readers may remember an earlier design, also with a short name that makes a statement: “The Preamp” from 1986. Twenty six years on, we present another audio control preamplifier where signal quality is paramount. This time, special attention is given to noise reduction tech- niques like Low Impedance Design, but still no frills, bells and whistles, and everything aimed to achieve the purest possible processing of stereo audio signals between the source (MD/MM record player or CD player) and the power amp. Unlike the 1986 “Preamp”, the 2012 version was designed by an external contributor, Douglas Self, in cooperation with Elektor (audio) Labs staffers for the practical implementation like PCB design and professional testing. Douglas’ and our goals are essentially the same, so I feel confident in adding the latest design to the series of legendary high-end audio designs published by Elektor these past 40 years or so. For some of the highly interesting techni- cal details of the Preamplifier 2012, dash off to page 16 where “all is revealed & more to follow”. The beauty of the project is in the total absence of any luxury: you’ll search in vain for a remote control, a USB connector, a display or a Chinese switch-mode PSU. Instead, you’ll only find what it takes to enjoy music in its purest form. Isn’t that’s what it’s all about? True audiophiles will concur I’m sure, others might shake their heads wearily. They probably don’t know what they are missing! Now, to return quickly to today’s harsh reality of virtual dominance by microcon- trollers and software: rest assured that there’s plenty of it in this edition. So if you’re not captured by high-end audio, then skip that one article on antediluvian analogue audio electronics. No offence! Enjoy reading this edition, 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. 16 Preamplifier 2012 (1) Introducing our new extremely high end audio preamp and kicking off with the Line-In, Tone, Volume and Output sections. 24 RFID Reader Hacks Among other types of RFID card, the MIFARE IS 0 14443 is worth exploring using a hacked or reverse-engineered reader device. 30 Lab PSU for Embedded Developers This versatile power supply got specially designed with the needs of the microcontroller enthusiast in mind. 34 LED Touch Panel Utilizing IR light bouncing off a fingertip to make a surprisingly reliable touch sensor for easy use in embedded applications. 39 What are you Doing? This month we interviewed Eben Upton to find out what the $25 Raspberry Pi computer is all about. 40 Electronics for Starters (4) This month we explore and learn how bipolar transistors and junction FETs can be used as constant-current sources. 45 E-Labs Inside: Hackerspace #42 A visit, camera in hand, to one of Holland’s most active hackerspace groups. 1 1 iffl M: 77* j [7 S3 ■ fl 1 ’ I' » 4 04-2012 elektor '''/kJ CONTENTS Volume 38 April 2012 no. 424 16 Preamplifier 2012 (1) Besides presenting a truly high end audio control preamplifier for home con- struction, this article series also aims to show how low-impedance design and multiple-amplifier techniques can be used to significantly reduce the noise le- vels in analogue circuitry. The result of the design effort is a top-notch preamp that’s brilliant not just sonically but also in terms of cost/performance ratio. 46 AVR Software Defined Radio (2) The series continues this month with digital sampling in theory and practice, complete with a Universal Receiver board you can build. 56 Thermometer using Giant Gottlieb® Displays Ever seen a pair of 4-inch diameter pinball score wheels indicating the water temperature in a French swimming pool? 24 RFID Reader Hacks This article tells you how to modify an existing RFID reader so it can read MI- FARE ISO 14443 cards. Alternatively, reverse engineering may be applied to build the entire reader yourself and you are ready to explore the technology behind MIFARE type cards including Oyster and others using similar protocols. 62 RS-485 Switch Board This relay module for the ElektorBus enables AC powered loads to be switched remotely, say, from a smartphone. 68 The RL78 Microcontroller A look at the hardware and software that comprises Renesas’ RL78 platform of 16- bit MCUs. We also review the awesome starter kit for the RL7/G13. 46 AVR Software Defined Radio (2) Here we will usean ATmega88to sample amplitude- and phase-modulated sig- nals, which we can either synthesise ourselves or fish out of the ether. We can even operate at frequencies of above 100 kHz. This article also describes the Universal Receiver Board used for a number of experiments. 72 Component Tips Raymond’s Pick of the Month: isolation devices ADM2587E and ADUM3160 73 Hexadoku Elektor’s monthly puzzle with an electronics touch. 74 Retronics: Philips EL3581 Dictaphone (ca. i960) Series Editor: Jan Buiting 56 Thermometer using Giant Gottlieb® Displays Here’s a stunning application of reels of a 1960s pinball scoring unit - a swim- ming pool thermometer! Once the temperature is displayed, the consumption of the circuit drops to zero, but the temperature display remains perfectly visi- ble. There are no batteries (dry or rechargeable), adjustments, or maintenance. 77 Gerard’s Columns: Conceptual Engineering The monthly contribution from our US columnist Gerard Fonte. 84 Coming Attractions Next month in Elektor magazine. elektor 04-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, Jeanine Opreij, 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 THE WORLDS SOUftCt £MA£Oe£t) EuECl HOWC !■ ENGINEEHiriG INFOHMATlOH VOICES# COIL Our international teams United Kingdom Wisse Hettinga +31(0)464389428 w.hettinga@elektor.com USA Hugo Vanhaecke +1 860-875-2199 h.vanhaecke@elektor.com Germany Ferdinand te Walvaart +31 46 4389417 f.tewalvaart@elektor.de France Denis Meyer +31 46 4389435 d.meyer@elektor.fr Netherlands Harry Baggen +31 46 4389429 h.baggen@elektor.nl Spain Eduardo Corral +34 91101 9395 e.corral@elektor.es Italy Mauriziodel Corso +39 2.66504755 m.delcorso@inware.it Sweden Wisse Hettinga +31 46 4389428 w.hettinga@elektor.com Brazil Joao Martins +551141950363 joao.martins@editorialbolina.com Portugal Joao Martins +351 21413-1600 joao.martins@editorialbolina.com India Sunil D. Malekar +9 1 9833168815 ts@elektor.in Russia Nataliya Melnikova 8107(965)3953336 nataliya-m-larionova@yandex.ru Turkey Zeynep Koksal +90532 2774826 zkoksal@beti.com.tr South Africa Johan Dijk +27 78 2330 694 / +31 6 109 31 926 j.dijk@elektor.com China Cees Baay +86 21 6445 2811 CeesBaay@gmail.com Volume 38, Number 424, April 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 04-2012 elektor ELEKTOR Membership Counter countries. Not a member yet? Sign up atwww.elektor.com/member 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 ■ 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 AudioXpress www.cc-webshop.com 23 Labcenter www.labcenter.com 88 Bel? Beta Layout www.pcb-pool.com 33 DesignSpark chipKIT™ Challenge www.chipkitchallenge.com 15 [rnMikrolleiiTDiuka TT. MikroElektronika www.mikroe.com 7* NATIONAL INSTRUMENTS National Instruments http://uk.ni.com . . . 3 11 Eurocircuits www.elektorpcbservice.com 2 EzPCB www.siliconray.com * Jaccartac' Jackaltac www.j ackaltac.com 65 . 9 picO i fi fcbibfi Pico Technology www.picotech.com/PS1 32 75 tlicvn Lnetsv □ulktijii: Renesas Contest www.circuitcellar.com/RenesasRL78Challenge. . 67 * ZeitControi i.MiiSiliit Sfcrhn Zeitcontrol www. basiccard.com 36 Not a supporting company yet? Contact Johan Dijk (j.dijk@elektor.com, +27 78 2330 694) no later than 24 January 2012 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 04-2012 7 NEWS & NEW PRODUCTS DIP switch is process-sealed for surface-mount soldering, washable-processing C&K Components’ new ultra-miniature, surface-mount DIP switch delivers consist- ent electrical performance and high relia- bility. The half-pitch TDA Series DIP switch features bifurcated contacts that provide increased electrical reliability when com- pared to other contact technologies. In addition, the switches are process-sealed for both surface-mount soldering and washable-processing, making them ideal for hand-held electronics devices, port- able computer devices, and instrumenta- tions and controls. “C&K has made the investment to enhance and expand our DIP switch product offering, delivering new switch features and options that provide design engineers with flexibility when specifying a DIP switch for a particular design,” said Owen Camden, Business Devel- opment Manager at C&K Components. The RoHS-compliant TDA Series is availa- ble in two termination styles, S-termination (Gullwing) and J-termination (Bend). The single pole, single throw (SPST) DIP switch is available in multiple positions, including 2, 4, 6, 8 and 1 0 positions. The TDA Series DIP switch features a contact rating of 24 VDC, 25 mA (switching state) and 50 V DC, 1 00 mA (steady state). The TDA Series DIP switch provides a maximum contact resistance of 1 0OmO. Operating temperature ranges from -40 9 C to +85 9 C. The TDA Series switches are available in tape and reel or tube packaging. www.ck-components.com (120209-10) Towards fully electrical vehicles, “so driving feels the same” On behalf of the ESTRELIA (Energy Storage with lowered cost and improved Safety and Reliability for electrical vehicles) con- sortium, project leader austriamicrosystems announces success- ful progress of the first six months of the EU FP7 project ESTRE- LIA. ESTRELIA demonstrates a successful example of collaborative European Research contributing to the EU 2020 C0 2 reduction objectives by enabling and demonstrating innovative 1C products manufactured in Europe. High costs, together with concerns for driving range, reliability and safety, are still the main hindrance for market adaption of full electrical vehicles (FEVs). The project ESTRELIA aims to provide building elements with enhanced reliability and safety at lowered costs for smart energy storage for FEVs. This will be accomplished through a modular approach based on optimized ultracapacitor power packs developed by Valeo. Corning will provide proto- type ultracapacitor cells, projected with up to 50% energy den- sity advantage over commercially available products. The perfor- mance of the power packs will be evaluated by Austrian Battery Research Lab. New Battery Management (BMS) ICs from austriamicrosystems will, for the first time, provide a flexible active cell balancing chip set also suited for the high accuracy demanding monitoring of Li-Ion batteries. The BMS ICs and architecture proposed from Fraunhofer MSB will be verified on prototypes built by E4V. Tests with new HV test eguipment developed by Active Technologies will proof test isola- tion protections in the environment of several 1 00’s V as present in FEVs. The new BMS 1C concept will enable higher efficiency by lower energy loss and improved long term reliability and lower the electronic component costs for BMS of Li-Ion energy packs. ESTRELIA will also develop new safety sensors, which are based on silicon based MEMS approaches delivering enhanced safety func- tions at lowered cost compared to existing solutions. While the gas sensor will allow detection of very low levels of volatile organic compounds as emitted in thermal overruns of battery packs, the new spark detector concept will enable general safety functions by flame detection from all hazardous events in a FEV. Finally, the development of new low cost power antifuses by Fraunhofer MSB together with the new energy management hardware (BMS 1C) and software will enable dynamic reconfigurable topologies in the energy storage unit, thus providing limp-home functionality to the FEV despite single cell failures. The consortium led by austriamicrosystems (AT) includes Valeo Electrical Systems (FR), Fraunhofer MSB (DE), Corning SAS (FR), Austrian Battery Research Laboratory (AT), AppliedSensor (DE), CEA LETI (FR), Active Technologies (IT), E4V (FR). All consortium partners are leaders in their respective areas of expertise. After six months of successful cooperation we are progressing very well with the so far achieved results. Our half year project team meeting was very productive and we have been able to solve open issues”, stated Ewald Wachmann from austriamicrosystems, who leads the coordination team of ESTRELIA. Based on several inputs from car manufacturers the 1C specifica- tion and design for the Battery Management ICs is progressing very well. A detailed concept using self-triggered power antifuses to bypass faulty battery cells has been developed and supported by device simulation. This is a first step to provide a cost effective solution to single cell failure for the future. Also the development of the very important safety sensors for EV’s is on schedule. For the new gas sensor the first modified samples for battery testing have been provided, and for the MEMS based spark detection sen- sor the appropriate piezo resistive concept has been selected and the design optimization is running. First samples of the ultraca- pacitor cell samples with high energy densities in the range of 7-9 Wh/L have already been investigated. By the end of the project, up to 50% higher energy density in the power pack is an intended innovation of the ESTRELIA project. www.estrelia.eu www.austriamicrosystems.com (120209-1) 8 04-2012 elektor NEWS & NEW PRODUCTS New 200W AC to DC modules Acal BFi, a division of Acal pic, recently launched of a new range of embedded power supplies from specialist manufac- turer, SL Power, which feature 90% effi- ciency and one of the smallest heat foot- prints in AC to DC conversion. The CINT1 200 family comprises eight mod- els with output voltages from 1 2 V to 48 V, and up to 200 watts of output power, from a wide input range of 90 V to 264 Vac. The space-saving CINT1 200 AC to DC modules Infineon XMC4000 microcontroller family gets ARM® Cortex™-M4 processor tool support Atollic TrueSTUDIO® for ARM® C/C++ development tool will be available shortlly for the new 32-bit XMC4000 family of Infineon Technologies AG that uses the ARM Cortex™-M4 processor from launch. Infineon’s XMC4000 line-up is targeted at a wide range of industrial applications, such as electric drives, solar inverters and the auto- mation of manufacturing and buildings. The XMC4000 family will be launched at Embed- ded World 201 2 in Nuremberg, Germany. With XMC4000 Infineon combines a full- measure 3” (7.6 cm) x 5” (1 2.7 cm), with a height of just 1 .3” (3.3 cm), allowing them to easily fit into a 1 U chassis. Designed to meet the stringent EMC requirements for industrial and informa- tion technology equip- ment (ITE) applications, the CINT1200 modules are HALT tested for durability and offer a 3-year warranty. The modules are CE marked in accordance with the low-voltage directive and are approved to ITE standards making them suitable for worldwide applications. Value-add manufactur- ing services allow Acal BFi to modify or pro- duce full custom versions of SL Power modules, including in-house testing for EMC, fast prototyping and a low mini- mum order quantity. www.acaltechnology.com/uk/slpower2 (120202-VII) featured configurable peripheral set with an industry-standard ARM Cortex-M4 core that is ideal for energy-efficient industrial applications. XMC4500, the first series of the new microcontroller family, delivers the 32-bit computing power embedded devel- opers need to innovate a variety of indus- trial applications within time-constrained development cycles. Peripheral interface support includes SPI, I2C, UART and CAN configurable serial modules together with 1 2-bit ADCs and DACs. The Atollic TrueSTUDIO for ARM develop- ment tool has recently been given the EDN Hot 100 products of 201 1 award. Atollic Tru- eSTUDIO is a world-class development and debugging tool that offers a state-of-the-art editor, an optimizing C/C++ compiler and a multiprocessor-aware debugger with real- time tracing. The tool suite delivers a leap in software development team collabora- tion and developer productivity, and offers advanced features including ARM build and debug tools, system analysis and real-time tracing using Serial Wire Viewer (SWV) tech- nology, and graphical-UML diagram editors for model-based design and architecture. Atollic TrueSTUDIO also offers multiple advanced features, such as: an ECLIPSE™- based IDE with a state-of-the-art editor; x86 C/C++ build and debug tools for devel- opment of PC command-line applications; parallel compilation and multiprocessor debugging; and integrated version-control system client with revision graph visualiza- tion, enabling easy tracing of the history of code additions and revisions. Additionally, Atollic TrueSTUDIO includes an integrated client for accessing popular bug databases like Trac and Bugzilla, and it includes integrated features for performing source code reviews and code review meetings too. Atollic offers optional add-on modules that extend Atollic TrueSTUDIO with advanced features for static and dynamic code analy- sis as well as automatic unit testing. True- INSPECTOR® performs static source code analysis (MISRA®-C compliance control and code metrics), TrueANALYZER® per- forms in-target test quality measurement up to Modified condition/Decision cover- age (MC/DC) using dynamic execution flow analysis, and TrueVERIFIER® performs auto- mated in-target unit testing of the embed- ded software. www.atollic.com (120202-IX) Advertisement If 5 ? PCBs Muuuuch Cheape No-frills policy 17,22 EURO 5 pcbs, 1 00 mm x 1 00 mm ♦per piece, incl. UflT (23%) + shipping costs e. g. Germang 1 0,89 EURO * JaCCaltac ujLULU.jackaltac.com elektor 04-2012 9 NEWS & NEW PRODUCTS Low Power, < 7ppm/°C guaranteed, 2.5 V voltage reference 1 C Touchstone Semiconductor, a developer of high-performance analog integrated cir- cuit solutions, today announced the new- est member of its voltage reference family, the TS6001A, a low-power, low-dropout precision SOT-23 voltage reference 1C that reduces drift to a guaranteed 7 ppm/°C maximum, a 2x improvement over its clos- est competitor, the MAX6025A. AO O0%„ Tppm/'C +2.5-V Vol!^ Refers™ iri SOT23 L&w initial Accuracy TS60Q1A-2.5: D.06% +iTVlv uj T5600t&-25:0.ttH ‘ SOT23-3 mooi Low Drift. TSSQOTA-2.5: 7ppfTV'C TS6KHi8-2 5; IDppmTC V*,-*5V ■L(jw Dropout 0.07SVatF iPfi = 500 pA Boost™ extends Gen4’s performance leader- ship by delivering three times higher signal- to-noise ratio (SNR) than previously possible. This is accomplished without the use of per- formance-robbing digital filters or external components, enabling manufacturer’s to produce the industry’s thinnest handsets and tablets with low material costs. The key to excellent touchscreen perfor- mance in noisy environments is high SNR. Gen4 already delivers up to four times the raw SNR of the competition through its internally generated 1 0 V Tx circuitry; whereas competitive offerings require cus- tomers to use large, expensive, and noisy external switching regulators to generate high-voltage Tx signaling. The Tx-Boost fea- ture, now available on all TrueTouch Gen4 devices, uses specialized hardware accelera- tion to triple the already best-in-class SNR of the Gen4 family. This high SNR enables manufacturers to employ sensor-on-lens with direct lamination to displays and in-cell architectures with flawless performance for the thinnest products in the market. The unique combination of a small form factor, few external components and low supply current make the TS6001 A an ideal choice for low-voltage, supply-independ- ent, power-sensitive applications, including handheld and battery-operated equipment. The TS6001A is capable of sinking and sourcing load currents up to 500 pA. The TS6001 A consumes only 27 pA of supply current at no-load. It also offers an initial accuracy initial output voltage accuracy of less than 0.08%. The TS6001 A and TS6001 B are available in a space-saving 3-pin SOT23 package. It is in stock and ready to ship. The product is in stock and available from Future Electronics. www.futureelectronics.com www.touchstonesemi.com/voltagereferences.html (120202-X) Cypress: high-voltage Tx drivers give touchscreens a boost Cypress Semiconductor Corp. unveiled a breakthrough feature for its Gen4 True- Touch® touchscreen controllers that dra- matically improves system performance without added cost. Cypress has developed a new proprietary technology based on Gen4’s patent-pending high-voltage Tx drivers. Tx- In addition, Tx-Boost efficiently parallelizes multiple operations in hardware, without burdening the CPU with costly digital filter- ing. This significantly increases Gen4’s scan speed, making the world’s fastest touch- screen controller even faster. These paral- lel operations also further improve Gen4’s industry-leading power consumption by increasing the amount of idle time during each scan period. “We understand that touchscreen custom- ers are in highly competitive markets and need constantly improving technology to stay ahead,” said Dhwani Vyas, Vice Presi- dent of Cypress’s User Interface Business Unit. “We’re pleased to provide Tx-Boost to enable the i nd ustry’s best control ler fa m ily to extend its leadership against competitive offerings. Customers who have seen this technology in action have been universally impressed.” The Tx-Boost solution is now available on all Gen4 TrueTouch devices. www.cypress.com (120209-2) 8051/80C51 legacy lives on with new Microchip microcontrollers Microchip Technology Inc. is set to con- tinue to manufacture legacy 8051/80C51 MCUs that provide pin-for-pin-compatible replacements for most of those recently placed under ‘End-of-Life’ (EOL) notifica- tion by NXP. Included are drop-in replace- ments for NXP’s P89LV51 RB2/C2/D2 and P89V51 RB2/C2/D2 EOL series of 80C51 8-bit microcontrollers. Microchip’s April 201 0 acquisition of Silicon Storage Tech- nology, Inc. (SST) included a legacy 80C51 MCU business, which Microchip has contin- ued to support. “Microchip has a history of supporting customers with long lifetimes on all of our product lines,” said Randy Drwinga, vice president at Microchip Technology Inc. “We also have a strong presence in the industrial, automotive and medical markets, and understand that long-life- cycle product support is important to these customers. We welcome anyone currently using NXP’s 80C51 MCUs who doesn’t wish to redesign their end prod- ucts to use our 100% compatible 80C51 product portfolio, and we offer them the option to migrate to our broad portfolio of 8-bit, 1 6-bit and 32-bit PIC® micro- controllers, at their convenience.” Microchip has a cross-reference document available on its Web site, as well as data sheets and a product brief. NXP’s P89LV ver- sions are 3 V MCUs, and are 1 00% compat- ible with Microchip’s SST89V MCUs. Like- wise, NXP’s P89V versions are 5 V MCUs, and are pin-for-pin compatible with Micro- chip’s SST89E microcontrollers. As with all 8051 -compatible microcon- trollers, Microchip’s 80C51 MCUs can be used with many third-party development tools that are widely available. Examples include programmers from Xeltek, Hi-Lo Systems, Advantech Equipment Corp., 10 04-2012 elektor Low Cost. High Performance. PC-based measurements from only £69 Nl USB-6008 Multifunction DAQ Nl USB-6008 12-Bit, 10 kS/s, Multifunction DAQ ■ 8 analogue inputs; 2 analogue outputs; 12 digital I/O; 32-bit counter ■ Bus-powered for high mobility; built-in signal connectivity ■ NI-DAQmx driver software and LabVIEW SignalExpress LE interactive data-logging software ■ £99 ALSO AVAILABLE: Nl USB-6009 14-Bit, 48 kS/s, Multifunction DAQ - £179 Nl USB-6210 16-Bit, 250 kS/s, Multifunction DAQ - £399 Nl USB-9201 12-Bit, 8 Channels, 500 kS/s - £549 Sensor-based measurements Nl USB-TC01 £79 Thermocouple Measurement Device - £79 ALSO AVAILABLE: Nl USB-9211A 24-Bit, 4 Channels, Thermocouple Input - £529 Nl USB-9219 4 Channels, Universal Analogue Input - £1049 Instruments Nl USB-5132 Nl USB-5132 £499 50 MS/s Bus-Powered Digitiser/Oscilloscope - £499 ALSO AVAILABLE: Nl USB-5133 100 MS/s Bus-Powered Digitiser/Oscilloscope - £699 Nl USB-4065 6V 2 -Digit USB Digital Multimeter - £1049 Digital I/O Nl USB-6501 Nl USB-6501 £69 24 Channel, 8.5 mA, USB Digital I/O - £69 ALSO AVAILABLE: Nl USB-6525 8 Solid-State Relays, 8 Dl, Counter, Channel-to-Channel Isolated - £249 Nl USB-9421 8 Channels, 11-30V Digital Input -£339 Nl USB-9472 8 Channels, 6-30V Digital Output - £339 Nl GPIB-USB-HS £349 Instrument Control Nl GPIB-USB-HS GPIB Controller for Hi-Speed USB 2.0 - £349 ALSO AVAILABLE: Nl USB-232 Single-Port RS232 Interface for USB - £129 Nl USB-485 Single-Port RS485 Interface for USB - £129 Nl USB-8451 I2C/SPI Interface - £339 At lower cost than you might think, National Instruments provides an intuitive platform that can connect to thousands of sensors and instruments to acquire, analyse and process signals, and present results graphically. Whether programming in C, Basic or LabVIEW on Windows, Mac or Linux, get the latest in PC-based data acquisition, instrumentation and instrument control, starting at less than £70. 01635 517300 » Buy online and explore the range at uk.ni.com/products/lowcost uk.ni.COm info.uk@ni.com Join Nl, Honeywell & PCB Piezotronics at 16 locations across the UK & Ireland: uk.ni.com/measurementsroadshow / — ; \ JOIN THE CONVERSATION: Follow us on * Search niukie \ ) ■^7 NATIONAL INSTRUMENTS ©2012 National Instruments Corporation. All rights reserved. National Instruments, Nl, and ni.com are trademarks of National Instruments. Other product and company names listed are trademarks or trade names of their respective companies. Prices subject to change. For latest prices, check online at ni.com/products. NEWS & NEW PRODUCTS EETools and Phyton. Note that some third-party sites have these devices under “Manufacturer: SST.” www.microchip.com/get/ 18 Dl www.microchip.com/get/SW8R (120209-3) New adjustable output low dropout voltage regulators for automotive applications ON Semiconductor has announced two new low dropout (LDO) voltage regulator ICs. Building on the company’s market-leading power man- agement portfolio for automotive applica- tions, the new devices are ideal for use in audio and infotainment systems, instru- ment cluster, navigation and satellite radio. The new NCV47700 and NCV47701 LDOs fea- ture an output diagnostic pin CSO that can be used to detect open and shorted loads. Using a resistor connected to the CSO pro- vides an adjustable output current level between 10 milliamperes (mA) and 350 mA with ±1 0% accuracy. Tying the ADJ pin to ground configures the NCV47700 and NCV47701 to be a current limited high- side switch. High peak input voltage toler- ance and reverse input voltage protection, as well as overcurrent and overtempera- ture protection functions are all included to safeguard against the effects of the harsh operating conditions typical of automotive applications. An integrated current sense feature negates the need to implement a discrete solution that would use more board space and raise the total component count. Adjustable output voltage versions of the devices are available; these cover the 5 volt (V) to 20 V range, with ± 6 % accuracy for the NCV47700 and ±3% accuracy for the NCV47701 . Both new LDO voltage regulator ICs have a junction operating temperature range of -40 °C to +1 50 °C, that matches or exceeds the specifications stipulated by the automotive industry. “These feature-packed LDOs are differenti- ated from alternative market offerings by integrated current sensing functionality and an array of protection mechanisms,” said Jim Alvernaz, director of the Automotive product division at ON Semiconductor. “The devices enable electronic design engineers to implement power management subsys- tem diagnostics, without the employment of a discrete current measurement circuit or additional protection components. This leads to improved power regulation in the audio/infotainment systems, instrumenta- tion clusters and navigation systems found in modern vehicles.” www.onsemi.com (120209-5) Verotec: Eleven new integrated development systems Verotec has developed eleven new models in four families of inte- grated development systems for stand-alone desktop or rack mount environments. Equally suitable for the hardware/software development envi- ronment and for use as the packaging for the finished system, the modular units are configured from the company’s stand- ard ranges of enclosures, subracks, back- planes, thermal management products and power supplies. The use of standard build- ing blocks reduces the developer’s time to market; all systems are user-configurable around the default options if required. cPCI, VME and VME64x are fully supported in all models. The DIO and D21 are desktop half- and full-width systems, supporting 6U 10 and 21 Slot cPCI and VME64x systems respec- tively. 9U high, space for 80 mm deep rear transition modules is provided as standard and cooling fans are mounted below the IEEE1 101.10/11 KM6-RF subrack. The V8, V9 and VI 2 are 8U, 9U and 1 2U 21 Slot sys- tems based on the KM6-II and KM6-RF sub- racks. Designed for rack mounting 6U cPCI and VME64x systems, all variants have integral thermal manage- ment; in the V8 and V9 models a removable fan tray is mounted beneath the subrack, in the VI 2 an extractor fan unit mounted in the rear of the unit augments the airflow through the boards. Both embedded and pluggable PSUs are supported in the D and V units. The H Series is designed around the IEEE1 101.10/11 KM6-HD heavy duty sub- rack for horizontal mounting of 6U cPCI or VME64x boards. The HI 2 is 1 U high with 2 slots, the H24 2U high with 4 slots and the H36 3U high with 6 slots; all versions sup- port full width rear transition modules. The cooling arrangements vary between mod- els, but all versions have both front and rear area cooling. Good EMC performance is achieved by the use of fabric-over-foam and beryllium copper gaskets and opti- mized hole diameter and spacing on the intake and exhaust cooling vent matrices. A range of different PSUs is supported. The TecSYS system is an entry-level VPX devel- opment platform to provide a basic physi- cal environment for soft ware development and board integration. Configured around a 5-slot 3U full mesh X4 PCI Express VITA 46.4 backplane with VITA 46.1 0 RTM capability, the 6U half-width desktop system provides fat pipe communications between all five slots and an interface with one of the most widely used architectures, PCI Express. www.verotec.co.uk (120209-6) 12 04-2012 elektor :::ccc5‘(r. 'scsccsc scccccce cccccccr sceciccf pc c c'c C’;f c w ~ ;::cccc 'cccccc arscoccs scocscec ccicccs;: osccstcc V Nt . Tzq Comprehensive reading: at home and on the road ml. Read Elektor with the cut-rate PLUS subscription! Subscribe now or upgrade: www.elektor.com/subs NEWS & NEW PRODUCTS Add (iBlue to your Bluetooth Smart application Ultra low power (ULP) RF specialist Nordic Semi- conductor recently released its brand new pBlue™ nRF8002 System-on-Chip (SoC) that provides a low cost, ultra-low power, uniquely easy to design-in single chip solution for Bluetooth Smart (as Bluetooth low energy will now be marketed to consumers) wireless tags and other accessories such as bracelets, pendants, keychains, small toys, and armbands. To add the pBlue™ nRF8002 to a product design demands no specialist understanding of Bluetooth low energy wireless technology or any embedded firmware development. Using a Nordic nRFgo-compatible nRF8002 Development Kit, developers can design Bluetooth Smart tags and accessories using a simple graphical user interface that allows them to go no deeper than configuring the built-in application layer and map- ping inputs and outputs to external components such as buttons, LEDs, and buzzers. The development kit even includes a small coin cell-powered tag design example that can be used for development, prototyping, and testing. The nRF8002 is supplied in a compact 5x5mm QFN package and includes a fully-quali- fied Bluetooth v4.0 low energy protocol stack, a highly configurable application layer, and built-in support for a range of Bluetooth v4.0 profiles including: Find Me, Proxim- ity, Alert Notifications, and Battery Status. This — combined with market-leading power consumption — makes the nRF8002 an ideal solution for low cost, miniaturized coin cell battery-powered applications. The Find Me profile allows users to pair small — but com- monly misplaced — everyday objects with their Bluetooth v4.0 smartphone in order to locate either from the other. In a similar way to how people often phone their misplaced cell phones to make them ring and easy to find, a small nRF8002-based Bluetooth Smart tag attached to a keychain, for example, can feature an audible alarm that can be acti- vated if the keys are misplaced by a pressing a button on a smartphone. Alternatively a misplaced smartphone could be made to ring or alarm by pressing a button on the tag. The Proximity profile adds further out-of-range functionality to the Find Me profile to allow users to pair valuable everyday Bluetooth v4.0 objects (e.g. smartphones and computers) with, for example, a wireless tag so that it alarms or securely locks the val- ued item if the user and item are separated by more than a specified distance (e.g. due to the user leaving the office, potentially leaving the item behind at a public place, or the item being stolen). Alternatively, the Proximity profile can also be used to automatically activate (unlock) a smartphone or computer when the user is within a specified distance (so saving the hassle and security risk of having to enter unlock passcodes manually). The Alert Notification profile allows users to be notified of specific events happening on a paired Bluetooth v4.0 device. This means, for example, an nRF8002-based sports armband could be set to vibrate if the user receives an incoming call from a specific person(s) while working out at the gym or running outdoors. The Battery Power profile enables users to be given low battery warnings. This means a Bluetooth v4.0 smartphone could, for example, alert users of the need to change the battery in any of their paired Bluetooth Smart wireless accessories — from heart- rate belts and foot pods through to remote controls, wireless mice, and keyboards. The Nordic nRF8002 is built on the same technology platform as its nRF8001 predeces- sor and so provides many of the same key technical performance and feature advan- tages including: • Peak currents as low as 13mA; • Months to years of battery lifetime from a single coin cell battery (depending on duty cycle); • Ultra-low power operation without the need for an external 32 kHz crystal; • An on-chip battery monitor. Samples of the nRF8002 are available now, along with the Nordic nRFgo compatible nRF8002 Development Kit (priced at USD $99) that enables engineers to quickly evalu- ate, test, and prototype Bluetooth Smart applications using the nRF8002. www.nordicsemi.com (120209-7) New ezLOAD PCB Support System Count On Tools Inc., a leading provider of precision components and SMT spare parts, announces the release of its newly redesigned ezLOAD PCB support system with modular frame. With the recent increase of densely populated double-sided circuit boards, COT recognized the need for more affordable board support options in the electronics man- ufacturing industry. The end result is an inno- vative design that is not only easy to setup and install, but also offers industry-leading ben- efits to EMS companies and contract manu- facturers worldwide. The newly redesigned ezLOAD PCB support system from COT fea- tures a new extruded aluminum base. The system not only reduces changeover times, but improves product build quality, increases revenues by providing significant cost savings, and can eliminate component damage during the assembly process. COT’s new ezLOAD features active grip tech- nology to securely hold boards during the assembly process. It protects components while allowing the boards to move freely through the assembly line. Also, with the basic universal design, there are no mechani- cal functions to fail. The system requires no air, electronics, or communication from the user. The magnetic locking base ena- bles a quick and easy installation. Other base designs are available for non-magnetic tables. Most importantly, the ezLOAD PCB support system is affordable compared to competitive products on the market. The ezLOAD PCB support system is compatible with any SMT equipment, from pick-and-place to chipshooters, screen printers, dispensers, AOI, and more. It is extremely durable thanks to the soft, flexible design, and is proven to be reliable after testing in the most hazardous conditions. The ezLOAD PCB support system is customizable depending on machine require- ments, specialized components, or specific design application requirements. www.cotinc.com/ezload (120209-4) M 04-2012 elektor DESIGNSPARK March 27 marks the end of the DesignSpark chipKIT™ Challenge! V Soon, your eco-friendly and energy efficient design solutions will be in the hands of Elektor and Circuit Cellar’s expert panel of judges. Did you have what it takes unleash the low-power combination t 4 of DesignSpark’s free PCB software and Microchip Technology’s chipKIT™ Max32™ development board? Find out on May 7, 2012 when the Grand Prize Winners will be announced. DesignSpark thipKIT" Challenge I J _! Ll t IN DIOILENT W, Microchip uued chipKIT™ is a registered trademark of Microchip Technology Inc. Max32™ is a registered trademark of D PREAMPLIFIER 2012 Parti: introduction and line-in/tone/ volume board By Douglas Self (UK) Audio lovers, sit up. Besides presenting a truly high end audio control preamplifier for home construction, this article series also aims to show how low-impedance design and multiple-amplifier techniques can be used to significantly reduce the noise levels in analogue circuitry. The result of the design effort is a top- notch preamp that’s brilliant not just sonically but also in terms of cost/performance ratio. It is now some time since I published a pre- amplifier design — the Precision Preamp in 1 996 [1 ]. Inevitably technology has moved on. In that design the recording output level was as low as 1 50 mV rms to get a good disc input overload margin, the amplitude being well within the reach of the average tape recorder input level control. Nowadays most audio line inputs will be from digital sources, typically at 1 V rms unbalanced or 2 V rms balanced, and recognition of that reguires a completely new design, espe- cially in the MM/MC phono section. The preamplifier described here demon- strates how very low noise levels can be achieved in analogue circuitry without using exotic parts. It was originally conceived as being entirely made up of 5532 opamps, like the earlier Elektor 5532 OpAmplifier [2] but during the design process it became clearthat adding a few LM4562s (which are now a good deal cheaper than they used to be) would avoid some awkward compro- mises on distortion performance, because of their superior load-driving ability. In addition, the preamplifier has a very ver- satile MC/MM phono input stage with gain- switching, which I believe can optimally handle any cartridge on the market; this is guided by an innovative level indicator that provides more information than just on/off from one LED and does away with the need for bar-graph metering. A block diagram of the proposed pream- plifier is shown in Figure 1 . In practice, the project is divided into several circuit boards, each of which will be discussed separately starting this month with the circuitry com- prising the line amplifier, tone control, vol- ume control, and output stage. Noise of three kinds There are three main causes of electronic noise in analogue circuitry: Johnson noise from resistors, and current and voltage noise from semiconductors. All resistances (including those forming an integral part of other components, such as the base spreading resistance of a bipolar transistor) generate Johnson noise at a level that depends on the resistance and the absolute temperature. There is usu- ally little you can do about the ambient temperature, but the resistance is under your control. Johnson noise can therefore be minimised by Low Impedance Design, in other words keeping the circuit imped- ances as low as possible. In the early 1 970s audio circuitry commonly used 25 k Q or 50 k£2 potentiometers and associated components of proportionally high impedance, mainly because the dis- crete transistor circuitry of early opamps used had poor load-driving abilities. When the (NE)5532 appeared, and equally impor- tantly, came down to a reasonable price, it was possible to reduce impedance levels and use 1 0 k£l pots. This may not seem very ambitious when you consider that a 5532 can drive about 800 Q while keeping its good distortion performance, but the pot value does not always give a good idea of, for example, the input impedance of the cir- cuit block in which it is used. It is not widely known that a standard Baxandall tone con- trol constructed with two 1 0 l pots has an input impedance that can easily fall to less than 1 k£l. There is a cunning way round this problem; the Bass and Treble tone control networks can be driven separately; more on this below. Fixed resistors are available in almost any value, but the pot values available are much more restricted, and the lowest practical value in that two-gang pots are available for stereo, is 1 k£L 16 04-2012 elektor PREAMPLIFIER 2012 Test conditions: supply voltage ±1 7.6 V; all measurements symmetrical; tone control defeat disabled. Test equipment: Audio Precision Two Cascade Plus 2722 Dual Domain (@Elektor Labs) THD+N (200 mV in, IV out) 0.001 5% (1 kHz, B = 22 Hz - 22 kHz) Max. output voltage 0.0028% (20 kHz, B = 22 Hz - 80 kHz) (200 mV in) 1.3V THD+N (2 V in, 1 Vout) 0.0003% (1 kHz, B = 22 Hz - 22 kHz) 0.0009% (20 kHz, B = 22 Hz - 80 kHz) Balance Tone control +3.6dBto-6.3dB ±8 dB (100 Hz) S/N (200 mV in) 96 dB (B = 22 Hz -22 kHz) ±8.5 dB (10 kHz) 98.7 dBA Crosstalk R to L -98 dB (1 kHz) Bandwidth 0.2 Hz -300 kHz Crosstalk L to R -74 dB (20 kHz) — 1 02 dB (1 kHz) -80 dB (20 kHz) Current noise is associated with opamp inputs. It only turns into voltage noise when it flows through an impedance, so it can be reduced by Low Impedance Design. The use of low value pots also means that opamp bias currents create less voltage drop in them and so there are less likely to be intru- sive noises when the wiper is moved. Voltage noise is the third type of noise. It is already in voltage format, being equiva- lent to a voltage noise generator in series with the opamp inputs, and so cannot be reduced by Low-Impedance Design. At first it seems that the only thing that can be done to minimise it to use the quietest opamps available. Opamps exist that are quieter than the 5532 or the LM4562, but Figure 1 . Architecture of the Preamplifier 201 2. Although functions appear as individual blocks here, several of these are comprised together on circuit boards, for example, the four orange-coloured blocks discussed in this article, i.e. from line input, through tone control, volume control up to balanced output. elektor 04-2012 17 PREAMPLIFIER 2012 HH £ H H & Figure 2. The circuit diagram of the line / tone / volume / output board is largely dominated by NE5532 and LM4562 opamps for good reasons. Note the unusually low value of the potentiometers used. they are expensive and have high current noise. A typical example is the AD797, which has the further drawback of only being available in a single package, putting the cost up more. A better path is the power- ful technique of using of mul- tiple cheap amplifiers with their outputs summed — or to be more accurate, averaged. With two amplifiers connected in parallel, the signal gain is unchanged. Their outputs are averaged simply by connecting a low value resistance to each amplifier and taking the out- put from their junction. The two noise sources are uncorre- lated, as they come from physi- cally different components, so they partially cancel and the noise level drops by 3 dB (V 2). The amplifier outputs are very nearly identical, so little cur- rent flows from one opamp to another and distortion is not compromised. The combining resistor values are so low (typi- cally 1 0 Q) that their Johnson noise is negligible. This strat- egy can be repeated by using four amplifiers, giving a signal- to-noise improvement of 6 dB, eight amplifiers give 9 dB, and so on. Obviously there are lim- its on how far you can take this sort of thing. Multiple opamps in parallel are also very useful for driving the low impedances of Low Impedance Design, so the two techniques work beau- tifully together. The Elektor 5532 OpAmplifier [2] pretty much took this to its logical conclusion. The multiple-amplifier approach gets unwieldy when the feedback components around each amplifier are expensive or over-numerous. 18 04-2012 elektor PREAMPLIFIER 2012 _-»! - L Baxandall and Self on Audio Power Uneor Audio Clossic (oJh^ltd pQperi I have tried hard in this project to design the highest performance preamplifier possible, and it is significant that in two out of the three stages, ideas put forward by Peter Baxandall have proved to be the best solution. He was a great man. Editor’s Note. Besides reprints of selected articles from Wireless World / Electronics World, Jan Didden’s book “Baxandall and Self on Audio Power” presents a previously unpublished ex- change of letters between Peter Baxandall and Douglas Self, both correspondents actively tracing the various causes of distortion in high end audio power amplifiers. The book is published by Linear Audio, www.linearaudio.net. To use two amplifiers in a standard Bax- andall tone control you would have to use quad-gang rather than dual pots for ste- reo, and also duplicate all the resistors and capacitors. While this would reduce the effect of all the noise mechanisms in the cir- cuit by a/2, giving a solid 3 dB improvement, it is not an appealing scenario. If instead you simply halved the impedance of the Baxandall network by halving the pot and resistance values and doubling the capacitor values, the situation is not equiva- lent. In the second case you have halved the effect of the opamp current noise flowing in the circuit impedances, and reduced the Johnson noise by root-two, but the opamp voltage noise remains unaffected and will often dominate. Line input and balance control stage This is a balanced input stage with gain vari- able over a limited range to implement the balance control function. Maximum gain is +3.7 dB and minimum gain -6.1 dB, which is more than enough for effective balance control. Gain with balance central is +0.2 dB. Looking at the circuit diagram in Figure 2 and discussing the left (L) channel only, IC2A is the basic balanced amplifier; it is an LM4562 for low voltage noise and good driving ability. The resistances around it are low to reduce noise so it is fed by unity-gain buffers IC1A/B which give a high input impedance of 50 k£l that improves the CMRR. Note the EMC filters R1 -Cl and R2-C2 and the very start of the circuitry. The stage gain is set by 1 k£l pot PI A, the nega- tive feedback to IC2A being applied through two parallel unity-gain buffers IC3A/B so the variation in output impedance of the gain- control network will not degrade the CMRR. The dual buffers reduce noise and give also more drive capability. In this stage combin- ing the buffer outputs is simple because the feedback resistance can be split into two halves; R8 and R9. This requires R1 1 and R1 2 to be paralleled to get exactly the right resistance value and so preserve the CMRR. The noise output of this stage is very low: -1 09 dBu with the balance control central; -106 dBu at maximum gain and -1 16 dBu at minimum gain, (all 22 Hz - 22 kHz, rms) The tone control stage It is not obvious but this is (mostly) a con- ventional Baxandall tone-control. Once more 1 l pots are used, requiring large capacitors to set the turnover frequencies, C7 at 1 jiF sets the bass frequency and C8, C9 at 1 00 nF set the treble frequency. The cut/boost is ±1 0 dB maximum for both. The stage has a low input impedance, especially when set to boost; to deal with this the Bass and Treble parts of the tone-control net- work are driven separately. The Treble net- work C9-P3B-C8 is driven directly by IC2A in the previous stage, while the Bass network R1 5-C7-P2B-R1 4 is driven separately by the extra unity-gain buffer IC2B, the other half of the LM4562 in the line input stage. I call this a split-drive Baxandall circuit. The Treble network is the two-capacitor version rather than the one-capacitor types; this has the advantage that the treble pot is uncoupled from the circuit at low frequen- cies and reduces the loading. The main tone-control opamp is IC4A, which drives the Treble feedback path directly, while unity-gain buffer IC4B gives separate drive to the Bass feedback path. Polypropylene capacitors are strongly rec- ommended as they are free from distortion while polyester types show significant non- linearity. Unfortunately they are also physi- cally larger and more expensive, but well worth it in my view. The noise output of the tone-control stage alone is only -1 13 dBu with con- trols set to flat. Relays RE1 and RE2 implement a tone con- trol defeat function by enabling the active volume control stage to be driven directly from IC2A. To prevent clicks and other noises when the relays switch over, R18 and R58 have been added, effectively keep- ing up the bias to IC9B and IC1 8A. To keep crosstalk down to a minimum each channel has its own relay. As a bonus, two contacts can be connected in parallel, preventing any risk of signal degradation and at the same time increasing life span. Active volume control stage The volume control is of the active Baxan- dall type which gives low noise at low vol- ume settings and also synthesises a quasi- logarithmic control law from a linear pot, giving much superior channel balance. Max- imum gain is +16 dB, with 0 dB obtained with the control central. The input imped- ance of the volume control stage, imple- mented with another 1 l<^ pot P4A, falls to low values at high volume settings. It is therefore driven by the ‘load-splitting arrangement’ where buffer IC9B provides half of the drive from the tone-control stage. Resistors R1 9, R20 ensure that IC4A and IC9B share the load between them. The conventional Baxandall active volume control as in [1 ] uses a single buffer and one inverting amplifier, such as IC5A and IC5B. Here four of these circuits are used in paral- lel to reduce noise by partial cancellation of the uncorrelated noise from the four ampli- fier paths, and to give sufficient drive capa- bility to drive the back end of the 1 k£l vol- ume pot. The use of four paths reduces the noise by 6 dB. The multiple shunt amplifi- ers have no common-mode voltage on their inputs and so no CM distortion, and the associated buffers handle less than a third of the output voltage so stage distortion is very low. The enhanced drive capability means that it is not necessary to resort to LM4562s which still get a little expensive if elektor 04-2012 19 PREAMPLIFIER 2012 COMPONENT LIST Resistors (1 % tolerance; metal film; 0.25W) R1,R2,R39,R40 = 100£1 R3-R6,R41 -R44,R78,R79 = lOOkfl R7-R1 2,R1 6,R1 7,R21 -R24,R33,R34, R45-R50,R54,R55,R59-R62,R71 ,R72 = 1 k Q R13,R51 =470^ R14,R15,R52,R53 = 430£1 R1 8,R35,R36,R56,R73,R74 = 22k a R19,R20,R57,R58 = 20£1 R25-R28,R63-R66 = 3.3k£l R29-R32,R67-R70 = 10£1 R37,R38,R75,R76 = 47£1 R77 = 120^ PI ,P2,P3,P4 = 1 k£2, 1 0%, 1 W, stereo poten- tiometer, linear law, e.g. Vishay Spectrol cermet type 14920F0GJSX13102KA. Alter- natively, Vishay Spectrol conductive plastic type 148DXG56S102SP (RS Components p/n 484-9146). Capacitors Cl ,C2,C1 0-C1 4,C26,C27,C35-C39 = 1 0OpF 630V, 1%, polystyrene, axial C3,C4,C28,C29 = 47pF 35V, 20%, bipolar, diam. 8 mm, lead spacing 3.5mm, e.g. Multi- comp p/n NP35V476M8X1 1 .5 C5,C6,C30,C31 = 470pF 630V, 1 %, polysty- rene, axial C7,C32 = IpF 250V, 5%, polypropylene, lead spacing 1 5mm C8,C9,C33,C34 = 1 0OnF 250V, 5%, polypropyl- ene, lead spacing 10 mm Cl 5, Cl 6,C40,C41 = 220pF 35V, 20%, bipolar, diam. 13mm, lead spacing 5mm, e.g. Multi- comp p/n NP35V227M13X20 Cl 7-C25,C42-C50 = 1 0OnF 1 00V, 1 0%, lead spacing 7.5mm C51 =470nF 100V, 10%, lead spacing 7.5mm C52.C53 = 1 0OpF 25V, 20%, diam. 6.3mm, lead spacing 2.5mm Semiconductors IC1 ,IC3,IC5-IC1 0,10 2,104-10 8 = NE5532, e.g. ON Semiconductor type NE5532ANG IC2,IC4,IC1 1 ,IC1 3 = LM4562, e.g. National Semiconductor type LM4562NA/NOPB Miscellaneous K1 -l<4 = 4-pin straight pinheader, pitch 0.1 ” (2.54mm), with mating sockets K5,K6,K7 = 2-pin pinheader, pitch 0.1 ” (2.54mm), with mating sockets JP1 = 2-pin pinheader, pitch 0.1 ” (2.54mm), with jumper l <8 = 3-way PCB screw terminal block, pitch 5mm RE1 ,RE2 = relay, 1 2V/960a 230VAC/3A, DPDT, TE Connectivity/Axicom type V231 05-A5003-A201 PCB# 110650-1 Note: all parts available from Farnell (but not exclusively), except PCB 110650-1 110650-1 vl.2 ©ELEKTOR Figure 3. Component overlay of the circuit board designed by Elektor Labs for the line / tone / volume / output section of the Preamplifier 201 2. Ready made boards may be ordered at www.elektorPCBservice.com. 20 04-2012 elektor PREAMPLIFIER 2012 you are using a lot of them. Four 1 0 £1 resis- tors R29-R32 are used to average the four outputs. At sustained maximum sinewave output (about 1 0 V rms ) the volume pot gets per- ceptibly warm, as a consequence of the Low-Impedance Design approach. This may appear alarming but the heating is well within the specification of the hotpot. This does not occur with music signals. The noise output of the active volume stage alone is -1 01 dBu at maximum gain and -109 dBu for 0 dB gain. For low gains around -20 dB, those most used in prac- tice, noise output is about -1 1 5 dBu. Rather quiet. Here I have quoted the noise performance for each stage separately, to demonstrate the noise-reduction techniques. In a com- plete preamplifier the noise levels add up as a signal goes through the system, though how this happens depends very much on the control settings. Balanced output stage The balanced output consists simply of a unity-gain inverter IC9A which generates the cold (phase-inverted) output. The bal- anced output is therefore at twice the level of the unbalanced output, as in normal hifi practice. Construction notes The project employs standard leaded com- ponents throughout. A high quality circuit board designed by Elektor Labs for the pro- ject is available through www.elektorP- CBservice.com. The component overlay appears in Figure 3. It is recommended to use a flip over type PCBjig. Start with low-profile components and finish with the taller ones. The finished board pictured in Figure 4 should be taken as an example to work from — success is guaranteed if you strive to achieve this level of perfection in construction. Do not forget to fit JP1 for the ground through connection, a similar jumper is present on the MC/MM board. This allows you to determine empirically which ground A- rfJTK.rou - AXICOM . flv DC (%uj C" ^>044, L-> £- >1 >*+! : ^ {T, HmiT-n llli&Wj-l -.1.1 amm SELECTOR p; Q&fpat Figure 4. The prototype of the line / tone / volume / output board impeccably built by Elektor Labs. elektor 04-2012 21 PREAMPLIFIER 2012 Line / tone / volume / output board # 1 1 0650-1 only. Test equipment: Audio Precision Two Cascade Plus 2722 Dual Domain (@Elektor Labs) All measurements symmetrical. 10 20 50 100 200 500 Ik 2k 5k 10k 20k 50k 100k Hz THD+N vs. Frequency. Measurements at 200 mV in and 2 V in (lower FFT of 1 kHz at 2 V in and 1 V out. curve) and 80 kHz bandwidth. 1 V out. At 200 mV in there is noise Only second harmonic visible at -1 25 dB. only (approx. 96 dB measured at 22 kHz BW), and even lower levels at 2 V. Distortion not evident until above a few kHz. 10 20 50 100 200 500 Ik 2k 5k 10k 20k 50k 100k 200k Hz Amplitude vs. Frequency. Note the resolution on amplitude scale is just 0.1 dB. Tone defeat enabled. However, identical response ob- tained with tone control enabled and controls at mid position. Response at max. min. and centre positions of tone control (3 curves). Bass and treble set to identical extreme positions. connection works best. When the wiring is complete one jumper has to be fitted, or both. Axial polystyrene caps require care in deter- mining where to bend the legs. Their size is not standardized and subject to various tol- erances compared to other parts. Finally, on the potentiometers, plastic types from Vishay Spectral may be used instead of cermet. At the time of writing, supply of the cermet versions was subject to a lead time of up to 93 working days at Farnell’s. Next month’s instalment will discuss the very high quality MC/MM preamplifier board. ( 110650 ) References [1] Precision Preamplifier 96, by Douglas Self. Wireless World July/August & September 1 996. [2] The 5532 OpAmplifier, by Douglas Self. Elektor October & November 201 0, www.elektor.com/ 1 001 24 and www.elektor.com/ 1 00549. 22 04-2012 elektor Do your electronics speak to you? Are the words audio ' , "vacuum tubes" and "speaker technology" music to your ears? Then you should be reading audioXpress! Recently acquired by The Elektor Group, audioXpress has been providing engineers with incredible audio insight, inspiration and design ideas for over a decade. If you're an audio enthusiast who enjoys speaker building and amp design, or if you're interested in learning about tubes, driver or a combination of both for maximum accessibility. Subscribe to audioXpress at www.cc-webshop.com today! Audi amotci Lou ds pea *4? v- ^ 'ft. rfo* i< j SjtiLfi ll'-an over, this 7 1 ^ i *vn*yrhirg you rad to ijii'un now mtiutitt Krippfllamt ^ J '-' 1 '-Iil'PI'C on auttapejher voicing V' ..! . r r.o* iMSucfcs w ppoa anat i h;,p!^ on autf speaker voicing ■ e&l ig and crossover changes. a mw 1 Stipe complex yijlh -ftrifuinrw; &vi)f ICQ adflriifina fg j 1^ ii sal of oudsooakor design « A 39 £ vuluot What will you find in audioXpress ? • 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 Yours today for just & Jhis honk, and snai |eurprodui Cl testing, and vintage audio, then audioXpress is the magazine for you! MICROCONTROLLER RFID Reader Hacks Reading Mifare (Oyster, IS 0 14443) an d iClass (IS 0 15693) RFID devices By Martin Ossmann (Germany) To help familiarise the population with new RFID tag technology, the German Federal Office of IT Security (BSI) more or less gave away several thousand readers in campaigns organised with computer magazines. This article tells you how to modify these readers so they can read MIFARE IS 0 14443 cards. If cannot put your hands on one of these giveaway readers, you can use reverse engineering to build the entire reader yourself. The new German personal ID card contains an ISO 4333 compliant MIFARE/DesFire RFID chip made by NXP. As part of the BSI campaign, the December 2010 issue of Computer Bild magazine came with an RFID reader and RFID card as a bonus, at a price of €3.70. It’s hard to imagine a cheaper way to get an RFID reader. The giveaway reader was the ReinerSCT cyberjack RFID Basis model [1 ], with a regular selling price (according to the packaging) of €34.90. In total 1 ,237,000 of these readers were given out [2], so they will probably be available on eBay for a good while (with prices starting at a couple of euros). This ‘BSI reader’ forms the basis for making your own MIFARE ISO 1 4443 reader. You can either modify an existing BSI reader or use the information obtained from reverse engineering to build the entire reader yourself. These readers use two different types of 1C, and we provide circuit diagrams for each type. Finally, we describe a reader with no special components for use with RFID devices compliant with the ISO 1 5963 standard. Hack#i: BSI reader with PN512 The internals of the reader, with its very compact circuit board, can be seen in the photo above. Figure 1 shows the block diagram of the RFID reader. A Cypress USB microcontroller (CY7C6431 6) handles the control tasks and communication with the USB port. The device is also powered from the USB port, with a voltage regulator (LP3982) providing a 3.3 V supply voltage for the microcontroller and the reader 1C. The reader 1C is an NXP PN51 2, which is suitable for RFID devices compliant with the ISO 14443 standard. The PN512 (data sheet available at [3]) can also be used as a transceiver for near field communication (NFC). The reader is useful in two ways. The first is that it gives you a reference design, with the implementation of the matching network between the 1C and the transmit coil being especially interesting. The associated circuit diagram is shown in Figure 2. An application note with an Excel worksheet for component dimensioning [4] is available from NXP. As you can see from the application note, the design of the reader is closely based on the recommended component values. If you have the reader in question, you can naturally use the existing circuitry to build your own reader. In our case, we unsoldered the existing microcontroller and replaced it with an ATmega88, as shown in Figure 3, to make the DIY reader shown in Figure 4. The circuitry around the AT mega88 is built on a piece of perforated circuit board connected to the BSI reader board with the PN512 1C. In Figure 5 you can see how the two boards are joined by thin enamelled copper wires. If you do not have a BSI reader or do not want to modify it, you can always build your own ISO 14443 reader by combining the circuits shown in Figures 2 and 3 and powering the circuit from a 3.3 V supply. Although the PN51 2 reader 1C can be obtained from various distributors, it is only available in a QFN package and must therefore be reflow soldered. Software The commands supported by MIFARE cards and the method used to convey them can be determined from the MIFARE card documentation and the ISO 14443 standard. We wrote some 24 04-2012 elektor MICROCONTROLLER software that allows some of the basic functions to be tested. The implemented commands and the results obtained from reading the unique ID number (UID) are shown in Listing 1 . Hack #2: BSI reader with MFRC523 When we opened up a second BSI reader from the Computer Bild giveaway campaign, we discovered that it was fitted with an MFRC523 instead of a PN512.The MFRC523 [5] is largely compatible 110750 - 11 +3V3 Figure 1 . Block diagram of the BSI reader. Figure 2. Wiring of the PN51 2 reader 1C. Listing i. Log of a MIFARE card reading session Enter command: W test WRITE Mifare r test REQA u test Get UID d test Get Version DesFire e test DesFire2 f test DesFire3 m test MIFARE Get UID PN512reset Transmitter started. REQUA: TX : [ 26 ] RX : [ 44 00 ] COLLISION LEVEL 1 (NoCRC)TX: [ 93 20 ] RX : [ 88 04 D2 3A 64 ] SELECT LEVEL 1 TX : [ 93 70 88 04 D2 3A 64 ] RX: [ 04 ] SAK=04 COLLISION LEVEL 2 (NoCRC)TX: [ 95 20 ] RX : [ 29 EE 02 80 45 ] SELECT LEVEL 2 TX : [ 95 70 29 EE 02 80 45 ] RX : [ 00 ] SAK=00 UID complete after level 2 UID= 04 D2 3A 64 29 EE 02 80 45 Read Mifare Card Data UID= 04 D2 3A 64 29 EE 02 80 45 SELECTED ! ReadData TX: [ 3 0 00 ] RX: [ 04 D2 3A 64 29 EE 02 80 45 48 00 00 00 00 00 00 ] ReadData TX: [ 3 0 04 ] RX: [ FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 ] ReadData TX: [ 3 0 08 ] RX: [ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ] ReadData TX: [ 3 0 OC ] RX: [ AA 55 BB 66 00 00 00 00 00 00 00 00 00 00 00 00 ] elektor 04-2012 25 MICROCONTROLLER +3V3 +3V3 values output as analogue values using a 5-bit DAC. Among other things, this can be used to judge the strength and quality of the received signal. This is illustrated by the oscillogram in Figure 8. The lower trace shows the analogue demodulator signal, and the upper trace shows the received digital signal. Optimal settings for the numerous parameters of the reader can be determined by analysing this and other signals. Hack #3: IS 0 15693 RFID devices Now that we’ve described the circuits for ISO 14443 RFID devices, it’s time for a final DIY circuit for an ISO 15693 RFID device reader, which does not require any special components. ISO 15693 and ISO 14443 are the two most Figure 3. ATmega88 circuit for use with the PN51 2 circuit. with the PN51 2, but a few software changes are necessary. To make experimenting easier, we soldered an MFRC523 on an adapter board. The reader assembled in this manner is shown in Figure 6. We made a special effort to simplify the complex coil matching circuit shown in Figure 2. As a result, we discovered that an ordinary LC circuit makes an adequate transmit circuit. This yields the considerably simpler circuit for a complete reader shown in Figure 7. The MFRC523 (like the PN51 2) can output tests signals on its test pins (MFIN, MFOUT, AUX1 and AUX2), including internal digital commonly used standards for 13.56 MHz RFID devices. Although these two standards use the same frequency, they involve distinctly different systems. ISO 1 4443 defines an interface for contactless smart cards with a maximum range of 10 cm, while ISO 15693 defines an interface for contactless tags with a maximum range of 1 .5 m. The circuit diagram of the ISO 15963 reader is shown in Figure 9, and the construction of the first prototype is shown in Figure 10. A 1 3.56 MHz crystal in the circuit provides the clock signal for the ATmega88 microcontroller as well as the HF signal for the transmit coil (LI ). The microcontroller can key the transmit signal using gate IC1 b in order to send data to the RFID device. The signal is transmitted by the series-resonant circuit LI / C6. Ir *i ' Viiii Efoklpr/Ekkliwr Of tkcfrenke 7006 i Figure 4. Prototype with ATmega88 and PN512 reader board. Figure 5. Use fine enamelled copper wires for connection to the reader board. 26 04-2012 elektor MICROCONTROLLER Figure 6. DIY reader with an MFRC523 on an adapter board. Figure 8. Test signals measured at the MFRC523: demodulated analogue signal (bottom) and received digital data (top). to PC IC2 MAX3232 +3V3 © IC1 Cl H h lOOn 16 MHz — 1 > +3V3 © VCC AVCC 2 PDO RXD PB1 3 PD1 TXD PD7 IC3 PD6 1 RESET PD5 19 PB5 SCK PD4 18 PB4 MISO PD3 17 PB3 MOSI PD2 14 PBO PCI 16 _ PB2 ATMega88 PC2 23 PCO PC3 27 PC4 28 PC5 AREF GND XTAL1 XTAL2 AGND +3V3 +3V3 LED LED 24 JP1 j — o o — JP2 — o o-* lOOn +3V3 © 13 24 12 31 11 6 6 23_ 5 29 4 30 AO ALESS D7 MISO RSTPD IRQ D5SCK D6 MOSI MFOUT MFIN TX2 AUX1 AUX2 MFRC523 A1 DVSS PVSS TVSS VMID TVSS AVSS OSCIN OSCOUT ~^C2 21 Q 1 22 < CIO H 1 C9 22p — < >— < *— < 22p > * LI 2uH lOOn = 27.12MHz 110750 - 14 Figure 7. Circuit diagram of the MRFC523 reader. The RFID tag responds using load modulation with a 423.75 kHz subcarrier. Figure 1 1 shows the signal at the transmit coil during a high-speed data exchange. The 13.56 MHz carrier can be seen in the middle. The sidebands generated by load modulation are located to the left and the right of the carrier at a spacing of 423.75 kHz. This signal is demodulated by rectifying the coil signal with diodes D1 and D2. Resonant circuit C9/L2 is tuned to 423.75 kHz and filters the received signal. The resulting signal is amplified byTI and filtered again by L3/C1 1. To extract the useful data, this 423.75 kHz signal is rectified by diodes D2 and D4 and low-pass filtered by C3, R6 and Cl 4. The resulting signal is applied to the ADC input of the microcontroller. There it is sampled at a rate of 52.986 kHz (13.56 MHz 256), so that each bit is represented by eight samples. This is achieved by clocking the ADC at a frequency of 847.5 kHz (13.56 MHz^- 16). This is distinctly higher than the maximum allowable frequency, with the result that we obtain less than 1 0-bit accuracy, but in our case this does not matter. The software first determines the signal level, then the optimal sampling time (bit synchronisation), and finally the start of frame (SOF). After this the useful data can be read. Alignment The receiver stage must be aligned in order to achieve a good range. To do this, fit jumper JP2 and then switch the reader on. This causes the 1 3.56 MHz signal to be pulse-width modulated at 423.75 kHz, using a 3.31 kHz square wave as the baseband modulation signal. With this test signal and an oscilloscope, alignment can be performed conveniently in a step by step process. After adjusting R1 to obtain the maximum transmit signal amplitude, you should see a 423 kHz signal on C9, modulated (keyed) by the 3.31 kHz square wave signal. Adjust C9 to maximise the amplitude of this signal. This is best done by replacing C9 with a 500 pf variable capacitor, adjusting it for maximum signal amplitude, and measuring the capacitance value. Of course, you can also use the cut-and-try approach with various values for C9. Once the resonant circuit C9/L2 is aligned, use the oscilloscope to elektor 04-2012 27 MICROCONTROLLER +5V © to PC MAX3232 19 ISP< 18 17 +5V © 13 12 TRIGOUT 11 IC1.A MOD 5 & R1 -| 1M |- C1 22pT R2 13.56 MHz R3 I M 10R h~T 1 | C3 1 1 |C4 20 ^^0 C4 lOOn vcc AVCC PDORXD PB1 PD1 TXD IC2 PBO RESET PB2 PB5SCK PB4 MISO ADCO PCO PB3 MOSI PCI PD7 PC2 PD6 PC3 PD5 ATMega88 PC4 PD4 PC5 PD3 PD2 AREF GND XTAL1 XTAL2 AGND IC1.B & X C2 10 15 14 16 23 24 | — O JP1 25 JP2 -o o-* 26 1 JP3 27 L - O <0-+ 28 21 22 T- C5 lOOn +5V © R7 L3 IC1.C & IC1.D & IC1 = 74HC00 D1 / V R11 250R k C7 n C8 470 P 5p...60p £ n | C8 D2 RIO 470uH E-r-® L2 R>- RF C9 220p C12 270p' D4 < CO CO \ 470uH T nr R8 2k5 DEMOD D3 470uH 1 i i I 1 11 C13 330p R6 ^ 6k8 R5 C14 330p 2x BAT43 2x BAT43 110750 - 15 Figure 9. Circuit diagram of the ISO 1 5693 reader. Listing 2. Readout from an RFID tag in a book - - >READsystemINFO TX= [ 0 0 2 B ; 96 90 ] RX=[00 OF 4E 82 61 45 00 01 04 E0 00 00 IB 03 01;13 10 ] UID=E0 04 010 04561 824E DSFID= 0 0 AFI = 0 0 MEM_BLKS=1B BYTESinBLK= 04 - - > DATA= 00 0 0 1 1 11 X 11 01 01 3 2 ; F 8 41 ] DATA= 1 1 01 01 32 2 01 RX= [00 31 20 54 5 7 ; A8 0E ] DATA= 3 1 20 54 57 1 TW 02 RX= [00 51 20 31 3 4 ; 3 C DD ] DATA= 5 1 20 31 34 Q 14 03 RX= [00 35 31 28 32 ;C2 CE ] DATA=3 5 31 28 32 51 (2 04 RX= [00 29 00 00 1 8 ; 8 E 25 ] DATA=2 9 00 00 18 ) 05 RX= [00 98 44 45 4 1 ; 2 4 CA ] DATA= 9 8 44 45 41 DEA 06 RX= [00 39 36 00 0 0 ; 9 1 2A ] DATA= 3 9 36 00 00 96 07 RX= [00 00 00 00 0 0 ; 7 7 CF ] DATA= 0 0 00 00 00 28 04-2012 elektor MICROCONTROLLER Internet Links [1] www.reiner-sct.com/npa/basis.html (ReinerSCT cyberjack RFID Basis product page) (in German only) [ 2 ] www.heise.de/ct/artikel/ePerso-Alltag-Vom-Foerdern-und- Fordern-Update-1 1471 16.html (in German only) [3] www.nxp.com/acrobat_download 2 /other/ identification/1 24533.pdf (PN51 2 data sheet) [4] www.nxp.com/documents/application_note/AN1445_An1444. zip (AN1445 Antenna design guide for MFRC52x, PN51x, PN53x; AN1444 RF Design Guide plus Excel Calculation) [5] www.nxp.com/documents/data_sheet/MFRC523.pdf (MFRC523 data sheet) [ 6 ] www.waazaa.org/download/fcd-1 5693-3.pdf (Identification cards - Contactless integrated circuit(s) cards - Vicinity cards Part 3: Anti-collision and transmission protocol) [7] www.waazaa.org/download/fcd-1 5693-2.pdf (ISO/I EC FCD 1 5693-2 Identification cards - Contactless integrated circuit(s) cards -Vicinity cards -Part 2: Radio frequency power and signal measure the signal at the drain lead of T1 . Adjust Cl 1 to maximise the signal amplitude at this point. You can view the demodulated signal on Cl 4 (‘Demod’ test point). Adjust the amplitude by varying the value of R1 1 until T1 is no longer overdriven. Figure 12 shows the signal on the drain lead of T1 (uppertrace) and the demodulated signal (lowertrace) when an RFID card is being read. The amplitude of the demodulated signal is approximately 3 V. Finally, adjust the value of C6 for maximum range. You can use the software to read various types of data from ISO 1 5963 cards. For instance, many libraries have fitted RFID tags on their books. Listing 2 shows the result of analysing the data from a book with the signature ‘TWQ 1 451 (2)’. As you can see, the signature is stored in the data area as plain text. All sorts of experiments can be performed using the circuits described here. The software is available for free download [13], so you can also use it (either as is or modified) for your own projects. ( 110750 ) PEF t5 « 0 46* OFFSET -35$ 200 »0 Hi LO dB/OIV RANGE 15-0 4Bn -17*3 dB Figure 1 1 . Spectrum during data exchange. interface) [ 8 ] www.waazaa.org/download/fcd-1 4443-2.pdf (ISO/IEC 1 4443- 2 cards, Contactless integrated circuit(s) cards - frequency, power and signal interface) [9] www.waazaa.org/download/fcd-14443-3.pdf (ISO/IEC 14443-3 Identification cards Contactless integrated circuit(s) cards - Proximity cards Part 3: Initialization and anticollision) [10] www.elektor.com/060221 (Ossmann, Martin: Experimental RFID Reader) [1 1 ] www.elektor.de/0601 32-2 (Schalk, Gerhard: The Elektor Electronics RFID Card 1 3.56 MHz card with MIFARE Ultralight 1C) (in German only) [12] www.elektor.de/060132-1 (Schalk, Gerhard: Elektor RFID Reader for MIFARE and ISO 14443-A cards) (in German only) [13] www.elektor.com/ 1 1 0750 (web page with downloads and links for this article) Figure 1 0. Prototype of the ISO 1 5693 reader. Figure 1 2. Received 432 kHz signal and demodulated signal. elektor 04-2012 29 POWER SUPPLIES & BATTERY CHARGERS Lab PSU for Embedded Developers Power supply for microcontroller By Ingo Cerlach (DHiAAD, ingo.gerlach@onlinehome.de) Anyone who develops circuits using microcontrollers knows that plug-in ‘wall wart’ power packs do not always make suitable power supplies. On the other hand, a proper laboratory power supply is expensive overkill — it’s too bulky and generally delivers only a single voltage. The PSU described here is small and supplies controllers with the 3.3 V or 5 V used typically. A second preset voltage between o and 15 V is provided for peripherals. circuits Characteristics • Input voltage 18 - 22 V >2 A • Output voltage 1:3.3 V and 5.0 V switchable • Output voltage 2: 0 - 15 V adjustable • Output current: 0 -1 A V adjustable • Display of voltage, current and temperature If you are dealing with just one microcon- troller and a couple of logic ICs or a small evaluation PCB, then a basic plug-in power supply will normally do the business. But if the peripherals are more extensive (or ana- logue ones with their predominantly higher voltages), a simple PSU of this kind will no longer be up to the job. You could of course still use a 5 V or 3.3 V plug-in PSU along with an adjustable-voltage lab PSU. But a more elegant and appropriate solution would be a small but sufficient PSU that meets the exact requirements of microcontroller developers. Specification Precisely these considerations inspired Ingo Gerlach to construct a PSU that would deliver not only a fixed voltage switchable between 5 V and 3.3 V for microcontroller electronics but also a separate supply for peripherals fully adjustable to any voltage between 0 and 1 5 V. A further feature was current limitation able to be set at any value without restriction. Microcontrollers and associated electronics seldom require more than a few tens of mA current. The PSU presented here, delivering a maximum of 1 A, it therefore fully ade- quate. Current limiting that can be preset between 0 and 1 A is a very handy extra. For the peripherals the 1 A maximum available is generally more than sufficient. For larger current requirements typically you would need special PSUs in any case. When we are producing a custom PSU spe- cifically for microcontroller circuit use, a digital display of current and voltage on both outputs is an absolute necessity. Con- sequently we need an LCD display and a small microcontroller to drive it. This also offers a bonus in that we can hook up a temperature sensor to monitor whether our PSU is overheating. Another plus-point is that we can use the controller already on board to switch in a cooling fan as and when required. Anyone dealing with digital electronics will consider the use of a ‘normal’ heavy trans- former plus bridge rectifier and smoothing capacitors somewhat anachronistic. Instead the author employed an off-the-shelf laptop power supply. External PSUs of this kind are extremely compact and efficient. You can often get hold of obsolete models at low prices, with output voltages between 18 and 22 V and need not worry about build- ing an inboard power supply and problems of components carrying mains voltage. Circuit specifics To meet the specification just described we’ll need more than just a couple of ICs to do the business. That said, the circuit in Figure 1 is by no means as complex as it appears at first sight. Both output voltages are produced using adjustable three-legged voltage regulators of the type LT1086. In order to achieve voltages all the way down 30 04-2012 elektor POWER SUPPLIES & BATTERY CHARGERS to 0 V together with proper short circuit protection, the value of the internal refer- ence voltage must be lowered from 1 .25 V at the lowest point of output voltage. In our circuit this negative auxiliary voltage is achieved in the following manner: If you follow the input from the external laptop PSU appearing at XI (D1 serves as protection against reverse connection) you reach IC1 1 , which produces a voltage of 1 2 V supplying not only the op-amps but also (by means of the 5 V regulator IC10) microcontroller IC8 and the LCD display. The same 12 V supply rail enables DC/DC-con- verter DC1 to generate a negative voltage of -5 V, in turn making it possible for IC7 to produce the necessary -1 .25 V. This -1.25 V voltage is connected to one side of P2, enabling the output voltage of IC1 to be adjusted between 0 and 1 5 V. It is also connected via switch SL5 to one of the other of the two trimpots R1 5 or R1 6. Appropriate adjustment of these enables you to switch between 3.3 V and 5 V. Presta- bilisation of the 1 2 V rail by means of IC4 serves to apportion the power loss. Current limitation requires us to monitor the value of current flowing. Measuring this is a fairly tricky assignment— as can be read in the application note [1] from Lin- ear Technology. In fact this involves a non ground-referenced high-side measure- ment (see weblink [3] for explanation of high-side and low-side monitoring). Ahead of IC5 you will see R1 0, which yields a volt- age proportional to current (0.1 V at 1 A). This voltage drop certainly occurs around the 1 2 V level. IC6 now produces from this (with the help of R1 1 and T5) a propor- tional current of up to 1 mA, which also flows though R1 7. At R1 7 we have a volt- age drop proportional to the current of up to 1 V — but referenced to ground! Input ADC3 of the microcontroller moni- tors this voltage, which appears simultane- ously on the non-inverting input of op-amp IC3.B. On its inverting input we have the voltage (IPOT) that was set by PI . Should the current flowing exceed the maximum that has been preset, then T4 is driven fur- Figure 1 . Circuit details of the lab power supply for microcontrollers. SL4 Output 3V3/5V0 LC DISPLAY CO o ? co o O co ^ > > > OH O' -555S5555E +5V vcc AVCC PCO(ADCO) PCI(ADCI) PC2(ADC2) IC8 PDO(RXD) PC3(ADC3) PDI(TXD) PC4(ADC4/SDA) PD2(INT0) PC5(ADC5/SCL) PD3(INT1) PC6(RESET) PD4(XCK/TO) ATMEGA8-P PD5(T1) PBO(ICP) PD6(AIN0) PBI(OCIA) PD7(AIN1) PB2(SS/OC1B) PB3(MOSI/OC2) PB4(MISO) AREF PB5(SCK) PB6 PB7 GND XTAL1 XTAL2 AGND |io & R21 10k 13 14 15 13 22 21 1 0 C24 lOOn 110645 - 11 elektor 04-2012 3i POWER SUPPLIES & BATTERY CHARGERS Figure 2. The author’s circuit board, built inside a project case. The Figure 3. The author’s completed prototype looks like this, heatsink (not visible here) is located on the rear of the aluminium panel carrying the voltage regulators. Operation and Software Despite the presence of a microcontroller the voltage and current are set by analogue means. The microcontroller’s prime function is to display present voltage and current values. The outputs are disconnected if the temperature limit is exceeded. Following switch-on the firmware version number is displayed briefly. After this the display indicates the temperature of the heatsink and the maximum current set. Following this we see the standard display format of voltage and current. With a load applied the current flowing is displayed. When the current maximum is altered the second line indicates the new value defined. Pressing the button next to the display switches off the outputs (and then displays the current temperature of the heatsink). This alarm appears when the preset warning level is reached. If the maximum temperature is reached this display appears. If this value is exceeded the outputs are turned off. td ® AAD/05/U Pou.ierSupply 1.0 7i=:rfip: 3i C Ok K-bixI: 625 iTift 0.03 U 0 :YlH 3.30 i..J 0 rr,R 9,00 b 500 mA 3,30 0 S iYiA 8,88 3 200rnA naxL 475rr,ti 1 0.00 U 0 rrifr 0 00 U 0 mrl I i E: Warn 5,80 U @ r.iA fernp:43C Err 5,88 U 8 mft 10.20 *0 ff* 5,88 U 8 rnA ther. The output voltage then sinks suffi- ciently that the input voltages of IC3.B are once again equal. The voltage on IC1 preset by P2 is handled in just the same way. Inter- estingly at this point the level of the high- side current measurement taken across R1 lies distinctly above the 1 2 V supply voltage of IC2. This happens only with op-amps like the LT1636, whose input common-mode voltage range is independent of the supply voltage up to 44 V maximum. So much for the analogue circuitry section. The digital side consists of the microcon- troller IC8, which not only measures out- put voltages and currents but also drives the LCD. With the help of IC9 it also mon- itors the temperature of IC1 , IC4 and IC5 on the heatsink and additionally controls a blower as required. The firmware is con- nected to the controller using the ISP con- nector SV1 . A quartz crystal is not required since the stability of the internal clock (pre- set at 4 MHz) is adequate. Pin 1 of SL7 is not intended for direct operation of the blower since insufficient current is available at the pins of IC8. Suitable blowers can instead be operated using their control input. The press button at SL6 serves as an ‘emergency off switch, which you can use to disconnect both outputs instantly. Construction and alignment The author has made available the layout files for the PCB he developed in Eagle for- mat. As normal, you can download these 32 04-2012 elektor POWER SUPPLIES & BATTERY CHARGERS files from the webpage relating to this arti- cle [2]. Here you can also find the firmware in C and in hex-code form as well as CAD files for the front panel. Populating the PCB with components is relatively simple, as SMD components are not used at all. The only thing to note is that upright-spindle trimmers are used for the trimpots. The author recommends a multi- turn pot for adjusting the output voltage. For mounting IC1 , IC4 and IC5 the author installed an aluminium panel inside the plastic project case with an aluminium heat- sink measuring 50 x 88 x 35 mm provided on the rear of the ali panel (see Figure 2). It is vital that the three voltage regulators remain insulated when they are bolted to the ali panel and that IC9 is in thermal con- tact with the heatsink. Some thermal grease will help in this respect. Before connecting power to XI you should adjust PI to its central position; do not fit IC8 yet. PI should be adjusted so that ICI produces an output voltage of exactly 1 2 V. Next adjust trim pot R5 so that pin 24 of IC8’s socket measures exactly 1 .20 V. Now it’s the turn of the switchable fixed voltage: we need to adjust R1 5 to produce 3.30 V and R16 to produce 5.0 V at the output of IC5. When the switch is set for 5.0 V R1 4 should be lined up so that exactly 0.50 V is measured at pin 27 of IC8. IC8 can now be fixed in its socket and — if you have not already done so— programmed. Fol- lowing switch-on the current values (volt- ages and currents) should be displayed, as the author’s completed prototype shows in Figure 3. (110645) Internet Links [1 ] http://cds.linear.com/docs/Applica- tion%20Note/an1 05.pdf [2] www.elektor.com/ 1 10645 [3] http://en.wikipedia.org/wiki/ Shunt_(electrical) Advertisement Beta LAYOUT Free Phone UK: 0800 389 8560 sales@pcb-pool.com p-cadznp$ .tiLar^i Attmm Ue&iner PCBrJS"! A A prEE Stencu > T'- of 4 5 ■ nnL . eagle T- / StfSKSj,- I H&0ML s ftssemUV 6 TK 3 - E® Pn % All registered brands remain the registered trademarks of the respective manufacturer ! tddcnte Qf(i?;riiCnda PHIH S PJ5 ¥ NrtiinNAJ IMITPUMENTS iu: .1 p p ■ rKV n D RS-274-X Easy-PC ■ PULSGNIX www.beta-layout.com elektor 04-2012 33 MICROCONTROLLERS LED Touch Panel Shine and touch Design: Thomas Pototschnig (Germany) Text: Luc Lemmens (Elektor Labs) A touch panel can be made in several different ways. Although the method described here has been known about for a substantial number of years, it is rarely used in practice. Despite this, it is very interesting and it’s certainly worth experimenting with. The theory: Two IR LEDs transmit light. When a finger is above them the light will be reflected off it, which can then be detected by a third IR LED that has been configured as a detector at that point in time. Touch sensitive switches have been relia- ble replacements for mechanical switches for may years. They also provide a much smoother way to control a device. They are much less prone to wear and they can, depending on the technology used, often be used in conditions where their mechani- cal counterparts would fail. Several methods are used to detect a key- press or a position on a touch panel, which often involves a detection of the change in resistance or capacitance. In this project a completely different method is used. Here we make use of the reflection and detec- tion of (infrared) light to determine where a panel is touched. The panel itself consists of a matrix of eight by eight IR LEDs, where use is made of a little known property of LEDs: they can detect light as well as emit light. An LED that has light shining on it with pref- erably the same wavelength will produce a small voltage as long as it’s not heavily loaded. Simply put, the method used here uses three LEDs at a time. The circuit lights up the outer two LEDs and the middle LED is used to ‘see’ if any of the light is reflected (Figure 1 ). When the matrix is scanned con- tinuously, it is possible to determine where the panel is touched. The panel sends the information via the USB link to a PC where a program calculates the touch position and displays it on a square window of 8 by 8 Figure 1 . The theory: Two LEDs emit IR light, which is reflected by the finger and then detected by the LED in the middle. blocks. The resolution is therefore quite lim- ited and the PC application is used more to illustrate the principles involved rather than to have a practical purpose. It does, how- ever, lend itself to experimentation, since both the firmware and the C++ application for the PC have their source code available for free on our website [1]. Circuit diagram Figure 2 shows the circuit diagram of the LED section. In here you can see that what was previously described as an 8 x 8 matrix is in reality made up of two matrices of four by eight LEDs (Figure 3). The even columns belong to one matrix and the odd ones to the other. This makes it possible to make LEDs in certain columns transmit, whilst those in the neighbouring column are used to detect how much of the light is reflected. At the heart of the circuit in Figure 4 is IC3, an ARM7 microcontroller made by Atmel. This includes a USB interface, which is used during the programming of the firm- ware for the circuit and also to send scan- ning information to the outside world, in this case the program that’s running on the PC. The connections labelled COLx and ROWy control the drivers for the columns and rows of the LED matrices. Another five port pins are used to control the analogue multiplexer (IC4) and an analogue input on AD4 measures the voltage that comes from a single selected LED in the panel. Between the analogue multiplexer and the A/D input of the microcontroller is a bandpass filter with a centre frequency of 1 0 kHz. When the LEDs function as trans- mitters they are driven with a pulsed signal with a frequency of 1 0 kHz in order to dif- ferentiate and suppress potentially inter- fering light sources. An extra ‘filtering’ of the background light takes place in the software: Immediately after turning on the 34 04-2012 elektor MICROCONTROLLERS Figure 2. The LED section consists of a matrix of 8 x 8 IR LEDs, divided into two groups of 4x 8 LEDs. Matrix A Matrix B Matrix A + Matrix B Kh Figure 3. This is how the two LED groups are wired up. In this way two LEDs can always be driven with the LED in between being used as a sensor. touch panel the first ten scans are used to determine the ‘black’ value of each pixel; it is therefore vital to leave the touch panel unobstructed during this phase. The scanning starts in the top-left corner of the panel. The LEDs in the first and third column of the first row are turned on via drivers IC5 to IC7. At the same time the LED in the second column is connected to AD4 of IC3 (the input to an A/D converter in the microcontroller) via the analogue multi- plexer (IC4) and the bandpass filter around IC2B. When the LEDs in the outermost col- umns are scanned there will only be a single LED lit in the previous column, since there is no other ‘neighbour’. The information from all pixels is sent via the USB link to the PC, where the analysis and the display of infor- mation take place. Construction Elektor Labs have designed two board lay- outs for this project: one for the LEDs and one for the control of the touch panel (Fig- ures 5 and 6). These can be mounted on top of each other, with the LEDs on top. We would recommend that you first solder the ARM7 processor (IC3), which is by far the most difficult part in this project with its 64-pin LQFP package. It won’t do any harm to wait with mounting the driver ICs, the fil- ter and the analogue multiplexer. Instead, you should first test the USB connection between the PC and touch panel (see the text below) before you fully populate the PCB. This makes any subsequent fault find- ing much easier should you need to carry it out. During the test phase of the circuit and whilst modifying the firmware for the pro- cessor it’s easier if you mount a (temporary) switch on JP1 . Programming the ARM processor To make the touch panel work, the ARM processor first has to be provided with the correct firmware. From Atmel’s website you can download a program called SAM-BA [2], which is a PC application that lets you pro- gram the flash memory of the touch panel. You should install this program on your PC. As part of the download on our web- site for this project [1 ] you will also find the source code for the firmware for the AT91 SAM7S256, developed using WinARM. Before you connect the supply voltage (i.e. connect the USB cable) you should put a jumper across JP1 of the touch panel. Once the power is connected you should wait a minimum of 1 0 seconds. The processor will then load SAM-BA Boot in the first sectors of its flash memory. This is the boot program that, amongst other things, makes it pos- sible to program the ARM via the USB port. This so-called Boot Recovery Procedure is carried out automatically when the TST, PAO, PA1 and PA2 pins are all high during the start-up. The jumper sets the TST level; the other port pins are all held high by pull- up resistors (R3 to R5). After 10 seconds you should disconnect the USB cable, remove jumperJPI and then reconnect the circuit to the PC again using the USB cable. Windows will then detect a new device and should install its associated driver. If for some reason this driver isn’t found automatically, you should manually select the folder ‘DRV’ in the Atmel SAM-BA folder. When the installation of the driver has finished, you should see the window shown in Figure 7. Next, start SAM-BA on the PC. If necessary, select the required virtual COM port for the USB connection and the target board as shown in the screen-dump in Figure 8. elektor 04-2012 35 MICROCONTROLLERS si H 1 3V3 O ^4u7^00^C MUX AO 48 v MUX A1 47 v MUX A2 44 «. R0W4A 43 «. R0W6B 36 «. R0W7A 35 «. R0W7B 34 v MUX INH 32 31 30 MUX A3 29 ' R0W3B 28 ' R0W3A 27 ' R0W1A 22 ' ROWOB 21 ' ROWOA 20 / C0L6 9 ' C0L5 10 ' C0L3 13 ' COLO 16 ' C0L4 11 ' C0L2 14 ' C0L1 15 ' R0W1B 23 ' R0W2A 25 ' R0W2B 26 ' R0W6A 37 ' R0W5B 38 ' R0W5A 41 ' R0W4B 42 ' C0L7 52 oo in oo — m ^■ 14 c ^00i^7l C15 4u7 Jci6^C' ^To lOOn MOOn o o o Odd d d d > > > PAO/PGMENO PA1/PGMEN1 PA2/PGMEN2 PA3 PA4/PGMNCMD PA5/PGMRDY PA6/PGMNOE PA7/PGMNVALID PA8/PGMM0 PA9/PGMM1 PA10/PGMM2 PA11/PGMM3 PA12/PGMD0 PA13/PGMD1 PA14/PGMD2 PA15/PGMD3 PA17/PGMD5/AD0 PA18/PGMD6/AD1 PA19/PGMD7/AD2 PA20/PGMD8/AD3 PA21/PGMD9 PA22/PGMD10 PA23/PGMD1 1 PA24/PGMD12 PA25/PGMD13 PA26/PGMD14 PA27/PGMD15 PA28 PA29 PA30 PA31 d d z z C3 C9 d d > C/5 3 LL. d d > CC O O O O d d d d > > Di = cr 1 O O O Q 9 d □ 0 d > > > TST IC3 ADVREF AT91 SAM7S256-AU-001 O 19 a. AD7 AD6 AD5 AD4 PA16/PGMD4 ERASE DDM DDP TDI TDO TCK TMS JTAGSEL PLLRC NRST o x d d z z C9 C9 C19 lOp XI fill 18.432MHz ~r~ C18 lOp 40 3V3 JPl v+o v+o v MUX AO | 10 v MUX A1 11 v MUX A2 14 v MUX A3 13 MUX INH 15 3V3 | R27 IC1 LM1117MP-3.3 C20 MOOn +5V < ■> ♦ 5 -03V3 33u ANALOG_OUT GNDA +5V DDM DDP V 33 'R0W7A 7 'R0W6B 6 49 'R0W6A 5 53 'R0W5B 4 51 'R0W5A 3 50 'R0W4B 2 'R0W4A 1 S2 H R33 C25 In ^0 C26 lOn ROW7B 8 y 18 CO > 08 17 IC5 07 16 06 15 05 14 04 13 03 12 02 11 O 01 z 0 - A2982SLW-T ROWOA 8 'rowob 7 'rowia 6 'rowib 5 'R0W2A 4 'R0W2B 3 'R0W3A 2 'R0W3B 1 T y K3 13 R13 14 R14 15 R15 16 R16 17 R17 18 R19 19 R20 20 R21 33R J3R_ J3R_ 33R 33R 33R 33R 33R 1 8 ■j 7 1 6 1 5 j 4 1 3 1 2 j 1 3V3 O R18 R22 Tk T1 «) +5V O C27 33u C23 lOOn BC857 +5V O R23 tn > IC6 d z o 08 07 06 05 04 03 02 01 T 13 R24 r 14 R25 r 15 R26 r 16 R28 r 17 R29 r 18 R30 r 19 R31 r 20 R32 r K5 33R 33R 33R 33R i 33R_ 33R 1 8 | 7 1 6 1 5 I 4 1 3 1 2 1 1 COL7 8 COL6 7 ' COL5 6 ' COL4 5 ' COL3 4 ' COL2 3 ' COL1 2 ' COLO 1 H A2982SLW-T CO > IC7 d z IS 08 07 06 05 04 03 02 01 11 8 12 7 13 6 14 5 15 4 16 3 17 2 18 1 DDM ULN2803AFWG DDP _ n |C28 C2 ^5p"" R34 27R R35 27 R JC22 ^33p C21 C24 15p 1 DOn K4 CT> O — _ — s. —J USB MINI B 070558 - 11 Figure 4. The circuit diagram for the touch panel is fairly straightforward. Most of the hard work is done in software. Figure 5. The PCB for the electronics from Figure 2 (90% of real size). Figure 6. This PCB is home to the 64 IR LEDs (90% of real size). 36 04-2012 elektor MICROCONTROLLERS COMPONENT LIST Controller Board Resistors (all SMD 0805) R1 = 300l 127 Then D = 255 - I D = D * D End If D = D / 64 PwmOa = D Waitms 60 Next I Waitms 800 Loop End +5V stant. A simple way to implement this is to add a source resistor, as shown in Figure 5. This arrangement is often used to gener- ate the gate bias voltage ‘automatically’. It also improves the stability of the output current by increasing the internal resist- ance. This works as follows: if the output current increases, the voltage drop over the source resistor also increases, caus- ing the gate voltage to be more negative relative to the source voltage. This acts to reduce the drain current. This circuit effec- tively generates a simple form of negative feedback. You can also set the value of the current within wide limits by selecting the value of the resistor. If you want to have a bit more than 1 mA, simply use a resistor with a lower value. Using a bipolar transistor The circuit shown in Figure 6 is a simple constant current source built around an NPN transistor, which converts a constant voltage into a constant current. A Zener diode at the input stabilises the base volt- age at approximately 2.7 V, due to the effect of its steep characteristic curve. As the base-emitter voltage is always approxi- mately 0.6 V, the voltage over the emitter resistor is approximately 2.1 V. This resis- tor therefore determines the emitter cur- rent. The collector current is only slightly less than the emitter current, which also includes the much smaller base current. With negative feedback provided by the emitter resistor, this circuit is almost directly equivalent to the FET circuit shown in Figure 5. The only difference is that here 1 ... 4 LEDs 1 ... 4 LEDs t* A i 1 mA 9... 12V BF245B I Figure 4. A simple JFET constant current source. Figure 5. Using a source resistor to set the current. Figure 6. A constant current source using a Zener diode. elektor 04-2012 41 BASICS Field-effect transistors The two main classes of transistors are bipolar transistors and field-effect transistors (FETs). A field-effect transistor consists of a small piece of semiconductor material with only one type of doping (either p or n). It has an isolated gate electrode, which alters the number of charge carriers in the region between the source and the drain when a voltage is applied to the gate. This changes the conductivity in this region, which is called the channel. Depending on the voltage on the gate, the concentration of charge carriers in the channel is either depleted or enriched. The advantage of field-effect transistors is that they do not need a current to con- trol the output current, but instead a voltage. The gate (G), source (S) and drain (D) terminals of a FET correspond to the base (B), emitter (E) and collector (C) terminals of a bipolar transistor. There are numerous types of field -effect transistors. Along with the junction FET, which has an isolating diode junction between the gate and the channel, there is another type (MOSFET) that has a metallic oxide isolating layer. Like bipolar transistors, MOSFETs are available in two polarities, called n-type MOSFETs and p-type MOSFETs according to the polarity of the source and drain voltages. MOSFETs are basic building blocks of many types of integrated circuits, especially computer ICs. Complementary n-type and p-type MOSFETs are often used in the same 1C, which is called CMOS technology. Power MOSFETs are usually fabricated with a vertical structure and accordingly designated VMOS. The following table provides a comparative overview of the specifications of a number of typical VMOS transistors: Source Gate Drain Type N/P channel Imax Umax p ■max Rds-on Qs Cdg BS107 N 150 mA 200 V 0.8 W 28 O 50 pF 4 pF BS170 N 175 mA 60 V 0.8 W 50 60 pF 5 pF BS250 P 180 mA 45 V 0.8 W 14 a 60 pF 5 pF Junction field-effect transistors use a semiconductor junction to isolate the gate from body of the transistor. This means that the gate voltage must always be negative, as otherwise the GS junction would be biased into conduction. JFETS are classified as depletion-mode FETs because charge carriers are normally present in the channel when no gate voltage is applied, and they can be depleted by applying a voltage to the gate. If an increasingly negative voltage is applied to the gate, the channel between the source and the drain is gradually pinched off until the transistor stops conducting. Incidentally, this behaviour corresponds exactly to that of a vacuum valve. -4 ~ 2 Vqs (V) 0 Atypical example of this type of FET is the BF245, which is primarily intended to be used in high-frequency applications. It has a typical transconductance of 5 mA/V, which means that changing the gate voltage by 1 V causes the drain current to change by 5 mA. The BF245B has a typical cutoff voltage (zero drain current) of approximately -4 V and a drain current of approximately 1 0 mA with zero gate voltage. you need a positive voltage source for the base, which makes the component count a bit higher. However, the good news is that the BC547 is cheaper and it provides better regulation in this circuit. The nega- tive feedback is so effective with this cir- cuit that you can scarcely measure any Figure 7. A constant current source with two transistors. difference if you first fit a BC547A, then a BC547B and finally a BC547C. In other words, you can use whatever version you happen to have in your parts tray. Another tip: if you don’t have a suitable Zener diode handy, you can replace it with a forward- biased LED and still obtain good results. Test the results for yourself with a new bat- tery and with a nearly discharged battery, or with an adjustable power supply. The LED 42 04-2012 elektor BASICS You want to power three white 1 -watt power LEDs from a 1 2 V lead-acid battery. The LEDs have a specified forward voltage of 3.4 V and a specified operating current of 350 mA. You want to use a constant current source to provide the correct current. The circuit uses a BD1 35 power transistor, which can be at- tached to a heat sink if necessary. The battery voltage can rise as high as 1 4 during charging and drop as low as 1 1 V during discharge. The circuit should operate properly within this range. The current source should supply a current close to 350 mA, but in no case more than 350 mA. At this relatively high current, you can assume that the base- emitter voltage is approximately 0.7 V. 1 ) You have three choices available for resistor R x . Which one would you use? A) 100ft B) 47 ft C) 22 ft 2) You measure a battery voltage of exactly 1 2.6 V, and the voltage over each of the LEDs is 3.4 V. How high is the efficiency of the circuit? D) 81% E) 52% F) 99% 3) You measure a battery voltage of exactly 14 V, and the voltage over each of the LEDs is 3.4 V. If the current is 350 mA, how much power must the BD1 35 dissipate? G) Approximately 0.5 W H) Approximately 1 W I) Approximately 3 W 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 April 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 February 2012 edition is ‘CDH\ Here are the explanations: 1 ) Answer ‘C’ is correct When you touch the contacts , the (small) capacitor charges relatively quickly . The two transistors conduct and light up the LED. Due to the high gain of the Darlington circuit, the base resistance could be even greater than 1 0 Mft, but resistors with such high values are difficult to obtain. The capacitor discharges very slowly, with a time constant of 10 s. However, the LED continues to emit light for much longer than 1 0 s. 2) Both transistors are in the B class and have similar current gains in the range of 200 to 450. Their current gains multiply, so the effective current gain lies in the range of approximately 40,000 to approximately 200,000. The figure of 1 00,000 is close to the middle of this range, so answer ‘D’ is correct. 3) The current gain with two NPN transistors would lie in the same range, and the junction voltages at saturation are the same: the base-emitter voltage is approximately 0.6 V, and the collector-emitter voltage is approximately 0. 1 V. However, there is a difference at the input. With two transistors of the same type, you need twice the usual base-emitter voltage (i.e. approximately 1.2 V) to cause the transistors to conduct. Only one base-emitter voltage (approximately 0. 6 V) is necessary with the complementary circuit. ‘H’ is therefore the correct answer. brightness should remain nearly the same as long as the battery isn’t completely flat, and an ammeter should show a constant collector current. Another commonly used type of constant current source uses a second transistor in place of the LED. In this case the reference voltage is effectively the base-emitter volt- age (around 0.6 V) of the left-hand transis- tor in Figure 7. If the voltage drop over the emitter resistor is too high, the left-hand transistor reduces the base current until everything is as it should be. The current provided by a constant current source is not only independent of supply voltage variations, but also independent of the voltage drop over the load. You can use the switch in the circuit shown in Fig- ure 7 to drive either one or two LEDs with the constant current source. The same cur- rent flows in both cases. This current source is quite practical and provides a current of approximately 6 mA. ( 120004 ) elektor 04-2012 43 ackerspace )f course Elektor’s lab isn’t the only place where ideas are born, projects are created and knowledge is Lathered and spread. There are probably hundreds of Photographs: D. van Zuijlekom No lack off workspaces and equipment. elektor Hacl<42, Arnhem, The Netherlands other ‘communities’ all over the world where people with the same mindset gather to work on their projects and ideas and brush up on their knowledge and skills and socialise. Here we give you a brief peek into the hackerspace of a Dutch group of enthusiasts located in Arnhem. Meet Hacl<42. Umbrellabat t is watching you! A Lab Monkey - every hackerspace needs one! Book Xing - where literary masterpieces are passed on. The PC Museum. How far back do you want to go? You too got an awesome hackerspace and want the world to know? Mail us at editor@elektor.com -—I. - — «— ¥ b m v " tf- elektor 04-2012 45 RADIO & TV AVR Software Sampling signals By Martin Ossmann (Germany) Defined Radio (2) As this series shows, the popular AVR microcontroller can be used for digital signal processing tasks. Here we will use an ATmega88 to sample amplitude- and phase- modulated signals which we can either synthesise ourselves or fish out of the ether. We can even operate at frequencies of above 1 00 kHz. How does it work? Read on to find out, in theory and in practice. A carrier wave can be used to send audio or data through the ether by modulating it in amplitude, frequency or phase. In a ‘software defined radio’ the first thing that happens is that the received signal is sampled; then a processor carries out the necessary calculations to recover the modulating signal. In the case of data transmission, we then decode the signal into a stream of bits. To understand how this all works, we will first look at how an analogue receiver operates. Reception, the analogue way The input stage of many modern receivers looks like Figure 1 (where we have not shown the first stage of ‘preselection’ filtering). It works as follows: suppose first that we want to receive a signal atU in with a frequency of f RX = 2 kHz. We set the frequency f L0 of the local oscil- lator (or ‘LO’) also to f L0 = 2 kHz. In the upper branch of the circuit (which is called the ‘in-phase’ or ‘I* channel) the input signal is multiplicatively mixed with the cosine wave produced by the LO. This produces a DC com- ponent X, which passes unchanged through the low-pass filter that follows. A component at 4 kHz is also produced, which is removed Figure 1 . Quadrature mixing. Figure 2. Geometrical interpretation. 46 04-2012 elektor RADIO & TV by the low-pass filter. The value of X depends on the amplitude A and phase (p of the input signal, the phase being measured relative to the output of the local oscillator. More precisely, ignoring any gain in the low-pass filter, we have X = A cos cp. If the input signal is exactly in phase with the cosine output of the local oscillator, X is maximised: this is why this branch is labelled ‘in-phase’. Much the same happens in the lower branch of the diagram. The difference is that the input is mixed with a sine signal (the cosine signal with a 90 ° phase shift). The value of Y depends again on the amplitude A and phase cp of the input signal, and we have Y = A sin cp. Vis maximised when the input signal is 90 ° phase shifted with respect to the cosine output of the LO. For this reason, the lower branch is called the ‘guadrature’ channel. Figure 2 shows the relationships graphically. The receiver can cal- culate the amplitude A and phase cp of the input signal from the values of X and Y. Let’s get digital Now let’s consider what happens when all the signals involved are sampled at a sample rate f s = 8 kHz, exactly four times the fre- guency of the input signal (see Figure 3). The process of sampling converts the continuous-time input signal into a sequence of numbers. If the input signal l/ in is a cosine wave with amplitude A and frequency 2 kHz (at the top of Figure 3), sam- pling generates the sequence of values L/ in = A, 0, -A, 0, A and so on. The values repeat every four samples, because we are sampling at four times the input frequency. Let us look first at the in-phase channel and sample the cosine out- put signal of the local oscillator. The sequence of samples is LO C os = 1 , 0, -1 , 0, 1 , .... Again, this repeats every four samples. The mixer multiplies the samples of U in by those of LO CO s. The result is the sequence U = A, 0, A, 0, A, .... After the mixer this sequence is passed through a low-pass filter. We can construct a simple low-pass filter by calculating a rolling average of sequences of four consecutive samples of U. For simplicity we multiply this result by 2, and the output of the filter is then X = A, A, A, A, A, ...; in other words, the output is a constant with value A. X can be thought of as samples of a DC level of A, where A is exactly the amplitude of the original input signal. Now we turn to the quadrature branch. The inputs to this branch’s mixer are the sequences U in = A, 0, -A, 0, A, ... and LO S | N = 0, 1 , 0, -1 , 0, .... The product of these sequences is V= 0, 0, 0, 0, 0, ...; in other words, the constant value zero. The result of low-pass filter- ing Vwill also be zero. The same argument can be applied when the input signal is a sine wave U in = A sin (27t • 2 kHz • t), giving the results X = 0 and Y = A. This shows that our discrete-time l-Q mixer works in just the same way as the classical analogue l-Q mixer described above. We have also seen that if the sample rate is four times the signal frequency, the output signals of the LO only take on the values zero, plus one and minus one. This in turn means that the digital mixer does not need a multiplier: we simply need to add and subtract the relevant input samples in the low-pass filter to calculate the values of X and Y. The hardware... A simple front end circuit (Figure 4) was designed to test this idea on an AVR microcontroller. The analogue-to-digital converter inside the ATmega88 is used to sample the input signal L/ in and digitise it. The firmware then carries out the necessary calculations and the results, X and Y, are output using PWM on pins OCOA and OCOB. To K1 VCC +5 V 0 ADC0 +5 V © Cl lOu | LED1 | R5 X C7 n 470n Tr4 R3 I K13 ISP 1 2 17 3 4 16 5 6 1 7 _r\ rv 8 19 9 10 18 15 C8 lOOn +5V © XI 23 R1 20MHz SI H RESET 21 1 10 20 V( :c AVCC PB3 (MOSI) PDO (RXD) PB2 (SS) IC1 PDI(TXD) RESET PD6 (OCOA) PB5 (SCK) PD2 PB4 (MISO) PD3 (OC2B) PB1 (OC1A) PD4 PCO (ADCO) PD7 PCI PC2 PC3 AREF PD5 (OCOB) ATMEGA88-20 PBO XTAL1 PC4 PB7 (XTAL2) PC5 GN D AGND 22 R6 4 1 — 5 6 13 24 _ 25 CLKout 26 11 14 R2 R7 4k7 H 4k7 Ih C4 lOn ?R8 -1-1 4k7 R9 | LED2 ^CUPPING C3 lOn H 4k7 Ih C6 lOn C5 lOn K11 O ♦ DAC2 K10 O ♦ DAC1 100181 - 15 Figure 4. Hardware for a simple front end. elektor 04-2012 47 RADIO & TV +5V' O D13 D14 i USB+5V +5V' 0—1 1 v. C7 < lOOn CM O CM 1^ ^10 Cl 8 lOOn PCO (ADCO) PCI (ADC1) PC2 u. o o OJ o o <5 > > < < IC2 PBO PB1 PB2 PB3 ATMEGA88 (RXD) PDO (TXD) PD1 PD2 PD3 PD4 (OCOB) PD5 (OCOA) PD6 PD7 a o □ o CN| CN| I ii 12 13 +5V' IC3 = 74HC04 IC3F 13 : ic3 100n © IC3E 11 10 K Modi O o USB+5V o-J" TX RX +5V BOB-FT232R-001 R17 -tfCLKout R19 ■ r — I I^J- 1 R20 4k7 Cl 6 lOn C17 lOn <11 R18 4k7 C14 lOn C15 lOn DAC1 K12 100181-11 DAC2 K10 Hi 102 K9 fO| 104 Figure 5. Circuit diagram of our universal receiver board. 48 04-2012 elektor RADIO & TV COMPONENT LIST Figure 6. The printed circuit board is available from Elektor as part of a kit including all the components. Resistors (5%) R1 =2.7ka R2,R22 = ^0n R3 = 220a R4,R1 1 =100kft R5,R14 = 470£1 R6,R13 = 2.2k£l R7,R8,R10 = 470kn R9,R15,R16 = 1k£l R^2 = 2.2Ma R17,R18,R19,R20 = 4.7k£l R21 = 33E1 PI = 1 1<£2 20%, 0.1 5W trimpot P2,P3 =1 Oka 20%, 0.1 5W trimpot Capacitors Cl = 100|iF 25V, radial C2,C3,C21 =10|iF 63V, radial C4,C5,C7,C1 8, Cl 9,C20 = 1 0OnF 50V C6,C1 3 = 470nF 63V C8 = 5.5-65pF 1 50V trimmer C9,C1 1 = lOOpF 5% 100V CIO = 27pF 2% 100V Cl 2 = 5.6pF ±0.25pF 1 00V Cl 4, Cl 5, Cl 6, Cl 7 = 1 0nF 5% 50V Inductors LI = 4.7jiH, 190mA, 1.7 ft L2,L3 = 1 jlxH, 270mA, 0.8 £1 Semiconductors D1 = 1 N4007 D2,D3,D5-D1 2 = LED, red D4 = SB1 1 00 D13,D14 = 1 N5817 T1 = BC560C T2 = BF245B IC1 =7805 IC2 = ATmega88-20PU, programmed IC3 = 74HC04 IC4 = 20MHz oscillator module Miscellaneous XI = 20MHz quartz crystal, 50ppm SI = pushbutton SPST-NO, 6mm footprint K1 = low voltage adapter socket K2,K6,I<8 = 2-pin pinheader, right angled, lead pitch 0.1 in. (2.54mm) K3.K9-K12JP3 = 2-pin pinheader, lead pitch 0.1 in. (2.54mm) K4,K5,JP1 ,JP2 = 3-pin pinheader, lead pitch 0.1 in. (2.54mm) l<7 = 6-pin pinheader, lead pitch 0.1 in. (2.54mm) JP1 ,JP2,JP3 = jumper 0.1 in. (2.54mm) CLKout.TPI = PCB solder pin 4 1C pin receptacles (for IC4) Mod = 5-way pinheader for Elektor BOB-FT232R-001 LCD1 =4x20 LCD e.g. HC200401C-YF62L-VA PCB# 100181-1 attenuate the PWM frequency component in these output signals, each is passed though a two-stage RC low-pass filter. The circuit is straightforward enough to be built on a small piece of prototyping board. Things are made even easier if the Elektor uni- versal receiver board is used: its circuit diagram is shown in Figure 5. As was the case for the signal generator described in the first part of this series [1 ], this is available as a kit including the printed circuit board (Figure 6) and all components. This is a good option, as popu- lating the board is not a tricky task. As you can see from the circuit diagram the universal receiver board includes all the components of the simple front end, but also allows for a wide range of addi- tional future possibilities that we will look at later on in this series. For example, it is possible to connect an active ferrite antenna: an example of such an antenna is again available as an Elektor kit, and elektor 04-2012 49 RADIO & TV Listing 1 : Calculating the quadrature components U=0 ; if ( sampleTime==0 ) { U= ADCv ; } if ( sampleTime==2 ) { U= - ADCv ; } U3=U2 ; U2=U1 ; U1=U0 ; X=U0+U1+U2+U3 ; OCROA=128+X/8 ; U0=U ; V=0 ; if ( sampleTime==l ) { V= ADCv ; } if ( sampleTime==3 ) { V= - ADCv ; } V3=V2 ; V2=V1 ; V1=V0 ; Y=V0+V1+V2+V3 ; OCROB=128+Y/8 ; < 0 II < > • the electronics and printed circuit board will be described in the next instalment in this series. ... and the software... The software, as always, is available as source code and as a hex file for download from the Elektor web site [2]. For our first experiment the software we use is called EXP-SimpleFrontend-2kHz-IQout-V01 . c. The program samples the input signal at a rate of 20 MHz / 5000 = 8 kHz. The signal is then mixed with a 2 kHz signal. A simple low- pass filter then produces the X and Y outputs, which we can also label as the quadrature components / and Q. Listing 1 shows the heart of this routine. The timer variable sam- pleTime always counts cyclically from 0 to 3, and thus repre- sents the current phase of the local oscillator. The variables u and v are used to hold the values that are obtained by multiplying the input value ADCv by the cosine sequence [1 , 0, -1 , 0] and the sine sequence [0, 1 , 0, -1 ] respectively. The values of u and v are then fed into a simple low-pass filter that calculates a rolling average over sets of four samples. The results of this calculation, x and Y, are the in-phase and quadrature components of the signal and are written to the PWM registers OCROA and OCROB respectively. ... and, finally, testing To test the receiver, we feed a sinewave signal from our signal gen- erator into the front end hardware via a 1 0 l<£2 potentiometer to allow adjustable attenuation. We use the SINE OUT (l<3) output of Figure 7. Sampling a 1 0 kHz signal and a 2 kHz signal (red) at 8 kSa/s. the signal generator and the program called EXP-SinusGener- ator-DDS-ASM-c-vo 1; the wiper of the potentiometer is con- nected to input ADC0 on the receiver board. The analogue outputs DAC1 and DAC2 are connected to an oscillo- scope operating in X-Y mode. Then we instruct the signal generator over its RS-232 interface to generate a 2 kHz sinewave [1 ] and adjust the amplitude of the signal using the potentiometer until the red LED (D3 in Figure 5) does not quite light. The front end is then being driven to its maximum level, just short of clipping. The oscilloscope should show a single point that moves slowly in a circle. In theory the point should be stationary, but because the oscillator control- ling the front end is not running at exactly the same frequency as that controlling the signal generator, the point will move. To see the effect more clearly, adjust the signal generator to pro- duce a frequency of 2005 Hz. Then the point will move in a circle making five revolutions per second. With the signal generator set to 1 995 Hz, the point will again move at five revolutions per sec- ond, but in the opposite direction. Adjusting the amplitude of the input signal using the potentiometer affects the radius of the circle in which the point moves. Our ‘l-Q demodulator’ has mixed the signal in the band around 2 kHz down to a centre frequency of 0 Hz. Signals in sidebands above and below 2 kHz are now distinguished in the direction of rotation of the point on the oscilloscope display. Now frequencies around 2 kHz are of relatively little practical interest: more interest- ing are frequencies in the longwave bands used for sending data by various transmitters. This requires one further small step, as we shall see in the next section. The road to RF The Nyquist-Shannon sampling theorem states that a sample rate of at least 2 f is required to represent losslessly a signal containing frequency components up to a frequency f. Using a lower sample rate than this is called ‘undersampling’ or ‘sub-Nyquist sampling’. Take a look at Figure 7. The time interval illustrated is 1 ms long. The upper black curve is a cosine wave, with the corresponding sine wave below, both at 1 0 kHz. As before, the signal is sampled at 8 kSa/s (kilosamples per second), giving sample values indicated by the small blue circles. With conventional sampling we need at least two samples per period of the 1 0 kHz signal, but here we have less than one sample per period: hence the signal is undersampled. The sequence of sample values that we obtain is [1,0, -1, 0, 1, 0, -1,0, 1 ] for the upper signal and [0, 1 , 0, -1 , 0, 1 , 0, -1 , 0] for the lower one. Superimposed on the figure, in red, are 2 kHz cosine- and sin- ewaves. For these signals the sample rate of 8 kSa/s satisfies the sampling theorem; but the surprise is that the 2 kHz signal and the 1 0 kHz signal give rise to the same set of sample values. This means that a 1 0 kHz signal sampled at 8 kSa/s is indistinguishable from a 2 kHz signal sampled at the same rate. In turn this means that our front end, which uses an 8 kSa/s sample clock, can equally well be used to demodulate signals at 1 0 kHz. There is of course a full theoretical analysis of the above phenom- enon, known as the Nyquist-Shannon sampling theorem for band- 50 04-2012 elektor RADIO & TV pass signals. One consequence of this theorem is that a sampled bandpass signal with bandwidth B starting at a multiple of the sample rate f s can be reconstructed perfectly as long as B < f s / 2. In particular, we can reconstruct a bandpass signal with compo- nents stretching from n x f s to n x f s + f s / 2 for any chosen integer n; or, stated another way, a bandpass signal centred at n x f s + f s / 4 with total bandwidth up to f s / 2. In particular, if we have a sample rate of 8 kHz we can demodulate signals equally well around any of the following frequencies: 2 kHz, 2 kHz + 1x8 kHz = 10 kHz, 2 kHz + 2x8 kHz = 1 8 kHz, 2 kHz + 3x8 kHz = 26 kHz, ..., 2 kHz + 20 x 8 kHz = 1 62 kHz, and so on. We can easily test this, for example by setting the signal generator frequency to 26005 Hz. For undersampling like this to be successful the signal being sampled must be band-limited, for example by the insertion of a bandpass filter in front of the AVR. Image frequencies atn x f s -f s / 4 are a Iso received: in our case these images are at 8 kHz - 2 kHz = 6 kHz, 2x8 kHz - 2 kHz = 1 4 kHz, ..., 25 x 8 kHz - 2 kHz = 1 98 kHz, and so on. So far we have assumed that the signal is perfectly digitised, and of course that is not the case. The sample-and-hold stage in any ADC has a so-called ‘aperture’, and a result of this is that it is not possible to mix down very high frequencies using the AVR. However, in the next part of this series, we will see how a signal transmitted by the BBC on 648 kHz (in the mediumwave band!) can easily be decoded. Amplitude and phase ThesignalsXand /give the strength of the in-phase and quadrature components of the input signal. However, we are rather more inter- ested in its amplitude A and phase cp, since one of our ultimate aims is to decode amplitude- and phase-modulated signals. If we had fast floating-point arithmetic we could compute the amplitude and phase from the X and /coordinates using the following two statements. A = sqrt(X * X + Y * Y); PHI = atan2(Y, X); The program EXP-SimpleFrontend-2kHz-Phase-Ampl- V01 . c calculates phase and amplitude using a rather more effi- cient method and outputs the results on DAC1 and DAC2. The out- put voltage level representing amplitude is logarithmically scaled, enabling a direct conversion to dB. Figure 8 shows how the phase of the signal transmitted by the BBC on 198 kHz changes overtime. The signal was received using an active ferrite antenna whose ampli- fied output is fed into the receiver’s front end. Antenna input ANT2 on the receiver board can be used for this purpose, with pin 1 of K4 linked to pin 2 of K5 so that the signal appears on input ADCO of the microcontroller. Again we use a sample rate of 8 kHz. Since 1 98 kHz = 25x8 kHz - 2 kHz, the signal of interest is mixed down to 2 kHz. The BBC transmission includes digital data sent using a phase modulation of ±22.5 degrees at a rate of 25 bit/s. This digi- tal modulation can clearly be observed in the mixed-down signal. FM, PM and AM - with PWM Next we want to try to generate some modulated signals ourselves. First install the program EXP-SQTX-l2 5kHz-PWMa-v0l . c into BPSK and QPSK modulation schemes A special case of phase modulation is binary phase shift keying (BPSK), where the bit values zero and one are encoded by signals 1 80 degrees out of phase with respect to each other. This cannot be done using the PWM method described in the text. However, we can take advantage of the settings available in the AVR’s reg- isters to select whether the event TimerValue == CompareValue results in a positive-going or negative-going edge on the output: in other words, we can selectively invert the PWM output. Intro- ducing this possibility has the effect of adding a further circle to the diagram shown in Figure 1 1 , as shown in the figure here. In particular we now have four signal shapes (represented by the points A, B, C and D) that are spaced at 90 degree phase intervals. This lets us implement QPSK (quadrature phase-shift keying) modulation. If we restrict ourselves to just a pair of dia- metrically opposite points (for example, A and C) we have the choice of two signals with phases 1 80 degrees apart: this gives us BPSK modulation. Our PWM generator thus covers all the most important modulation schemes. They are all implemented in the program code and can be selected by invoking the appropriate preprocessor directive. Figure 8. Phase modulation observed on a BBC 198 kHz (Droitwich) transmission. elektor 04-2012 51 RADIO & TV HMU1LZZ miU BIG BOLD detachable mini-board (Figu wired back to the main board 3-core screened cable (K7 & K8^ tested this arrangement satisfac rily up to at least 1 0 m (30 ft.), ted in silicone, I just slip the ser| probe into the pool. Software The choice of microcontroller not critical, since we’re not as ing it to do anything particular clever. It just has to handle: • one l 2 C bus as master; • one internal counter of 1 5 minutes pprox.); • one analogue comparator; • two digital inputs; • three optotriac drive outputs. e 3), via a to- Pot- sor you need to write a 0 to c^S543 ATTiny 2313 at www.atmel.com). A unique thermometer built from pinball machine parts on its PD2 and PD4 ports tells the micro- controller the reels have both reached this position. Once the display has been reset to ‘00’, all the microcontroller then has to do is send the right number of pulses to make it display the measured temperature. The drawback with these wheels is that they can’t go backwards: so to go down one digit, you have to make them go all the way round. However, it’s only a relative drawback, since a complete rotation takes only 2 s, and moreover, this rapid rotation is a pleasure for the eyes and the ears [1]. So the switching won’t produce interfer- ence on the AC powerlines, the ‘increment display’ command is executed carefully at the zero-crossing point of the AC voltage using an optotriac coupled with a triac. The pulse length to advance the reel by one step is 100 ms. The mechanism seemed to me so reliable, I didn’t bother to use the addi- tional contact these reels have to indicate that the mechanism has advanced correctly. Using 1 00 ms pulses, I have never noticed the slightest error. The TMP100 thermal sensor is installed along with its decoupling capacitor on a As none of these functions requires any great precision, the internal RC clock is ade- quate and consequently we can dispense with a quartz crystal. At first start-up, microcontroller performs initialisation as follows: • configures the various ports as inputs or outputs; • configures the pull-up resistors on its inputs; • configures the counter (prescaler, inter- rupt enable), • recognises the ‘00’ position on the displays. Before we go on, let’s remember that on a microcontroller with built-in pull- up resistors, once a port has been con- figured as an input (register DDRD2=0), all we have to do is write a 1 to this port (SBI PORTD,PD2 = Set Bit on port D2) for an internal 20-50 l<^ resistor to be con- nected within the microcontroller itself between this input and the supply rail. To effectively remove this pullup resistor, After initialisation, our microcontroller reads the temperature sent by the TMP1 00 sensor via the l 2 C bus and converts its hex value into binary coded decimal (BCD). The sensor accuracy is 0.5°C or better — more than we need, since we’re not going to be displaying the decimals. If it freezes, the dis- play will simply show ‘00’. The microcontroller compares each new measurement with the previous reading it has stored, and determines whether the wheels need to go forward or backward. Once the measurement has been made and the display updated, the microcontroller starts an internal counter programmed to 1 5 min and goes into an infinite loop, from which it can only exit by way of an inter- rupt. This will come either from the counter reaching the end of the 1 5 min, or from the analogue comparator detecting the power rail dropping below the threshold of about 2.4 V. But don’t worry, there’s still a safety margin left — the microcontroller will work right down to a voltage of only 1 .8 V. If the loop is interrupted by the timer, it’s time for the microcontroller to make a new temperature measurement. In the event of elektor 04-2012 59 HOME & GARDEN Figure 4. This prototype worked, but has been improved still further; it does not correspond to the final version of the PCB. a change, a brief activation of the optotriac and triac powers the transformer which supplies the voltage to make the wheels go forward and display the new tempera- ture. During this time, the 1 F capacitor recharges. If the temperature has dropped, the cor- responding reel will have to go through ‘0’ before the microcontroller can send it the number of pulses corresponding to the fig- ure to be displayed. Then the AC power is turned off again. Rest! If the loop is interrupted by the analogue comparator, the AC power is enabled for two seconds and recharges the capacitor, then the infinite loop starts again. If for some reason — for example, the effect of ageing — the capacitor should one day dis- charge in less than a quarter of an hour, the comparator will take care of it. So thanks to this, the thermometer is never in danger of falling asleep for good. The microcontroller is programmed via the AVR/ISP connector K1 0, to which we con- nect a programmer. I use USBPROG (Elektor October 2007) [2] along with the AVR Stu- dio software from Atmel. Nothing needs to be changed in the configuration of the fuses, the default parameters are: • Internal RC clock 8 MHz (CKSEL=01 00 SUT=1 0) • internal clock division by 8 (CKDIV8=0) My source file and the hex code are on line just waiting to be downloaded [1 ]. Electrical safety issues Building this thermometer ought not to pose any problems. However, as the board is connected directly to the 230 V (USA: 1 1 5 V) AC powerline, it carries a lethal volt- age. Be sure to take all the usual precautions and do not take any chances with safety, particularly with the choice of pushbutton for forcing start-up (marked * on the circuit) or the wiring to it. In fact, since 230 VAC (USA: 1 1 5 VAC) rated pushbuttons are not too common components, it’s better to opt for an ordinary switch, easier to find in a ver- sion with a rating suitable for the intended use here. This is all the more vital since the thermometer is likely to be used outdoors or in conditions where an isolation fault may have fatal consequences. For the wiring, fol- low the indications on the circuit (Figure 2) and use high-quality screw terminals, espe- cially for l<2 and l<3, like those in the proto- type in Figure 4. Connecting up the reels The two connections to the electromag- net are easy to find. Check with an ohm- meter that the coil is in good condition. If it is burnt out, the resistance will be zero or infinity. If the coil is in good condition, it will have a lowish resistance: 7 Q measured on a Williams coil, around 30 Q on a Bally. To find the other connections needed for Figure 5. My Gottlieb thermometer in its Perspex case. Each reel is mounted on a card guide. 6o 04-2012 elektor HOME & GARDEN r — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -i ! The author Ludovic Meziere, 44, a fiddle player and son of a fiddle play- er, has been constantly playing with a soldering iron ever since the day his father forgot to put it away when he was 7. Ob- tained a BTS [roughly equiva- lent to an HNC] in electrical engineering in Valenciennes, France in 1 988. Has been a technical salesman for profes- sional audiovisual equipment for 20 years with SEMAP (www. semap.fr), and a lecturer on Audiovisual Equipment Tech- nology on a BTS course for 1 2 years. Occasional prototype developer for the CNRS [French national centre for scientific research] and cameraman for Remi Gaillard (www.nimportequi.com). His ambition is to put electronics everywhere it’s possible — even if there’s no point. Outdoors, my Gottlieb thermometer built in to the shower wall. The cat and the showerhead give an idea of the scale. the thermometer to work, the ones for the ‘0’ detector, depending on the type of counter you have, Williams, Bally, or Gottlieb, you’ll have to use the continuity tester to identify the connections to the contacts that open when the wheel passes through ‘O’. I’d be delighted if readers like my idea and find other applications for it than mine. Don’t hesitate to tell the editor about vari- ants you may think of; if they are interest- ing, they might get published. (110673) Internet Links [i] www.elektor.com/ 1 10673 - Sound and light show of the thermometer wheels moving - Software for download [2] www.elektor.com/060224 [3] http://youtu.be/sKD01 9Y0KWg http://youtu.be/sKD01 9Y0KWgit [4] http://www.pinrepair.com/gtb/ Finding these wheels? If the project tempts you, but you’re worried that the wheels may be difficult to find, then you obvi- ously aren’t familiar with the resources out there on the Internet. It’s easy to find new or second- hand devices in many countries. The destruction of obsolete pinball machines [2] has not been able to completely wipe out the huge numbers that were mass-produced (a single pinball machine could have as many as 20 reels): spare or salvaged parts can still be found at acceptable prices. Cleaning the wheels If the reels you’ve recovered need cleaning, go about it gently, as the figures are fragile. Don’t whatever you do use any cleaning prod- ucts— at most, mild soap and warm water. If the figures are printed on paper that’s been stuck onto the actual reel, it’s better not to at- tempt touching them at all. If you dismantle the mechanism to clean or admire it, watch out for little springs flying out in all directions! Never lubricate them! The rem- edy would be worse than the problem. If the counter jitters, either the mechanism is clogged up with dust, or it’s been poorly re-fitted. You do sometimes find, after overheating inside the pinball machine, that the solenoid or the sleeve within which the core slides get deformed. Before you do something you might regret, do take the time to do a bit of research on the Internet; using magic formulas like ‘EM score reel repair’ or ‘cleaning’, you’ll pick up some helpful advice. elektor 04-2012 61 HOME & GARDEN RS-485 Switch Board ElektorBus relay module By Jens Nickel Our ElektorBus series has shown how much interest there is in home automation applications. Here we describe a small circuit board that can switch two AC (230 VAC) loads. Also, two of the inputs to the on-board microcontroller are brought out to terminals so that the state of two switches can be read back. The board works with the ElektorBus and so is an ideal building-block for a home automation system controlled from a PC, tablet or smartphone. So far the ElektorBus project has centred around hardware and software for experi- mental and development purposes. We will now start to move towards a more fin- ished system, in particular looking at home automation applications, which have gen- erated a lot of interest among our readers. The board we describe here is designed to switch two AC (230 V) loads and to read the state of two switches. The module is compact and based on an ATmega88 and an LT1785 RS-485 driver, the same ICs as we used in the ElektorBus experimental node [1]. Demonstration software that talks the ElektorBus protocol is also available for download, to run on microcontrollers, PCs and smartphones. The relay module, which is available ready-built from Elektor, can of course also be used in other projects. Bus connection The circuit diagram is shown in Figure 1. The circuit receives its 1 2 V DC power sup- ply over screw terminal connector l<3. The RS-485 part of the circuit closely mir- rors that of the experimental node, with data lines RO and Dl, control lines DE and / RE, which allow half-duplex operation, and the RS-485 bus signals A and B. A 1 20 Cl ter- mination resistor can optionally be wired across the bus lines using a jumper. The four wires of the ElektorBus are con- nected at l<3: 12 V and GND to supply power and the A and B data lines. Besides those there are two extra connections. The first, ‘Shield’, is intended to be connected to the cable’s screen. This is connected to ground via jumper JP1 : this should normally be done only on one node, for example the one that provides power to the bus. The second extra connection, ‘SIG_GND’ (for ‘signal ground’) provides an additional connection to the ground point of the RS-485 driver. For the moment this signal is simply connected to bus ground in the relay module. However, we wanted to allow for the future possibility of providing a separate ground for the RS-485 driver 1C. When loads are switched it is possible that there will be local interference generated on the bus ground; and if the ground poten- tials at the drivers differ too widely this can result in spurious bits being detected on the bus. We have already observed this effect once [2]. One solution might be to connect signal ground directly to bus ground at only one point on the bus, while in the other bus nodes the two signals are linked via (for example) a 100 £1 resistor. Of course, this arrangement requires a fifth conductor in the bus cable. We have not yet tested this possibility, but keep the option open for when the bus is a little more mature: by all means experiment yourself! Microcontroller pins The test LED, test button, ISP (in-system programming) interface and clock and power supply circuitry will all be familiar from the experimental node design. We have replaced the single-in-line expansion connector with a 2-by-3 header, which is more compact and for which it is easierto find suitable cables. The connector gives access to four of the micro- controller’s pins, each of which can be used as a digital input or output or as an ana- logue input (ADC0 to ADC3). Two of these pins, along with ground, are also brought out to screw terminals, making it easy, for example, to connect a light switch. It should go without saying that the switch and all associated cables should be kept well away from any AC powerline wiring! The main feature of the module is the pair of relay-switched outputs. These are con- nected to two of the microcontroller’s pins, PB0 and PB1 , via relay driver IC3. The relays are SPST NO (single pole, single throw, nor- mally open) types. With the circuit as shown these switch between the input labelled ‘phase’ and the outputs labelled ‘SI’ and ‘S2’. These three signals are brought to larger screw terminals. The relay outputs can be used to switch low-voltage equip- ment or mains equipment such as light- ing. If AC powerline voltages are used, the module must be mounted in an enclosure that prevents accidental finger contact in accordance with all applicable regulations 62 04-2012 elektor HOME & GARDEN Figure 1 . Up to two loads and two switches can be connected to the module using the screw terminals. in your state or country. The printed circuit board is round and compact, and can be fitted into an enclo- sure with a diameter of 60 mm (Figure 2). Do not fit the board in a junction box that already carries domestic AC grid wiring, and the bus wires should not be run parallel to AC wiring in trunking (see also the ‘Cabling’ text box). The switching module should be fitted in its own enclosure and the bus cable in its own trunking. In many countries elec- trical installations such as this must only be carried out by suitably qualified or compe- tent people. Software With suitable firmware we can breathe life into the switching module. The ready-built modules are delivered with the microcon- troller not programmed, as the board can be used for a wide range of applications. However, there is of course demonstration software available, which is compatible with the ElektorBus. The relays can be switched from a PC, using our USB-to-RS-485 con- verter and the ElektorBusBrowser.exe software. The same can be done from an Android smartphone or tablet, using the combination of the AndroPod board and the free ElektorBusBrowserForAndroPod app described recently [3], [4]. We also provide a suitable user interface to allow the relays to be controlled. This is implemented in HTML and works equally well on PCs and Android devices. The hardware is wired up as shown in Fig- ure 3. As usual, the software is all available for free download from the project web page accompanying this article [5], and source code is of course provided. After opening the zip archive the first thing to do is drag the ‘UIBus’ folder to the desk- top. Then, if you will be using a smartphone Elektor Products and Support . Free software down|oad • RS-485 switch board (ready built and tested): # 110727-91 All products and downloads are available via the web pages accom- • USB-to-RS-485 Converter (ready built and tested): #110258-91 panying this article: www.elektor.com/ 1 1 0727 elektor 04-2012 63 HOME & GARDEN COMPONENT LIST Resistors SMD shape 0603 R1,R2,R3 = 10I<£1 R4 = 0£2 R5 = 120£l R 6 = 4.7I<^ R7 = 1.5kft R 8 = 1 0^ Capacitors Cl ,C2 = 22pF NPO (0603) C3,C4,C5 = 1 0OnF X5R (0603) C6,C7,C8 = 4.7 jiF X5R 1 0V (0805) C9 = 4.7pF X5R 25V (0805) Semiconductors D1 = SIM (1000V/ 1 A) LED1 ,LED2 = LED, green (0603) IC1 = ATmega 88 A-AU, programmed IC2 = AP78L05SG-1 3 IC3 = DS2003TM/NOPB IC4 = LT1 785CS8#PBF as a controller, transfer the required files to it, for example using the PC software Adif- Controller as described in [4]. The firmware needs to be programmed into the micro- controller: the firmware is written in C using the ‘AVR Studio’ environment, and a ready- compiled hex file is included in the down- load. In this example the data EEPROM in the AT mega88 is not used: the board’s node address (which is ‘5’) is hard-coded into the program. Testing After firing up the ElektorBusBrowser the HTML user interface will appear: see Fig- ure 4. In the PC version the COM port address must be set up first using the combo box at the top of the screen, match- ing the address used by the USB-to-RS-485 converter. Then click on the button below. The ElektorBus scheduler can now be launched by clicking the ‘on’ button in the HTML user interface. The scheduler now polls the master (with node address 1 0) at regular intervals to prompt it to send any Figure 2. To keep the board compact we have used SMD components. The circular shape allows installation in an enclosure with a diameter of 60 mm. Figure 3. For a first test connect a USB- to-RS-485 converter and a relay module together over the bus. The relay module has node address 5 (hard-coded into the demonstration firmware). Miscellaneous RE1 ,RE2 = 1 2V, SPST-NO (e.g. G5Q-1 A-EU DC1 2) JP1 , JP2 = 2-pin pinheader, lead pitch 0.1 in. (2.54mm) K1 ,l<2 = 6 -pin pinheader, lead pitch 0.1 in. (2.54mm) l<3 = 6 -way screw terminal block, lead pitch 3.81 mm l<4 = 3-way screw terminal block, lead pitch 7.62mm l<5 = 3-way screw terminal block, lead pitch 3.81 mm XI = 1 6MHz quartz crustal, HC-49S case SI ,S2 = pushbutton, SPNO (e.g. B3S-1 000) PCB# 110727-1 alternatively Ready assembled and tested board # 110727-91 switching command that might be avail- able to the relay module. It is of course necessary to arrange for the command to be acknowledged: when the relay module receives a command, it replies with a mes- sage that contains the current state of its two relays. This means that the module is never directly addressed by the scheduler. As a consequence it is possible to have over a hundred relay modules connected to a single bus without the congestion that would arise from having the scheduler poll them all. In fact, the status message is sent during the so-called ‘FreeBusPhase’ which is initiated by the scheduler after each occasion when the master is polled. Dur- ing a FreeBusPhase any bus participant that happens to have something to say is free to send a message. A collision can occur if there is more than one such participant, and so, if safe receipt is important, the acknowl- edge message from the relay module must in turn be acknowledged by the PC. This FreeBusPhase ‘AcknowledgeMessage’ is automatically sent by the JSBus Javascript Cablin As we reported in the ‘E-Labs Inside’ section of the March 201 2 edi- tion, we have been testing various cables for use with the bus. You can see the results in a YouTube video [7]. We started with a ten-core cable from the store room, which had one pair twisted. Next we tested some CAT 5e cable (four twist- ed pairs with an overall screen). We found cable lengths of 30 m caused no problems at all in either case, and so it seems that we do not need to recommend a specific cable. The only important aspect is that the A and B signals should be carried on a twisted pair. It is not normally allowed for the network cable to be carried in the same conduit as mains cables carrying 230 V. In some countries ex- ceptions are made for special-purpose cables, of which one example is the YCYM 2x2x0 . 8 EIB/KNX bus cable designed for home auto- mation applications. It should be possible to use such a cable with the ElektorBus, but we have not tested it. Such cable is somewhat pricey: it can cost several pounds per metre. 64 04-2012 elektor HOME & GARDEN library that is loaded as part of the demon- stration HTML file (see Listing). The library decodes the message from the relay node, and the user application code simply has to accept the two ‘parts’ (information units) which comprise the message. The first part represents the status of relay 1 (sent on channel 0) and the second part the status of relay 2 (on channel 1 within the same mes- sage). The function ProcessPart, which is defined in the Javascript code in the HTML page, is called for each of the two parts. Within this function the status value (zero for ‘off or one for ‘on’) is used to update the status text suitably for the appropriate relay in the HTML user interface. We have covered the above more thor- oughly in previous articles on the Elektor- Figure 4. The ElektorBusBrowser PC software and the HTML user interface (left). In the window to the right you can see simulated bus nodes which can be brought into action for development purposes [8]. Advertisement Elektor RF & Microwave Toolbox 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! ■ 1 It H» 1 1 ID | 9 11 ts, 11 11 ipi 1 L*j t C*ltuhP Cvrr ill Gain Pldbinpui »Ldh Mpiii OmiJEllH QumiU GLh2 DvwaJIU*! Gvnull OtH Highlights: • Amplifier cascade (NF, Gain, PI db, OIP 2 , OIP 3 ) • Field intensity and power density converter (W/m 2 , V/m, A/m, Tesla, Gauss, dBm, W) • PCB Trace calculator (impedance/dimensions) • PI and T attenuator • Antenna temperature (Kelvin) • EMC (EIRP, ERP, dBpA//m) • Filter Design (Butterworth, Chebyshev, prototype) • And much more 10.147 Hju 16 Ifii £0117 Hi" 17.01 IT klin 1 __ kMn Download your app now! Available in Android Market Further information at www.elektor.com/rf-app O Silicon log Online Electronics Store * Boards • Kits * Modules ■ Components * Tools * Instruments FOR * Companies * Professionals 4 Students ■ DlYers * Amateurs USB STC 8051 MCU Programmer Free For 8051 Developers SEN1060 GPS Module With Antenna Small, Low Cost, Easy To Develope $50 (HMC5883L) 3 Axis Compass Module Integrate Compass Easily $12.5 | LM3886 68Wx2 HiFi Audio Amplifier HiFi Sound At Affordable Price $99.9 Simplify your electronics projects by visiting http://www.siliconray.com elektor 04-2012 65 HOME & GARDEN Listing: User interface in HTML and Javascript (excerpt)