www.elektor..com DECEMBER 2008 au$ i 2.90 - nz$ 1 5.50 - sa 84.95 - us$ 9.95 £ 3.90 cs worldwide The only universal and reusable development solution, available online today RS EMBEDDED DEVELOPMENT PLATFORM rswww.com/edp m EasyPlC is a world-class tool that enables immediate prototype design... User-Friendly PIC development system lU r.TtH BOARD High-Performance USB 2.0 On-Board Programmer mikrolCD - Hardware In- Circuit Debugger on-board enables easy debugging Thanks to many new features, you can start creating your great devices immediate- ly, supports 8-, 14-, 18-, 20-, 28- and 40- pin PIC microcontrollers (it comes with the PIC16F887). The^^^^^ (Hardware In-circuit Debugger) enables very efficient step by step debugging. Examples in M, ^^^^and language are provided with the board. EasyPIC5 comes with the following printed documentation: EasyPIC5 Manual, PICFIash2 Manual and mikrolCD Manual. Also EasyPIC5 is delivered with USB and Serial cables needed for connecting with your PC. s - ■ is*" V Evolving product features and modern input design require the use of touch screens. The h with connector available on EasyPIC5 is a T with the ability to display and receive information on the same display. It allows a display to be used as an input device. Simple installation onto the face of a GLCD for easy a/--;; connection to EasyPIC5 board with built-in Touchscreen Controller and Connector. SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD mikroElektronlka A. J DEVELOPMENT TOOLS I COMPILERS I BOOKS Find your distributor: UK, USA, Germany, Japan, France, Greece, Turkey, Italy, Slovenia, Croatia, Macedonia, Pakistan, Malaysia, Austria, Taiwan, Lebanon, Syria, Egypt, Portugal, India, Thailand, Taiwan, Czech and Slovak Republic. http://www.mikroe.com/ Rejected! I am often asked why such and such an article proposal was rejected for publication in Elektor and methinks it's a good idea to use this space to explain a bit about the background. First, however, I should mention that unlike some of our competitors, Elektor does accept articles from anyone from anywhere, which is another way of saying that making it into print and reaching a million or so fellow enthusiasts or industry workers via a multi-lingual magazine is not limited to "the happy few", "approved authors", or similar. Anything that hits our email boxes is in principle considered for publication, brushing up and/or post-engineering by our lab, no matter if the piece is poorly written or the prototype built on perfboard — in general we are good humoured with a keen eye for originality. However! There are a few reasons for not accepting a contribution, which inevitably get stamped. Like this: uninventive use of com- ponents (old hat); use of obsolete components (goner); rehashing manufacturer's datasheets (regurg) or old Elektor articles (!) (e-copy-cat); vague circuits nicked from websites (i-copy-cat), poor electronic design (dreamon) and attempts to use the magazine as a sales pitch for products (marcomm). If it seems these qualifications are unkind or perhaps disparaging, you should know that they originate from engineers and editors with a total of 1 00 or so years experience in the business, happily applying the lingo that tends to set them apart from language pur- ists and marcomm people. As a good number of authors (from as far away as Iran) have already discovered, reading the Author Guidelines posted on our website (under the Service tab) is an excel- lent way of dodging our stamps, and I'm told that supplying a work- ing prototype, some photos and comprehensive copy in an organ- ised way, is the ticket to success. Even if an article proposal is sadly rejected for publication, its keywords, key components, design method(s) and of course author contact details are stored in a wiki-ish repository maintained by our lab workers on a hijacked part of our server. In this way, the wiki, if challenged with a suitable query, can be used to consult potential authors and maybe trigger them to cover their favourite subject in a different way if so required. Reject we may — neglect, we don't. Jan Buiting Editor lekfo r electronics worldwide Free! 24-page i-TRIXX Supplement starts on page 45 32 Hi-fi Wireless Headset RX-AUDIO-2,4 711007120 - 0*01 (» 1 ) Although they've been on the shelves of audio and video equipment retailers for quite a few years now, wireless headsets have been conspicuously absent from hobby electronics magazines. It has to be said that building this sort of headset, especially if we set ourselves a certain level of quality, is far from simple — or rather, was far from simple, until some recently-brought- out modules came along to help us out. CONTENTS If you fit a line of LEDs on a circular PCB and power them on conti- nuously, they generate rings of light when the board is spun. If you add a microcontroller, you can use the same set of LEDs to obtain a more interesting effect by generating a Virtual' text display. This ar- ticle also describes a simple technique for using the Earth's magnetic field to generate a synchronisation pulse. The potential applications extend from rotation counters to an electronic compass. Volume 34 December 2008 no. 384 projects 16 LED Top with Special Effects 22 Bits on Parade 32 Hi-fi Wi reless Headset 77 BASCOM AVR Course (4) 80 U niversal User Interface Module 90 PLDM Power LED driver module 94 Design Tip Temperature Switch 96 Omni Pendulum mm Kill iiw » Universal User Interface Module technolo< This module provides a simple user interface for extending microcontroller-based circuits. Graphics and text display commands can be sent to it over a serial interface, and, using its UART, the module reports back when the state of any of six inputs changes. Additional firmware can display a slideshow of images stored on an SD card. 40 Power over Ethernet (PoE) 70 DOT NET on a Chip 86 Electronic Transformers Revealed and Explained info & market Thanks for supporting us in 2008 and Best Wishes for the Festive Season from all Elektor staff! Omni Pendulum Most people seem to think that the only thing digital electronics is good for is blinking LEDs. There is no easy to way to interface a microcontroller to the real world without some arcane 'input stage' with amplifiers and filters. This project is different. The microcontroller in it is directly connected to a small coil — and there is nothing else (except, maybe, a power source and some noise suppressing capacitors). And yet it manages to achieve something that's almost impossible with any kind of traditional analogue setup: perpetual motion. 6 Colophon 8 Mailbox News & New Products 28 RS Embedded Development Platform (EDP) 104 Elektor SHOP 108 Sneak Preview infotainment 100 Hexadoku 101 Retronics 'QQE' RF power double tetrodes (ca. 1950) ELECTRONICS WORLDWIDE elektor international media Elektor International Media provides a multimedia and interactive platform for everyone interested in electronics. From professionals passionate about their work to enthusiasts with professional ambitions. From beginner to diehard, from student to lecturer. Information, education, inspiration and entertainment. Analogue and digital; practical and theoretical; software and hardware. tf SUPERSiZE SOMMER ISSUE troffti L ■— -“flLJTTL Hi | — j— a Volume 34, Number 384, December 2008 ISSN 1 757-0875 Elektor aims at inspiring people to master electronics at any personal level by presenting construction projects and spotting developments in electronics and information technology. 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 1 1 times a year with a double issue for July & August. Elektor is also published in French, Spanish, German and Dutch. Together with franchised editions the magazine is on circulation in more than 50 countries. International Editor: Wisse Hettinga (w.hettinga@elektor.nl) Editor: Jan Buiting (editor@elektor.com) International editorial staff: Harry Baggen, Thijs Beckers, Ernst Krempelsauer, Jens Nickel, Clemens Valens. Design stc Antoine Authier (Head), Ton Giesberts, Luc Lemmens, Daniel Rodrigues, Jan Visser, Christian Vossen Editorial secretariat: Hedwig Hennekens (secretariaat@elektor.nl) Graphic design / DT Giel Dols, Mart Schroijen Managing Director / Publisher: Paul Snakkers Marketing: Carlo van Nistelrooy Customer Services: Anouska van Ginkel 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 6 elektor - 12/2008 an introduction r The principal aim of this one-day course is to introduce the student to the concepts involved in RFID. On completing this course the student will have learned: - the basic components of a RFID system - common applications for RFID - techniques to configure the RFID reader to enable communication with either ICODE or Mifare transponders - the commands and syntax used to read and write data from and to RFID transponders John Verrill BSc (Hons) CCAI PGCE Formerly Head of Electronics at Whitby Community College and Chief Examiner of Electronics for the Welsh Joint Education Committee. Programme: 09:00 Reception, Registration & Tea 09:1 5 Introduction to facilities and aims of the workshop Introduction to RFID technology and devices Overview of Flowcode for PIC Microcontrollers Reader module communications in ICODE mode 1 1 :00 Coffee break 11:15 Read and write transponder data in ICODE mode 13:00 Lunch 1 3:30 Introduction to Mifare transponders Reader module communications in Mifare mode 14:45 Tea break 1 5:00 Using security keys Read and write transponder data in Mifare mode Using 'Value' format Plenary session 16:00 Close The course fee is £ 1 99.00 (including lunch and certificate) Subscribers to Elektor are entitled to 5% discount! Date: Saturday 1 7 January 2009 Location: Birmingham City University (Technology Innovation Centre) More info and registration at www.elektor.com/events V REGISTER NOW'. Places strictly limited. Email: subscriptions@elektor.com Rates and terms are given on the Subscription Order Form Head Office: Elektor International Media b.v. P.0. Box 1 1 NL-61 1 4-ZG Susteren The Netherlands Telephone: (+31 ) 46 4389444, Fax: (+31 ) 46 43701 61 Distribution: Seymour, 2 East Poultry Street, London EC1A, England Telephone:+44 207 429 4073 UK Advertising Huson International Media, Cambridge House, Gogmore Lone, Chertsey, Surrey KT1 6 9AP, England. Telephone: +44 1932 564999, Fax: +44 1932 564998 Email: p.brody@husonmedia.com Internet: www.husonmedia.com Advertising rates and terms available on request. Copyright Notice The circuits described in this magazine are for domestic use only. All drawings, photo- graphs, 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 transmitted in any form or by any means, including photocopy- ing, scanning an recording, in whole or in part without prior written permission from the Publisher. Such written permission must also be obtained before any part of this publication is stored in a retrieval system of any nature. Patent protection may ex- ist 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 Publisher cannot guarantee to return any mate- rial submitted to them. Disclaimer Prices and descriptions of publication-related items subject to change. Errors and omissions excluded. © Elektor International Media b.v. 2008 Printed in the Netherlands 12/2008 - elektor 7 INFO & MARKET MAILBOX Elektor Workshop Feedback (1) Dear Elektor — I felt it was important to thank Elektor (and the guys at Birmingham City University) for the wonder- ful workshop (Graphical Programming of Microcontrollers Using Flowcode, Ed.) on Saturday (October 4, 2008, Ed.)\ I learned so much, and had a great time. Everyone was very friendly and helpful, which was great as I was so nervous before the workshop started, especially being the youngest there (15)! The workshop went at a very nice pace, not being too technical, whilst being informative and interesting. I was very impressed with the amount of material given out, as this helped greatly when at home. The venue and tutors there were great, and the whole event was extremely professional. I look forward to the new E-vents, and if relevant to what I am doing, I will not hesitate to register! Conor Riches (United Kingdom) So when will you submit your first article for publication in Elek- tor, Conor? Elektor Workshop Feedback (2) Dear Elektor — I would like to thank you for the course held on Saturday (PIC Programming using C, October 4, 2008, Ed.). A lot of ground was covered and I enjoyed it. Now all we need is a follow up course to put the words into action. John De Quincey (United Kingdom) Elektor Workshop Feedback (3) Dear Elektor — just a quick note to thank you for organis- ing such an enjoyable day at Birmingham TIC on Saturday (October 4, 2008, Ed.). The college staff were all very friendly, helpful and well able to provide the information to us. I also enjoyed the food immensely. My only complaint was that the day went too fast! I look forward to attending similar E-vents when they become available. Richard Large (United Kingdom) E-vents covering RFID and High-End Audio Amplifiers are now scheduled , see the Elektor home page for details on the work- shops and masterclasses. Cheap ‘scopes on review Dear Editor — I would like to comment the DSO review article which appeared in October 2008 issue of Elektor. I agree with Dr. Scherer's opinion that the Rigol DSO is far superior to the Owon model. I've used my own Rigol DS1062CD at home for a year now and have been very happy with it. I use mainly Tektronix and Agilent DSOs at work. There is a misunderstanding on part of the author about the memory density of the Rigol DSO, all models in the DS1000 series have 1 megabyte of sample memory (512k per channel if both channels are active, and 512 k for logic analyser). See full specifications from: www. rigolna.com/ products_osc_ DS1 000_spec.aspx. The logic analyser functions are also good, although serial protocol demodulation and channel naming are not possi- ble like with Agilent mixed sig- nal DSOs. This may change in future firmware releases, they responded to my enquiry. Con- sidering after-sales support, Rigol has a very fast support response from China. I con- tacted them about a firmware upgrade recently, and got a response & firmware file in a few hours time! I do not understand the com- ment on the build quality. I have limited experience on the Owon model but the quality of the Rigol model is good. My own choice was made on the fact that Rigol designed and manufactures the low range Agilent DSO's. If Agilent trusts to rebrand their scopes and sell in their own name then the build quality must be depend- able. I would recommend the Rigol's DSOs for general low-frequency laboratory use and with the price tag of less than 1 keuro, one can be fitted on all work tables! It's also an excellent choice for educa- tional institutions, since the students can get experience in real industrial grade instru- ments. And for any microcon- troller work, the logic analyser comes in handy. Juss SauQy (Finland) The reviewer, Thomas Scherer, replies: Dear Dr. Saily, thank you for your comments. Yes , the DSOs from Rigol use 1 MB memory. I mentioned that they can use up to 512 kS per channel. The same about build quality: I never said a word about this. I said that both manufacturers have to improve their products and — looking at the software of the Rigol — in my eyes, there's room for improvement — the software is not good enough. Regarding your other points: I just did not test the logic ana- lyzer functions. And I'm notshure if Agilent just sells rebranded Rigol scopes or if Rigol works just as a hardware factory for Agilent, which would make a difference. I am unable to say what is true. Thomas Scherer (Germany) Jussi Saily replies: I forgot to add one thing about the memory modes. The Rigol DSO has two memory modes selectable from the settings menu. Mine was on the low memory density setting on default (as I suspect was Dr. Scherer's), and I was confused on the low performance before I found out that the high memory density setting needs to be ena- bled! As you know, engineers don't read manuals ;-) 8 elektor - 12/2008 I didn't mean to upset Thomas, just to clarify some things which may make a difference in selecting the right scope for your personal use. The Rigol DSO has the deepest memory I've seen in any other low price category scope, and is really useful in digital circuit work. They're constantly improving the firmware, and you can easily upgrade it for no charge. The latest firmware I got about a month ago has many improvements like more automatic measurements. Specifically the Agilent DS03000 series are rebranded Rigol DS5000 series scopes. They're designed and manufactured by Rigol in China. Jussi Saily Power LED please Dear Elektor — first, I've just been reading the September 2008 issue of Elektor, and would like to congratulate the team on yet another great issue. Now, on to the point of this email. I've been thinking for a while that, given the UK government's insistence that all traditional light bulbs be banned within the next three years, there must be a better alternative to the horrible compact fluorescents that are being pushed onto us. Lack of dimming and poor quality make them very undesirable, but as yet I've found no viable alternative to the good old filament bulb. I've been toying with the idea of direct bulb replacement (bayonet/Edison screw) unit which would consist of a small transformer circuit and suitable LED cluster, capable of direct exchange for a bulb and able to work with the electronic/ dimmer switches that many people would otherwise need to replace to use the compact fluorescents. I could probably come up with a suitable working design, but lack of relevant experi- ence and an even greater lack of free time makes this just another project I'd like to find time to work on :-). Therefore I thought I'd mention it to yourselves, to see if it might be the sort of thing you would like to investigate and possibly come up with a project for. Right, thanks very much for the time taken to read this email, and very best wishes to all those who make Elektor the must- read magazine it is. Steve Clark (United Kingdom) Thanks for the suggestion Steve , it's been copied into our design lab , as well as to a number of freelance contributors. If readers feel they can contribute in any way do let us know. nected to external port 80, it is mandatory to have http:// in front of the ip address. T. Geerts (The Netherlands) DigiButler live demo from France Our reader Yves Masquelier from France has connected his DigiButler board to the Internet to enable you all to see it's actually working. His board has been pro- grammed to read a number of temperatures including that of the ColdFire micro! 59999 username = user password = 1 234567 Give Yves' DigiButler a call and see if you can bother him to switch the kitchen light on and off! (note: service avail- able subject to Mr Masqueli- er's provisions) I liked the article, I consider the author's choice of the driver architecture remarkable to say the least. Elektor has been covering LEDs and LED drivers quite intensively lately and everyone now seems to agree on the current source as the best way to power an LED. All commercially available LED drivers are, in principle, current sources. The driver discussed in the article is a voltage source with pot adjustment. If, after some time, the LED exhibits a change in forward voltage, the current is likely to change, causing the light intensity to fluctuate con- siderably. Worse, the LED may get excess current causing severe reduction of its lifetime. The above problems do not occur if you use dedicated LED drivers like the MAXI 6820 and MAXI 6832A, which are easy to apply and do not require adjust- ment. They also allow the compensation network R1-C2 to be dropped, as well as output capacitor C3. See www.maxim-ic.com/ MAXI 6820 and www. maxim-ic.com/MAXl 6832A. Fans Janssen (Maxim Benelux) (The Netherlands) ■r p : ' freeze etg &i arfrimr : \ P~ t H 1! VW-U! «■ . * ■* Vw'iin ■[ S ^ "C r-hJ-HUE B.VEWK K TEu-E hav-ic : n.'fercfHitax •»L mti *■*&**& vkku,* ■ ■ cj nnjstilt *| Sea'dnKii] fj | Li Hi-KBfi ncibjc* Jnua t+rtii . | ■! 1 $’ j 1? rn i'iiiy.. iH url = http://81.56.186.109: Multiple DigiButlers on the same network (2) Dear Jan — a small error slipped into my previous contri- bution to Mailbox (November 2008, Ed.). When using a web browser to call a DigiButler not con- Improvements for Luxury LED Bicycle Light Dear Jan — I'd like to respond to the Luxury LED Bicycle Light article published in the Sep- tember 2008 issue. Although Mai I Box Terms • Publication of reader's orrespondence is at the discretion of the Editor. • Viewpoints expressed by correspondents are not necessarily those of the Editor or Publisher. • Correspondence may be translated or edited for length, clarity and style. • When replying to Mailbox correspondence, please quote Issue number. • Please send your MailBox correspondence to: editor@elektor.com or Elektor, The Editor, 1 000 Great West Road, Brentford TW8 9HH, England. 12/2008 - elektor 9 INFO & MARKET NEWS & NEW PRODUCTS Graphical Programming of Microcontrollers Using Flowcode Saturday 1 3 December 2008 from 9:00 am to 4.00 pm, Birmingham City University, Technology Innovation Centre. Presenters: Dr. Nick Holden BSc(hons) PhD CEng MIET and Mr. Parmjit Chima BEng PgDip. The purpose of this one-day course is to program and apply PIC microcontrollers in an accessible and practical way. The participants will learn how to use Flowcode to exercise some of the functionality of these modern microcontrollers using peripherals such as timers, counters, digital port I/O, A/D and USART, with polling and interrupt techniques. The course will use the E-blocks hardware with one of the common 40-pin PIC microcontrollers. The graphical programming of the microcontroller is done with the revolutionary new software Flowcode version 3. The knowledge gained can also be applied to other 8-bit microcontrollers such as the AVR from ATMEL. The participant will at the end of the day be able to build embedded systems with analogue values and switches as inputs and output via LCD and LEDs. This workshop is also a very thorough preparation for programming these microcontrollers in C. Prerequisites include some electronics skills, digital technologies and computer proficiency (Windows). The course fee is £ 160, including lunch and certificate. Every participant also receives the CD Flowcode software version 3 home edition (value £ 48.30). Elektor subscribers are entitled to a 5% discount. Be quick to register online at www.elektor.com, there is space for only 1 6 participants! PIC Proqramminq usinq 'C' - hands-on for beqinners Saturday 1 3 December 2008 from 9:00 am to 4.00 pm, Birmingham City University, Technology Innovation Centre. Presenters: Dr. Anthony Wilcox GRIC PhD CEng MIET and Mr Andrew Hill BSc MIET. The main goal of this one-day course is to provide an introduction to the programming of PIC microcontrollers in the C programming language. The course is mainly aimed at participants who are unfamiliar with the C programming language, but who would like to learn to use it in an embedded environment. The participant will be introduced to those aspects of the C language that are most relevant to the programming of microcontrollers. The hardware used in the course consists of E-blocks. Course objectives: - the participant can make a simple C program - the participant can program a PIC microcontroller in C. Some experience in programming is recommended, such as (Visual) Basic, Pascal, Assembly or another language. No prior knowledge of C is expected, but some familiarity with electronics, digital technology and computer proficiency (Windows). The course fee is £ 160, including lunch and certificate. Every participant will also receive free software and example files as presented on the course. Elektor subscribers are entitled to 5% discount. Be quick to register online at www.elektor.com, there is space for only 1 6 participants! Elektor comes to the USA Packed with electronics projects, know-how and technology, Ele- ktor magazine has now come to North America (and Canada)! A special landing page is available for US and Canadian readers. Elektor USA magazine's Novem- ber 2008 and October 2008 trial issues are on distribution directly when it will be added to the suc- cessful English, Dutch, Spanish, French, German, Italian, Portu- guese and Brazilian magazines centrally produced by Elektor International Media, with web- sites to match. Elektor USA issue #1 is scheduled to appear well before Christmas 2008. WWkY.ClffclDr.CPm □ClUUhhiWK- lektor electronics worldwide :tor International Magazine is coming to North America from the Publishers' US address after a successful introduction at the Audio Engineering Society (AES) Convention held in San Francisco on October 2-5 and Embedded Systems Conference (ESC) Boston, October 27-30. The official launch issue of Elektor USA will be January 2009 American and Canadian readers originally subscribed to the Eng- lish-language Elektor can now subscribe on-line using the spe- cially created USA landing page, which contains an offer they will find hard to refuse! www.elektor-usa.com Avnet / Cypress Spartan-3A video Cypress Semiconductor Corp. and the Avnet Electronics Market- ing Americas business region of Avnet, Inc. announce the launch of a new online design demon- stration "PSoC, the Mixed Signal FPGA Companion Chip." The video shows designers how to use a Cypress PSoC (r) Programma- ble System-on-Chip in cost-effec- tive companion chip applications with a Xilinx FPGA. The 30-minute video is available on demand and free of charge at the link below. The new video gives a brief overview of the fl exibility and integration of the mixed-sig- nal PSoC device, followed by a detailed review of its FPGA con- figuration, USB and touch sensing capabilities. Cypress member of technical staff Dave Van Ess presents these fea- tures using the Xilinx Spartan-3A FPGA Evaluation Kit from Avnet, 10 elektor - 12/2008 which pairs a Xilinx low-cost Spar- tan-3A 400A FPGA with a PSoC device. The board comes with Cypress's CY3217 (MiniProg) Programmer as part of the Xilinx Spartan-3A FPGA Evaluation Kit, available exclusively from Avnet for $ 39. For designers interested in a more advanced USB and touch sensing evaluation environment, Cypress offers the CY32 1 4-PSoCEvalUSB Kit, which includes enhanced development and debugging sup- port. The PSoCEValUSB Kit is avail- able on the Cypress Online Store and from authorised distributors. www.cypress.com /go/PR/ PSoCFPGAwebinar www.cypress.com www.cypress.com /go/ avnetkit (080872-1) DSP Waveform Generator for USB BitScope 1 00 BitGen is a new waveform and timing event generation solution for USB BitScope 100. It generates standard sinusoid, tri- angle, sawtooth and square wave- functions but it is capable of a lot more than this; clocks, voltages, triggers, waveform bursts, sweeps and chirps, white and pink noise, loadable arbitrary waveforms and even live waveforms captured with BitScope can all be gener- ated concurrently with mixed sig- nal acquisition. Its software selectable synthesis- ers are controlled using the same powerful DSO program that drives BitScope; there are no new software tools to learn and all generator I/O is inte- grated with BitScope so setup is fast and easy. BitGen operates inde- pendently or sample locked with BitScope. Triggers are inte- grated so waveform generation and cap- ture is always per- fectly synchronised. Frequency synthesis is very precise; better than 1 ppm with crystal reference accuracy and event timing and burst dura- tion is also very precise with a resolution better than 50 ns. A second timing chan- nel accepts external triggers or clocks or it can be used to output synchronised clocks or triggers for external devices. It also serves as a convenient probe calibration signal. Bit- Gen is available now as a purchase option or upgrade pack for USB BitScope 1 00. www.bitscope.com (080872-11) Ultra-slim, low-power LED strip light reduces energy and maintenance costs Hawco introduces new linkable, low- profile LED strip lights that offer an econo- mical alternative to incandescent and florescent lighting. Designated planet- saver®, the LED Strip Lights are available in two versions: a 230 volts AC module and a 1 2 volts DC LED ultras low power (ULP) module. Both versions feature a versatile plug-and-play facility that enables multiple units to be con- The PLANETSAVER instantly light up at full brightness and can be specified to provide either a cold or warm white colour temperature. nected in series to meet lighting Available with a compact straight requirements. The rugged planet- and/or flexible connection option, saver LED Strip Lights significantly lower energy consumption and feature a long operating life of more than 50,000 hours, reducing maintenance costs. up to 10 LED strip lights can be connected in series. The 230 VAC Led Strip Light is available with lamp dimensions of 320mm to 820 mm, providing a light output of 42 cd to 1 32 cd. The 12 VDC LED ULP Strip Light is available in lengths from 320 mm to 820 mm with corresponding light output of 48 cd to 1 38 cd. Typical applications include refri- geration, chiller cabinets, kit- chen units, shop displays, under shelves, pelmits, bookcases and wardrobe. www.hawco.co.uk (080872-III) 13.56 MHz RFID Reference Design Atmel® Corporation announced its Keen+ reference design for the development of secure, 13.56 MHz logic-based, passive RFID, close proximity applications. The AT88SC-ADK2 Keen+ devel- opment kit includes Atmel's Crypto Evaluation Studio tool suite, an application development board, CryptoRF® samples in both tag and smart card form, a USB cable, and a quick start guide. The Crypto Evaluation Studio tool suite has a menu-driven, graphical user interface for CryptoRF config- uration and testing, plus develop- ment libraries and code examples for host-side cryptographic opera- tions required for secure commu- nication. The application devel- opment board includes Atmel's ISO/IEC 1 4443-B-compliant, AT88RF1 354 host-reader chip; an Atmel AYR flash microcontroller; and USB connectivity to PC and power. Schematics and PCB lay- out are also included. The AT88RF1 354 host reader per- forms RF communication, packet formatting, decoding, and com- munication error checking and is based on the royalty-free, ISO/IEC 12/2008 - elektor 11 INFO & MARKET NEWS & NEW PRODUCTS 14443-2 Type B signal modula- tion scheme and ISO/IEC 14443- 3 Type B frame format, used by 60% of the vendors of RFID host readers. Data is exchanged half duplex at a 106 kbit per second rate. A two-byte CRC_B provides communication error detection capability. The AT88RF1354 can be used with both RFID transpond- ers or contactless smart cards and is compatible with 3.3 V and 5 V host microcontrollers with two-wire or SPI serial interfaces. The highly integrated reader 1C requires fewer external components than competing RFID reader chips, resulting in a BOM in the $2.00 'A* \Mi CK' ,^OFf AT***' j range for a host reader based on this reference design. This is sig- nificantly lower than designs using competing RFID reader ICs. The AT88RF1354 is available in the smallest package option obtainable today - a 6mm x 6mm, 36-pin QFN. Atmel's Keen+ RFID Development Kit, including reference designs and software is available now for $99.95. www.atmel.com/products / secureRF / (080872-IV) LED Module Strips for signage and channel-letter applications Providing solid state lighting design engineers with a flexible and scalable lighting solution, TT electronics OPTEK Technology has developed a series of LED module strips for signage and channel-let- ter applications. Available in red, amber, green, blue and white, the LED strips provide fast response times and low power consumption, resulting in low power require- ments from circuit power supplies. Typical applications for OPTEK's LED light strip product line include commercial channel lighting for signage applications, media illu- mination, large area backlighting, point-of-sale displays, mood-setting decoration, landscape lighting, and neon replacement lighting. The LED module strips include the following models: -OVM12F3x7 Series 3 LED mod- ule strips - comprised of 30 mod- ules per strip in lengths of 3 inches to over 40 feet long, the water- proof strips feature a power dissi- pation of 1 .5 W, input voltage of 12 V, and operating temperature ranging from -30°C to +50°C; - OVM1 8F4x7 4 LED module strips - consisting of 20 modules per strip in lengths from 3 inches to over 30 feet long, the waterproof strips fea- ture a power dissipation of 1 .5 W, input voltage of 1 8V, and operat- ing temperature ranging from - 30°C to +50°C; - OVQ12S30x7 flexible LED light strips - comprised of 30 high bright- ness LEDS per unit in lengths up to 16 feet, the red and yellow LED strips feature a power dissipation of 2.7 W while the green, blue, white and warm white strips fea- ture a power dissipation of 2.3 W, with an input voltage of 1 2 V and operating temperature of -30°C to +50°C. www.optekinc.com / viewparts.aspx? categorylD=51 In Europe, contact JP Delaporte at info@optek-europe.com. In Asia, contact T.H. Swee at thswee@optekasia.com (080872-V) Molex: new solder charge technology Molex Incorporated has devel- oped a new Surface Mount Tech- nology (SMT) attach method that offers better fatigue strength and lower applied costs compared to traditional SMT mounting meth- ods. Already Molex's new Sol- der Charge Technology™ has been adopted by major OEMs and CEMs to enhance yields and increase reliability over typi- cal Ball Grid Array (BGA) attach methods. The solder-charge uses standard reflow processing and a reflow profile is available for every prod- uct that takes advantage of this high-density feature. The solder- charge extends slightly beyond the tip of the terminal to seat within the solder paste on the solder-pad. The terminals lower onto the pad upon the melting of the solder mass within the reflow oven. In reflow, the solder transforms into a rectangular sloping solder fillet. 12 elektor - 12/2008 This bugle-shaped solder-charge fillet is a far more robust structure than a ball-shaped BGA solder fillet. In addition, the solder not only provides a 360 degree coat- ing around the terminal but also reaches through the hole in the pin for added retention strength. Incorporating Solder Charge Tech- nology™ into the design process offers several benefits over stand- ard BGA attachments. The sol- der-charge provides a significant amount of tolerance to compen- sate for variability in the PCB flat- ness, giving added assurance that the PCB adhesion will work effec- tively. In-house tests have shown the resulting solder-charge joint is three-times stronger than that of a BGA. The mechanical design of the joint allows for visual inspec- tion post processing, this reduces the process engineer's reliance on Dage x-ray screening. Overall, the shorter cycle times and fewer rework and secondary processing steps help increase output provid- ing a very cost-effective solution. Ideal for high-speed circuitry, Molex Solder Charge Technology™ achieves a reliable mating interface with 2.00 mm wipe and two points of contact for clean signal transmis- sion and enhanced durability. For information about incorpo- rating this attachment style into an assembly design, visit the url below. www.molex.com / product / soldercharge.html (080872-VIII) CyFi: world's most reliable 2.4-GHz low-power wireless solution for embedded control applications Cypress Semiconductor Corp. recently introduced a complete 2.4-GHz solution for the wire- less embedded control market. The new CyFi™ wireless solution delivers the industry's leading combination of reliable connectiv- ity, power-efficiency and superior long range, and is supported by the flexible and easy-to-use design capabilities of Cypress's flagship PSoC® programmable system-on- chip. The solution is optimized for applications requiring sensors, actuators, active RFIDs, standard cable replacement, and human- to-machine interfaces. Prime appli- cations for this solution include wireless sensor networks, home and building automation and remote controls for a broad range of markets such as industrial and consumer. CyFi transceivers are powered by PSoC devices, which integrate programmable analogue and dig- ital blocks, hundreds of pre-con- figured user modules and an 8- bit microcontroller onto a single chip. A PSoC device can replace multiple discrete components, inte- grates numerous functions and can be reprogrammed at any stage of the development proc- ess for unmatched flexibility. The CyFi protocol stack links the PSoC device and the CyFi transceiver, and offers a pre-configured, cus- tomizable PSoC firmware module that can be dropped into the PSoC Designer™ 5.0 integrated develop- ment environment (IDE). The com- bined solution enables designers to create feature-rich wireless appli- cations with no complex coding. For more information on the CyFi Low-Power RF solution, visit the website below. Cypress further introduced the CY3271 PSoC FirstTouch™ Starter Kit with CyFi Low-Power RF, the CY3271-EXP1 Environmental Sens- ing Expansion Kit, the CY3271- RFBOARD RF Expansion Kit and the CyFi Low-Power RF Develop- ment Kit (CY321 0-CYFI). The CY3271 USB thumbdrive kit provides an easy way to evaluate the quick prototyping and debug- ging of wireless systems based on the CyFi solution. Designers can also use the kit to leverage the touch-sensing, temperature-sens- ing, lighting-sensing and proxim- ity sensing capabilities of PSoC devices. The CY3271 kit includes PSoC IDE software, a sense and control dashboard for data collec- tion, a PC dongle with RF, a mul- tifunction board, an RF expansion board with power amplifiers for long-range wireless applications, and two battery boards. The CY327 1 -EXP 1 Environ- mental Sensing Kit is the first of many future expansion kits to the CY3271 that enables customers to quickly and easily evaluate the robust, programmable analogue capability of a PSoC device, plus CyFi Low-Power RF — quickly ena- bling a wireless sensor solution with pressure, humidity, tempera- ture and ambient light sensors. The CY3271-RFBOARD RF Expan- sion Kit is an add-on to the CY3271 that provides two addi- tional RF expansion and AAA bat- tery boards — further enabling evaluation of the CyFi Low-Power RF solution. The CY321 0-CYFI general-purpose development kit enables seamless prototyping and debugging of PSoC devices and CyFi transceiv- ers. The kit includes two develop- ment boards, two PSoC modules and three CyFi modules to build wireless applications. The CYRF7936 CyFi transceiver is now available in a 40-pin QFN package. The CY3271 PSoC FirstTouch Starter Kit, CY3271- EXP1 Environmental Sensing Kit, CY3271-RFBOARD RF Expansion Kit with CyFi Technology and the CyFi Development Kit (CY 3210- CYFI) are currently available on the Cypress Online Store as well as in channel partners' inventories. www.cypress.com / go/PR/Cy Fi www.cypress.com/shop (080872-X) 12/2008 - elektor 13 INFO & MARKET NEWS & NEW PRODUCTS Unicycle-riding robot Murata Manufacturing Co., Ltd. has developed a unicycle-riding robot, called MURATA GIRL™, following its bicycle-riding robot MURATA BOY™. Various types of robot capable of performing such roles as entertain- ment and security have been cre- ated recently for use in our daily lives. These robots require several of Murata 's own products, includ- ing capacitors that store electricity in electronic circuits, sensors that control motion, and communica- tion modules that exchange infor- mation. Since the robotics market is expected to experience strong growth, expansion in the demand for such electronic components is also expected. MURATA GIRL can maintain bal- ance and move around on a uni- cycle, keep a certain distance from an object using a US sensor, and transmit moving images via a live camera. Signals from the gyro sensors help control the unicycle wheel in the forward and backward directions and a fly wheel inside her torso monitors side direction in order to maintain balance. Ultrasonic sensors detect obsta- cles (send/receive pair of sensors), allowing the robot to judge how far away an obstacle is by measuring the time it takes to transmit ultra- sound and receive the reflected signal from the obstacle. MURATA GIRL™ sends and receives commands and data via mobile information terminals and PCs using a 2.45GHz band Bluetooth radio wave. www.murataboy.com / ssk-3 / index.html (080872-VI) Freescale: world's most powerful automotive microcontroller for 'green' engine design Faced with soaring fuel prices and pressures to curb green- house gases, automakers are racing to design vehicles that deliver better fuel economy and reduced emissions. High- performance microcontrollers (MCUs) play a key role in green automotive design, and Frees- cale Semiconductor has intro- duced the industry's most pow- erful and sophisticated MCU for engine control in mainstream, high-volume automobiles. Freescale's new MPC5674F is the latest addition to the com- pany's growing portfolio of 32-bit automotive MCUs built on Power Architecture™ technology. The MPC5674F addresses the auto- motive industry's need for precise control of engine events, enabling developers to optimize combustion and tune engines for improved fuel efficiency and cleaner emissions, without sacrificing performance. Manufactured on 90-nanometer technology, the MPC5674F out- paces other powertrain MCUs with its 264 MHz clock speed. This fast performance allows the core to execute more than 600 mil- lion Dhrystone instructions per sec- ond (DMIPS) - about 10 times the performance level of today's con- ventional engine controllers. The MPC5674F MCU's combination of exceptional CPU performance, advanced signal processing capa- bilities, quadruple analog-to-digital converters (ADCs) and 4 MB on- chip flash memory addresses the growing computational demands of green engine designs. These designs include common rail die- sel injection systems, gasoline direct injection engines, homoge- nous charge compression ignition (HCCI) systems and hybrid elec- tric vehicles (HEVs). The MPC5647F helps automo- tive developers meet government- mandated emissions standards by providing 4 MB of flash - one of the largest flash arrays avail- able in the powertrain MCU mar- ket. This large amount of on-chip flash provides ample non-volatile memory to support computation- ally intensive modeling environ- ments and auto code generation, without the cost and complexity of adding off-chip memory. (080872-IX) 14 elektor - 12/2008 Get more ah-ha! moments. flflflflflfU jVir-.i-j-: ill-* * :i ki ’- Jpj“, J K dCtti :ous U.liiS £!K?j*rcp: BU* n-auisiaHli Tl flmSflOZflSi ■:«J E S za Lhj.j ■Q ■V ■T ™ I H Monday wnmto • i • © p Introducing Logic, the new Logic Analyzer with SPI, Serial and I2C. Now shipping for $149. III! | • • logic Decide if Logic is worthy of your workbench at saleae.com. 5 /fe/e MICROCONTROLLERS Spin the top to display programmed text Michael Bragard (Germany) If you fit a line of LEDs on a circular PCB and power them on continuously, they generate rings of light when the board is spun. If you add a microcontroller, you can use the same set of LEDs to obtain a more interesting effect by generating a "virtual 7 text display. This article also describes a simple technique for using the Earth's magnetic field to generate a synchronisation pulse. The potential applications extend from rotation counters to an electronic compass. Do you still remember your second- ary-school physics classes? Some stu- dents found them very relaxing, while others (which presumably includes many of our readers) probably recall the following situation: a free-hang- ing loop of wire is suspended in the magnetic field of a horseshoe magnet. The teacher causes a DC current to flow briefly through the loop of wire, and it moves to one side and then back as though pushed by an invisible hand. The teacher then tells you that the operating principle of the electric motor is based on this phenomenon. After you had more or less accepted this remarkable fact, the next phys- ics class brought yet another surprise: the teacher said that the effect also worked in the opposite direction. This time, he connected a sensitive moving- coil meter to the loop of wire instead of a current source as before, and then he moved the loop back and forth in the magnetic field. Each movement of the loop caused a deflection of the meter pointer. He concluded this lesson with the words, ‘This is the operating prin- ciple of an electrical generator’. Now you may be wondering what this would-be generator has to do with our LED top. Let’s briefly recall another version of the above scene: a coil is rotated between the arms of a horseshoe magnet, and at the same time a sinusoidal trace appears on the screen of an oscilloscope connected to the coil. The top described here includes a small coil, which is located in the Earth’s magnetic field instead of the field of a horseshoe magnet. To put it more precisely: when the top spins, the coil rotates in the horizontal com- ponent of the Earth’s magnetic field. If the speed of rotation is constant, the voltage induced in the coil is sinusoi- dal - in other words, the coil acts as an electrical generator. Of course, the Earth’s magnetic field is very weak; the horizontal component used here has a strength of less than 20 jl/T in Central Europe. The generated voltage is pro- portional to the enclosed area of the coil and the number of turns. There are upper limits to both of these quantities, since the coil must fit in a top that can be spun by hand. To avoid the effort of making a hand-wound coil, here we use a commercial fixed inductor. Nat- urally, the amplitude of the voltage is also proportional to the speed of rota- tion, and thus to the skill of the user. The coil voltage that is needed for this application is on the order of 50 //V. Concept Moving LEDs driven by rapidly changing signals have become rela- tively popular in recent years. Elektor has also published construction arti- cles for devices with rotating LEDs that can display a virtual text or pat- tern in space [1]. They operate on the same principle as a raster-scan moni- tor. The LEDs move over a surface in space in the same way that an elec- tron beam moves over the phospho- rescent screen of a CRT. Both systems owe their operation to the latency of human visual perception. The per- sistence of the individual picture ele- ments and their constant fast repeti- tion produce the illusion of a coher- ent, stable image. Most systems with rotating LEDs are standard products. They must over- come two problems that are inherently associated with the principle. The first problem is transferring electrical power to the rotating part, while the second problem is generating a suitable syn- chronisation signal. 16 elektor - 12/2008 L The power transfer problem is often solved by using a special transformer consisting of a winding in the station- ary part and another winding in the rotating part. The top described here does not have this problem, because it does not have a stationary part. Electrical power is supplied by batter- ies on the round circuit board, which are arranged symmetrically relative to the axis of rotation and rotate with the board. For synchronisation, it is necessary to recognise when the board has com- pleted a full rotation (one spin of the top). This is essential if the objective is to display a stationary image. In the commonly used designs with a sta- tionary part, an IR light beam or a Hall sensor is used to generate a pulse once per rotation. This solution is very exact and easy to construct, but generating a synchronisation pulse is much more difficult with a top that does not have a stationary external reference point. Costly acceleration sensors or angular PDO/RXD PD1/TXD PD2/INT0 PD3/INT1 PD4/XCK/T0 PD5/T1 PD6/AIN0 PD7/AIN1 MEGA8-AI PBO/ICP PB1/OC1 A PB2/SS/OC1 B PB3/MOSI/OC2 PB4/MISO PB5/SCK PB6/XTAL1/TOSC1 PB7/XTAL2/TOSC2 AVCC GND GND 16 — 1 t D12 17 Dll 7 DIO 8 D9 9 he 7 =► 6 he . =► 4 =► 3 2 8x 3300 Figure 1. The circuit of the LED top essentially consists of an Atmel ATmega8 microcontroller linked to an opamp circuit that generates the synchronisation signal. 080678 - 11 12/2008 - elektor 17 MICROCONTROLLERS Figure 2. For the sake of clarity, the analogue portion of the circuit is shown separately here, divided into five functional parts (A to E). The signals shown in Figures 3 to 5 were measured at the test points marked in this diagram (TP1 to TP6). velocity sensors are also of no use here. As previously mentioned, the sensor used with this top is a small, inexpen- sive inductor spinning in a local, homo- geneous magnetic field. For example, the magnetic field could be the Earth’s magnetic field. The top will also work just as well if you hold a permanent magnet next to it. With appropriate amplification and phase comparison of phase-offset sig- nals, a square-wave signal suitable for triggering a microcontroller inter- rupt can be generated from the small, induced sinusoidal voltage. Circuit The schematic diagram of the LED top (Figure 1) essentially consists of an Atmel ATmega8 microcontroller linked to an analogue circuit that generates the synchronisation signal. The micro- controller (IC2) drives two LED strips, each with eight SMD LEDs. The LED currents are limited by resistance net- works. The rest of the digital portion of the circuit corresponds to the usual minimum configuration of an Atmel AVR microcontroller, with a power-on reset network (R8/C8) and an ISP con- nector (K3), which can be used to load the software into the microcontroller. Capacitor Cl is intended to decou- ple HF interference from the analogue portion. The power supply of the circuit has been kept very simple. The two CR2032 cells wired in series provide a nominal voltage of 6 V. The combination of RIO and D17 (a 5.1-V Zener diode) limits this to a value that the microcontroller can handle. Battery utilisation is fairly good, since the circuit will continues to operate until the microcontroller stops running at around 3 V. The supply volt- age is buffered by the parallel combi- nation of C9 and CIO, which provide a capacitance of around 100 ijF. This is divided between two capacitors to maintain a balanced weight distribu- tion on the rotating PCB. For the sake of clarity, the analogue por- tion of the circuit is shown separately in Figure 2, divided into five functional parts (A to E). Part A supplies the left lead of inductor LI (at TP1) with a constant voltage of 7.5 mV via R3 and buffer capacitor C3. This voltage is produced by a voltage divider with Listing Main algorithm for rotation detection in the LED top ISR ( INT0_vect ) { // rising edge of the sensor pulse cur rent_round_t ime = current_round_time_zaehl ; // counts the duration of the last round in ms // is starting a new round realistic? (80% of the time of the last round) if (current_column > (column_number*8 ) /10 ) { // here: adopt lap time for new co- lumn timing, Timerl runs with 1MHz timerl_startvalue = 1000/ column_number*current_round_time ; current_column = 0 ; #if def ROTAT I ON_COUNTER if (game_status == GAME_ONGOING) number_of_turns++ ; #endif // ROTAT I ON_COUNTER } // clear elapsed time meter for the time in ms between two rising edges current_round_time_zaehl = 0; } ISR (TIMER0 OVF vect) // this routine should be cal- led every millisecond TCNT0 = 255 - 125; // increment the cyclic coun- ter (without overflow) if (current_round_time_zaehl < 255) { current_round_time_zaehl++ ; } else { current_round_time_zaehl = 255; } } ISR (TIMERl_OVF_vect ) { // calling time is based upon the actual speed TCNT1H = 255 - ( t imerl_startvalue >> 8) ; TCNT1L = 255 - ( t imerl_startvalue & 255) ; // next column, or missed syn- chronization condition, // then new start: time-controlled if (current_column < column_number ) { current_column++ ; } else { current_column- - ; } } 18 elektor - 12/2008 its associated decoupling capacitor. Part B has another decoupling capacitor and the sensor coil LI, in which the voltage is induced. With typical coil characteris- tics, rotation in the Earth’s magnetic field generates an induced sinusoidal volt- age with an amplitude of around 50 jl/V. The induced 50-/7V AC voltage is present at TP2, superimposed on the 7.5-mV DC voltage (see Figure 3). Inductor L2 is not connected to the circuit; it is only present on the board for balancing. The third part (C) of the analogue portion contains opamp ICla, which is con- figured with R4 and R5 as a non-inverting amplifier with a voltage gain of 200. This yields a sinusoidal voltage with an amplitude of 10 mV at the output of the opamp (LM358 pin 1, or TP3), super- imposed on a DC voltage of 1.5 V (Figure 4). This volt- age forms the input signal of part D of the circuit, which consists of two passive low- pass filters (R6/C5 and R7/ C4). In addition to attenuat- ing HF interference, which is unavoidably present when the top is used close to a source of electromagnetic interference such as a PC, the differing time constants of these filters (C4 is much larger than C5) produce a phase offset between the fil- ter outputs at TP4 and TP 5. This can be seen graphically in Figure 5. These two sinusoidal sig- nals are fed to the inputs of IClb (pins 5 and 6) in part E. This opamp does not have any feedback, so it oper- ates as a comparator with its full open-loop gain and compares the two phase- offset sinusoidal signals on its inputs (which have nearly the same amplitude). This comparison causes the opamp’ s output to be High when the voltage on the non-inverting input of the opamp (TP5) is higher than Figure 3. The signal voltage induced in inductor LI by the Earth's magnetic field is only around 50 juV. Figure 4. The signal after amplification by opamp ICla. the voltage on the inverting input (TP4). This is the case for half of the sine-wave period, and thus for half of the top rotation. The output of this opamp is fed directly to the interrupt input of the ATmega8 (IC2), where each rising edge indicates the start of a new rotation. Assembly Fitting the components on the circular PCB (Figure 6 and Figure 7) is very easy if you use the parts kit avail- able from the Elektor Shop. This is because all the SMD components are pre-assem- bled, so you only have to sol- der the leaded components to the board. You can adjust the weight balance of the components on the board by slightly shifting the positions of the leaded components, in order to obtain the least amount of wobble when the top spins. If you want to assemble your own board from scratch, pay careful attention to the polar- ity of the SMD LEDs. Study the data sheet closely, and if necessary test the LEDs with a 9-V battery and a 1 kQ series resistor. Of course, proper orientation is impor- tant for all components that have a specific orientation. Figure 5. Comparator IClb generates a pulse signal from the phase-shifted outputs of the RC networks. The pulse signal drives the interrupt input of the microcontroller For the axle of the top, we used two plastic (polyamide) M6 screws with good results. We glued the heads of the screws together to form an axle, and then fitted the PCB of the top to the lower screw between two wash- ers and secured with a nut. It’s a good idea to use a nor- mal pencil sharpener to put a point on the lower plas- tic screw in order to reduce friction so the top will spin longer. Software The software for the LED top was written in AVR Studio [2], which is available from Atmel for free download via 12/2008 - elektor 19 MICROCONTROLLERS Figure 6. The circular PCB for the top is available with the SMDs pre-assembled. the Internet. The C code was compiled using the GCC cross-compiler. The code can be loaded into the ATmega8 via the ISP connector on the PCB. Oper- ation of the code is essentially inter- rupt-driven. After the initialisation and generation of the display matrix, the main routine constantly tests whether the running condition is still satisfied. It is satisfied if the duration of one rota- tion falls within certain range, which can be configured using constants. The core algorithm for the detection of a complete rotation is described briefly below. It is also shown in the listing, and it comprises three interrupt han- dlers that service the external inter- rupt and two timer interrupts. The rest of the program should be self-explana- tory and adequately commented. The hardware interrupt routine becomes active when a rising edge is detected on the INTO pin. After this interrupt is triggered, the ISR(INT0_ vect) routine first checks whether the time of the last rotation is plausi- ble. The start of a new rotation is only plausible if the duration of the previous rotation is at least 80% of the time of the new rotation. Next, the exact time for a new column is determined from Timer 1, which runs at 1 MHz. This time must be adjusted constantly because the top spins slower and slower while the program is running, so the columns must be displayed for a slightly longer time on each rota- tion. The variable current_column is set to zero, which causes the image to be built up again from the first col- umn of the display matrix. The vari- able current_round_time_zaehl uses TimerO to count the time between two rising edges for the purpose of plausi- bility checking, and it is also reset to zero here. The timer interrupt routine ISR(TimerO_OVF_vect) is called every millisecond under time control, and it increments (without overflow) the counter for the duration of the current rotation (current_round_time_zaehl) . Timerl and its routine ISR(Timerl_ OVRjvect) are used to increment the columns in the display matrix. This timer is first updated with the time to the next call (which means the dis- tance between the two columns) by adjusting it according to the current rotation speed of the top as determined for the last rotation. If the synchroni- sation pulse is missing, which means that the external interrupt does not occur at approximately the expected time, a new rotation can be started here under purely time-based control. However, practical experiments have shown that this is not necessary, so all this does is to prevent an overflow of the variable current_column. The full source code is available on the project page for this article at www. elektor.com for free download. After downloading the source code, you can easily modify the text to be displayed, which is contained in a string in the COMPONENTS LIST Resistors All SMD 0805, 1 %, unless otherwise indicated R1,R6,R7 = lOOkQ R2 = 1 50Q R3,R9 = 47kQ R4 = 4kQ7 R5 = 1 MQ R8 = 1 OkQ RIO = 22kQ R1 1 ,R1 2 = 330f2 9-pin SIL resistor array Capacitors Cl ,C5,C7 = 1 OOnF (SMD 0805) C2,C9,C1 0 = 47 id? 16V (SMD electrolytic) C3 = 680nF (SMD 0805) C4 = 2jd?2 1 6V (SMD 0805) C6 = 1 OnF (SMD 0805) C8 = 47pF (SMD 0805, NP0) Inductors L1,L2 = 150mH fixed inductor, Q min = 50, RM5 (1 2x1 6 mm), e.g. Fastron 1 1 P-1 54J- 50 (Reichelt.de # L-11P150M) Semiconductors D1 -D8 = LED, red, 628nm, SMD 1 206 with lens, e.g. Kingbright KPTD- 3216SURC (Reichelt.de # 1206KRT) D9-D16 = LED, yellow, 588 nm, SMD 1206 with lens, e.g.. Kingbright KPTD- 3216SYC (Reichelt.de # 1206KGE) D1 7 = zener diode 5. IV 1 .3 W (BZV85-C5V1 ) IC1 = LM358 (SMD S08) IC2 = ATmega8-16AU (Atmel), SMD TQFP-32 Miscellaneous SI = DIP switch 2-way (MULTICOMP MCDS02, DIL04) Kl, K2 = CR2032 SMD battery holder (Re- nata SMTU-2032-1 -LF, SMTU-2032-1, Reichelt.de # KZH 20PCB-1) K3 = 6-way DIL pinheader, lead pitch 2.54mm (Tyco-AMP # 1241050-3 AMP) Polyamide screw, M6x 20 with nut and 2 washers BAT1, BAT2 = Lithium button cell type CR2032 Kit of parts incl. SMD-populated board, Elektor SHOP # 071 120-71 20 elektor - 12/2008 header. After this, compile the entire source code with the widely used GCC compiler and load it in the top via the ISP port. Leave the fuse bits in the ATmega8 set to their factory default values (1 MHz internal clock). The microcontroller in the parts kit avail- able from the Elektor Shop is pre-pro- grammed, so the top is ready to use immediately after assembly and will display a demo text. However, you can replace the program code at any time with newly compiled code containing your own text. Applications Of course, you are free to choose the text to be displayed by the top - anything from ‘Hello World’ to a company name or a short slogan is possi- ble. With ‘Happy Birthday’ plus the name of the recipient, the top makes an ideal personal- ised birthday gift. You can also extend this idea to the pre-Christmas season. By programming an additional timer in the ATmega code, you could imple- ment a sort of mini- ature Advent calen- dar. For example, the top could display a nice phrase or the keyword for a little surprise on each day of Advent. A software ver- sion with a rotation counter has also been developed to cause the top to generate a ‘live’ display of the number of rotations it has completed. You could then organise a competition to see who is the best top spinner (such a competition was staged live at the Ele- ktronika show in Munich last Novem- ber). At the time of publication of this article, several tops with this software will in action in the Elektor booth at the electronics trade show in Munich, where they form the basis for a sport- ing competition. Several hundred rota- tions can certainly be achieved, and the daily champion among the top spinners will receive a prize - a LED top, of course! Storing the results in an internal EEP- ROM is another conceivable extension. In addition to the number of rotations, it would also be possible to display the angular velocity or other derived quan- tities. Another effect that illustrates the basic principle of the circuit can be achieved by displaying the letters ‘WSEN’ with a space between each pair of letters. the basic principles of induction in 1831, he presumably did not envisage that one day they would be applied to an LED top. Your secondary-school physics teacher was probably equally unsuspecting. The top was devel- oped for students in a hands-on group at the Institute for Power Electron- ics and Electrical Drives of RTWH Aachen, Germany [3], with the aim of offering first-semester students a cir- cuit that even electronics neophytes could assemble and whose operation they could understand. In addition, the circuit had to be suitable for taking home after being assembled and being used there with- out elaborate equip- ment (power supply, soldering iron or PC) to display a func- tion that everyone could understand. If in addition the theoretical con- tents of the lec- tures (including the principle of induction, non-inverting operational amplifiers, and C program- ming) can be incorporated in a pocket-sized project, experi- ence from past semesters shows that this often creates enthusiasm and gener- ates interest in learning even more. ( 080678 - 1 ) Figure 7. Top view of the spinning-top PCB. Only one of the two inductors is used in the circuit. The second one is only present for mass balance. This gives you a sort of compass that shows the observer the orientation of the currently dominant magnetic field. Although there may be devices that are simpler and more suitable for showing compass directions on a desert expedition, they certainly do not create the same sense of marvel as our spinning top compass. Conclusion When Michael Faraday investigated Links and references [1] 'Rotating Message Display with LEDs and an AVR Micro', Steffen Sorge, Elektor January 2007. [2] AVR Studio: www.atmel.com/avrstudio [3] ISEA: www.isea.rwth-aachen.de/en 12/2008 - elektor 21 MICROCONTROLLERS Udo Jursz and Wolfgang Rudolph (Germany) This project puts the Elektor ATM 18 AVR board to use as a tester for the Inter-Integrated Circuit bus. This two-wire bus goes by various names, including IIC, l 2 C, and (at Atmel) TWI (for 'two-wire interface'). As this bus is very widely used, many microcontrollers have a built-in interface for it. The tool described here can be used to perform quick, simple tests on l 2 C ICs and modules. When engineers at Philips developed the I 2 C bus 20 years ago, they prob- ably didn’t have any idea how wide- spread and important it would become. Nowadays it forms an essential part of many types of diagnostic and con- trol systems and other products. It is also used in most embedded applica- tions. The reasons for this success are readily apparent: with a data transmis- sion rate of up to 3.4 Mbit/s and low cost, it is an attractive option. It was designed right from the start to enable networking of multiple components. As a bidirectional bus with a master/slave architecture, the I 2 C bus does a very good job of fulfilling this task. Although its software addressing scheme and integrated protocol may make it appear complex and cumber- some at first, it is easy to use in prac- tice. Its two signal lines, consisting of a serial clock line (SCL) and a serial data line (SDA), can be used to control Mega88 PC5 PC4 SDA SCL O W 3 C/J PCF8574 AO A1 A2 addr. 64 o c n 3 Cfl PCF8591 AO A1 A2 addr. 144 o (/) 3 Cfl 24C512 AO A1 addr. 160 Vcc o (/) 3 CO PCF8583 AO addr. 162 080317- 11 Figure 1. 1 2 C bus with four slaves. a large number of sensors or implement communication tasks between micro- controllers. The original data transfer rate was 100 kbit/s, but in 1992 it was increased by a factor of 4, and 1998 it was boosted to a healthy 3.4 Mbit/s. Its ‘clock stretching’ capability also allows the bus to be used to service very slow bus devices. With the lat- est developments, it is now possible to control well over 30 devices on each bus segment. 22 elektor - 12/2008 Kie © o © © ■- © © © © u ,3 K7 _>■ k L/ J 3f O / C^^'j+^nclub ? R± 0803UJ SDAal owed to change SDA SDA constant SCL bit valid 080317-13 Figure 3. Each data bit is transferred when the signal on the clock line (SCL) indicates that the data is valid. Protocol Data is transmitted in both directions on the bus. To enable access to indi- vidual target devices, each I 2 C bus IC has its own address. The I 2 C bus protocol has a set of precisely defined situations that allow each bus device (slave) to recognise the start and end of a transmission and whether it is being addressed by the master device (microcontroller). Both lines (SDA and SCL) are high in the quiescent state and thus inactive. Start condition The start condition indicates to the devices on the bus that a data trans- mission will follow. The start condition is generated by changing the state of the SDA line from high to low while SCL is high (Figure 1). Data transmission The currently active transmitter places eight data bits on the data line (SDA), which are shifted serially by the clock signal pulses on the SCL line gener- ated by the master (Figure 3). The data transfer starts with the most sig- nificant bit. Acknowledge The currently active receiver acknowl- edges the receipt of a byte pulling the SDA line low while the master gen- erates the ninth clock pulse on the SCL line. This means that SDA goes low during the ninth clock pulse on the SCL line. The acknowledgement also means that the receiver expects to receive another byte. If the receiver wishes to end the transmission, it must indicate this by omitting the acknowl- edgement. The actual end of the trans- mission is achieved by generating the stop condition. Stop condition The stop condition is the reverse of the start condition with regard to the level on the SDA line. In this case, SDA must change from low to high while SCL is high (Figure 4). This ends the data transmission. Addresses are transmitted and acknowledged in exactly the same way as data. The following process occurs in the simplest case, which is a data transfer from the master to a slave (such as a PCF8574 output port). First, the master generates a start con- dition and then transmits the address of the port IC in bits 7-1, with the desired data transmission direction set in bit 0 (in this case ‘O’ for ‘write’). The address is acknowledged by the addressed slave device. The master then sends a data byte, which is also acknowledged. It can break the con- nection now by generating a stop con- dition, or it can send additional data bytes to the same slave device. This is all we want to say here about the basic operation of the I 2 C bus. There are many other interesting things about the bus that could be described, such as using several mas- ters on a single bus, reserving the bus (repeat start condition), byte trans- fers and acknowledgement. Wikipe- dia is a good source of further basic information. Addresses In order to use the tester, you need to know the device addresses. Every type of IC has a base address. Some examples are: 8574 port expander: 0x40 = 64 (decimal) PCF8591 A/D converter: 0x90 = 144 (decimal) EEPROMs: OxAO = 160 (decimal) PCF8583 clock IC: OxAO = 160 (decimal) The address byte contains eight bits. With the usual 7-bit addressing scheme, the remaining bit is used to control the data transfer direction. The master uses this bit to indicate whether it wishes to send or receive data, and it is called the ‘R/W bit’. For example, ‘Al’ (decimal 161) can be used to address an EEPROM for read- ing. When an address is placed on the bus, the addressed device acknowl- edges receipt of the address, which also indicates that it is ready to receive or send data. If the master does not receive an acknowledgement form the addressed slave, the address was not received correctly or the slave cannot receive or send data. Many types of ICs allow the last three bits to be used as subaddresses. They thus have three pins that can be con- nected to GND (‘0’) or V cc (‘1’) as appropriate. For example, you can con- nect eight PCF8574 ICs to the same bus and address them individually. A full bus cycle is shown in schematic form in Figure 5. It begins with a start 12/2008 - elektor 23 MICROCONTROLLERS r" r" SDA / \ / w \r\r SCL \/',:;\/a/a/;::v/a/::wa/ L I start condition address R/W data data (1 Byte) (1 Byte) acknowledgement acknowledgement L I (no) stop condition acknowledgement 080317-15 Figure 5. Data transfer with addressing and acknowledgement. condition, which is followed by the address and R/W bit. After this, you can see the acknowledgement, which is followed by a byte transmitted by the master. After this byte is acknowl- edged, the master sends the next byte. It is also acknowledged by the slave. As the master does not have any more data to send, it generates the stop condition. Minimal hardware In order to use the I 2 C bus, you have to put together a pull-up adapter (Fig- ure 6). A 2.2-kQ resistor must be con- nected to each of the two bus lines (serial clock (SCL) on PC5 and serial data (SDA) on PC4) to pull them up to + 5 V (Figure 7). If you want to connect more than one device to the bus, the bus port must have more than one socket or one set of pins. Figure 8 shows a serial EEP- ROM with a capacity of 4 Kbits (such as an ST24C04MN) connected to the bus. Here the test adapter is connected directly to the IC socket. In other situ- ations, you could connect the tester to one or more ICs on a prototyping strip- board or a printed circuit board. Tester software A program that you can use for initial testing is available for download from the Elektor website or the Computer: club 2 website. It supports several sim- ple commands that can be used for communication with the I 2 C bus inter- face via the serial port of a PC. Load the program ATM18_I2C_Tester in the microcontroller and connect the system under test to a terminal emulator pro- gram using communication port set- tings 38400, N, 8, 1. The following start message will appear after a reset: ATM1 8 1 2C _Tester VI. 2 If you press the question mark key (?) in response, a list of the available commands will be displayed. There are two types of commands: low-level commands and high-level commands, which are specifically designed for controlling EEPROMs. The command interpreter acknowledges each issued command with a number in the range of 0-3: 0 = Command executed 1 = Unknown command 2 = Incorrect or missing parameter(s) 3 = Error during command execution The most important low-level com- mands are: STA = Set start condition STP = Set stop condition DRB = Direct read byte DWB = Direct write byte In theory, you can control any I 2 C IC with these commands. For example, suppose you want to send a byte to a PCF8574 port expander to define the states of its eight outputs. Here you must remember that all data is output in hexadecimal form, so the address is ‘40’ (short for ‘0x40’) rather than ‘64’. The data byte is ‘55’ (deci- mal 85 or binary 01010101), which means that after the transfer is com- pleted alternating port pins are high and low, which you can easily check with a meter or logic tester. Command: STA // Start condition DWB 40 // Slave address DWB 55 // Data byte STP // Stop condition Response: 0 // Executed 0 // Executed 0 // Executed 0 // Executed Now you can also read data from the IC. Naturally, you expect the output states you read back be the same as what you sent. Here the address is ‘0x41’ because the R/W bit must be set to 1. And indeed, you see that the read byte is ‘0x55’. Command: STA // Start condition DWB 41 // Slave address DRB 0 // Read without ack STP // Stop condition Response: 0 // Executed 0 // Executed 55 // Port data 0 // Executed For another example of using low-level commands, you can write a byte to a 24C04 EEPROM with address ‘0x00’ as follows: Figure 6. Test adapter construction. Vcc Figure 7. Schematic diagram of the adapter. 24 elektor - 12/2008 Command: STA // Start condition DWB AO // Slave address DWB 00 // Byte address DWB 11// Data byte STP // Stop condition Response: 0 // Executed 0 // Executed 0 // Executed 0 // Executed 0 // Executed To read data from the EEPROM, you must first send the internal address of the desired data with the R/W bit set to ‘write’. After this, you must send the address again with the R/W bit set to ‘read’ in order to read one or more bytes. The following example with low-level commands demonstrates reading one byte from address ‘0x00’: Command: STA // Start condition DWB A0 // Slave address DWB 00 // Byte address STA // Restart DWB A1 // Slave address DRB 0 // Read without ack STP // Stop condition Response: 0 // Executed 0 // Executed 0 // Executed 0 // Executed 0 // Executed 1 1 // EEPROM data 0 // Executed High-level commands With the high-level commands, you only have to specify the slave address and the byte address in order to read or write an EEPROM directly. The interpreter handles the addressing and generates the start and stop con- ditions all on its own. Here again, all data is communicated in hexadecimal form. RSB = Read single byte RDB = Read double byte RMB = Read multiple bytes WSB = Write single byte WDB — Write double byte WMB = Write multiple bytes ‘Set’ commands: SA = Set slave Address BA = Set byte address ‘Get’ commands: SA? = Get slave address BA? = Get byte address IDN? = Get identity string ? = Get help High-level examples Writing several bytes to a 24C04 EEP- ROM starting at address ‘0x00’: Figure 8. Testing a 14V04 EEPROM. Command: Response: SA A0 // Slave address 0 // Executed BA 00 // Byte address 0 // Executed WMB 1 1 22 33 44 55 // 5 bytes 0 // Executed Reading several bytes from a 24C04 EEPROM starting at address ‘0x00’: Command: Response: SA A0 // Slave address 0 // Command execution acknowledgement BA 00 // Byte address 0 // Command execution acknowledgement RMB 5 // Read 5 bytes 1 1 ,22,33,44,55// EEPROM data Reserved addresses and 10-bit addressing Certain l 2 C addresses are reserved and cannot be used for connected devices. Due to these reserved addresses, only 1 1 2 of the 1 28 addresses possible with 7-bit addressing are avail- able for use. Address R/W bit Description 0000000 0 General call address 0000001 X CBUS address 0000010 X Reserved for a different bus format 000001 1 X Reserved for future expansion 00001 XX X Reserved for future expansion 1 1 1 1 lxx X Reserved for future expansion 1 1 1 1 Oxx X R8C/13 applications In order to handle a growing number of new l 2 C ICs, 1 0-bit addresses were introduced. This makes it possible to address up to 1024 devices on a single bus. Thanks to the use of previ- ously unused addresses in the '1111 'Oxx' range together with the R/W bit, there is no interfer- ence to 7-bit devices on the same bus, so 7-bit and 10-bit devices can be used together on the same bus. 10-bit marker Address part 1 R/W bit Address part 2 11110 XX X Acknowledge 1 XXXXXXXX Acknowledge 2 The five bits of the reserved address '11110' are sent first, followed by the first two bits of the device address. The R/W bit is sent next, since an acknowledgement follows every byte. Of course, more than one device may respond to the first part of the address, and they can all send an acknowledgement. The second part of the address is sent after the acknowledgement. All bus devices selected by the first part of the address also decode the second address byte. In a properly configured network, there can be only one device that generates an acknowledge- ment after this. Now the communication can begin. 12/2008 - elektor 25 MICROCONTROLLERS Listing 1 Finding addresses with Bascom ' ATM18 I2C tester ' I2C : SCL = PC5, SDA = PC4 $regfile = "m88def.dat" $crystal = 16000000 Baud = 38400 Dim N As Byte Config Portb = Output Config Scl = Porte. 5 Config Sda = Porte. 4 Print "ATM 18 I2C ad- dress test" For N = 2 To 254 Step 2 I2cstart I2cwbyte N If Err = 0 Then Print N I2cwbyte 0x55 I2cstop Next N End Listing 2 Writing data to an EEPROM $regfile = "m88def.dat" $crystal = 16000000 Baud = 38400 Dim N As Byte Dim Adr As Word Dim H As Byte Dim L As Byte Dim Dat As Byte Config Portb = Output Config Scl = Porte. 5 Config Sda = Porte. 4 Print "ATM 18 24C512 write For Adr = 0 To 1000 Input Dat I2cstart I2cwbyte 160 H = High (adr) L = Low (adr) I2cwbyte H I2cwbyte L I2cwbyte Dat I2cstop Next Adr End u ' start 'slave adsress 'high address 'low address 'write byte ' stop 24C512 Finding addresses with Bascom In a situation where several ICs with jumper-programmable subaddresses are present on a bus or you want to investigate an unknown system, you often do not know the I 2 C slave addresses. A small program written with Bascom can help here. It tries each address in turn to see whether a device responds. Each time an address is sent, the system variable ERR is assigned a ‘1’ if no acknowledgement is received or to ‘O’ if an acknowledge- ment is received, which means that the address is valid. The program tests all even-numbered addresses in the range of 0 to 254, since the corresponding odd-numbered addresses would be the read address of the same ICs. This program (see Listing 1) generates a list of addresses in decimal notation, such as the following example: ATM 18 I2C address test 64 144 160 162 Here the ICs show in Figure 1 were found. Although the PCF8583 clock IC has the same base address as every EEPROM, in order to avoid an address conflict its subaddress is altered by connecting its A0 pin to V cc so that it appears at address ‘162’ instead of address ‘160’. Writing data to an EEPROM Here we use a 24C512 EEPROM, which has a total capacity of 64 KB. This rel- atively large address space requires using a 16-bit address for the stored data. Consequently, two internal address bytes are sent after the I 2 C addressing cycle. They are followed by one or more data bytes. The pro- gram (see Listing 2) receives individ- ual bytes from the serial interface and stores them in the EEPROM starting at address ‘O’. Data output to a port expander The objective here is to read data from an EEPROM and transfer it to a PDF9574 port expander. This gives you a basic tool for software control of all types of devices and machinery. The program (see Listing 3) also transmits the data via the serial interface for auditing or checking. Reading the individual bytes from the EEPROM requires the same actions as for low-level control of the 24C04, except that here the byte address is transmitted in two parts (high byte and low byte). After this, the I 2 C address must be sent again with the R/W bit set to ‘read’(address ‘161’ instead of ‘160’) in order to read the data. ACK is used in I2CRBYTE for the actual read- ing process, and if more than one byte must be transferred, the final byte is fetched with NACK. ( 080317 - 1 ) The ATM18 project at Computer:club 2 ATM18 is a joint project of Elektor and Computer:club2 ( www.cczwei.de ) in collaboration with Udo Jurft, the editor in chief of www.microdrones.de. The latest developments and applica- tions of the ATM1 8 are presented by Computer:club 2 member Wolfgang Rudolph in the CC2- tv programme broadcast on the German NRW-TV channel. The ATM18-AVR board with the l 2 C tester was featured in instalment 24 of CC 2 -tv, which was first broadcast on 23 October 2008. CC2-tv is broadcast live by NRW-TV via the cable television network in North Rhine-West- phalia and as a LiveStream programme via the Internet (www.nrw.tv/home/cc2). CC2-tv is also available as a podcast from www.cczwei.de and - a few days later - from sevenload.de. 26 elektor - 12/2008 PC Oscilloscopes <& Analyzers BitGen DSP Waveform & Timing Generator for USB BitScope 100 Powerful waveform generation & mixed signal data capture in one low cost USB test instrument. Digital Storage Oscilloscope Dual Channel Digital Scope with industry standard probes or POD connected analog inputs. Fully opto-isolated. Mixed Signal Oscilloscope Capture and display analog and logic signals together with sophisticated cross-triggers for precise analog/logic timing. Multi-Band Spectrum Analyzer Display analog waveforms and their spectra simultaneously. Base-band or RF displays with variable bandwidth control. Direct Digital Synthesis Generator Arbitrary waveform crystal referenced DDS frequency synthesis. Microsecond one-shot timing precision and burst generation. Independent but sample synchronized with BitScope capture. Noise, Dither and Entropy Generator Pseudo-Random Number noise, dither and entropy generation. White, pink or binary with programmable or random seed. Voltage, Clock and Logic Generator Programmable voltage, clock and serial logic generation. Adjustable DC reference and mark/space clocks to 5MHz. Logic level shifting and probe calibration signals. BitGen is a comprehensive DSP based waveform and timing generation solution available as standard in BS100M or an option for BS100U. From clocks, sine, square or triangle waves to sophisticated bursts, chirps, noise or user programmable signals, BitGen supports them all. www . bitscope . com INFO & MARKET REVIEW RS Embedded Develo Jan Buiting (Elektor UK Editorial) Basic Communications Analogue Input Module Module Interfacing of up to 28 analogue channels USB • RS232 • RS485 • 2x CAN • RTC with the onboard MAXI 1 38 ADC for extra • 240 bytes NVRAM 1 2 channels of 1 0-bit ADC through the standard on-board Ether- net connection. RS Components has launched a unique concept that's claimed to revolutionise the way you design. Like most good ideas, it's deceptively simple - a universal and reusable Baseboard to provide a single platform to evaluate different microcontrollers and applications. Staying abreast of technology is an expensive business, especially in elec- tronics design. Each time you need to upgrade to a new processor, your old development kit goes in the bin. This leaves you not only with the expense of buying a new one, but with the hassle of interfacing both software and hard- ware to existing application circuits. RS Components now offers a perma- nent solution to this perennial problem - the RS Embedded Development Plat- form, or RS EDE Their single, reusable platform means you can drastically reduce product design cycles and gain a competitive advantage in bringing products to market — fast! What’s more, RS have made software drivers, frameworks, full schematics, Gerber files and parts lists available online, IP free. So you can easily stay ahead of the game — the industrial variety, that is. A world first RS claim this is the world’s first devel- opment tool to provide options for dif- ferent microcontroller manufacturers, technologies and applications on one platform. It consists of a robust, re- usable Baseboard with four identical ‘stations’. Many permutations of microcontroller specific CPU (Central Processing Unit) Modules and Application Modules are possible. I found even with the mini- mum (out of the box) configuration of Baseboard and CPU module I was able to set up, using the supplied example code, a basic web server application Faster, cheaper The kit received from RS for this review succeeds in providing a hardware plat- form and software frameworks to allow 28 elektor - 12/2008 Digital Input/Output Module Interfacing of up to 12 channels • with overvoltage protection • 16 TTL inputs via I2C • 1 6 500 mA outputs • 1 6 25 mA logic outputs TM STR912 32-bit ARM9E CPU module 96 MIPS • Ethernet • USB • I2C • CAN EDP baseboard 3V3 and 5V regulators • 3x I2C • 2x CAN • extended Eurocard (200 x 100 mm) • 64-way DIN connector area for standard rack system backplane you to quickly concentrate efforts on application and software develop- ment. I was unable though to substan- tiate RS’ claim of customer trials hav- ing indicated “a reduction in the time and layout stage from the 13.2 week industry average to 8.5 weeks” — I am just an editor with less than 3 weeks to produce all of this month’s Elektor articles (and a lot more). Assorted CPUs and modules To accompany the launch of the EDR RS developed a range of CPU and Application modules. The CPU mod- ules released so far are the STR912 unit based on the ARM9 from ST Microelec- tronics, and an Infineon XC167 mod- ule that looks particularly suited for demanding industrial, motor control and automotive applications. The CPU modules are complemented by a series of ready to use Application Modules ranging from motor control to communications. All are sturdily built, have a uniform footprint of 80 X 40 mm, two connectors and, it must be said, succeed in reducing circuit con- struction times significantly. I hear that forthcoming modules, in the coming months, include the latest NXP ARM Cortex module which will allow developers to run NI Lab VIEW natively as well as a module which will be able to host any of Microchip’s Explorer 16 modules including the PIC 24 Microcon- troller, the dsPIC33 digital signal con- troller (DSC) families and the new 32- bit PIC32MX devices. What we really can’t wait for though, are the applica- tion modules on the way, a powerful BLDC motor controller which will drive dual 24V, 4 A motors or triple 24 V 4 A brushed motors and Bluetooth, WiFi, FireWire and mass storage modules which will really make the EDP a ver- satile choice for new designs. Fingers crossed we’ll see these followed by Atmel, Renesas or Freescale micros to mention but a few. Out of the box The box I got from RS for the purpose of this article contained the following modules: ARM9 CPU; Digital; Ana- 12/2008 - elektor 29 INFO & MARKET REVIEW Brushed Motor Control Module (not plugged on) For brushed DC motors up to 1 2 V, 3 A • With external screw terminals to allow up to 5 A • LM1 8200 driver has inputs for: current sense, tacho gen., DC volts, 2 limit switches, chopper and quad encoder logue; Comms; Motor Control and of course the Baseboard. This does not appear to be a standard complement sold by RS — the closest it comes to as compared to what customers can buy is the STR9 Foundation Kit (= Base- board + STR9 CPU module + Comms module). For a basic Webserver all you need to have is the Baseboard, the ARM9 CPU module and of course Ether- net connectivity to the web and USB connectivity to the PC, not forgetting a wall wart 12-V DC adapter. The use of two keyed connec- tors on each module (and on the base board) makes for rugged- ness and reliability while pre- cluding boards to be fitted the wrong way around. On the down side, the contact pressure is such that modules are hard to remove again (but is made a littler eas- ier with the extraction tool pro- vided). Also, with the CPU mod- ule installed there are only three free positions for apps modules left, which is a bit scanty. Fortu- nately, bus extension connectors are available at the edge of the EDP Baseboard and the 64-way DIN connector on the end allows the I2C and CAN control buses to be linked to other baseboards to pro- vide more positions. Software complement The real power of the EDP may well lurk in the industry-leading software suites that come with it, rather than the hardware. The CD with the kit is a breeze to use, although it will take 15 minutes or so to do a full installa- tion using the recommended order. For the STR9 you install HiTOP for ARM, the Keil ARM Compiler, GNU for ARM and, optionally, FTDI drivers, plus a bunch of examples. In good USB fash- RS Embedded Development Platform W* W»i Embedded Development Platform Getting Started Install XC167 Module Install STR9 Module C01 Comms Module EDP Documentation MCI Motor Controller DI054 Digital Module AN16 Analog Module Base Board RS EDP Website EDP Website vl .1 June 2006 EXIT party support for the RS EDP (tested and untested!) is found in the Release Notes with the kit: IAR EWARM CSPY, Keil RV-MDK ARM and Rowley Cross- Works ARM 1.7. Pricing and availability It must be said that the prices of the modules and starter kits restrict the EDP system to the realms of pro- fessional designers and software developers. The STR9 Foundation Kit, for example, is priced at £ 359, while the individual application mod- ules are around the £ 100 mark. But then such factors as money saved in terms of development time, the ability to switch CPU platforms rapidly, the flexibil- ity of the system, the big names involved (including RS Com- ponents themselves), the lush software complement and other “company-internal consider- ations” may help application developers to convince many a Head of Engineering to sign an order for an EDP ( 080646 - 1 ) ion, you first do the software installa- tion and only then connect the hard- ware! The Xcl67 CPU module gets the following installed: Infineon DAS, HiTOP for 167, Keil C166, DAvE and again examples galore. More third- Internet Link www.rswww.com/edp 30 elektor - 12/2008 VISIT 2000 SERIES 3000 SERIES LU in O O o to 250 MHz bandwidth 1 G5/s real-time sample rate 128 megasample record length With daSS-leading bandwidth, sampling rate, memory depth and an array of advanced high-end features,, the PiCDScope 5000 PC Oscilloscopes give you the features and performance you need without any compromise. The Ho Compromise PC Oscilloscopes Advanced Triggers in ^ddiiEon io the standard iriggvs the PicoScepe sow series comes as standard with purse width, window, dropouL delay and logic level triggering 250 MHz Spectrum Analyser High-speed USB 2,0 Connection Automatic Measurements Arbitrary Waveform Generator Dchne your own waveforms or select From S predefined signals with the 1 2 hit, 1 ?5 MS/s arbitrary waveform generator. Waveform Playback Tool + h Pi coScope software row W allows you to go back, review, 5- jflP and analyse up Eo 1 ODD captures w within itf waveform playback tool., Technology The 1 PiCOStupc J 0 O 0 Scries of GSdElOscupes from Pi cm Technology includes qeoernl purpose and high resolution models: With 1 2 bit resolution am! 1% accuracy [lie 1 PicoScopu 3424 is ablt So diitiKI chang-es as s-mall a10 — — >10 — — kn Operating temperature -10 — + 80 -10 — + 60 °c The audio source connected to K2 is isolated from the transmitter by capacitors C6 and C7; despite their high values, these must not under any circumstances be electrolytics, in order to maintain the overall qual- ity of the link. Push-button S2 enables you to change the transmit chan- nel. If you use the 2.4/AE module, the right-hand part of Figure 1 comes into play, and lets you set the transmit channel ‘manually’ using the top three switches of SI, S2 then being inactive. The other switches on SI allow us to experi- ment with the other options available in the 2.4/AE mod- ule, as shown in Table 3. One other interest- ing option of the modules, accessible via K3, is the addi- tional channel for transmitting digital data at a maximum rate of 5 kbits/s. Constructing the transmitter As seen in Figure 2, the suggested PCB is L-shaped, as the transmitter modules have components on both faces, which means they can’t be mounted onto the PCB, even though the small size of their connector really demands it. Watch out for the 16-pin female con- nector for this module: it’s a 2 mm pitch type, available from Farnell, for example. Take care as well to select the correct values for Rl, R2, and R3, depending on which of the Aurel modules you’ve chosen, as shown in the circuit, as the 2.4/AE mod- ule really doesn’t like being powered from 5 V! out its associated receiver, so let’s take a look at that right away. Receiver circuit The receiver circuit shown in Fig- ure 3 is a little more complicated than the transmitter, mainly because of the headphone amplifier, which we wanted to be as good quality as the Aurel modules it goes with. The receiver has the same DIL switches SI and push-button S2 as the transmitter, with the same functions, but you don’t have to fit them if you don’t want to, as when it is no longer Before plugging the module into the female connector on the PCB, note that if it’s a 2.4 with a single-row connec- tor, it plugs into the bottom row of the female connector, with the side marked “Aurel Tx-Audio-2.4” up, as in the pho- tos of our prototype. If it’s a 2.4/AE, it takes up all of the female connector. The transmitter can’t be tested with- receiving any signal, the receiver module automat- ically starts scanning the 8 channels it can receive and locks onto the first one it detects. So if you’re only using one transmitter with it, which is usually the case, the link is set up all by itself, and to confirm this, pin 2 of the module goes to 2.7 V, as shown by D3 lighting, after amplification in Tl. See Table 4 for the other channel select modes — four in all — that can be configured using Sl-8 and a jumper on Jl. The audio outputs are available on pins 8 and 10 and drive two identical chan- nels. A first stage, built around IC2A (or IC2B), forms a second-order Sallen & Key low-pass filter. This lets us cut off everything above 24 kHz, thereby 12/2008 - elektor 35 WIRELESS AUDIO S2 I H r- 10n 1 SI 10 ITTTT1 I mn i i ID http fTTTTl — I 20 +5V O _32 11 19 20 _22 21 -0+9V BT1 9V 5 BT2 9V -0-9V MODULE1 19 12 18 13 17 14 16 15 15 16 14 17 13 18 12 5 11 4 VCC. USER_BIT TACT_SW PWRON TACT_SW MUTE SW2 DAC_L SW1 GND SWO DAC_R ID3 ID2 DAC_L ID1 AMP_L IDO DAC_R CHJ/IODE AMP_R OB GND FORMAT TACT_SCAN CH_L CTJNU GND DC_IN CH_R GND GND OO 9 10 27_ 30_ 28. 29. 26. 25_ 24_ 23 RX-AUDIO-2.4 IC1 D1 +9VO — <► 1N4004 ci 470u 25V LM317T IN OUT ADJ C3 lOOn -0+5V +9V C4 470u 25V lOOn IC2 H D2 C9 CIO lOOn C15 lOOn H C16 lOOn C5 2u2 R6 r ||-^-r8k2 C6 820 p R7 R5 R13 X cii 2u2 R11 8k2 +5V R21 JR23 I R1^ 8k2 R1^ Ik R11 10k R12 [Toor R17 C12 820 p R18 Tk R20 •— flOOR R1^ 10k K2 O L R ♦ AUDIO D3 080647 - 12 R22 ? €> BC547 IC2 = OPA2134 IC3 = OPA2134 Figure 3. Receiver circuit. eliminating the residual digital arte- facts from the Aurel modules. Without the filter, overall distortion is around 0.5-1%, but drops to 0.016% with it. This filter is followed by the dual-gang balance pot P2 in conjunction with the volume pot P3. The ‘power’ — if we can call it that, for a headset — amplifier is formed by the dual op amp IC3 chosen, like IC2, from the range of excellent audio mod- els from the now-defunct Burr Brown (now part of Texas Instruments) with type number OPA 2134. This IC offers extremely low inherent distortion and noise, and is perfect for this project. The amplifiers are powered from a split power rail with respect to ground, with the aim of eliminating the ‘big’ electro- lytic output capacitors that would oth- Figure 4. Receiver circuit board. The Aurel digital audio modules 36 elektor - 12/2008 COMPONENTS LIST receiver Resistors 0.5 or 0.25 watt, metal film, 5% R1 = 270Q R2 = 22C2 R3 = 820D R4,R23 = 1 kQ5 R5,R1 3 = 47kQ R6,R7,R1 4,R1 5 = 8kQ2 R8,R1 6 = 2kQ2 R9,R1 7 = 1 00k£2 R1 0,R1 8 = IkQ R1 1 ,R1 9 = 1 0k£2 R12,R20 = 100L2 R21 ,R22 = 4kQ7 PI = 50T2 preset P2 = 10kf2 potentiometer, dual linear (Vishay-Sfernice type P9A2RFISX1 BB2 1 03MAE3) P3 = 10kf2 potentiometer, dual log- arithmic (Vishay-Sfernice type P9A2RFISX1 BB2 1 03MLE3) Capacitors C1,C4 = 470/-/F 25V, radial, lead pitch 5mm C2,C3,C9,C1 0,0 5, Cl 6 = 1 OOnF, ceramic, lead pitch 5mm C5,C8,C1 1 ,04 = 2jL/F2, MKT, lead pitch 5 or 7.5mm C6,C1 2 = 820pF C7,C1 3 = 560pF Cl 7 = 1 OnF ceramic, lead pitch 5mm Semiconductors D1 = 1N4004 D2,D3 = LED red, low current T1 = BC547B IC1 = LM317 (TO220) IC2,IC3 = OPA21 34PA (DIP8) Miscellaneous K1 = 2-way pinheader K2 = 3-way pinheader J1 = 3-way pinheader with jumper 51 = DIL switch block, 10 contacts 52 = pushbutton, 1 contact BT1,BT2 = 9V PP3 battery with clip-on lead (optionally with double-pole switch) Modulel = RX-AUDIO-2.4 (Aurel) + 2 off 2x8 contacts with 2.0mm lead pitch (e.g. Molex type 872641 652, Farnell # 856-0145) PCB no. 080647-2 erwise be needed. Despite the receiv- er’s consumption of nearly 100 mA, we’ve used two 9 V batteries in the 6F22 (PP3) format. If you’re sure you won’t ever con- nect the batter- ies the wrong way round, you can replace D1 with a wire link and gain a little longer bat- tery life. Another option would be to use 12 recharge- able AA cells in series, tapping off Table 2. Principal specifications of the Aurel RX Audio 2.4 modules (Aurel figures). Parameter RX-Audio-2.4 Units Min. Typ. Max. Supply voltage - 5 - V Power consumption - 65 - mA Frequency range 2,400 - 2,4835 GHz Frequency stability - +/-100 - kHz Sensitivity - -83 - dBm Number of channels - 8 - - Frequency response (-1 dB) 20 - 20 000 Hz Dynamic range - 92 - dBm Channel separation - 80 - dB Signal-to-noise ratio - 87 - dB Operating temperature -10 - + 60 °C the ground at 4.8 V, i.e. after 4 cells, giv- ing power rails of + 9.6 V and -4.8 V. The circuit copes perfectly well with this asymmetry. According to its data sheet, the Aurel module must be powered from 5 V ± 0.1 V, corre- sponding to a preci- sion of 2%. Pot PI in conjunction with R2 makes it possible to adjust the voltage to 5 V exactly. 12/2008 - elektor 37 WIRELESS AUDIO Table 3. The function of the DIL switches on the transmitter and receiver. The receiver and 2.4/AE transmitter have all the options, unlike the 2.4 transmitter. The ID bits make it possible to use several wireless systems in parallel without interference. In this way, a wireless 5.1 system is easy to achieve. SI Module 1 Function SI -1 SW2 Channel select, bit 2 SI -2 SW1 Channel select, bit 1 SI -3 SWO Channel select, bit 0 SI -4 ID3 Identification bit 3 (2.4/AE) SI -5 ID2 Identification bit 2 (2.4/AE) SI -6 ID1 Identification bit 1 (2.4/AE) SI -7 IDO Identification bit 0 (2.4/AE) SI -8 CH_MODE Use S2 to select channels SI -9 OB Out-of-band communication fortesting (2.4/AE) Sl-10 FORMAT Encrypted (2.4/AE) Constructing the receiver The suggested PCB is shown in Fig- ure 4 and doesn’t present any particu- lar problems in construction. However, sourcing the components is worth a few comments. The OPA 2314s are available from Far- nell or RS Components, for example. The same goes for the pots we’ve used, from the special audio range by Vishay-Sfernice in order not to degrade the performance of our system by using types that might have the ill grace to start ‘crackling’ after only a few uses. Just as for the transmitter, the female connector for the receiver module is a 2 mm pitch type, but needs to have 2 rows of 16 contacts. As such a type doesn’t seem to exist, we used two 2 x 8-contact types stacked end-to-end. Although in tricky reception conditions LED D3 can be quite handy, to see if the receiver has indeed been able to find the signal, it is entirely optional, especially if you are keen to minimize power consumption. Tests and measurement results Given the cost of the Aurel modules, it’s wise to carry out a few simple checks before powering up the project. On the transmitter side, check that reg- ulator IC1 is indeed supplying the cor- rect voltage required by the module you’re using before you plug it into its connector. Re-read if necessary what we’ve said above about the correct position for it in the connector. On the receiver side, check too that the supply to the Aurel module is indeed 5 V ± 0.1 V. If all is well, plug the modules and ICs into their respective sockets and apply the power. LED D3 on the receiver should light very quickly if you are in automatic channel search mode. Oth- erwise, and if you are using a 2.4/AE transmitter module, it will only light if DIL switches S 1-1 to 7 are set the same on both transmitter and receiver. You can then connect an audio source to the transmitter and note the fine qual- ity of the whole link via the receiver headset,. Even though the author — a serious hifi enthusiast — (still) has fairly reliable ears, a few measurements were added to support the good impression left by the first listening. In order for these to be meaningful, they were made over the whole of the audio chain, i.e. from the transmitter input to the receiver output. The signal-to-noise ratio is better than on many commercial audio amplifiers used in headphone mode, while the distortion, even though it does increase slightly above 5 kHz because of the digital conversion technique used, is still way below what even the most experienced ears can hear. The sound level that can be achieved from the headphone output using the OPA 2134 is more than adequate, whether you use a medium- or low- impedance headset, and will even let you damage your eardrums if you turn the volume up too high. The frequency response, measured under the same conditions as the dis- tortion, is from 15 Hz to 18.5 kHz at the -3 dB points. The power consumption is the sole drawback of this project, but unfortunately there’s nothing we can do about that, as it’s mainly due to the Aurel modules. It amounts to 72 mA for the transmitter and 97 mA/-16 mA for the receiver, with both LEDs lit. Whether you’ve never used a wireless headset before, or have already been disappointed by certain commercial models, we have not the slightest hes- itation in recommending this project which makes no compromises in terms of audio quality. Table 4. How to choose the receiver's various channel select modes (X = pin floating). Mode CH MODE (SI -8) TACT SCAN (J1-1) CTJNU (J1-3) Function DIP GND X X Channel selected by SI -1 , SI -2, and SI -3 TACT X GND X Channel change using S2 TACT SCAN X X GND Performs a scan after S2 is pressed AUTO SCAN X X X Automatic scan 38 elektor - 12/2008 Figure 5. Frequency response. Figure 6. Distortion measurements. The sample Aurel digital wireless audio modules used by Elektor in this article were kindly supplied by P2M (France) ( 080647 - 1 ) Internet links Aurel: www.aurelwireless.com UK distributors: J&C Components (info@jandccomponents. co.uk); Radio-Tech Limited (sales@radio-mo- dem.com); CHARTLAND Ltd. (chartland@ dial. pipx. con). US distributor: ABACOM (abacom@abacom-tech.com) Author's website: www.tavernier-c.com Advertisement B++IL4/IXS www.parallax.com Milford Instruments (+44) 1 977 683665 http://www.milinst.com The Propeller chip from Parallax Simplify your embedded designs with the Parallax-designed Propeller chip. This high-speed parallel-processing microcontroller has eight 32-bit processors that can perform truly simultaneous tasks, J J independently or cooperatively, with deterministic timing. 12/2008 - elektor 39 TECHNOLOGY PoE Power over Ethernet Stefan Tauschek (Scantec) Providing power to apparatus over network cables has always been usual practice for fixed- line telephones, and now the same capabilities are becoming available on wired Ethernet. The IEEE 802.3af PoE (Power over Ethernet) standard allows up to 13 watts to be supplied and its successor, PoEPIus (802.3at), allows up to 30 watts. In this article we look at how it works in theory and in practice. Power over Ethernet (PoE) allows power to be supplied to all kinds of devices, from access points to IP cameras. Alt- hough users will be happy to be relieved of the problem of finding a spare mains socket when connecting up their latest gadget, things are not so easy for the manufacturer of networking equipment. A 24-port switch fully fitted out with PoE needs a power supply with a rating of nearly 1 kW. High-efficiency switching supplies and careful power management are thus needed. Figure 1. Power can be supplied via endspan PSEs (PoE-capable switches or hubs) or via midspan PSEs with normal switches or hubs. The connected device which receives power is known as a PD. PSE (power < transmitter) TOT ] mm HOT TOOT TOOT TOOT fflnflpqnnnn Switch Midspan PSE PD (power < receiver) k IP Phone WAP Security Camera IEEE standard PoE IEEE standard 802. 3af defines PoE. The standard speci- fies how both data and power are delivered over a net- work cable (generally Cat 5 or Cat 5e). An extension to the standard, 802. 3 at, is already being worked on. It will allow for higher power levels, sufficient to supply laptops, video phones and high-power WLAN access points without the need for separate mains adaptors. In delivering power over a network cable PoE is reminiscent of analogue fixed-line telephone systems (POTS, or Plain Old Telephone System) which provide phantom power to apparatus over the a- and b-wires. PoE allows a modern VoIP telephone to be powered in a similar way, without needing a separate mains supply. The problem of thin wires Delivering electrical power over a Cat 5 Ethernet cable pre- sents some technical difficulties. The conductors used are typi- cally AWG 24 (approximately 0.5 mm diameter) and have a resistance of around 94 Q per kilometre. The figure is slightly higher than might be expected because the individual twis- ted conductors in 1 km of cable are slightly more than 1 km long. If we consider the maximum cable run for a single seg- ment of an Ethernet network (100 m) and use four conductors to carry power, we can expect a total loop resistance in the region of 1 0 Q. If the connected device needs say 1 0 W of power at 5 V the current drawn will be 2 A and the cable 40 elektor - 12/2008 will drop 20 V and dissipate an astonishing 40 watts! The conclusion is clear. To reduce losses in the cables we need to use higher voltages at lower currents to send power to the attached client devices, each of which will contain a DC-to-DC converter to reduce the voltage to the required level at a higher current. In the PoE standard the nominal voltage supplied is 48 V (with an acceptable range being 36 V to 57 V) at a maximum of 350 mA. This means the system is covered by the SELV (safety extra-low voltage) regulations [1]. Even at this voltage there is a noticeable voltage drop: 0.35 A times 10 Q is 3.5 V. The network cable dissipates up to 1 .2 W. DC-to-DC converters at both the supply and cli- ent end ensure stability of the final supply voltage. PoE topology As Figure 1 shows, a PoE system consists of a source (the PSE, or Power Sourcing Equipment) and a number of sinks (PDs, or Powered Devices). There are two types of PSE: so- called endspan devices and midspan devices. The former are sources of data packets and current, while the latter pass data packets through and add PoE. Figure 2 shows how the unused pins 4 and 5 (positive) and 7 and 8 (negative) of an RJ45 connector can be used in 10BASE-T and 100BASE-T systems. An alternative is shown in Figure 3, where phantom power is supplied on data pins 1,2,3 and 6. Phantom power exploits the fact that Ethernet connections provide galvanic isolation between pairs of connected devices using a transformer at each end. It is therefore pos- sible to add a DC voltage to the signals using the centre taps of the transformers, without adverse effect on signal quality. This form of PoE is generally preferred as with existing instal- lations it is not always certain that the so-called 'spare pairs' are actually connected in the cables or connectors. In Giga- bit Ethernet systems there are no spare pairs, as all eight con- ductors are used (in four differential pairs) for data transfer. PoE operation At power-up a PSE device must first determine whether any PDs are connected and what their power requirements are, and check that there are no short-circuits in the network. To this end the PoE standard specifies a signalling protocol whereby the necessary information is exchanged at boot time to ensure effective power management. After reset or power-up the so-called 'signature detection' sequence starts (yellow area in Figure 4). The PSE provides a 0. 1 V/|js voltage ramp in the range from 2.7 V to 1 0 V. By carrying out two impedance measurements it can determine whether a PD is connected. If the detected impedance lies in the range 1 5 kQ to 33 kQ the classification phase begins. If an impedance outside this range is detected, power is disabled on the connection. The next step is to determine the power classification of the PD. During this phase the PSE raises the voltage into the range 14.5 V to 20.5 V. The PD should draw a 'sig- nature current' which signals its power class to the PSE. The PSE can then determine the PD's power requirement. The 802. 3af standard specifies five power classes (see Table 1). When classification is complete the PSE raises the phantom supply voltage to its nominal value of 48 V. The maximum POWER SOURCING POWERED DEVICE EQUIPMENT [PSE] (PD) Figure 2. In a Fast Ethernet system power can be supplied over the two spare conductor pairs. POWER SOURCING POWERED DEVICE EQUIPMENT [PSE) (PD) Figure 3. Phantom power uses the data conductors and hence is also compatible with gigabit Ethernet. PSE Voltage Figure 4. Signalling protocol for 802.3af PoE. Table 1 The 802.3af standard defines four power classes plus a reserved class, which is used for PoEPIus. Class Use Signature PSE power PD power 0 standard < 5.0 mA < 15.4 0.44 W to 12.95 W 1 optional 10.5 mA <4.0 0.44 W to 3.84 W 2 optional 18.5 mA < 7.0 3.84 W to 6.49 W 3 optional 28.0 mA < 15.4 6.49 W to 12.95 W 4 reserved 40.0 mA reserved reserved 12/2008 - elektor 41 TECHNOLOGY PoE Figure 5. The classification phase in 802.at consists of two pulses. Figure 6. The AS 11 35 controller is available in a 5 mm square QFN package. Figure 7. Block diagram of a PoE DC-to-DC converter using an AS11 35. PSE Voltage Paddle Ground in . package m j > bfliiom u i= m m a I Z ti; u_ > z * 20 19 18 17 16 NC 1 15 CS V0D48O 2 14 CSS NC 3 Asms 13 cawip VDD48( 4 12 FB GND 5 r- cfj cr> ^ 11 LVMODE a □ <£ z z 9 (J o g 01 V> tr in 3 < O 7^ * £ losses in the cable are such that at least 37 V appears at the PD at a current of 350 mA, for a total power of 12.95 W. There is thus a total of three phases: detection, classifica- tion, and application of power (operation). There are vari- ous timing requirements that must be observed. For exam- ple, under PoEPlus, signature pulses can last a maximum of 30 ms and the gap between them can be at most 1 2 ms. to 720 mA from 350 mA and the maximum permissible cable temperature is set at 45 °C. PSEs designed according to the new standard can be used with 'old' PDs. On the other hand, new PDs can of course not draw the full 30 watts from an old-style PSE. The new parts of the system are accommodated by extending the classification procedure. As Figure 5 shows, there are now two classification pulses. PDs conforming to PoEPlus must initially identify themselves as class 4 devices. During the extra classification pulse they must then draw a signa- ture current of 40 mA. A PoE standard device will ignore the second pulse, allowing a clear distinction to be made between PoE and PoEPlus devices. Practical implementation Many companies, including Linear Technology, Texas Instru- ments and National Semiconductor, are already producing chips to support PoE technology. Because of their high level of integration we will look below in greater detail at prod- ucts from Akros Silicon, a relatively young company. The AS1 113, AS1 124, AS1 130 and AS1 135 are PoE controllers fabricated using a standard high-voltage CMOS process. They are physically small and have a high level of integration. The AS1 1 1 3 implements the 802. 3af stand- ard, delivering up to 1 3 W of power. The most recent mem- ber of the family, the AS1 135 (Figure 6), is designed for PoEPlus applications and can deliver output powers from 1 3 W to 30 W. Since the various PoE devices from Akros Silicon are pin-compatible with one another, system manu- facturers can lay out a single printed circuit board for both high- and low-power devices, avoiding the need for com- plete re-designs. The PoE ICs include a current-mode DC-to-DC converter with soft-start and current limiting functions. Using suitable external components, flyback, forward or buck configurations can be realised, and both isolated and non-isolated devices are supported. The AS1 135 example circuit has particularly high efficiency thanks to an active rectifier, where the conventional second- ary switching diode is replaced by a synchronously-con- trolled FET. This technique avoids the otherwise inevitable forward voltage drop of 0.5 V or more associated with Schottky diodes, substituting the voltage drop across the very low channel on resistance of a modern MOSFET. This saves up to 0.5 W or even more at higher currents. ill- PoEPlus using the AS1 135 The design we describe here is based on the Akros S con reference design. The AS1 135 [2] is the first control- ler device to support the provisiona 802. 3at ( Draft 3.0) standard, which uses a double pulse during the classifica- tion phase. It is therefore backwards compatible and can be used as a PD adaptor in power-drawing devices and in PoE-standard PSEs. More power The successor to PoE, IEEE 802. 3at or PoEPlus or PoEP- lus, is under development. It is backwards compatible with 802. 3af and will allow up to 30 W to be delivered to a PD. The standard mandates the use of Cat 5e cabling and the PSE voltage range is raised from between 44 V and 57 V to between 50 V and 57 V. The maximum current is raised The highly-integrated DC-to-DC converter drives an external power switch and monitors the current through the primary winding of a transformer. It provides a soft-start function. The switching frequency can be set using a resistor in the range 1 00 kHz to 500 kHz: in the example circuit we have selected 350 kHz. The transformers do not need to be made specially: suitable types are available from distributors such as Coilcraft, Halo Electronics and Wurth Elektronik. 42 elektor - 12/2008 Figure 8. Connecting an AS11 35 to the Ethernet cable. PD circuit The Ethernet cable from a switch or midspan is terminated using a Belfuse RJ45 socket/transformer, which supports data rates up to 1 Gbit/s and which is designed for use in PoE applications. As can be seen in Figure 7, the centre taps are taken via a bridge rectifier to the voltage input V dd 48I of the 1C. In the practical circuit shown in Figure 8, all pairs are used and so two bridge rectifiers are provided. The signature current of 40 mA is set by resistor at R c | ass/ corresponding to power class 4 and thus also to PoEPlus. The resistor at R curr sets the current limit: the pin being left open circuit corresponds to the maximum value of 900 mA. The feedback pin FB is not used in the isolated buck/boost converter configuration, and so is taken to ground. The capacitor on pin CSS sets the time constant for the soft-start function: 1 00 nF gives a value of around 2 ms. Since in practice it is not known in advance whether a device capable of being powered using PoE will actually be used in a network that supports it, devices also need to be able to accept power from an external mains adaptor. This is very straightforward to set up using the Akros control- lers. An external voltage between 1 0 V and 57 V is applied via a diode to pin V DD 480 and simultaneously via an RC network to LVMODE. This tells the controller that an external supply is available and V DD 48I is isolated. The DC-to-DC converter, however, remains active. The voltage regulator circuit proper, shown in Figure 9, is rather more complicated. The polarity-protected, rectified voltage from the Ethernet cable is taken from pin V DD 480 via a pi-filter which protects the LAN signal wires from inter- ference. From there it goes to the primary side of a trans- former and thence to the primary switching transistor, which {2} VDD480 »- C4 .1uF 100V D01608C-103MLB LI _TYVY\ 10U ' ' C6 :i0uF 100V t v ^ m 1.1A I r\\/ — ' — — — X sfjov Place CIO & Cll close to AS1135 {2} NDRV » R57 0.0 „ — 4- {2} CS »- Q3 Si4848DY R11 0.18 lOOpF {2} VBN » CIO 330nF 1 — tr 1 0 1 _|C17 Us 4.7uF 2 i. 8V NL BZT52C5V1 ,5W {2} COMP »- C27 15nF _C22 0.47uF > R23 > 2K m D17 • R83 24.9K NL A MMBT3906 NL R84 11.5K NL 10 DC-DC Converter Halo: TGSP-P026EFD20LF Coilcraft:GA3567-BL T3 R77 -vW- 0.0 BZT52C16-7-F 16V ,5W BZT52C16-7-F 16V ,5W 35 F 2i D20 5 BAS16W-TP NC LED C FB E COMP C18 1.5uF NL Hb * C13 7nF 2KV Optional short circuit protection _|P c- IV 4. C14 7nF 2KV C42 1 1 220pF 50V 100k _2 k&r arr 47uF 16V 47uF 16V Option Filter Inductor J16 Short across L7 47uF 16V CCUJ 2.2uH,MSD1278 NL R16 8.87k 1% > R22 >825 R61 0.0 C38 330uF, 16V _L IOuF 16V -X R56 6.19K 1% 'N/V — 1 C24 — J- C21 NL 2 .2nF R64 3.32K HEADER 2x1 .IOOx.100 X7 BRD GND Figure 9. DC-to-DC flyback converter with an output power of 30 W and active rectification. 12/2008 - elektor 43 TECHNOLOGY PoE About the author Stefan Tauschek studied electronic engineering, specialising in commu- nications, at the Munich University of Applied Sciences, and worked for several years developing multimedia compon- ents, video processing and streaming media technologies. He is now a technology consultant at Scantec AG, supporting industrial cu- stomers in projects invol- ving networking, telecommunications and automation. E-mail: stefan.tauschek@scantec.de switches to ground. The device used here is a Si4848DY from Vishay, an N-channel MOSFET with an on resistance of around 1 00 mQ at a current of 3.5 A. Components R59, R62, C35 and D6 form a snubber network to suppress spikes. Short-circuit protection on the secondary (device) side is provided by a limiting circuit consisting of R83, C 1 8 and Q5. In operation the voltage difference between pins 5 and 6 of the transformer is about 6.5 V. This is sufficient to ensure that transistor Q5 remains firmly off. If there is a short circuit at the output, the AS1 135 sets the mark-space ratio of the switching pulses in flyback converter configura- tion to a minimum and the voltage between pins 5 and 6 falls. Then Q5 starts to conduct and pulls the COMP pin of the AS1 1 35 to ground. This in turn limits the current to about 1 00 mA for as long as the short-circuit persists. The Fairchild FOD2712 optocoupler allows the AS1 135 to monitor the output voltage. The frequency response of the negative feedback loop can be set using an extra RC network to achieve stable operation with a quick control response and low overshoot. The future: 60 W As standard PoE has become more widespread for local area networks, more and more client devices have become able to make use of it. The power limit of 1 3 W offered by 802. 3af was, at the end of the 1 990s when the stand- ard was developed, entirely adequate as there were few devices capable of using phantom power and the Cat 3 cable that was generally installed was not electrically suit- able for providing more. Since then things have changed: now Cat 5 and Cat 5e cable are ubiquitous in network installations, offering higher bandwidth and lower resistance. Also, there has been a sharp growth in demand for devices such as VoIP telephones, IP cameras and wireless access points, which can all benefit from PoE. PoEPlus supports these developments by doubling the avail- able power to 30 W. But, adding to the performance also provokes the desire: and so the IEEE 802. 3at working group is now looking at how power levels of up to 60 W can be delivered using Cat 5e cable. Figure 10. The reference board from Akros Silicon, ready for operation. Internet Links [1] SELV: http://en.wikipedia.org/wiki/Extra-low_voltage [2] AST 135 product page: http://www.akrossilicon.com/products/asl 1 35.html More power using four conductor pairs Since the PoEPlus specification stretches the physical capac- ity of Cat 5e cabling and connectors to the limit, a further doubling in power can only be achieved by using greater parallelisation. The IEEE working group looking at this prob- lem is therefore intending to consider delivering electrical power over all four Ethernet cable pairs rather than just two. That would give a direct doubling of power capacity to 60 W. However, the working group appears to have suffered a case of cold feet, as in Draft 3, dated March 2008, a power limit of 24 W for two pairs was proposed. There is considerable concern over cable overheating, particularly in large networks with thick bundles of cables, which could lead to damage to the cable or even to fires. Whatever variation wins through, it is certain that PoEPlus in its final form will be specified for power levels in excess of 30 W, divided over four pairs of conductors. ( 080334 - 1 ) 44 elektor - 12/2008 f>>« co ection tnxx.cow electronics world J W" Things past ML* ✓J >4 * . m v *■ 'i i _ i i r * tkm* *3 4,1 > I i L * ' 1 - j j 1 to- « i * 7- i# 4 / r I m t ji •% ■i Elektor is now & tomorrow m Secure a head start in electronics i Advantages to subscribers IcVtOT iti.fiirt - r 9 Lsdi * Cheaper than 1 1 issues from the newsstand A * C t& om* \)5& With every issue subscribers get up to 40% discount on selected Elektor products Vote * 5 ftet 6<4 e * As a welcome gift you get a free 2GB MP3 player worth £31 .50 No queues, travelling, parking fees or ‘sold out' Elektor is supplied to your doorstep every month — Always up to date - read your copy before ^ everyone else www.elektor.com/subs * Tel. +44 (0) 20 8261 4509 i^l[!i:lmnu:M wcirldwiiJii Or use the aubscrl prion order form noor ifto und or tho magazine. Assorted small circuits in a free 24-page section in Elektor s December 2008 edition For the third year round, Elektor editors and designers have compiled a varied collection of simple but useful and sometimes even charming electronic circuits that you can build yourself, eliminating, hopefully, any cause to complain about a general lack of simple stuff in the magazine. The 2006 and 2007 i-TRIXX supplements were generally well received in terms of their classroom merit and technical content, both by old hands at electronics and newcomers to the Elektor publication, from all over the globe. The success story is continued this year. Although the present i-TRIXX collection is again aimed at those of you starting out in electronics or on a modest budget & scavenging components from the junk box, we know that the circuits presented also have an appeal if you just want to slap something up in an afternoon or so. All projects are based on easy to obtain components or items normally thrown away as useless just because you're told they are not "state of the art", whatever that means. An i-TRIXX project is never complicated, big or difficult to understand, we hope! Plus, it can be soldered together in a spare hour or so. These free 24 pages contain a large selection of these types of circuits pulled from the Elektor lab and from our large circle of free-lance contributing authors. If you would like to contribute to next year's 'dose', please let me know. Happy reading & soldering (all RoHs compliant, of course!) Jan Buiting Editor CONTENTS Add more speakers 4 Switching with relays 5 Potted-plant battery 6 Scarecrow 7 Acoustic finder for model aircraft 8 An intercom using six components 9 Schrodinger s egg 10 Remote Control Extension 11 Eco- server 12 Parking sensor (also for men...) ....13 LED bicycle lamp 14 Theremin Is Alive and Well ..15 USB -controlled mains socket 16 Electronic cat s eye 17 Code lock 18 Capricious blinking light 19 Moving -coil alarm sensor.... 20 LED Night light 21 6-component code lock 22 LED Blinker 23 i-TRIXX collection 3 Add more speakers Design: Franz-Peter Zantis (Germany) The chances are that you only have one socket on the back of your mini HiFi to connect the speakers. Wiring an extra set of speakers in parallel to the originals may damage the amplifier output stage if the resulting load impedance is too small. Extending the sound of your HiFi into another room (e.g. bedroom or study) may not be entirely unproblematic. For clarity the modification to only one of the stereo channels is described here, simply repeat the process to make extensions for both the left and right channel speakers. It may be the case that you have a mini HiFi without any speakers or you want to use the (usually low quality) existing speakers as extension speakers. Firstly check the amplifier rating which should be either in the amplifier handbook or printed on the back of the amplifier. Choose a set of main speakers (LSI) which have an impedance greater than the minimum load that the amplifier can handle. This minimum load may for example be 4 £2 in which case 6Qor better still 8 £2 speakers would be a good choice. Amplifiers with a minimum load of 6 £2 would need 8 £2 or better 12 £2 speakers. Most amplifiers will have enough power in reserve to offset the reduction in volume. The loudspeaker sensitivity with respect to the volume setting now seems to have an approximately logarithmic characteristic rather than linear. For the extension speaker LS3 make sure its impedance is equal to or greater than the main speaker LSI. From the diagram you can see that the principle is really simple, now that the main speakers have an impedance greater than the minimum value required by the amplifier it allows an extension speaker (with a suitable series resistor R1) to be wired in parallel without loading the amplifier too much. The minimum value of series resistor R1 can be calculated: R1 = (R . x 7 + R x ' min LSI min Z - Z X LS3 LSI Z,„) / (Z IC1 - R ) LS3' ' ' LSI min' LSI min' The value R is the minimum load that the amplifier can min r handle (check the amplifier specification). The power rating (P R1 ) of resistor R1 can now be calculated: P p1 = (P x R1) / ((z,„ + R1)^2 : Z ltM + Z 1Q1 x R1) R1 ' max / / \\ LS3 ' LSI LSI ' Power dissipated in the extension speaker will be: P = (P x z ) / ((Z + RI )^2 / Z +1 x ri) LS3 V max LS3' ’ '' LS3 ' > LSI LSI ' Power dissipated in the main speaker will be: = P max / (1 + Z|_si / (Z|_ S3 + RI)) A typical example giving R min = 4 0, P max = 50 W, Z =80 and Z LS3 = 80 can be worked out in your head. RI is not needed i.e. it has a value of 0 0 and power is divided equally between LSI and LS3, each dissipating 25 W. When however Z LS1 has a value of 6 0, then RI = 4 0, P LS1 = 33.3 W, P LS3 = 11.1 W and P R1 = 5.6 W. Ensure that the power rating of RI is bigger than this figure. 4 i-TRIXX collection Semiconductor devices such as triacs and thyristors are taking over more and more tasks from normal relays. However, this doesn't mean that you can't build interesting or useful with normal relays. Switching THIS CIRCUIT, SUCH AS Design: Thomas Scarborough (South Africa) THE ONES DESCRIBED BELOW: circuits with relays THERE ARE A VARIETY OF APPLICATIONS FOR There are many practical applications in which it is necessary to switch a lamp or other device on and off by using a short pulse or briefly pressing a button. For example, this method (which is also called toggle operation) is used in the staircases of many public buildings for switching the hall lights using relays with built-in timers, such as the German Eltako series. Relays are a perfect choice for this application. A relay with two separate changeover contacts is well suited to this sort of job. Many relays are available in encapsulated form, which provides better protection against corrosion and soiling of the sensitive contacts. In principle, it does not matter which product you use as long as the relay is designed to handle the intended task. The contacts and the coil must both be specified for the currents and voltages used in the application. Here one of the two changeover contacts (RLAlb) switches a load (such as a lamp, machine or motor) on and off. The second changeover contact (RLAIa) is used to latch the relay. This means that the relay remains actuated after pushbutton switch SI (a normally-open switch) is released. When SI is pressed, RLAIa closes and shorts out SI. As a result, current continues to flow through the relay after the button is released. A brief interruption is all it takes to stop the current, and this is provided by S2, a normally-dosed switch. Naturally, an external switch such as the contacts of a motion detector can be connected in place of SI or in parallel with it. If you wish, you can also use a separate supply voltage ('optional switching') to energise the relay coil in parallel with the usual control arrangement. Gag circuit We conclude with small story from the author's experience. As a youth, he once hid a circuit like this in a rubbish container. The idea was that when the lid was opened, it should send a current through the filament of an incandescent lamp (with the glass removed) to light a string of small firecrackers. In order to attract potential victims, Thomas glued a piece of paper to the container with a note saying that the lid should not be opened under any circumstances. When his father came home from work in the evening, he asked with some surprise what the note on the container was supposed to mean, since he had opened the lid and nothing had happened. As his son thought that his circuit must have failed to work, he went straight to the rubbish container, opened it, and found himself in the midst of a hail of exploding firecrackers. As it happened, his father had seen him putting together his firecracker alarm earlier that morning. ( INTRUSION ALARM r SAFETY MAINS SWITCH Picture the following situation: while a table saw is running in a carpentry shop, there is a sudden power failure. As a result, everything stops working, and everyone takes a break. If the shop foreman forgets to switch off the machine, it will unexpectedly start up again 'on its own' when the power is restored. This can be quite hazardous. If the above circuit is fitted to the table saw, this cannot happen. It will remain in the 'off' state even after power is restored, and it can only be started again by pressing switch SI again. For a truly professional solution, the circuit can be built using a large green pushbutton for SI and a large red pushbutton for S2 (available in the better class of home-improvement shops). ~~r. THEFT ALARM For this application, SI is replaced by a switch with normally- dosed contacts and the object to be protected (such as a PC) is placed on top of the switch so that its weight actuates the switch. If the object is removed, the switch closes and a siren is activated by RLAlb, and it continues to sound until switch S2 (in a concealed location) is pressed. +VE r TWO-WHEELER ALARM Contact switches respond to motion. If a contact switch is used for SI and the entire arrangement is built into a moped, scooter or motorcycle, the alarm will be triggered as soon as a thief moves the vehicle. , If SI is replaced by a door switch or window switch, the circuit can be used as the core of a home intrusion alarm system. With this version of the circuit, as many switches as desired can be connected in parallel in place of SI. A key switch can be used for S2 in this case, so that the siren triggered in case of an alarm can only be switched off by the homeowner. i-TRIXX collection 5 Potted-plant battery Design: Thomas Scarborough (South Africa) As incredible as it may sound, the author has recently been powering a LCD clock module from a set of potted plants. A 'biological power station' of this sort may remind you of the well-known apple and lemon batteries, where two electrodes made from different metals are stuck into a piece of fruit to form a sort of simple galvanic cell. However, in this case the cells of the battery draw their energy directly from the plants, rather than from an electrochemical process. Does this means that the plants are actually generating the electricity? pot soil shared by the plants would act as a sort of 'common ground' in the literal sense. The pots must also be located on an electrically non-conductive surface. The schematic diagram shows how five potted plants can be connected in series to form a biological battery with five cells. Five or six plants are enough to power a 1.5-V LCD clock or a simple LCD thermometer. Just like a normal battery cell, each plant has two terminals. The first terminal is located on a branch of the plant. This terminal can be formed by sticking a needle or small pin through a branch of the plant and connecting an alligator clip to it. The other terminal is in contact with the pot soil. There's no question that the plant battery supplies free energy. It's not much, but it's still energy. This energy is apparently not generated by an electrochemical process, but instead directly by the plants. The plants continue to supply energy as long as they remain alive. Thomas does understand exactly how this works, but he knows from experience that it does work. r j A potential difference of approximately 0.4 V can be measured between the plant and the soil it grows in. This voltage source can supply a power of approximately 0.8 microwatt, regardless of whether the plant is a small houseplant or a large bush. Of course, this is far too little power for most applications, but it is enough to operate a simple LCD clock module. Of course, this requires connecting several plants in separate pots in series to form a battery. The series connection would not work if the plants were all in the same pot, since in that case the HOW DOES IT WORK? A relatively long metal rod stuck into the soil, also connected with an alligator clip, is sufficient for this purpose. All of this is shown quite clearly in the photos. Five or six potted plants can be connected together in this manner to form a series circuit as shown in the schematic diagram. Now an electronic device, such as an LCD clock with very low power consumption, can be connected to the outer terminals of this battery. The positive terminal of the clock is connected to a free branch of the first plant in the series, while the negative terminal is connected to the soil of the last plant in the series. \ The operating principle of the potted-plant battery is currently the subject of vigorous discussion in numerous forums. We don't want to get involved in these discussions here, but we can present a few facts mustered by the author to counter the arguments of his opponents: 1. The objection that this is simply an ordinary electrochemical reaction can be proven false by using gold-plated electrodes, since gold is a noble metal that does not participate in electrochemical reactions. Nevertheless, the plant battery produces electricity if gold-plated electrodes are used. 2. It has been suggested that that the energy comes from the reception of radio signals. This theory can be disproved by the fact that the battery also works when it is inside a Faraday cage. 3. A plant expert has suggested that the electricity is generated by the DNA of the plant. The author regards this as the most plausible explanation. (Discussion closed.) 2N7000 G TO-9P 4060B 6 i-TRIXX collection Design: Thomas Scarborough (South Africa) Scarecrow Take a look in any back garden and you are likely to see evidence of the affection we hold for garden birds. Bird feeders and bird baths draw them into the garden in the depths of winter when their usual foodstuffs have long since fallen from the trees and lie frozen in the soil. Even in the summer months bird tables are scattered with old crusts and sunflower seeds to provide a snack for the summer visitors and some people (probably falsely) interpret birdsong as some sort of a thank you from our feathered friends. Anyone who tends a fruit and vegetable garden may have a slightly less welcoming attitude toward them; in the sowing season they eat seeds and nip off the tips of new shoots. At harvest time they take fruit that we were hoping to eat ourselves. As any hobby gardener will tell you, some form of scarecrow can be useful at certain times of the year to protect the crops. You sometimes see a traditional scarecrow stuffed with straw and wearing last years cast-offs standing in the middle of a farmer's field. You will probably also have noticed that after a few days the crows find that this new structure makes a useful lookout post where they can perch and contemplate the breakfast laid out before them. No matter how closely the scarecrow may resemble Ozzy Osbourne, birds quickly learn that static structures pose no threat. A much more effective strategy is to use sound energy. The sudden sound of a shotgun will set all birds in earshot up into the air, and many commercial bird scarers use this effect. The author has suggested this very simple circuit which periodically produces a loud sound to scare birds. The design consumes very little power and uses a common integrated circuit and a piezo sounder. Despite its simplicity, field trials have shown that the device is effective: birds simply flew away when the unit was switched on. After some time the birds did however return, it seems like they eventually become accustomed to almost any disturbance. Anyone living close to a vineyard will know that the farmer only sets out bird scarers as the grapes begin to ripen so that by the time the birds have become tolerant of the noise most of the crop will already have been harvested. The heart of the circuit is a CMOS counter type 4060B (IC1). This chip contains a clock generator circuit which only requires two external components R1 and Cl to set the frequency of oscillation. The clock is connected internally to a 14-stage binary counter with each stage dividing the frequency of the previous stage by two. This circuit uses outputs Q4 and Q14 giving division ratios of 2 4 (= 16) and 2 14 (= 16,384). With the values given the output signal from Q14 is around 1 Hz. This frequency is not audible but is used here to turn TR1 and with it the piezo sounder on and off. The circuit periodically produces a loud screech. If necessary the piezo sounder XI (the type without any internal electronics) can be replaced by a small piezo tweeter unit to increase the sound level. The whole circuit can be powered by primary cells but if the unit is going to be used for longer than about one week it is better to use a high capacity rechargeable battery. The circuit can also be expanded by adding a Light Dependent Resistor (LDR) so that it turns off at night. Remove the connection to ground on pin 12 and connect instead an LDR between pin 12 and ground. Connect a 10 kO (or thereabouts) trimmer between +12 V and pin 12, now adjust the trimmer so that the circuit shuts down as evening approaches. i-TRIXX collection 7 mstm 8 +4V8...+6V IC1.A 1N4148 20 ms 070234-11 (Elektor Labs) the model stops responding to you signals and sets off on its own into the wild blue yonder? Panic breaks out, one thing you can be sure of is that it will eventually come down, the only question is where? (and in how many pieces?) A minor technical glitch can mean that you spend the next few hours scrabbling through hedges, wading across bogs, being chased by dogs and climbing trees in search of the model. Who said that flying model aircraft was a sedentary pastime? Maybe you should be using more of your other senses rather than just relying on your eyes to track down the wayward model. This circuit may be of some assistance... I The circuit can ■ : be powered from the receiver battery pack; it only takes a few pA in normal use when the beeper is not sounding. If the model flies off because the battery pack voltage has sunk too low it will not pose a problem for this circuit. It consumes very little current and will carry on beeping for a long time after the receiver stops working, until the batteries are almost completely flat. It is possible to power the circuit from its own battery pack but you would also need a double-pole on/off switch to switch the receiver and alarm together. Otherwise with separate on/off switches you may forget to turn the alarm back on again the next time you fly. When you think of all the time, money and energy that you have invested in building your model it would be almost negligent not to take the precaution of adding this very simple circuit to the model's electrics. The operating principle is very simple; as long as the receiver is picking up a signal from the transmitter the circuit remains quiet but when the signal disappears for whatever reason it starts to make a loud beeping sound. The loss of signal may be due to the model flying beyond the transmitter range, a temporary electrical fault or the receiver battery voltage dropping too low. When the search is underway an acoustic signal has the advantage that it can be heard from a great distance and is very easy to locate even if the model has come down behind a bush or in a tree. The circuit is so simple and small that it can be built on a small piece of perforated prototyping WW board. Once it has been constructed, wired-up to the receiver and switched on it can be tested simply by checking that the beeping starts shortly after the transmitter is turned off. For peace of mind it jp makes sense to perform this check before the model is released. Next time you visit the flying field you can relax a bit more knowing that if your model does head off on its own you stand a better chance of recovering it, unless of course it's taken a dive into a lake... The circuit is simpler than it looks, input signal is provided by one of the servo outputs on the receiver. When the servo impulses stop IC1.A no longer charges C2 via D1 and R2. After a short while IC1.B begins to oscillate on and off at a low frequency turning the piezo beeper Bzl rhythmically on and That really is all there is to it. The inputs of unused gates IC1.C and IC1.D are tied ground to ensure that they do not oscillate and draw unnecessary current. (Both outputs of these gates will therefore be 'high'). i-TRIXX collection = 1 ms & & 8 9 12 13 An intercom using six components Design: Thomas Scarborough (South Africa) Many electrical transducers have reversible properties: spin the shaft of an electric motor and it becomes a generator, connect a loudspeaker to the input of an amplifier and it works as a microphone. With this last example in mind it is possible to build a super simple intercom that can also be used as a baby monitor. Two piezo loudspeakers are used here as both microphone and loudspeaker, giving a total of six components for the complete circuit. As can be witnessed from the circuit diagram the intercom does indeed contain very few components. The circuit is sensitive enough to pick up speech and any other background noise at a distance of a few metres from the microphone. The unit uses a power opamp fitted in the master unit to boost the signal, giving a maximum output power of around 0.5 W. Control of the intercom conforms the master-slave principle; the master site operator has total control over the system from switch on to talk/listen control. The remote site consists of just a simple enclosure to house the piezo loudspeaker and is connected to the master unit using two-core cable. The design is simple but quite versatile and is suitable for many applications ranging from house intercom to baby monitor. Ignoring the power supply and the on/off switch SI the complete circuit uses just six components. The two-pole send/listen switch S2 simply reverses the positions of XI and X2 in the circuit. For this reason it is important that the transducers are both of the same type. Two moving- coil loudspeakers can also be used in the same basic configuration but it would be necessary to include an impedance transformer at the input to match the opamp input to the (lower) microphone impedance. The piezo transducers used here have a much higher impedance and do not need a transformer which helps keeps the component count down to an absolute minimum. Signal amplification is provided by the power opamp type LM380N (IC1). With S2 in the position shown in the diagram X2 acts as the microphone and XI as the speaker. Operating the switch swaps the function of XI and X2. The switches together with one of the piezo speakers (XI or X2) are fitted into the master enclosure while the other speaker is fitted at the remote site (front door, garden shed, nursery etc.). A two core cable is all that is needed between the two units. Both XI and X2 should be the same type of speaker. The 2-inch tweeter type KSN1020A from Motorola is a good choice here but any similar piezo tweeter would also be suitable. It is important not to use a conventional low-impedance midrange or bass speaker fitted with a coil and magnet. During testing the circuit proved to be quite sensitive; if both speakers are in the same room you will hear the unmistakable screech of acoustic feedback. It is better to put the speakers in different rooms or alternatively for the purposes of testing only, the circuit sensitivity can be reduced by changing the value of Cl. In operation the circuit consumes around 12 mA so a 12 V stabilised mains adapter is an ideal power source but batteries could also be used and would give a reasonable life expectancy if the unit were not in continuous operation. Schrodinger s egg Design: Rob Reilink (The Netherlands) Boiling an egg to give the correct yoke consistency is clearly a very serious business. Everyone has their own preference and it's a sure indicator of a bad day ahead when your breakfast egg turns out to be over or under cooked. Empires have crumbled, marriages failed and banking institutions brought to their knees all for the want of a perfectly cooked egg. OK so maybe we are guilty of over-egging the pudding slightly but the 'doneness' of a boiled egg is difficult to gauge, other foodstuffs are not so secretive; they change colour or yield to the prodding of a knife when they are cooked but a boiled egg just sits there in the pan gently bouncing up and down... A bit like Schrodinger's cat experiment we cannot know the state of the contents until the box/shell is cracked open. Unlike the fate of Schrodinger's cat we can predict the outcome by measuring cooking time. Providing the other variables (egg size, initial egg temperature) are constant measuring the cooking time should produce consistent results. Kitchen timers come in all shapes and sizes the design here emulates the old clockwork wind-up versions with a pointer indicating the time left. Two pushbuttons are used to set the timed period, indicated by the number of LEDs illuminated. As the timer progresses fewer LEDs are illuminated until at the end of the timed period they all go out, indicating that the egg is perfectly cooked. Thinking about how the circuit could be implemented you would probably begin with some digital timer/counter to provide an accurate time base and then add a few gates and drivers for the LEDs. You may even want to simplify the hardware more by using a microcontroller. Over the years we have seen many similar designs that have gone down this route but maybe there is an alternative solution? As demonstrated here and using very few components we can also approach the problem from an analogue direction. A repeatable time base is produced by measuring the time it takes for the voltage in an RC network to decay. The graph plot illustrates what happens when a charged capacitor C is discharged through a resistor R. The voltage does not fall linearly with time but instead traces a curve corresponding to the exponential function. If we were to set ^ voltage thresholds every 0.5 V and measure how long it takes for the voltage to fall 0.5 V it is dear that in the first time period would be shorter than the second which in turn would be shorter than the third I etc, not exactly ideal for 53- a time base. The answer to this problem of non linearity is to use an LM3915 1C. This device is a dot/bar display driver for 10 LEDs. The input voltage level is connected internally to 10 comparators * each with a different threshold voltage. The thresholds in the LM3915 are related exponentially so that they compensate for the discharge curve. The time period between each LED going out is now equal. The RC network is made up from C1/C2 in parallel and R3. Two small capacitors in parallel are used here because they take up less space than a single larger capacity capacitor. Pushbuttons SW2 and SW3 are used for setting the time; a press on SW3 extends the time while a press on SW2 reduces the time. Once the desired number of LEDs are lit the buttons are released and the timer runs. Transistor Q1 limits the voltage on C1/C2, without this measure the capacitor would charge up to the supply voltage and the first time period would be very long. Q1 limits the voltage to approximately 0.6 V above the internal reference voltage (Pin 7 of U1). R4 reduces the current drawn from the reference to 0.5 mA. The LED brightness is also defined by the current drawn from the reference voltage. Using the layout diagrams given here it is possible to make your own PCB. The images can be transferred to a transparent film ensuring that the finished PCB outline measures 72.6 x 47.8 mm. A .pdf file for the layout can also be downloaded from the corresponding page of the Elektor website, just click on 'Layout' to open the file in Adobe Reader. Armed with a copy of the layout on film you should be able to get the PCB made up in an electronic workshop or PCB manufacturers assuming you do not want the bother of making it yourself. Construction can begin by first fitting the resistors then the capacitors followed by the LEDs and transistor. An 18-way socket can now be mounted to take the 1C and lastly fit the pushbuttons and then on the back of the PCB fit the battery holder for the two AAA cells. You can experiment with the values of C1/C2 and R3 to alter the maximum timing period. 10 i-TRIXX collection Design: Jeroen Peters (The Netherlands) Don't worry — we're not planning to reinvent the cable remote control units used in the 1960s. You can continue to use your stable of IR remote controls (a different one for every imaginable device), and using infrared remote control will be even more convenient than before. A normal remote control unit is helpless if the distance is too great or the device to be controlled is in a different room (or worse yet, concealed in a cupboard). We can change that. 100u 16V GND NE555 BC547B BC639 SFH5110 0 0 o ' U U U e e i: Jb fjll Uri B 1 2 3 In brief terms, the operating principle of the solution presented here is that you place an IR receiver in a location where it is readily visible to your IR remote control unit. The received signal, in electrical form, is processed and sent further on its way via an IR transmitter LED (and a length of cable if necessary). This way you can not only increase the range, but also magically operate devices 'around the corner' under remote control. You can also turn down the music in the living room while the food is being served in the dining room, and much more. With regard to IR remote control, you should be aware that there is no such thing as a single operating principle - instead, there is a host of signal types, modulation scheme and codes. Every manufacturer, be it Sony, Philips, Sharp or Panasonic, thinks it has to define its own standard. The only common factor is the use of pulsed IR light. In other words, the signals are transmitted as a series of short or long pulses of light at specific base frequency. The pulse widths are in the range of a few microseconds. Using modulated IR light provides better noise immunity with respect to sunlight and light from household lamps. The modulation frequency is typically in the range of 30 to 45 kHz. For the sake of simplicity, you can use a receiver with a typical average value of 36 KHz, since the receiver modules are not that highly discriminating. The Osram SFH5110-36 (IC1) is a fully integrated IR receiver (see photo) that operates at 36 kHz and generates pulse signals from the received IR light. ICs of this type are available for a number of other frequencies, but experiments have shown that most remote control units also work with the 36-kHz version. Nevertheless, you can use an SFH5110-33 (33 kHz) or an SFH5110-40 (40 kHz) if it suits your purpose. Here T1 simply acts as an inverter, so a signal with the right polarity for IC2 is available at R2. When IC1 receives IR light. its output goes low and the collector of T1 goes high. This signal drives the Reset input of the timer 1C (IC2), which acts as a controlled 36-kHz signal source. IC2 acts as an oscillator. As long as T1 provides a 'high' signal, a pulse waveform at the desired frequency of 36 kHz is present at the output. The frequency is determined by R3, R4 and C2. Although the frequency may vary slightly due to component tolerances, this does not have a significant effect in practice. In summary, we can say that whenever the receiver sees IR light, the circuit emits IR light at a frequency of 36 kHz via IC2 and the IR LED (D1). Transistor T2 is an amplifier stage that provides the current through the LED (approximately 60 mA). The current pulses are filtered by R6 and C3 to reduce the peak load on the power source. As the maximum supply voltage is 5.5 V, a 7805 is a good choice for providing a regulated supply voltage from an unregulated DC voltage in the range of 8 to 12 V. Take care that the light from the LED cannot fall on IC1, as otherwise the circuit will go into business on its own and constantly emit IR light, which makes it useless as remote control extender. If necessary, you can use a length of cable to connect the IR transmitter LED to the circuit board. This worked quite well with the prototype for a distance of up to 3 metres with a twisted-pair cable. Even longer distances are probably possible. i-TRIXX collection 11 (Dr. Thomas Scherer ; Germany) You may have considered using a server to store photos which can be shared with family and friends on the Internet or maybe you would prefer to host pictures of your eBay sale items on a home server for ultimate control. All of this can be achieved with a dedicated PC (or server) but it needs to be running 24/7 which is quite wasteful and not at all eco-friendly. On top of this, to allow access it is necessary to open ports in the PC and router firewalls and this can compromise system security. A much better solution is to build this small, neat and silent internet server which consumes just 2 W and can be bought cheaply. The eco-server can be built into the case shown. It looks like a Mac mini but is in fact a Network Attached Storage enclosure with space for a 2.5 " hard drive. Googling "Landisk Mac mini" should bring up a supplier (mostly European). A USB port also allows it to be used as an external drive. The item can be found at on-line auction sites where it usually retails for less than 50 euros. You get quite a lot for your money! fm mm COMPACT FLASH A 4 In addition to the mini fan and switch there are two LEDs indicating network activity and a socket for the efficient 12 V (switched mode) mains adapter input. There are connectors for the USB 2.0 and 10/100 Mbit Ethernet LAN also on the rear of the unit. In addition to its function as a USB hard drive it also contains a complete Linux PC with integrated server software including SMB for windows using the FTP necessary for Internet communications. All Administration including set-up and security configuration are performed via the integrated web site. At this price you really could not build a Linux PC yourself from scratch. The power cables and IDE ribbon cable connector are shown in the photo above. The complete micro-PC uses just 150 mA at 12 V. To keep the power demands to an absolute minimum we are going completely solid-state and using a CF to IDE adaptor which allows a Compact Flash card to be fitted in place of the hard drive. Without the hard drive the fan is not required and can be disconnected. You will now need a cable to connect the CF adapter to the IDE connector; this can also be purchased for less than 10 euros. The power connector on the adapter card is the same as that used by floppy disk drives so it is necessary to make a small adapter cable. Unfortunately the IDE connector on some CF adapter cards is female (unlike a true hard disk which has a male connector) so it is necessary to either buy a suitable IDE extension cable or make your own gender changer using two male 40- pin connectors and a short length of ribbon cable as shown below. In this application the speed rating of the CF card is not critical, the 4 GB 40x card used here is fast enough and can be bought for less than 10 euros. Total power consumption for the complete mini-server is just 170 mA at 12 V = 2 W! A peek inside the case shows how it is all arranged. The finished mini-server can just be tucked away on a convenient shelf, without a fan it runs silently. Files can be transferred to and from the card locally over SNB. Open port 21 in the router's firewall to the server's IP address. The server can be assigned a fixed IP address in the same address range (scope) as the router (e.g. 192.168.1.100 when the router itself has the address 192.168.1.1) and disable DHCP on the server set-up. The server has a maximum data rate of around 3.5 MB/s. Below is a screenshot of the integrated website user interface. The eco-server is also inherently very secure; all of the software is stored in flash ROM which is relatively immune from attacks by marauding cyber vandals. CB PREMIUM IP Config Mairfle nance smu seruer FTP Seruer Disk Utility MunlfflcdfEon Host Mart e Group Name SERVER TEST 3 Administrator admin i 1 [Li. i- j DiteTTm* 22-36:36 GMT1 ft. ! ,1 l‘ !' j F MAC Address DHCP 192 1SSJQ 100 6a b314:QQ:3b dQ OH • ENABLE O DISABLE ftnz aft nnsv rnrn k t innware 1 Fir mware Ver . NAS-BASIC^? . LC A[ ER 6&D OisVlD Frfti SiE* Tolsl Size |Master| CF 4G8 3631 ME3 free 3871 MB Parking sensor (also for men...) Design: Thomas Scarborough (South Africa) Apparently there is scientific evidence suggesting that women are at a disadvantage when it comes to carrying out tasks that require a high level of spatial ability [1]. This would seem to support the cliche long held by many chauvinistic men that women will never be any good at parking their car. There are however just as many studies that refute these findings so it is not scientifically justifiable for any open-minded person to base their attitudes on the conclusions of just one study, no matter how sure they may be of its findings. Recently one of our colleagues here Pere Kersemakers the editor in charge of i-Trixx, himself a confident car driver, made a complete hash trying to park his car on the street between two other cars. He came away with more than just a dent to his pride. Needless to say, just across the road seated in front of a pub were some young women enjoying a quiet drink. His feeble excuse at the time was that although men are normally better than women at doing some jobs they can easily get distracted... It looks like even experts might sometimes benefit from the assistance of an electronic parking sensor if only to help keep their minds focussed. According to recent research it has been shown that a large majority of the species ' homo electronicus' carry both X and Y chromosomes i.e. they are male. With this in mind we added the bracketed comment in the title. It was thought that otherwise the majority of readers may, after a cursory glance at the article's title, simply dismiss the article thinking that they personally could not possibly find a need for it. The truth is that many carmakers are now offering parking sensors as expensive accessories for their new models and anyway even if you do not want to use one yourself why not build one for someone you know who will find it useful? Thomas Scarborough from South Africa has developed this very simple but useful active SONAR circuit. Using just five components it should only take a few hours to build the unit and fit to a vehicle. SONAR (SOund, Navigation And Ranging) is a technique which uses sound propagation to detect obstacles, communicate or make measurements. The system is particularly effective underwater where it is used to make depth measurements, detect other vessels or locate fish shoals. Above the water ships also use the technique to detect obstacles in low visibility conditions. Historically the first complete sonar system was the result of collaborative work by scientists of several nations and after the Titanic disaster in 1912 there was a need for ships to be fitted with systems which could detect icebergs. Without SONAR the remains of the Titanic would not have been discovered in 1985. The parking sensor described here works on the active SONAR principle. The circuit can detect obstacles within a range of around 1 m. The unit does not necessarily need to be fitted in a car bumper it can also be mounted on the end wall of a garage where it will indicate during parking when the car is close to the wall. The operating principle is so simple that you have to wonder why it hasn't been done before. In the same way that a feedback howl occurs when a PA system is not set up correctly so that sound from the speakers bounces around the room, gets picked up by the microphone and amplified. This circuit relies on the feedback produced when a sound reflecting surface (a wall or another car) bounces the sound from X2 to XI. The only 1C used is the LM380N (IC1) power opamp which has a fixed gain of 50. The piezo sounder X2 emits the signal amplified by IC1 consisting of background noise picked up by On-Off 2 B1 12V 6 XI Piezo Sounder X2 Jj 1 Piezo s Sounder the sounder XI. Without a reflector the sound energy picked up by XI is not sufficient to initiate feedback but when a reflective surface is brought closer to XI and X2 some part of the signal will be amplified with a gain greater than unity. The resulting feedback signal occurs at the resonant frequency of the two transducers and is in the low kilohertz band. The separation distance does not have too much influence on the resonant frequency. The tone is quite loud because peak sound pressure is achieved at resonance. For this application it is important to use simple piezo sounders for X1/X2 and not the type which have built-in electronics to make them buzz. These are normally used to output sounds but as this circuit shows they can also be used to detect them. Make sure both transducers are the same type so that their resonant frequencies are as close as possible to get good sonar effect. Cl increases the coupling from output to input making the circuit more sensitive. C2 provides AC coupling to X2. Using simple piezo transducers like those shown the circuit has a range of around 1 m. This can be doubled if more expensive piezo tweeters are used in place of XI and X2. The entire circuit can be fitted onto a small piece of perforated prototyping board. The value of 470 pF for Cl is about optimal for most applications. XI and X2 should be mounted about 1 m apart, both facing in the same direction. Without Cl the circuit is much less sensitive so XI and X2 can be mounted closer, with a separation of just a few centimetres. The detection range will now be from 1 to 10 cm. With one circuit mounted on the left and another on the right rear of the car you now have a useful parking aid. Try experimenting with Cl to achieve optimal range for your application. The circuit takes around 12 mA so if the unit is fixed on the rear wall of your garage it will need a mains adapter. In constant use a set of batteries only last a few days so it would not be economically or ecologically wise to power the unit in this way. Transducers XI and X2 could also be positioned by a door to announce arrivals or could be used to announce 'close the door after you'. It can also serve as an alarm to protect the contents of cupboards or cabinets. With XI and X2 fitted underneath expensive equipment like for example a laptop, it will let out an alarm beep when the equipment is lifted up. Internet Link [1] http://news.bbc.co.Uk/1 /hi/health/42021 99. stm i-TRIXX collection 13 mR\m LED bicycle lamp How would you feel if you had just bought a shiny new bicycle with an 'afterglow' rear lamp, hub dynamo, and all the mod cons, only to have the halogen bulb of the front lamp burn out after just a few kilometres? Annoyance? That's exactly what happened to the author when he went for his first night-time ride with his new two-wheeler. Naturally, he wasn't keen to repeat this experience, so simply buying a new bulb (plus a spare) the next day was not a viable option. Why couldn't the lamp be fitted with a power LED? Then he could count on 20,000 kilometres without any lamp replacement. the radiation angle of a bare LED is too wide (more than 120 degrees), and a LED cannot use the existing lamp reflector effectively. Optics with a beam angle of 20 to 30 degrees are suitable for this purpose. The author had never imagined that a little 2.4-W halogen bulb would not last even one hour on the bike. From a technical perspective, this has to do with what is called the 'bathtub curve': most components fail either right away or after a long time. So it was probably just bad luck - or perhaps not? Maybe the hub dynamo was the culprit. This was his first experience with such a high-tech generator on a bike. As we all know, there's nobody faster on the draw with a screwdriver than an electronics hobbyist, so already the next morning his bicycle lamp lay in pieces on the kitchen table. He discovered that in addition to the switch, it contained a pair of 6.5-V zener diodes wired in reverse parallel to protect the bulb against excess voltage. No problem then - just bad luck. However, you need more than just a LED and the optics. A dynamo supplies roughly 6 V AC at a rated power of 3 W, which isn't the right match. LEDs need DC, so a rectifier must be fitted upstream. The typical voltage across a Luxeon 3-W LED operating at its rated current of 700 mA is 3.7 V, which isn't the best fit to the 6 V / 0.5 A rating of the dynamo. A bridge rectifier always has two diode junctions in series, so the voltage across the LED plus the rectifier is around 5.2 V. A 1.2-0 / 2 W series resistor for current limiting adds another 0.84 V at a peak current of approximately 0.7 A (even a hub dynamo can't deliver more than this). With this load, the dynamo output thus needs to be slightly more than 6 V. The LED can handle current pulses as high as 1 A. Installation: It is usually necessary to cut a piece off the Still, he decided that from then on an incandescent lamp had back of the reflector to make room for the LED optics. The no place on such a fancy bike, so it was out of the question. author filled the space between the reflector and the optics His resolve was firm: a LED had to go in. with heat-melt glue. This makes a bombproof joint with the Compared with a glowing coil of wire inside a glass bulb, a reflector. To improve heat dissipation, the small aluminium LED has the advantage that it not only has a longer useful life and a more constant brightness over its useful life, buf also that modern LEDs actually have higher light efficiency than incandescent bulbs. The choice was thus not difficult: a LED means more light and end to bulb replacement. Fortunately, power LEDs rated at 3 W and suitable for this application have been available for some time now^With 1-watt types, you're more likely to end up with a hazy glow than with a real light. The next step was to ordqr a 3-watt LED and associated optics. Optics are necessary because ^ plate of the LED was bolted to a slightly larger aluminium plate with an edge length of around 4 cm. Four holes were drilled in the latter plate to receive the plastic posts at the rear of the LED optics. After the plate is fitted over the posts, the protruding ends can be pressed down with a hot soldering iron to fix the LED in place. Now you only have to find a place for the small, round bridge rectifier and resistor in the lamp housing, and you're all set. Postscript: Due to the imperfect match, this sort of arrangement with a 3-W LED is not much brighter than a lamp with a halogen bulb. Another issue is that the traffic regulations in some countries (guess where...) are so strict that this sort of DIY modification is simply not allowed. However, you usually won't be ticketed for this, since a decently bright lamp is always better than a burnt-out bulb 14 i-TRIXX collection Theremin Ts Alive and Well Design: Thomas Scarborough (South Africa) Leon Theremin (or as he was christened. Lev Sergeivitch Termen), a Russian inventor, left the ranks of the living in 1993, but the electronic musical instrument that he invented in 1919 and which bears his name has made him nearly immortal [1]. Here we describe a modern version of this instrument, which is played without touching it and has an almost mystical aura. After an hour's worth of work with the soldering iron, you can entrance your audience with unworldly sounds. Of course, the construction of a real theremin is more complicated than the circuit described here. By using a small medium-wave AM radio as a supplementary external component, we managed to considerably reduce the number of components. This is because a theremin is essentially nothing more than a small radio transmitter whose frequency can be modified by moving your hand closer or further away, within a range of around 30 cm. This frequency change (modulation) results from the effect of capacitive coupling, and if you select the right carrier frequency it can be converted to the audible frequency range by using a suitable receiver. With a bit of practice, you can easily learn how to wave your hands and arms in the air close to the theremin in order to impress your listeners with melodies produced entirely under your control - a process that often appears like magic to spectators who aren't aware of how it works. The circuit described here has one distinct shortcoming relative to a genuine theremin, which is that it not possible to vary the loudness of the generated tones. The circuit is based on a type 4093 CMOS 1C. The prototype was built using a Motorola type MC14093BPC. Only three of its four gates are used here. The inputs of the unused gate (ICId) are tied to the supply voltage rail in order to prevent interference. The first two gates act as oscillators. Gate ICIa oscillates at approximately 3 MHz, as determined by the frequency formula f - 1 / (2.2 x R x C). In practice, the frequency of the oscillator is slightly lower than the calculated frequency. ICIb oscillates at around 100 kHz. The outputs of the two oscillators are mixed in gate ICIc. The signal from the mixing stage is responsible for the audible tone, which can be received by a radio placed next to the circuit - not only at 3 MHz, but also at several other spots on the dial. It can even be received in the short-wave band. With the circuit switched on, rotate the tuning knob of the radio until you find the setting where the signal has the maximum volume and the least interference. You should hear a constant tone from the speaker. If you now move your hand close to the sense electrode (marked 'Sensor' in the circuit diagram), your body capacitance acts in parallel to Cl to increase its effective capacitance. This changes the frequency of oscillator ICIa, and thus the frequency of the audible tone. With only a small amount of practice, you can learn to play the instrument and produce exactly the melody you want to hear. Use a short, well-soldered wire to connect the sensor to the circuit board. A piece of aluminium foil or copper-plated circuit board makes a suitable sensor. In the photo, the connection is made using the yellow alligator clip. You can use a length of coaxial cable to feed the output signal of the circuit (from the pin with the green alligator clip in the photo) to the aerial input of the AM radio used as a receiver. The screen braid of the cable must be connected to circuit ground. As radio receivers with an aerial connector for medium-wave signals have become rather scarce nowadays, you can also fit an alligator clip to the far end of the cable and secure it to the ferrite rod antenna of the receiver. The Theremin circuit can also be used for non-musical purposes, such as a person detector or theft alarm. If you use a large piece of aluminium foil as a sensor and place it under the doormat, the arrival of a visitor will be signalled by a change in the pitch of the tone. Naturally, you could also use a metallic door knocker as the sensor. 4 4 j J If an object that you want to protect against theft is placed on top of the sensor foil, it effectively becomes part of the sensor. This means that the pitch of the tone will change if the object is removed. Here the actual sensor can be concealed by a non-conductive object, such as a tablecloth, a book, or the like. The circuit can be powered by a battery or a (non-stabilised) 12-V AC mains adapter, and it draws only a few milliamperes. i-TRIXX collection USB 230 V Input Does this sound familiar: your PC is switched off, but the monitor, speakers and so on are still consuming power because you forgot to switch off the peripheral devices? Of course, switched socket strips are available, but they aren't the most attractive desk accessories and you can't reach the switch if the strip is located under your desk. Or you may simply forget to switch it off. A better and more convenient solution is a master/slave socket that supplies power to the 'slaves' (peripheral devices) only when the 'master' (PC) is drawing power. However, getting the sensitivity setting right is often difficult with such a device when it is used with a PC. For a master/slave socket to work properly, it must sense the current drawn by the master and switch the power to the peripheral devices on or off when the current rises above or drops below a certain value. In addition to being convenient, this can be quite useful. For example, if power-hungry devices (such as a RAID system with a large number of disk drives and a beefy power supply) are switched on at the same time as a high-performance PC (which nowadays may feature an incredible 1-kW power supply), you run the risk of blowing a fuse or tripping an MCB. If the peripheral devices are switched as slaves, there is a time delay because the circuit takes a while to respond. This is a very nice 'side effect'. Unfortunately, this approach does not always work reliably with a PC, because modern PCs are (unfortunately) not switched on with a proper mains switch. Instead, a button triggers a circuit that in turn enables the power stage of the power supply. Switching off the PC via 'Start' a'Turn Off Computer' is now common practice. As a result, the PC has at least three operating states with regard to power consumption: (a) normal operation, (b) various sleep states, and (c) switched off - although it still draws current in the 'off' state. The circuitry of the socket strip cannot always clearly distinguish the various states, with the result that the slave devices are sometimes switched off and on in rapid succession. In addition to being bad for the peripheral devices, this can cause premature contact wear in the relay usually fitted in the socket strip. However, help is at hand: with only four electronic components, you can build a simple and reliable USB- controlled socket strip as shown in the schematic diagram. As you can see, all you need is a resistor, an LED (optionally red), and a solid-state relay (also called an electronic relay). IC1 can handle up to 8 A if fitted on a heat sink, which USB -controlled mains socket Dr Thomas Scherer (Germany) corresponds to nearly 2 kW at 230 V. As you rarely need this much power, the circuit is fitted with a 3.15-A (slow-acting) fuse FI. Here's how it works: when the PC is on, +5 V is present on the USB ports. Consequently, a current flows through R1, LED D1 and the control input of IC1. Although a control current of 8 mA is sufficient, to be on the safe side the current is set to 13 mA here by resistor R1 (150 Cl). Please note that this minimum-component solution is only possible with the type S202S12 relay [1]. This is because it includes not only a zero-crossing detector, but also a snubber network to reduce voltage spikes during switching. Construction: This circuit operates at mains voltage, which can have fatal consequences with careless or improper work. You should never simply solder the four components together and stuff them into a box, and leaving them exposed in operation is taboo - without exception. Proceed as follows: 1. Obtain the four components. 2. Buy a small plastic case with a built-in mains plug. 3. Obtain a fuse holder for the fuse (panel-mount type). 4. It's also a good idea to use a bezel for the LED to hold it securely. 5. Take a USB cable, cut off the 'B' plug, strip back the cut end, and separate the individual conductors. 6. Take an AC socket strip (with three sockets) and cut off the plug. 7. It is advisable to use cable feedthroughs with compression fittings (cable glands) for the USB and mains cables (steps 5 and 6) to prevent the cables from being pulled loose. This is important. 230V 230V rS— i — 230V C) Ft f 1 230V i 3.15A After you have prepared all of this, fit IC1 in the mains-plug case with screws and fit the LED in a (plastic) bezel. Fit the two cable glands in holes drilled for this purpose. Now pass the two cables through the glands and clamp them firmly in place. Keep the cable lengths reasonably short. Finally, use short lengths of insulated stranded wire (thin for the LED and thick for pins 1 and 2 of IC1) to wire everything together. If it looks like the accompanying photo, you can screw on the lid of the case, insert the fuse in the fuseholder, and plug the case into a mains socket. LED IC1 - I % € SIOJSIJ If nothing pops (no explosion) and you don't see any smoke, use a mains tester to check the USB plug. If nothing lights up with either of the outer contacts, you can risk inserting the plug in your PC. If the red LED lights up when the PC is switched on, you have apparently done everything right and you can plug the power cables of the monitor and other peripherals into the slave sockets. With a 3.15-A fuse, you can easily handle a slave device load of up to x 500 watts. Slava Cabfe Link:[1] sharp-world.com/products/device/ lineup/data/pdf/datasheet/sl 02s12_e.pdf Electronic cat s ey Design: Thomas Scarborough The eyes of almost all members of the cat family are much more sensitive at night than the human eye. At low light levels, cats not only see approximately twice as well as we do, but also notice practically every movement in their field of view - as many a small grey rodent has learned to its regret. This means that in theory a cat would make an excellent watchdog if (and there's the rub) the species Felix catus actually had any interest in intruders. If you use an electronic cat's eye as an intrusion detector, you can leave your feli&e companion to its favourite occupation (mousing). When the author decided to develop an 'electronic cat's eye', what he had had in mind was a light sensor that was as simple and sensitive as possible. His 'all-seeing eye' is a passive sensor that detects changes in brightness. This means that even this sensor is blind in full darkness, so it needs an auxiliary light source for proper operation. However, the circuit works very well in a very dim environment. As it responds to changes in brightness, the e-eye is well suited to detecting cars passing a driveway entrance or recognising cautious intruders who avoid using a pocket-lamp and work by the light of a street lamp. If the circuit is adjusted to for maximum sensitivity, the e-eye will respond to the interruption of a light beam in the same way as a conventional light barrier and can be used to secure a range of approximately 10 m. The basic sensor element is R5, a light-dependent resistor (LDR) with type number A 9060. If you fit the LDR in a piece of blackened tube (see photo), the circuit can detect shadows on a white wall at a distance of 2 metres. The range can be increased considerably by adding a collecting lens with a focal length corresponding to the distance to the LDR. v The circuit uses the CMOS version (TLC555) of the 555 timer 1C as a threshold detector. The 1C is wired as monostable multivibrator. When it is triggered by a signal on pin 2, it supplies a single positive pulse on pin 3. The pulse width is determined by R3 and C4 from t = 1.1 x R3 x C4 = 1.1 x 47k x lOOp = 5.2 s The pulse is triggered when the voltage on pin 2 drops below one-third of the supply voltage. Operation: The current through the illuminated LDR produces a voltage across R1. If less light falls on the LDR, the current decreases and the voltage across R1 drops. The change in the voltage across R1 is differentiated by the combination of C2, PI and R4, with the result that only relatively fast changes in light level (and thus the voltage) reach the trigger input. The sensitivity, or in other words the amount of variation in the light level necessary to trigger a pulse, can be set with PI. The sensor thus responds to motion, as does a cat's eye, and it ignores slow changes in light level due to clouds, dawn or dusk. Stable operation is ensured by the combination of Cl, T1, R2 and C3. When the monostable is triggered, the positive output pulse drives T1 and D1 into conduction. Pin 2 is thus connected to the supply voltage to prevent detection of further light fluctuations. Due to the slow discharge of Cl, IC1 remains blocked for around 0.1 second longer than the duration of the output pulse. These four components are not essential; the circuit will still work if they are omitted. The output of IC1 switches the DMOS power FET T2, which in turn can drive a load. T2 can switch a current of up to 1 A at 12 V without a supplementary heat sink. The maximum current with a suitable heat sink is 5 A. You can adjust the circuit for maximum sensitivity by rotating PI until IC1 just stops being triggered automatically. R4 prevents shorting of the supply voltage via T1 when the wiper of PI is at ground. The quiescent current consumption is approximately 0.5 mA under dark conditions. It rises to as much as 2.5 mA under bright conditions. You can experiment with different values for Cl and R1 to see how they affect the behaviour of the circuit. To prevent triggering of the circuit immediately when it is switched on, you can connect the Reset input (pin 4) to the junction of a 1000-pF capacitor connected to ground and a 100-kn resistor connected to +12 V. i-TRIXX collection 17 Code lock r Design: Rob Reilink (The Netherlands) There always seemed to be a point in old thriller movies when the camera zoomed in on beads of sweat forming on the safe cracker's face as he strains to hear through a stethoscope the sound of tumblers falling while twiddling the dial on a safe. Nowadays it's a bit more sophisticated; the scoundrel reaches into his tool bag takes out what could be a prototype breadboard that you may find lying on a bench in the Elektor labs. He attaches it to the lock mechanism, presses a few buttons, lights flash accompanied by some bleeps that you would expect such a device to make and bingo, the door to the bullion vault swings open. Others fictional characters use a 'sonic screwdriver' to gain entry or escape from marauding aliens. From a safety point of view if the code lock is used for entry/exit control it is essential to provide an alternative means of escape for use in the event of a fire. The electronic level of protection is quite good but as you will appreciate the security of any code lock system is also a function of the robustness of the key pad and how firmly it is mounted. Sturdy mechanical locks are still widely in use for security purposes but ever more electronics-based systems are appearing on the market. The most familiar electronic security system is the door entry device where a code sequence is entered using a numeric keypad. Rob Reilink's circuit suggestion shown here performs this job admirably while using very few components. The circuit is built around the CMOS 10-stage Johnson counter type 4017. With this device only one of the ten outputs (0 to 9) is ever high. In this application it is configured to count on the falling clock edges. At reset only output 1 is high and with each falling clock edge the high is transferred to the next o/p. When it reaches 9 the next active clock edge transfers it back to 0 and the process repeats. It is important to make sure that you have the right type of keypad for this circuit; do not use the type that are commonly used for calculators or telephones where the keys are wired as a matrix, instead you need one where all the keys have GND GND 070397-11 one common connection. A keypad can be made up using discrete pushbuttons wired according to the circuit diagram or it may be possible to modify the wiring of a matrix type keypad. There is practically no limit to the number of keys allowed on the keypad, in fact the more keys you have the longer it would take to find the correct code by entering every possible combination. The code sequence can be up to six numbers long or if you are not too bothered about security it can be just a single number. The unlock code is determined by the keypad wiring. The common connection to all the keys is wired to COMM. The unlock sequence shown in the circuit diagram is 1234. The first number key in the code is wired to output 0 (pin 3) of U1 . The second code number key is wired to output 1 (pin 2) of U1 etc. When all the code keys have been wired up the next output pin of U1 provides the 'OUT EN' signal. In the circuit the fifth output from U1 is used to provide the 'OUT EN' signal. All other keys are wired to ground. Operation of the circuit begins after a reset (pressing any non-code key) output 0 of U1 will go high. Transistor Q1 will be conducting because of the forward bias at its base provided by R3 and R1. The reset input of U1 (pin 15) is held low (inactive). The voltage level at the clock input of U1 (pin 13) is around 0.6 V which is interpreted as a digital 'O'. When the first key in the sequence is pressed the COMM signal will go high providing a rising clock edge on pin 13, when the key is released the falling clock edge causes the counter to advance so that now only output 1 (pin2) is high. This process is repeated for the entire code sequence. When the last key is released the 'OUT EN' will go high indicating a correct code sequence and switches transistor Q2 into conduction which pulls the OUT signal low. A relay or similar electrical device can be connected between OUT and V cc the maximum current supplied here is approximately 100 mA. Any incorrect key pressed will put a low on the COMM line and turn off Q1, generating a reset of the whole chip. The code sequence must now be entered from the beginning again. It is possible to make your own PCB using the layout shown here (see the Elektor website for more information on this design) when the images have been transferred to transparent film check that the overall dimensions of the track side measure 40.6 x 29.2 mm. The circuit can be powered with a voltage in the range of 3 to 15 V. The circuit takes a quiescent current of around 30 pA at 3 V. Two standard AA batteries should be capable of powering the circuit for over a year. When the batteries go flat or the mains power fails (when powered by a mains adapter) the code lock will remain locked. 18 i-TRIXX collection grey zone between the high and low levels, since such voltages can have unpredictable effects on the behaviour of the 1C, and in the worst case they can lead to the destruction of the 1C. By contrast, Schmitt triggers do not have an undefined input voltage range, and the voltage ranges corresponding to the high and low input levels actually overlap. Design: Thomas Scarborough (South Africa) One of the many good features of electronic circuits is their reliability. When you switch on your television set, you expect to see a picture appear on the screen a short time later. If the screen remains dark, you can rightfully assume that there's something wrong somewhere. This predictability even extends to the behaviour of DIY circuits and their components, as can be seen from the explosion and cloud of smoke that usually occur if you accidentally connect an electrolytic capacitor the wrong way round. To put it briefly, we could say that it's almost impossible to build a circuit whose behaviour cannot be predicted - but is this really true? To give an example, you can quickly and easily put together a circuit that uses astable multivibrators (AMVs) to drive blinking LEDs. A characteristic feature of all such circuits is that the LEDs blink at regular intervals. However, it would be much more amusing to cause a LED to blink in a purely random manner, so that its behaviour would not be predictable. The circuit shown here uses three AMVs built around Schmitt- trigger inverters (ICIa, ICIb. and ICIc), each of which is followed by a buffer (ICId, ICIe, and ICIf). To understand how this works, first assume that the output of inverter 1 is presently high. In this case, capacitor C2 at its input will be charged via the resistor (R1) connected between the output and the input. After a certain length of time, the voltage on the capacitor will reach a level that causes the inverter to change state, and the output will switch to the low level. Now the capacitor will be discharged via the resistor until the inverter changes state again, after which the process will start again from the beginning. This sequence will be repeated endlessly, or at least until the battery is used up. The time interval between the state changes depends on the values of capacitor Cl and resistor R1. You should note that this sort of oscillator design only works properly with a Schmitt trigger. Normal inverters (and normal logic gates) cannot tolerate 'undefined' input voltages in the 'N The only task of the buffers here is to decouple the three multivibrators from the components on the right-hand side of the schematic drawing. As a capacitor cannot pass a DC voltage, capacitors C5-C7 are used to convert the rising edges of the buffer outputs into voltage pulses that cause the LED to blink briefly but brightly. This keeps the current consumption within bounds, since it primarily consists of the brief current pulses that flow when the LED blinks. Diodes D2, D4 and D6 collectively implement a logic OR function. As a result of this arrangement, the LED blinks when it receives a voltage pulse via D2, D4 or D6. This randomness of the circuit also arises from this. Each oscillator operates at a different frequency, so the pattern of pulses at the junction of D2, D4 and D4 is constantly changing. As a result, the LED blinks in a random manner, as shown in the following diagram. Of course, the behaviour of the circuit is not truly random, so it would perhaps be better to call it a 'pseudo-random blinker'. The three oscillators always operate at the same frequencies, so the pattern of superimposed pulses from the oscillators repeats periodically after a certain length of time. However, this time interval is so long that the repetition cannot be recognised by simply observing the blinking LED. True random-number generators take advantage of unpredictable phenomena such as the thermal noise of resistors and semiconductors. This noise is so weak that strong amplification is necessary before it can be used. The circuitry necessary for this would be much more complex than the present circuit. If this circuit is powered by a 9-V battery, the average current consumption (as measured over several minutes) is approximately 0.84 mA, at least with our prototypes. The peak current through the LED is 16 mA. This means that the circuit can operate for around one month from a 600-mA battery. With a supply voltage of 12 V, the output resistance of the output transistors in the 40106 decreases, which causes the peak current through the LED to rises to approximately 28 mA. Naturally, the average current consumption of the circuit also increases accordingly. 1C 1C 0" C2 40106 ICIB T j£ mu ttV R3_ 7m2 1C1A & C4 40106 T — mu ICID j7i 40106 ICIE ErTl L < #i « f|i Lfj \ Ul mu ICIF 13 JTl 12 40106 ICu G3Y i-TRIXX collection 19 Moving -coil alarm sensor Design: Bemd Geveshausen (Germany) Moving coil meters belong to an era before the digital voltmeter (DVM) was invented. In those days all measurements were represented by a needle swinging back and forth in front of a graduated scale. Its name is descriptive; the meter consists of a coil (attached to the needle) pivoting in a magnetic field. The current to be measured passes through the coil and causes it (and the needle) to twist in the field. A little while ago the Elektor offices received this circuit idea from one of our readers. Mr Bernd Geveshausen came up with an amazingly simple and unconventional alarm idea to protect his motorcycle from theft. He offered the circuit for publication and sent this photo of his finished prototype: The circuit suggestion certainly generated some interest in the Elektor lab where we were able to dig out a few moving coil meters to test the principle. Mr Geveshausen had the idea that a moving coil meter could also be used in reverse. Many electrical transducers have properties that are reversible. In this case if the coil is physically made to turn in the magnetic field it should be possible to measure the small current induced in the coil by this movement. Mr Geveshausen explained his idea: "Mount the meter upside down so that the pointer is hanging down and add some weight to the tip of the pointer. The measured voltage output is now proportional to the acceleration through the pendulum axis experienced by the meter." In other words you shake the meter and it generates a voltage... sounds like an accelerometer! Tests carried out in the Elektor labs showed that the sensor is sensitive to any movement of the vehicle. To convert the signals from the meters to an alarm signal requires very little in the way of electronics. A photo of the prototype sent in by Mr Geveshausen is reproduced here. The result of converting it into the Elektor circuit diagram format is also printed. The additional weight pushed onto the end of the pointer is just a short length of insulation stripped from a wire. Two meters mounted at 90° to each other are used to measure movement of the bike through two axes. The meters are wired in series; all we need now is an amplifier to boost the signal produced by them. A standard 741 type of opamp together with a few components is all that is necessary. The 4.7 kfl trimmer adjusts the alarm sensitivity. When the voltage at the output of the 741 gets high enough transistor T1 (e.g. BC547B) conducts, pulling the output OC low and lighting the LED which indicates that the vibration has been detected. The diode (e.g. 1N4148) at the base of T1 protects the transistor from negative transients. A diode in series with the supply protects the circuit if the supply leads are accidentally swapped during installation. A 12 V piezo buzzer can be fitted between the open-collector OC output and the positive supply. The circuit can supply 100 mA to the load. In the same way that Mr Geveshausen made his original circuit, the complete design is small enough to be built onto a small section of perforated prototyping board. The type of moving-coil meter that can be used in this circuit is not at all critical, just make sure that any resistor wired in series with the meter is removed before the meter is used in the circuit. Old VU meters like the ones shown in the photo will be fine. The circuit draws around 2 mA and once installed in the bike it can be in continuous operation for about a month before the battery needs to be recharged. The type 741 1C can be replaced by a TL061 to reduce the operating current; this will allow the circuit to run continuously for around six months before the battery needs charging. • • iii 741 100|i 16V rnn-r^i-. 4k7 X M-® 1N4148 BC547B 0 x OC f-M-O 1N4148 A A \ 4H | 1|I 1|0. 1000|I i c T1 ) BC547B » / 3 1 z T 1N4148 ~ ' i-TRIXX collection LED Night light Design: Dr. Thomas Scherer (Germany) Some types of night light are fitted with a small 1 W fluorescent tube which provide just enough illuminati stop you bumping into things when you need to visi bathroom in the middle of the night. The unit shown h fits into a European mains outlet but similar models available in the UK and US. In continuous use you can the fluorescent tube to last for a couple of years befo packs up. Then of course it will be necessary to think a replacement. We are gradually becoming more awa the impact that our throw-away culture is having on environment, much better to recycle. The dead ni is a case in point; it can be revived with a new circuit set of LEDs to produce an improved version of the orig design which is not just ecologically sound but also r efficiently and will last much longer. The enclosure shown plugs directly into a (European Continental) mains outlet and is specifically designed to ensure that all parts of the internal circuitry are completely insulated and cannot be accidentally handled. It is important to ensure that any similar enclosure used for this circuit provides adequate insulation, mains voltage is lethal! Firstly when the old night light innards are removed make sure that the fluorescent tube is correctly disposed of and not just tossed in a bin. With the new circuit and LEDs fitted you can expect the light to last over 100,000 hrs which equates to more than 10 years continuous operation! Add to this the improved efficiency and it's clear that this design will save both money and energy. A mains transformer is normally the first essential component that you would find in any low-voltage circuit powered from the mains. The night light enclosure is however too small. Instead the circuit uses a capacitor as a sort of pre-resistor to drop the voltage. At 50 Hz the capacitor's impedance is given Z = 1 / (2n x 50 Hz x Cl) One advantage of this approach is that a capacitor represents a reeictive load to the supply while the consumer unit measures effective power. Better still; the majority of electrical equipment connected to the national grid has an inductive load, so the nightlight will go some (tiny) way to correct the power factor. An LED is essentially a diode and only allows current to flow in one direction, connect it across a low voltage AC supply and it conducts only when it is forward biased. Two LEDs connected in anti-parallel will alternately flicker quite noticeably at 50 Hz. The circuit uses the bridge rectifier Brl to give full wave rectification resulting in a much less noticeable 100 Hz flicker. Capacitor C2 performs two functions: firstly it acts as a reservoir capacitor to smooth out the voltage peaks so that the light from the LEDs light does not flicker and secondly it protects the LEDs by absorbing any transient voltage surge which can occur when the unit is plugged in. The worst case would be if the unit is plugged in at the point that the mains voltage is at its peak value. The circuit would suddenly have 330 V across it and across Cl, giving rise to a very high value of impulse current which could destroy the unit. R1 limits this surge to 1 A, at switch on C2 will be discharged and thus better able to absorb the voltage transient and protect the LEDs. R2 ensures that C2 is discharged before the unit is next plugged in. Resistors R3 and R4 discharge any voltage remaining on Cl before it has time to give you a 'surprise' when you handle the unit after it is unplugged from the mains socket. It is important to use two resistors in series here because the voltage rating of a typical resistor is 250 V maximum. Using a single resistor here would mean that this limit is exceeded 100 times a second. It is better to use a > 0.5 W carbon film resistor for R1; they tend to be more robust than metal film resistors when subjected to current surges. Any worries concerning the lack of brightness of the new light sources were quickly laid to rest when testing the circuit. Instead of LED1 and LED2 shown in the circuit diagram the prototype was fitted with five white high-efficiency LEDs in series, each with a 10,000 mcd rating at 25 mA. The value of capacitor Cl was chosen as 330 nF to give a current of 25 mA but the result was so bright that Cl was changed to 100 nF to reduce the current to 7 mA. Fewer LEDs or less efficient types would also reduce the brightness. The overall real power drawn by the circuit was measured at only 140 mW! One last word regarding the components; it is important to ensure that Cl is an X2 type of capacitor suitable for use at mains voltages. It should be marked with a voltage rating '250-' or higher. A DC voltage rating of 630 V (and therefore an X2 type) is also sufficient. Finally this circuit is connected to the mains, it is vital to ensure that you adhere to all safety guidelines when building and testing the circuit. i> HLEDI C2 ZH ! I 47 ^ [LED2 25 V i-TRIXX collection 21 d/T h; - iw&! i ■ Vvi>; -vii --v-' ** * « ,.■» v- It appears that '6 is the author s favourite number. In the wake of his intercom design, he has now developed a design for a code lock that also consists of six components (if you don't count the buttons). A code lock circuit should be able to do more than just release an electromechanical door latch. It must also be able to reliably prevent entry by any potential intruder who doesn't know the code - which is exactly what this circuit does. The lock releases the latch when the right pair of buttons is pressed at the same time. If any other button is pressed (here represented by button S3 in the circuit diagram), the user must wait 90 seconds before making another attempt. This makes any effort to discover the right code by trying all possible combinations a very time-consuming enterprise. For instance, you could use a 12-button keypad with all buttons except the two buttons for the desired code connected in parallel (in other words, connected as shown for S3). The fact that the right buttons must be pressed at the same time instead of in one after the other can also be regarded as a severe obstacle to unauthorised entry, since most code locks operate with sequential code entry. The circuit is based on a type 4028B CMOS decoder 1C, which is designed to convert a 4-bit binary code into a decimal value. Flowever, this function is not used in this case. The only thing that matters here is that a '1' is present at the O 0 output (pin 3) when a '0' level is present on all four inputs (A-D). When this happens, power MOSFET TR1 conducts and the electromechanical latch is energised to open the door. Design: Thomas Scarborough (South Africa) be well advised to bring along a tent and sleeping bag ;- ) . Although using a higher capacitance value may increase security, it also has drawbacks - especially if the legitimate user accidentally presses the wrong button. As already mentioned, you can use a 12-button keypad for code entry. Select two buttons of your choice for the code and wire them as shown for SI and S2 in the schematic diagram. Now the latch will not open unless these two buttons are pressed at the same time. Connect the rest of the buttons in parallel and wire them as shown for S3 in the diagram. Note that many keypads have one contact of each of the buttons connected in to a common terminal. This sort of connection does not present a problem for the 'wrong' (S3) buttons, since they must anyhow be connected together. Flowever, if SI and S2 are also connected to this common terminal, the connection to the rest of the buttons (represented by S3) must be broken, as otherwise the supply voltage will be short-circuited. In most cases, the connection can be broken by simply scraping away the appropriate tracks on the printed circuit board. The C input is tied to ground ('0' level), state the D input is held in the '0' state order to open the door, the user must put inputs A and B in the '0' state as well by pressing buttons SI and S2 simultaneously. If an incorrect button (S3) is pressed, input D is put in the '1' state, which prevents opening of the latch (a single '1' is all that is necessary for this). After this happens, capacitor Cl discharges slowly via R3 and prevents the circuit from responding to any further key presses for the next 90 seconds. If you wish, you can increase the degree of protection against potential code breakers even further by changing the value of Cl. For instance, if the value of Cl is raised to 1000 pF a potential intruder would and in the quiescent by resistor R3. In The power MOSFET can easily handle a power level up to 10 watts. For levels higher than this (up to 43 W), it must be mounted (with insulation) on a heat sink. The choice of mains-powered or battery-powered operation depends on the specific situation. The circuit draws almost no current in the quiescent state, so battery-powered operation is certainly possible. Flowever, the battery must be large enough to supply the high short-term current that flows when the code lock actuates the latch solenoid. Does this mean that mains-powered operation is better in case of frequent use? Perhaps, but you should also consider what happens when there is power failure. 22 i-TRIXX collection LED Blinker Design: Thomas Scarborough (South Africa) A light draws attention, and two lights draw even more attention. If they also blink or move, you can hardly miss them. This principle has long since proven its worth in the professional spheres of road and air traffic, and it can be put to good use in the private sphere of model building as well. Why shouldn't you build a model airplane with attention- getting lighting? The simple circuit described here can cause two LEDs to blink alternately at an interval of approximately 1 second. The circuit consists of a type 4093 CMOS 1C and a few peripheral components. This 1C contains four NAND gates, of which only two are needed here. To avoid generating interference, the inputs of the two unused gates (ICIc and ICId) are connected to the supply voltage line. The operation of the circuit is quite simple. NAND gate ICIa and its associated circuitry form an oscillator. It operates at a frequency of 1 Hz and drives the second gate (ICIb), which acts as a buffer. The output of the second gate is connected to LEDs D1 and D2 via capacitors Cl and C3. When the buffer output level changes from low to high, a charging current flows thorough C3 and causes LED D2 to light up briefly. The capacitor is charged fairly quickly because the current is only limited by the maximum output current of the gate. This results in a short current pulse, which causes the LED to emit a brief flash of light. The output level subsequently switches from high back to low, which causes C2 to charge quickly in the same manner, with the result that LED D1 flashes in the same way as D2. The net result is that the two LEDs blink alternately. Capacitors C2 and C3 are discharged via diodes D3 and D4, respectively. These diodes also protect the LEDs against excessive reverse voltages. The circuit can be operated from a battery with a voltage of 6 to 12 V, and it draws around 1 mA of current. If necessary, the current-limiting resistor R1 can be replaced by a wire link. In this case the current consumption will increase to 2 mA. If the blink interval is too long, the blinking rate can be increased by reducing the value of Cl. If you want to fit even more blinking LEDs in your model airplane, you can use the surplus gates (ICIc and ICId) for this purpose. In this case, both inputs of each gate must be connected to point 'A' (the output of gate ICIb). Connect a network of the same type as the one shown connected to point 'A' in the schematic to the output of each of additional gates. R1 must be omitted in this case. IC1=MC14093BCP Ultra K A4M1M I A ItDHE Movies Pictures Music Record In an on-the-go world where devices are wireless and communication is mobile, you’re always plugged in — even when you're not. See the latest in-vehicle and wireless technologies, plus an astounding array of portable content, at the 2009 International CES® If there's only one show on your Smartphone, make it CES. It's the trade-only event that drives the digital economy. Register now at CESweb.org. THURSDAY-SUNDAY LAS VEGAS, NEVADA www.CESweb.orq 2009 International PRODUCED BY WHERE ENTERTAINMENT, TECHNOLOGY AND BUSINESS CONVERGE f I* Br" klESiFjU VISA Quasar Electronics Limited PO Box 6935, Bishops Stortford CM23 4WP, United Kingdom Tel: 08717 177168 Fax: 07092 203496 E-mail: sales@quasarelectronics.com Web: www.QuasarElectronics.com EMM M K-. wPm m Mr All prices INCLUDE 17.5% VAT. Postage & Packing Options (Up to 2Kg gross weight): UK Standard 3-7 Day Delivery - £3.95; UK Main and Next Day Delivery - £8.95; Europe (EU) - £6.95; Rest of World - £9.^5 (up to 0.5Kg). lOrder online for reduced price UK Postac e! Payment We accept all major credit/debit cards. Make cheques/PO’s payable to Quasar Electronics. Call now for our FREE CATALOGUE with details of over 300 kits, projects, modules and publications. Discounts for bulk quantities. Credit Card a EUROCARC3 MasteiCant © SOLO SWITCH ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ iMr HjiLHo! Ho!|€hristmas 2008 i§ron it's wa§ T+ 1 . M ^ >3 UT DON'T J £ s have some fantastic gilt:|deas for young (and old) enquiring minds ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ ?)< K Electron lie Project 1 Labs An electronics ; course in a box! All a: ssume no previous knov /ledge and require N 0 solder. See website f details ar full 30 in ONE -£16.95 Order Code EPL030KT 130 in ONE -£39.95 Order Code EPL130KT 300 in ONE -£59.95 Order Code EPL300KT 500 in ONE -£149.95 Order Code EPL500KT Robot Sensor - £19.95 Order Code EPLR20KT Digital Recording Laboratory - £29.95 Order Code EPLDRKT AM-FM Radio Kit -£6.95 Order Code ERKAFKT Short Wave Kit - £6.95 Order Code ERKSWKT Crystal Radio Kit - £6.95 Order Code ERKCKT Electronic Bell -£8.95 Order Code EAKEBKT Electronic Motor - £8.95 Order Code EAKEMKT Generator - £8.95 Order Code EAKEGKT Room Alarm - £4.95 Order Code EAKRAKT Hand Held Metal Detector - £7.95 Order Code ELMDX7 Metal Detector - £7.95 Order Code ELMDKT Robot & Con- struction Kits Future engineers can learn about the opera- tion of electronics, robotics and transmis- sions systems. Trainmech — £12.95 Order Code C21-606KT See our website for even more great gift ideas! Tyrannomech -£12.95 Order Code C21-601KT Musical LED Jingle Bells -£17.95 Order Code 1176KT Flashing LED Christ- mas Tree - £5.95 Order Code VMK100KT Robomech -£12.95 Order Code C21-603KT Moon Walker - £33.95 Order Code 401 5KT Robot Arm - £54.95 Order Code 401 7KT www. QuasarElectronics. corh Secure Online Ordering Facili ies • Full Product Listing, Descriptions & Photos • Kit Documentation & Software Downloads TECHNOLOGY MICROCONTROLLERS DOT NET on a Chip Microcontroller programming using C# and Microsoft Visual Studio Jens Kiihne (Germany) The .NET ("dot-net") Framework is a powerful tool for programming PCs as it relieves the developer of much time-consuming work. The framework is now also available, in a slimmed-down form, for 32-bit microcontrollers. It allows easy programming of l 2 C, SPI, Ethernet and many other functions without the need to get to grips with the details of the hardware. What's more, a development environment is available for free! User code layer User application and libraries i Managed code Base class library layer Systemlibrariesr.NET Hardware Drawing WPF ... : Native code CLR Execution Type Garbage Built-In engine system collector functions TlnyCLR layer PAL njiii i in (Some CLR colls use Timers RAM 1/0 (IAL rtrth0UtPALl HAL Interaction with hardware and peripherals Hardware layer Device Processor 1/0 Peripherals Figure 1. Architecture of the .NET Micro Framework (HAL = Hardware Abstraction Layer, PAL = Peripheral Abstraction Layer). As computers become faster and faster and are equipped with more and more memory, programming becomes easier and easier. Few software developers bother with assem- bly code these days as most applications can be realised using higher-level programming languages. Not only does this reduce development time, it also gives the code a much greater degree of independence from the underly- ing hardware. The Microsoft .NET Framework takes software development to a new level. The source code, which can be written for example in C#, an object-oriented version of C, is first translated into an intermediate language which is independ- ent of the target hardware platform. This 'managed code' is then translated into machine language only at run-time by the so-called 'Common Language Runtime', or CLR. To this is added a wide selection of base classes which are designed to simplify almost any conceivable programming task, ranging from low-level hardware control to database interfacing and graphical output. Finally, there is an easy-to- use development environment called Visual Studio, of which the so-called 'Express Edition' is available free of charge. Early next year Elektor plans to publish a two-part hands-on series on programming PCs using .NET. Embedded .NET A .NET framework for embedded applications has been available since 2007, following Microsoft's introduction of the .NET Compact Framework for PDAs and similar devices. The .NET Micro Framework is a small and efficient .NET run-time system that can run managed code on 32-bit micro- controllers. Anyone at home with Visual Studio and per- haps with C# will now be able to use this tool and modern programming language for programming microcontrollers. Visual Basic is not currently supported, but this situation may change in the future. Compilation of source code (i.e., its translation into managed code) works in essentially the same way as for the desktop version of the .NET framework (see text box). The .NET Micro Framework does not require an underlying operating system. A slimmed-down version of the Common Language Runtime communicates directly with the hard- ware (and is therefore also known as the bootable run-time environment). The run-time environment has only modest requirements: a 32-bit processor with around 1 00 kByte of working memory is needed. A memory management unit (MMU) is not required. An alternative approach In contrast to conventional microcontroller programming, the developer no longer needs to understand the details of the hardware. The .NET Micro Framework abstracts access 70 elektor - 12/2008 r — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -i i Highlights of the .NET Micro Framework (Version 3.0) i • Modern programming language: Visual C# ■ i • Powerful and widely-used development environment: Microsoft Visual Studio 2008 ■ i • Express Edition of the development environment is free ■ i • Hardware can be treated in an object-oriented way (managed drivers) ■ 1 • Automatic memory management using garbage collection • Powerful base class library (part of the standard .NET library, plus extensions for embedded systems development) ] • Development boards available from US$ 100, with QVGA LCD panel from US$ 300, and modules from US$ 30 ] • Rapid prototyping and debugging with the aid of an extensible emulator • Live on-device debugging • Extensive hardware support: GPIO ports, serial interfaces, SPI bus, l 2 C bus, Ethernet with TCP and UDP sockets, WLAN, LCD panels, touchscreens, USB devices; USB host functions, CAN and PWM are indirectly supported via hardware manufacturers • Secure network connections using Secure Sockets Layer (SSL) • User interfaces using slimmed-down Windows Presentation Foundation classes i • File systems (for example for SD cards) ■ to hardware using its base class library and treats hard- ware components as objects. Instead of manipulating bit masks to configure hardware peripherals, the programmer can simply set the properties of an object. This approach is termed 'managed drivers'. Furthermore, the application program need not concern itself with memory organisation. A garbage collector, a familiar concept from the PC world, tidies up memory when free space is in short supply. A further advantage of this approach is that it makes porting programs between plat- forms as straightforward as possible. Although not a full operating system in itself, the Framework does provide services which would normally be provided by an operating system. Figure 1 shows the layer architec- ture of the .NET Micro Framework. Although the Framework does not depend on an underlying operating system, it can however make use of an operating system if available and take advantage of its services. The .NET Micro Framework is, however, unsuitable for real-time programming. Although it is fast, there are no guarantees of deterministic performance. The garbage col- lector alone can give rise to several milliseconds of timing jitter. Also, managed code is inevitably executed more slowly than native code. In the .NET Micro Framework all managed code is interpreted (in contrast to the PC .NET Framework, where a 'just-in-time' compiler translates man- aged code into native code prior to its first execution). Free IDE The Microsoft Visual Studio 2008 development environment is required to develop code for the .NET Micro Framework. A free 'Express Edition' for C# is available [1]. The .NET Micro Framework SDK plug-in can also be downloaded free of charge, and so it is possible to begin development without paying a penny for software [2] [3]. However, for each device with an installed .NET Micro Framework a fee is payable. This will be included in the Listing 1 : Toggling a port pin using System. Threading; using Microsoft . SPOT . Hardware ; namespace GpioOutputPortSample { public class Program { public static void Main() { OutputPort outputPort = new OutputPort (Cpu . Pin . GPIO_PinO , true); while (true) { Thread. Sleep (500) ; outputPort . Write (! outputPort . Read ()) ; //toggle port } } } } 12/2008 - elektor 71 TECHNOLOGY MICROCONTROLLERS Listing 2: Port trigger using System; using System. Threading; using Microsoft . SPOT ; using Microsoft . SPOT . Hardware ; namespace GpioInterruptPortEdgeSample { public class Program { public static void Main() { InterruptPort port = new InterruptPort (Cpu . Pin . GPI0_Pin3 , false, //no contact bounce filter Port . ResistorMode . PullDown, Port . InterruptMode . InterruptEdgeBoth) ; port . Onlnterrupt += new NativeEventHandler (port_0nlnterrupt ) ; Thread . Sleep (Timeout . Infinite) ; } private static void port_0nlnterrupt (uint port, uint state, TimeSpan time) { Debug . Print ( "Pin=" + port + " State=" + state + " Time=" + time); } } } Figure 2. An emulator in action, in this case for the Tahoe development board. Listing 3: Transmission over the serial port using System . 10 . Ports ; using System. Text; using System. Threading; namespace SerialPortWriteSample { public class Program { public static void Main() { SerialPort serialPort = new SerialPort ( "C0M1" , 9600, Parity. None) ; byte [] outBuffer = Encoding . UTF8 . GetBytes ( "Hello World ! \r\n" ) ; serialPort .Write (outBuffer, 0, outBuff er . Length) ; serialPort . Dispose ( ) ; //keeps the emulator running to see results Thread . Sleep (Timeout . Infinite) ; } } } 72 elektor - 12/2008 price when a pre-configured module is used, as the manu- facturer will already have paid the licence fee to Microsoft. For first experiments no hardware is required, however, as the SDK includes a extensible emulator. In essence this is a port of the CLR to the x86 processor, using an underlying operating system (Windows XP or Vista). Direct emulation is provided of all the hardware compo- nents supported by the .NET Micro Framework (see text box). Furthermore, hardware manufacturers offer SDKs with emulators that mimic both the the appearance and the behaviour of development boards (see Figure 2). GPIO ports, SPI devices, l 2 C devices, serial interfaces, LCD pan- els, RAMs, flash memories and many other devices can all be simulated. More about the .NET Micro Framework can be found on the Internet [2] [3] [4] [5], and in the author's book [6]. Platforms Currently the .NET Micro Framework runs on ARM7- and ARM9-compatible processors. Support for Analog Devices Blackfin processors has been announced. For application and development a number of platforms are available, which include to varying extents the range Figure 3. The Embedded Master TFT Board. Compiling for the .NET Micro Framework In .NET the compiler converts the source code into 'assemblies' (executable .EXE files and .DLL class libraries) containing code in CIL (Common Intermediate Language) and 'metadata', or self-descriptive code. The CIL code is the same, regardless of the high- level language used (C#, C++ or Visual Basic). This means that parts of a program written in C# and in Visual Basic can interop- erate without problems. At run-time the managed code is executed by the CLR (Common Language Runtime) environment, which must be installed on the target processor. The .NET Micro Framework uses a special compact version of the intermediate language to reduce ROM and RAM requirements on the target device. To this end the .NET Micro Framework metadata processor tool generates optimised 'pe-files' from the man- aged .NET assemblies. Visual Studio and the .NET Micro Framework plug-in hide all these steps from the user. Currently the .NET Micro Framework only supports Visual C#. In theory any .NET language compiler could be supported, as the metadata processor reads in ordinary .NET assemblies as generated by all the .NET compilers. In practice, however, Visual Basic still uses a special Visual Basic run-time library, which has yet to be ported to the .NET Micro Framework. of peripherals supported by the Framework. We shall look at two examples. Device Solutions [7] offers the Meridian CPU, based on a Freescale i.MXS 100 MHz ARM920T processor. It includes 8 MByte of SDRAM and 4 MByte of flash memory. The CPU module, costing US$ 75, sports an interface for a 2.7 inch QVGA LCD panel, 1 6 to 32 GPIO ports, two RS232 interfaces, SPI and l 2 C interfaces and one PWM channel. The corresponding 'Tahoe' development board, which includes all the connections, a power supply and an LCD panel, is available for US$ 400. GHI Electronics [8] offers its Embedded Master TFT Module for US$ 80 and a development board including a TFT LCD panel for US$ 350 (Figure 3). The company also has in its portfolio the smallest and lowest cost development system that runs the .NET Micro Framework (Figure 4). Priced at US$ 100, the USBizi includes a 72 MHz ARM processor, 96 kByte of RAM, 5 1 2 kByte of flash memory, an SD card slot, 44 GPIO ports (of which 35 can be con- figured to generate an interrupt), SPI, l 2 C, four TTL-com- patible serial ports, a 1 0-bit ADC and a 1 0-bit DAC, and much more. The LQFP100 chip from the same company Figure 4. The USBizi development kit. 12/2008 - elektor 73 TECHNOLOGY MICROCONTROLLERS Listing 4: Temperature sensor on the l 2 C bus (managed driver) using System; using System. Threading; using Microsoft . SPOT . Hardware ; namespace I2CTemperatureSensorSample { /// < summary > III Managed driver for the TMP100 temperature sensor chip III from Texas Instruments on the I2C bus. Ill < / summary > public class TMPlOOSensor { #region constants private const byte clockRateKHz = 59; private const byte REGISTER_Control = 0x01; //command to configure sensor private const byte REGISTER_Temperature = 0x00; //command to request result private const byte CONTROL_EnergyMode Shut down = 0x01; private const byte CONTROL_DataLengthTwelveBits = 0x6 0; private const byte CONTROL_OneShot = 0x80; //ms The maximum time needed by the sensor to convert 12 bits private const int conversionTime = 600; private const int transactionTimeout = 1000; //ms #endregion private readonly byte address; private readonly I2CDevice device; public TMPlOOSensor (byte address) { this. address = address; I2CDevice . Configuration config = new I2CDevice . Configuration (address , clockRateKHz) ; this. device = new I2CDevice (config) ; } public float Temperature ( ) { //write to one shot bit in control register to trigger measurement, //that means telling the sensor to capture the data, byte controlByte = CONTROL_OneShot J CONTROL_DataLengthTwelveBits | CONTROL_EnergyMode Shut down ; byte [] captureData = new byte [] { REGISTER_Control , controlByte }; WriteToDevice (captureData) ; //the conversion time is the maximum time //it takes the sensor to convert a physical reading to bits Thread . Sleep (conversionTime) ; //prepare the control byte to tell the sensor to send //the temperature register byte [] temperatureData = new byte [] { REGISTER_Temperature } ; WriteToDevice (temperatureData) ; //prepare the array of bytes that will hold the result //coming back from the sensor byte [] inputData = new byte [2] ; ReadFromDevice ( inputData) ; //get raw temperature register short rawTemperature = (short) (( inputData [0] << 8) | inputData [1] ) ; //convert raw temperature register to Celsius degrees //the highest 12 Bits of the 16 Bit-Signed- Integer (short) are used //one digit is 0.0625 ° Celsius, divide by 16 to shift right 4 Bits //this results in a division by 256 float temperature = rawTemperature * (1 / 256. Of); return temperature; } private void WriteToDevice (byte [] outputData) { //create an I2C write transaction to be sent to the temperature sensor I2CDevice . I2CTransaction writeXAction = device . CreateWriteTransaction (outputData) ; //the I2C data is sent here to the temperature sensor int transferred = this . device . Execute (new I2CDevice . I2CTransaction [] { writeXAction }, 74 elektor - 12/2008 transact ionTimeout ) ; //make sure the data was sent if (transferred != outputData . Length) throw new Exception ( "Could not write to device."); } private void ReadFromDevice (byte [] inputData) { //prepare a I2C read transaction to be read from the temperature sensor I2CDevice . I2CTransaction readXAction = device . CreateReadTransaction ( inputData) ; //the I2C data is received here from the temperature sensor int transferred = this . device . Execute (new I2CDevice . I2CTransaction [] { readXAction }, transact ionTimeout ) ; //make sure the data was received if (transferred != inputData . Length) throw new Exception ( "Could not read from device."); } public byte Address { get { return this . address ; } } } } is a processor with similar features, measuring 20 mm by 20 mm and costing just US$ 30. Practical examples Figure 5 shows the Microsoft Visual Studio 2008 develop- ment environment with a code window and a .NET Micro Framework application. In the project properties it is poss- ible to set where the program will be sent to for execution: choices include various installed emulators and real hard- ware connected over USB, network or serial interfaces. Our listings show how simple it is to program using the .NET Micro Framework. Anyone with a basic understand- ing of the C programming language will find the code easy to follow. Listing 1 shows how to use a managed driver to toggle a GPIO output pin every half second, for example to flash an LED. Listing 2 shows how a method can be called when a GPIO input pin changes state, for example to respond to the press of a button. It is equally straightforward to send a string of characters out over a serial port, as Listing 3 demonstrates. Receiving data is equally easy: Listing 4 shows a managed driver for a Texas Instruments TMP100 temperature sensor con- nected over the l 2 C bus. Figure 5. The Visual Studio 2008 development environment. source code for a simple web server and Internet radio using an MP3 decoder device. ( 080450 - 1 ) The GHI Electronics website [8] gives a collection of other examples (under 'Projects'), inc uding, among other things, About the author Jens Kuhner is a software developer at Vallon GmbH in Germany, working on .NET applications for the .NET Desk- top and Compact Frameworks. Jens is also the author of a recently-published book 'Expert .NET Micro Framework' (Apress, 2008). He has been interested in the .NET Micro Framework from the beginning and is an active beta tester of the technology. He also writes regular articles in the .NET Micro Framework forum. He can be contacted at kuehner@ web.de or via his blog [4]. Internet Links and References [1] Microsoft Visual Studio 2008 Express Edition for Visual C#: http://www.microsoft.com/express/product/default.aspx [2] Official .NET Micro Framework pages: http://www.microsoft. com/netmf/default.mspx [3] .NET Micro Framework team blog: http://blogs.msdn. com/ netmfteam/ [4] Author's blog: http://bloggingabout.net/blogs/jens/ [5] Jan Kucera's .NET Micro Framework pages: http://www. microframework, eu [6] Jens Kuhner, 'Expert .NET Micro Framework' (Apress, 2008), ISBN 1 -59059-973-X [7] http://www.devicesolutions.net [8] http://www.ghielectronics.com 12/2008 - elektor 75 0 PCB - S oldering .co.uk Supphers af PCB Soldering Equipment & Rework Stations Online Price £44.95 n ^ m +J ^ wi O Q S U| 9 cp en NEW IN STOCK 328 Working Platform Krr ImOitfnt j p liptiteGin - 1 P^n Hr-ar Rf-Er>Tirn Pad A I £ Pfcrnirtuil Tod 2 "■ C-J^bOf' F HOfS " M k,* Online Price £1 39,95 2HHJ 7dW S^leterEng Slalton SaldwEng Iron Tips & Air NoieIos Online Price £7435 Hoi Tweezers fi Static n 710 Infrared Welding Station Online Price £^4 95 Online Price £ 7 50,00 Testpins.co.uk SiW Im of R*c'#pfxJei 4 Prab** For Test-pins £ P/obes Visit www, Wst-pfnz, co, uk Abow G&coiiNcods *$oapi>is& www.pcb-soldering.co.uk A|lQfld*le ElflC!r^H!ltMl4 ^3 |ftdynr I = 1 To 6 0 K = I Wave Pwm la = Pwm K = I + 10 Wave Pwmlb = Pwm K = I + 20 Wave PwmOa — Pwm K = I + 30 Wave Pwm 0 b = Pwm K = I + 40 Wave Pwm2a = Pwm K = I + 50 Wave Pwm2b — Pwm Waitms 50 Next Pwm Loop Sub Wave A = 6 . 1415 * K A = A / 60 B = Sin(a) B = B + 1 B = B * B B = B * 63 Pwm = Int (b) If Pwm < 2 Then Pwm = 2 End Sub PWM signals. Timer 1 has two independent PWM output channels with a resolution of 8, 9 or 10 bits. Listing 3 shows how both channels Pwm la and Pwmlb of timer 1 can be programmed to produce output signals with 10-bit resolution. The signals are output from OC1A (PB1) and OC1B (PB2). Their electrical characteristics are the same as other port pins so you can just hang an LED together with a series current-limiting resistor on the output or connect the output to a buffer like the ULN2003 fitted to the Elektor ATM1 8 AVR board. The program produces increasing brightness signal from channel A and decreas- ing brightness signal from channel B. 78 elektor - 12/2008 LED control using six PWM channels The Me ga88 provides six PWM outputs signals. Timers 0 and 2 both offer a resolution of eight bits. The individual outputs are on the following output pins: OClAon PB1 OC1B on PB2 OCOA on PD6 OCOB on PD5 OC2A on PB3 OC2B on PD3 Figure 2. Brightness control of six outputs. In this last exercise we use all six PWM outputs, for the sake of symmetry in this application, timer 1 is configured with a resolution of only eight bits. The aim of this example (Listing 4) is to smoothly control the brightness of a row of LEDs such that a sinusoidal 'wave' of light travels along the row. A loop with 60 brightness levels per LED is sufficient to produce a smooth transition between levels. The value of variable I is used in the sub Wave to produce the light level value. It is first multiplied by 271, divided by 60 and then its sine function is found. The result in the range ±1 is then offset to the range 0 to 2. The eye's perception of bright- ness is nonlinear so to compensate, the value is squared. It now lies in the range 0 to 4 so multiplying by 63 converts to the 0 to 2 55 range (almost) of PWM values used to con- trol the LEDs. The steps at lower values of brightness are quite noticeable so the lowest possible level is limited to 2. Using this calculation and the corresponding phase shift generated in the program produces an interesting lighting effect. The overall result is a wave of brightness moving along the line of LEDs. The LEDs can be arranged in a line or as a circle. It is possible to expand the line further by adding six, twelve or more LEDs. ( 080846 - 1 ) Program downloads and forum As usual the programming examples and additional info can be downloaded from the project page at www.elektor.com/080846. We also welcome your feedback on the Elektor forum. Advertisement AmDHF- L_A MCITHE’B C Ljjt\MtL£D t ATlLJN Lfjww flnrj^-ar-SrcF' Hmv tu Blt-'lc £7*«**f D«l[£n br the 5AKJ 'S-tOy. S-TClJilriASirKrrtivm. Ain** 'I * QorrmtXtork B4t ■ f^l*njr 5X-K»t Cm*ip.rt Wr 1 ^ ^ jrnrftf mhfc l T**L 4 ■■Tooti. Bt*i«4lAllb*t! ^5,' ’ r y l rTW Fi*i Vtmf U LmtCwmS^ MS m&Tt EsFUm 1HU . '■■cLV.-jk M IIh: JlfiS Co' -rt-W* "Cibtn *-hJ Rh-e Su«#T WWW. XG ameStatio n .com FHi 5 LZjg&fi.Z-Ein] jjijr-H3Pfi@NuwVe.rigr Tel: 01 635 40347 Nii'.vhury EJi:i:l riming LIH Fm:UlKiaffil43 tamii/HMri EeikRG.14 BU) 2 in: I: clrn.iltif iii?.vh i-v.l'n^ii.i n.iik v.vjth jt ■: H t i i ryid I’xlm nl ■: s . m . i i k Many ideas one solution ^°° 3 % Contract Manufacturing & ^ 0,01 http://www.propox.com * More details available at: office@propox.com i| 8 £88 §* o XffifD ?2g ^U- El Hod l|l ZULU! oil pi * * Sj5 t3o!i mg© U;0| °o| Ozh: iss €0 UJ LUIj Q 111 12/2008 - elektor 79 MICROCONTROLLERS Michael Gaus (Germany) This module provides a simple user interface for extending microcontroller-based circuits. Graphics and text display commands can be sent to it over a serial interface, and, using its UART, the module reports back when the state of any of six inputs changes. Additional firmware can display a slideshow of images stored on an SD card. This article could equally well have been entitled ‘two for the price of one’: on the one hand the project described here is an update of a design published in Elektor in April 2007 [1]. The ‘Elec- tronic Badge’ used a low-cost display from a mobile phone to display images stored on an SD card. It used an Atmel ATmega8, and we promised a future upgrade to the ATmegal68. Here we make good that promise. We have also designed a printed circuit board to make the project even easier to build: the board can be ordered via our web- site. The ATmegal68 microcontroller is a firm favourite with Elektor staff and readers alike, and has the benefit of allowing easy debugging using the reset input. However, the story does not end there. In this project we can also cause the display to show vector graphics and text: using simple commands sent to the ATmegal68 over a serial interface we can conjure up rectangles, lines and characters on the tiny screen. In return, the microcontroller will report (asynchronously and autonomously) over the serial interface whenever any one of six inputs changes state. This allows a keyboard, joystick or other digital input device to be connected. The whole thing thus forms a universal user interface module, which is entirely controlled, perhaps from another micro- controller, over a single serial port. This relieves the main microcontroller of dealing with user interface functions; it also avoids the need to redesign inter- face hardware and software for each new project. User interface The universal user interface module has the advantage that the only con- nection required to the host microcon- troller or other circuit is a single UART (TXD and RXD lines). The interface is configured to run at 115200 baud with 8 data bits, no parity and one stop bit (‘8N1’), but this can easily be changed in the source code. A further advantage is its use of a particularly low-cost dis- play. The LM15SGFNZ07 [2] [3] is used in Siemens A60, A65, C60, MC60, M55 and S55 mobile phones and is avail- able as a spare part for well under ten pounds. The display is capable of showing graphics at a resolution of 101 by 80 pixels in 4096 colours. It takes a few simply-structured commands to the module over the UART to change foreground and background colours, show text, draw lines and rectangles and display bitmaps. This makes it easy to construct menus to control the operation of the host microcontroller or to display readings. The available commands are listed in the text box ‘Control’. After many of the commands a brief pause is required before the next com- mand can be sent. As a rule of thumb, the total delay allowed should be around 10 /js per pixel of the LCD that is updated. Commands received while the module is working will be partially or completely ignored. For this reason the user interface module sends out a one-byte status message ‘command execution complete’ over the serial interface when it is ready for the next command. The host should only send a new command when this status mes- sage has been received. Reports of the status of the inputs to the module are also eight bits long. Whenever an input changes state (for example, whenever a connected push- button is pressed or released) a sta- tus byte is output via the UART (see text box ‘Status reports’). The need for polling and debouncing of buttons is entirely avoided as a new message is automatically output on each input status change. A further feature is that if input PC0 is held low (button 1 pressed) when power is applied, the module enters a configuration menu, where it is possible, for example, to adjust the LCD contrast. Circuit At the heart of the circuit (see Figure 1) is an ATmegal68 microcontroller. The LCD is driven over an SPI bus. The protocol was determined by author Michael Gaus by analysing the data traffic in a mobile phone (and so 80 elektor - 12/2008 Figure 1. The popular ATmegal 68 lies at the heart of the circuit. 0+3V GND GND GND 080320 - 11 12/2008 - elektor 81 MICROCONTROLLERS information is provided here with- out guarantees of correctness or completeness!). The pinout of the LCD is given in the text box ‘LCD pinout’. There are solder pads on the rear of the LCD and so no spe- cial miniature connector is needed: simply solder thickish enamelled copper wire to the pads, bend the wire in a right angle and solder to the holes provided in the printed circuit board. The LCD can be fur- ther fixed to the board using a short length of double-sided adhe- sive tape: further advice can be found on the project website [4]. The circuit communicates with the outside world via two headers. K1 has ground connections as well as connections for the pushbuttons or other input devices. If pushbuttons are used, normally-open types are needed. K1 also carries the RXD and TXD signals of the serial inter- face, for example for connection to another microcontroller. The RXD (and TXD) pins of the ATmegal68 are protected by internal diodes and so 5 V levels can be used: for extra safety we have added series resistor R8. LCD Wenu EMC-sl Care and feeding ICOHiS 3 I n«W Diitamci Tsd Fnvxnloilii |pr(i 1 IhliH 1JS< K htti v*«t'! U x kg j>J ■: $* j S*i i trad :in:lnb 1 IHHH T rrd Mra b*q ft**"* IT" *■ i n-rt iftfi fro fa Jl*t ■ $ 1*1 p F r. End? Sh | If r- [fcyr 1 [J] njrm EUmv l.'J-Uf: Figure 2. This PC program can be used to send a range of graphics commands the module. to TXD and RXD are also available on pins of K4. The Elektor USB-to-TTL serial cable (5 V version) [5] can be connected directly to header K4. The FTDI FT232RQ device used in the cable has an input threshold voltage of typically 1.6 V, and so no level shifter is needed. The interface can of course be made fully RS-232 compatible with the addition of a MAX3232. Figure 3. Suggestion for a simple programmer adaptor. For testing and development it is con- venient to connect the system to a PC running a terminal emulator pro- gram. Author Michael Gaus has writ- ten a short Windows program (see Figure 2) to exercise the graphics commands. This, along with the firmware for the microcontroller, is available for free download from the project pages accompanying this article [4]. If pins 2 and 3 of JP1 (marked ‘USB’ on the printed circuit board) are shorted together the circuit will draw its power over the USB inter- face. If instead three 1.5 V cells (or a regulated mains supply deliv- ering 4 V to 5 V) are to be used, pins 1 and 2 of JP1 (marked ‘Ext’, for external power, on the board) should be shorted. External power can be connected either at K1 or via the pins marked ‘VIN’ and ‘GND’. From JP1 the supply goes to volt- age regulator IC1 which produces the 3 V operating voltage for the AVR microcontroller and the LCD. In the mobile phone the LCD is operated at 2.9 V. Diode D1 protects against reverse polarity: a Schottky type is used because of its lower forward volt- age drop. The power supply for the two LCD backlight LEDs is taken from immediately after Dl, with R3 and R4 acting a current limiting resis- tors. D2 protects the voltage reg- ulator in case a voltage should accidentally be applied to its out- put that is greater than its input voltage. The crystal is loaded by two type NPO ceramic capacitors, which have good temperature stability. Status reports Whenever the state of one of the inputs changes a byte (whose bits we label D 7 down to DO) is output by the microcontroller. The microcontroller also sends a status message when the processing of a command has been completed. The type of status message is encoded in the top two bits, D7 and D6. The coding structure is as follows. D7 D6 D5 D4 D3 D2 Dl DO Meaning 0 0 -reserved- 0 1 R R R R R 1 Command execution complete, ready for next command ('R' indicates reserved bits) 1 0 PC5 PC4 PC3 PC2 PCI PCO Sent when pushbutton input state changes. A 7 1 7 in one of the lower six bits indi- cates that the corresponding input is low (button pressed), while a 'O' means that the input is high (button released) 1 1 -reserved- 82 elektor - 12/2008 Programming An ISP-compatible programmer can be connected to connector K3. The programmer should use a voltage of between 3 V and 3.3 V to indicate a logic ‘1’: if only 5 V levels are availa- ble, a MAX3392E (or its pin-compatible bi-directional cousin, the MAX3378E) may be used as a level shifter. Fig- ure 3 shows a suitable circuit, which we have not tested. The microcontrol- ler can also be supplied with power via this circuit, pin 1 of the level shifter being connected to the termi- nal marked ‘3 V’ in the main circuit. In principle this 3 V supply could also be connected via pin 2 of K3, which is not PCB and component layout. COMPONENTS LIST Resistors R2 = 1 Oka SMD 0805 R3 / R4 / R5 / R6 / R7 = 150Q, SMD 0805 R8 = 470a SMD 0805 Capacitors Cl / C3 / C4 / C5 = lOOnF, SMD 0805 C2,C6 = 2jL/F2, SMD 0805 C7,C8 = 22pF, NP0, SMD 0805 Semiconductors Dl, D2 = MBR0520L, Schottky, SOD- 123 (Farnell # 1467521) IC1 = PQ1 T301 M2ZF> voltage regulator (LDO), 3V, 400mA, SOT-23-5 (Digikey # 425-1674-1 -ND) IC2 = AT mega 1 68-20AU, TQFP32 (Atmel) Miscellaneous LCD1 = LM1 5SGFNZ07 (see text) XI = 7. 3728MHz quartz crystal, HC-49 case K1 = 10-way SIL pinheader, lead pitch 2.54 mm K2 = SD card socket (Farnell # 9186158) K3 = 6-way (2x3) boxheader, lead pitch 2.54 mm (Farnell # 1096984) K4 = 6-way SIL pinheader, angled pins, lead pitch 2.54 mm JP1 = 3-way pinheader with jumper, lead pitch 2.54 mm PCI ,PC2,PC3 = solder pin, 1 mm diameter Enamelled copper wire, max. 0.5mm diameter PCB, ref. 080320-1 from www.thepcbshop. com Control The user interface module is controlled over a serial port and can accept commands to draw graphics and display text. The commands available are as follows. Parameter <0000rrrr> <0000rrrr> <0> cbitmap data> Notes: Meaning Set foreground colour (four bits each for red, green and blue components) Set background colour (four bits each for red, green and blue components) Draw filled rectangle between vertices (xl ,yl) and (x2,y2) Draw line from (xl ,yl ) to (x2,y2) Set text cursor position to (x,y) Print text (ASCII); zero byte marks end of string Display bitmap image in rectangle between vertices (xl ,yl ) and (x2,y2): each pixel of the bitmap consists of two bytes <0000rrrr> and < ggggbbbb>, where four bits each specify the red, green and blue components Command (hex) 01 02 03 04 05 06 07 • x-coordinates must lie in the range from 0 to 100 (00 to 64 hex). • y-coordinates must lie in the range from 0 to 79 (00 to 4F hex). • Twelve bits in total specify a colour: four bits for each of the red, green and blue components. For example, to clear the screen to blue proceed by drawing a rectangle from (0,0) to (100,79) with the desired foreground colour as follows. • Set the foreground colour to blue (red and green components set to zero, blue component to OF hex): 01 00 OF • Draw a rectangle (100 in decimal is 64 hex, 79 in decimal is 4F in hex): 03 00 00 64 4F 12/2008 - elektor 83 MICROCONTROLLERS LCD pinout Here are the connections to be made to the reverse of the LCD. Pin 1 is to the left, pin 10 to the right. Further information can be found on the Internet [2][3]. 1 LM1 5SGFNZ07 04E0541 91 9A L ■ r Pin Signal Meaning 1 1C S Chip select 2 /RESET A reset pulse is re- quired when power is applied 3 RS Register select: 0 = data, 1 = command 4 CLK Clock 5 DATA Data 6 VCC Approximately 3.0 V (2.9 V used in origi- nal mobile phone) 7 GND 8 LED1_A LED1 anode 9 LED_K LEDl and LED2 common cathode 10 LED2_A LED2 anode Specifications LCD: LM15SGFNZ07 (for example from a Siemens C60 mobile phone), 101 pixels by 80 pixels, graphics, 4096 colours, LED backlight, driven over SPI connection LCD price: available new on eBay at low cost UART interface to send graphics commands and receive status messages ^ Up to six inputs for pushbuttons or other digital input devices Supply voltage: 4 V to 5 V USB-to-TTL cable can be direct- ly connected; module can be USB-powered ^ SD card interface to display photo- graphs and graphics LCD settings menu included in firmware currently used, but some programmers allocate this pin as an extra power sup- ply, and so it cannot be used safely The SD card socket is not used when the circuit is being employed as a user inter- face module. It is connected to the micro- controller in the same way as described in the ‘Electronic Badge’ article. Badge firmware If images stored on the SD card are to be displayed on the LCD the appro- priate additional firmware needs to be downloaded into the microcontrol- ler. If PCO is held low when power is applied (by pressing button 1) a test image appears on the display, followed by a menu. A brief press of button 1 (shorter than 500 ms) advances to the next menu entry; a long press (greater than 500 ms) selects the current entry (shown with a red background). The corresponding action is carried out when the button is released. The main menu allows the user to adjust the dis- play sequence with an adjustable delay between them. The delay is specified in the file config.txt stored on the SD card. The image filenames should be at most eight characters long, followed by a dot and a three-character file extension. The bitmaps must be exactly 101 pix- els (horizontal) by 80 pixels (vertical) and the colour depth must be eight bits per channel, of which the microcon- troller uses only the most significant four bits. The card must be formatted for the FAT 16 file system and the files must not be fragmented. This can be achieved by writing all the images to the card in one go immediately after formatting it. Finally, one further important piece of advice: the card must on no account be inserted or removed while power is applied to the circuit. ( 080320 ) con- trast, to show an information screen, or to start a slideshow. The contrast should only need to be adjusted (if at all) within a small range of its default value of 43. If no button is held down when power is applied a test image is dis- played consisting of four coloured bars (white, red, green and blue) and the version string ‘Diashow VI. 1’ will briefly appear. Then the bitmap images stored on the SD card are displayed in Internet links [1 ] http://www.elektor.fr/magazines/2007/ avril/badge-electronique.81 151 .lynkx [2] http://sandiding.tripod.com/m55.html [3] http://forum.lcdinfo.com/viewtopic. php?p = 8395 [4] www.elektor.fr/080320 [5] www.elektor.fr/080213 84 elektor - 12/2008 More than meets the eye p*2£t i * J pvhv. electronics .. Temperature & Humidity Data Logger with LCD The EL-USB-2-LCD is the first EasyLog USB data logger to feature a statub display so you can check minimum, maximum and last stored readings at the touch of a button. Behind the display there gm ar^ more new features, including a rolling mode for logging and a push-to-start option to complement the -35 to +80°C & 0 to 100%RH measurement range, direct to USB connectivity, free softwbre and compact design - all for less than £60. To find outmore visit www.lasc^relectronics.com or call 01794 884567 Take out a free subscription to E-weekly now Do you want to stay up to date with electronics and computer technology? Always looking for useful hints, tips and interesting offers? Subscribe now to E-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 £ weekly t IFKXft ES-'i r-r li: bnj4il _ j own h int uJ h and ■kwc M rirft pfci^ ia i#rf l l rftm l,l *Bi rmr - ■■■ i :■ :-«■■*•: ■■a - l — i cvd b ir-'n::j. ■. ■■■ ."H dr npn ■* n,Hma jt - ’■ ra m va i Wp.'iMi 1) kin i id . ■ ■ b. J a 1. k . b .pi u I — Register today on www.elektor.com/newsletter SERVICING YOUR COMPLETE PROTOTYPE NEEDS 1 EUROCARD (160 x 100 mm) + Tooling + Photoplots , + m yd 4 * Price example Any size and contour possible! Optional: • Soldermask • Fast-turnaround • Silkscreen • 4-Layer Multilayer • 6-Layer Multilayer tfOWmOAD oW wmi Freephone Q) 0800-3898560 Tel.: +353 (0)61 701 170 Fax: +353 (0)61 701165 pcb-pool@bety^out.com qxif nnr g tnrks Simply send your files A/IA A/l/ll /•/§ AA and order ONLINE: rV 0 “ rl/l/Ll V I# Iff 12/2008 - elektor 85 TECHNOLOGY POWER SUPPLIES Electronic Transformers Their anatomy and application Dr. Thomas Scherer (Germany) Low-voltage halogen lamps have grown in popularity since their launch in the 1980s. The same timeframe has seen the development of 'electronic transformers' that are compact, lightweight and economic. What makes them tick — and what other applications can we find for them? When low-voltage halogen lamps first appeared their power supplies used conventional iron-cored transform- ers with 1 2 V AC secondaries. The same applied to those trendy suspension-wire light systems using three miniature 35-W spotlights dangling from parallel wires; the insubstan- tial airiness of these light fittings contrasted strongly with the weighty circular core of the 1 00 watt transformers that fed them. Humming hefty lumps of 1 2 V transformer did not make installation of built-in downlighters any easier either. It's little wonder therefore that the industry was forced to develop a slimmer and less weighty substitute for the time- served transformer with its bulky iron laminations and cop- per windings. So please pay respect now to the electronic transformer presented in Figure 1 . Anatomy Today of course these tiny electronic transformers are all but universal. They have become so widespread and affordable Figure 2. Inside the plastic case we find a straightforward switch-mode power supply using discrete components. Figure 3. The rear side of the printed circuit board displays a spartan appearance, with no ICs and just a handful of semiconductors. that three vital questions demand an answer: • What's actually inside these miracles of miniaturisation? • What kind of output can we expect? • What other applications could we dream up for these lit- tle gizmos? No sooner said than done — and bought and dismantled. You probably guessed: inside the plastic case is nothing more than a switch-mode power supply (SMPS). Was this blindingly obvious? Not necessarily, because a close look at the printed circuit board (PCB) in Figure 2 reveals that the electronics are less conventional than you might have guessed. Certainly we see some diodes, capacitors, an out- put transformer (right and two high-voltage power MOS- FETs (centre) more or ess where you would expect these to be. But there are two surprises: • For starters, the output does not appear to be provided with any rectification or electrolytics for smoothing. • Secondly, next to the MOSFETs you might have expected a high-voltage electrolytic for filtering the rectified mains voltage. For our first observation the obvious conclusion is that our halogen lamps must be run not on DC but on some kind of AC voltage! As far as the second is concerned, the input side of the SMPS must be supplied with a pulsating (rather than smoothed) DC voltage. Consequently we can expect the output waveform to resemble the 1 00 Hz output of a full- wave bridge rectifier, only the more so because the solitary 68 nF foil capacitor on the output of the diode bridge has far too little capacity to do a proper job of smoothing. Both dodges make sense: direct current is not essential for lamp bulbs and the absence of rectification not only improves efficiency but also save hard cash. Omitting a high-voltage electrolytic saves both cost and space on the PCB. This elegance of design is matched by the fact that not a single 1C is employed. On the rear side of the PCB (Figure 3) we discover apart from some SMD-resistors and capacitors merely three transistors and two diodes. The PCB looks a bit flimsy, being only 1 mm thick, but in fact it is made of sturdy epoxy material and not from brittle SRBP (Paxolin, Pertinax). In place of real fuses we have two thin PCB tracks drawn in zigzag fashion. The first 'what' ques- tion has now been answered. Curves The array of components used indicates that AC must appear at the output. And it's a foregone conclusion that the signal there will be in the upper kHz region. Naturally. 86 elektor - 12/2008 So you will be just as astonished as I was when I applied the 'scope to the output terminals. Figure 4 shows a rather familiar waveform: it's the standard kind of 100 Hz ripple waveform you would naturally expect to see on the far side of a bridge rectifier. But not quite normal, because this waveform displays a mirror image either side of the horizontal. The riddle is resolved in Figure 5: by speeding up the time- base we discover a squarewave signal of about 32 kHz at the output, which is very much what we might expect as the unrectified output of a switch-mode power supply. And as our SMPS is designed to provide a pulsating DC voltage rather than something smoothed and filtered, the output is overlaid with the 1 00 Hz waveform of the input. The signal of Figure 4 consists therefore of a 32 kHz squarewave AC voltage amplitude-modulated at 100 Hz. So, on now to our second 'what' question. Should we be concerned about the overtone frequencies of the 32 kHz squarewave signal, if it is fed to a couple of halogen lamps along two catenary (suspension) wires a metre long? Defi- nitely, because this device would transmit a broad band of radio interference starting in the RF region and extend- ing into medium wave territory. Disappointingly, there's no mention whatsoever of this either on the plastic case or in the instruction leaflet. Despite the pretty CE symbol dis- played on the casing (and a number of international techni- cal approval markings), a radiating electronic transformer of this kind should be better screened and ideally not used at all for catenary wire lighting. Applications Now just the final 'what' question remains. Having deter- mined that an electronic transformer is best used only with screened (metal-cased) lamp fittings, we need to say some- thing about the stability of the output voltage. The nominal voltage of 11.2V (unloaded) drops to 1 1 .0 V when sup- plying a 5 A load current. That's certainly a fraction less than the 1 1 .5 V marked on the unit but of adequate stability for this voltage. Because this kind of '12 V transformer' offers such good bang for our buck — models rated at 1 05 W (around 8.5 A) are available cheaply — it's well worth seeing if this bargain might have alternative applications. Most of these will demand direct current and we could simply rectify and smooth the output voltage. The high switching frequency means that four Schottky diodes of adequate rating would be preferable to a normal bridge rectifier. For smoothing at 30 kHz around 1 00 |jF/A would be adequate — were it not for the 100 Hz amplitude modulation. So let's remove it altogether. Figure 6 shows a temporary lash-up with a foil capacitor soldered on the rear side of the PCB, raising the capacity on the input side of the bridge rectifier to a good 700 nF. You can see how effective this is by looking at the output in Figure 7, where we see a signal with the 1 00 Hz compo- nent reduced visibly. We can improve on this: up to 50 W a high-voltage electrolytic rated 1 00 to 220 |jF/385 V will be fi ne. At 1 00 W and more we would need to raise the capacity correspondingly. As can be seen with our modified electronic transformer in Figure 8, such a hefty capacitor Figure 4. Output signal waveform at a timebase of 5 ms/ division. Figure 5. With the timebase reset to 20 jus/division the high-frequency component becomes visible. Figure 6. In this experiment a plastic foil capacitor has been soldered in cascade with the input rectifier to raise the filter capacitance value. 12/2008 - elektor 87 TECHNOLOGY POWER SUPPLIES Figure 7. Improved smoothing on the input side lowers the amount of 100 Hz modulation on the output. Figure 8. This modified 60 W transformer has been fitted with a 1 00 juF filter capacitor (above) and an NTC thermistor (arrowed). The output transformer (right) has additionally been rewound with 2x8 turns to produce two 15 V secondaries. naturally will no longer fit inside the unit's plastic casing. If you are adding a high-voltage electrolytic of this kind for smoothing you will also need to fit a thermistor (NTC) with around 22 Q cold resistance to the mains lead (arrowed in red) in order to keep the switch-on inrush within bounds. Adequate smoothing on the output is achieved with an elec- trolytic rated at 1000 |jF/25 V. The 25 V voltage rating is necessary because the output's peak value can rise to around 1 6 V. With these two modifications made, we have now created an affordable SMPS that delivers around 1 5 V direct current. In Figure 2 the eight turns of the secondary winding of the output transformer are clearly visible. As the primary wind- ing is extremely well insulated with a layer of plastic, this enables us to remove the secondary winding and substitute something different to produce different voltages. On the models we looked at each turn produced 2 V or so. You could for example wind two enamelled copper wires in parallel and produce a winding with a precise centre tap, which would enable you to achieve full-wave rectification with just two diodes. That would save one diode path and reduce losses in the process. Conclusion? An electronic transformer makes an ideal basis for a cheap, lightweight power supply. And 'green' too — the example illustrated develops a measured efficiency of 90 % when operating with its nominal load! ( 080691 - 1 ) r< i i Electronics inside out! The free e-magazine about internet, computers, hacking, tweaking, modeling, gadgets, geekstuff, gaming and DIY electronics. The e-zine you have to check out now! Receive i-TRIXX in your mailbox FOR FREE each Wednesday! Play the i-TRIXX Quiz and win! Test your knowledge about internet, computers and electronics. Take your chance now and play the i-TRIXX Quiz. There are great prices to win! From the Elektor labs: Simple, useful and fun electronic circuits! Warning! Any experimentation involving mains voltages de- mands extreme care and absolute respect for electrical safety guidelines and separation distances. Powered by Check i-TRIXX.com and subscribe now! gGekfor 88 elektor - 12/2008 Prototype & small series PCB specialists Simple online pricing Fast online ordering Clear online order tracking Order pooling CIRCUITS All services low pooling prices wide pooling choices 1-8 layers - no tooling charges - no minimum order - from 3 working days - 100% DRC verification Call us: 020 8816 7005 Email: euro@eurocircuits.com www. eu roci rcu its.com full options service 1-16 layers UL marking WWW. elektor. com ^oirniTECh 55 Your partner for reliable and cost effective manufacturing SMD, TH, FINAL ASSEMBLY, TEST AND PACKING INJECTION MOULDED PLASTIC (THERMOPLASTIC) DETAILS METAL SHEET BOXES END SOLUTIONS FOR YOUR PROJECTS! www.rommtech-3s.com info@rommtech-3s.com r ~ Design your own Embedded Linux control centre This book is not about XI 0, ZigBee, Z-wave or any that's available commercially. Instead, it covers a do-it-your-self sys- tem made from recycled components. The main system descri- bed in this book reuses an old PC, a wireless mains outlet with three switches and one controller, and a USB webcam. All this on a PC is linked together by Linux - as it can be obtained free of char- Design yo ur embedded CONTROL C QlT 0 PC * ilektor Elektor SHOP ge. This book will serve up the basics of setting up a Linux environment - including a software development environment - so it can be used as a control centre. The book will also gui- de you through the necessary setup and configuration of a Webserver, which will be the interface to your very own home control centre. All software will be available for downloading from the Elektor website. 234 pages • ISBN 978-0-905705-72-9 • £24.00 • US$ 48.00 Elektor Regus Brentford • 1000 Great West Road Brentford TW8 9HH • United Kingdom Tel. +44 20 8261 4509 Order quickly and safe through www.elektor.com/shop 12/2008 - elektor 89 Dr. Thomas Scherer This year, for the first time, the efficiency of LEDs has overtaken that of fluorescent tubes. Power LEDs are thus now a realistic and energy-saving alternative to other forms of lighting. Getting them to light up, however, needs a bit of electronics, and hence the universal module described here. One thing is for sure: the twenty- first century will be the age of semicon- ductor light sources. How can we be so certain? See the text box ‘LEDs today’. Figure 1. The 3 W LED from Cree used by the author in his experiments is a particularly beautiful piece of electronics. Current for LEDs Their low dynamic resistance and markedly negative temperature coef- ficient of forward voltage makes oper- ating LEDs from a constant voltage source impractical. Instead, a constant current is needed. It is for the same Technical characteristics • Universal switched LED current source • Efficiency: up to 87 % • Input voltage: 2 x 6 V AC to 2 x 27 VAC • Maximum input voltage: 40 V • Output current adjustable from 0. 1 A to 1 A (maximum 2 A) • Up to eight white LEDs in series • Maximum output voltage: 34 V • Several modules can be powered from one transformer Figure 2. OSRAM's presence in the semiconductor lighting market includes OSTAR, a hex 3 W LED. 90 elektor - 12/2008 LEDs today For: A light bulb with the standard colour temperature of 2700 K has a maximum efficiency of 1 5 Im/W, or 3 %.lt has a life of 1 000 h. A halogen lamp has four times the life expectancy, and gives out some- what more light: a typical efficiency is 25 Im/W, or 5 %. Fluorescent lamps can reach efficiencies of over 20 % (up to 100 lm/ W) and have life expectancies of over 10000 h. Modern energy-effi- cient bulbs, because of their small size, only manage around 60 lm/ W, and unfortunately only reach their normal brightness after a de- lay: at low temperatures normal brightness is never reached. They are not suitable for frequent switching. A modern white [1] high-power LED has the following features. • Light output efficiency of over 1 00 Im/W (over 1 50 Im/W has been achieved). • Life of over 50000 h. • Rapid and problem-free switching on and off. • Small physical size opening up new opportunities for lamp design. Against: The advantages of power LEDs are so clear that it is surprising that they are not more widely available. The devices currently available that contain a large number of 5 mm LEDs are of little use. The main obstacles to adoption of LED lights are their high price and their cooling requirements. A single good-quality white 3 W LED of the sort shown in Figure 1 today costs several pounds. Special high-efficiency LEDs, 5 W types, multiple-LEDs (see Figure 2) and RGB LEDs (see illustration) are considerably dearer. Also, to prolong their life, the LEDs must not be allowed to get too hot. Efficiency reduces as temperature rises, and so is also improved by adequate cooling. Good cooling is, however, difficult to provide and so it is understandable that good-quality LED lamps tend to come with a 'designer' label and a price to match. reasons that LEDs are normally wired in series rather than in parallel: otherwise device-to-device variations would lead to an unequal distribution of load and hence brightness. In the case of power LEDs designed for lighting applications energy effi- ciency plays an important role. This means that there is no real alternative to using a switching regulator to drive the devices. Unfortunately commonly- available integrated switching regula- tors are designed for constant output voltage rather than constant output current. It is not easy to convert them to constant current operation because the internal reference voltage used by the error amplifier is usually in the region of 2.5 V, and is rarely less than 1.2 V. Even with a 1.2 V reference regu- lating the current by simply measuring the voltage drop across a shunt resistor leads to unacceptable losses: at a cur- rent of 1 A a 1.2 V voltage drop calls for a 1.2 Q shunt resistor which will dissi- pate 1.2 W in wasted power. Special- purpose LED driver ICs are available, but almost invariably in hard-to-solder SMD packages. A clever little circuit offers an alternative approach. PLDM circuit If we want to make use of a low- cost integrated switching regula- tor in a five-pin TO-220 package, such as the LM2525Z-ADJ, then the trick in converting it into a con- stant current source lies in artificially raising the level of the error signal. The circuit in Figure 3, which forms a uni- versal driver module for power LEDs, is surprisingly simple and easy to adapt. D1 and D2 rectify the voltage from the mains transformer, which must have either two identical secondary wind- ings or a single winding with a cen- tre tap. In comparison to a full-wave bridge, the arrangement shown saves on the losses associated with the volt- age drop across one diode. Schottky diodes keep the remaining voltage drop down to below 0.5 V. The recti- fied voltage supplies switching regu- lator IC1, a so-called ‘buck’ step-down converter, on pin 1. The input voltage must always be greater than the out- put voltage. The IC includes an error amplifier which drives a pulse-width modulator and switching transistor. The PWM signal produced appears on Figure 3. Circuit of the switching voltage/current regulator. 12/2008 - elektor 91 POWER LED Figure 4. With a supply voltage of 25 V and five 3 W power LEDs connected to the PLDIVI, the mark-space ratio of the switching regulator is approximately 50 %. Figure 5. The PLDIVI printed circuit board measures just 60 mm by 40 mm. COMPONENTS LIST Resistors R1 = 1 Q / 2W (carbon film or metal film) R2 = 1 OI<£2 R3 = 1 kD R4 = 2Is‘:r lim Wat&iMpc ■ Fle«™ttRtC rtBsmnmnt ■ PDC FYngranirnno usl's C » SFI'} prirapi» and praaM Cm .Vi E 1 f Va 1.1 A'ii|>Tirra- Hlr** (rttor rtvr rf r*fl WA-tfP- Belore qLesDans. please rev nu r F.4Q jetsnn! Log in FlrhEorjnh. 31 HE Axcru JdcvnLincrtLmn v rt :1 IJny’iA ElfthtQr + ■prfnh-A WHJtrt I L^HIraniK + np'rfE your JEi sirtuiLa irriri iriuml ■necTrwJe* (caiwra Limitiil pen nil alter fnr flRlrtn. ukbdhiR In n.r i I KI ■ A n yiajr inailKii far fr rr r.Vi h LVn 1 1 n - Y 1 SJnhrcrui) & sp e y Dec- l* r EM HIcrsKDntrnlleri Thi sej*s -we* -sr^ete ft fltth e5P* A* r«df e-^rvWTHhltVjh'i St* ri J-rl uWAft-d 108 elektor - 12/2008 Description Price each Qty. Total Order Code Universal Display Book for PIC Microcontrollers Design your own Embedded Linux Control Centre on a PC CD-ROM FPGA Course £14.50 Computer Vision £32.00 PIC Microcontrollers £27.95 (323 (323 £23.00 £24.00 Free Elektor Catalogue 2008 Prices and item descriptions subject to change. The publishers reserve the right to change prices without prior notification. Prices and item descriptions shown here supersede those in previous issues. E. & O.E. Sub-total P&P Total paid Name Address + Post code Tel. Email Date - - Signature EL12 Yes, I am taking out an annual subscription to Elektor and receive a free 2GB MP3 player*. I would like: I I Standard Subscription (11 issues) Subscription-Plus (11 issues plus the Elektor Volume 2008 CD-ROM) * Offer available to Subscribers who have not held a subscription to Elektor during the last 12 months. Offer subject to availability. See reverse for rates and conditions. Name Address + Post code Tel. Email Date - - Signature EL12 METHOD OF PAYMENT (see reverse before ticking as appropriate) Bank transfer Cheque (UK-resident customers ONLY) □ Giro transfer □ □ nn ■ ag ■ ti Expiry date: Verification code: Please send this order form to* (see reverse for conditions) Elektor Regus Brentford 1000 Great West Road Brentford TW8 9HH United Kingdom Tel.: +44 20 8261 4509 Fax: +44 20 8261 4447 www.elektor.com sales@elektor.com *USA and Canada residents may (but are not obliged to) use $ prices, and send the order form to: Elektor US PO Box 876 Peterborough NH 03458-0876 Phone: 603-924-9464 Fax: 603-924-9467 E-mail: custservus@elektor.com METHOD OF PAYMENT (see reverse before ticking as appropriate) □ □ □ □ Bank transfer Cheque (UK-resident customers ONLY) Giro transfer t r T ; ■ U 1 - -T1 Mart erf aid Expiry date: Verification code: Please send this order form to Elektor Regus Brentford 1000 Great West Road Brentford TW8 9HH United Kingdom Tel.: +44 20 8261 4509 Fax: +44 20 8261 4447 www.elektor.com subscriptions@elektor.com ORDERING INSTRUCTIONS, P&P CHARGES Except in the USA and Canada, all orders, except for subscriptions (for which see below), must be sent BY POST or FAX to our Brentford address using the Order Form overleaf. Online ordering: www.elektor.com/shop Readers in the USA and Canada may (but are not obliged to) send orders, except for subscriptions (for which see below), to the USA address given on the order form. Please apply to Old Colony Sound for applicable P&P charges. Please allow 4-6 weeks for delivery. Orders placed on our Brentford office must include P&P charges (Priority or Standard) as follows: Europe: £6.00 (Standard) or £7.00 (Priority) Outside Europe: £9.00 (Standard) or £11.00 (Priority) HOWTO PAY All orders must be accompanied by the full payment, including postage and packing charges as stated above or advised by Customer Services staff. Bank transfer into account no. 40209520 held by Elektor Electronics with ABN-AMRO Bank, London. IBAN: GB35 ABNA 4050 3040 2095 20. BIC: ABNAGB2L. Currency: sterling (UKP). Please ensure your full name and address gets communicated to us. Cheque sent by post, made payable to Elektor Electronics. We can only accept sterling cheques and bank drafts from UK-resident customers or subscribers. We regret that no cheques can be accepted from customers or subscribers in any other country. Giro transfer into account no. 34-152-3801, held by Elektor Electronics. Please do not send giro transfer/deposit forms directly to us, but instead use the National Giro postage paid envelope and send it to your National Giro Centre. Credit card VISA and MasterCard can be processed by mail, email, web, fax and telephone. Online ordering through our website is SSL-protected for your security. COMPONENTS Components for projects appearing in Elektor are usually available from certain advertisers in this magazine. If difficulties in the supply of components are envisaged, a source will normally be advised in the article. Note, however, that the source(s) given is (are) not exclusive. TERMS OF BUSINESS Delivery Although every effort will be made to dispatch your order within 2-3 weeks from receipt of your instructions, we can not guarantee this time scale for all orders. Returns Faulty goods or goods sent in error may be returned for replacement or refund, but not before obtaining our consent. All goods returned should be packed securely in a padded bag or box, enclosing a covering letter stating the dispatch note number. If the goods are returned because of a mistake on our part, we will refund the return postage. Damaged goods Claims for damaged goods must be received at our Brentford office within 10-days (UK); 14-days (Europe) or 21 -days (all other countries). Cancelled orders All cancelled orders will be subject to a 10% handling charge with a minimum charge of £5.00. Patents Patent protection may exist in respect of circuits, devices, components, and so on, described in our books and magazines. Elektor does not accept responsibility or liability for failing to identify such patent or other protection. Copyright All drawings, photographs, articles, printed circuit boards, programmed integrated circuits, diskettes and software carriers published in our books and magazines (other than in third-party advertisements) are copyright and may not be reproduced or transmitted in any form or by any means, including photocopying and recording, in whole or in part, without the prior permission of Elektor in writing. Such written permission must also be obtained before any part of these publications is stored in a retrieval system of any nature. Notwithstanding the above, printed-circuit boards may be produced for private and personal use without prior permission. Limitation of liability Elektor shall not be liable in contract, tort, or otherwise, for any loss or damage suffered by the purchaser whatsoever or howsoever arising out of, or in connexion with, the supply of goods or services by Elektor other than to supply goods as described or, at the option of Elektor, to refund the purchaser any money paid in respect of the goods. Law Any question relating to the supply of goods and services by Elektor shall be determined in all respects by the laws of England. September 2007 SUBSCRIPTION RATES FOR ANNUAL SUBSCRIPTION Standard Plus United Kingdom £44.00 £53.00 Surface Mail Rest of the World £58.00 £67.00 Airmail Rest of the World £74.00 £83.00 USA £59.95 See www.elektor.com/usa Canada £70.95 for special offers HOWTO PAY Bank transfer into account no. 40209520 held by Elektor Electronics, with ABN-AMRO Bank, London. IBAN: GB35 ABNA 4050 3040 2095 20. BIC: ABNAGB2L. Currency: sterling (UKP). Please ensure your full name and address gets communicated to us. Cheque sent by post, made payable to Elektor Electronics. We can only accept sterling cheques and bank drafts from UK-resident customers or subscribers. We regret that no cheques can be accepted from customers or subscribers in any other country. Giro transfer into account no. 34-152-3801, held by Elektor Electronics Please do not send giro transfer/deposit forms directly to us, but instead use the National Giro postage paid envelope and send it to your National Giro Centre. Credit card VISA and MasterCard can be processed by mail, email, web, fax and telephone. Online ordering through our website is SSL- protected for your security. SUBSCRIPTION CONDITIONS The standard subscription order period is twelve months. If a permanent change of address during the subscription period means that copies have to be despatched by a more expensive service, no extra charge will be made. Conversely, no refund will be made, nor expiry date extended, if a change of address allows the use of a cheaper service. Student applications, which qualify for a 20% (twenty per cent) reduction in current rates, must be supported by evidence of stu- dentship signed by the head of the college, school or university faculty. A standard Student Subscription costs £35.00, a Student Subscription-Plus costs £44.20 (UK only). Please note that new subscriptions take about four weeks from receipt of order to become effective. Cancelled subscriptions will be subject to a charge of 25% (twenty-five per cent) of the full subscription price or £7.50, whichever is the higher, plus the cost of any issues already dispatched. Subsciptions cannot be cancelled after they have run for six months or more. December 2008 Atlas Star Pack Atlas DCA and Atlas LCR in Premium Carry Case Atlas DCA - Model DCA55 Semiconductor Analyser Identifies type and pinout! Connect any way round. Measures gain, junction characteristics and more. Now with premium strong probes!! Atlas LCR - Model LCR40 Passive Component Analyser Automatic component identification (inductor, capacitor or resistor). Auto frequency selection. Measures main component value and other parameters too such as the DC resistance of inductors automatically. Special Offer prices for limited period or until stocks last. 1 ■ r If j r~ electronic design ltd Atlas ESR - Model ESR60 Measure capacitance and ESR! Capacitance from luF to 22,000uF ESR from 0.01 ohms to 20 ohms Battery included + Gold plated croc clips Features our unique I automatic discharge function LED Torch - Great Gift! Uniross Aluminium 6 LED Torch 150mm long 2 AA Batteries (included) Fabric Wrist Strap Sealed retail pack |>\ a V\V' Atlas LCR see description in main offer o. Atlas DCA see description in main offer new probes! Atlas SCR - Model SCR100 Triac and Thyristor Analyser Automatic part identification (Triacs and Thyristors) Auto pinout identification. Gate sensitivity testing. Gate voltage drop measurement Automatic current from: IOOuA to 100mA. Tests at 12V regardless of battery condition. Fitted with new premium probes. Supplied^\th battery and user guide. 0 X wk'P- ir M pip) pxnr ©ota IPto© MM Atlas IT -Model UTP05 Network Cable Analyser Automatic cable pattern identification for nearly all types of RJ45 based cabling. Identifies all types of wiring errors and faults. Will identify cabling type even if the wiring has faults or errors. Supplied with 2 intelligent terminators. Compatible with “Identified” terminators for easy multiple cable run labelling. Supplied with battery and laminated guide. T. L est Road 17 6HF. than All levels of the Proteus Design Suite now include a world class fully integrated shape based autorouter at no additional cost. The Proteus Design Suite also incorporates ■ Professional schematic capture ■ Highly confi ■ Publication quality schematics ■ Interactive c ■ Fully configurable bill of materials ■ Polygonal a ■ Large component libraries for both ■ RS274X, E) simulation and PCB layout database e> Mixed mode SPICE circuit simulation 3D Viewer v ■ Co-simulation of PIC, AVR, 8051 and an d DXF ex ARM7 microcontroller firmware ■ Automatic component placement and gateswap optimization Prices start from just £1 50 - visit our website for full details or to download a free demo. Electronics Labcenter Electronics Ltd. 53-55 Main Street, Grassington, North Yorks. BD23 5AA. Registered in England 4692454 Tel: +44 (0)1756 753440, Email: info@labcenter.com exc. VAT & delivery