U Ldi&'EW www.elektor.com JULY/AUGUST 2008 aus$ i 6.95 - nz$ 21. 50 -sar 99.95 -us$ 15.95 £ 5.80 'ectronics worldwide a trip to Ch ilia! or one of the marvellous prizes from our scratch lottery! XCypMami Co BCero MMpa htt p ://r- p o i nt.nnm.ru www. jo u rn a l-p I aza.ne t R34 Water Tank Level Kits PIC Based Water Tank Level Meter Kit KC-5460 £29.00 + postage & packing This PIC-based unit uses a pressure sensor to monitor water level and will display tank level via an RGB LED at the press of a button. The kit can be expanded to include and optional wireless remote display panel that can monitor up to ten separate tanks (KC-5461) or you can add a wireless remote controlled mains power switch (KC-5462) to control remote water pumps. Kit includes electronic components, case, screen printed PCB and pressure sensor. Telemetry Base Station for Water Tank Level Meter KC-5461 £23.25 + postage & packing This Base Station is used with the telemetry version of the KC-5460 water tank level meter. It has an inbuilt 433MHz wireless receiver and can handle data transmissions from up to 10 level meters and display the results on a 2-line 32-character LCD module. Kit includes silk screened PCB, case, electronic components, receiver module and the RF transmitter upgrade for one tank level meter. Remote electric pump control option available. Requires 9-12VDC 100mA plugpack. LED Water Level Indicator MKII Kit KC-5449 £10.25 + postage & packing This simple circuit illuminates a string of LEDs to quickly indicate the water level in a rainwater tank. The more LEDs that illuminate, the higher the water level is inside the tank. The input signal is provided by ten sensors located in the water tank and connected to the indicator unit via-light duty figure-8 cable. Kit supplied with PCB with overlay, machined case with screen printed lid and all electronic components. Requires 12-18VAC or DC 500mA plugpack. Studio 350 - High Power Amplifier KC-5372 £55.95 + post & packing Studio Quality, Low Noise, Low Distortion. The Studio 350 power amplifier will deliver a whopping 350WRMS into 4 ohms, or 200WRMS into 8 ohms. It offers some real grunt without any compromise, using 8 (yes, EIGHT!) 250V 200W plastic power transistors - four MJL21 193/4 complementary pairs to be precise. It is super quiet, with a signal to noise ratio of -125dB(A) at full 8 ohm power. Harmonic distortion is fantastic - just 0.002%, and frequency response is almost flat (less than -IdB) between 15Hz and 60kHz!. We have mentioned the power, but we forgot to give you the music power figures of 240W* into 8 ohms and 480W* into 4 ohms. Kit supplied in short form with PCB and electronic components. Kit requires heatsink and +/- 70 V power supply (a suitable supply is described in the instructions). • Power figures applicable when described power supply is used. Flexitimer/lnterval Timer KC-5464 £8.75 + post & packing Here's a new and completely updated version of the very popular low cost 12VDC electronic timer. It is link programmed for either a single ON, or continuous ON/OFF cycling for up to 48 on/off time periods. Selectable periods are from 1 to 80 seconds, minutes, or hours and it can be restarted at any time. Kit includes PCB and all specified electronic components. §■ J Post and Packing Charges Order Value Cost Order Value £200 - £499.99 £500+ £10 - £49.99 £5 £50 - £99.99 £10 £100 -£199.99 £20 Max weight 121b (5kg). Heavier parcels POA Minimum order £10. Note: Products are despatched from Australia, so local customs duty and taxes may apply. How to order: Call Australian Eastern Standard Time Mon-Fri Phone: 0800 032 7241 Fax: +61 2 8832 3118 Email: techstore@jaycarelectronics.co.uk Post: P.0. Box 107, Rydalmere NSW 2116 Australia Expect 10-14 days for air parcel delivery Car Kits Fuel Cut Defeat Kit KC-5439 £6.00 + post & packing This cheap and simple kit enables you to eliminate this factory fuel cut and go beyond the typical 15-17PSI factory boost limit. The kit simply intercepts the MAP sensor signal, and trims the signal voltage above 3.9V to avoid the ECU cutting the fuel supply to the engine. Kit includes PCB with overlay & all specified electronic components. 12-24 V High Current Motor Speed Controller Kit KC-5465 £29.00 + post & packing Want to control a really big DC motor? This design will control 12 or 24VDC motors at up to 40A continuous. The speed regulation is maintained under load, so the motor speed is maintained even under heavy load. It also features automatic soft-start, fast switch-off, a 4-digit LED 7-segment display to show settings, an overload warning buzzer and a low battery alarm. All control tasks are monitored by a microcontroller, so the functionality is extensive. Kit contains PCB and all specified electronic components. Radar Speed Bun Mk2 KC-5441 £29.00 + post & packing We have improved and refined this kit since it was published and it is now even more stable and accurate. If you're into any kind of racing like cars, bikes boats or even the horses, this kit is for you. Kit includes PCB and all electronic components. Check out the Jaycar range in your FREE Catalogue - logon to www.jaycarelectronics.co.uk/elektor or check out the range at www.jaycarelectronics.co.uk 0800 032 7241 (Monday - Friday 09.00 to 17.30 GMT + 10 hours only) For those who want to write: P0 Box 107, Rydalmere NSW 2116 Sydney AUSTRALIA 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. DEVELOPMENT TOOLS | COMPILERS | BOOKS http://www.rn Hardware In- Circuit Debugger on-board enables easy debugging High-Performance On-Board Programmer IN-CIRCUIT pruinAr.iHLn d 'J- ■ ' J 1 ttovsft- PIC develop- ment system UtVkLUI-Mtm BOARD atures, you can starfcreating your grei^B^Pes immediate- s 8-, 14-, 18-, 20-, 28- and 40- pin PIC^Trncrocontrollers (it comes with the PIC7I6F887). The (Hardware In-circuit Debugger) enables very efficient step by step debugging. Examples in , , 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. Evolving product features and modern input design require 1tfl the use of touch screens. The i "jjjjjjL with connector available on EasyPIC5 is a with the ability to display and receive information on the V same display. It allows a display to be used as an input device. Simple installation onto the face of a GLCD for easy connec ti° n to EasyPIC5 board with built-in Touchscreen : .. ; ^ Controller and Connector. Thanks to m This year's edition of Summer Circuits is quite special. Apart from a vast number of circuits and ideas we present a scratchcard lottery unique to electronics magazine publishing. The hidden number on the scratchcard on the opposite page may win you a trip to China! Or an oscilloscope, a development kit, a voucher, Elektor Credits and lots more. Elektor editors have phoned their contacts in the trade and industry to request sponsorship for this special event. The response was overwhelming. For example, National Instruments have sponso- red 8 LabVIEW packages complete with USB data acquisition modules, representing a total value of £1 8,500! Agilent kindly added a fantastic portable oscilloscope worth £1 ,300 to our stock of prizes. Fluke obliged by allowing us to give away one of their digital multimeters worth £460. Elektor themselves added a little something to the stock of prizes: an ElekTrack unit that allows you to find back your caravan at all times, or indeed any other vehicle or valuable object. Also from Elektor are sets of E-credits and a number of vouchers that allow you pick your own prize from the Elektor Shop. Main prizes worth in excess of £40,000 The main prize Join the scratchcard lottery and win a unique trip to China. Visit the Great Wall — discover the culture of this extraordinary country. Besides, the trip allows a peek into China's electronics industry. As part of the trip you will visit a trade fair, a number of product manufacturers as well as some of the largest electronics shops in the world. After the visit, we're sure a wondrous world has opened up for you. 8 pcs N I LabVIEW with Nl USB-6009 data acquisition card, worth £2,300 (€ 3,000) each Scratch and enter a draw for prizes worth £40k+ ! Winning was never easier. Before 31 August 2008, scratch to reveal your personal code and go to the Elektor website. On the website, answer the (very) simple question and then enter your code. htt p i//r- p o i nt.nntn.ru www. jo u r n a l-p I aza.ne t Just four steps to a fantastic prize! 1. Scratch to reveal your personal code 2. Go to www.elektor.com/scratch 3. Answer a simple question 4. Enter your code and win Initial conditions for participation Lottery not open to employees of Elektor International Media, its business partners and/or associated publishing houses. No cash equivalent in lieu of prize(s). Legal action and correspondence barred. Lottery subject to acceptance of terms. Lottery closes on 31 August 2008. Elektor ElekTrack module worth £300 (€ 400) You should get out more... Those first days of spring are so hard on our lab workers — birds are singing and you can smell the grass but the only thing these poor souls smell is solder fume. More than one hundred circuits pass their hands — requiring boards to be designed and parts to be ordered. Once the boards arrive, they have to be tested and one mistake means 'all over again'. Then the material is passed to the Dutch, English, French, German and Spanish editors who provide the matching texts and illustrati- ons. Manuscripts are returned to the lab for a check on technical aspects. Meanwhile drawings are produced in Elektor style (well done Marty) and with these fini- shed, DTP assembles the text and illustrations into an 'SC item', which is handed to the editors for final corrections. I will not diverge into more technicalities of Elektor magazine production. Our aim is for you to trawl the magazine contents for nice projects and ideas as you can hear birdsong and smell the new grass. This year our source of inspiration was 'all things outdoors': do-it- yourself, sporting, biking, on the road by car or camper, with or without caravan, you name it — everything that keeps us out of doors long enough to take our minds off electronics. Scratch-and-Win! This years' Summer Circuits edition contains a Scratch Number lottery. We called half a dozen selected suppliers and advertisers and they all agreed to make prizes availa- ble for this unique event. If the Summer Circuits issue is a cake made from many ingredients then scratch-and-win is the icing! Wisse Hettinga International Coordinating Editor Plus Colophon 8 News & New Products 10 Electrical Safety 16 AlphaSudoku Puzzle 118 Elektor SHOP 128 Sneak Preview 132 SUMMER CIRCUITS 2 (bold type = PCB design included) Audio, Video & Photography Automatic S/PDIF Selector Auto-off for Audio Gear Camera = Data Store Five-output Video Distribution Amplifier Play the Guitar — Recycle Tip Slave Flash Trigger TV Muter Video Isolator 104 120 69 101 73 35 81 43 Computers, Software & Internet MypHanbi co acero MMpa htt p Mr- p o i nt.nnm.ru www. jo urna l-p I aza.net Assistance for BASCOM Programmers 1 1 Mobile Phone Data Cable = Interface Converter 64 USB <-> RS-232 Cable 63 USB Standby Killer 86 Hobby, Games & Modelling 1 23 Game — all MCU-free 61 Deluxe'123'Game 41 Golf Tally 112 Intelligent Presence Simulator 65 Lamp in a Wine Bottle 38 LED SpinningTop 1 16 Logic Goats 79 Pitch Meter for Model Helicopters 40 Programmable Servo Driver 59 Pseudo-random Glitter 97 Radio Control Signal Frame Rate Divider 94 Reaction Race using ATtinyl 3 44 RGB Light 91 Servo Control 107 Smooth Flasher 41 Tent Alarm 56 CONTENTS Volume 34 July/August 2008 no. 379/380 Home & Garden Bell Alarm 33 Environmentally-friendly Mosquito Repeller 20 FLTwilight Switch 95 Flowcode for Garden Lighting 52 Lighting Governor 121 Outside Light Controller 1 23 Post-box Monitor 37 Put that Light Out! 36 Remote Control Mains Switch 55 RFID Door Opener 32 Tracking Solar Panel 1 8 Underwater Magic 98 Zigbee-based Wireless Motion Sensor 78 DTMF-controlled Home Appliance Switcher 84 Flowcode for Garden Lighting 52 GPS Receiver 76 Multitasking Pins 20 Simple USB AVR-ISP Compatible Programmer 60 SimpleProg 93 Turbo BDM Lite Coldfire Interface 1 02 Universal Thermostat 82 Power Supplies, Batteries & Chargers 1 2-V Fan Directly on 230 V 1 22 48-V Microphone Supply 44 Automatic Car Battery Charger 1 1 9 Battery Discharge Meter 24 Car & Motorcycle Battery Tester 64 Cheap 12V/ 230 V Invertor 62 Cigarette-lighter Battery Charger 1 1 7 Dimmable LED Light 21 Energy-efficient Backlight 92 The Gentle Touch 53 Gratis Symmetrical Opamp Supply Voltages 57 LED Switching Regulator 1 20 LiPo Manager 67 Low-Voltage Step-Down Converter 66 Mini Bench Supply 1 06 Mini High-voltage Generator 58 Phantom Supply for TV Antenna 105 RC Mains Sockets with Feedback 69 Smart Chocolate Block 34 Solar Cell Array Charger with Regulator 1 1 4 Solar Cell Voltage Regulator 46 Solar Powered Battery Charger 88 Solar Powered Uninterruptible PSU 90 Solar-powered Automatic Lighting 22 RF (radio) DCF77 Preamplifier 68 Detector with Amplification 1 08 FM Microbug 92 Software-defined Valve Radio 1 08 Wireless Audio Transmitter 28 Test & Measurement 22-bit A/D Converters 87 Active Rectifier 74 Automatic Range Switching 73 Car & Motorcycle Battery Tester 64 Digital Rev Counter for (Older) Diesels 110 Discrete PWM Generator 45 Gas Flow Meter 30 LED Tester 28 Magnetic Flip-Flop 70 Microlight Fuel Gauge 98 Minimalist Oscilloscope 47 Operating Hour Counter 35 Portable Thermometer 1 9 Simple Audio Power Meter 58 Stroboscope with Trigger Input 54 Temperature Sensor with 2-Wire Interface 42 Miscellaneous Electronics & Design Ideas Fog Lamp Sensor 23 Fog Lamp Switch 87 High-intensity LED Warning Flasher 54 Indicator for Weller Soldering Stations 72 ISO Standard for Car Radios 1 24 Mysterious Self Charging 27 Piezo-powered Lamp 109 PR4401/02 off the Beaten Track 125 The OC 171 Mystery (solved) 96 PWM Control for Permanent Magnet Motors 1 00 Simple Bike Light 89 Simple Capacitive Touch Sensor 80 Simple One-Wire Touch Detector 46 Solar Lamp using the PR4403 1 22 ELECTRONICS WORLDWIDE Kypnanbl CO scero MMpa htt p ://r- p o i nt.rmm.ru www.journal-plaza.net 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. TiPCtron» cS el\ou^ nC GfiA MIC TAUNT Spftwjre builds 'hardware Icktor Sternet !«idio ISFACTORY RESULTS Volume 34, Number 379/380, July & August 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, Guy Raedersdorf. 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 8 elektor - 7-8/2008 r SAPS -400 A 'powerhouse'switch-mode supply for audio amps The switch-mode power supply unit (SMPSU) is renowned for its efficiency but notorious for its design complexity, compared with its predeces- sor the linear supply. With the SAPS-400 we offer a powerful, adjustable symmetrical supply that's ideal for lightweight audio power ampli- fiers and happily sits in less than a quarter of the space taken by a comparable supply of conventional design.. PCB, populated and tested , ready-mounted in aluminium U profile Art.# 070688-91 • £159.00 • US$318.00 lektor SHOP Specifications 400 W continuous Symmetrical output voltage, adjustable between 35 V and 60 V Compatible with 100-120 and 200-240 VAC (50-60 Hz) line voltage Auxiliary voltage 1 5 V symmetrical, 500 mA Short-circuit resistant Dimensions just 90 x 1 50 x 40 mm Weight: 450 g Order quickly and safe through WWW.el6ktor.COIn/shop or use the Order Form near the end of the magazine r 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 Lane, Chertsey, Surrey KT1 6 9AP, England. Telephone: +44 1932 564999, Fax: +44 1932 564998 Email: p.brady@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 7-8/2008 - elektor 9 INFO & MARKET NEWS & NEW PRODUCTS Live EDGE 2008 US$ 100,000 challenge in support of green design Premier Farnell pic and its subsidi- ary companies Newark, Farnell, Premier Electronics, CPC, Farnell- Newark and MCM launched its in- ternational competition Live EDGE - Electronic Design for the Global Environment, now in its second year. Trees were planted world- wide to celebrate the launch of this year's challenge which includes a second category for students. The competition is designed to pro- vide a forum where electronic de- sign engineers and students can design products that are environ- mentally friendly through the use of electronic components. Registration for news, updates and activities started on 6 May 2008 via the Live EDGE website and on the Live EDGE Design Chal- lenge group on Facebook. The Live EDGE website will soon fea- ture social networking tools, and a leading edge community forum in the near future for engineers to share and develop ideas. Entries can be submitted between 1 October 2008 and 31 January 2009. Judging will start on the 1 February 2009 and winners will be announced on the 2 April 2009. The competition is open to anyone aged 1 8 or over. Electronics engineers, students and inventors around the world are invited to submit designs for an innovative product that utilises electronic components and has a positive impact on the environ- ment, for example by increasing energy efficiency or reducing car- bon emissions. The winning entrant for both the full-time student and the general/ open category will receive a cash prize of US$ 25,000 as well as a design support package valued at an additional US$ 25,000 to move the design towards produc- tion. The support package will in- clude the services of an electronic design consultancy to help develop the design to prototype stage, as- sistance with legal matters and IP registration, some marketing and publicity, as well as Premier Far- nell's help in securing investment funding. The group will actively market the end product to millions of customers globally through their leading edge website, catalogue and direct marketing. In addition, up to three entrants for the full-time student category and three entrants for the general/open category will be eligible for 'hon- ourable mentions', each receiving a cash prize of US$ 5,000. Reflecting the environmentally friendly theme of the competition, Live EDGE will be largely web- based to avoid international travel and transportation. For example, the judges will confer online and it will be possible to view the award ceremony from the competition website. www.live-edge.com www.premierfarnell.com (080485-III) 12 GHz USB sampling oscilloscope Pico Technology's new PicoScope 9201, a dual-channel PC Sam- pling Oscilloscope has a band- width of 12 GHz. The instrument uses sequential equivalent-time sampling to achieve a sampling rate of 5 TS/s. The wide band- width allows acquisition and meas- urement of fast signals with a tran- sient response of 50 ps or faster. Timebase stability, accuracy, and a sampling interval of 200 fs al- low timing characterization of jit- ter in the most demanding applica- tions. The ability to trigger on high frequencies up to 10 GHz allows measurements on microwave com- ponents with extremely fast date rates. Data acquisition and measurement analysis are performed in parallel, enabling the instrument to achieve outstanding measurement through- put. The instruments provide fast acquisition speed up to 200 kS/ s and waveform performance analysis with automated direct or statistical measurements on both single-valued signals (sine-wave, pulse, impulse) and multi-valued signals (NRZ, RZ). Markers and histograms, math and FFT analy- sis, colour-graded display, para- metric limit testing, eye diagrams and mask template testing can be used independently or in concert. Accurate eye-diagram analysis for NRZ and RZ signal types is essen- tial for characterizing the quality of electrical and optical transmitters to beyond 7 Gb/s. The PicoScope 9201 was designed specifically for the complex task of analyz- ing digital communications wave- forms. Compliance mask and par- ametric testing no longer require a complicated sequence of setups and configurations. The important measurements you need are right at your fingertips, including in- dustry-standard mask testing with built-in margin analysis, extinction ratio measurements with improved accuracy and repeatability, auto- matic eye measurements — cross- ing %, eye height and width, one and zero levels, jitter, rise and fall times — and more. In addition, mask testing of sdh/sonet, Fibre Channel, Ethernet and other stand- ards simplifies compliance testing. A full colour display helps you to discriminate waveform details. A colour-graded display mode adds a third dimension — sample den- sity — to your signal acquisitions and analysis. The PicoScope 9201 is available from local distributors, or direct from Pico Technology. www.picotech.com (080452-V) 10 elektor - 7-8/2008 Analog + Digital Digital Storage Oscilloscope Dual Channel Digital Scope with industry standard probes or POD connected analog inputs. Fully opto-isolated. USB Mixed Signal Oscilloscope r Inventing the future requires a lot of test gear... ...or a BitScope 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. Multi-Channel Logic Analyzer Eight logic/trigger channels with event capture to 25nS. DSP Waveform Generator Optional flash programmable DSP based function generator. Operates concurrently with waveform and logic capture. Mixed Signal Data Recorder Record to disk anything BitScope can capture. Supports on-screen waveform replay and export. User Programmable Tools and Drivers Use supplied drivers and interfaces to build custom test and measurement and data acquisition solutions. BS100U Mixed Signal Storage Scope & Analyzer Innovations in modem electronics engineering are leading the new wave of inventions that promise clean and energy efficient technologies that will change the way we live. It's a sophisticated world mixing digital logic, complex analog signals and high speed events. To make sense of it all you need to see exactly what's going on in real-time. BS100U combines analog and digital capture and analysis in one cost effective test and measurement package to give you the tools you need to navigate this exciting new frontier. Standard 1M/20pF BNC inputs Smart POD Connector Opto-isolated USB 2.0 12VDC with low power modes BitScope DSO Software for Windows and Linux BS100U includes BitScope DSO the fast and intuitive multichannel test and measurement software for your PC or notebook. Capture deep buffer one-shots, display waveforms and spectra real-time or capture mixed signal data to disk. Comprehensive integration means you can view analog and logic signals in many different ways all at the click of a button. The software may also be used stand-alone to share data with colleagues, students or customers. Waveforms may be exported as portable image files or live captures replayed on another PC as if a BS100U was locally connected. www . bftscope . com A 7-8/2008 - eleklor n INFO & MARKET NEWS & NEW PRODUCTS Design your own chips with MACH64 The MACH64 Programmable Logic Starter Kit from Nurve Networks takes you from mys- tery to mastery in the black art of Complex Programmable Log- ic Devices (CPLDs). CPLDs are chips that are inter- nally constructed of an array or matrix of programmable logic units or blocks. Each cell can perform various logic functions. The power of CPLDs is that with a software based tool you can write 'code' that is compiled into a hardware description that is then downloaded and flashed into the CPLD changing its be- haviour to your exact specifica- tions. By mastering this technol- ogy, you can develop your own chips that run at blazing speeds as well design very complex sys- tems that would be impossible with discrete TTL chips. CPLDs are a great starting point for those interested in program- mable logic technology and al- low you to seamlessly move into their bigger brothers — Field Programmable Gate Arrays (FP- GAs) when you're ready. The MACH64 kit is actually two kits in one: - A complete Lattice ispMACH 4064 series development kit with a built-in programmer which sup- ports external targets as well. - The MACH64 is a powerful ed- ucational kit that teaches CPLD technology and programming from the ground up — applicable to any CPLD. The MACH64 kit comes complete with everything you need to learn, experiment, design and program with CPLDs. The included 250+ page manual starts off with the technology of CPLDs and then eas- es you into the ABEL language used to program CPLDs. The numerous challenging hands-on projects in- clude: basic logic gates, counters, state machines, ALU design, audio generation, NTSC and VGA video generation and much more. Everything you need to build all the labs is included in the kit along with extra parts for your own crea- tions. Resistors, capacitors, LEDs, transistors, diodes, and more! Package includes - MACH64 development board - Built-in programmer - 250+ page hard copy user manual - 9 V @ 300 mA, 2.1 mm, DC wall adapter - DB25 parallel port programming cable - External CPLD programming cable - A/V cable - Solderless breadboard - 40 hookup wires (20 long, 20 short) - Over 75 passive components - 1 .0 MHz, 3.58 MHz, 25. 1 75 MHz oscillators - Windows CD-ROM with software & tools - Over 20 step by step tutorials System requirements: Windows PC with parallel port. NTSC TV moni- tor for NTSC labs. VGA monitor for VGA labs. Nurve Networks LLC, www.xgamestation.com (080485-1 Parallel Port Programming Interface VC CIO Select Built-In Programmer 9V Power Port A/V Port OrVOfl Switch Display ISP Programming Port LEDs. \ VGA Port (icmalc HQ-15 pint Oscillator VCCIO IspMACH 4064 Prototyping Area More analogue 3-axis accelerometers from Freescale Accelerometers are becom- ing mainstream technology for consumer applications that require low power con- sumption and advanced mo- tion sensing within a small form factor. Freescale Semi- conductor has expanded its low-g triple-axis analogue accelerometer product fam- ily to address this rapidly emerging trend in consumer electronics. The MMA7361 L, MMA7368L, MMA7341 L and MMA7331 L tri- ple-axis analogue accelerometers have tailored features designed to enable motion sensing in mobile phones, hard disk drives, media players, games and toys. The MMA73xxL XYZ-axis analogue accelerometers provide a self-test diagnostic feature that verifies the accelerometer is in working order at any time before or after it is im- plemented in design. All four de- vices are extremely flexible with a selectable 1.5- 12 g range to tackle various sensing functions, such as fall, tilt, motion, position- ing, shock and vibration for multi- functional applications. Consumer designers will find the MMA73xxL acceler- ometers ideal for use in cell phones and portable me- dia devices to provide func- tions such as tilt scrolling, gaming control, tap to mute and freefall hard disk drive protection. In addition to enabling mobile platforms, the MMA73xxL devices also can be used in consumer applications that require wireless sensing, such as enabling remote control LED lighting for home and indus- trial automation. www.freescale.com (080452-VIII) 12 elektor - 7-8/2008 Reduce prototype development and testing times to hours and min- utes with and compilers for various NICIIs. 1 CD-i fDr ' M" P^-oMppr T t? >: - CAN PIAT57T*, SUfe Ifpt is f r f-Sj nJ l:di *1 4 M i, 3 :-*nj|JT l 0 1 Q O CP A mu i twini D-OOOJ iwm; p-. HWi] bMf tbOlM n.-vin fo-Mwah ft + SPlLCMJpOliW.Chp ftWl ftn frftp.rfJkH. K tP+. DPPJl' £ pn ■ ■'. »■■ SFl_litrl..Srl I iu-£ f pA JjI u Li^pt ^olMdh m h hfatmcdi SFkJiMJn* ftjicl H-.iPrf ma la'r F-r^ri ta Itfr b^n m ‘ +h t»»[ mi j- WvP ., ■** A ** r SF1.ttiLR*M_D^« hfci^ xwipE-SP* «!d 5* Xi- co v-wi cl 15^ U Ltmtor* m "■ lftd_bWn||*-SI 14 : help you to dev application more and comfortably. ASCII Chary^SThan tool, partrtnarly useful when working with LCD display. USART Terminal is a tool for RS232 communi cation - baud rate con- trol, RTS and DTR com- mands... And many other tools are available as well: mikroBootloader, EEprom Editor, HID Terminal, Seven Segment Decoder, UDP Terminal. : Sfl agjriiH* nitniiMmiM ; i : z- i :■ ■ & t i : :■ : ! :■ : : 1. f |. f- i. M H f « F T- I- 1 1 ■ t+ 1 rilCww _1W_ Watch Window allows you to monitor program items during runtime sim- ulation. It displays variables and controller's SFR (Special Function Registers), their addresses and values. Values are updated as you go through the simulation. Statistics - After successful compiling, you can review detailed statistics on your code. Supporting an impressive range of microcontrollers, easy-to-use IDE, hundreds of ready-to-use functions and many integrated tools makes MikroElektronika compilers one of the best choices on the market today. Besides , mikroElektronika compilers offer a statistical module, simulator, for graphic dis- plays, , ASCII table, HTML code export, com- munication tools for SD/MMC, UDP (Ethernet) and USB, EEPROM editor, program- ming mode management, etc. SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD 1 11 mikroElektronika 3, A DEVELOPMENT TOOLS I COMPILERS I BOOKS http:// 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. kroe.com/ INFO & MARKET NEWS & NEW PRODUCTS Open-air metal alloy resistors are flameproof Providing design engineers with a robust current sense device for thermal conditions, IRC's OAR-TP series open-air sense resistors are ideal for use in high reliability serv- ers, lithium ion battery packs and open-frame power supplies. The resistors are constructed with a flameproof heavy gauge metal alloy, welded nodes and copper leads, and the long form factor dis- sipates heat at the solder joints. The OAR-TP Series resistors are also suitable for surge and pulse, feedback and low inductance applications. The OAR-TP Series open air sense resistors feature power ratings of 1 W, 3 W and 5 W, with TCRs to ±20 ppm/°C and tolerance to ±1% and ±5%. Inductance values are typically less than 1 0 nH. http://www.irctt.com/ (080452-VI) New Cypress PSoC (r) enables motor control and other applications Cypress Semiconductor Corp. supplies a new PSoC (r) mixed-sig- nal array with an enhanced ana- logue-to-digital converter (ADC) for fast analogue sampling and expanded 8 k Flash memory capacity for complex algorithm processing. The CY8C23x33, the newest member of Cypress's flagship PSoC family, targets ap- plications with rich feature and software content, ranging from motor control, to camera image engines, to powerline communi- cations (PLC) and more. The new CY8C23x33 device features an 8-bit successive-ap- proximation (SAR) ADC to allow a urn level of configurability to quick- high sampling rate of 375 Ksps. It ly adapt to changes in feature re- offers 26 GPIOs to deliver a premi- quirements. The device is available in a 5x5 mm QFN package to minimize board space. The CY8C23x33 PSoC devices feature four digital blocks, in- cluding two basic and two com- munication blocks, and four ana- logue blocks, including two con- tinuous time and two switched capacitor blocks. One of the device's digital blocks is a dedi- cated hardware PC block that enables fast and easy program- mability to reduce design time. www.cypress.com / psoc www.cypress.com / psoctraining (080485-11) Summer Circuits 2008 contributors rewarded! Flowcode for ARM is here Matrix Multimedia have recently launched a new version of their popular graphical programming language for microcontrollers - Flowcode for ARM microcontrol- lers. 32 bit ARM microcontrollers are now available for the same price as 8-bit micros but offer mas- sive advantages to developers: low power, more I/O lines, sever- al times more ROM and RAM than a typical 8 bit micro, full floating point and maths libraries and a massive increase in processing speed and power. This new ver- sion of Flowcode provides engi- neers and developers access to all of these features of the ARM based on Atmel's popular range of AT91 microcontroller range. Flowcode for ARM is also backwards com- patible with Flowcode for PlCmi- cro® microcontrollers and Flow- code for AYR® microcontrollers For the second year round, all free-lance contributors that made it into Elektor's Summer Circuits edition receive a present along- side payment, some paperwork (sorry for that!) and eternal fame in electronics land. This year we've Freescale Flexis™ JM USB Microcontroller Family development kits to send to those who responded successfully to our call for contributions published which provides an easy mi- gration route to 32 bit power. ARM hardware development tools, based on the Matrix's E- blocks range, are also avail- able. A fully functional demon- stration version is available on the Matrix web site. www.matrixmultimedia.com (080452-IV) over the period February through April 2008, on our websites and in the magazine. We're grateful to Freescale Semiconductor for sup- plying the kits. Congratulations everyone and keep sending us Summer Circuits items — the 2009 edition is wait- ing to be filled! Jan Buiting, Editor (080452-VII) 14 IX fQU IpU r M T t::; J.r-TT R “ h I C* □ f VTP" L DP H TNT, f PAI hi. Ivf X. T CPF R IhiT ■. TJL7I4? h EasyPIC5 Starter Packs — everything needed to learn about and develop with PIC microcontrollers from only £99 UNI-DS3 Universal Development System dsPICPR03 Development System PICPLC16B Control System PoScope Multi-Function Instrument LAP-1 61 28U Logic Analyser Leaper-48 Universal Device Programmer Robo-PICA Robot Experiment Pack NX-51 V2 Microcontroller Trainer IDL Series Circuit Labs Please see our website at www.paltronix.com for further details of these and other products We stock components, control systems, development tools, educational products, prototyping aids and test equipment Paltronix Limited, Unit 3 Dolphin Lane, 35 High Street, Southampton, SOI 4 2DF I Tel: 0845 226 9451 I Fax: 0845 226 9452 I Email: sales@paltronix.com Secure on-line ordering. Major credit and debit cards accepted. Prices exclude delivery and VAT. We also stock a range of probes and test leads suitable for use with the PoScope as well as money-saving bundles. We can supply all ZeroPlus logic analysers and advanced protocol decoding options. We also stock Leap device programmers for EPROM/ EEPROM/Flash EPROM, 8051 and PIC. The PoScope features a 16-channel logic analyser with I2C, SPI, 1-wire and UART serial bus decoding, dual-channel oscilloscope, pattern generator, spectrum analyser, chart recorder and square-wave/PWM generator in one low-cost instrument for £79. The LAP-1 61 28U from ZeroPlus is a powerful 16- channel 200MHz logic analyser with UART, I2C and SPI protocol decoding priced from £195. Further protocol decoding options available including 1-wire, Microwire, CAN, LIN, PS/2 and USB. The Leaper-48 is a USB- based universal device pro- grammer supporting an exten- sive range of memories, programmable logic devices, microcontrollers and digital signal processors at a low price of £295. Please see our website for full list of sup- ported devices. Four starter packs available, all of which include the EasyPIC5 development board, USB power/programming lead, blue backlit 16x2 character and 128x64 graphic LCDs, touch- screen overlay for GLCD, RS-232 lead, PIC16F877A 40-pin microcontroller and DS1820 temperature sensor plus manuals and software. EasyPIC5 Starter Pack - £99 Our EasyPIC5 Starter Pack is ideal for those wishing to learn about and program using assembly language or other makes of compiler. The pack contains the EasyPIC5 board, all required leads, character and graphic LCDs, touch-screen, PIC16F877A MCU and DS1820 temperature sensor. Exclusive to Paltronix, the pack also includes a getting started guide, tutorials and example programs — ideal for newcomers to microcontrollers. MikroElektronika’s EasyPIC5 development system simply must be the most versatile and best value PIC development system on the market. The board supports Flash-programmable devices in the PIC10F, 12F, 16F and 18F families in 8, 14, 18, 20, 28 and 40-pin packages and features a fast built-in USB2.0-based programmer. Also on the board are a useful range of I/O devices such as LEDs, pushbutton switches, potentiometers, RS-232 interface, USB and PS/2 connectors and provision for the easy fitting of character and graphic LCDs, touch-screen and DS1820 tempera- ture sensor (all of which are supplied in our starter packs). Clearly labelled DIP-switches and jumpers allow any I/O devices not being used to be disabled and all of the PIC’s I/O lines are available on IDC headers for easy expansion using MikroElektronika’s extensive range of add-on boards or for connection to your own circuits. Detailed documentation and example programs and our own getting started guide and tutorial make the EasyPIC5 ideal for beginners and experienced users alike. Work with various MCUs using one development board with the UNI-DS3. Currently supporting PIC, dsPIC, AVR, 8051, ARM and PSoC devices, the UNI-DS3 has a wide range of I/O features from £109 including main board and one plug-on MCU card. We stock all MikroElektronika development and add-on boards and PIC, dsPIC/1 6-bit PIC, AVR and 8051 compilers. We stock a large range of similar development systems for PIC, dsPIC, AVR, 8051, ARM and PSoC microcontrollers. A wide range of microcontroller and PC-based control boards and add-ons are also available. Start experimenting with robotics with the Robo- PICA robot experiment pack. Contains everything required to build various PIC microcontroller-based robot projects and carry out a large range of fun experi- ments for £89. Similar robot kits stocked based on 68HC1 1 , 8051 , AVR and BASIC Stamp plus large range of accessories. Other training systems available for microcontroller and electronics teaching. We have a large range of prototyping products from bread- boards to advanced digital and analogue circuit labs. o As featured in the May 2008 edition of Elektor magazine - Please note that our packs all include the LCD displays, touch- screen and DS1820 temperature sensor. EasyPIC5 BASIC Starter Pack - £149 EasyPIC5 C Starter Pack - £189 EasyPIC5 Pascal Starter Pack - £149 Get off to the best start with the EasyPIC5 and save money with one of our compiler starter packs, which include the contents of the above EasyPIC5 Starter Pack plus a full version of MikroElektronika’s mikroBASIC, mikroC or mikroPascal PIC compilers. These user- friendly compilers feature in-circuit debugging when used with the EasyPIC5 and also provide library routines to support all the EasyPIC5’s built-in I/O devices and optional add- on boards. The new dsPICPR03 is a development system for the dsPIC with advanced I/O and communications devices including RS-232, RS-485, CAN, Ethernet, real-time clock, SD card reader and displays. Starter packs priced from £149. The PICPLC16B makes an ideal platform for developing and implementing control and automation applications. This PIC microcontroller- based board has 16 relay outputs, 16 opto-isolated inputs plus RS-232, RS-485 and Ethernet interfaces for £99. Designed specifically for teaching 8051 microcon- troller interfacing and programming, the NX-51 V2 incorporates a useful range of I/O devices and comes complete with detailed example programs for £99. The IDL-400 Logic Trainer, IDL-600 Analogue Lab and IDL-800 Digital Lab all feature a large solderless breadboard, built-in DC power supplies, switches, displays and useful logic gates or test features and are priced from just £1 79. 7-8/2008 - elektor 15 INFO & MARKET ELECTRICAL SAFETY 1. Use a mains cable with moulded-on plug. 2. Use a strain relief on the mains cable. 3. Affix a label at the outside of the enclosure near the mains entry stating the eguipment type, the mains voltage or voltage range, the freguency or fre- quency range, and the current drain or curent drain range. 4. Use an approved double-pole on/off switch, which is effectively the ‘discon- nect device’. 5. Push wires through eyelets before soldering them in place. 6. Use insulating sleeves for extra protection. 7. The distance between transformer terminals and core and other parts must be >6 mm. 8. Use the correct type, size and current-carrying capacity of cables and wires - see shaded table below. 9. A printed-circuit board like all other parts should be well secured. All joints and connections should be well made and soldered neatly so that they are mechanically and electrically sound. Never solder mains-carrying wires directly to the board: use solder tags. The use of crimp-on tags is also good practice. 10. Even when a Class II transformer is used, it remains the on /off switch whose function it is to isolate a hazardous voltage (i.e., mains input) from the pri- mary circuit in the equipment. The primary-to-secondary isolation of the transformer does not and can not perform this function. In all mains-operated equipment certain important safety requirements must be met. The relevant standard for most sound equipment is Safety of Informa- tion Technology Equipment, including Electrical Business Equipment (Euro- pean Harmonized British Standard BS EN 60950:1992). Electrical safety under this standard relates to protection from • a hazardous voltage, that is, a volt- age greater than 42.4 V peak or 60 V d.c.; • a hazardous energy level, which is defined as a stored energy level of 20 Joules or more or an available continuous power level of 240 VA or more at a potential of 2 V or more; • a single insulation fault which would cause a conductive part to become hazardous; • the source of a hazardous voltage or energy level from primary power; • secondary power (derived from internal circuitry which is sup- plied and isolated from any power source, including d.c.) Protection against electric shock is achieved by two classes of equipment. Class I equipment uses basic insu- lation ; its conductive parts, which may become hazardous if this insulation fails, must be connected to the supply protective earth. Class II equipment uses double or reinforced insulation for use where there is no provision for supply protec- tive earth (rare in electronics - mainly applicable to power tools). The use of a a Class II insulated transformer is preferred, but note that when this is fitted in a Class I equip- ment, this does not, by itself, confer Class II status on the equipment. Electrically conductive enclosures that are used to isolate and protect a hazardous supply voltage or energy level from user access must be protec- tively earthed regardless of whether the mains transformer is Class I or Class II. Always keep the distance between mains-carrying parts and other parts as large as possible, but never less than required. If at all possible, use an approved mains entry with integrated fuse holder and on/off switch. If this is not avail- able, use a strain relief (Figure, note 2) on the mains cable at the point of entry. In this case, the mains fuse should be placed after the double-pole on/off switch unless it is a Touchproof® type or similar. Close to each and every fuse must be affixed a label stating the fuse rating and type. The separate on/off switch (Figure, note 4), which is really a ‘disconnect device’, should be an approved double- pole type (to switch the phase and neu- tral conductors of a single-phase mains supply). In case of a three-phase sup- ply, all phases and neutral (where used) must be switched simultaneously. A pluggable mains cable may be con- sidered as a disconnect device. In an approved switch, the contact gap in the off position is not smaller than 3 mm. The on/off switch must be fitted by as short a cable as possible to the mains entry point. All components in the primary transformer circuit, includ- ing a separate mains fuse and separate mains filtering components, must be placed in the switched section of the primary circuit. Placing them before the on/off switch will leave them at a hazardous voltage level when the equip- ment is switched off. If the equipment uses an open- construction power supply which is not separately protected by an earthed metal screen or insulated enclosure or otherwise guarded, all the conductive parts of the enclosure must be protec- tively earthed using green/yellow wire (green with a narrow yellow stripe - do not use yellow wire with a green stripe). The earth wire must not be daisy- chained from one part of the enclosure to another. Each conductive part must be protectively earthed by direct and separate wiring to the primary earth point which should be as close as pos- sible to the mains connector or mains cable entry. This ensures that removal of the protective earth from a conduc- tive part does not also remove the protective earth from other conductive parts. Pay particular attention to the metal spindles of switches and potentiome- ters: if touchable, these must be protec- tively earthed. Note, however, that such components fitted with metal spindles and/or levers constructed to the relevant British Standard fully meet all insulation requirements. The temperature of touchable parts must not be so high as to cause injury or to create a fire risk. Most risks can be eliminated by the use of correct fuses, a sufficiently firm construction, correct choice and use of insulating materials and adequate cool- ing through heat sinks and by extractor fans. The equipment must be sturdy: repeatedly dropping it on to a hard sur- face from a height of 50 mm must not cause damage. Greater impacts must not loosen the mains transformer, elec- trolytic capacitors and other important components. Do not use dubious or flammable materials that emit poisonous gases. Shorten screws that come too close to other components. Keep mains-carrying parts and wires well away from ventilation holes, so that an intruding screwdriver or inward falling metal object cannot touch such parts. As soon as you open an equipment, there are many potential dangers. Most of these can be eliminated by discon- necting the equipment from the mains before the unit is opened. But, since testing requires that it is plugged in again, it is good practice (and safe) to fit a residual current device (RCD)*, rated at not more than 30 mA to the mains system (sometimes it is possible to fit this inside the mains outlet box or multiple socket). * Sometimes called residual current breaker - RCB - or residual circuit cur- rent breaker -RCCB. These guidelines have been drawn up with great care by the editorial staff of this magazine. However, the publishers do not assume, and hereby disclaim, any liability for any loss or damage, direct or consequential, caused by errors or omissions in these guidelines, whether such errors or omissions result from negligence, accident or any other cause. 3-core mains cable to BS6500 1990 with three stranded conductors in thick PVC sheath Max current 3 A 6 A 13 A conductor size 16/0.2 mm 24/0.2 mm 40/0.2 mm Norn cond area 0.5 mm 2 0.75 mm 2 1.25 mm 2 overall cable dia. 5.6 mm 6.9 mm 7.5 mm Insulated hook-up wire to DEF61-12 Max current 1.4 A 3 A 6 A Max working voltage 1000 V rms 1000 V rms 1000 V rms PVC sheath thickness 0.3 mm 0.3 mm 0.45 mm conductor size 7/0.2 mm 16/0.2 mm 24/0.2 mm Norn cond area 0.22 mm 2 0.5 mm 2 0.95 mm 2 overall wire dia 1.2 mm 1.6 mm 2.05 mm 3-flat-pin mains plug to BS 1363A 16 elektor - 7-8/2008 *Th . t ’tw .Rfe*^, 4 'H WA |li« | PicoScope 5000 Series [JJ The No Compromise o PC Oscilloscopes 250 MHz bandwidth 1 GS/s real-time sample rate 138 megasample record length O With class-leading bandwidth, sampling rate* memory depth and an array of advanced high-end features, the PkoScope 500Q PC Oscilloscopes give yon the features and performance you need without any compromise. Advanced Triggers in addition to the standard rnggerMhe Periscope SOGft series rcmes w ■standard with pulit witfth, yvinj^w. drqpoOEp ddoy. -vid fag* kwi* triggering. Arbitrary Waveform Generator Define your awn waveforms or select tram 9 prcdr: fined signals.Wllh lhc 11 b*iC . 12 S MS/s arbitrary i^dvcfa-rnn generator. Waveform Playback Tool PicoScopc software now .illOwi yOv t& gO t?acb. review, ‘V And analyse up lo I COO captures w vvlihm its. waveform playback took Techiioiogv The Pk 9S»5? 3000 Series nf nsriliascdpcs from P*cp Technology indudes general purpose and h flh fcsc- u‘jop models: W^th 12 bil resolution and ^accuracy. the iOMh? PicoS^p* H34 i* able to deflect Ehnnfles. as small ns G.02-^ • (2-^jjpm) - making i( She KtepJ +-chaiwiii OKillasctpe fot analog design and anjdjrfiS, TN> higher 5pc<:d fi bit m oddi m ihc PtcoSwpe JDQQ I !■:■■. I .iMi: dimpling i ilq\ u;> 10 2QQMS/S ind Up to 1 MS/s record lengths r&T gHwaH purpose w Switch off Portb .4=1 waitus 5 loop On power-up the microcontroller sets the gate of the MOSFET (connected to out- put B.4) to 0 so that it conducts; a line- arly rising current then flows through the choke and LED. The voltage drop across the 0.1-0 shunt resistor is proportional to 7-8/2008 - elektor 21 this current. Once the nominal voltage is reached, the microcontroller switches off the MOSFET and waits a few milliseconds. During this time a linearly decaying cur- rent flows through the choke, LED, shunt and recovery diode. Then everything restarts and it happens all over again. The result is a direct current voltage with a tri- angular waveform overlaid. The Bascom program for the microcontroller (see List- ing) is short and simple to understand. Source code and hexfile for the program can be downloaded free of charge at www.elektor.com. In this circuit we use a 6-V lead-acid gel- cell battery for the power supply; although these are heavy, they are dependable and simple to charge. The 56-0 resistor and zener diode act to limit and stabilise the microcontroller supply voltage, which is used also as a reference voltage for the voltage divider set with PI. The LED chosen is a Luxeon LXHL-LW3C (nominal values: 3 watts, U lED = 3.7 V, / LED = 0.7 A). A 100-nF capacitor connected in parallel with the LED and shunt is wired direct to the PCB; this is to eliminate pos- sible interference effects from cable capac- ity. The 100-pF electrolytic capacitor is vital to smooth the 6 V operating voltage, which would otherwise 'droop 7 or 'sag 7 . The choke should not saturate at maximum current but match the load of the current being carried. To avoid generating square-wave effects that could produce false current values, the shunt resistor used should be a carbon film type, not wirewound. The lamp, used for speleology (cave explo- ration), has operated very reliably over a lengthy period and is more economical in battery use than a halogen lamp. One problem arose in use when the LED got (far) too hot. It appeared that the current cut-off value was not being observed, due possibly to microcontroller failure or a dirty (or faulty) trimpot. If the latter's wiper loses contact with the carbon track the compa- rator input becomes open-circuit and can become any old value (as then does the LED current). Installing a watchdog timer could help (to restart the microcontroller promptly), also a pulldown resistor from the comparator input to ground. ( 070963 - 1 ) Solar-powered Automatic Lighting C. Tavernier connector for solar panel charger R1 S S2\ ON T (override) rf 0 0 0 0 1 R2 +5V © R3 ■GO- 4 ~0 N i c C3 □ ^7 ji 1 15V C2 lOn R5 © GP5 GPO/ANO IC1 GP4/AN3 GP1/AN1 PIC12C671 GP3 GP2/AN2 SI OFF (override) n C4 'S lOOn R4 n 100n +5V -0 R6 1 I sJ 1 o 0) 4-> 0) TJ > U 0) j_ cc H— c P2 \ PI \ Ik lighting duration Ik threshold day/night -0-i 100n - 0 —* R7 LDR 080228-11 You're doubtless familiar with the little solar-powered automatic lighting units found in DIY stores each year as summer approaches, sold in packs at ridiculously cheap prices. They certainly work, but their electronics and most of all their housings, manufactured for extreme cheapness, have a life expectancy that's proportional to the purchase price... Our project here adopts a slightly different approach. It's intended for use in conjunc- tion with existing or still-to-be-built garden lighting systems, which in particular may be more powerful than the cheapo stuff mentioned above. The project described here cannot operate alone, but must be used in conjunction with the 'Solar-pow- ered Battery Charger' project described elsewhere in this issue. This charger has a connector already provided to interface directly with the garden lighting systems described here. So the charger handles the 'intelligent' charging of the battery by the solar panels, while the circuit shown here takes care of the control of the lighting part. Naturally, it includes a photocell, in the form of an LDR (light dependent resistor), to measure the ambient light and, to avoid wasting the pre- cious energy stored in the batteries, a pres- ence detector so as to only light up when there is a need. Furthermore, the detector has a time delay, which makes the lighting unit very convenient in practice. Given that it has to be used in conjunction with the solar-powered battery charger, the circuit is obviously very simple, as you can see from the schematic diagram. It uses just a single 1C, a Microchip type 12C671 PIC microcontroller - i.e. the same type used in the charger, to make your buying easier. Let's remember that this 1C includes an ana- logue-digital convertor with several inputs, which is obviously going to be put to good use here. It's powered from the stabilized 5 V supplied by the charger, via pins 3 and 4 of 22 elektor - 7-8/2008 the connector provided for this purpose. Take a look for a moment at the charger circuit and note that, when it is used in conjunction with the automatic lighting system, the jumper between pins 1 and 2 of its connector has to be removed. This allows relay Re2 in the charger to be driven by our automatic lighting system, instead of directly by the charger itself. So, the load fed by the automatic charger here com- prises the lamps or other lighting devices to be controlled. However, the excessive battery discharge protection is retained, as this information, from output GP4 of the charger's 12C671, is fed to input GP4 of IC1 via pin 2 of the connector. This same input also receives override (optional) switch SI, which makes it pos- sible to force the lighting off. Input GP3 also receives a switch making it possible to force the lighting on all the time, for exam- ple, when you want to admire or show off your garden at night, by overriding the presence detector circuit. The latter employs a ready-to-use off- the shelf module, since these days it's no longer worthwhile nor sensible to build such a unit from scratch. It's powered at 5 V and provides a logic high output when a presence is detected, which is connected to input GP3. Watch out! Different modules of this type currently on the market exist with various supply voltages and gener- ating high or low levels during detection. One module suitable for this application is available for example under reference PI8377 from Lextronic (www.lextronic.fr) where the author got it from. Some judi- cious online shopping may be in order to find a local equivalent The ambient light level is measured using an LDR connected to analogue input AN2, while adjustable potentiometers are con- nected to both inputs AN1 and ANO. Pre- set P2 allows adjustment of the day/night threshold according to the characteristics and positioning of the LDR used, while PI allows adjustment of the duration of the lighting following presence detection, from a few seconds to around ten minutes or so. The program for the 12C671 PIC is of course available for free download from the Ele- ktor website or from the author's own website: www.tavernier-c.com.The project works immediately and only requires cor- rect setting of PI and P2 as indicated above. Finally, it should be noted that that before it can be used with the automatic charger described elsewhere in this Summer Circuits issue, the charger must first be adjusted on its own, as described in the relevant article. In other words, do not connect up the two projects as you will be struggling with an equation with at least two variables that may interact in unex- pected ways. (www.tavernier-c.com) (080228-1) Web Links and Literature PI8377 data sheet: www.lextronic.notebleue.com/ ~lextronic_doc/pi8377.pdf Application notes for Cubloc™ modules (in French only): www.lextronic.fr/~lextronic_doc/ Applications_B.pdf Downloads The source code and .hex files for this project are available from www.elektor. com; file # 080228-1 .zip. Fog Lamp Sensor Harrie Dogge For several years now, a rear fog lamp has been mandatory for trailers and caravans in order to improve visibility under foggy conditions. When this fog lamp is switched on, the fog lamp of the pulling vehicle must be switched off to avoid irritat- ing reflections. For this purpose, a mechanical switch is now built into the 13-way female connector in order to switch off the fog lamp of the pull- ing vehicle and switch on the fog lamp of the trailer or caravan. For anyone who uses a 7-way connec- tor, this switching can also be imple- mented electronically with the aid of the circuit illustrated here. Here a type P521 optocoupler detects whether the fog lamp of the caravan or trailer is connected. If the fog lamp is switched on in the car, a current flows through the caravan fog lamp via diodes D1 and D2. This causes the LED in the optocoupler to light up, with the result that the phototransis- tor conducts and energises the relay via transistor T1 . The relay switches off the fog lamp of the car. For anyone who's not all thumbs, this small circuit can easily be built on a small piece of perforated circuit board and then fitted somewhere close to the rear lamp fitting of the pulling vehicle. (060384-1) 7-8/2008 - elektor 23 Battery Discharge Meter Christian Wendt Men like their hobbies. The author is a particu- lar fan of fishing, and like many anglers is the proud owner of not only a fishing rod, but also a boat: and this is where the electronics comes in. The author's boat has an electric outboard motor, and with his mind wrapped up in his sport it can easily happen that the battery is allowed to run down, leaving the not very enticing prospect of a long paddle home. Simple approaches, such as computing the optimal point to stop and turn round, are not really satisfactory, as angling involves the boat making a relatively large number of short hops. The author therefore decided to go back to first principles and find an electronic solution. Energy measurement In order to estimate and show the energy stored in the battery we need an LCD panel, a microcontroller and suitable sensors. In theory we need to measure time (easy enough) and voltage (also easy) as well as current. Energy dissipated in measurement should be minimised (trickier). The product of the three measured values gives electri- cal energy. Time measurement is straightforward on a microcontroller. Modern devices have an integrated analogue-to-digital converter which is accurate enough for measuring the battery voltage. It is harder to meas- ure current as the current drawn by the outboard motor is large and it is difficult to avoid dissipating a few percent of the Battery 6 K4 V +12V c O O ACS750SCA-050 FI SI O 1A F R2 IC2 L7805CP 3 ^7c Motor K5 +12V o ♦ 3 C3 lOn C13 IC1 13 12 11 _4 3 X 2 20MHz T T ! C2 15p +5V l o a > RA0/AN0/CIN+/ICSPDAT RC0/AN4 >RA1/AN1/CIN-/VREF/ICSPCLK RC1/AN5 >RA2/AN2/COUT/TOCKI/INT RC2/AN6 RC3/AN7 RC4 RC5 RA3/MCLR/VPP RA4/TiG/OSC2/AN3/CLKOUT |> RA5/T 1 C KI/OSC 1 /CLKIN C/3 C/3 > PIC1 6F676-I/P 070821 - 11 A 24 elektor - 7-8/2008 power delivered by the battery in heating up the shunt resistor. Fortunately there are current sensors avail- able for just this kind of application. The ACS750 [1] is essentially a thick piece of wire with accompanying Hall-effect sen- sor and conditioning circuitry. The series resistance is 130 pQ and so the voltage dropped across the sensor is very small. The 1C requires a 5 V supply and in the qui- escent state (no current flow) has an out- put voltage of 2.5 V. When a current flows this voltage will rise or fall, depending on the direction of flow. The version used here, the ACS750SCA-050, is linear from -50 A to +50 A with a transfer character- istic of 1 V per 25 A, ideal for feeding into the analogue-to-digital converter in the microcontroller. In this application voltage measurement is not so critical. The voltage should be monitored in case a fault (such as a bad connection) causes it to drop rapidly. Typically, however, the voltage remains fairly constant and it is adequate to dis- play the charge used in amp-hours (Ah), the unit normally used to express battery capacity. The capacity of the battery is best deter- mined experimentally: charge the bat- tery, do a few laps of a lake until the bat- tery is completely flat, and let the circuit tell you the capacity in Ah. Make a note of this value. It would be possible to extend the meter to allow the battery capacity to be entered, in order to provide a 'petrol gauge' display calibrated in percent. The circuit's 'user interface' consists of a single button which is used (among other things) to reset the Ah counter. If the but- ton is held down when the meter is turned on the counter will be reset to zero; if the button is not held down when the meter is turned on, it will start from the most recent stored value. Circuit(s) In the interests of reliable operation the circuit of the battery meter is divided into two parts. The normal arrangement is that the battery and motor are at the stern of the boat, while the captain is looking forward. A couple of meters of cable are therefore required between the two parts. Data transfer between the two parts of the circuit must be resilient to noise (even that generated by electric eels!). The author decided to use a microcontrol- ler both in the measurement part of the cir- cuit and in the display part, with an RS-232 serial link between the two. Conversion to standard voltage levels is done using a MAX232 at each end, as shown in the com- bined circuit diagram (Figure 1). On the sensor side of the system a PIC16F676 is used. It has analogue inputs with a resolution of 10 bits, which, tak- ing into account the effect of the voltage divider formed by R2 and R3, gives a res- olution of 20 mV for the battery voltage measurement. LED D1 is an under-volt- age alarm, lighting when the battery volt- age falls below 10.6 V. RAO of IC1 is con- nected directly to the output of current IC5 L7805CP £ 3 t > nAjL _ vcc C1 + IC6 Cl- TIOUT T1 IN T20UT T2IN RUN R10UT R2IN R20UT C2+ MAX232 GND m C2- LU > LCD1 EA DIP162 DNLED |p p CO lOOn QQQQQQQQQQQQQQl CO CM a co co co CO CM IC7 +5V’ l RA0/AN0 VDD RB0/INT RA1/AN1 RB1/RX/DT RA2/AN2/VREF RA3/AN3/CMP1 RB2/TX/CK< RB3/CCP1 >RA4/T0CKI/CMP2 RA5/MCLR/VPP RB4/PGM RB5 RA6/OSC2/CLKOUT >RA7/OSC1/CLKIN RB6/T10S0/T1CKI/PGC< RB7/T10SI/PGD to tfi > in 10 11 12 13 PIC1 6F628-20I/P J 1N4148 CM CO m K3 ^6 6 6 6 6 6 1 fk 070821 -11B 7-8/2008 - elektor 25 sensor IC2, giving a current resolution of approximately 125 mA. The measurement results then flow out of the serial port and via the MAX232 over the RS-232 link to the display. A PIC16F628 drives the display, polls push- button S2 and jumper J1, and receives serial data from the measurement unit. Contrast is adjusted using PI, and T1 switches the backlight on and off. With the suggested values for R6 and R8 the backlight current in the prototype was 38 mA. If more bright- ness is required, lower resistor values can be used as long as the maximum rating for the display (150 mA) is not exceeded. Each part of the circuit has its own regu- lated 5 V supply to improve overall reliabil- ity. The current consumption of the sensor part is approximately 20 mA, and the dis- play part draws approximately 17 mA with the backlight off. Circuit board A printed circuit board has been designed for each half of the circuit, making two small modules that can be connected together using a cable. The only unusual component on the sensor module (Fig- ure 3) is the current sensor. The copper tracks that run to it are wide and the tags are fixed to the board with assistance from plenty of solder tinning. Other slightly unu- sual sights are the miniature fuse with sol- der connections to the right and the six-pin PCB-mount mini-DIN socket to the left. This socket allows ready-made six-way cables to be used, and the miniature plugs also are conveniently able to pass through small holes. Cables with four-way plugs will of course not fit in six-way sockets. If you wish to use a different sort of con- nector, then you should of course dispense with the mini-DIN sockets. The important thing is to ensure that the 12 V supply is COMPONENTS LIST Sensor module Display module Resistors R1 = 4700 R2 = 3kO09 R43 = 1 kO Resistors R4,R5,R7,R9 = 2kQ7 R6,R8 = 560 R10 = 27kO PI = lOkO preset Capacitors C1,C2 = 15pF ceramic, lead pitch 5mm C3,C4 = 10nF ceramic, lead pitch 5mm C5 = lOOpF 25V radial, diameter 6.3mm C6,C7, C10-C13 = lOOnF ceramic, lead pitch 5mm C8 = lOpF 25 V, radial, lead pitch 2.5mm C9 = lOOnF ceramic, lead pitch 5mm Capacitors C14 = 220pF 16V radial, lead pitch 2.5mm, diameter 6.3mm C15,C16,C17,C19-C22 = lOOnF ceramic, lead pitch 5mm C18 = lOpF 25 V radial, lead pitch 2.5mm C23,C24 = 15pF ceramic, lead pitch 5mm Semiconductors D1 = LED, red D2 = 1N4001 IC1 = PIC16F676-20I/P, programmed, Elektor SHOP #070821-41 IC2 = 7805 IC3 = ACS750SCA-050 IC4 = MAX232 (DIP16) Semiconductors D3 = 1N4148 T1 = BC337 IC5 = 7805 IC6 = MAX232 (DIP16) IC7 = PIC16F628-20/P, programmed, Elektor SHOP #070821-42 Miscellaneous K1 = 6-way mini-DIN socket, PCB mount K4,K5,K6 = spade terminal 2 M3 screws and nuts FI = miniature fuse, 1 A, fast, for solder mounting SI = on/off switch Mini DIN cable with moulded 6-way plugs for connection of module XI = 20MHz quartz crystal, parallel resonance PCB, ref. 070821-1, from www.thepcbshop.com Miscellaneous J1 = 2-way pinheader and jumper S2 = pushbutton K2 = 6-way mini-DIN socket, PCB mount K3 = 6-way pinheader, lead pitch 2.54mm LCD1 = LCD, 2x16 characters, e.g. EA DIP162 DNLED X2 = 20MHz quartz crystal, parallel resonance PCB, ref. 070821-2, from www.thepcbshop.com provided on the cable along with ground and the RxD and TxD signals. The LCD panel is fitted directly to the sol- der side of the display module circuit board (see Figure 4). It is therefore best to leave soldering the display until last. Pin 1 of the display is marked 'LCD1' on the component side of the circuit board. As long as care is taken to observe this, noth- ing should go wrong with mounting the display. It is well worth fitting the two microcon- trollers in sockets in case you should want to alter the program at a later date. The dis- play board is equipped with a six-way con- nector K3 to allow in-circuit programming of the microcontroller. The software for each processor is as always available as source code (for Microchip's MPLAB) and as object code for free down- load from the Elektor website [2]. Operation When the unit is switched on using SI the 26 elektor - 7-8/2008 display will briefly show: Accu Control WEN May 07 and then subsequently: for reset press switch... 7 whereupon a seven-second countdown will start. The current state of the battery will then be displayed: its terminal voltage, instanta- neous current, and the remaining battery charge. If jumper J1 is fitted the zero point of the current sensor can be calibrated by up to ±10 units in the least significant digit. Every ten seconds the remaining charge value is stored in the EEPROM of the dis- play microcontroller. The display backlight is only enabled while the motor is running or by a brief press of the button. In his pro- totype the author used a waterproof Van- dal resistant' pushbutton. Something fishy No angler is properly equipped to go about his hobby without special glasses that include a polarisation filter to reduce the effect of light reflections from the water. As a result it is possible that the display can appear to be unstable and flickery: some- time legible, sometimes not. When he first saw this effect the author suspected a fault in the electronics or software and it was some time before he realised that the operation of LCDs depends on polar- ised light, and that the problem was right under (or rather over) his nose. ( 070821 - 1 ) Web Links [1] http://www.allegromicro.co m/en/Products/Part_Numbers/0750/ [2] http://www.elektor.com Peter Lay Here we take a light-hearted, exploring yet purposely unscientific look at one of the fundamental effects of physics, namely contact voltage. When two dissimilar materials come into contact an exchange of (negatively charged) electrons occurs so that the donor material losing electrons takes on a net positive charge while the material receiving electrons takes on a neg- ative charge, the overall effect giving rise to a contact potential. This effect occurs to a greater of lesser extent in all materials, the most common examples are the produc- tion of static electricity produced by rub- bing two different materials together and also the thermo-voltaic effect. So much for the theory, now to practice... To take what at first sight may seem like a mistaken example of this phenomenon we will need a discharged capacitor and a DVM (digital voltmeter) with a high input impedance. Connect the capacitor termi- nals to the DVM and short together the capacitor terminals using a length of wire and two crocodile clips. If all is in order the DVM display will read 0 (zero) volts. Now remove the short circuit and closely watch the DVM display as the voltage, microvolt by microvolt slowly rises. The capacitor is gaining charge from somewhere... This effect is the result of the contact volt- age (see diagram). In the capacitor there are two boundaries: (1) the metal electrode and the dielectric and (2) the dielectric and second electrode. At both boundaries free electrons pass from one material to the other. The two contact voltage sources are connected back to back in series which should cancel out the contact potential. So much for theory, in practice the boundary structure is not entirely homogeneous so that tiny potential differences are present. This produces the small potential difference that we can measure at the terminals. Aluminium electrolytic capacitors are a little more complex; one terminal is con- nected to aluminium foil which has an insu- lating oxide layer; next comes a layer of liq- uid electrolyte and finally another alumin- ium foil connected to the other terminal. This structure gives rise to three potential boundaries. In addition, when the capacitor is charged, free electrons from the terminal electrode store energy by producing elec- trochemical reactions within the electro- lyte (a process known as dielectric absorp- tion or 'soakage'). These effects are more pronounced in electrolytics compared to other types of capacitor. Experimental results indicate that the measured voltage is higher with larger value capacitors. It has also been shown that the voltage exhibits a temperature coefficient; the higher the temperature, the greater the measured voltage. To explore this characteristic further, a capacitor was carefully heated in a con- trolled manner. It is important not to use a naked flame or microwave oven; not just to prevent the possible melting or com- bustion of the external plastic casing, but more importantly to guard against the possible production and release of poi- sonous fumes. Once an electrolytic capac- itor has been heated up in this way it will be irreversibly damaged so that it will no longer be suitable for use in a circuit. Hav- ing said that, sometimes it's necessary to sacrifice a few capacitors for the sake of experimentation. Measurement with a DVM (/? f = 1 MQ) of a radially leaded electrolytic capacitor with a rated capacitance of 100 pF gave a terminal voltage of 5 mV at 20 °C. At a temperature of 120 °C the potential had risen to 230 mV and the short circuit current was 0.5 pA. More precise measurements of the capaci- tor indicated that the voltage source had a source impedance of 852 kO and a source voltage of 426 mV. As a first approxima- tion we can say that the correspondence between the terminal voltage and tem- perature is approximately linear. Using the measurements from the example above we therefore get a temperature coefficient of 2.25 mV/K. 7-8/2008 - elektor 27 Tests with other capacitors have produced a no-load terminal voltage of over 0.9 V. Several capacitors could be connected in series, not as a potential power source but as a sensor. Two final notes: 1. The term 'no-load voltage' ignores the 1 MO input impedance of the voltmeter, which in series with the 852 kO source impedance loads the measured potential. 2. All of the measurements were made using discharged capacitors with no exter- nal voltage source. (071 153 - 1 ) LED Tester Henry Schouwstra This simple LED tester consists of a cur- rent source with a potentiometer that can be used to adjust the current. The current source is implemented using a type TL081 opamp. The output current of the opamp flows through the diode and R2. The voltage drop across R2 is fed back to the inverting input and compared with the reference voltage, which is set with R1 and applied to the non-inverting input. The adjust- ment range is approximately 0-30 mA, which is suitable for testing all normal +12V LEDs. If you wish, you can connect a multi- meter across the LED to measure the volt- age on the LED. For the power source, a good option is to use a small laboratory power supply with the output voltage set to 5 V. It is convenient to fit the potentiometer with a scale so you can see directly how much current is flowing through the LED. In order to calibrate the scale, you can temporarily connect an ammeter in place of the LED. ( 080170 - 1 ) Wireless Audio Transmitter * D1 +12V C. Tavernier Sitting peacefully under a tree at the bot- tom of your garden, or stretched out beside your swimming pool, you may feel like listening to your favourite music from your hifi. Rather than turning the volume up beyond reasonable limits and risking upsetting all your neighbours or attract- ing the wrong audience, we suggest building this little wireless audio transmit- ter/receiver combination. Using the UHF ISM (industrial, scientific, medical) band and quality FM (frequency modulation), it won't impair the sound quality and will let you listen nice and discreetly. The transmitter uses a well-known module manufactured for some years now by Aurel as their 'FM audio transmitter'. It works in the licence-free 433.92 MHz band and so allows our project to operate completely legally as the transmitter is type-approved to quite strict technical specifications. Note however the frequency you're using is not exclusive as it is shared by many other wire- less devices such as headphones and key fobs for garage doors and so on. The equip- ment is low-power however and should have a short range. The Aurel module is a complete FM audio transmitter designed for powering from 28 elektor - 7-8/2008 12 V. The only external components required, R5, R6, and C5, form the pre- emphasis (high-boost) network specific to frequency modulation. Used alone, this module offers a typical audio input sensitivity of 100 mV rms. So we are driving it from an opamp with gain adjustable between 0.5 and 5, extend- ing the voltage range from 50 to 500 mV, to make it compatible with any audio device line output. Note in passing that, if you reduce resistor R1 to 2.2 kO, you can increase the sensitivity to 2.5 mV so that the transmitter could then be used as a UHF radio mic for use in shows and events, for example. The power supply can be obtained from a 12 V battery or a 'plug-top' power supply; diode D1 protects the circuit from reversed polarity by. The receiver is just as simple, since it uses the complementary module to the previ- ous one, again from Aurel, and naturally called their 'FM audio receiver'. This receiver has a squelch (FM noise silenc- ing) adjustment, set by the voltage applied to pin 15. Potentiometer PI connected to this makes it possible to adjust the squelch threshold so as to have a receiver that won't output noise in the absence of a sig- nal, using the information provided on pin 18. This is High when a signal is present and Low when absent. Here it drives an 8-into-1 CMOS analogue multiplexer, of which only input 8 is used. This solution employs a very cheap, good-quality analogue switch that is easy to use. Its output passing via the volume control P2 and is applied to the well-known small integrated power amplifier LM386. The transmitter's RF output power of a few hundred milliwatts is more than adequate for such an application, and its quality likewise, especially if you combine it with a loudspeaker worthy of the name, with a pair of headphones as the next best alternative. The Aurel receiver module and CMOS mul- tiplexer both require a 5 V supply; this is stabilized by a standard 3-terminal regula- tor. The circuit as a whole is powered from 9 V, and is also protected against possible reverse polarity by diode D1. Given the relatively high current consump- tion of the amplifier, especially if you use it for longer periods, rechargeable NiMH batteries will obviously be preferable to primary cells, which wouldn't last very long and will turn out rather expensive in the long term, as well as bad for the environment. As far as the antennas are concerned, for both transmission and reception, sim- ple quarter-wave whips ensure a range of a hundred metres or so - even more if line-of-sight. You can of course buy such antennas ready-made, but a simple piece of stiff wire around 17 cm long (i.e. a quar- ter wavelength at 433.92 MHz) will do the job just as well, and cost a lot less. Equipped with these two modules you can make the most of your music wherever you like. Don't forget, though, that outdoors, the best music of all is that of birds, that is, the feathered variety. (www.tavernier-c.com) (080232-1) Advertisement l-MMMOND l^r/l/MNUMCTURING Die-cast aluminium, metal and plastic enclosures. sales@hammond- electronics.co.uk 7-8/2008 - eleklor 29 Gas Flow Meter R. Pretzenbacher The most surprising thing about this circuit is the sensor that it uses: a 4.5 V miniature torch bulb. The glass envelope is (care- fully!) broken and then the pieces of glass removed, leaving just the filament intact. The filament forms the actual sensor ele- ment (see Figure 1). As you can see from the circuit diagram in Figure 2, the bulb filament is supplied with 20 mA from a constant current source, with the result that the filament warms up. The current, which can be adjusted using PI, is a compromise between the sensitivity of the unit and its operating life. If the current is too high the filament will reach too high a temperature and sooner or later will burn out. The filament has a positive, although relatively small, temperature coefficient of resistance: the hotter the filament the greater its resistance and so the greater will be the voltage dropped across it at a given constant current. If air (or another non-flammable gas) flows through the pipe in which the filament is mounted, the filament will be cooled and the voltage across it will fall. The greater the air flow the cooler the filament and so the lower the voltage. The relationship between flow rate and voltage is reason- ably linear. An important use of this meas- urement technique is in the air intake of car engines, where an ordinary thin heated wire is used as the sensing element in place of the lamp filament. Operational amplifier IC1.A is used to sub- tract the voltage drop across the coil from a voltage produced by the PICAXE micro- controller (IC3) via its PWM output on pin 5, filtered by the RC-network comprising R9 and C5. The second operational amplifier amplifies the residual signal as needed. The gain can be adjusted using P2. The PICAXE08M from Revolution Education Ltd is a PIC microcontroller that can be pro- grammed in BASIC (see www.picaxe.com). When power is applied the PICAXE auto- matically goes through the offset cali- bration procedure, which helps the unit achieve excellent sensitivity. Simultane- ously the measured voltage is digitised within the PICAXE. The result of the flow rate measurement is made available both as an analogue voltage (pin 7 of IC1.B) and in digital form on the TTL-level RS-232 out- put K1. The BASIC program that runs in the PICAXE is available for free download from the Elektor website at http://www.elektor. com, look for file # 070346-11.zip. The NE555 is present only to provide a small negative voltage of around -2 V for the LM358. This lets us use this low-cost operational amplifier in such a way that its output can swing down to 0 V. The NE555 inverter circuit allows the unit as a whole to be powered from a single 5 V supply. Using this circuit the author has obtained a usable output signal from 0 V to 3.5 V when measuring very gentle flows from 0 nl/h to only 120 nl/h. He used the circuit to check the operation of an industrial nitrogen (N 2 ) flow rate meter. It must be admitted that a circuit as simple as the one described here has a few infe- licities. The sensitivity of the unit is highly dependent on the filament used and on the current through the filament (although this is compensated for by the calibration that the PICAXE carries out). Also inconvenient is the strong dependency on the temper- ature of the gas whose flow rate is being measured. To compensate for this the gas flowing through the pipe must be heated to a defined temperature before being passed over the filament. And we cannot emphasise strongly enough: do not under any circumstances use this circuit with flammable gases! ( 070346 - 1 ) cm £ cc o Q. 30 elektor - 7-8/2008 QUASAR electronics Quasar Electronics Limit PO Box 6935, Bishops Stc CM23 4WP Tel: 0870 241 United Kingdp 6 1826 ed rtford m Fax: 0870 460 1045 E-mail: sales@quasarele Web: www.QuasarElectro ctronics.com nics.com osflB Postage 3-7 Day Europe SOrder We acc to Quas Call no project4 95 & Packing Op Delivery - £3. (EU) -£6.95; R4 online for reduc opt all major cr ar Electronics, for our FREE modules and w £9 ions (Up to 0.5 UK Mainland st of World - ed price UK Pc} edit/debit cards Prices include CATALOGUE publications. : UK Standard lery - £8.95; I) |r assembled ^nd ready for use (AS prefix). r, r 8-Ch Serial Isolated I/O Relay Module Computer controlled 8- channel relay board. 5A mains rated relay out- puts. 4 isolated digital inputs. Useful in a vari- ety of control and sens- ing applications. Controlled via serial port for programming (using our new Windows inter- face, terminal emulator or batch files). In- cludes plastic case 130x100x30mm. Power Supply: 1 2Vdc/500mA. Kit Order Code: 3108KT - £54.95 Assembled Order Code: AS3108 - £64.95 Computer Temperature Data Logger 4-channel temperature log- ger for serial port. °C or °F. Continuously logs up to 4 separate sensors located 200m+ from board. Wide range or free software applications for stor- ing/using data. PCB just 45x45mm. Powered by PC. Includes one DS1820 sensor. Kit Order Code: 3145KT - £17.95 Assembled Order Code: AS3145 - £24.95 Additional DS1820 Sensors - £3.95 each Rolling Code 4-Channel UHF Remote State-of-the-Art. High security. 4 channels. Momentary or latching relay output. Range up to 40m. Up to 15 Tx’s can be learnt by one Rx (kit in- cludes one Tx but more avail- able separately). 4 indicator LED ’s. Rx: PCB 77x85mm, 12Vdc/6mA (standby). Two and Ten channel versions also available. Kit Order Code: 3180KT - £44.95 Assembled Order Code: AS3180 - £54.95 DTMF Telephone Relay Switcher Call your phone num- ber using a DTMF phone from anywhere in the world and re- motely turn on/off any of the 4 relays as de- sired. User settable Security Password, Anti- Tamper, Rings to Answer, Auto Hang-up and Lockout. Includes plastic case. Not BT ap- proved. 130x110x30mm. Power: 12Vdc. Kit Order Code: 3140KT - £54.95 Assembled Order Code: AS3140 - £69.95 Infrared RC Relay Board Individually control 12 on- board relays with included infrared remote control unit. Toggle or momentary. 15m+ range. 112x122mm. Supply: 12Vdc/0.5A Kit Order Code: 3142KT - £47.95 Assembled Order Code: AS3142 - £59.95 PI it & ATM EL Programmers We have a wide flange of low ATMEL Programmers. Comply documentation available from Programmer Accessories: 40-pin Wide ZIF 18Vac Power su Leads: Parallel (LDC441) £3.95 / socket (ZIF40W) £14.95 pply (PSU010) £18.95 (LDC136) £395 /Serial USB (LDC644) £2.95 cost PIC and te range anc| bur web site. NEW! USB & Serial Port PIC Programmer USB/Serial connection. Header cable for ICSP. Free Windows XP software. Wide range of ;upported PICs - see website for complete listing. ZIF Socket/USB lead hot included. Supply: 16-18Vdc. Kit Order Code: 3149EKT - £39.95 Assembled Order Code: AS3149E - £49.95 NEW! USB 'All-Flash' PIC Programmer USB PIC programmer for all ‘Flash’ devices. No external power supply making it truly portable. Supplied with box and Windows Software. ZIF Socket and USB lead not included. Assembled Order Code: AS3128 - £44.95 “PICALL” PIC Programmer “PICALL” will program virtu- ally all 8 to 40 pin serial- mode AND parallel-mode (PIC16C5x family) pro- grammed PIC micro control- lers. Free fully functional software. Blank chip auto detect for super fast bulk programming. Parallel port connection. Supply: 16-18Vdc. Assembled Order Code: AS31 17 - £24.95 ATMEL 89xxxx Programmer Uses serial port and any standard terminal comms program. Program/ Read/ Verify Code Data, Write Fuse/Lock Bits, Erase and Blank Check. 4 LED’s display the status. ZIF sockets not included. Supply: 16-18Vdc. Kit Order Code: 3123KT - £24.95 Assembled Order Code: AS3123 - £34.95 www. QuasarElectronics. corn cure Online Ordering Facilities • Full Product Listing, Descriptions & Photos • Kit Documentation & Software Downloads 7-8/2008 - eleklor 31 RFID Door Opener Ralf Kiinstler The RFID-based project described here employs a specially-programmed 1C from the 'SFChip' (the 'SF' stands for 'Special Function') product family. The SF6107 [1] is an 1C designed to work as an RFID receiver for tags that operate on a nominal fre- quency of 125 kHz. Tags (or, more properly, 'transponder cards') compatible with the EM4102 contain forty bits of data and are available for a pound or two each. The support circuitry required for the SF6107 consists of just a couple of pas- sive components, two transistors, a hand- wound coil and, if desired, a DC buzzer. As the circuit diagram shows, a complete door opener, capable of recognising a mas- ter RFID tag and learning the codes of up to twenty further tags, is not very compli- cated at all. The 1C drives the coil via pin 3 and T1. Together with Cl, the coil forms a paral- lel resonant circuit. The cable linking the main electronics and the coil can be up to 80 cm long. If the coil is reasonably well adjusted, tags can be read at distances of up to about 3 cm. The voltage across the coil is demodulated by D2 and then passes via C3 to pin 6 on the 1C. An RFID tag in the vicinity of the coil absorbs energy from the field produced by the coil and uses it to subsequently trans- mit its stored ID code. The 1C compares this code against the values it has registered in its memory. If there is a match, T2 is driven on, which in turn activates the relay and then the door lock electromagnet. Simultaneously the 1C emits the ID code of the recognised tag in serial format on pin 2. Alternatively, for audio feedback a piezo buzzer can be connected to this pin. The buzzer will sound whenever the card that is being held next to the coil is recognised. After the 1C is reset (either when power is applied or by taking pin 1 briefly down to ground) the 1C emits status information on pin 2. This consists of a list of the stored trans- ponder ID codes preceded by their count. In the case of one master tag and two additional tags, the following might be output: #T3 #R00 : CC00154423 #R0 1 : CC00154427 #R02 : CC00154434 Each line is terminated by a 'CR' and an 'LF'. The first line gives the count of stored tag ID codes. There follow the individual ID codes, starting with the master tag. Each ID code consists often hexadecimal digits, making a total of 40 bits. The data transfer format is 9600 baud, 8 data bits, no parity and one stop bit. If a piezo buzzer has been connected to pin 2 it will emit a strange sound during any serial activity. If, instead of the piezo buzzer, a 10 kQ pull- down resistor is connected to pin 2, the sig- nal output will be suitable for connecting directly to pin 2 of a 9-way sub-D socket, which can then be taken to a PC using an ordinary serial cable. If, on the other hand, the serial output is to be taken directly to a microcontroller without level-shifting, a 10 kO pull-up resistor should be connected A to pin 2. The 1C checks which resistor is present at start-up and inverts its serial output if necessary. Use the following procedure to erase all the stored ID codes prior to reprogramming: 1. Switch the unit off 2. Fit JP1 (this pulls pin 5 to ground) 3. Switch the unit on 4. Wait ten seconds 5. Switch the unit off 6. Remove JP1 Now a master tag (any RFID card) can be read and its ID stored. Hold the tag up to the coil. Then take it away and bring it up 32 elektor - 7-8/2008 a second time: if the relay is activated then this means that the card has been success- fully programmed as the master and its ID code has been stored. To program further tags into the unit it is necessary to switch it into programming mode. This is done by holding the master tag up to the coil for around one minute. There then follows a twenty-second time window during which further tags can be programmed. Programming mode can be reentered as above to store further tag IDs, up to a maximum of twenty (plus the mas- ter tag). The circuit can be constructed using the printed circuit board shown, whose layout is available for download from the Elektor website. Current consumption with the relay off is around 16 mA. If a more powerful relay is to be used, drawing more than 100 mA of coil current from the 5 V supply, a BC337 should be used forTI. For optimum tag reading reliability and range the parallel resonant circuit consist- ing of the coil and capacitor should have as high a Q (quality) factor as possible. Coils made from 0.5 mm enamelled cop- per wire on a diameter of between 50 mm and 60 mm have given good results. These dimensions are not particularly critical, but it is important that the resonant frequency of the circuit is as close to the operating frequency of 125 kHz as possible. In our prototype we measured the induct- ance of a 30-turn coil with a diameter of 55 mm at about 100 pH. It was possible to read RFID tags with values of Cl between about 47 nF and 14 nF, corresponding to resonant frequencies of 71 kHz to 133 kHz. It is not necessary to have an oscilloscope to adjust the resonant frequency and Q factor. An ordinary digital voltmeter meas- uring the voltage across capacitor C4 (or at the cathode of D2) will do. Different values for Cl can be tried: the higher the meas- ured voltage, the better. With the correct COMPONENTS LIST Resistors R2 = 2MQ (or 2MQ2) R3 = 68kO R4, R5 = IkQ Capacitors C1*,C4 = 33nF C2 = 10nF C3 = 47nF C5 = 100 |jF 25V Semiconductors D2,D3 = 1N4003 T1,T2 = BC546* IC1 = SF6107 (www.sfchip.de) Miscellaneous J1 = 2-way pinheader with jumper BZ1 = piezo buzzer K2,K3 = 3-way PCB terminal block, lead pitch 5mm Rel = relay, 5V, type V23057* LI =100 pH inductor (30 turns 0.5mm ECW, 55mm diameter* PCB, # 071154-1 from Elektor SHOP or www. thepcbhop.com) * see text capacitance voltages of more than 8 V are possible. After these measurements have been car- ried out and the tag IDs have been pro- grammed into the unit, further tests can be carried out making small adjustments to Cl to obtain maximum reading range. ( 071154 - 1 ) Web Link [1] SF6107 information (in German): http://www.sma- tronic. mine.nu7SF6107.htm Bell Alarm Patric't Kindt If you use a lamp with a motion sensor for outdoor lighting, the original electri- cal switch is actually no longer necessary. If you replace the switch with the circuit described here, an acoustical signal will be generated each time the outdoor lamp is switched on. It's thus somewhere between an alarm and a doorbell. The operating principle is simple. A circuit that causes a voltage drop of only a cou- ple of volts is connected in series with the o lamp. As the circuit needs a DC voltage, the current for the lamp is passed through a bridge rectifier. The voltage drop across the circuit is determined by R1. The func- tion of Cl is to smooth the raw DC voltage. Note that this is not an example of peak rectification, but instead of averaging. For this reason, the voltage on Cl is lower than you might expect. Ultimately, the DC volt- age on Cl reaches the same value as the average voltage across R1. For example, consider what happens with a 100-W lamp. For convenience, we can assume that the lamp has a resistance of 529 O. If we ignore the voltage across the diodes and the voltage across R1, the current is approximately 0.39 A on aver- age (not 0.43 A). This is because the aver- age mains voltage is only 207 V = (230 x V2) -f- (tt/2). This yields a voltage of approxi- mately 8.5 V on Cl. As the buzzer and T1 only draw a few mi lliam peres from Cl, in practice the voltage will differ from this value by at most a few tenths of a volt. Here you should use a DC buzzer with a large operating voltage range. A good example is the CEP-2260A, which has a volt- 7-8/2008 - elektor 33 age range of 3-20 V (available from Digi- Key and other online sources). The charging time of C2 determines how long the buzzer remains energised, and here it will be a few tenths of a second. Depending on how much current the buzzer draws, you can increase the value of R2 in order to extend the time (this is cer- tainly necessary with the above-mentioned buzzer type). Depending on the lamp power, you can consider adjusting the value of R1. This will certainly be necessary if you use a 150-W lamp or larger. In this case, cut the value of R1 in half, primarily because the power dissipation will otherwise be too large. In the example described here, it is around 3 watts. The bridge rectifier also deserves special attention. A large current can flow briefly when the lamp is switched on 'cold'. A 250- V, 1.5-A bridge rectifier is adequate for a 100-W lamp, but heavier-duty diodes are necessary with higher lamp power - such as the 1N5408 (1000 V/ 3 A). Due to the heat generated by R1, make sure that R1 is located a certain distance away from the other components in the assem- bled circuit. Also bear in mind that the entire circuit is connected to mains poten- tial. Never make any adjustments while the circuit is connected to the mains! It's thus a good idea to test the circuit before fitting it into the switch box. ( 080169 - 1 ) Smart Chocolate Block LJ Edmund Martin What can be done, when two light bulbs in one light fitting are to be switched sepa- rately, but only one switch circuit is availa- ble? Simple: build a 'smart chocolate block' into the ceiling rose! The circuit is built from discrete components and with a bit of ingenuity can be fitted onto a printed circuit board measuring just a centimetre or two square. When light switch SI is operated for the first time lamp Lai, which is connected in the usual way, lights; La2 remains dark. Electrolytic capacitor Cl starts to charge via rectifier diode D1 and resistors R1 and R2 until zener diode D3 conducts, limiting the voltage to about 6.8 V. This voltage is used as a supply for the rest of the circuit. The second lamp is connected via a triac and a fuse (1.5 A, medium speed recom- mended). The triac is triggered by T4, which can only happen when T3 does not pull its base down to ground. The first time the cir- cuit is switched on this is the case, as we shall see below. Transistors T1 and T2 form a bistable flip- flop with a well-defined power-up state. R14 and R15 cause both transistors to be initially turned off. As the voltage across Cl rises, transistor T1, driven via resistors R7 and R9, turns on. The base drive for transistor T2, which is provided via D2, the low-pass filter formed by R6 and C2, and R5, would arrive a little later, but when T1 turns on it diverts the base current away from T2, which there- fore remains turned off. This situation is sta- ble: the base of T3 is not pulled down and so this transistor conducts. To turn the second lamp on, switch SI is opened and then, within a second or so, closed again. The effect of this action on the flip-flop is as follows. When the switch is opened the voltage across Cl falls more rapidly than the volt- age across C2. The main reason for this is resistor R3, which is directly responsible for the discharge of Cl; C2 can only discharge through the relatively high resistance of R5, 34 elektor - 7-8/2008 since the other path is blocked by diode D2. This means that T2 is driven via R5 for one or two seconds longer than T1 is driven via R7 and R9. If during this time the supply voltage reappears, it can no longer drive the base of T1 via R7 as T2 is conducting all the current to ground. This situation is also stable, as C2 is recharged via D2 and R6. When T2 conducts it pulls the base of T3 to ground, so that this latter transistor turns off. Darlington transistor T4 now conducts as its base is pulled high via R4. T4 now provides the trigger current for the triac via current limiting resistor RIO, and the second lamp lights. T5 and T6 together form a zero-crossing detector. It ensures that the triac is never triggered at a moment when the AC mains supply is at a high voltage point in its cycle. This avoids a rapid inrush current into La2, which would give rise to considerable radio interference. Also, trigger current is only required for the triac for a small fraction of the period of one cycle of the mains sup- ply. If this current were drawn continuously from the low voltage supply, Cl would rap- idly discharge; R1 and R2 would have to be considerably reduced in resistance, which would increase the heat dissipation of the module, perhaps making it infeasible to build the circuit into a plastic ceiling rose. Using the component values shown the triac is only driven when the instantane- ous mains voltage is less than about 15 V in magnitude. The voltage divider formed by R11, R12 and R13 switches on the transis- tors T5 and T6 when the voltage is greater than +15V or less than -15 V respectively. The collectors of these transistors, which are connected together, pull the base of T4 down to ground or to a slightly negative voltage when the mains cycle is outside the desired phase window. Any resistors across which mains voltages will be dropped are formed from two indi- vidual resistors wired in series to ensure that the maximum voltage specifications of ordinary 0.25 W components are not exceeded. This applies to R1 and R2, as well as R11 and R12. The whole circuit is at mains potentials and great care must be taken to observe all relevant safety pre- cautions in construction and installation. ( 070466 - 1 ) Hermann Sprenger The flash that is built into digital cameras is designed for indoor photography. At sub- ject distances of greater than five metres or so, the light is usually not powerful enough to take a satisfactory picture. Unfortunately most such cameras do not include a shoe for an external flashgun, and so a light-trig- gered slave flash is called for. The flash built into the camera produces a very rapid change in light intensity which is picked up by a phototransistor in the slave. The pulse is transmitted via Cl to the tran- sistor, which then briefly shorts the contacts on the slave gun together. The sensitivity of the device can be adjusted using PI. The circuit can be connected to the shoe con- tacts of the slave flashgun using a coaxial cable, or, with space permitting and a nim- ble bit of DIY, can be built inside it. The circuit is not suitable for use with flashguns which have a voltage of more than 20 V across the trigger contacts, or with cameras that emit a number of 'pre- flashes' before taking the picture proper. ( 080319 - 1 ) Operating Hour Counter Thomas Rudolphi These days there are all kinds of power/ energy meters available which can measure the power consumption and the operating costs of mains powered appliances. A pre- requisite is that the appliance has a mains plug. However, if the power consumption is known then the energy use of the appli- ance can also be determined in a much easier way. The operating hour counter for mains (230 VAC) appliances described here can measure the following, even in difficult to access places: 1. Number of times that it is switched on and off (up to 99999) 2. How long the load (lamp, fan, etc.) has been switched on (up to 99999:59:59 hours, resolution 1 s). Because the power consumption of the load is known and using the information from the PIC, the energy consumption can then easily be determined using a Micro- soft Excel file. The whole circuit is built around an 8-pin PIC12F682 processor. The circuit draws very little current, so that it can be powered directly from the mains via two series resi- stors of 68k each (R1, R2). Zener diode D1 limits the positive voltage to 5.6 V and the negative voltage to -0.6V. At the node R2/ D1 there is therefore a, more or less, square wave voltage. D3 and Cl provide a filtered voltage for the PIC processor. D2 ensures that at input GP2 with internal weak pull- up there is a square wave voltage of 5 V with a frequency of 50 Hz. 7-8/2008 - elektor 35 2 47|^^0V D3 H Cl 1N4148 0 Id GPO GP1 GP2/TOCKI MCLR/GP2 GP4/OSC2 GP5 PIC12C683 to (0 o 5 O N D2 ©l ji R1 1N4148 R2 > © CO CM 0J rC 58k IH 58k h D1 z 5V6 X I- m fo Ui DC J2 RESET R3 LED1 LEDIR 070349 - 11 The data is sent every second via IrDA using an IR LED and at a baud rate of 38k4. With R3 the current during the short pulse is limited to about 35 mA. With J2 the accumulated data can be reset (counter and time back to 0). To do this, the jumper has to be installed before the circuit is turned on, and it's removed again after the circuit is switched off. The software has been written with the freeware 'SourceBoost' C compi- ler (see web links). It has the following functions: - initialisation of the processor (init()) - writing the data to the internal EEPROM - deriving time information from the 50 Hz zero-crossings (RealtimeO) - sending of the IrDA data via an IR- LED (HandlelrDaCommunicationO) - power-down detection after which the time information is written to the inter- nal EEPROM. In the lnit() routine the processor is initiali- sed and the ON/OFF counter is incremented by one and the value is saved in EEPROM. It also clears the data in the EEPROM if the jumper is in place. The main loop (for(;;)) waits for the zero- crossing detection in the CheckZero- Cross() routine. As soon as this arrives the time information is updated in RealtimeO, which also sends part of the IrDA data every 100 ms. Only a small part of the data is sent to the IR-diode each time to prevent Cl from being discharged too much (relati- vely large current through the LED). The CheckZeroCrossO routine also checks whether the zero-crossing arrives every 20 ms. If not, then is the power has been switched off and the data has to be saved to the internal EEPROM as quickly as possible (before Cl discharges too deeply). With a Pocket PC (PDA) (always fit- ted with an IrDA port as standard) and a terminal program (for example Zterm/PPC, see web links) the data can be very easily read out. The (ASCII-) output is in the form: C=00000 H=00000:00:00 The circuit can easily (temporarily) be mounted inside, for example, a lamp fitting and must be connected in parallel with the load. ( 070349 - 1 ) Downloads The source and hex code files for this project are available as a free download from www. elektor.com; file # 070349-11.zip. Web Links Freeware C-compiler: www.sourceboost.com/CommonDownload/Binaries/ SourceBoostV6.85/sourceboostv685.zip Terminal program for PDA: www.coolstf.com/ztermppc Put that Light Out! R1 Cl R2 Stefan Hoffmann If you forget to switch off the light after leaving a seldom used room (such as the loft), there's a strong likelihood that it could remain lit for months, running up an expen- sive power bill in the process. How can we prevent this waste? It's not hard for electronics enthusiasts to design a little circuit to mitigate the effects of absentmindedness. The notion is simple; if the light is left on when the hatch or door is closed, a rhythmic sounder/buzzer signal produces an alarm that hopefully will not be masked by other noise. The circuit is powered as long as the lamp bulb is switched on by light switch SI. If the reed switch S2 then signals that the hatch has been closed, the sounder operates. The red LED, mounted outside the loft next to the entry hatch, also indicates that the lamp up there needs to be switched off. The circuit does not use a transformer, meaning that the whole circuit is at mains potential. For this reason the components must be placed inside an insulated plastic case for protection, with no way that people can touch any part of the circuit (this includes the sounder). 36 elektor - 7-8/2008 The connecting wires to the LED and the reed switch contact must be fully pro- tected to the same touch-proof degree too. For the sounder you can use any type that operates on direct current in the region between 1 V and 3 V. In this circuit the operating voltage is limited by the LED connected in parallel to the buzzer. Using a red LED will provide around 1.7 V to the sounder. The current requirement of this kind of miniature sounder is about 5 mA. (stefankhoffmann@yahoo.de) (080115-1) Post-box Monitor Mathieu Coustans Or "Has the postman been yet?" This project was born out of the idea of avoiding having to go out to the post-box on a rainy day to see if the postman has been. Whereas in the UK the letterbox is often a slot in the front door, very remote road-side post-boxes are common in other countries. Of course, it rains a lot less in Summer, but it does still happen — and always just when you're expecting an important letter; what's more, not everyone is on holiday, and loads of people go straight indoors without checking their post-box. It would be nice to have some way of dis- playing the status of the post-box. Until very recently, this type of (luxury) accessory was the privilege of private vil- las fitted with CCTV systems, the rest of us mere mortals not really feeling the need to spy on the postman using a CCTV cam- era. So the author decided to build a little circuit which is ridiculously cheap to build — in its most basic version, it ought not to cost more than about £ 3. The author's project was built on proto- typing board (perfboard) and uses only very standard components, the object of the exercise being to produce a simple but effective circuit. In its basic version, the cir- cuit in question remembers if the postman has been (it doesn't actually detect the postman, but any kind of post slipped into the post-box by lifting the flap protecting the opening) and can indicate this 'event' visually (an LED) or audibly (buzzer or vocal alarm based on the ISD25xx). However, that the author soon ruled out the latter option because of the noise pollution it generates and the noticeably higher current con- sumption compared with just an LED. Those readers who are keen to provide their system with a vocal-type alarm at any cost can take a look at the author's website, where he describes the system he used CD4013 truth table CL D R s Q Q Low>High transition 0 0 0 0 1 Low>High transition 1 0 0 1 0 High>Low transition X 0 0 Q Q Immaterial X 1 0 0 1 Immaterial X 0 1 1 0 Immaterial X 1 1 1 1 from the following supplier, before aban- doning it. Conrad Electronics sell a module the size of a chewing-gum leaf for around £ 6 [ 1 ]. A glance at the circuit shows how stagger- ingly simple it is. The central component is a CD4013 logic 1C (sequential logic), a D- type flip-flop with reset and priority set to '1', active high. You can find the truth table for the flip-flop in the inset. It's more com- plicated than it seems at first sight (CL = Clock, D = Data, R = Reset, S = Set, Q = Q output and Q = Q output). You can see that this is only triggered once on a rising edge. This edge is generated by the magnetic leaf switch, since the latter is sensitive to any significant variation in the magnetic field: the simple fact of opening the hinged flap of the post-box to put the post in can be used to produce a change of state in the reed switch. The diagram illustrates the respective positions of the reed switch and magnet. The author has all sorts of potential devel- opments in mind for his circuit. If the sub- ject intrigues you, why not drop by his blog [2] from time to time, to see how things are developing? — a basic knowl- edge of French is required, though. (080243-1) Web Links [1] Author's website: http://ludvol.free.fr/articles. php?lng=fr&pg=211 [2] Author's blog: http://lespace-electronique.blogspot.com 7-8/2008 - elektor 37 Lamp in a Wine Sebastian Westerhold Electronics need not always be a matter of dry theory or be taken with great seri- ousness. We were reminded of this by the author, who wrote to us to describe a very peculiar 'circuit': 'My other half Jessica is the kind of woman, rather rare on this planet, who takes a keen interest in the wonderful world of electronics and who shows great forbearance towards the hours I spend immersed in my hobby. For Christmas 2006 I gave her a soldering iron, a small set of too Is and a bundle of com- ponents. They went down rather well, and it was not long before LEDs were flashing away under the control of an NE555, 4017 and other bits and pieces. At some point in the following autumn Jes- sica asked me to come and look at her lat- est 'circuit'. On the way down to the cellar I imagined the possibilities for what might await me in my workshop. What I saw, how- ever, I never would have expected: each made from a resistor and a capacitor, artfully sol- dered together, a pair of earrings! And all RoHS compliant, of course.' The inventive project described here is also a product of Jessica's creative flair. The couple were experimenting with fill- ing wine bottles with water, and adding various chemical colourants. Then LEDs of various colours were submerged in the liquid, giving strange and beautiful light- ing effects. The ultraviolet-active dye 'fluo- rescein sodium' gives off an intense green light when stimulated using blue, or even better, ultraviolet, LEDs. Rhodamine B is another ultraviolet-active dye: in this case the emitted light is bright red. Both fluo- rescein sodium and Rhodamine B can be ordered via chemist's shops, or, more eco- nomically, over the Internet. Although the prices of these dyes may appear high, only very tiny quantities are needed: one gram of dye is enough for at least ten wine bot- tles full of water. Even more spectacular effects can be achieved using a full-colour RGB LED in conjunction with these dyes. The driver circuit, which is an ideal project for begin- ners, can be built on a small piece of per- forated board in half an hour or so. Being microcontroller based, the circuit is very compact. As always, the software is avail- able for download from the Elektor web- site at http://www.elektor.com. Ready-pro- grammed microcontrollers are also availa- ble: the order code is 080076-41. ( 080076 - 1 ) 38 elektor - 7-8/2008 SERVICING YD U R COMPLETE PROTOTYPE NEEDS 1 EUROCARD (160 x 100 mm) + Tooling + Photoplots + VAT €49 Price example Any size and contour possible! Optional: • Soldermask • Fast-turnaround • Silkscreen • 4-Layer Multilayer • 6-Layer Multilayer pwkmp QWt Freephone Q) 0800-3898560 rjH, kJS fuHUT How* Simply send your files A/IA Q/l/|| and order ONLINE: rV 0 " rVl/Wf V Wiwl High quality Gotti fietilhre Price dij 2 W/ d>4< »' a i l We add value to PCBs when others just sell it. - One Stop Manufacturing Service - Free Electronics Components - Free Prototyping Assembly - Professional Consultant Computer Vision CZ^ Principles and Practice IPRtr AlH 1- Computer Vision principles ond Pra«Ti« NEW! lettof ^jlektor ISHOP Computer vision is probably the most exciting branch of image processing, and the number of applications in robotics, auto- mation technology and quality control is constantly increasing. Unfortunately entering this research area is, as yet, not simple. Those who are interested must first go through a lot of books, publications and software libraries. With this book, however, the first step is easy. The theoretically founded content is under- standable and is supplemented by many practical examples. Among other subjects, the following are dealt with in the fun- damentals section of the book: Lighting, optics, camera tech- nology, transfer standards and stereo vision. The practical sec- tion provides the efficient implementation of the algorithms, followed by many interesting applications. 320 pages • ISBN 978-0-905705-7T-2 • £32.00 • US$64.00 Elektor Regus Brentford • 1 000 Great West Road Brentford TW8 9HH • United Kingdom Tel. +44 20 8261 4509 Order quickly and safe through www.elektor.com/shop 7-8/2008 - elektor 39 - Ufa Hanspeter Povel 'Pitch' is the name given to the angle of inclination of the rotor blades of a helicopter. In model helicopters the pitch angle is critically important to flight perfor- mance. Typical pitch values lie in the range from -3 degrees to +10 degrees. There are various ways to check and set the rotor blade angle. One method uses a flybar rod (which resembles the small auxi- liary rotor blade under the main rotor) set horizontal with the help of a spirit level, a protractor fixed to the rotor blade, and a plumb line. The method does work, but the rotor axis must be kept as vertical as pos- sible and the blades as horizontal as pos- sible to obtain an accurate measurement. As so often, a little electronics can make life a lot simpler. Searching for a suitable 1C, the author came upon the SCA100T inclinometer from VTI Technologies [1]. The device is a micromechanical sensor which measu- res angle on two axes using a capacitive method. The SCA100T-D01 has a range of -30 degrees to +30 degrees and a reso- lution of 0.0025 degrees. The measured angle can be read out in digital form over an SPI port. If we want to connect the device to a laptop or desktop PC, we need a suitable interface. A simple approach is to use a ready-made USB-to-SPI converter such as the 10-Warrior 24 from Code Mercenaries [2]. As the circuit in Figure 1 shows, this unit can drive two SPI ports simultaneously, and also sports an LED to indicate operation. The circuit diagram shown in Figure 2 therefore shows how two identical inclinometers are con- nected to the two SPI ports. si 6 o o o 0 0 0 1 SSI S2 Tr3 +5V 6 OOO 0 0 0 1 SS2 h^edi SCK MISO MOSI IC1 4_ 5_ 6 _ 7_ 8 _ 10 11 12 Cl □ 10(i 16V X C2 lOOn 14 VCC PO.O/RXD P0.4/SPI-SS/LCD-ON IIC-SCL/P0.1 P0.5/SPI-MOSI/LCD-RS IIC-SDA/P0.2 P0.6/SPI-MISO/LCD-R/W SPI-DRDY/P0.3 P0.7/SPI-SCK/LCD-E LCD-DB0/P1.0 P1.1/LCD-DB1 LCD-DB2/P1.2 P1.3/LCD-DB3 LCD-DB4/P1.4 P1.5/LCD-DB5 LCD-DB6/P1.6 P1.7/LCD-DB7 PullToGND D+ vreg IO-Warrior D ~ POWER 24 NC GND R1 H 1k3 [ 080101 - 11 MOSI 1 6 0 0 OOO i MISO GND1 R3 H iooqF R1 1 iooq| 1 SI R4 100Q R2 - — | loooh 1 7 3 10 Cl C2 □ lOOn 12 X 4(i7 16V MOSI © IC1 SCK CSB MISO SCA100T STX STY CX X Y CY 2 11 5 8 MOSI 2 6 OOO OOO 1 R7 H iooqF R5 1 iooq| 1 S2 R8 100Q R6 MISO_2 GND2 H iooqF i 7 3 10 C3 C4 □ lOOn 12 X 4(i7 16V MOSI © IC2 cx - SCK X - CSB Y - MISO CY SCA100T STX STY 11 080101 - 12 The completed module is shown in Figure 3. One inclinometer is screwed to a black guide plate in order to simplify attaching it to the rotor blade. The other inclinometer, which is mounted on a grey block, is attached to the flybar. The whole assembly is shown in Figure 4, attached to a model helicopter and ready to make some adjustments. The last piece in the jigsaw is some suitable software running on the host PC. Using the IO-Warrior hardware simplifies matters con- siderably in talking to the hardware, as lib- raries are available for download from the Code Mercenaries website to allow access 40 elektor - 7-8/2008 to the SPI data from programs written in C++ or in Visual Basic. The author plumped for the latter language, as a free develop- ment environment for it is available from Microsoft. He then wrote a short Visual Basic program to display the measured angles, rounded off to the nearest tenth of a degree. The two values measured are the inclina- tions of the flybar and of the rotor blade. The difference between these two values can be calculated to yield the pitch angle. Since the sensors measure angles on two axes, the less relevant values are shown in smaller text on the display. These values depend on the horizontal alignment of the model and should be less than ten degrees. The sign (positive or negative) of the dis- played results can be changed to suit the mounting arrangement with a click on the button marked '+/-'. The Visual Basic soft- ware is available as a free download from the Elektor web page for this project. ( 080101 - 1 ) Web Links [1] http://www.vti.fi/en/products-solutions/product- finder/search/motion.html [2] http://www.codemercs.com Smooth Flasher Burkhard Kainka Ordinary LED flashers turn the LED on and off abruptly, which can get a little irritat- ing after a while. The circuit shown here is more gentle on the eyes: the light intensity changes very slowly and sinusoidally, help- ing to generate a relaxed mood. The circuit shows a phase-shift oscillator with an adjustable current source at its out- put. The circuit is capable of driving two LEDs in series without affecting the current. The frequency is set by three RC networks, each of which consists of a 100 pF capacitor and a 22 kQ resistor. Operation is largely independent of sup- ply voltage, and the average LED current is set at about 10 mA. The circuit adjusts the voltage across the emitter resistor so that it matches the base voltage of the first transistor (around 0.6 V). The phase shifting network gives rise to the oscillation around this average value. In the prototype of this circuit we used an ultra-bright red LED. ( 080383 - 1 ) o - Deluxe "1 23' Game Stefan Hoffmann The rules of the '123' Game are described in the '123 Game - all MCU-free' article. Naturally, a more luxurious version can be built with a microcontroller. Here you don't have to manipulate a probe tip to play the game, and the playing field is formed by LEDs instead of mini-sockets. A microcontroller drives the LED array, and three input buttons take over the role of the probe tip. In contrast to the simple version, the built-in 'intelligence' of the microcontroller also allows two humans to play against each other. A 'welcome screen' with various LED patterns is displayed after the circuit is switched on. A bicolour LED then cycles through all three colours (red, green and orange) while waiting for the player to select a game mode: - Button 1: Human vs. MCU; human starts; - Button 2: MCU vs. human; MCU starts; - Button 3: Human vs. human. The course of play is essentially the same as before. The human player and the com- puter take turns moving by one, two or three steps. When it's the human's turn to move, he or she presses a button for the desired number of steps (T, '2' or '3'). The selection steps is confirmed by the '123' LEDs and then performed on the play- ing field LEDs. The bicolour LED is green when it's the human's turn and red when it's the computer's turn. Purely for effect, the computer does not move right away, but instead 'ponders' a while before mov- ing, and the moves are made slowly, step by step, instead of all at once. The number of steps the computer wants to move is also shown by the '123' LEDs. The move is then performed on the play- ing field LEDs. If the human player tries to move past the goal, this is corrected auto- matically. In the human vs. human mode, the bicolour LED turns orange to indicate that it's the opponent's turn. The winner is determined by the micro- controller. If the human player wins, the bicolour LED blinks green, and if the com- puter wins it blinks red. If the opponent wins, the LED blinks orange/red. A beeper gives extra lustre to the 'victory ceremony'. It gives a low beep if the human loses and celebrates a human victory with two high beeps. 7-8/2008 - elektor 41 SI £ BT1 4V5 s D33 D32 D31 R9 R8 S2 H R7 S3 11 S4 12 13 D34 DUOLED L X X 1 green RIO red R11 10 21 20 I! AREF VCC AVCC PC6(RESET) IC1 PCO(ADCO) PCI(ADCI) PC2(ADC2) PC3(ADC3) PC4(ADC4/SDA) PC5(ADC5/SCL) PDO(RXD) PDI(TXD) PD2(INT0) PD3(INT1) PD4(XCK/T0) PD5(T1) pd6(aino) ATmega8-P PD7(AIN1) PBO(ICP) PBI(OCIA) PB2(SS/0C1 B) PB3(MOSI/OC2) PB6(XTAL1/T0SC1) PB4(MIS0) PB7(XTAL2/TOSC2) PB5(SCK) GND AGND BZ1 23 24 25 26 27 28 14 15 16 17 18 19 8 22 B.O R1 H 1k5 [ < * ^^)26 * * ^^)27 ' * ^^)28 * * ^^)29 * * ^^ )30 B.1 R2 H 1k5 [ * ' ^^)21 * * ^^)22 * 1 ^^)23 * * ^^)24 * * ^^ )25 a n ^3 ™ R4 — I ik5 h B.3 1 1 R5 1 1k5 H B.4 ' ' ^^)16 * * ^^)17 * ’ ^^)18 * * ^^)19 * ’ ^^ )20 ^^)11 ° ^^)12 ° ^^)13 ° ^^)14 ° ^^ )15 B.5 R6 ° ^^)6 ° ^^)7 ^ U ' ^>10 ~^^)1 ^^)2 ^^)3 ^^)4 ^^ )5 C.4 C.3 C.2 C.1 C.O 080132- 11 The software for the ATmega8 was gener- ated using BASCOM, and it can be com- piled with the demo version. The BASCOM source code and a hex file can be down- loaded from the www.elektor.com — the archive file number is 0801 32-1 1 .zip. A pre- programmed microcontroller is also avail- able (order no. 080132-41). ( 080132 - 1 ) Temperature Sensor with 2-Wire Interface Stefan Dickel When designing a precision outdoor tem- perature sensor it is a good idea to elec- trically isolate the sensor from the signal conditioning circuitry to protect it from voltage spikes such as might be induced by lightning. Digital signal transmission is preferred over analogue as the circuitry is more straightforward, communication is more reliable and subsequent processing of the temperature readings is easier. In the design shown here the signal and the power for the converter circuit are both carried on just two wires. A type PT1000 temperature sensor is used. This is capable of withstanding tempera- tures of well over 130 °C (such as might be found in solar heating systems). The vol- tage dropped across the sensor is taken as input to an Analog Devices AD654 vol- tage-to-frequency converter. The power rail is then modulated with a square wave signal whose frequency is dependent on the measured temperature. The signal can be carried on a cable over a great distance. At the receiver end an optocoupler provi- des for electrical isolation. T1 forms a current source that delivers a constant current of 1 mA into the tempe- rature sensor R2. The current can be adjus- ted for calibration using trimmer poten- tiometer PI. The voltage across the sensor is taken to the VIN input (pin 4) of the vol- tage-to-frequency converter IC1. R4 and Cl are chosen so that the conversion factor is 10 kHz per volt. The temperature is given by the formula T = (f- 10000)/ 38 where T is the temperature in °C and f the frequency in Hz. The frequency therefore ranges from 8.8 kHz (at -30 °C) to 15.7 kHz (at +150 °C). The output transistor of IC1 has its collec- tor at pin 1 and its emitter at pin 2. Pin 1 is connected to the positive signal line via resistor R5, and pin 2 is taken directly to the negative signal line. The demodulation function is carried out by the circuit around T2. The value of the current sense resistor R6 is chosen so that when converter IC1 is in its quiescent (off) state T2 is not switched on. When the out- put transistor of the converter turns on, extra current is drawn from the supply via R5, making the total current drawn consi- derably higher. In turn, the voltage drop across R6 increases significantly and T2 is turned on. A large collector current now flows through R7, R8 and the LED inside optocoupler IC3. The phototransistor inside the optocoupler is now also turned on. 42 elektor - 7-8/2008 I Isolated Grounded I I Finally, at connector K4 the signal is avai- lable with a low impedance, suitable for further processing. So that we can arrange for the circuit to ope- rate from a single supply we use an isolating DC-DC converter. This not only provides the 12 V needed by the sensor circuit, but also offers up to 1000 V of electrical isolation. ( 080096 - 1 ) Harry Baggen These days many more audio-visual devices in the home are connected together. This is especially the case with the TV, which may be connected to a DVD player, a hard disk recorder, a surround- sound receiver and often a PC as well. it's highly likely that the PC has a TV-card, which again is connected to the same sys- tem. On top of this, there are many ana- logue connections between these devices, such as audio cables. The usual result of this is that there will be a hum in the audio installation, but in some cases you may also see interference on the TV screen. This often creates a problem when earth loops are created in the shielding of the video cables, which may cause hum and other interference. The surround-sound receiver contains a tuner that takes its sig- nal from a central aerial distribution sys- tem. The TV is also connected to this and The ground loop problem can be over- come by galvanically isolating the video connections, for example at the aerial inputs of the surround-sound receiver and the TV. Special adaptors or filters are sold for this purpose, known as video ground Video Isolator loop isolators. Good news: such a filter can also be easily made at home by yourself. There are two ways in which you can create galvanic iso- lation in a TV cable. The first is to use an isolating transformer with two separate windings. The other is to use two coupling capacitors in series with the cable. The lat- ter method is easily the simplest to imple- ment and generally works well enough in practice. The simplest way to produce such a 'filter' is as an in-line adapter, so you can just plug 7-8/2008 - elektor 43 it onto either end of a TV aerial cable. The only requirements are a male and female coax plug and two capacitors. The latter have to be suitable for high-frequency applications, such as ceramic or MKT types. It is furthermore advisable to choose types rated for high voltages (400 V), since the voltages across these capacitors can be higher than you might expect (A PC that isn't connected to the mains Earth can have a voltage as high as 115 V (but at a very low, safe current), caused by the filter capacitors in its power supply. These capacitors don't need to be high value ones, since they only have to pass through frequencies above about 50 MHz. Values of 1 nF or 2.2 nF are therefore sufficient. To make the isolator you should connect one capacitor between the two earth con- nections of the coax plugs and the other between the two signal connections. The mechanical construction has to be sturdy enough such that the connections to the capacitors won't break whenever the in- line adapter is removed forcibly. A good way to do this is to make a cover from a piece of PVC piping for the central part. Wrap aluminium foil round the outside and connect it to one of the plugs, so that the internal parts are properly shielded from external interference. Make sure that the aluminium foil doesn't make contact with the other plug, otherwise you lose the isolation. The majority of earth loops will disappear when you connect these filters to all used outputs of the central aerial distribution system where the signal enters the house. ( 080481 - 1 ) Stefan Hoffmann This is a reaction timer game between two players, red and green. Each player has a pushbut- ton in front of him that he must press at just the right moment: not too early and not too late. The aim is to be the first to press the but- ton. The 'right time' is indicated by a multi-colour LED. Each round of the game runs as follows: after a welcome pattern (flashing red and green, playing two tones), the LED starts to blink red slowly. A player who presses during this phase (too early) is 'punished' by a low-pitched tone and the lighting of the LED in his colour. Player 2 8 (5 t> IC1 RST/PB5 SCK/PB2 PB3 MISO/PB1 PB4 MOSI/PBO ATtiny13 a JR2 Cl I"- After a random time period the LED turns yellow. The first to press dur- ing this period is the winner and is rewarded by a rapid flashing of the LED. If the LED goes out again before either player has pressed his button, it is too late and another round of the game starts. As a glance at the well-commented source code for the microcontrol- ler software shows, the sequence of events and their timing can eas- ily be adjusted as required. Source and object code files are as usual available for free download from the Elektor website (http://www. elektor.com). Ready-programmed microcontrollers are also available. ( 080118 ) Joseph Kreutz 48 V 'phantom' powering has become the standard for professional condenser microphones. The supply (or rather bias) voltage is applied over both wires of the balanced screened cable via two 6kQ8 resistors (see reference [1]) - the abso- lute value is not critical, since a variation of ±20% is permitted, but they must be matched to an accuracy of 0.4% or bet- ter [2]. Many microphones are fitted with an output transformer, and derive their power from a centre tap on the secondary. If the currents supplied by the two wires of the balanced line, which flow in opposite directions through the two halves of the secondary winding, are not identical, the magnetic fluxes they induce in the core of the transformer do not cancel out prop- erly, and spurious magnetization occurs, causing distortion and a reduction in the microphone's dynamic range. With an output current of 0.4 A, the PSU described in this article can 'supply' at least 40 microphones. The mains voltage is applied to a 30 VA transformer which sup- plies 24 V rms . Its secondary feeds a voltage doubling rectifier formed by diodes D1 and D2 and capacitors C3 and C4. Capacitors Cl and C2 suppress the switching noise pro- duced by the rectifier diodes. This volt- age-doubling rectifier provides around 72 VDC, and so offers an adequate margin to allow for ±10% fluctuations in the mains voltage. Voltage regulation is taken care of by 44 elektor - 7-8/2008 TL783KC regulator IC1 on which an abun- dant amount of information may be found at [3]. Basically, this is an adjustable regula- tor in a TO220 package that offers excellent residual ripple and low noise on its output voltage. The TL783KC regulator includes a MOS series pass transistor and accepts an input voltage of up to 125 V, making it an ideal candidate for this application. Diodes D3 and D5 respectively protect the PSU against transients at switch-off and reversed polarity. The output voltage is set by resistors R1 and R2 according to the formula: V ou t = V ref x(1 +R2/R1) where reference voltage V ref = 1.27 V. D3 These resistors should preferably have a tolerance of 1%, and R2 is likely to dis- sipate 0.5 W. Resistor R3 provides a mini- mum load that is vital for maintaining the PSU's off-load voltage at 48 V, and is also used to supply LED D4. If the LED is not used, R3 must without fail be connected to ground. Last but not least, regulator IC1 must be mounted on a heatsink with a thermal resistance of less than 1.5 °C/W using the standard insulating kit: top-hat insulating washer, mica washer, and heat sink com- pound... make sure you use enough, but not too much! ( 070602 - 1 ) Bibliography and Web Links [1] Microphone Essays, p. 83. Jorg Wuttke, www. schoeps.de/E-2004/miscellaneous.html (11 MB document in German, downloads via links at bottom of page) [2] DIN EN 61938 standard [3] http://focus.ti.com/docs/prod/folders/print/tl783.html [4] http://en.wikipedia.org/wiki/Phantom_power Discrete PWM Generator Alexander Wiedekind-Klein PWM waveforms are commonly used to control the speed of DC motors. The mark/space ratio of the digital wave- form can be defined either by using an adjustable analogue voltage level (in the case of a NE555 based PWM generator) or digitally using binary values. Digit- ally derived PWM waveforms are most often produced by the timer/counter modules in microcontrollers but if you do not want to include a microcontrol- ler in your circuit it's also quite simple to generate the signals using discrete logic components. An extension of the circuit shown can produce two PWM wave- forms from an 8-bit digital input word. Each signal has 15 values. The 8-bit word can be produced for example from an expansion board fitted in a PC or from an 8-bit port of a processor which does not have built-in PWM capability or from a laptop's printer port. +5V 070378 - 1 1 The mark/space ratio is only programma- ble up to 15/16 rather than 16/16; a binary input of 0000 produces a continuous low 7-8/2008 - elektor 45 on both outputs turning both motors off. Similar circuits often employ a dedicated 'enable' input to turn the motors off but it is not necessary in this design. The diagram shows the circuitry required to produce just one waveform. For the full two channel circuit it is necessary to use an additional 74HC193. The clock signal pro- duced by the HCF4060 generator can be used to drive both channels and the free flip flop in the 74HC74 package can be used for the second channel (the corresponding pin numbers are shown in brackets). Alto- gether the entire two channel circuit can be built using just four ICs. ( 070378 - 1 ) Simple One-wire Touch Detector Lars Nas This simple circuit can be used to activate whatever you like, for example, by con- necting it to microcontroller, relays, secret alarms, robot applications or just turn on LED1 which lights up as long as you touch the metal plate. The circuit consists of voltage divider R1 and R2, one Schmitt trigger/inverter gate from a 40106 1C, a small capacitor to keep strong RF at bay and LED1 with current lim- iting resistor R3. The metal plate is connected via a wire to R1. R1 and R2 together form a voltage divider. Since the current from your body is very small it's understood that R2 has a high value like 10 Megohm to maximise the voltage over R2 so it can be detected by input pin 1 of gate IC1.A. R1 has been added to prevent electrostatic discharge (ESD) energy from damaging the inverter gate input. ESD may occur when you have been charged with an amount of electro static energy by walking on a carpet with rubber soles. You can increase the sensitiv- ity of the detector by experimenting with lower values fore R1 e.g. 1 kO and a smaller metal plate. The value of pull-up resistor R3 is calcu- lated such that the current through LED1 is below its maximum continuous rated value. Most regular LEDs are 20 mA types. The circuit still works if you remove LED1 and just have the pull-up resistor R3 con- nected to output pin 2 and then connect a microcontroller input pin directly to pin 2. Do check however that the microcontrol- ler has a weak pull-up (i.e. to +V DD ) at its port line. ( 080057 - 1 ) Solar Cell Voltage Regulator Reuben Posthuma This device is designed to be a simple, inex- pensive 'comparator', intended for use in a solar cell power supply setup where a quick 'too low' or 'just right' voltage indicator is needed. The circuit consists only of one 5- V regulator, two transistors, two LEDs, five resistors, two capacitors, and one small battery. Although a 4-V battery is indicated, 4.5 V (3 alkalines in series) or 3.6 V (3 NiCd cells in series) will also work. The specifications of voltage regulator IC1 are mainly determined by the size and number of the solar cells and the current pull of the equip- ment connected to the output. Here the low- drop 4805 is suggested but other regulators may work equally well as long as you observe the output voltage of the solar cells. Transistors T1 and T2 are complementary types i.e. one each of the pnp and npn vari- ici ♦ 46 elektor - 7-8/2008 ety. Although the ubiquitous BC557B (pnp) and BC547B (npn) are indicated, any small- signal equivalents out of the junk box will probably do. The values of voltage dividers R1/R6 and R3/R4 may need to be adjusted according to the type of transistor and its gain, or according to the desired volt- age thresholds. Using the resistor values shown in the schematic, LED D2 turns on fully when the voltage is just above 5 volts. LED D1 turns on when the voltage drops below 4.2 volts or so. Between those two thresholds, there is a sort of no man's land where both LEDs are on dimly. A buzzer or other warning device could be connected across the terminals of LED D1 to give a more substantial warning if the voltage drops below operating limits. The current consumption of the circuit is about 20 mA at 5 V, and it decreases with the voltage supplied by the solar cells. ( 080453 - 1 ) Minimalist Oscilloscope Burkhard Kainka If you are the proud owner of an old oscilloscope tube, you may be interested in using it once more for its original pur- pose. All you need are the right voltages on the right pins: in practice you may need to peer closely inside to find out which pins on the base correspond to the acceleration and deflec- tion electrodes, in particular if there is no part number to be seen on the tube. The tube we had for experimental purposes was a 7 cm model of unknown provenance. So the first step is to establish which pins correspond to the heater, cathode, grids, deflection plates, and anode. With this done we can make our simple oscillo- scope as follows: connect the Y input via a suitable capacitor to one of the Y deflection plates; for X deflection we use a neon lamp oscil- focus regulator circuit we have a complete lator to generate a timebase; and with a oscilloscope. Operation of the horizontal deflection oscillator is visible as the gentle flickering of the neon lamp. Whenever the voltage across the parallel-connected capacitor reaches the strike volt- age of the lamp, it is discharged with a brief pulse of current. It is hard to imagine a simpler way to generate a sawtooth waveform. The supply voltage of 300 V is adequate for simple experiments, even if the tube is rated for oper- ation at 1000 V or even more. Now, if a signal is applied to the Y input, we should be able to see the waveform on the screen. It must be admitted that the design's sensitivity, linearity, trace size, bandwidth and trig- gering facilities leave a little to be desired. Nevertheless we have shown how little circuitry is required to make a real working oscilloscope. ( 080386 - 1 ) Advertisement Your price conscious PCB supplier EURO CIRCUITS Online price calculation Online ordering Online order tracking Online 24/24H and ?/?o Interested? Contact us: +44 2088 167 0 05 E-mail: euro@eurocircyits.com www.eurocircuits.com A la carte pooling for standard hoards up to 6 layers from 1 to 1000 pieces from 3 working days onwards - pooling with more options - up lo 3 layers - from 1 to 1000 pieces - from 3 working days onwards your board, our challenge up to 16 layers from 1 piece onwards from 3 working days onwards 7-8/2008 - eleklor 47 Underwater Magic XCypHanbi co scero Mupa htt p ://r- po i nt.nnm. ru www. jo u rn a l-p I aza.net LudovicMeziere If we were looking for a slogan to sell this project in some mail- order catalogue, we might erators drive three groups of high-bright- ness red, green, and blue LEDs using an 8- bit word per colour - which theoretically gives the possibility of lighting the water in 16 million different shades. Circuit A quick glance at the circuit might make us wonder if the designer hasn't forgotten something, given the excellent 'readabil- ity' of the electronics employed. A micro- well have chosen the slo- gan "16 Million Colours in the Water in Your Swimming Pool" as its subtitle. In just a few months, we've seen increasingly 'visible' applications for (high) power LEDs. After all, was it not Philips that paid for the illumina- tions on some of the most famous ave- nues in the world? The author of this project took it into his head to give a festive look to his swimming pool as cheaply as possible. The use of a ready-made PC PSU module to supply the power makes it possible to reduce the over- all cost of this project very significantly. Principle Three PWM (pulse width modulation) gen- controller and no less than three strips of ten or so LEDs, each with its own dropper resistor. Each strip is driven by a transistor, and there you have all the ingredients of this recipe. The potential of microcontroller IC1, an AT90S8515P from Atmel, is admittedly under-exploited, but the choice of it is jus- tified by the presence of three PWM drivers in the same package, as well as by its very affordable price and excellent availability. The board has an ISP connector (In System Programming), K2, to allow for future soft- ware updates. The three PWM outputs drive type IRFI540NPBF MOSFET transistors T1-T3, which have a power dissipation rating that's easily sufficient for this application. You may like to fit them with a small heat- sink, which will be enough to dissi- pate the small amount of heat produced by the transistor switching. These tran- sistors each drive ten or so LEDs. The spot draws a whopping maximum current of nearly 10 amps at 5 V, mean- ing that a power- ful PSU is needed. Building one yourself would turn out expensive. So the solution to this cost issue is to opt for a PC PSU module, which usually has no problems providing some 30 A at 5 V, for only a mod- 48 elektor - 7-8/2008 est sum. And there you have it — every- thing has been said that needs to be about the electronics employed. The aspect we're going to tackle in the next paragraph is very important, given its implications... Construction As shown in the introductory photo, the whole of the electronics fits onto a pair of printed circuit boards. The LED board is round so it can be fitted easily into a cylin- drical body that will conveniently slide into a masonry orifice provided for it in the wall of the swimming pool. The second, smaller board is rectangular, with truncated cor- ners, and it carries the power electronics. The dropper resistors in the LED sup- ply lines also act as spacers for the two boards. The first step in construction is to fit the thirty LEDs on the track side of the round board. Take care to get the polar- ity correct. This done, we end up with a board as shown in the second photo. You can then move on to fitting the resistors, which should be pushed fully home into the holes provided for them on the LED board and then be soldered into place. The 3 remaining adjacent lands close to the microcontroller and marked '+5V' should be fitted with a piece of insulated solid wire the same length as the final spacing of the two boards. Now it's time to move on to building the controller board. IC1 could be fitted into a socket (with spring contacts) just in case. Start by soldering the smaller components, capacitors, diode (only fitted if the voltage supplied by the PC PSU is being increased, see next paragraph; otherwise replaced by a wire link). Next, fit the transistors (paying attention to their orientation - their heat- sinks should face the outside of the board) and socket K2 (fitting it later once the two boards are piggy-backed is tricky because of the difficulty of access under the con- troller board). Once the two boards are built and after having taken the trouble to check your work, you'll be able to mount the con- troller board piggy-back onto the LED board, taking care to leave a certain dis- tance between them so as to ensure a lit- tle air circulation (confined). To do this, all you need do is to slip the leads of the 3 W resistors fitted to the LED board into the corresponding holes all round the edge of the controller board. This operation requires a certain dexterity; you can insert the leads of the first row of resistors, then angle the board slightly so as to insert the leads of the next resistors, cut 2 or 3 mm shorter, and so on. Once all the resistors are in place, you can solder them and trim the leads off. © © K1 +5V © -O D1 +5VMCU © w 1N4004 39 38 37 36 35_ 34 33_ 32_ 30_ 3 1 21 _ 22 _ 23 24 25 26 27_ 28 C2 1000|a 16V 40 X (5 5 PAO PBO PA1 PB1 IU1 PA2 PB2 PA3 PB3 PA4 PB4 PA5 PB5/MOSI PA6 PB6/MISO PA7 PB7/SCK ALE RESET ICP OC1B AT90S8515P PCO PDO PCI PD1 PC2 PD2 PC3 PD3 PC4 PD4 PC5 PD5 PC6 PD6 PC7 PD7 XTAL1 -1- XTAL2 ‘19 20 ‘18 29 10 11 12 1 3 14 15 16 17 +5V +5V D2 ... Dll = red ) — £H D2 D3 D4 D5 D6 D7 D8 D9 D10 Dll L L L L L L L L L L TTTTTTTTTT ci 10n 5 T1 s IRFI540NPBF +5V ©- +5V D12 ... D21 = green J— < > l > < > < > l > i > < > < i 1 > D12 D13 D14 D15 D16 D17 D18 D19 D20 D21 K2 O O 3 4o o o o o o o o © 10 TR12 TR13 TR14 J[R15 j[R16 J[R17 J[R18 j[R19 J[R20 JrI TTTTTTTTTT Ja T2 s IRFI540NPBF +5V ©- +5V -0- D22 ... D31 = blue ) — < i < i ( » 1 i < i ( » 1 i < i ( i D22 D23 D24 D25 D26 D27 D28 D29 D30 D31 7R21 TR22 TR23 \R24 \R25 \R23 \R27 \R23 \R23 J[R30 TTTTTTTTTT a T3 s IRFI540NPBF 071037-11 7-8/2008 - elektor 49 Now let's move on to the PC PSU module, which needs a little 'check-up' - in fact, it needs a slight modification: its green lead (signal: ps_on) must be connected to ground to enable the power supply to start up. Keep only all the black leads (ground) and all the red leads (+5 V) — the other output wires/leads can all be cut off. The available power supply allowing, it's worth increasing the 5 V level up to 5.6 V by adjusting the potentiometer in the reg- ulator circuit - this will increase the bright- ness of the LEDs a little bit. If the voltage is increased in this way, the microcontroller supply is brought back down to 5 V by the use of series diode D1 in the microcontrol- ler supply line. Clearly, if the voltage is not adjusted, D1 should be omitted and a wire link fitted in its place. This done, the 5 V lines from the PC PSU can be connected to the controller board. It is fitted with a connector, K1, for this purpose, in the form of a pair of pins. Take care to correctly identify the positive (+, closest to the silk-screened legend K1 and the micro- controller) and negative poles (-, the other pin). The three points marked '+5V' should have already been connected to the match- ing points on the LED board when the two boards were connected together. Now all that remains, after checking the quality of your work one last time, is to try it out for the first time. Whatever you fancy, don't look straight at the front side of the LED board (to see if all the LEDs are work- ing!). It should be obvious if it's working OK, the light will gradually change colour. But don't expect to be able to see all 16 million different shades ;-). Installation The spotlight should be fitted into a posi- tion provided for it in the swimming pool, either in place of a standard spot, or, as the author did, in place of the return flow of a swim-jet system. A sheet of Perspex® fas- tened using nylon bolts with a silicone seal will ensure it is nice and watertight. A sheet of 'White Frost' - a type of diffusing filter used in video - is fitted behind the plas- tic window for better diffusion of the light from the LEDs. The PSU module is fitted well out of harm's way in the pool pump space, connected to the piggy-backed boards via an extension of a few metres. To avoid excessive volts drop, this extension should use the thickest cable practical. Software The software written for the microcontrol- ler to execute is very simple. It includes (artwork reproduced at 90% of actual size) fit ImS! HI flij mmi ifUiM 1 1 |ff| wM Ti T- <5 .(I || n COMPONENTS LIST Resistors R1-R30 = 608/3 W Capacitors Cl = 10nF C2 = 1000 |jF 16V radial Semiconductors D1 = 1N4004 LED1 - LED10 = Golden Dragon blue LB-W5KM- EZGY-35 from OSRAM LED11 - LED20 = Golden Dragon green LT-W5KM- HZKX-25 from OSRAM LED21 - LED30 = Golden Dragon red LR-W5KM- HXJX-1 from OSRAM T1 a T3 = IRFI540NPBF, isolated IC1 = AT90S8515P, Atmel, programmed with hex file from archive 071037-11. Miscellaneous K1 = 2 solder pins K2 = 10-way DIL (2x5) pinheader Heatsink for the 3 transistors (optional) PC power supply PCBs, ref 071037-1 (controller) and 071037-2 (LED) available from www.thepcbshop.com 50 elektor - 7-8/2008 (artwork reproduced at 90% of actual size) several subroutines whose function is to light or extinguish a colour instantaneously, and light or extinguish a colour in progressive mode. The primary loop calls these subroutines to create the effects. Each PWM (pulsewidth modulation) receives a value between 00 and FF that determines the mark/space ratio of the signal driving the bases of the transistors. The first part of this loop makes the spot change gradually from one colour to another by combining the three primary colours. The second part, much more dynamic, comprises coloured flashes that appear faster and faster until you get a near-stro- boscopic effect. Results As shown in the photos, at night the result is impressive. The cat seems to likes it a lot, too, though the wavelength of the red light is soon attenuated as it travels through the water. ( 071037 - 1 ) FT232R USB UART IC Clock Generator Output FTDIChip-ID™ Security Dongle USB to serial designs using the FT232R have been further simplified by fully integrating the external EEPROM, clock circuit and USB resistors onto the de- vice. • Free Downloadable Driver Options: VCP and D2XX drivers for all Windows, Mac and Linux platforms • Interface Options: available with a parallel FIFO interface (FTDI P/N: FT245R) • Programming: pre-programmed with unique USB serial number burnt in • Available as a single IC and can also be acquired in a range of easy to use modules and cables to be used with any of the driver options Vinculum VNC1L Embedded USB Host Controller IC • Single chip embedded USB Host Controller IC device • Entire USB protocol handled on the chip • Two independent USB 2.0 Low-speed/Full-speed host ports with integrated pull-up and pull-down resistors • Support for USB suspend and resume • Support for bus powered and self powered USB device configuration Web Links [1] AT90S8515P datasheet www.atmel.com/dyn/resources/prod_documents/DOC0841. PDF Downloads The artwork for the two PCBs (071037-1 and 071037-2) can be downloaded from the Elektor website at www.elektor.com. The source code and .hex files for this project (071037-1 1 .zip) are also available from www.elektor.com Future Technogy Devices International Ltd Practical USB Interface Solutions 373 Scotland Street Glasgow G5 8QB Scotland, United Kingdom TEL: +44 (0)141 429 2777 Sales Enquiry: salesl@ftdichip.com Technical Enquiry: supportl@ftdichip.com www.ftdichip.com www.vinculum.com 7-8/2008 - elektor 51 Jan Middel Flowcode is well known from the many 'E- blocks' projects that have been published by Elektor over the last few years. This year's Summer Circuits also has a project that is programmed using Flowcode. The circuit presented here uses a microcontroller pro- grammed with Flowcode to turn garden lights on and off at user-definable times. At the hart of the circuit is a PIC16F88 microcontroller. It uses a 2 line by 16 char- acter display to show the settings. These can be adjusted using a set of three push buttons. Potentiometer PI is used to adjust the contrast of the display. Output RA3 of the PIC is used to drive transistor T1, which in turn drives a relay that turns the lights on and off. The supply voltage is stabilised using a standard 7805 voltage regulator 1C. SI is the reset switch, which is connected to the MCLR input of the PIC. MCLR should be VDD O R1 DOWN S3 S4 w w T o o- o o- T UP ENTER o < > o R7 R8 LDR +12V GND VDD O ^06 ^OOn GND VDD R3 GND | VDDO— a a > IC1 RAO/ANO RA1/AN1 RA2/AN2/CVREF/VREF- RA3/AN3/VREF+/C1 OUT > RA4/AN4/T0CKI/C2OUT PIC16F88-I/P RA5/MCLR/VPP RA6/OSC2/CLKO > RA7/OSC1/CLKI RB0/INT/CCP1 RB1/SDI/SDA RB2/SDO/RX/DT RB3/PGM/CCP1 RB4/SCK/SCL < RB5/SS/TX/CK < RB6/AN5/PGC/T 1 0SO/T 1 CKI < RB7/AN6/PGD/T 1 0SI in in > lO 12 13 +12V O GND DIO ^ X □ 1N4001 RE1 RIO 390R CO I ^Jji Enter switch Loop as long as Enter switch 1 \ ^ / Clear LCD LUDDispla... k) Clear Print Ad ust Hours LUDDispla... k l Cvi h-. + '-' + Ki ,-H l'" I to set the minutes (in the same way as for the hours). After pressing Enter again, you are asked for a value for the light threshold. This value is compared with the amount of light falling on the LDR. When the value of the LDR becomes less than the threshold the lights come on. Another press of the Enter switch takes you to the day-of-week setting. This determines the days when the light stays on for longer at night. A final press of the Enter switch then starts the clock. It is of course possible to modify the soft- ware in certain places. You could for exam- ple change the time at which the lights come on in the morning. This function could even be removed completely if you have no need for it. ( 080113 - 1 ) Downloads The Flowcode (.fcf) file for this project, 080113-1 1 .zip, is available on the Elektor website as a free down- load, as is the layout for the printed circuit board (08011 3-1 .zip). IC1 VCC Rainer Reusch Consumer appliances these days hardly ever have a proper mains switch. Instead, appliances are turned on and off at the touch of a button on the remote control, just like any other function. This circuit shows how a device (as long as it does not draw too high a current) can be switched on and off using a pushbutton. The approach requires that a microcontroller is already availa- ble in the circuit, and a spare input port pin and a spare output port pin are required, along with a little software. When power is applied T1 initially remains turned off. When the but- ton is pressed the gate of T1 is taken to ground and the p-channel power MOSFET conducts. The microcontroller cir- cuit is now supplied with power. Within a short period the microcontroller must take output PB1 high. This turns on n-channel MOSFET T1 which in turn keeps T1 turned on after the pushbutton is released. Now the microcontroller must poll the state of the pushbutton on its input port (PB0) at regular intervals. Immediately after switch-on it will detect that the but- ton is pressed (a low level on the input port pin), and it must wait for the button to be released. When the button is next pressed the device must switch itself off: to do this the firmware running in the micro- controller must set the output port pin to a low level. When the button is subsequently released T1 will now turn off and the sup- ply voltage will be removed from the circuit. The circuit itself draws no current in the off state, and for (rechargea- ble) battery-powered appliances it is therefore best to put the switch before the voltage regulator. For mains-powered devices the switch can also be fitted before the volt- age regulator (after the rectifier and smoothing capacitor). Since there is no mains switch there will still be a small standby cur- rent draw in this case due to the transformer. Be careful not to exceed the maximum gate-source voltage specifica- tion for T1: the IRFD9024 device suggested can withstand up to 20 V. At lower voltages R2 can be replaced by a wire link; other- wise suitable values for the voltage divider formed by R1 and R2 must be selected. 7-8/2008 - elektor 53 The author has set up a small website for this project at http://reweb.fh-weingarten. de/elektor, which gives source code exam- ples (which include dealing with pushbut- ton contact bounce) for AVR microcontrol- lers suitable for use with AVR Studio and GNU C. Downloads are also available at http://www.elektor.com. ( 080251 - 1 ) High-intensity LED Warning Flasher uu uu Jose Luis Basterra This circuit was designed as a warning flasher to alert road users to dangerous situ- ations in the dark. Alternatively, it can act as a bicycle light (subject to traffic regulations and legislation). White LEDs only are rec- ommended if the circuit is used as a bicycle front light (i.e. for road illumination) and red LEDs only when used as a tail light. During the day, the two 1.6-V solar cells charge the two AA batteries. In darkness, the solar cell voltage disappears and the batteries automatically power the circuit. The flash frequency is about one per sec- ond and the LED on-time is about 330 ms. The duty cycle should enable the batteries to power the circuit over night. The circuit is composed of three parts. Under normal daylight conditions the bat- teries are charged through diode D4. In darkness, pnp transistor T1 is switched on, supplying battery current to the second part, a low-frequency oscillator compris- ing T2 and T3. The third part is the LED driver around T4. It conducts and switches on the LEDs D1- D2-D3 when the collector voltage of T3 swings high. Two LEDs (D1, D2) are 20,000- 30,000 mcd high-brightness yellow types and one (D3) is a normal 3-mm red LED for control purposes. Of course it is possible to increase the number of LEDs to obtain higher brightness. However you will run into limitations regarding the maximum collector current of transistor T4. For really high power applications a MOSFET transis- tor is suggested instead of the common or garden BC547B. ( 080312 - 1 ) Stroboscope with Trigger Input BerndOehlerking The Conrad Electronics company has a light flash stroboscope kit in its product line (number 580406) which can be easily expanded with an electrically isolated trig- ger input. Figure 1 shows the original schematic for the stroboscope. The neon lamp shown in the circuit (and which is used to provide a regular triggering of the flash tube) is removed and the additional circuit shown in Figure 2 is connected to the points label- led 'A', 'B' and 'C'. In this way a flash circuit is created that can be activated with an exter- nal trigger signal. The thyristor on the stroboscope PCB (a C106D from ON Semiconductor) requires only 400 pA to be triggered. Via voltage divider R1-R2-R3, diode D1 and electro- lytic capacitor Cl, a DC voltage of about 8 V is generated from the incoming mains voltage and, with the values shown, can deliver a current of about 1 mA. This vol- tage is used to supply the trigger pulse (in practice the duration is about 100 ps) via the transistor in the optocoupler and vol- tage divider R4/R5. The trigger signal for the LED in the opto- coupler is presented via C2/R6 and R7. Diode D2 is connected in anti-parallel with the LED in the optocoupler to protect this LED from an external trigger signal with the wrong polarity. The differential network at the input (C2/R7) ensures that even if there is a long duration input pulse there 54 elektor - 7-8/2008 1 D1 P R1 1 N4007 LAI f 2 D1 — N- R3 1N4148 «o R6 C Cl □ 100n 35V i-C 100k Trigger C 2 OO^HI R7 {ID lOOn 1N4148 c(>- " R5 080367 - 12 is nevertheless only a short pulse sent to the gate. R6 is necessary for the periodic discharge of C2. A standard 5 V digital signal is sufficient for driving this trigger input. With this expansion circuit it is possible to reach a repetition frequency of more than 20 Hz. Above this frequency the flash tube starts to flash erratically. The optocoupler used is a CNY65, which easily provides class II isolation (generous space between the connections to the LED on the one side and the transistor on the other side). Please note: this circuit operates at high voltages that can be lethal. Even after the mains voltage is removed there may still be dangerously high voltages present across the electrolytic capacitors in the circuit! ( 080367 - 1 ) Remote Control Mains Switch Jaap van der Graaff As the only electronics engineer in my fam- ily and circle of friends, it is sometimes not possible to evade an appeal for help. This time the request came from a friendly eld- erly lady in a retirement home. In her room the light switch by the door and the pull cord above the bed operate the light fitting on the ceiling in the middle of the room. However, she would prefer that her stand- ing lamp was operated by these switches instead, since she does not actually have a light fitting mounted on the ceiling. This standing lamp has an on/off switch in the power cord and is plugged into a power point. However, it stands rather far from the bed so that she always has to find her way in the dark. A wireless operated power point is not really a consideration, because it is just a matter of time before the remote is lost. Or maybe not? Behold a feasible circuit. Buy a wireless power point and an enclosure that is big enough for the remote control and a small 7-8/2008 - elektor 55 piece of prototyping board. On the proto- typing board build the circuit according to the accompanying schematic and (care- fully) open the remote control and solder wires to the push buttons for 'on' and 'off'. Measure if these are polarised and if that is the case connect them to the 4N25 opto- couplers as shown in the schematic, where pin 5 has a higher voltage than pin 4. The operation is as follows. The lady oper- ates the pull cord or light switch to turn the light on. This causes the mains volt- age to be applied to the transformer. The relay is activated which charges Cl. While Cl charges, a small current flows through optocoupler 1. The result is that the 'on' button on the remote control is pressed. The remote control switches the corre- sponding power point on and to which the standing lamp is connected. The standing lamp will therefore now turn on. Capacitor C2 is charged at the same time. If the lady pulls the cord again, or if she operates the switch near the door, the relay will de-ener- gise and C2 discharges across optocoupler #2. This operates the 'off' contact of the remote control and the light goes out. The remote control continuous to oper- ate from its normal battery and the white enclosure is attached to the ceiling in place of the light fitting. Diode D1 ensures that Cl is discharged when the relay de-energises. D2 ensures that C2 cannot discharge across the relay, but only across optocoupler 2. ( 080252 - 1 ) Tent Alarm Stefan Hoffmann IC2 l\ 1 71 Although this alarm is designed to protect valuables left in a tent, it can also be used as a baggage alarm (either on or in one's bags) and in similar situations. The tent alarm can be triggered by many different sensors. One is a current loop, connected to pin PB4 of an ATtiny13 micro- controller: this could be a thin wire which would be broken by a prospective pilferer caught off his guard. Alternatively, it can be a reed switch contact normally held closed by a magnet, arranged so that the budding burglar will accidentally move the magnet and thus open the contact. This could be used to protect a door or a zip fastener securing a tent. Another sensor connected to PB4 is an LDR (light dependent resistor). If the LDR is left in a dark place (such as under a sleep- ing bag) the thief will trigger the alarm if he moves the bag to expose the sensor to light. The resistance of the LDR is about 100 kO in the dark and just a few ohms in the light. If only the light sensor is to be used, the alarm wire (or reed contact) socket can be shorted using a jumper. If the LDR is not to be used, it can either be (temporarily) taped over to exclude light from it or (more permanently) replaced by a 100 kO resistor. A third sensor which can trigger the alarm is a vibration detector (S6), which is wired in series with a tilt sensor. The tilt sensor allows the vibration sensor to be disabled when the alarm unit is left upside-down. When the tilt sensor contacts are open, PB1 cannot be pulled low and so no alarm can be triggered. The unit also features a number of push- buttons and switches connected to PB2. The arrangement and labelling of these buttons and switches is described below. On the left of the device lies switch SI with the (deliberately misleading) legend 'Power on/off'. Of course, this does not turn the alarm on and off. On the right of the device is switch S2 with the legend 'Speaker on/off', which, naturally, does nothing of the sort. As you have probably already guessed, the red and green but- tons also have nothing to do with arming or disarming the alarm. These decoys should be enough to annoy and delay all but the most resourceful of robbers. Naturally, once the alarm has been triggered by uncovering the LDR, it will not turn off again if the LDR is then covered. The only way to disable the alarm is to set SI and S2 in the correct positions (namely, 'Power on' and 'Speaker on') and hold down the two buttons simul- taneously for five seconds. More com- plicated deactivation procedures can be programmed into the software, in case you are worried that some light-fingered Elektor reader (not that such a person exists) will be able to steal your valuables after having seen this article. The circuit requires a supply voltage of between 3.6 V and 5 V. In the circuit dia- gram we show a power supply made using a 9 V battery and a 5 V voltage regulator. The ATtiny13 microcontroller belongs 56 elektor - 7-8/2008 to Atmel's AVR family, and can be pro- grammed using BASCOM. Source and object code files, including fuse settings, are available in a ZIP archive that is avail- able for free download from the Elektor website. The source code can be modi- fied to suit your own application and then recompiled using the free version of BAS- COM. The software arranges matters so that the processor enters sleep or power- down mode when the alarm is correctly deactivated; there is no other way to turn the device off. To wake the device up the switches must be set correctly (both to 'on') and the unit shaken briefly. The LED blinks twice to confirm that the device has woken up; after a brief delay of approxi- mately three seconds the alarm is armed. This state is indicated by three flashes of the LED. While the alarm remains in the armed state the LED blinks briefly once every few seconds. When the alarm is triggered the red LED lights immediately. If it is not disarmed, the alarm sounds after a short pause. To disarm the unit, both switches again need to be in the 'on' position as described above and both buttons must be pressed. After a double flash, whether the LED is on or off indicates whether the buttons must then be pressed again or not. (stefankhoffmann@yahoo.de) (0801 35-1) Gratis Symmetrical Opamp Supply Voltages Many ways to obtain a set of symmetrical supply voltages for operational amplifiers and comparators from a single +5-V sup- ply voltage have been described already. The simplest option (including with regard to component availability and price) is to use a MAX232, which is available in the 16-pin DIP package for less than 30 p (50 eurocents). In nearly all microcontroller circuits with an RS232 port, this 1C is already present any- way to provide level conversion between TTI signals (5 V) and RS232 signals (nomi- nally ±12 V), so you can obtain a set of sym- metric supply voltages for opamps almost free of charge. It's not even necessary to add any cir- cuitry around the 1C. Figure 1 shows how a MAX232 is typically wired in a microcon- troller circuit. The symmetrical voltages (at around ±9 V) generated from the +5- V supply voltage can be taken from pin 2 (V dd ; +9 V) and pin 6 (V EE , -9 V) of the 1C. As you can see from Figure 2, the no-load voltage is nearly 10 V and you can draw up to 5 mA at 9 V, which is enough for most standard opamps and plenty for low-power opamps. The MAX232 has two charge pumps, each of which has two external capacitors for voltage doubling. These are 10-pF electro- lytic capacitors in Figure 1, which yields a somewhat stabler output voltage than the standard circuit with 1 pF as shown in Fig- ure 2. The charge pumps of the MAX232 are operated at an oscillator frequency of around 50 kHz, so the amount of ripple on the output voltage is quite small (typically less than 10 mV with a 2-mA load). This means that in most cases you can +5V Q +9V -O si K3 16 S2 6 ( ► 14 2 7 7 13 3 8 8 4 9 15 ru 5 SUB D9 ? a a VCC > C1 + IC3 C1- T10UT T1 IN T20UT T2IN RUN R10UT R2IN R20UT C2+ MAX232 GND LU C2- C5 HI lOu CO 11 10 C8 lOu 11 9 C6 lOu -9V 25 26 080498- 11 +5V O CM CO a a CL Q- a a > > RC6/TX/CK _i o RB5/PGM RC7/RX/DT s RB6/PGC RB7/PGD IC4 38 39 40 OUTPUT VOLTAGE vs. LOAD CURRENT CD < Q_ I— ZD O 10 8 6 4 2 0 -2 -4 -6 -8 -10 EITHER V+0RV- _ Vqc = ±5V NO LOAD ON .0ADED 1|iF \ ^ O.lnF F TRANSMITTER OUTPUTS (EXCEPT MAX220, MAX233A) I I I - V- LOADED, NO LOAD ON V+- V+ LOADED, NO LOAD ON V- 10 15 20 LOAD CURRENT (mA) 25 470n BC560C 080498-13 manage without any additional filtering of the output voltage. In sensitive applica- tions, such as amplification of small audio or measurement signals by one or more opamps, it's a good ideal to use a small gyrator circuit for additional suppression of the residual 50-kHz signal. Figure 3 is an example of such a circuit that has been proven frequently in practice. Of course, you can use other types of complimentary 7-8/2008 - elektor 57 small-signal silicon transistors, such as the BC547 (NPN) and BC577 (PNP), in place of the BC550 (NPN) and BC560 (PNP) shown on the schematic. Transistors in the cur- rent gain class 'B' (such as the BC547B and BC557B) are also suitable, and the values of the capacitors between the bases of the transistors and ground can also be increased (e.g. 100 pF) or decreased (e.g. 1 pF). The voltage drop across the gyrator circuit is only around 0.7 V. ( 080498 - 1 ) Simple Audio Power Meter Michiel Ter Burg This simple circuit indicates the amount of power that goes to a loudspeaker. The dual-colour LED shows green at an applied power level of about 1 watt. At 1.5 watts it glows orange and above 3 watts it is bright red. The circuit is connected in parallel with the loudspeaker connections and is powered from the audio signal. The additional load that this represents is 470 Ohm (R1//R3) will not be a problem for any amplifier. During the positive half cycle of the out- put signal the green LED in the dual-colour LED will be turned on, provided the voltage is sufficiently high. At higher output volt- ages, T1 (depending on the voltage divider R2/R1) will begin to conduct and the green LED will go out. During the negative half cycle the red LED is driven via R3 and will turn on when the voltage is high enough. In the transition region (where T1 conducts more and more and 'throttles' the green LED as a result) the combination of red/green gives the orange colour of the dual-LED. By choosing appropriate values for the resistors the power levels can be adjusted to suit. The values selected here are for typ- ical living room use. You will be surprised at how loud you have to turn your amplifier up before you get the LEDs to go! The resistors can be 0.25 W types, pro- vided the amplifier does not deliver more than 40 W continuously. Above this power the transistor will not be that happy either, so watch out for that too. Because T1 is used in saturation, the gain (Hfe) is not at all important and any similar type can be used. The power levels mentioned are valid for 4-Ohm speakers. For 8-Ohm speakers all the resistor values have to be divided by two. ( 080506 - 1 ) Mini High-voltage Generator B. Broussas Here's a project that could be useful this summer on the beach, to stop anyone touching your things left on your beach towel while you've gone swimming; you might equally well use it at the office or workshop when you go back to work. In a very small space, and powered by simple primary cells or rechargeable bat- teries, the proposed circuit generates a low-energy, high voltage of the order of around 200 to 400 V, harmless to humans, of course, but still able to give a quite nasty 'poke' to anyone who touches it. Quite apart from this practical aspect, this project will also prove instructional for younger hobbyists, enabling them to dis- cover a circuit that all the 'oldies' who've worked in radio, and having enjoyed valve technology in particular, are bound to be familiar with. As the circuit diagram shows, the project is extremely simple, as it contains only a SI 58 elektor - 7-8/2008 single active element, and then it's only a fairly ordinary transistor. As shown here, it operates as a low-frequency oscillator, making it possible to convert the battery's DC voltage into an AC voltage that can be stepped up via the transformer. Using a centre-tapped transformer as here makes it possible to build a 'Hart- ley' oscillator around transistor T1, which as we have indicated above was used a great deal in radio in that distant era when valves reigned supreme and these was no sign of silicon taking over and turn- ing most electronics into 'solid state'. The 'Hartley' is one of a number of L-C oscilla- tor designs that made it to eternal fame and was named after its invertor, Ralph V.L Hartley (1888-1970). For such an oscillator to work and produce a proper sinewave output, the position of the intermediate tap on the winding used had to be carefully chosen to ensure the proper step-down (voltage reduction) ratio. Here the step-down is obtained inductively. Here, optimum inductive tapping is not possible since we are using a standard, off-the-shelf transformer. However we're in luck — as its position in the centre of the winding creates too much feedback, it ensures that the oscillator will always start reliably. However, the excess feedback means that it doesn't generate sinewaves; indeed, far from it. But that's not important for this sort of application, and the trans- former copes very well with it. The output voltage may be used directly, via the two current-limiting resistors R2 an R3, which must not under any circum- stances be omitted or modified, as they are what make the circuit safe. You will then get around 200 V peak-to-peak, which is already quite unpleasant to touch. But you can also use a voltage doubler, shown at the bottom right of the figure, which will then produce around 300 V, even more unpleasant to touch. Here too of course, the resistors, now know as R4 and R5, must always be present. The circuit only consumes around a few tens of mA, regardless of whether it is 'warding off' someone or not! If you have to use it for long periods, we would how- ever recommend powering it from AAA size Ni-MH batteries in groups often in a suitable holder, in order not to ruin you buying dry batteries. Warning! If you build the version with- out the voltage doubler and measure the output voltage with your multimeter, you'll see a lower value than stated. This is due to the fact that the waveform is a long way from being a sinewave, and mul- timeters have trouble interpreting its RMS (root-mean-square) value. However, if you have access to an oscilloscope capable of handling a few hundred volts on its input, you'll be able to see the true values as stated. If you're still not convinced, all you need do is touch the output terminals... To use this project to protect the handle of your beach bag or your attache case, for example, all you need do is fix to this two small metallic areas, quite close together, each connected to one output terminal of the circuit. Arrange them in such a way that unwanted hands are bound to touch both of them together; the result is guar- anteed! Just take care to avoid getting caught in your own trap when you take your bag to turn the circuit off! ( 080229 - 1 ) Gilles Clement The objective of the circuit described in this Summer Circuits article on all things outdoors is to create a servo motor polarity- inverter, to allow the drive to a model servo motor to be inverted with respect to the command from a radio-control receiver chan- nel. Hence this module is inserted between one of the receiver out- puts and the servo motor to be driven. One of the most obvious applica- tions is to reverse the rotation sense of the servo motor output arm. This feature is useful when all the chan- nels of a receiver are used up and you need to control a second servo motor in paral- lel with the first one (using a 'Y' cable) but inverting the sense of one of them. Generally, it is also often useful to be able to adjust the end positions of the output arm and the neutral position independ- ently (when the two servo motors aren't exactly the same or are mounted differ- ently in the two wings, for example). The movement of servo motors used in modelling is coded using pulse width mod- ulation (PWM). The width usually varies from 1 ms to 2 ms, with the signal repeat- ing at 20 ms intervals (i.e. 50 Hz). The transmitter controls use poten- tiometers whose travel defines the pulse width for each channel. These pulses are sent sequentially (as many as there are channels) to the receiver, which decodes them and sends them to the relevant outputs according to the order in which they arrive. As we've said, the objective here is to invert the travel of a servomotor output arm, while also permitting the whole of the range of move- ment to be manually shifted so as to adjust the rudder neutral posi- tion ('trim'). Let's take a look at the electronics. The microcontroller we've chosen here is the deceptively small 12F675 PIC from Microchip. It's quite extraordinary, a real little eight-legged marvel! Although it is really very small (8-pin DIL), it is capa- ble of doing masses of things. A 12F675 is in fact the heart of the whole circuit (see circuit diagram). Of course, for it to work, it needs to have 7-8/2008 - elektor 59 the required .hex file, extracted from the archive file 080323-11.zip (see Downloads). The microcontroller only needs three addi- tional components (excluding the servo- motor extension, the most expensive item in this project): a 5 V regulator (78L05) to provide the supply voltage, a miniature push-button used as a control, and one pull-up resistor. The electronics will fit onto a piece of pro- totyping board of 9 x 6 holes, making it easy to fit into the scale model concerned. Just a word about the calibration of the internal oscillator. The last byte of the 12F675's program memory contains the calibration value for the internal oscillator, which makes it possible to adjust the clock to 4 MHz within ±1%. Right at the start of your operations, you need to go and read this byte (read the memory) and save it as there is a danger of erasing it when you start programming. One of the most important aspects of this project is adjusting it (when you are aware of the consequences an error here can have -just try piloting a scale model by revers- ing the controls!). Warning: you mustn't touch the transmit- ter during this stage - i.e. while powering up the receiver - as we are measuring the receiver output signal when the transmit- ter control is at rest. We start first of all by confirming the meas- urement of the input signal, very important in order for the output signal calculation to be correct. Warning: the remark to not touch the transmitter during this stage applies here too, for the same reasons. If the push-button is pressed a second time, the gradual shift of the neutral position starts, then if it is released and immedi- ately pressed again, the movement takes place in the opposite direction. This mode is exited automatically if the push-button hasn't been pressed for 2 seconds. The ser- vomotor 'flutters' a little to indicate the end of the steps. One conclusion is called for: it works very well, and it doesn't cost an arm and a leg... Clemgill@club-internet.fr (080323-1) Web Links 12F675 datasheet http://ww1.microchip.com/downloads/en/devicedoc/ 41190c.pdf Downloads The source code and .hex files for this project are available for downloading from the Elektor website at www.elektor.com; archive file 080323-11.zip. Simple USB AVR-ISP Compatible Programmer 2x BAS316 K1 VBUSO d- a D+ O ID GNDO USB D2 D1 R14 R12 68 Q 68 Q R13 R1 o Jsi 2 21 6 11 _ 12_ 13 +3V3 — © 20 VCC AVCC AREF PC5(ADC5/SCL) PC4(ADC4/SDA) PC6(RESET) PC3(ADC3) IC1 PC2(ADC2) PCI(ADCI) PCO(ADCO) PDO(RXD) PDI(TXD) PD2(INT0) PB5(SCK) PD3(INT1) PB4(MIS0) PD4(XCK/T0) PB3(M0SI/0C2) PD5(T1) PB2(SS/0C1 B) PD6(AIN0) PBI(OCIA) PD7(AIN1) PBO(ICP) ATMega8-16 GND XTAL1 XTA L2 AG C5 ^ToOn 8 [9 XI 10 ND p I 12MHz 1 22 28 27 26 25 24 23 19 18 17 16 15 14 22 K4: 1 = M0SI 2 = VCC 4 = GND 5 = RESET 6 = GND 7 = SCK 8 = MIS0 R8 | 68 Q | — - R9 RIO R11 680 680 680 K2 O O o +3V3 © L © V+ V+ © K4 o a o o o o-P 10 K3 O 080161 - 11 Nand Eeckhout Modern PCs rarely have a serial or parallel port any more, to the great regret of any- one who experiments with microcontrol- lers every now and then. In the old days it was very simple to use the parallel port of a standard PC and program just about any type of AVR microcontroller with it. When you want to do that now, you're first obliged to buy a programmer that communicates with the PC via USB, which immediately raises the threshold of get- ting started with these microcontrollers. The circuit presented here offers a solu- tion to this. As you can see from the schematic, this is a very simple circuit, built around a cheap, standard AVR microcontroller plus a hand- ful of passive components. You may have already observed that this microcontrol- ler does not have a USB interface and the circuit does not use a USB to serial con- verter either. The strength of this circuit is found in the firmware. The USB interface has been implemented in software, as we have shown in an earlier article 'AVR drives USB' in the March 2007 issue. The firmware ensures that the circuit is recognised by the PC as a serial port and communicates with AVR Studio, the standard Atmel develop- ment environment, as if it were a 'real' AVR- ISP programmer. The circuit is easily built on a small piece of prototyping board or even on a bread- board, since the controller is available in 60 elektor - 7-8/2008 a DIP-28 package. If you are going to pro- gram the controller yourself (via connec- tor K2) then make sure that you set the configuration fuses so that the internal oscillator uses the external crystal as the clock source. Jumper K3 is provided in the event you would like to power the circuit to be pro- grammed from the USB port. We do not recommend that you do this, however, but sometimes there is no other option. K4 is a 10-way box header which has the same standard pinout that Atmel uses everywhere. ( 080161 - 1 ) D1 D2 D3 4 O o o o d f d d o o o o o RS-232 Cable O output are converted into RS-232 signals on the tiny board described here. The voltage level adaptor is a MAX3232 from Maxim. This industry-standard part comprises two transmitters and two receiv- ers, ideal for our USB<->serial convertor, which itself offers the four fundamental signals of an RS-232 standard port, namely TXD (Transmit Data), RTS (Request To Send), RXD (Receive Data) and DTR (Data Terminal Antoine Authier This project lets you conven- iently connect any computer with USB ports directly to a simple, traditional connector — the 9-pin RS-232 (anyone remembers it?). It converts the electrical sig- nals from a USB<->serial TLL convertor to the RS-232 stand- ard. So in a nutshell, it converts a USB port into a standard but basic serial port: only the four basic signals are available. The USB<->serial convertor chosen here is the TTL-232R USB to TTL UART cable from FTDI, available as part number 080213-71 and described in the June 2008 issue (see the Elektor website). The TTL logic signals available on the cable Ready). Charge pumps built into the 1C provide the 12 V levels required by the RS-232 standard. This circuit works equally well from 3.3 V as from 5 V supply rails and supports both these levels on its logic input and out- puts. In theory, it also ought to work correctly with the 3.3 V version of the cable mentioned above, the TTL-232R-3V3 - how- ever, we haven't checked this experimentally in the lab. Instead of the complete cable, you can use just the TTL-232R- PCB module (or TTL-232R-PCB- 3V3 for 3.3 V), currently only the former is available from the Ele- ktor Shop. The 1206 cases size SMD (sur- face mount device) compo- nents used here make it pos- sible to achieve a compact board, while still being easy enough to handle by constructors who may not be very used to this type of component, and who, in building this useful little project, will be able to practice and get an idea COMPONENTS LIST Capacitors Miscellaneous C1-C5 = lOOnF 25 V (SMD 1206) K1 = 6-way right-angled SIL pinheader K2 = 9-way cable mount sub-D plug (male) FTDI TTL-232R cable (5.0 V), Elektor SHOP # Semiconductors 080213-71 IC1 = MAX3232CSE (or -ESE) Piece of large diameter heatshrink sleeving PCB, ref. 080470-1 from www.thepcbshop.com Ol 7-8/2008 - elektor 63 of how nimble-fingered they are before attacking more complex circuits using SMDs. No surprises in the construction of the project. Start by soldering the 1C and the capacitors, then the connectors. Use a right-angle 0.1-inch SIL pinheader to reduce the pull on the cable. With a straight header, the cable and board would form a cumbersome and inelegant right angle. The sub-D connector may be cannibalized from an old cable, as long as it's a male one (i.e. a plug, not a socket). Slide the board between the two rows of pins on the con- nector and solder these directly onto the PCB copper islands provided. To finish off, you can protect the whole thing by slipping it into a piece of heat- shrink sleeving of suitable diameter. ( 080470 - 1 ) Web Links http://pdfserv.maxim-ic.com/en/ds/MAX3222- MAX3241.pdf www.ftdichip.com/Products/EvaluationKits/TTL-232R Downloads The PCB artwork for the board is available for free download from our website (www.elektor.com); file # 080470-1.zip. Car & Motorcycle Battery Tester D1 Open = Car Joseph Zamnit Going camping nowadays involves taking lots of electronic equipment whether for day to day running or for fun and enter- tainment. Most of the time a charged lead- acid battery and a power inverter would be used to ensure a smoothly organised holiday where ideally the missus and the children cheerfully use their electric and electronic gear! With rechargeable lead-acid batteries it's invariably useful — if not essential — to determine whether the power source you're hauling along on your travels is los- ing capacity and needs to be topped up. The same circuit would also come in handy when going on a car or motorbike trip as it can check the status of a 12 V (car) or a 6 V (motorcycle) battery. Although the circuit draws so little power that it will not notice- ably load the battery under test, it should not be left connected permanently. The circuit employs the familiar LM3914 (IC1) to display the voltage level. The LED readout creates a battery status readout: when the top LED lights, the battery is fully charged. When the bottom LED lights, the battery needs imminent charging! Switch SI selects between 12 V and 6 V operation. A series diode, D1, protects the bargraph driver from reverse supply volt- age. A colour-coded display with individual LEDs could be used instead of the com- mon-anode bargraph display for better indication of the state of the battery. ( 080421 - 1 ) Mobile Phone Data Cable = Interface Converter O ' Michael Gaus Nowadays microcontroller circuits that cannot be connected to a PC are hope- lessly old-fashioned. One option is to use one of the many types of ready-made USB to serial interface converters to out- fit a microcontroller circuit with a MAX232 level converter. However, in some cases it is not so easy to retrofit a level converter if the circuit is already fitted in an enclo- sure. An example of this is provided by the various Internet routers that clever users employ for novel purposes (with modified firmware). If you enjoy plying a soldering iron, you can keep everything simple and inexpensive. This is based on the fact that older-model mobile phones did not have any USB cir- cuitry for connection to a PC. Special cables incorporating an interface converter were (and still are) available for these devices. They even included level conversion from 64 elektor - 7-8/2008 RS232 to digital logic levels. What could be simpler than to use a data cable of this sort? After all, you can obtain these cables very inexpensively via the Web. Another advantage of these cables is that they supply +5 V from the PC, which can be used to power small circuits. The author has found that a cable with type number KQU08A, which was originally designed for use with Siemens C55 mobile phones, is quite suitable. The 'remodelling' is very easy in principle: you just cut off the mobile-phone connec- tor and solder a five-way socket header in its place. The photo shows that the author also used a small piece of perforated circuit board for improved mechanical strength. The pin assignments are easy: yellow = +5 V, red = ground, blue = RxD, white = TxD, and green = DCD, although the last signal can be ignored in most cases. You should always check the wiring scheme just to be sure. Note that the RxD, TxD and DCD signals are designed for 3.3 V and are active low. If you are driving a circuit with a 5-V supply voltage, no problems will arise if you con- nect the TxD line of the cable to the RxD input of a 5-V microcontroller, since the MCU will almost always interpret the sig- nal levels correctly. However, you should connect the TxD output of the MCU to the RxD line of the cable via a voltage divider formed by a 1.8-kQ resistor in series with a 3.3-kQ resistor. You can also use a 3.3-V Zener diode in place of the 3.3-kQ resistor. The load on the 5-V line should be kept at 100 mA or less. Before you start modifying the cable, it's a good idea to connect it to a PC, install the included driver, and see whether a vir- tual COM port is configured on the PC for the cable. If this is OK, connect TxD and RxD together and check whether your terminal emulator program can properly receive transmitted data (without local echo enabled). ( 080321 - 1 ) Intelligent Presence Simulator TR1 FI 1VA2...3VA 01 C. Tavernier However effective a domestic alarm sys- tem may be, it's invariably better if it never goes off, and the best way to ensure this is to make potential burglars think the premises are occupied. Indeed, unless you own old masters or objects of great value likely to attract 'professional' burglars, it has to be acknowledged that the major- ity of burglaries are committed by 'petty' thieves who are going to be looking more than anything else for simplicity and will prefer to break into homes whose occu- pants are away. Rather than simply not going on holiday - which is also one solution to the problem (!) - we're going to suggest building this intelligent presence simulator which ought to put potential burglars off, even if your home is subjected to close scrutiny. Like all its counterparts, the proposed cir- cuit turns one or more lights on and off when the ambient light falls, but while many devices are content to generate fixed timings, this one works using randomly variable durations. So while other devices are very soon caught out simply by daily observation (often from a car) because of their too-perfect regularity, this one is much more credible due to the fact that its operating times are irregular. The circuit is very simple, as we have employed a microcontroller - a 'little' 12C508 from Microchip, which is more than adequate for such an application. It is mains powered and uses rudimentary volt- age regulation by a zener diode. A relay is used to control the light(s); though this is less elegant than a triac solution, it does avoid any interference from the mains reaching the microcontroller, for example, during thunderstorms. We mustn't forget this project needs to work very reliably dur- 7-8/2008 - elektor 65 COMPONENTS LIST Resistors R1 = IkO 500mW R2 = 4k07 R3 = 5600 R4,R6 = lOkO R5 = 7kQ5 R 7 = LDR R8 = 470kO to 1 MO PI =470 kO potentiometer Capacitors Cl = 470pF 25V C2 = lOpF 25V C3 = 1nF5 C4 = 10nF Semiconductors D1,D2 = 1N4004 D3 = diode zener 4V7 400 mW LED! = LED, red D4 = 1 N4148 T1 = BC547 IC1 = PIC12C508, programmed, see Downloads Miscellaneous RE1 = relay, 10A contact SI = 1-pole 3-way rotary switch FI = fuse 100 mA TR1 = Mains transformer 2x9 V, 1.2 -3 VA 4 PCB terminal blocks, 5 mm lead pitch 5 solder pins PCB, ref. 080231-1 from www.thepcbshop.com ing our absence, whatever happens. The ambient light level is measured by a conventional LDR (light dependent resis- tor), and the lighting switching threshold is adjustable via PI to suit the characteristics and positioning of the LDR. Note that input GP4 of the PIC12C508 is not analogue, but its logic switching threshold is very suitable for this kind of use. The LED connected to GP1 indicates the cir- cuit's operating mode, selected by ground- ing or not of GP2 or GP3 via override switch SI. So there are three possible states: perma- nently off, permanently on, and automatic mode, which is the one normally used. Given the software programmed into the 12C508 ('firmware') and the need to gen- erate very long delays so as to arrive at lighting times or an hour or more, it has been necessary to make the MCU operate at a vastly reduced clock frequency. In that case, a crystal-controlled clock is no longer suitable, so the R-C network R5/C3 is used instead. For sure, such a clock source is less stable than a crystal, but then in an applica- tion like this, that may well be what we're after as a degree of randomness is a design target instead of a disadvantage. Our suggested PCB shown here takes all the components for this project except of course for SI, S2, and the LDR, which will need to be positioned on the front panel of the case in order to sense the ambient light intensity. The PCB has been designed fora Finder relay capable of switching 10 A, which ought to prove adequate for lighting your home, unless you live in a replica of the Palace of Versailles. The program to be loaded into the 12C508 is available for free download from the Ele- ktor website as file number 080231-1 1 .zip or from the author's own website: www. tavernier-c.com. On completion of the solder work the cir- cuit should work immediately and can be checked by switching to manual mode. The relay should be released in the 'off' posi- tion and energized in the 'on' position. Then all that remains is to adjust the day/ night threshold by adjusting potentiom- eter PI. To do this, you can either use a lot of patience, or else use a voltmeter - dig- ital or analogue, but the latter will need to be electronic so as to be high impedance - connected between GP4 and ground. When the light level below which you want the lighting to be allowed to come on is reached, adjust PI to read approximately 1.4 V on the voltmeter. If this value cannot be achieved, owing to the characteristics of your LDR, reduce or increase R8 if neces- sary to achieve it (LDRs are known to have rather wide production tolerances). Equipped with this inexpensive accessory, your home of course hasn't become an impregnable fortress, but at least it ought to appear less attractive to burglars than houses that are plunged into darkness for long periods of time, especially in the mid- dle of summer. (www.tavernier-c.com) (080231-1) Downloads The PCB layout can be downloaded free from our web- site www.elektor.com; file # 080231 -1 . The source code and .hex files for this project are avai- lable free on www.elektor.com; file # 080231 -11. zip. Low-Voltage Step-Down Converter Steffen Graf Sometimes you have a situation where you have a 5-V supply voltage but part of the circuit needs a lower supply voltage. A volt- age regulator from the Texas Instruments TPS62000 family [1] is a good choice for this if the current consumption is less than 600 mA. The essential advantages are: • small (but still manually solderable) SMD package; • high operating frequency (750 kHz) => small external inductor; • integrated power MOSFETs => high effi- ciency (up to 95 %); • no external switching diode necessary. You can thus use this device to build a very compact, highly efficient voltage converter. A sample layout generated by the author 66 elektor - 7-8/2008 is available as a file on the Elektor website. The TSOP62000 provides an inter- nal reference potential of 0.45 V, which can be used to set the out- put voltage in the range of 0.5 V to 5 V by means of resistors R2 and R3. The formula for this is: V out = 0.45 V + (0.45 V) x (R2 / R3) For relatively low voltages, the value of inductor LI should be 10 pH, but a value of 22 pH is bet- ter if the output voltage is 3.3 V or more. The input voltage can be anywhere in the range of 2 V to 5.5 V, and of course it has to be higher than the desired output voltage. The output voltage is 3.3 V with the indicated component values and an input voltage of 5 V. If you want to reduce the com- ponent count even further, you can use a member of the family with a fixed output voltage. The available voltages are 0.9, 1.0, 1.2, 1.5, 1.8, 1.9, 2.5, and 3.3 V. With this approach you can omit R2, R3 and C3, so the output can be connected directly to pin 5. ( 070966 - 1 ) Web Link [1] TPS6200 datasheet focus.ti.com/lit/ds/symlink/tps62000.pdf LiPo Manager Andreas Graff This circuit performs a managerial role for a three-cell Lithium-Polymer ('LiPo') rechargeable power pack used in a model aircraft. It monitors the voltage of each cell during discharge and cuts power to the motor when any cell dips below a voltage threshold. The R/C receiver is also powered from this battery via a Battery Elimination Circuit (BEC) but it remains operational so that the pilot remains in control and can safely glide the aircraft in to land. LEDs indicate which of the three cells caused the power to be cut. The circuit resets once power is turned off and on again. The circuit shown in Figure 1 measures the three voltage levels without the use of any dedicated hardware A/D converter. The A/D conversion is achieved by apply- ing a voltage to an RC network and meas- uring the time it takes for the voltage to reach a threshold level (a digital T). For this application the technique has a number of advantages: the RC network is a low pass filter which removes any spikes and noise from the measured voltage and the hardware required is small, light and inexpensive. Before measurement all ports are set to 0/ P and low so that the capacitors discharge. The ports are now configured as inputs and a timer measures how long it takes the three voltages to reach the threshold (see Figure 2). It is a simple job to calibrate the circuit so it is not necessary to define absolute values for the trigger points. Only the low-to-high time is measured so it is not necessary to take into account any hysteresis levels. The aircraft is only flown within a fairly limited temperature range so it is valid to assume that small variations in the characteris- tics due to temperature changes can be ignored. The time constants for all three inputs are chosen so that the time taken for the three voltages to pass the threshold is roughly of the same order of magnitude. The meas- urements are made on the steep rising edge of the exponential so the measure- ment sensitivity for all three levels is about the same (see Figure 3). Measurement at the 6 V and 9 V tap must take into account the readings from the cell(s) below so that it can be determined which cell was guilty of triggering the shut- down. The result is shown on one of three LEDs. The Microchip PIC P16F84 controller incor- porates protection diodes on its inputs. The high values of the RC networks series resistors ensure there are no problems of latch-up with inputs of 6 V and 9 V. During program debugging a serial inter- face (9600, 8, n,1) was implemented in soft- ware (TxData on RB3, RxData on RB4), there 7-8/2008 - elektor 67 (start measurement; timer reset) 3 is more than enough memory space in the controller so the routine has been left in the program. The routine outputs the (8- bit) decimal value of the actual measure- ment for channel 1, channel 2 and chan- nel 3. The controller watchdog is enabled to ensure reliable operation. All the source and hex files for this project are available to download free of charge from the Elektor website at www.elektor. com; the archive number is 080053-11.zip. To calibrate the circuit it is necessary to short the CAL pin to ground during power up. All three LEDs will light to indicate that it is in calibration mode. All LEDs now extin- guish when CAL is released and calibration proceeds as follows: - LED for Channel 1 (D18) lights. Connect the output of a power supply to channel 1 (pin 3 of K1) and adjust the DC output to the correct level for one cell (2.9 V) then momentarily ground the CAL pin. - LED for Channel 2 (D19) lights. Connect the output of a power supply to channel 2 (pin 2 of K1) and adjust the DC output to the correct level for two cells (5.8 V) then momentarily ground the CAL pin. - LED for Channel 3 (D20) lights. Connect the output of a power supply to channel 3 (pin 1 of K1) and adjust the DC output to the correct level for three cells (8.7 V) then momentarily ground the CAL pin. The LiPo manager is now in normal opera- tional mode and ready to go. ( 080053 - 1 ) DCF77 Preamplifier +5V Rainer Reusch A popular project among microcontroller aficionados is to build a radio-controlled clock. Tiny receiver boards are available, with a pre-adjusted ferrite antenna, that receive and demodulate the DCF77 time signal broadcast from Mainflingen in Germany. DCF77 has a range of about 1,000 miles. All the microcontroller need do is decode the signal and output the results on a dis- play. The reception quality achieved by these ready-made boards tends to be pro- portional to their price. In areas of marginal reception a higher quality receiver is nee- ded, and a small selective preamplifier stage will usually improve the situation further. The original ferrite antenna is desoldered from the receiver module and connected to the input of the preamplifier. This input consists of a source follower (T1) which has very little damping effect on the resonant circuit. A bipolar transistor (T2) provides a gain of around 5 dB. The output signal is coupled to the antenna input of the DCF77 module via a transformer. The secondary of the transformer, in conjunction with capa- citors C4 and C5, forms a resonant circuit which must be adjusted so that it is centred on the carrier frequency. An oscilloscope is needed for this adjust- ment, and a signal generator, set to gene- 68 elektor - 7-8/2008 rate a 77.5 kHz sine wave, is also very useful. This signal is fed, at an amplitude of a few millivolts, into the antenna input. With the oscilloscope connected across C4 and C5 to monitor the signal on the output reso- nant circuit, trimmer C5 is adjusted until maximum amplitude is observed. It is essential that the transformer used is suitable for constructing a resonant cir- cuit at the carrier frequency. Our proto- type used a FT50-77 core from Amidon on which we made two 57-turn windings. It is also possible to trim the resonant fre- quency of the circuit by using a transfor- mer whose core can be adjusted in and out. In this case, of course, the trimmer capacitor can be dispensed with. ( 080248 - 1 ) Stefan Hoffmann Actually this is a travel tip, not a circuit. If you own a digital camera, then you've got a memory card for computer data as well. Camera memory cards are primarily for storing pictures of course but they are also ideal for backing up data you might need on a journey. Cameras are not fussy about data formats and with today's memory capacities of typically 2 GB on a cheap SD card, these memory cards provide more than enough storage for photos. This makes memory cards ideal for storing all kinds of emer- gency information such as details of your reservations, handy addresses, PDF copies of air tickets, travel permits and loads more. If you prefer this data to be independent of the camera you could also keep a sepa- rate SD card with this information in your pocket in case your luggage is lost, your briefcase is stolen or your wallet goes walk- ies. These memory cards are so compact that you could even keep one below a pad- ded insole inside your shoe... ( 080152 - 1 ) RC Mains Sockets with Feedback Jens Nickel When on a trip to his local DIY emporium to buy light bulbs the author found a set of three radio-controlled mains sockets, plus transmitter, at a bargain price. Before the thought 'those will come in handy one day' had even made the journey from mind to mouth, they were in the trolley. On the journey home numerous ideas for what to do with the devices came to mind, most of which, it must be admitted, were rather fanciful in nature. One thing became apparent: for high-availability mission-critical applications, such as arm- ing the (yet to be implemented, natch) home alarm system, or pre-warming the (not yet fully fitted-out) shed, one key fea- ture was lacking. There was just one tiny LED on the remote control transmitter to show whether the on and off commands were being sent. There was no feedback from the receivers to indicate whether the command sent by the transmitter had been correctly received. Suddenly the author was reminded of one of the first projects on which he worked as a fresh-faced young Elektor editor. In 2005, his Elektor lab colleague Peter Ver- hoosel (who is now enjoying a well-earned retirement) put together an interesting arti- cle about novel applications for radio con- trolled switches. The transmitter was modi- fied so that the sockets could be switched on and off under timer control [1]. Suddenly inspiration struck and the author was off to the DIY shop to buy another set of radio controlled mains sockets. With a few more pounds invested in the project, he was ready to start experimenting. The idea was to use the two systems together to make a remote switch suitable for 'safety critical' applications. A multi-way extension lead is plugged into the remotely switched socket, and the apparatus to be switched is plugged into one of the sockets on the extension lead. An ordinary mains adaptor is plugged into another of the sockets on the extension lead. Usually an adaptor with a 12 V output will be required. Now we turn to the second transmitter- receiver set. The transmitter has to be mod- 7-8/2008 - elektor 69 ified a little by taking the contacts normally used for the battery to a suitable socket so that the unit can be powered from the mains adaptor. One of the 'on' buttons on the transmitter must also be bridged by a small switch. There is the possibility of a small difficulty here if the two transmit- ter-receiver sets are configured to operate on the same channel. In general this con- figuration cannot be changed, and so the best solution is to use button 1 on the first set to switch the remote device and button 2 on the second set to send the feedback signal. The rest is obvious enough: the socket at the receiver end of the second set will now indicate whether the remote appliance has been properly powered up. One possibil- ity would be to use the second receiver socket to power an LED night light or simi- lar device. The system is armed by closing the switch that shorts the pushbutton on the second transmitter, and (if it has a power switch) turning on the mains adaptor. And amaz- ingly, the prototype worked first time: a press of the 'on' switch of the first trans- mitter switched on the remote socket, powered up the extension lead, and trig- gered the second transmitter into sending its feedback. The second receiver socket duly turned on, indicating that the origi- nal transmission had been successfully received. ( 080500 - 1 ) Web Link [1] http://www.elektor.com/magazines/2005/october/ remote-control-operator.57913.lynkx Magnetic Flip-Flop n Bernhard Schnurr The sensitivity of a reed switch can be affected by the judicious nearby placement of small mag- nets. Also, reed switches exhibit a certain amount of hysteresis: there is a distinct difference between the level to which the magnetic field strength must rise for the switch to pull in and the level to which it must fall for the switch to drop out. These properties in combination allow us to make an element with two stable states: a flip-flop. All we need is a permanent magnet strategically placed in the vicinity of the switch. In practice getting the arrangement right is tricky, as the distance from the switch must be correct to within a fraction of a millimetre. However, once the right position is found, we have a bistable element that can be switched using either a second magnet or a small coil. The state of the element is preserved with- out power. Since the adjustment required to achieve symmetrical behav- iour is so critical, it is simplest to employ a second magnet, some- what further away than the first. The behaviour of the system can be adjusted over a wide range by carefully rotating this second magnet, and it is now relatively easy to obtain reliable sensitive point along the reed switch. The prototype shown in the photograph switches with a coil current of approximately 40 rmA. It is also possible to obtain other behaviours. One possibility is a normally-on reed contact with the contact broken when the coil current exceeds a certain value, forming a kind of electronic fuse. Equally, we can produce a normally-off contact which makes at a defined coil current: essentially a configurable relay. With the prototype shown we achieved switching currents of up to approximately 180 mA, and with the second magnet correctly adjusted it is possible bistable operation. to achieve switching currents down to just The drive coil can be made using about a one milliamp. metre of enamelled copper wire wound The graph shows the points at which the reed switch changes state, as a function of the angle at which the second magnet is placed and on the coil current. The curve is not particularly smooth, as you might expect from genuine measured data. Without the second magnet the contact pulls in at 63 mA and drops out at -17 mA. ( 071158 - 1 ) using a 2.5 mm drill bit as a temporary former. The coil is then fixed at the most 70 elektor - 7-8/2008 Supptf&rs ef PCD Soldering Equipment & Rework Stations NEW IN STOCK Wm 328 Working Platform /AxJI $ 17 -+ 45 W Solde ni n g Sla E Jo n I Range Of Tools & Accessories 1 £ | CL V M m r~* n a § Kic mdudw I-Il -1 AjiGut € ■ Ail Nutik'i j’DW So'flff mg Iran w^h funic iVbsoibcr k on 5 i 4 jx 1 ff™ ia!:: . J ir n id*i lip ^itfc Hevr ng Elrrwnt Vj< f"> i Pen- Heat F?Mrt’ani Pad Kl hvnmJ Tot:- 2xCVbflftF llWS _ L Opine Price £139195 29 QQ 7 QW 5*1 derm 9 Station Online Price 1:74.95 SoldwEng I ron Tipi & Air $M 5MD Hot Tweezers & Station I 710 Infrared Welding Station I # Online Price £44,95 Online Price £ 7 WOO Test-piims.co.uk Qi r+ifpfc* Rkw4»Jh t F^ofrf# For Tesf-p^ns & Prah&s Visit www, tesfrpfris, to. uk kbort dSMOur^ttxte a so apples www.pcb-soldering.co.uk AflmHAi EhctmnkiliA-43 Hoddudofi l*duHiMGMEr& 1 *44 10}1 B92 4M?M YV peb-se faring ^ »h Riflda; ^Dan.^Dddc^dorK Hcrifardfsbiw. EMI &ff F *-$4 |Q|1S92 4 507 S 1 E s-n'e-ifipcb-icdf-rng 6a.uk Electronics Engineers - Join A Winning Team! UK, Europe and Middle East The Lektronix Group of Companies are the worlds leading provider of Industrial Automation repairs with an enviable reputation for the best in technical excellence and customer service. Due to the huge demand for our services, and our future expansion plans, we need to employ additional engineers at all our workshops to keep pace with the additional work we are receiving. We are looking for English speaking Electronic Repair Engineers, Electronic Repair Technicians and Electronic Component Level Repair Engineers in all the following locations: • Walsall, UK • Bridgend, UK • Newry, Northern Ireland • Katowice, Poland • Brno, Czech Republic • Dubai, UAE Do you have an interest in electronics? Have you any experience in the field of practical electronics? Have you experience in Radio/Television/Home Electronics? Does your hobby/interest include electronics? Are you willing to learn new tricks - electronic engineering? Do you want work in an exciting and challenging environment? Do you have any experience with Machine Tool Systems - PLC's - Servo Drives - Servo Motors - Monitors-VDU's - AC Drives - DC Drives - Temperature Control - Digital Electronics - Analogue Electronics? LeKceon X Please Contact: Mr Brian Stewart - Group Technical Director Lektronix International Ltd, Unit Cl, Lockside, Anchor Brook Ind Park, Aldridge, West Midlands, WS9 8EQ, United Kingdom. We offer a competitive salary and all the other benefits normal with a go ahead company. For an application form please either: Telephone +44 (0)1922 455555, or apply online at www.lektronix.net/about/careers 7-8/2008 - elektor 71 Heinz Kutzer Many of the soldering stations produced by Weller/Cooper Tools Group use the 'Magnas- tat' principle to control the bit temperature. The interchangeable bits are fitted with a magnetic cap which pulls on a contact in the iron and completes a circuit to switch power to the heating element. When the magnet in the tip reaches a predefined tempera- ture (the so-called 'Curie temperature') it loses its magnetism and releases the switch contact. The process is reversible so that the contact is remade as the temperature falls. A number stamped on the cap identi- fies its operating temperature: 5 = 260 °C, 6 = 31 0 °C, 7 = 370 °C and 8 = 425 °C. When used with lead based solders a 370 °C bit is the usual choice. The heating element is switched on when the tip is below this tem- perature and off when it is above it, keeping the tip temperature constant. It is fair to say that the Weller solder station is probably the most commonplace piece of test gear you are likely to encounter in labs and electronics departments up and down the country. They have a good reputation for reliability and the circuit suggested here is an add-on indicator lamp to show when the soldering tip is up to tempera- ture. The circuit described here is intended to be installed in the housing which forms the base of the soldering iron. An LED fitted to the front panel indicates when the iron is heating. The circuit works by measuring the voltage difference dropped across a shunt resistor fitted in series with the heat- ing element in the iron. It is not necessary to carry out any calibration on the circuit. This design can be fitted to the WTCP-S, WTCP 50 and WTCP 51 soldering iron sta- tions from Weller. The add-on indicator circuit can be seen in the uppermost dashed box of the cir- cuit diagram, the lower box represents the internals of the soldering iron station. A transformer in the base supplies 24 V to the heating element in the iron and is connected via a cable and three pin plug/ socket on the base unit. The heating ele- ment has an impedance of 12 O which pro- duces an average current of 2 A and a peak value of 2.822 A. Using a 33 mQ resistor for the shunt (R1) gives a voltage drop of 93 mV (peak) when the element is heating. IC2 is a LM358 type dual operational ampli- fier. The amplifiers are powered from a sin- gle-ended power supply and IC2.A is con- figured as an amplifier with a gain of 100. It amplifies the positive halfwaves of the voltage dropped across the shunt R1. The resulting output signal charges up capaci- tor C4 to approximately 10 V via diode D1 when the element is on. IC2.B is configured as a comparator and resistors R5 and R6 set the reference voltage to around 2.1 V. When the element is heating the compara- tor output is positive and the LED lights. As the operating temperature is reached the magnetic switch opens and the voltage across C4 is discharged through R4 (time constant = 100 ms) and the LED turns off. Power for the circuit is derived from the 24 V 72 elektor - 7-8/2008 transformer in the solder station. Diode D1 performs halfwave rectification and Cl is a reservoir capacitor to produce a DC voltage for the 12 V voltage regulator (IC1). The maximum offset voltage for the LM358 is only 7 mV, with a gain of 100 this can produce an output offset of 0.7 V which is well below the 2.1 V comparator thresh- old and is not likely to be a problem so it is not necessary to fit any form of offset adjustment. ( 080121 - 1 ) Play the Guitar - Recycle Tip Wisse Hettinga You'll find a pair in every attic, at every jumble sale you will see a few in a box, every hobbyist has at least about four or so among their collection of bits and pie- ces: old sets of PC speakers! After having served commendably for a few years on either side of the monitor they were disconnected and disappeared into the nooks and crannies mentioned above. This though, does not need to spell the end for these speaker sets. Anyone who calls themselves a bit of a guitar player will always have a need for a practice amplifier. v ^ And especially so if it can work from bat- teries as well. The recipe is simple. The little speaker box without the amplifier you still throw away. The speaker with the amplifier can be used as is; connect your guitar with an adapter plug going from jack to mini-jack. The output of the electric guitar does not match the input of the amplifier very well. But don't panic, a matching network between them, spruce it up a bit with some spray paint (black) and You Play the Guitar! ( 080495 - 1 ) Rainer Reusch You can pick up a 3 1 / 2 - d i g i t digital volt- meter module nowadays for a little as a couple quid. This is a simple and expen- sive way to fit out a piece of equipment with an instrument. Most modules are based on the well-known ICL7106 1C. They operate from an ordinary 9-V battery, and they only provide a fixed measuring range (200 mV or 2 V). The accessory circuit described here converts a DVM module into a voltmeter with 20-V and 200-V measuring ranges, with the added bonus of automatic range switching. This requires a ground-referenced symmetri- cal supply voltage (±5 V) instead of a bat- tery. An inexpensive TL431C is also used to generate an adjustable reference volt- age from the supply voltage. The circuit described here uses an LCD module with a fixed measuring range of 200 mV. It has three pins for driving the decimal point; two of them are used here. This is how the circuit works: IC1 converts the voltage to be measured by the DVM module into a ground-referenced volt- age. This part of the circuit is based on a design idea from Carsten Weber [1] that was published in the June 2005 issue of Elektor Electronics. If the input voltage is less than 20 V, the voltage divider formed by R1 and R4 reduces it by a factor of 100. Transistor T2 is cut off, so R3 has no effect on the divi- sion ratio. The voltage at the junction of voltage divider R8/R13 is 200 mV because the open-collector output of compara- tor IC2A is in the high-impedance state. If the input voltage rises above 20 V, IC2A changes state and the voltage at the junc- tion of voltage divider R8/R13 drops to less than 20 mV. In response to this, the output of comparator IC2B goes high and T2 conducts. R3 is now connected in paral- lel with R4. This yields a division factor of 1000 (200-V range). Of course, the larger division factor also causes the input volt- age of IC2A to drop. To prevent this com- parator from changing back to its previ- ous state (which would cause the circuit to act like a sort of oscillator), the value of R10 must be chosen such that the voltage at the junction of voltage divider R8/R13 is less than 20 mV, as previously mentioned. The calculated value (with R10 in paral- lel with R13) is approximately 9.6 mV. In practice, the value is around 18 mV due to the resistance of the output transistor of the comparator. This means that the circuit will switch back to the lower volt- age range when the input voltage drops below approximately 18 V.The amount of hysteresis can be set by adjusting the value of R10. However, the circuit will oscillate if the value is too high. Film capacitors Cl, C3 and C4 suppress noise and create a certain amount of inertia for range switching. This prevents frequent back-and-forth switch- ing in the threshold region. The other two comparators of IC2 supply mutually complementary output levels that depend on the measuring range. The associated decimal points of the DVM mod- ule are driven via p-channel FETs. 7-8/2008 - elektor 73 The circuit has two trimpots: PI is used to correct for the offset voltage of the oper- ational amplifier (IC1), while P2 is used to set the threshold level for range switching. For this purpose, first adjust the trimpot to produce the maximum possible reference voltage (around 3.4 V). Next apply an input voltage that causes a display reading of 19.99 (which ideally means 19.99 V). Now turn P2 until the measuring range switches. As a check, reduce the input voltage to force the measuring range to switch back, and then slowly increase the input voltage again. The ideal setting is reached when the measuring range switches before the DVM module displays an 'overrange' indication. ( 080249 - 1 ) Reference [1] DVM Without Isolation, Elektor Electronics June 2005. Active Rectifier Dr. Thomas Scherer Diodes make admirable rectifiers and are simple and economical, but unfortunately they also exhibit forward voltage drop, and hence also power loss. The losses in ordinary silicon diodes are of the order of 0.7 W/A to 1 W/A, and for Schottky diodes the losses are in the region of 0.4 W/A to 0.5 W/A. In a bridge rectifier these losses are doubled, as the current path is always through two diodes in series. These considerations led to the develop- ment by Wolfgang Schubert two years ago of an active rectifier using suitably- driven power MOSFETs, published in the 2006 Summer Circuits issue of Elektor. The circuit was highly symmetrical, consisting of a quad opamp and four MOSFETs, form- ing a bridge rectifier with a very low volt- age drop. However, reports in the Elektor online forum indicated that some people had experienced problems with the circuit. Curi- osity aroused, the author was prompted to look more closely at the design, and so he built a version in order to test it more thoroughly. It appeared that the outputs of the TL084 did not always swing close enough to the positive and negative rails to switch the FETs off fully. Time for some modifications. 74 elektor - 7-8/2008 FI The first thought was, why not use a trans- former with a centre tap on its secondary winding? Then we only need to simulate the action of two diodes, reducing cir- cuit complexity and cost, as well as power losses, by nearly a factor of two. It also means that we do not have to find com- plementary p-channel FETs. The second thought was, instead of using 1 % resistors, why not use two trimmer potentiometers and allow an adjustment to find the optimal switching voltages for the pseudo-diodes? The result of these considerations was the circuit shown here, which roughly resem- bles one half of the original design. AC1 and AC3 are connected to either end of the secondary winding of the mains trans- former, and AC2 is connected to its centre tap. Each half of the dual opamp drives its own power MOSFET. When power is first applied the reservoir capacitors are both discharged, and the parasitic diodes present in each MOSFET are put to positive use: through them the capacitors are initially charged to provide power for the opamp. Usually the circuit will be in normal operation after the first half-cycle of the mains. Let us suppose for illustration that the input is connected to a transformer with two 12 V secondaries and a power rating of 50 VA, and that at the output of the circuit we connect a load of approximately 5 Q . Roughly speaking we would expect a recti- fied output voltage of approximately 15 V and an output current in the region of 3 A. The voltage divider formed by R3 and R4 will provide a reference voltage of 7.5 V. Every 10 ms there will be a negative volt- age peak either on AC1 or on AC3. If the voltage at the junction of R1 and R2 or at the junction of R5 and R6 is less than the 7.5 V reference, the output of the corre- sponding opamp will go high and the con- nected MOSFET will be turned on. PI and P2 allow the point where the MOSFETs are turned on to be set individually in terms of the voltage difference between input and output. These voltages can be measured using an oscilloscope (a multimeter will not do the job!) between test points 1 and 2 and between test points 1 and 3. With the component values given the threshold voltage can be set in the range 0 V to 375 mV in our example. In prac- tice, with a 3 A load and using BUZ11 MOSFETs, a suitable threshold voltage is between 50 mV and 100 mV. Power losses in the MOSFETs are only around 150 mW to 300 mW and so the devices do not need extra cooling. The potentiometers should not be set so that the MOSFETs conduct for longer than necessary, as this leads to brief short circuits of the input, audible as a humming of the transformer. It is best to start with the potentiometers adjusted to the centre of their travel. D1 and D2 ensure that the inputs to the opamps never see excessive voltages of the wrong polarity. D3 and D4 protect the gates of the power MOSFETs. With the components shown the active rectifier is suitable for output currents of up to around 5 A. The maximum trans- former voltage is 15 V and so the output voltage is limited to about 20 V under load. With no load, a nominally 18 V trans- former with poor regulation can give rise to DC voltages of over 32 V, exceeding ICVs maximum rating. Lower-impedance toroi- dal transformers with secondaries rated at up to 20 V (corresponding to 27 V at the output under load) work fine. The reservoir capacitors should be rated at at least twice the secondary voltage of the transformer. If more current is required (as is quite likely, since the circuit is designed for operation at low voltages) higher-power (lower 'on' resistance) FETs and larger smoothing capacitors are needed. Using the IRFZ48N and two 4700 pF electrolytics up to 10 A can be delivered with minimal losses. With a small piece of aluminium as a heatsink the FETs barely get warm. The printed cir- cuit board tracks need to be reinforced with soldered wire links, and 6.3 A slow- blow fuses should be fitted for electrical safety. Other dual opamp ICs besides the AD822 can be used. The author has also had good results using an original Texas Instru- ments TLC272. The outputs of this device can swing down to very nearly 0 V, which is essential in this circuit. Other suitable types include the OPA2244 and the bet- ter-known LM358N. An Eagle layout file for the printed circuit board is available for free download from the Elektor website. The author would like to thank Hans-Jurgen Zons for his help in designing the printed circuit board. ( 080499 - 1 ) 7-8/2008 - elektor 75 GPS Receiver Thierry Duquesne GPS has many other applications than just satnav in cars and other vehicles. It can also be used, for example, to note the position of a 'secret spot' for finding wild mush- rooms out in the woodlands near your holi- day chalet in Southern France. . . Without seeking to compete with commer- cial GPS receivers, which employ powerful cartographic software to locate a vehicle or pedestrian in towns, our device quite simply lets us decode the GPS frames transmitted by the satellites and display the decoded latitude and longitude co- ordinates, which is enough information for finding where you are in the middle of a forest. Besides the cost (£ 65 or so) and the weight, the receiver described here is also interesting because of its powering, since it operates from just a simple 9 V bat- tery, unlike commercial receivers that use a special built-in battery that's usually not removable. Lastly, the system can very easily be incorpo- rated into a mobile object like a robot etc. Introduction to the GPS system The Global Positioning System (GPS) is the main current worldwide satellite position- ing system and the only one to be fully operational, while waiting for the European Galileo system. Set up by the US Defense Department in the 1960s, the system allows a person equipped with a receiver for the GPS frames to find out their position on the surface of the Earth. The first experimental satellite was launched in 1978, but the con- stellation of 24 satellites only really became operational in 1995. Operating principle The satellites send out electromagnetic waves that travel at the speed of light. Knowing this and the time the wave takes to arrive, it is possible to calculate the dis- tance between satellite and receiver. To measure the time taken by the wave to reach it, the GPS receiver compares the transmission time (included in the signal) and reception time of the wave transmitted by the satellite. If the receiver has a clock that is perfectly synchronized with that of the satellites, three satellites are enough to determine the position in three dimen- sions by triangulation. However, if this is not the case, it takes four satellites to be able to resolve the clock issue and receive Specifications: • Power supply: 5 V/ 115 mA • Built-in patch antenna • System status display via red LED (flashing if the module is searching satellites for data acquisition and steady when at least three satellites have been successfully acquired) • High sensitivity (-152 dBm for tracking, -139 dBm for acquisition) • Rechargeable back-up battery for memory and real-time clock • Position accuracy ±5 m and speed accuracy ±0.1 m/s •Only four pins: 1=GND 2 = +5VVcc 3 = serial communication: TTL, 8 data bits, no parity, 1 stop bit, uninverted (SIO: Serial Input Output) with 4,800 bps transmission 4 = mode selection (one single data Displaying longitude and latitude information There are three possible formats for displaying longitude and latitude data: • 'GPS co-ordinates' format (degrees, minutes, and fractions of minutes) e.g.: 36°35.9159 • 'DDMMSS' format (degrees, minutes, seconds) e.g.: 36°35 54.95 •'decimal' format e.g.: 36.5986° The author normally uses the 'GPS co-ordinates' format display IC1 JP1 si + 9V l V 11 D1 7805 0 ♦ X = 1N4007 C2 470n +5V © LCD1 C4 C3 ■ □=□ 470n lOOp 16V r \ LC DISPLAY LM016L v J c/> Q > V) G O V) < Oi-cMco'3-in>>OCOCLUOQQOQOQO +5V ©- R1 |> — I 1k5 I — MCLR PGD PGC GND J2 a R2 T +5V © S2 Mode +5V © ICD-2 programming i/f © Ml SIO GPS receiver RAW J3 TXD RXD GND PC comms (hyperterminal) 2 3 4 5 6 7 11 12 13 17 18 Cl 20 ih On lOOn © MCLR RB0/INT IC2 RBI RAO RB2 RA1 RB3 RA2 RB4 RA3 RB5 RA4 RB6/PGC RA5 RB7/PGD PIC16F876 RC0 RC1 RC3 RC2 RC5 RC6/TX RC4 RC7/RX J. OSC1 OSC2 J. R3 i C5 22p XI 1^1 20MHz 10 21 22 23 24 25 26 27 28 14 16 15 19 X C6 22p 6 7 8 9 10 PGD PGC 11 12 13 14 080238-11 76 elektor - 7-8/2008 IC2 = PIC16F876A (20 MHz), programmed with hex file from archive080238-11.zip the data correctly. A GPS can operate anywhere, just as long as it has an unob- structed view of the sky, 24 hours a day, 7 days a week. However, it's important to be aware that the position data may be incor- rect in the presence of electromagnetic interference. NMEA 0183 frames Most GPS receivers provide data that can be used by other devices. The standard for- mat is NMEA 0183 (National Marine & Elec- tronics Association). A NMEA 0183 frame is transmitted in the form of ASCII characters, at a rate of 4,800 baud. Each frame is preceded by '$', followed by the two letters 'GP' and three letters to identify the frame (most often GGA). Next come a certain number of comma-separated fields (making it pos- sible to separate the various data). To end, there is a checksum, preceded by the '*' symbol. This can be used to verify no errors have occurred during the transmis- sion. One frame consists of a maximum of 82 characters. After that, it moves on to a new frame. Thus any microcontroller with a serial port can extract the data from the GPD module. Here are a few examples of standard frames provided by the GPS module used in this article: $GPGGA, 170834, 4124.8963, N, 08151.6838 ; W, 1,05, 1.5, 280.2, M, -34.0, M,„*75 $GPGSA, A, 3,1 9,28,1 4,1 8,27,22,31 ,39,„„1 .7,1 .0,1 .3*34 $GPGSV, 3, 2, 11, 14, 25, 170, 00, 16, 57, 208, 39, 18 ,67,296,40,19,40,246,00*74 $GPRMC, 22051 6, A, 5133.82, N, 00042.24, W, 173.8, 231.8, 130 694, 004.2, W*70 These strings of characters can be exploited to extract the wanted information, includ- ing for example the time, date, latitude, longitude, altitude, speed and direction of movement, and even the number of satel- lites being received or the validity of the received data. The GPS receiver used is based on the inte- grated module offered by Parallax Inc. from the USA (or their local distributors). Its principal characteristics are as follows: • Reception of up to 12 satellites • Data updated once per second • 2 operating modes: - Smart Mode: when the RAW pin is open- circuit (internally pulled up to logic high), the default 'Smart Mode' is enabled. In COMPONENTS LIST Resistors R1 = lk05 R2,R3 = 10kQ Capacitors Cl = 100nF C2,C4 = 470nF C3 = 100pF 16V C5,C6 = 22pF Semiconductors D1 = 1N4007 IC1 = 7805 (TO220 case) this case, the commands for receiving the special GPS data can be executed and the result returned. Each command is repre- sented by one hexadecimal byte. Depend- ing on the command, a certain number of data bytes will be returned. To send a com- mand to the GPS receiver module, the user must first send the header characters '!GPS' (obviously without the quotes) followed by the specific command of their choice (for example, 0x02 to obtain the number of sat- ellites being received) - in this instance, the receiver module would return one byte of data with the number of satellites. - Raw Mode: When the RAW pin is forced low, the 'RAW Mode' is enabled, the mod- ule can then transmit the characters of the standard NMEA 0183 frames (GGA, GSV, GSA, and RMC), making it possible to use the raw GPS frames directly. Miscellaneous XI = 20 MHz quartz crystal (low profile) JP1,S1,S2= 2-pin connector, 5mm lead pitch J2 = 6-way SIL pinheader J3 = 3-way SIL pinheader K1 = connector for 9V battery LCD1 = LCD, 2x16 characters, e.g. LM016L or equivalent Ml = GPS receiver module type 28146 (Parallax Inc.) PCB, ref. 080238-1 from www.thepcbshop.com Certain devices, like engines, computers, and Wifi links, emit magnetic fields and interference that can prevent the module from receiving the required signals from the satellites and adversely effect its opera- tion and performance. The acquisition time for a minimum of four satellites may take up to five minutes. In the application described, we're going to be using the GPS module in 'smart mode'. Electronics Taking a look at the block diagram, we can see that our receiver revolves around a PIC16F876A microcontroller from Micro- chip Technology. Amongst its other tasks, it takes care of the transcoding and dia- logue between the Parallax GPS receiver and the LCD display. It's worth noting that the circuit has been 7-8/2008 - elektor 77 designed with two operating modes: you can either display just the geographical co-ordinates of latitude and longitude, or scroll through a whole mass of information (received frame validity, number of satel- lites received, date, GMT, altitude, latitude, longitude, and so on). Powering is by way of a simple 9 V dry bat- tery (or rechargeable), which connects to terminal block JP1. The 5 V supply voltage is generated by IC3, a 7805 regulator. Con- nector J3 allows dialogue with a PC via an RS-232 link (make provision for interfacing with a MAX232), while connector J2 allows programming of the PIC and in-circuit debugging thanks to the ICD2 marketed by Microchip. The on/off switch SI connects to the SI ter- minal block on the board, the mode selec- tion switch connects to the adjacent S2 terminal block. PCB It only takes a few minutes to build this cir- cuit using the circuit board suggested here. The first step consists of soldering the small number of wire links, then the resistors, 1C socket, unpolarized capacitors, and then the electrolytic capacitors, taking great care to observe correct polarity. Check for the presence of power on the correct pins of the 1C socket. If everything is OK, next fit the programmed PIC (with the power off) into the socket, and finish by fitting the LCD display and the GPS module. The circuit should then work as soon as power is applied. Selecting the display mode By default, at power up the receiver displays the latitude and longitude co-ordinates. If you want to display more information, all you have to do is keep button S2 pressed as you power up the receiver. ( 080238 - 1 ) Downloads The PCB artwork is available for free downloading from our website www.elektor.com; archive file 080238-1.zip. The source code and .hex files for this project are also available from www.elektor.com; archive file 080238-11.zip. Web Links GPS 28146 manual: www.parallax.com/Portals/O/Downloads/docs/prod/ acc/GPSManualVI. 1.pdf PIC16F87XA data sheet: ww1.microchip.com/downloads/en/DeviceDoc/ 39582b.pdf ZigBee-based Wireless Motion Sensor Sven van Vaerenbergh +3V3 IC2 LM1117-3.3 ZigBee Master £ BT2 9V 5 +3V3 1 2 3 4 5 6 7 8 9 10 XBee vcc TX RX CD* Reset PWM nc nc Slp/DTR GND i/o i/o i/o i/o *RTS i/o Vref Status *CTS i/o 20 19 18 17 J 6 2 5 _14 13 12 11 Digital Output t> 6 ♦ o 080166-11 It's easy put together a ZigBee wireless system if you use the XBee and XBee Pro modules. In this circuit, they are used to read the signal from a passive infrared PIR) motion sensor. This signal can be sent from one module to the other by using I/O Line Passing. A digital input signal on the DI01 pin (pin 19) of module A can drive a digital output signal (DI01) of module B. Similarly, an analogue input signal on ADO of mod- ule A (pin 20) can control a PWM output signal of module B. The 'master' module receives the sensor information from the 'slave' ZigBee mod- ules. A single PIR sensor (type AMN14112) is connected to each slave. It has a digital output, a detection range of 10 metres, and an operating voltage of 5 V. As the ZigBee modules operate from 3.3 V, the lower sup- ply voltage is obtained by using a 3.3-V regulator (type 1117) in combination with the circuit shown here. The schematic diagram is simple and con- sists of only a few components: a 3.3-V volt- age regulator with a 9-V battery, the mod- ule, the PIR sensor, and a transistor. The transistor pulls the digital input of the Zig- Bee module to ground when the PIR sen- sor detects motion. When the PIR sensor does not see anything, the transistor is cut off and the 3.3-V supply voltage is applied to the ZigBee module via a 2.2-kO pull-up resistor. Power is provided by the 9-V bat- tery. This compact circuit can be built into a small case (so it can be placed in the gar- den, for example). The modules are programmed using the X-CTU program. The data sheet for the 78 elektor - 7-8/2008 XBee modules is quite clear, and the com- mands are simple. The screenshot shows a terminal emulator with the settings for the transmitter module (with the connected PIR sensor). Be sure to update the ZigBee command set to version 10A2 (vl.xAO*) when you are programming the modules, as otherwise you cannot include parameters with some of the commands and the module will not understand some of the commands. Also be sure to perform a Read opera- tion first when you update the firmware (from 1083 to 10A2). If you immediately perform a Write with the new version, you will lose communication with the module because the configured parameters will be overwritten. The PIR transmitter module can be placed anywhere within a range of 30 metres from the receiver, such as in the garden. For a larger range, you can use the somewhat more expensive XBee Pro modules. ( 080166 - 1 ) Downloads The source code and hex code for this design are avai- lable on www.elektor.com for free downloading; file # 080166-11.zip. Master ZigBee code (receiver) ATMY = 1 (Master address = 1) ATDL = 0 (The address of the module it must receive data from is 0) ATPL = 0 (Low power consumption) ATIU = 1 (Disable transmission via UART) ATBD = 3 (Set communication to 9600 baud) ATD0 = 5 (Digital output on pin 20 of the module) ATD1 = 5 (Digital output on pin 19 of the module) ATIA = 0 (The master must change its outputs based on the slave with address 0. If ATIA = OxFFFF, the master will change its outputs based on each received packet, independently of the address of the transmitter.) ATWR (Save the settings in the flash memory) Slave ZigBee code (transmitter) ATMY = 1 (Slave address = 0) ATDL = 0 (The address to which it must transmit is 1) ATPL = 0 (Low power consumption) ATIU = 1 (Disable transmission via UART) ATBD = 3 (Set communication to 9600 baud) ATD0 = 3 (Read the digital input signal on pin 20) ATD1 = 3 (Read the digital input signal on pin 19) ATIR = 14 (Sampling rate = 0x14) ATWR (Save the settings in the flash memory) Logic Goats Rob Ives The central processing unit (CPU) at the heart of every computer or microcon- troller system is basically a vast collection of microscopically small switches and logic gates. Unfortunately, the function of the logic gates in particular seems hard to grasp for the not too technically minded (or those who can't read simple tables). Now, through the power of paper (cheap and generally available) these logic gates are available in goat form. Properly constructed from the DIY guide the AND goat will nod its head only in you press the right button and the left button. The OR goat, then, will nod its head in approval when the left button or the right button or both buttons are pressed. The NOT goat, finally, gives a friendly nod of the head when the button is not pressed. These models can be made from paper using delightfully designed cut-and-fold models you can download on the Fly- ing Pig website. Suitable for age range 5 through 105 (some help may be required at the extremes). ( 080482 - 1 ) Web Link www.flying-pig.co.uk/pagesv/logicgoat.html 7-8/2008 - elektor 79 Simple Capacitive Touch Sensor ■ " - » - — - — — - — ~ - . Wim Abuys Capacitive touch sensors are based on the electrical capacitance of the human body. When, for example, a finger comes close to the sensor, it creates a capacitance to Earth with a value of 30 to 100 pF. This effect can be used for proximity detection and touch- controlled switching. Capacitive switches have clear advantages compared to other types of touch switches (for example 50 Hz or 60 Hz detection or resistance detection), but are often more complex to implement. Manufacturers such as Microchip have in the past designed spe- cialist ICs for this purpose. However, it is still possible to design a reliable capacitive detector and/or switch using only a limited number of standard components. In this design we detect the change in the pulsewidth of the signal when the contact is touched. In Figure 1 the following stages can be recognised, from left to right: -a square-wave generator with a fre- quency of 300 kHz, using a Schmitt trigger 1C (CD4093); - an RC network with a flyback diode, fol- lowed by a Schmitt trigger/contact plate with an isolation capacitor of 470 pF; - an RC network that converts the change in pulsewidth into a voltage. This voltage is about 2.9-3. 2 V when the plate is touched (and 2.6 V when it isn't touched); - an LM339 comparator is used to compare the voltage at point C with a reference volt- age (D). The latter is set to about 2.8 V using a potential divider. As long as the contact plate is touched the output of the circuit will be active. To make the operation of the circuit clearer we have 2 i — \ \ \ \ 1 1 \ ! / / / § 1 1 I / / / i 1 1 a ¥ t 1 t V | f 1 J 1 1 1 ■ 1 | i — i ® 1 1 1 1 1 1 1 1 1 1 1 1 1 1 i i i i 1 1 1 .! i 1 © 080175- 12 shown the signals at various points in Fig- ure 2. The dotted line represents the sig- nal when the plate is touched, the solid line when it isn't touched. The reference voltage at D has to be set up once via potential divider R4/R5 (change the value of R4). The required value is strongly dependent on the surface area of the contact plate (this is usually a few square centimetres). Larger surfaces increase the capacitance and the voltage at C will therefore be greater when the plate isn't touched. The reference voltage at D should then be set closer to 3.4 V. The touch sensor can therefore also be made to work with larger areas (such as the com- plete metal enclosure of a device). The circuit only works when a connection for higher frequencies (300 kHz) is made to Earth in some way. The circuit therefore doesn't work in battery-powered systems without a connection to Earth. In many systems without a direct connection to Earth there is sufficient parasitic capaci- tance to the mains Earth. In some cases it will be necessary to add an extra capacitor IC1 = 4093 IC2 = LM339D £] ic i ™ JC4 © JC5 p| 100n 6?) 100n LJ R4 R1 (p lOOn 1 10k I 1 < > — <► GND C3 lOOn R5 GND +5V O R6 K1 F) + k o K2 80 elektor - 7-8/2008 080175-1 ©Elektor COMPONENTS LIST Resistors R1,R2,R6 = 10kQ R3,R5 = lOOkO R4 = 47kO Capacitors C1,C2 = 470pF C3,C4,C5 = lOOnF Semicondcutors D1 = 1N4148 IC1 = 4093 IC2 = LM339D Miscellaneous K1,K2 = 2-way pinheader PCB, ref. 080175-1 from www.thepcbshop.com between the mains Earth and the Ground of the circuit. To comply with safety regu- lations this capacitor should be rated for >3-4 kV (i.e. a Class Y capacitor). The output signal can be used in various ways to switch on systems. The addition of an extra Schmitt trigger to the output is recommended in many cases, especially if the output connects to a digital input. ( 080175 - 1 ) Downloads The layout for the printed circuit board is available from the Elektor Electronics website as a free down load; ref. 080175-1.zip. =T V Muter O— Michael Holzl Many households are still graced by tube- type television sets. If you want to connect one of these large tellies to your stereo sys- tem to improve the sound quality, this is usually not a problem because there are plenty of SCART to Cinch adapters avail- able in accessory shops. However, with some sets your pleasure is spoiled by the fact that the audio outputs of the SCART connector are not muted during channel switching. This can some- times lead to nasty signal spikes, which can cause the loudspeakers of your stereo sys- tem to emit irritating popping and cracking noises. In such cases it is a good idea to fit your system with a mute circuit. Fortunately, the right time to activate the mute circuit is defined by the fact that the happy zapper presses buttons on the remote control to switch channels, and the remote control emits IR signals. There are even inexpensive ready-made IR receiver modules available, such as the TSOP1136 used here, which produce trains of active- low pulses in response to such signals. About the circuit: when no IR signal is present, a capacitor is charged via P2 and a diode. IC1 is a comparator that compares this IR voltage (applied to its non-inverting input on pin 3) to a voltage applied to its other input on pin 2. This reference voltage, which can be adjusted with PI, determines the switching threshold of the comparator. If IC2 receives an IR signal, T2 conducts, and as a result the voltage on Cl drops rapidly below the threshold level set by PI. This causes T1 to change from its previous 'on' state to the 'off' state. As a result, the relay drops out and the audio link to the stereo system is interrupted for the duration of 7-8/2008 - elektor 81 the noise interval. It's all quite simple, as you can see. If you do not have a stabilised 5-V supply voltage available, you can use the circuit at the of the schematic diagram (with a 5-V voltage regulator) together with a simple (unstabilised) AC mains adapter that sup- plies a voltage in the range of 9 V to 12 V to the 7805 (IC3). You can also use a relay with normally- closed contacts instead of normally-open contacts. In this case, simply swap the sig- nals on pins 2 and 3 of IC1 so the relay pulls in when an IR signal is received instead of dropping out. This saves a bit of power because the relay is only energised during zapping. If you can't find any worthwhile use for the second comparator of IC1, it's a good idea to connect pin 6 to +5 V and pin 5 to ground. To improve noise immunity, you should shield the IR sensor so it is not exposed directly to light from a fluorescent fixture. ( 080325 - 1 ) Universal Thermostat Ruud van Steenis This circuit came about because of the dis- satisfaction regarding the operation of the thermostat in a refrigerator. When using the built-in thermostat, it turned out that it was necessary to reduce the temperature setting in the summer in order to keep everything cold, compared to the set- ting in winter. This is probably as a result of a temperature sensor that is mounted too close to the cooling element, which means that phenomena such as thermal leaks and the average temperature in the fridge are not sufficiently accounted for in the control loop. While designing the circuit for this elec- tronic thermostat a decision was made to increase the control range so that it would also be suitable for other appli- cations. Potential applications are the temperature control of a (living) room, heating of a flower box and obviously the etching tank! The control range is adjustable from -25 °C to +75 °C in steps of 0.25 °C. The hysteresis is also adjustable. Hysteresis is the temper- ature error at which the system will turn on or off. A very small hysteresis results in a very stable temperature but has as disad- vantage that the heating or cooling system turns on and off at a high rate, which gen- erally leads to extra wear and tear in the compressor (cooling) or pump (heating). The hysteresis can be adjusted from 0.1 °C (very stable temperature) to 10 °C (practi- cally no control at all...) in steps of 0.1 °C. The settings can be changed with 3 push buttons and the information is displayed on a 2x16 character LCD. The settings are stored in the EEPROM inside the PIC. Dur- ing normal operation the LCD is used to display the actual temperature. The main component in this circuit consists of a PIC 16F628. In addition to the afore- mentioned 2x16 character LC display, the D1 1N4001 IC1 K1 + Q >1 7805 0 t Cl □ 10ja 63V ft 1 N4 ° 01 a BC547 IC3 © DS1820 +5V ■o C2 U±3 10|a 63V K4 +5V © / Pi 10k R4 H 2k2 J fc 6 K3 f O- O- K5 C= O- O R5 I LCD v > fo o o o o o o o o o o o o o o o| • ••• 10 +5V © Tr6 17 18 ^^00n © MCLR RB0 RBI RAO IC2 RB2 RA1 RB3 RA2 RB4 RA3 RB5 RA4 RB6 PIC16F628 RB7 OSC1 OSC2 -u 16 XI I I 15 4MHz 8 9_ 10 11 11 12 13 12 13 14 15 16 1 > +5V R7 R3 R2 R1 S1_„ S2 S3 _ td 6 td 6 btl n© n + 6 O MODE 080090 - 11 82 elektor - 7-8/2008 temperature sensor, type DS1820, also serves an important role in the circuit (con- nected to K5). Fortunately the DS1820 is already factory calibrated, so this saves us from a difficult task. A classic 7805-regula- tor and a common transistor pretty much complete the circuit. The clock source for the PIC is supplied by a 4 MHz ceramic reso- nator with built-in capacitors (Conrad Elec- tronics order number 726406/726507). There are two switching outputs from the PIC, one for cooling applications and another one when heating is called for. When cooling, the refrigeration system obviously has to be turned on when the temperature is too high, while when heat- ing, the appropriate action needs to be taken when the temperature threatens to become too low. A jumper in this cir- cuit makes the selection between cooling (jumper 2-3 on K3) and heating (jumper 1-2 on K3) possible. When the circuit is turned on, the display shows 'temperature' with underneath that the actual temperature in degrees Cel- sius. If the sensor is not connected then an error message will be displayed. By holding down the 'Mode' button until an asterisk appears, the text 'set temperature' appears and you can set the desired temperature in steps with the + and - buttons. By press- ing the Mode-button again it is possible to set the desired hysteresis with the + and - buttons. A hysteresis of 1 °C means that with a tem- perature setpoint of 20 °C and when heat- ing, the output becomes active when the temperature drops below 19 °C (20-1), while everything turns off when the tem- perature reaches 21 °C (20+1). To connect the circuit to external equip- ment a relay control (via K2) was chosen because of safety considerations. The transistor can easily handle currents up to 100 mA and a free-wheeling diode sup- presses the back-emf from the relay coil. The power supply voltage can be selected based on the rated coil voltage of the relay that is used, 12 V, for example. Keep in mind that when using this circuit to replace the thermostat in a fridge, the com- pressor motor which is to be controlled is directly connected to the mains and a safe implementation of the complete circuit is therefore absolutely essential. If this circuit is used to heat, for example, a flower box, it can be useful to replace the switching transistor with a HEXFET. A pro- totype circuit with an IRFP3710, supplied a 12-V heating element with 1.5 A without any trouble at all, while the losses where so small that no heatsink was required. The 5-V output voltage from the PIC was in this case sufficient to turn the FET on properly. The program in the 16F628 fills only about half of the available program memory space. Because there was no compelling need to program the whole thing in a par- ticularly 'compact' way, the PicBasic Pro compiler was used for generating the hex file for the PIC. Both the source file (1820THER.BAS) as well as the hex file to be programmed into the 16F628 (1820THER.HEX) are available free from the Elektor website as file number 080090-11.zip. The source code is liberally commented, so that making changes (changing the temperature range, for example) is quite straightforward. The temperature is initially set to 20 °C and the hysteresis to 2 °C. For the sensor it is best if you use a 'plain' DS1820 and fit it with a length of 3-way ribbon cable. When using it with a refrig- erator this has the advantage that the sensor cable can be easily routed to the outside because the rubber seal on the fridge door still closes sufficiently well to seal around the cable. Once the ribbon COMPONENTS LIST Resistors R1,R2,R3,R5 = 4kQ7 R4 = 2kQ2 R6 = 10kQ R7 = 330 PI = 10kQ preset Capacitor C1,C2 = 10pF 63V C3 = lOOnF Semiconductors D1,D2 = 1N4001 T1 = BC547 IC1 = 7805 IC2 = PIC16F628-04/P (programmed, with software # 080090-11) Miscellaneous XI = 4MHz ceramic resonator SI ...S3 = miniature push button K1,K2 = 2-way pinheader K3,K5 = 3-way pinheader K4 = 16-way pinheader DS1820 and 3-way ribbon cable LCD with 2x16 characters PCB #080090-1 from www.thepcbshop.com cable is connected to the DS1820, you can cover the sensor entirely with a thin layer of two-part epoxy glue and (before the glue has set) shrink a small length of heatshrink tubing around it. This gives a good, waterproof seal. Alternatively you can buy a ready-made waterproof DS1820 sensor (for example Conrad Electronics # 184037/184052). These have, however, a type of telephone cable that is somewhat thicker than the rib- bon cable. ( 080090 - 1 ) Downloads The source- and hex-code for this project, 080090- 11. zip, as well as the layout for the PCB (080090-1.zip) are available as a free download from the Elektor website. 7-8/2008 - elektor 83 Features •Controls 6 high-power DC devices Five digits password security • User-defined password • Feedback to user by sounds • Password and device status retained in EEPROM • Device status on LED panel Hesam Moshiri Caution. This circuit is not approved for connection to the public switched telephone network (PSTN). Caution. Observe electrical safety precautions when connecting mains- operated loads to the circuit. This circuit can be called using your mobile or a regular telephone set (with DTMF keys) and after passing some procedures, you can control DC-powered appliances installed in your home. Examples include the front door latch and the pump of a plant watering system. You call the circuit and after three rings, it will answer your call and you will hear two little beeps. Next you enter your pass- word. The default password for the circuit is: 12345 . Finish the password number with a hash (#) character. If your pass- word is correct, you will hear two short beeps and you can control your devices or change a password. If you push the char- acter * you will enter the password menu. Enter a new password using numbers (0-9) and with five digits length. Close off with a # at the end of the new password (e.g. 54321#). You will hear one long beep indi- cating that your new password is stored in memory and the circuit will disconnect the phone connection. If you do not push *, you can control your devices by enter- ing pre-assigned numbers. For example, the number T is for home front or rear door and every time you push it the door will open. Numbers 2-6 are for controlling five other devices. With every key push you change a device status and you will hear appropriate sounds that relate to the device status (see flowchart). After every command, the new device status will be stored in EEPROM. Once all devices have been controlled, simply hang up. If the circuit is called but the user doesn't after 7 seconds. In all of these procedures, enter any numbers, the circuit will hang up when you enter any number, the circuit D9 = zener diode 4V7 400mW D10-D15 = 1N4001 T1 = BD139 IC1 = Atmega8-16PC, programmed, Elektor Shop #080037-41 IC2 = MT8870 IC3 = 7805 IC4 = ULN2004 Miscellaneous RE1-RE6= 12V coil, e.g.V23057 XI = 3.5795MHz quartz crystal K1,K2,K3 = 10-way boxheader K4 = PCB terminal block, lead pitch 5mm K5-K10 = PCB terminal block, lead pitch 7.5mm Kll = RJ11 connector, PCB mount, Hirose TM5RE1-64 (Digikey # H11257-ND) J1,J2 = 3-way SIL pinheader with jumper PCB, ref. 080037-1 from www.thepcbshop.com COMPONENTS LIST Resistors R1 = 68kO R2,R4 = IkO R3 = 3300 R5 = lOkO R6 = lOOkO R7 = 220kO R8-R15 = 2200 Capacitors Cl ,C2,C3,C5,C9-C1 2,C1 5 = lOOnF C4 = 2pF2 40V radial C13 = lOOOpF 40V radial C14 = lOOpF 40V radial Semiconductors B1,B2 = B40C1500 (80Vpiv, 1.5A) D1-D8 = LED, low current, 3mm 84 elektor - 7-8/2008 o o 7-8/2008 - eleklor 85 will acknowledge reception with one short beep. Please wait briefly for the circuit to receive and process the number pressed. A maximum of three wrong password entries is accepted. With every wrong pass- word you enter, you will hear one long beep and if you enter a wrong password thrice, you will hear one long beep again and the circuit will hang up on you. The circuit shows the status of all devices by its LED panel. D1 indicates the circuit power, D2 the answer status (ON: phone line is busy; OFF: phone line is free). The other LEDs indicate the status of the con- trolled devices (LED ON: device = ON, LED OFF: device = OFF). The schematic diagram Figure 1 has these main parts: power supply, ring detector, answering circuit, tone decoder, microcon- troller, output relays and LED panel driver. The power supply includes IC3, C6, C7 and C8 producing the +5 V supply voltage for the circuit. The ring detector comprises B2, C1-C4, R1, R2 and D9. Cl, C2 and C3 pick up the ring (AC) voltage of between 80 V and 100V, 25 Hz. B2 converts the ring voltage to DC. C4 serves for noise reduction and R1, R2 and D9 create a suitable voltage level at the PD4 pin of the microcontroller. When you call the circuit, one +5 V ring pulse appears at the cathode D9. The answer cir- cuit includes B1, C5, R4, R3 and T1. If you want the circuit to answer to one ring, put one resistor in parallel with the telephone line, reducing the line voltage to approxi- Table 1 . ATmega8 programming settings CKSEL0 0 CKSEL1 0 CKSEL2 1 CKSEL3 0 CKOPT 1 1: Unprogrammed, 0: Programmed mately 15 VDC and passing about 20 mA through the resistor. Answering the call implies driving T1 into saturation. Therefore the telephone line current will pass through R3. To hang up, T1 is switched off. The func- tion of C5 is to inject a sound produced by the microcontroller. The DTMF tone decoder circuit includes R5, R6, R7, C9, CIO, Cl 1, XI and IC2. IC2 (an MT8870) is a DTMF tone decoder 1C. It receives the DTMF tones via R5, R6 and C9. The corresponding binary data of each code appears on the Q1-Q4 pins. An incom- ing code is indicated by a rising edge on the STD pin. The event is fed to the INTO pin of the microcontroller. A High level on the TOE pin of the MV8870 enables the outputs Q1-Q4. Here it is strapped to the +5 V rail. The micro is an ATMega8 from Atmel. The final stage has a ULN2003 high voltage and high current Darlington transistor array 1C, that easily copes with the relay and LED panel currents. Each output pin of this 1C can drive up to 500 mA. The LED panel includes D1-D8 that indicate circuit acti- vity and status of all devices. Caps C11 and C12 are included for noise reduction and it is to use multilayer capacitors ceramic for this purpose. The PCB for the controller is shown in Fig- ure 2. One PCB section comprises the main circuit the other is for the LED panel. The two PCBs are interconnected with a 10-way (2x5) IDC connector. Once the circuit has been built up, the micro has to be programmed with the firmware hex file from free download archive 080037-11.zip found on the Ele- ktor website. The source code is also avail- able: it was produced using MikroC from MikroElektronika. Connect the 9-12 VDC mains adapter to J1. Next, program the microcontroller by means of the ISP socket, K2. Select an 8- MHz internal clock source for the micro by setting the fuse bits per Table 1. Don't for- get to program both the Flash (filename, hex) and the EEPROM (filename. eep) file! Connect your electrical appliances to the circuit observing all relevant electrical safety precautions. The EEPROM in the cir- cuit ensures that settings are not lost after a reset or when a mains power interruption occurs. Finally, we can calculate the security of the system. With a five-digit password, we have a 1 in 100,000 probability of hitting the correct code by chance, which seems adequate for such a simple system. ( 080037 - 1 ) USB Standby Killer Wim Abuys When turning a computer on and off, vari- ous peripherals (such as printers, screen, scanner, etc.) often have to be turned on and off as well. By using the 5-V supply voltage from the USB interface on the PC, all these peripherals can easily be switched on and off at the same time as the PC. This principle can also be used with other appli- ances that have a USB interface (such as modern TVs and radios). This so-called 'USB-standby-killer' can be realised with just 5 components. The USB output voltage provides for the activation of the triac opto-driver (MOC3043) which has zero-crossing detection. This, in turn, drives the TRIAC, type BT126. R1 R2 FI 230V 230V MOC3043 BT136 MT2 MT1 080259-11 MT2 86 elektor - 7-8/2008 The circuit shown is used by the author for switching loads with a total power of about 150 W and is protected with a 1-A fuse. The circuit can easily handle much larger loads however. In that case and/or when using a very inductive load a so-called snub- ber network is required across the triac. The value of the fuse will also need to be changed as appropriate. The circuit can easily be built into a mains multi-way powerboard. Make sure you have good isolation between the USB and mains sections (refer to the Electri- cal Safety page published regularly in this magazine). ( 080259 - 1 ) J.Geene In most countries it is now mandatory or at least recommended to have a rear fog light on a trailer with the additional requirement that, when the trailer is coupled to the car, the rear fog light of the towing car has to be off. The circuit shown here is eminently suitable for this application. The circuit is placed near the rear fog light of the car. The 12-V connection to the lamp has to be interrupted and is instead con- nected to relay contacts 30 and 87A (K1, K3). When the rear fog light is turned on it will continue to operate normally. If a trailer with fog light is now connected to the trai- ler connector (7- or 13-way, K2), a current will flow through LI. LI is a coil with about 8 turns, wound around reed contact SI. SI will close because of the current through LI, which in turn energises relay Rel and the rear fog light of the car is switched off. The fog light of the trailer is on, obviously. The size of LI depends on reed contact SI . The fog lamp is 21 W, so at 12 V there is a current of 1.75 A. LI is sized for a current between 1.0 and 1.5 A, so that it is certain that the contact closes. The wire size has to be about 0.8 mm. The relay Rel is an auto- motive relay that is capable of switching the lamp current. The voltage drop across LI is negligible. ( 080261 - 1 ) 22-bit A/D Converters Steffen Graf When accuracy matters more than speed, the MCP3550 series of analogue-to-digital converters from Microchip [1] is worth a look. They are ideal for accurately measu- ring DC voltages that only change slowly over time, offering an extremely high reso- lution of 22 bits while only drawing a paltry 150 pA from a 5 V power supply. With the addition of a low power voltage reference such as the MAX6520 [2] as shown in the circuit diagram we have an ultra-pre- cise analogue-to-digital converter with a total current consumption of around 0.2 mA, using only a minimum number of compo- nents. The conversion results are output using a serial interface that is easy to con- nect to the SPI port of a microcontroller. A file containing a printed circuit board layout for this design is available for free download from http://www.elektor.com. vcc Notch Fs Effective Part frequency resolution (Hz) (Hz) (bit) MCP3550-50 50 12.5 21.9 MCP3550-60 60 15 21.9 MCP3551 50 & 60 13.75 21.9 MCP3553 - 60 20.6 Microchip make four versions of these ICs. As the table shows, they differ in the fre- quency of the built-in notch filter, which is designed to help suppress mains hum. They also have different sample frequencies, as well as different effective resolutions. ( 070967 - 1 ) Web Links [1] http://ww1.microchip.com/downloads/en/ DeviceDoc/21 950d.pdf [2] http://datasheets.maxim-ic.com/en/ds/ MAX6520.pdf 7-8/2008 - elektor 87 Solar-powered Battery Charger C. Tavernier Long before the current fashion for sustain- able development caused solar panels to blossom on roofs and terraces in non sun drenched areas of the world, numerous nomadic and Route 66 users were already using them on motor-homes or pleasure craft. In these situations, the primary role of a solar panel is not to sell power back to the local electricity board or utility, but to charge an array of batteries in our on the vehicle or craft to provide a source of elec- tricity after dark. Even though such an operation might appear trivial, all the more so if you look at certain 'charger' circuits, it really is noth- ing of the sort, if you're keen to look after your batteries. Even though it does work, the solution of wiring batteries, supplied load, and solar panels in parallel is far from being satisfactory in at least two situations, which we'll discuss below. When the load powered by the batteries consumes little or nothing at all, and the batteries are already well charged, and it's also a sunny day, the batteries are in seri- ous danger of being over-charged, which as everyone knows will severely shorten their life — and possibly your travel, ling distance. On the other hand, when the load powered by the batteries is drawing a lot of current and there is little or no sun, the batteries can end up completely discharged, which as it may turn out is just as detrimental to their life as over-charging. Yet it takes only a handful of components to build our intelligent regulator, the cir- cuit of which is given in Figure 1 . It uses a PIC 12C671 microcontroller, which has the double advantage of being housed in an 8-pin DIL package and containing a multi- input analogue/digital converter (DAC). Potential divider R6-P2-R7 feeds a discrete voltage level to ANO to set the battery volt- age at which charging should be stopped, to prevent any risk of over-charging. Poten- tial divider R8-P1 and R5, feeding PIC ana- logue input line AN1, this time defines the battery voltage below which the load should be disconnected to avoid excessive discharge. In this way, a voltage window is created for the PIC to maintain in the inter- est of the battery's health and lifetime — and your peace of mind, of course. The voltage present at the battery termi- nals is measured via the potential divider - fixed this time - R1 and R2, feeding PIC port line AN2. Zener diode D5 protects the microcontroller from any spurious external voltage that might appear on the terminals of the solar panels - during thunderstorms, for example. Depending on the above mentioned volt- age thresholds, the circuit controls relays Rel and Re2, via transistors T1 and T2. The first is used to connect the solar panels to the battery. Hence it is energized as long as the battery is not being over-charged, otherwise it is off. The second, T2, is used to connect the battery to the load being powered. So it is energized as long as the battery is not too deeply discharged, oth- erwise it is off. Diode D1, which must be a Schottky type to minimize the forward voltage drop, avoids the battery discharging through the solar panel in periods of weak sunshine. A nor- mal silicon diode in this position will have a too high forward drop (about 0.6-0.7 V) to ensure optimum results hence is not recommended. Note the 4-pin connector at the bottom of the circuit diagram. This allows the present charger to be connected to the Solar-pow- ered Automatic Lighting Module described elsewhere in this issue. If this module is not being used, all you need do is connect a jumper across pins 1 and 2, as indicated in the diagram. To make this project easy to build, we've designed the PCB shown here. As usual, the copper track layout is contained in the free download available from the Elektor web- site. This PCB has been designed for 10 A Finder SPDT relays, which leaves plenty of freedom in terms of choice of panels and battery. When designing this charger, we 88 elektor - 7-8/2008 + SOLAR - SOLAR + BATT - BATT + LOAD - LOAD COMPONENTS LIST Semiconductors D1= 1N5821 Resistors D2,D3 = 1 N4148 R1 = 15kO D4 = 1 N4004 R2-R4 = 5kQ6 D5 = zener diode 4V7 400mW R5,R7 = 2k02 Q1,Q2 = BC548 R6,R8 = 8200 IC1 = 78L05 P1,P2 = IkO potentiometer IC2 = PIC12C671, programmed, see Downloads Capacitors Miscellaneous Cl = 470 pF 25V Rel1,Rel2 = relay, 10A contact C2,C5,C6 = lOOnF FI = fuse, 2A C3 = 220nF 4-way SIL pinheader C4 = 10nF 6 PCB terminal blocks, 5mm lead pitch C7 = lOpF 25 V 1 wire bridge PCB, ref. 080225-1 from www.thepcbshop.com planned for a maximum battery current of 2 A, as indicated by the fuse value given, but there's nothing - apart, perhaps, from your wallet, for the cost of the battery and solar panels - to stop you from going higher. The .hex file to be programmed into the PIC 12C671 is available free to download on the Elektor server, as well as from the author's own website (see end of article). Once built, the project is elementary to adjust, and only requires a DC voltmeter and an adjustable PSU, even a very simple one. Do not connect any of the external elements to the charger, and replace the battery by your stabilized PSU set to 12 V, with a voltmeter across it. Then increase the voltage to 14.5 V and adjust P2 so that Rell just drops out. Then reduce this voltage to confirm that Rell is energized again at around 12.8-13 V (depending on component tolerances). Continue to reduce the voltage down to 10.5 V and then adjust PI so that Rel2 drops out. Increase the voltage again to check that Rel2 is energized again around 12 V or just under. PI and P2 do not interact, so it is easy to adjust them independently. Lock the wipers of PI and P2 with a little sealant and fit your project into a case, tak- ing care to protect it from damp if it is to be used outdoors. A sealed electrical junc- tion box is ideal for this, at a ridiculously cheap price. (www.tavernier-c.com) (080225-1) Downloads The source code and .hex files for this project are available for free from www.elektor.com; file # 080225-11.zip. The PCB design is available for free download from our website www.elektor.com; file # 080225-1.zip Simple LED Bike Light Gatze Labordus On my mountain bike I always used to have one of those well-known flashing LED lights from the highstreet shop. These often gave me trouble with flat batteries and lights that fell off. As an electronics stu- dent I thought: "this can be done better". First I bought another front wheel, one which has a dynamo already built in the hub. This supplied a nice sine wave of 30 Vpp (at no load). With this knowledge I designed a simple power supply. The transistors that are used are type BD911. These are a bit of an over- kill, but there were plenty of these at my school, so that is why I used them. Some- thing a little smaller will also work. The power supply is connected to an asta- ble multi-vibrator. This alternately drives T1 BD911 4x 1 N4004 R1 D5 Cl C2 —I— n±j !==□ / 47 n 47n 47|J. 63V 47(x 63V 6V8 J2 LAI Y R3 C4 10(4 I 63V T3 Q> — X BD911 R2 J3 C3 10n 1 63V T2 o Y €> BD911 LA2 080504-11 the front light and the rear light. The fre- can be calculated with the formula: quency is determined by the RC time-con- stant of R3 and C3, and R2 and C4. This time t = R3xC3 = 20x10 3 x10x10 -6 = 0.2 s 7-8/2008 - elektor 89 You can use a 22 kQ (common value) for R2 and R3, that doesn't make much difference. On a small piece of prototyping board are six LEDs with a voltage dropping resistor in series with each pair of LEDs. Such a PCB is used for both the front and the rear of the bike. Of course, you use white LEDs for the front and red ones for the rear. The PCB with the main circuit is mounted under the seat, where it is safe and has been working for more than a year now. There are a few things I would change for the next revision. An on/off switch would be nice. And if the whole circuit was built with SMD parts it could be mounted near the front light. This would also be more convenient when routing the wiring. Now the cable from the dynamo goes all the way to the seat and from there to the front and rear lights. ( 080504 - 1 ) Solar-powered Uninterruptible PSU C. Tavernier When you want to power an electronic device from solar panels, broadly speaking there are currently two approaches. The first, very conventional method (described elsewhere in this double issue) consists of employing a combination of solar panels (or an array), an automatic charger, and a battery (or an array). This combination then powers the device concerned, which has its own voltage regulating circuits. The second, which we are proposing in this project, consists of building a 'solar' PSU directly. It is of course based on the same concept as the one described above, but having been designed for this purpose right from the start, the elements it com- poses are integrated to a higher extent, leading to improved efficiency. Our suggested circuit is intended to power a number of current electronic devices directly, and can provide three different voltages: 3.3 V, 5 V or 12 V, depending on component selection; all at a current of 400 mA, which can even be increased to 1 A if necessary (details below). It's primarily based around IC3, a high-per- formance switching regulator from Linear Technology. Depending on whether you choose an LT1300 [1] or an LT1301 (*) [2] you will have a choice of two output volt- ages: 3.3 or 5 V for the former, and 5 or 12 V for the latter. For both ICs, the voltage is selected by fitting jumper SI or not, as indicated in Table 1 . Look carefully into the output voltages you will require and then select the appropriate ICs for the project. When jumper S2 is fitted, the output cur- rent of these ICs is internally limited to 400 mA. It can be increased to 1 A by omit- ting the jumper, but we don't really recom- mend this as the rest of the circuit has been optimized for an output current from a few mA to 400 mA maximum. The primary power source is the NiMH rechargeable battery pack, which in the LI + PS -PS +BAT -BAT +V 0 COMPONENTS LIST C2 = 47pF 25V Resistors R1,R8 = lOkO R2 = 220 R3,R6 = IkO R4 = 100Q R5 = 1800 R7 = 2700 Semiconductors D1,D2 = 1N5817 T1 = BC548C IC1 = LM317 IC2 = TL431 IC3 = LT1300 (or LT1301, see text) LED1 = LED PI = 10 kO potentiometer Miscellaneous Inductors LI = 22 pH (or 33 pH, see text) S1,S2 = 2-way pinheader, lead pitch 2.54 mm, with jumper 6 solder pins Capacitors Cl = 1 00(aF 25V PCB, ref. 080223-1 from www.thepcbshop.com 90 elektor - 7-8/2008 case of the LT1300 will comprise two 1.2 V cells, or three cells in the case of the LT1301. The solar panel should be chosen to deliver a voltage of the order of 9 V at an output current of around 100 mA. Such panels are available commercially. IC1 acts as a constant current charger to limit the current to around 60 mA. To avoid overcharging the battery in the event of low current draw by the device powered on the one hand and constant sunshine on the other, the circuitry around IC2 and T1 has been added. IC2 is just a variable zener which will turn on T1 harder as the voltage at the wiper of PI increases. In this way, when the voltage at the battery terminals rises too high, as at the end of charging, T1 will be turned on harder and harder, bypassing part or all of the charg- ing current to ground via R5 and R7, and lighting the LED as it does so. This is simply a contemporary variation of the traditional shunt voltage regulator. The whole of the project fits easily onto a compact printed circuit board of which the component mounting plan repro- duced here. The copper track layout is a free pdf download as usual. Building up the board should not present problems as there are no oddball components to solder Table 1. IC3 LT1300 LT1301 LI 22 mH 33 pH SI fitted +V = +5 V +V = +1 2 V SI absent +V = +3.3 V +V = +5 V S2 fitted 'max = 400 mA Lax ~ 400 mA S2 absent La* = 1 A Lax= 1 A or mount. An 8-pin DIL socket should be soldered in the IC3 position to allow fitting of one or the other of the intended ICs. If your usual retailer doesn't have them in stock, you should be able to obtain them from mail order suppliers, for example, from Farnell. Take care choosing the choke LI (22 pH for the LT1300 or 33 pH for the LT1301). It must be able to handle a current of 800 mA with- out saturating, which is far from being the case with many ordinary moulded types. Our 22 pH one comes from Radiospares (RS Components) and is an ELC08D from Panasonic. It is vital that diodes D1 and D2 are Schottky types, to minimize forward volt- age drop, and in the case of D2, to be fast enough in terms of recovery. AA or even AAA 1.2 V batteries will be suitable, given the impressive capacity of current types on the market. The circuit should work the moment it is powered; all that remains is to adjust potentiometer PI. To do this, temporar- ily disconnect the solar panel and batter- ies, replacing the latter with an adjustable stabilized power supply unit, across which you should also connect a voltmeter. If you are using the LT1300 version, i.e. with two 1.2 V cells, set your PSU to 3.2 volts and then adjust PI to obtain definite illumina- tion of the LED. If you use the LT1301 ver- sion (and hence three 1.2 V rechargeable cells), you'll need to set your PSU to 4.8 V and again adjust PI till the LED lights. (www.tavernier-c.com) (080223-1) Web Links [1] LT1300 www.linear.com/pc/downloadDocument. do?navld=H0,C1 ,C1 003,C1 042,C1 035,P1449,D2742 [2] LT1301 www.linear.com/pc/downloadDocument.do?navld= H0,C1 ,C1 003,C1 042,C1 031 ,C1 060, PI 450,D3451 Downloads The PCB design for the project is available to down- load from the www.elektor.com; file # 080223-1 .zip. = RC,B Lights Joseph A.Zamnit The overall effect produced by this project is a glowing sequence of lights changing slowly from one colour to the next. The microcontroller cycles through randomly generated values of red, green and blue hues of light to produce a variety of nice colours. The software implemented on the con- troller interpolates from one shade to another, each colour channel being treated independently. Light intensity is control- led by means of pulse width modulation (PWM) for each colour. A high frequency of approximately 60 Hz is used to modify the light intensity and eliminate any flicker that might arise. One major problem that had to be over- come was unequal brightness of the LEDs used, the result of which is a tendency for one particular colour to dominate in the overall hue produced. It was found that blue LEDs are perceived to have the largest intensity and green, the lowest. This was compensated for by using a large resis- tor for blue and a low resistor for green, together with two green diodes in series for higher green colour intensity. The values of the resistors may have to be tweaked to achieve the best balanced colour intensity. A diffused glow was achieved by cutting the lens of the ultra bright LEDs used and using a ping pong ball as a basic diffuser. This very simple project is perfect for a rainy day and can be built in a couple of hours. Despite its simplicity it will produce a very interesting and glowing effect. Sev- eral units may be built and they will mix a variety of colours randomly. The source and hex code files for the PIC12F675 device are available as free download # 080419-11.zip from the Ele- ktor website. The code was developed using CCS C. (080419-1) 7-8/2008 - elektor 91 FM Microbug Thijs Beckers Although the idea has been around for a good while already, it's still cute: a tiny cir- cuit that you can hide just about anywhere for all sorts of eavesdropping activities. Fun for at work, but also usable as a babyphone. The basic necessities are a small micro- phone and a little transmitter. This can be realised using very simple resources. This bug circuit operates in the normal VHF FM band and can thus be received using any ordinary radio. The schematic is based on a somewhat uncommon 1C, the 74LS13, but with a bit of searching you can still manage to find one somewhere. The other five components (that's all!) are all readily available. You might already have them in your parts drawer. Here we use an electret capsule for the microphone. The necessary bias voltage is tapped off from the supply voltage via R1. If you use a crystal microphone instead, you can omit R1 and C3. The microphone signal is fed to pin 5 of the 1C. C2 is included to slightly improve the performance and sensitivity of the circuit. Cl serves to decouple the supply voltage so any spikes that may be present are sup- pressed. Just about any short length of wire makes a suitable antenna. The circuit operates on the third harmonic at around 100 MHz. It takes a bit of experi- menting to find the right frequency on the radio, but within a range of a few metres the circuit can even overpower signals from relatively powerful transmitters. Of course, this circuit is not entirely legal, so you shouldn't try to boost the power too much. A range of 20 metres is certainly possible with the circuit as shown. This very simple circuit is highly sensitive and somewhat prone to positive feedback, especially if you hold it in your hand. The best approach is to put it down somewhere and stay away from it; then it works fine. If you want to experiment with the circuit, feel free! ( 080480 - 1 ) Energy-efficient Backlight Rainer Reusch The backlights used in some LCD panels are not exactly economical: typical current draws of 20 mA to 100 mA are common. Normally the current is determined by a series resistor, which leads to additional power losses. It is considerably more efficient, if a little more com- plex, to use a switching regulator 1C. Alternatively, it is often the case that driving the LCD panel is a microcontroller, which we can press into service to provide reg- ulation in software. Fortunately, the regulation does not need to be exceptionally precise. At the heart of our circuit is T1, a p- channel MOSFET, which is driven by an inverted (active low) pulse- width modulated signal from the +5V microcontroller. Components D1, LI and Cl form the remainder of the standard step-down switching regulator configuration. In the cir- cuit diagram the LCD backlight is represented by two LEDs; the cur- rent flowing through these LEDs is measured by a shunt resistor, filtered, and finally amplified to a level suitable for input to the A/D converter in the microcontroller using an operational amplifier. R1 ensures that the transistor switches off completely when the microcontroller is reset (at which time all ports become inputs). The circuit can be used with any microcontroller that can gener- ate an inverted PWM signal at a frequency in the range 10 kHz to 100 kHz. We have developed a demonstration program and code module for the Atmel ATmega32 92 elektor - 7-8/2008 using GNU C. The source code can be downloaded from the Elektor website at http://www.elektor.com or from the author's site at http://reweb.fh-weingar- ten.de/elektor. The program generates the PWM sig- nal at 31.25 kHz (if the processor clock is 8 MHz) on the 0C2 output (PD2) of the ATmega32 microcontroller. The pulse width can be adjusted in 256 steps. If the gain of the operational amplifier is 25.5 a current of 100 mA through the LEDs will correspond to a voltage of 2.55 V at the input to the A/D converter. The internal reference voltage of the ATmega32 is nominally 2.56 V, and so an LED current of 100 mA will lead to a ten-bit conver- sion result of 03FFh. It is sufficient to monitor only the top eight bits of this value, and depending on the error from the desired value, increment or decre- ment the pulse width of the PWM signal. This forms an integral controller. As it stands, this solution cannot compete on simplicity with a series resistor. How- ever, we can make some simplifications to the circuit by eliminating the regulation feedback loop. Dispense with the opera- tional amplifier and surrounding circuitry, and have the software output a fixed PWM signal. This loses the ability of the circuit to compensate for part-to-part variation in the components and for temperature, but in practice such compensation is rarely necessary. The software also supports the simplified version of the circuit. (080250-1) SimpleProg Easy ISP for AVR microcontrollers Dr. Thomas Scherer A trawl of the Internet will reveal no end of simple AVR microcontroller programmer designs for connection to the parallel port of a PC. Here at Elektor we have also pub- lished a few variations on this particular theme. One thing that is perhaps surpris- ing is how different the various designs are from one another. One of the main reasons for the differences is that the programmers are intended for use with different AVR microcontroller development environ- ments, although in some cases it is perhaps not always made as clear as it ought to be which one this is. The circuit shown here was developed as part of the current Elektor AVR-ATM18 project series. Troubled by a nagging feeling that a circuit is not a proper cir- Advertisement 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: h 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 "" i ^ V G,cs E . ■ Etefctor ^ r i e c -i tpjiil taw IM in -raniilli E2 i a -j ■' - i rr J ‘ ■ ■ c| n r ti a-sir a ” - ! t -aha i ■i-s- n iBi^a ttt j "h- , ir--ii73i jh ■ i ■ mii mi w- npai ■ ■ r a. a id ■ im p * 4 < i * ■ ra JMb, .ii k ■***■•+* ■ till* hi k -i-.T Register today on www.elektor.com/newsletter TCll 01635 40347 Ni:whur^ Eicohniikini; UH Fzn: D153Q 3&I4-1 hiKfof HKri Hjriiu? EeifctRd14MiD 2 mil: drr:.lltif Ili'Vh ■- V- h': 74 ■ I . i' fa . 1 1 k L*.V J firth II rytd iMftTi rf f S . . 1 1 k PCB House ^Start from £30 ^Prototype & Production &No Min Order i^Fast Delivery 7-8/2008 - elektor 93 cuit unless it contains at least one active component, the author added an LED to show when data transfer is occurring. In fact, this visual feedback is extremely help- ful when troubleshooting, and is a worthwhile addition even if our aim is to make the simplest possi- ble programmer. Construction is very straightfor- ward. The circuit can be built on a small piece of perforated board, using a flat cable with a 25-way sub- D plug crimped to one end and a 26-way IDC header crimped to the other to connect to the PC's paral- lel interface. The six-way ISP cable is plugged into a suitable box header on the perforated board. If six-way headers prove hard to get hold of, a ten-way type as shown in the pho- K1 Printer tograph can be used instead with just the middle six pins wired. The programmer is compatible with the STK200 and STK300 from Kanda and will therefore work in conjunc- tion with any program that offers those devices as options. It works perfectly with BASCOM [1], and Kanda also offers excellent (and free) programming software [2]. Observe that this unit uses 5 V sig- nal levels. The target microcontrol- ler should therefore also be pow- ered from a 5 V supply, at least while it is being programmed. ( 080479 - 1 ) [1] BASCOM: http://www.mcselec.com [2] http://www.kanda.com/avr-isp-software. html Radio Control Signal Frame-rate Divider . * .. i i 1 1 t i i 4 l • _ 1 lii '* £*4 1 fer I i| * l> M •! ’* J *! B.B >•. ,* nuns* »» •' ^ l« !| !| y i • • Mike Mobbs Model radio-control equipment has evolved considerably over the years, and the humble servo has grown from the 1.5 ms at 50fps (frames per second) for- mat, to the more precise and powerful VDD COMPONENTS LIST Cl = 100nF C2 = lOOnF IC1 = CD4017 (SMD) IC2 = CD4081 (SMD) K1 = 3-wire cable with 3-way socket K2 = 3-wires cable with 3-pin plug PCB, ref. 080136-1 from www.thepcbshop.com digital variety using, typically, 400 fps, and accessories such as helicopter gyros have evolved to make use of these improved servos. As a result, the later generations of gyros often only provide the 400 fps 'digi- tal' signal, which is not suitable for use with the older 'analogue' servos. All is not lost, as this circuit allows only one frame in eight to reach the servo, replicating the 50 fps sys- tem. The prototype version was built using standard ICs, and sits neatly under the gyro (a CSM720 in the test setup) to provide the analogue output. The circuit uses a Type 4017 CMOS decade ring counter, which is clocked by the falling edge of the input via the CPI (enable) pin, and reset by output 7. The first input pulse 94 elektor - 7-8/2008 after reset sets output 1 high, which allows the next input pulse through to the output via a CMOS 4081 OR gate. Thus only one pulse in every eight is fed to the output. The use of negative logic to provide the AND function removes any risk of timing glitches, as the gating signal is established before the input pulse, and is stable for the duration of this pulse. Other divider ratios can be used by choos- ing the relevant output for the reset. A miniature PCB with SMD parts on it was designed for the converter to enable it to be incorporated into a model where space is always at a premium! The circuit is best encapsulated in heatshrink sleeving. (080136-1) FL Twilight Switch ©- 230V ©- 4x 1N4007 R1.A 0W5 R1.B 0W5 Jr2 R9.A 0W5 R9.B Tr 4 Tr5 05 T1 Z ck 1 vlA 10)i 4)0.7 6V i6V 16V «L BC547 r^n 10 C5 SFH309 0W5 R6 © R8 LAI THY1 * BT169D 070895-11 Peter Herlitz This light dimmer has been especially designed for use with fluorescent lamps (FLs). The circuit contains only a few com- ponents and can be built on a circuit board of only 2 by 3 cm if you use SMD components. The mains voltage is rectified by D1 to D4 and this waveform goes to the in series connected fluorescent lamp and a thyri- stor. During the day the thyristor will not receive any gate current so that the lamp will remain off. At night the thyristor will receive a continuous gate current so that the fluorescent lamp stays fully on. The light/dark detection circuit is built around T1 to T4. This part is fed directly from the rectified mains voltage via R1/D5/C1. Photo transistor T1 measures the amount of ambient light. During the day, when there is sufficient light, T1 conducts. In that case T2 and T3 will block and T4 conducts so that the thyristor does not receive any current. When dusk falls the voltage across electro- lytic capacitor C2 increases. At some point this will become high enough so that T2 and T3 will conduct. T4 will not receive any base current any more and blocks, so that the thyristor will receive continuous gate current via voltage divider R6/R7/R8 and the lamp will light up. R9 and R10 pro- vide for some hysteresis in the switching behaviour of T2 and T3, so that the circuit does not repeatedly turn on and off when duskfalls. When building the circuit make sure that it is electrically safe, since it is directly con- nected to the mains voltage. (070895-1) Advertisement WWW. elektor. com vjihd (Af ILJfs LJ! Haw TO SLfiLD- AWJ5 pe^idiFj wsufl dwh winrii Inspirwi b*ih* y 11 * c “ n ""“ 10 ™ 641 ingludfsT Piuai ji sas Tfloh. [h-mcnl LtlHM . C-i rwt i-JT HdLrijf »1i AM j*cnli! •■Tht Fgn War Lc-.i>n Evitatted 5ffl.trnil ■-G>llp*rtrSlfl-i.bHt Hit! "■Chant, pn XC.S CcniW-! * A -1 .III J PirnTT ■ (THt r.U' DriHa^nttTR Hn r.Y WWW.X Pm: , .. TATION.COM 1 ^ ‘:; u ^*_l 7-8/2008 - elektor 95 The 0C1 71 Mystery (solved) ) Jan Buiting, PE1CSI The OC170 and OC171 transistors are ger- manium p-n-p alloy-diffused transistors in a TO-7 metal case. They were designed by Philips in the early 1960s as RF transis- tors with a (then spectacular) transition frequency of about 70 MHz. At the time, these devices marked a transition from the old 'grown alloy' to the new 'alloy-diffused' junction manufacturing, at the verge of the silicon age that was about to begin. The OC170 and OC171 were a good success and got widespread use as RF and IF ampli- fiers, oscillators and mixers in early MW/LW portable radios as well as TV sets. When Philips phased out their 'OC type prefix to comply with the Pro Electron semiconduc- tor type designation system, successors of the OC170/171 called AF114, AF115, AF116 and AF117 appeared on the market. Both the OC and the AF devices carry a 'terrible secret' inside their TO-7 metal can. If you switch on a 'dead' 1960s transistor radio containing one or more of the above mentioned trannies, try gently tapping them with a small screwdriver. In many cases the radio will crackle, burst to life or work intermittently and drop silent again after a while. Surprisingly, unsoldering a suspect OC171 from the circuit and checking its junctions -6V 2 E B S C using an ohmmeter will not reveal faults in the junction proper. The device will also achieve its normal electrical specifications. However, an unexpected short-circuit may be measured between the shield wire (S) and the emitter or collector. In the 455 kHz IF amplifier shown in Figure 1, a domino- effect with all transistor biasing occurs if, say, the collector of the first OC171 is shorted to the shield, hence to ground. This was a practical case and a trigger to start a research. In reference [1] Andrew Emmerson explains that these short-circuits are caused by micro- scopic conductive 'hairs' growing from the inside of the can in the air space under the grease filling (probably petroleum jelly or an early form of silicone grease). The phenom- enon is illustrated in Figure 2. Typically the hairs will reach the emitter or collector wire. The nature of the growth is unknown; some suggest it's due to an electrochemical effect between the can metal and the wire metal, with the air and the slightest trace of acid in the grease interacting in the process. Oth- ers claim it's a 'Philips nasty' — a chemically engineered time bomb to generate sales of new radios. An even more unlikely sugges- tion is one of Philips' US competitors having supplied the grease through a sub-contrac- tor 'in the plot'. Interestingly, reference [2] confirms that the much dreaded 'Qual. Lab.' at Philips Semiconductors had expressed doubts about the use of a grease sealant around the diffused Ge junction used in OC17x and the later AFIIx devices. It is not known if the air pocket beneath the grease filling is intentional or a production flaw. 96 elektor - 7-8/2008 A well established trick applied by radio &TV service engineers was to cut the shield lead (S), isolating it from the circuit ground but if you were unlucky a hair would land between the E and B wires. Another disadvantage is the transistor case then being at the emitter or collector potential, causing RF radiation and the magical but unwanted 'hand effect 7 — the TO-7 is a relatively large case! The hairs may be 'zapped 7 using a 47 pF electrolytic charged to about 50 V and con- nected between the S (shield) wire and the E, B and C wires twisted together. Although this method is good to retain the origi- nality of your radio, the fault may occur again after some time as the hair growth continues. Germanium transistors have a bias voltage of 0.2-0.3 V, so if an OC171 or one its sib- lings is replaced by a modern silicon p-n-p RF transistor like the BF450 or BF451 (Fig- ure 3), resistors may have to be changed to get 0.6-0.7 V V B _ E bias levels in the cir- cuit. Also, almost all silicon transistors will have a much higher transition frequency than the old 'geranium grot', so due atten- tion should be given to RF decoupling and changed internal capacitances. There is no point in buying NOS (new old stock) OC17x or AFIIx transistors on EBay as the shiny devices you'll get will have the problem too. Reportedly some audio transistors like the AC 127, AC128, AC176, AC187 and AC188 also suffer from unwanted hair growth in invisible places. ( 080473 - 1 ) [1] Electronic Classics, Collecting, Restauration and Repair, Andrew Emmerson. ISBN 0-7506-3788-9. [2] 50 Jaar Herkennen (Recognising 50 Years). Philips Semiconductors Nijmegen, C. van Anrooij, F. Geer- sten. H. Jacobs, P. Willemsen, G. de Wind (Editors). ISBN 90-90-17050-2. Pseudo-random Glitter Hans-JiirgenZons A question recently asked on the Elektor website forum was how to make several white LEDs 'sparkle'. The helpful author has not only provided a useful suggestion (use a ran- dom effect), but also devel- oped a suitable circuit and even designed a PCB layout. You can download the Eagle files for this from the Elektor website page for this article (www.elektor.com, archive # 080329-1.zip). But first let's consider the basic question: artificial spar- kling or glittering can best be simulated by having the different light sources switch on randomly at a particu- lar frequency. Surprisingly enough, it is not all that easy to generate truly random sequences electronically. However, the electronic ran- domness does not necessarily have to be perfect for glitter applications. Patterns that appear to be random are suf- ficient for the desired visual impression. Based on this principle, the author uses two 556 timer BT1 £ 9V 850Hz R2 5 DIS IC1.A THR OUT TR CV Cl lOOn 180Hz n? i 13 C2 lOn 12 +9V -© 47[i 6V 10 DIS IC1.B THR OUT TR CV C3 lOOn 11 C4 lOn Js I 14 13 |S 15 +9V 16 IC1 = NE556N SV2 SV2 1 © CTRDIV10/ DEC IC2 & CD4017 CT=0 0 1 2 3 4 5 6 7 8 9 CT>5 10 1 5 6 9 11 .12 9 10 12 ■V 13 14 y y y y y Q O- 1 R12 D8 2k2 x 2 2k2 R8 D4 Q O 3 2k2 R7 D3 X 4 2k2 R1 1 D7 Q O b 2k2 R6 D2 \L 6 2k2 R5 D1 \°- / 8 R10 D6 2k2 9 10 1 R13 D9 2k2 Q O- 11 2k2 R9 D5 \L 12 2k2 R14 D10 t 3 14 JMi 080329 - 11 ICs to generate signals whose frequencies (850 Hz for ICIa and 180 Hz for ICIb) can be divided by each other with- out yielding an integer divi- sor. A decimal counter oper- ated in an unconventional manner uses these two sig- nals to produce a constantly pseudo-random pattern on its ten outputs, which repeats itself only very infrequently. This behaviour is obtained by applying the higher-fre- quency signal to the CLK input of counter IC2, with the CLK Inhibit input on pin 13 being driven by the lower- frequency signal. The result is 'genuine pseudo-random' blinking. LEDs can be connected directly to the ten outputs, since a CMOS output can anyhow only supply a few milli-amperes. However, it is recommended to use series resistors (2.2 kO to 4.7 kO) to reduce the load on the 1C out- puts if the supply voltage is higher than 10 V. If you want to have more than ten LEDs glitter, you can naturally build several copies of this circuit. ( 080329 - 1 ) 7-8/2008 - elektor 97 Microlight Fuel Gauge Jean-Pierre Duval Over the Internet, a microlight owner asked me to make him a fuel gauge for his ultra light aircraft. This seemed to me to offer various very interesting aspects, so I decided to take up the challenge. I started by gathering some basic informa- tion to define the specifications that would be required for this measuring instrument, so vital for any craft moving in the third dimension where a good supply of fuel is absolutely vital to prevent accidents and embarrassment. Here are the key details: - a microlight always takes off with the fuel tank full; -fuel consumption is usually between 7 and 9 litres/hour; - it's important for the gauge to be per- fectly readable in all circumstances, e.g. in the form of a bargraph; -an indication of the amount of fuel remaining, expressed in litres; - an indication of the instantaneous fuel consumption (l/h); - it must be possible to have complete con- fidence in the gauge, so provision needs to be made for a warning in the event of it going wrong; - for the transducer, we use the manufac- turer's data (in this case Digmesa); for greater safety, all data used are taken at minimum values; - two alerts need to be provided: 3.5 litres and 2 litres of fuel reserve remaining. All these conditions are taken into account by the firmware - the program burned into the microprocessor - more than by the hardware, which can thus remain rela- tively simple. Apart from the fuel flow sensor, an Atmel ATmega8 microcontroller, and the display, all it takes is a few capacitors and a very small number of resistors. Time now to take a look at the circuit. Let's start with the power supply. Totally conventional, we start out with the 12 V supplied by the battery, dropped to 5 V by a 7805 regulator. Upstream of this, a fuse, not shown on the circuit, protects the whole unit. Diode D1 protects the regula- tor against unintentional polarity reversal of the voltage at the power supply input. LED D2 indicates the presence of the out- put supply rail from the regulator IC1. Now let's move on to the more interesting bit, which is the electronics of the virtual fuel gauge proper. Leaving aside the microcontroller, the most important component in this project is the flow sensor. This is an FHKSC 932-8501 from Digmesa [1] & [2]. This detector can meas- ure fluid flows from 0.03 to 2.0 l/min, equiv- alent to a range of 1.8 to 120 I/hr — more than sufficient for the application envis- 98 elektor - 7-8/2008 • • ©Elektor 080054-1 C6 «HI-» • * PI + - in am.) (HDi) Cl .rr.... 1 • XI IC1 1 C7 I ( COMPONENTS LIST Resistors R1 = IkO R2 = 330 R3 = 4k07 PI = 10 kO preset Capacitors Cl = 220pF 25V C2 = lOpF 25V C3-C6 = lOOnF C7,C8 = 22pF Semiconductors D1 = 1N4004 D2 = LED, red IC1 = 7805 IC2 = ATMEGA8, programmed with hex file from archive 080054-11.zip Miscellaneous XI = 32.768 kHz quartz crystal K1 = 2-way pinheader K2 = 16-way SIL pinheader K3 = 3-way pinheader LCD, 2x16 characters with backlight, general purpose FI = flow meter, Digmesa type FHKSC 932-8501 (Conrad Electronics) PCB, ref. 080054-1 from www.thepcbshop.com aged. Originally developed for measuring water flow in coffee machines, it is equally capable of measuring other fluids, as long as they are not too chemically aggressive (alcohols, petrol, wines, etc.). The ability to set the sensor port connections at different angles gives it unquestionable installation flexibility. After that, we are interested in the (artifi- cial) heart of the circuit — now it's time to get down to the really clever stuff. The microcontroller used here, IC2, is an ATmega8 from the Atmel stable [3]. We shouldn't underestimate it — despite its name, this is a powerful component that we are far from pushing to its limits. It uses its internal 8 MHz oscillator to run the program and an external 32.768 kHz clock crystal to measure the instantaneous con- sumption. The crystal frequency is com- mon, by the way, from the use in watches where it's one on the easiest ways of creat- ing a stable source for seconds pulses. This ATmega8 microcontroller has 24 I/O ports, of which we are only going to be using a few, for the following functions: • six ports are used for the LCD display, i.e. almost the whole of port C (PC0-PC5); • one INTI port (PD.3) as an input for the pulses supplied by the flow sensor; • two ports, PB.6 and PB.7, are devoted to the above mentioned clock crystal. For Reset we use the microcontroller 'Brown-out' programmed via the micro- controller 'fuses'. 'Brown-out' defines the supply voltage level at which the pro- gram starts — in our case the minimum voltage is 2.7 V. The Reset pin has an internal pull-up, so no external one is needed. BASCOM Basic includes the tools needed to configure the fuses. All unused ports are configured in the pro- gram as inputs, and from an electrical point of view are tied to ground on the board. The liquid flow sensor produces very clean 5 V (TTL) pulses which trigger an interrupt (INTI) used to measure the engine's fuel consumption. Here, it is wired in accord- ance with the manufacturer's data (see [1]) www.digmesa.com, i.e. by adding a 4.7 kO pull-up resistor and a lOOnF capacitor between the signal output and ground (TTL-mode output). Preset PI allows adjustment of the LCD dis- play contrast by adjusting the voltage V EE . The program is written in BASCOM BASIC, a powerful, economical programming lan- guage that's all the same very easy to imple- ment. There is a free version available that is capable of producing up to 4 k of code [4]. The irreproachable operation of this fuel gauge relies on a plethora of arithmetic calculations going on inside the microcon- troller. We'll describe the most important ones so that if necessary you can adapt the characteristics of this flowmeter so as to use it for other applications. Let's suppose that our fuel tank has a capacity of 29 litres. If we assume that the sensor provides 1,800 pulses per litre (we measured over ten tanks and were at between 1,900 and 2,000 pulses per litre - in accordance with the manufacturer's data, but reduced down to 1,800); that gives us a maximum of: 1,800 x 29 = 52,200 pulses for a completely full tank; in order to main- tain a degree of safety margin (poorly-filled tank, leaks, and so on) we'll give ourselves a margin of 10%, and so will only count 48,000 pulses. Each pulse corresponds to 1,000/1,800, i.e. 0.555 ml. The calculation of the instantaneous consumption expressed in litres/hour is a weighted value, recalculated every 10 seconds The TIMER interrupt is used here in the Clock configuration to generate a very pre- cise second value, so even with very low consumptions, the response is very close to the true value. The calculation of the vol- ume remaining in the tank is performed by decrementing the amount consumed per unit of time from the volume remaining (see inset 'Procedure for calculating vol- ume of fuel remaining'). All that remains to mention is the alert thresholds, at 3.5 and 2 litres, defined in the firmware. Again, if you want to adapt thee values to your personal requirements, Procedure for calculating volume of fuel remaining: Once again, the calculation is extremely simple : If, at the outset, volume=48000 int errU pt routine rem at each interrupt, the volume is decremented DECR volume display rem after a formatting step volume_remaining= volume Tank = Str (volumeremaining) Tank = Format (tank , "00.0") Locate 1,1: Led "V:" ; Tank 7-8/2008 - elektor 99 do feel free to edit the microcontroller source code. These calculations refer to the amount remaining; when one of the thresholds is reached, it causes the LCD display to blink at a fast rate. One of the most interesting aspects of this project is the very customized way the display is used. It's worth taking a slightly closer look at it. Some display tricks are used to display the values. The top line of our display (two lines of 16 characters) is used to show the numeric information about the volume remaining (V) and instantaneous consump- tion (l/h). The character at the extreme right of this top line is a user character intended to sym- bolize the flowmeter. As long as the latter is working, this character changes shape, giv- ing the impression of rotation. This is what we've called the 'operation indicator'. In the measuring second, we make it change between two characters symbol- izing the flowmeter. If the flowmeter isn't working, there is no variation in volume during the measuring period, and so this right-hand end character remains static. Let's see now what the bottom line does. It's used to indicate the tank status in graphical form. When it is full, we will have 15 solid blocks to the right of the R (for 'Reservoir' = Tank). The characters on the LCD display are each made up of an 8 row by 5 column matrix of pixels. To be able to display the gradual reduction in the amount of fuel available, we have created several special user charac- ters. The solid block of 5 columns is part of the LCD display's own character set. We're going to create a block with just 4 columns, then one with 3, then 2, and then 1. After that, the block in question just goes blank. Let's move on now to the calculations. We have 15 characters, each with 5 col- umns, giving us 80 columns in all. We have taken 48,000 as our starting point (allowing for our safety margin). Hence by division, 48,000/80 = 600. So, we can see that we need to lose one column every 600 pulses. So we display the appropriate number and type of characters corresponding to the information to be displayed. In the photo of the display, the last character consists of two columns. A printed circuit board was designed for this project. It's approximately the same size as the display, which can be mounted onto the board piggyback-fashion. The component layout needs no special men- tion. You should start with the smaller com- ponents, resistors, capacitors, headers, and diodes, finishing off with the socket for IC2. Don't fit the processor into its socket until you have first checked that the required voltage (5 V) is present on the relevant pins (7, 20, referenced to one of the pins con- nected to earth, 2,3 etc. refer to the circuit diagram). It only remains to fit the flow sensor into the fluid (whatever it is) supply pipe. Header K3 is used for its supply and output signal. The LCD display connects to header K2. Take care to get it the right way round! We're very curious to know what applica- tions readers are going to find for the vir- tual gauge described here! jeanpierre.duval2@orange.fr (080054-1) Downloads The source code and .hex files for this project, along with the board design are available on www.elektor. com. The respective file names are 080054-11.zip and 080054-1.zip. Web Links [1] Flow sensor source www.digmesa.com/ [2] Flow sensor data sheet www.digmesa.com/digmesa/upload/pdf/FFIKSC/ 932-850xxxx_GB.pdf [3] ATmega8 data sheet www.atmel.com/dyn/resources/prod_documents/ doc2486.pdf [4] BASCOM BASIC (MCS) www.mcselec.com/index. php?option=com_ docman&task=cat_view&gid=99<emid=54 PWM Control for Permanent Magnet Motors Franz P.Zantis DC motors with permanent magnets are widely used and popular among model builders. A particular characteristic of these motors is a large discrepancy between the startup torque and the nominal torque. If a permanent magnet motor is to be pow- ered from a DC supply and a constant, high torque is required at a variable operating speed, a pulsewidth modulator (PWM) of the type described here is needed. We construct an astable multivibrator with the help of a couple of gates from a 40106 hex Schmitt trigger 1C. The multivibrator has a mark-space ratio ('duty factor') that can be adjusted over a very wide range, independent of its operating frequency. Adjusting the potentiometer changes the D1 R4 100 elektor - 7-8/2008 ratio between R a and R b/ which together make up the total resistance of the poten- tiometer. Capacitor Cl is charged via R b and is discharged via R a . The correspond- ing mark-space ratio is present at the out- put of the oscillator on pin 4 of the 40106. The output high time is determined by R a , while the output low time is determined by R b . The oscillator frequency is constant at approximately 115 Hz. Transistor T1 pro- vides current gain: when pin 4 of the 40106 is low, T1 turns on, and when the output is high, T1 is turned off. Sufficient current is available at the collector of this transis- tor to drive the base of the 2N3055 power transistor. R4 and C2 provide decoupling for the oscillator from the large currents switched by the power output stage. The moving-coil meter connected via R7 serves to monitor the state of the battery, which is useful when rechargeable cells are used. The circuit has been used by the author to drive a motor salvaged from an old cas- sette tape recorder. In this case the 2N3055 did not require a heatsink. Interested readers will find that a search of the Internet turns up plenty of information on the theory and practice of driving DC motors using pulsewidth modulation. ( 060187 - 1 ) +m/ monitors, TV sets, other VCRs and so on. For example, in a hall, the image produced by a central DVD player can be shown on five different TV screens with the sound repro- duced through a separate amplifier. The circuit is based on the type EL2020 (or similar) operational amplifier which is marled by large bandwidth. The LL2020 amplifies the video signal applied to the input stage, with a gain adjustment range of ±6 dB. Output transistor Q1, a 2N3866, applies the video signal to the five out- puts designed to drive loads with 75-0 impedance. Video fans and professionals in the field will find in this small signal distributor/amplifier an excellent ally when it's necessary to dis- tribute a single video signal across several equipments. The circuit shown here should have a lot of applications. Basically, the distribution amplifier takes the composite video signal from a video player (VCR) or a video generator (analogue output) and buffers it in such a way that it can be simultaneously applied to up to five different video equipment inputs, like The circuit requires a ±12 V symmetrical supply voltage, which can be obtained from a conventional power supply as shown by the schematic. ( 080478 - 1 ) 7-8/2008 - elektor 101 Turbo BDM Lite ColdFire Interface Luc Lemmens In the April and May 2008 issues of Elektor the DigiButler was introduced, which is a simple, low-cost Home Automation Server built around the MCP52231, a ColdFire microcontroller made by Freescale. The two article instalments also mentioned Daniel Malik's Turbo BDM Lite ColdFire interface (TBLCF), a low-cost programming inter- face that is fully open source. Although we referred to the extensive TBLCF documen- tation, we didn't have enough time during the preparations of the DigiButler project to fully test this interface, and there wasn't an RoHS compliant replacement for the microcontroller in that circuit. This is now available, however, and may be obtained as a free sample via the Freescale website. The software and firmware for the TBLCF can be found via the link at the end of this article, and tblcf_v10.zip is the file that we need. This can also be found as part of the free download (071 1 02-1 1 .zip) that we've added to the Elektor website. The .zip file contains a manual (manual_v14.pdf), which clearly explains how the drivers should be installed and how the controller for the interface should be programmed. It's just a matter of figuring out where the various files are stored. The USB drivers (page 13 of the manual) are contained in usb_drivers_v10.zip. Extract all the files from this .zip file into a new folder on the hard drive. You can then con- nect the interface to the PC, which should result in a message stating that a new hard- ware device has been found. If that doesn't happen it's a case of carefully checking all soldering on the TBLCF board. Note that the LED on the interface won't turn on yet at this stage. Next, follow the instructions given in the manual to install the drivers. To program the firmware you need the files tblcf_bt.exe and tblcf.abs.s19. These can be found inside pc_binaries_v10.zip and tblcf_firmware_v04.zip\bin respectively. When the programming of the firmware has been completed Windows will start another procedure to install the new driv- ers, after which the PC has to be restarted. Once this has been done the LED on the TBLCF should be lit continuously if it has been correctly recognised by Windows. Whenever communications take place between the PC and the target system the LED flashes. Adding the TBLCF to the CodeWarrior 6.3 IDE is clearly explained in the manual, and tblcf_gdi.dll can be found inside pc_bina- ries_v10.zip. The item 'Startup file' can be left blank. Up to this point the manual has held our hand through the installation process, but there is (as with the parallel programmer interface from the May issue) a section that requires extra attention: the settings for the flash programmer. From CodeWar- rior, open the menu Tools -> Flash Program- mer. Click on Load Settings and load the file setup.xml, which can be found in the folder DigiButler software\SW_Main_Board (see archive 071 1 02-1 1 .zip). Check that the Tar- get Processor in this window is set to: 5223x. For the Connection choose TBLCF and make sure that the target initialisation file is M52235EVB_PnE.cfg. Then click on Flash Configuration and from the Device table select the CFM_MCF5220_25MHz. Then overwrite setup.xml using Save Settings to keep the new settings. ( 080448 - 1 ) Web Link http://forums.freescale.com/freescale/board/ message?board.id=CFCOMM&thread.id=624 102 elektor - 7-8/2008 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 I each Wednesday £ Play the i-TRIXX Quiz and win! From the Elektor labs: Simple, useful and fun electronic circuits! Test your knowledge about internet, computers and electronics. Take your chance now and play the i-TRIXX Quiz. There are great prices to win! Check i- TRIXX.com and subscribe now! Powered by Automatic S/PDIF Selector Ton Giesberts These days there is an increasing number of devices that have a digital audio out- put, for example digital cable tuners, sat- ellite receivers, DVD players/recorders or game consoles/computers. It is often the case that the existing receiver doesn't have enough coaxial S/PDIF inputs to accommo- date all these devices, or the receiver is at the other side of the room from the TV and other equipment, and we'd rather not lay three or four separate S/PDIF cables along the skirting boards. This clever little circuit gets round these problems in an ingen- ious way. It doesn't need a mains supply nor does it have any external switches. The latter makes it possible to hide the device behind the equipment. The circuit detects the appearance of a new S/PDIF signal on one of its two inputs and switches this to its output, so that only one connecting cable is required to connect two devices with S/PDIF outputs to the receiver. When several devices are turned on that output a continuous S/PDIF signal, the required device needs to be momen- tarily turned off and then on again to select it. It is relatively easy to expand the circuit with more inputs. Because we wanted to avoid the use of a mains adaptor for this circuit we decided to make it battery-powered. For the design we therefore strived to keep the current con- sumption as low as possible. That meant that we didn't use buffer stages or comparators to detect the input signals. Instead we used bist- able relays, which only require a short pulse to change their state, which is then latched. +9V 104 elektor - 7-8/2008 When an S/PDIF signal appears on one of the inputs, a cascade circuit is used to derive a DC voltage from it. Because the nominal voltage of S/PDIF signals is only 0.5 V pp (when terminated by 75 O), each input has a cascade stage with four diodes and four capacitors. The generated volt- age then becomes twice the peak-to-peak value, which in this case results in nearly 1 V. In order to keep the threshold volt- age as low as possible the cascade stage is loaded as little as possible, the capaci- tors are as small as possible and for the diodes we've used special Schottky types (BAT85). This signal is then fed to a bipolar transis- tor that requires about 0.5 V to 0.6 V for it to conduct. A base resistor of 1 MO and a capacitor are used for interference sup- pression. The bipolar transistor drives a differentiator C3/R1 (C9/R4 for the other channel) to create a short pulse for the relay. The gate of the following P-chan- nel MOSFET is momentarily connected to ground via capacitor C3 and transistor T2. This FET then drives the set-coil of one relay and the reset-coil of the other relay. The BS250 used here can switch a direct current of 250 mA without any problems, and has an even high peak-current capac- ity (up to 500 mA). The number of inputs can be increased by adding more of these stages. Note that when there are more than two stages you need to connect each reset-coil via diodes (e.g. BAT85) to the FETs. In that way the voltage on the reset-coils doesn't end up at the set-coils of the other relays. Depending on the type of relay used, you typically need about 15 mA to energise each coil. This means that the maximum possible number of inputs is much more than you're ever likely to need. It is possible to use 12 V types for the relays. The G6A series made by Omron are guaranteed to switch at 8.4 V, for exam- ple the G6AK-234P-ST-US-DC12. The coil resistance is 800 O, which means that it requires only 11 mA. If you find you have some 'hesitant 1 relays when you're using more inputs and switch the relays via diodes, you can always use 5 V types. The switching current will then be higher, but in practice this has little effect on the bat- tery life. The current consumption of the circuit with signals present at both input is about 1.6 pA. This implies that the maximum the- oretical battery life could be 35 years for a standard 9 V battery (500 mAh), which is much longer than its expected shelf life. Another option is to use three or four Lith- ium cells in series. These probably will give the circuit 'near-eternal life'. ( 080484 - 1 ) Phantom Supply for TV Antenna Dr. Thomas Scherer The author gave his father-in-law a USB TV stick as a present. After experimenting with it for a little while, they concluded that the performance of the device when used with a passive antenna was very poor. An active antenna, unfortunately, requires an extra power supply, which is not really practical when used with a laptop. Reason enough, then, to solve the problem properly; and in any case the author wanted to try to shake off his unwanted reputation with his father- in-law as an amateur engineer! The author took the USB stick home with him, with the idea of somehow or other adding the needed phantom power out- put to the device. Fortunately things turned out considerably simpler than he had expected. As Figure 1 shows, the stick is held together by a few screws, and so getting it apart is straightforward. So how does a phantom power supply work? Normally the antenna input is decoupled, as far as DC is concerned, from the main electronics by a capacitor. If we can somehow get 5 V onto the input in such a way that it does not short out the HF signal, we can provide a power supply to an active antenna. The cur- rent consumption of the amplifier in such an antenna is typically between 20 mA and 50 mA. This current (at +5 V) can easily be sourced from the computer's USB connec- tor. If we connect this supply via a coil to the antenna input the problem is solved: the coil will present a high impedance to the high frequencies in the TV signal. In order to make the antenna input short- circuit proof it is a good idea to add a 10 O metal film resistor in series with the coil. Using this type of resistor has the advan- tage that it will fail to an open circuit if overloaded for a prolonged period, and thus acts as a kind of fuse. The author used a 220 pH fixed inductor (any value above about 10 pH will do) with a DC resistance of 5.6 Q. At a measured current draw of 30 mA the total voltage drop is around 0.5 V, which is entirely acceptable. The two components were simply soldered together (Figure 2) and shrouded in heat- shrink tubing. The 'module' was then sol- dered into the USB stick: the red arrows in Figure 3 show where the solder connec- tions were made. The 5 V pin of the USB plug is opposite the ground pin, which in turn is easy to identify as it is electrically joined to the shield of the plug. The final construction is shown at the bottom of Figure 1. The modification should work with all types of USB TV sticks: analogue tuners can benefit as much as digital tuners from an active antenna. ( 080503 - 1 ) 7-8/2008 - elektor 105 Mini Bench Supply n Every electronics engineer is familiar with the anxiety of the moment when power is first applied to a newly-built circuit, won- dering whether hours of work are about to be destroyed in a puff of smoke. A high- quality power supply with an adjustable current limit function is an excellent aid to steadying the nerves. Unfortunately power supplies with good regulation performance are expensive and homebrew construction is not always straightforward. Many of the laboratory power supplies' currently on the market are low-cost units based on switching regula- tors which, although certainly capable of delivering high currents, have rather poor ripple performance. Large output capaci- tors (which, in the case of a fault, will dis- charge into your circuit) and voltage over- shoot are other problems. The power supply described here is a sim- ple unit, easily constructed from standard components. It is only suitable for small loads but otherwise has all the character- istics of its bigger brethren. Between 18 V and 24 V is applied to the input, for exam- ple from a laptop power supply. This avoids accompanying smoothing. No negative supply is needed, but the output voltage is nevertheless adjustable down to 0 V. A difficulty in the design of power supplies with current limiting is the shunt resistor needed to measure the output current, normally connected to a differential ampli- fier. Frequently in simple designs the ampli- fier is not powered from a regulated supply, which can lead to an unstable current regu- lation loop. This circuit avoids the difficulty by using a low-cost fixed voltage regulator to supply the feedback circuit with a stable voltage. This arrangement greatly simpli- fies current measurement and regulation. To generate this intermediate supply volt- age we use an LM7815. Its output passes through R17, which measures the output current, to MOSFETT1 which is driven by the voltage regulation opamp IC1C. Here R11 and C4 determine the bandwidth of the control loop, preventing oscillation at high frequencies. R15 ensures that capaci- tive loads with low effective resistance do not make the control loop unstable. The negative feedback of AC components of the current via R12 and C5 makes the cir- its output, and negative feedback of the DC component is via the low-pass filter formed by R14 and C6. This ensures that the volt- age drop across R15 is correctly compen- sated for. C7 at the output provides a low impedance source for high-frequency loads, and R16 provides for the discharge of C17 when the set voltage is reduced with no load attached. Current regulation is carried out by IC1D. Again to ensure stability, the bandwidth of the feedback loop is restricted by R19 and C8. If the voltage dropped across R17 exceeds the value set by P2, the current limit function comes into action and T2 begins to conduct. This in turn reduces the input voltage to the voltage regulation circuit until the desired current is reached. R7, R9 and C3 ensure that current regula- tion does not lead to output voltage over- shoots and that resonance does not occur with inductive loads. The controls of the power supply are all voltage-based. This means, for example^ that PI and P2 can be replaced by digital- to-analogue converters or digital poten- tiometers so that the whole unit can be 106 elektor - 7-8/2008 driven by a microcontroller. IC1B acts as a buffer to ensure that the dynamic charac- teristics of the circuit are not affected by the setting of PI. IC1A is used as a comparator whose out- put is used to drive two LEDs that indicate whether the supply is in voltage regulation or current regulation mode. If D2 lights the supply is in constant voltage mode; if D1 lights it is in constant current mode, for example if the output has been short- circuited. The power supply thus boasts all the features of a top-class bench supply. IC1A and its surrounding circuitry can be dispensed with if the mode indication is not wanted. A type LM324 operational amplifier is sug- gested as, in contrast to many other simi- lar devices, it operates reliably with input voltages down to OV. Other rail-to-rail opamps could equally well be used. The particular n-channel MOSFET devices used are not critical: a BUZ21, IRF540, IRF542 or 2SK1428 could be used for T1, for exam- ple, and a BS170 could be used in place of the 2N7002. The capacitors should all be rated for a voltage of 35 V or higher, and R15 and R17 must be at least 0.5 W types. The fixed voltage regulator and T1 must both be equipped with an adequate heatsink. If they are mounted on the same heatsink, they must be isolated from it as the tabs of the two devices are at different potentials. ( 080326 - 1 ) Servo Control G. Baars This circuit lets you control a servo in a simple way. It is built around a cheap and common logic 1C. Together with a few resistors, capacitors and a diode this circuit can certainly be cal- led simple and can be built on a small circuit board. NAND gates IC1A and IC1D are used to build an oscillator which produces negative pulses with a repetition frequency of about 50 Hz. These very narrow pulses are used to toggle the output of the SR (set/reset) flipflop, which is built with gates IC.1B and IC.1C, every 20 ms. With every set-pulse the out- put of IC1 C goes low, which causes C3 to be discharged via PI, after which the situation reverses. This results in a pulse at the output of IC1B, which repeats every 20 ms and the duration of which can be adjusted with PI. From experimenting with this circuit and an S3003 servo from Futaba it was observed that with a pulse duration of 1- 2 ms it rotated through an angle of 90 degrees. However, by shor- tening the pulse duration a little more, to about 0.6 ms, there was a further 30 degrees of rotation. The component values in the circuit were chosen so that the pulse duration can be set from 0.6 to 2 ms with PI and the total rotation amounts to about 120 degrees. Since the S3003 servo has a not inconsiderable tor- que of 4 kg-cm, at can be used, for example, to remote control the tuning capacitor of a so-cal- led 'magnetic-loop' RF antenna. The current consumption of the servo depends on the torque that needs to be delivered and varies from a few tens to several hundreds of milliamps. ( 080026 - 1 ) +5V +5V IC1A & D1 — N- 1N4148 R1 <> 1 180k I - IC1D 13 12 +5V K1 080026 - 11 COMPONENTS LIST Resistors: R1 = 180kO R2 = 47kO R3 = 10kQ PI = 50kO linear potentiometer Capacitors C1,C2 = lOOnF C3 = 47nF Semiconductors D1 = 1N4148 IC1 = 74HCT00 Miscellaneous K1 = 2-way SIL pinheader K2 = 3-way SIL pinheader PCB, # 080026-1 from www. thepcbshop.com 7-8/2008 - elektor 107 Software-defined Valve Radio Burkhard Kainka Software-defined radio (SDR) is all the rage. The idea is this: a very simple radio receiver is given top- of-the-range performance with the aid of a little software. Even newer is SDVR (software- defined valve radio), where a sin- gle-valve radio is turned into a world receiver with some help from a PC. Power comes from four AA cells for the heaters, and a 9 V bat- tery provides the anode supply. The circuit is very simple: a PC900 (EC900) triode is used in a homo- dyne regenerative (Audion) con- figuration. Adjustment of the feedback is not necessary as the receiver always oscillates at high amplitude. A tuning capacitor can also be dispensed with as fine tun- ing is done in software. Coarse adjustment of the received band is possible by screwing the inductor core in and out. The receiver works in the 49 m band using a 30-turn coil on an 8 mm former. The SDRadio program by Alberto (http://digilander.libero.it/i2phd/ sdradio) is used as the decoder. The illustration shows an AM sta- tion being received. The sound card used (a USB Sound Blaster) has a sample rate of 96 kHz, giving a tuneable range of 48 kHz. In the illustration we can see three further transmissions. A weakness of the receiver is that it only has one output channel. This means that each transmitter can be seen twice in the spectrum dis- play, and there is no suppression of image frequencies as would be expected in a fully-featured SDR. Sometimes this can result in audi- ble interference, in which case the only remedy is to tune to another transmitter. And if none of the channels appeals, you can simply move to another band with a twist of the screwdriver. ( 080384 - 1 ) Detector with Amplification Burkhard Kainka A simple shortwave radio detec- tor is neither very sensitive nor very selective. However, with a little extra amplification we can improve the reception perform- ance significantly. The additional circuit is designed to compensate for the losses in the resonant circuit. A transistor is used to amplify the RF signal and feed it back into the resonant circuit. When the gain is set cor- rectly we can make the amount of this feedback exactly equal to the losses. The resonant circuit is then critically damped and has a very high Q factor. Now we can separate transmissions that are just 10 kHz apart, and we can tune in to very weak stations. The tuning capacitor used has two gangs of vanes with capac- itances of 240 pF and 80 pF. These two gangs are connected in parallel to make a 320 pF vari- able capacitance. The air-cored inductor has 25 turns on a diam- eter of 10 mm, with taps at 5-turn intervals. The resonant circuit so formed is capable of covering the full shortwave band from 5 MHz to 25 MHz. The shortwave detector can be connected to a power ampli- fier, or, for example, amplified PC loudspeakers. The antenna does not have to be very long: in experiments we used a one- metre length of wire. Tuning the radio involves adjusting the vari- 108 elektor - 7-8/2008 able capacitor to bring in the station and then adjusting the gain of the feedback circuit for optimal output volume. If the potentiometer is turned up too far, the receiver will go into self-oscillation and become a mini-transmitter. At the optimal setting the sound quality is very pleasant and certainly no worse than many ordi- nary shortwave radios. If you find shortwave detectors that use a battery and an amplifier a little new-fan- gled, you can get your fix of nostalgia by dispensing with the battery and connect- ing a crystal earpiece to the detector's output. The radio will of course also work without the feedback circuit, but with rather poorer performance. ( 080387 - 1 ) Piezo-powered Lamp Burkhard Kainka Energy is becoming ever more expensive, and some fresh ideas are needed. There are already human-powered devices on the market, most of which employ a dynamo to generate power. It is also possible to recover energy from a piezo crystal of the sort found, for example, in the loudspeak- ers in greetings cards. Making use of this device is relatively straightforward. Piezo crystals can generate voltages of many tens of volts when given a firm enough prod with a finger to bend the baseplate. The charge moved, however, is relatively small and the crystal is effec- tively a capacitor with a capacitance of only around 20 nF to 50 nF. This means that we need larger-scale storage in the form of an electrolytic capacitor. The piezo crystal can be treated as an alter- nating current source. We therefore need a rectifier and a reservoir capacitor. Pressing the metal surface of the transducer ten or twenty times with a finger will charge the electrolytic in steps to the point where it has enough charge to drive a LED. The cir- cuit is a 'charge pump' in the full sense of the term. When the button is pressed the electro- lytic discharges into the LED, which emits a brief, but bright, flash of light. ( 080385 - 1 ) Advertisement See your design in print! Elektor Electronics (Publishing) are looking for Freelance Technical Authors/ Designers If you have # an innovative or otherwise original design you would like to see in print in Europe's largest magazine on practical electronics # above average skills in designing electronic circuits # experience in writing electronics-related software # basic skills in complementing your design with an explanatory text # a PC , email and Internet access for efficient communication with our in-house design staff; then do not hesitate to contact us for exciting opportunities in getting your designs published on a regular basis. Elektor Electronics Jan Buiting, Editor P.O. Box II, NL-61 14-ZG Susteren, The Netherlands, Fax: (+31) 46 4370161 Email: editor@elektor.com 7-8/2008 - elektor 109 Digital Rev Counter for (Older) Diesels Romain Lievin Current diesel vehicles are (practically) all fitted with a rev counter. But diesel- engined cars tend to last' longer than their counterparts with petrol engines, so it is more than likely that there are still a fair number of older diesel cars around without such an instrument for measuring engine speed. We're going to enable you to fit them with one. On a petrol engine (motorbike or car), it's very easy to pick up pulses that reflect the engine revs. The number of articles that have appeared in Elektor are proof of this. Most circuits confine themselves to detecting the pulses generated by the ignition, either by magnetic coupling or directly, after shaping of an electrical signal. Since diesel engines by their very nature don't have spark plugs, an alter- native method has to be found. Here, it takes the form of a logic Hall-effect sen- sor (UGN3140) that delivers a pulse every time a magnet passes in front of it. You could equally well use a reflective pho- todetector... The biggest difficulty lies in finding a spot to fit one or more mag- nets. The timing belt pulleys would be a good location, but the whole assembly is always protected by a cover. Diesel vehi- cles are often fitted with a vacuum pump for the brake servo system. This pump is connected to the camshaft via a belt. The ideal spot for fitting two magnets and the sensor! Why two magnets? Any good mechanic knows that a 4-stroke engine has to make two revolutions for each engine cycle. But the camshaft controls this cycle in just a single revolution, and hence it turns at half the engine speed. So using two magnets enables us to obtain the correct number of pulses. As you can see, the circuit amounts to just a single 1C, an AVR microcontroller from Atmel. Long gone are the days when it took no less than six ICs to produce even a two-digit a rev counter! What's more, using a microcontroller with a crystal-controlled clock makes it pos- sible to dispense with any form of calibra- tion. The microcontroller contains everything needed to count pulses, using its interrupt U1 7805T K1 0 - , R3 Ht Ml 100uF 1 16V 14V K2 0 - 10uF 16V +5V O [R7 R8 I K4 C3 lOOnF (TXD)PDI (INT0)PD2 o o > IC1 (RXD)PDO (INT1PD3 (T0)PD4 (T1)PD5 (ICPJPD6 RESET (AINO)PBO (AINI)PBI PB2 (OCI)PB3 ATtiny2313 PB4 (M0SI)PB5 (MIS0)PB6 3 I] (SC^PB7 i — i — 2 X X CD C4 10nF 05 22? XI lilt C6 22p 3.6864 MHz 11 12 13 14 15 16 17 18 19 R6 R5 R4 R2 R1 +5V -O 4k7 4k7 4k7 4k7 4k7 D1 D2 D3 T5 BC557 t • t D4 D5 D6 D7 D8 R9 PBO RIO PB1 R11 PB2 R12 PB3 R13 PB4 R14 PB5 R15 PB6 R16 PB7 10 T4 BC557 < o < o u u dp O, a -Q O T3 0) w— LD1 HD1105 10 T3 BC557 < o < o u u dp O, a -Q O T5 0> m— LD2 HD1105 10 T2 BC557 < o < o u u dp O, a ~g -Q O "O CD 14— LD3 HD1105 6 1 10 T1 BC557 < o < o u u d P O, a ~g -Q O "O CL) 14— LD4 HD1105 6 1 071133-11 110 elektor - 7-8/2008 LD1-LD4 = 7-segment LED display, common anode, e.g. HD1105 T1-T5 = BC557 IC1 = AT90S2313, programmed with hex file from archive 080238-11 IC2 = 7805T Miscellaneous XI = 3.6864 MHz quartz crystal K1,K2 = solder pin K3 = 3-way pinheader K4 = 2-way pinheader with jumper UGN31 Hall-effect sensor PCB, ref. 071133-1 from www.thepcbshop.com COMPONENTS LIST Resistors R1,R2,R4-R8 = 4k07 R3 = S14K14 varistor R9-R16 = 2200 Capacitors Cl = lOOpF 25V C2 = lOpF 25V C3 = lOOnF C4 = lOnF C5,C6 = 22pF Semiconductors D1-D8 = LED, red, rectangular input, and directly drive a multiplexed dis- play, using its I/O lines that can sinking up to 20 mA. The display comprises four digits, to count from 60 to 9,999 revs. The bargraph is just a little gimmick that makes it easy to visu- alize engine acceleration or deceleration over a range of 1,000 rpm. It consists of eight LEDs, so offers a resolution of 125 rpm. To improve display accuracy, we recommend using two additional intermediate magnets (i.e. a total of four magnets on the camshaft). Because of the way the software has been designed (see software paragraph), the device needs at least one pulse every 0.5 second, i.e. 2 Hz, and hence a resolution of 120 rpm, which is not really enough and leads to an unstable display. The Hall-effect sensor is connected to header K3. Two additional magnets make it possible to increase the resolution to 60 rpm. The number of magnets fitted can be con- figured by means of the jumper fitted to header K4 (which may, as applicable take the form of a: - no jumper = two magnets, -jumper fitted = one magnet. Not much needs be said about the power supply, except that: - the regulator might need a heatsink, as the vehicle on-board voltage can reach 14 V, which represents a volts drop of 9 V with a current consumption of 30 mA, i.e. ^ 0.3 W; - the (vital) presence of a special car varis- tor to protect the regulator from voltage spikes. Otherwise, it's goodbye to the regu- lator the first time you start up! This project requires relatively few resources, whence the use of a small microcontroller: the Atmel AT90S2313, which by now is an old faithful in Elektor. It has two timers, I/O lines capable of driving LEDs directly, and an interrupt input. The interrupt input is used to count pulses by incrementing a software pulse counter (cntH:cntL). The timer is set to generate an interrupt every 2.5 ms. This interrupt is used to: -multiplex the display: each display is refreshed every 2.5 ms; hence the whole display is refreshed at a frequency of 80 Hz; - increment a software counter up to 250 ms (= one tick). At each tick, the value of the pulse counter is stored alternately in counter 0 or counter 1. This tick is also used in the primary loop to trigger counter processing and display refresh. In the primary loop, counters 0 and 1 are added together to obtain the number of pulses seen during the last two consecu- tive 250 ms time slots, i.e. 0.5 s. This trick makes it possible to update the display more frequently (250 ms) without having to wait for the end of the measurement (0.5 s). This makes it possible to increase the speed of the digital chain without compromising accuracy. The remainder of the software consists of converting the number of pulses into rpm. Everything is implemented in integer arithmetic. Given that the measurement is performed over 0.5 s, the result has to be multiplied by two to obtain the frequency, and then by 60 to obtain a value in revs per minute. All that then remains is to convert the binary result into a decimal value, which is achieved using Atmel's binary-to-BCD conversion routines (AVR204 Application Note). The most significant digit (MSD) is set to 0, and the result is then converted back to binary. This is a crafty method for calculating a remainder out of 1,000 (mod- ulo) for the bargraph. This value then has to be divided by eight, as the bargraph has eight LEDs (coded by subtraction and a loop). The result is used as an index for a decimal-to-7-segment transcoding routine. As supplied, the software occupies about 75% of the program flash memory. The software has been developed to work on an AT90S1200 or an AT90S2313. With a bit of luck it should also work on an AT90S1200, but although we haven't actu- ally tried that, we're sure there are Atmel programming enthusiasts among our read- ers capable of doing it. Let us know! The small inset schematic is that of a test generator specially designed for the rev counter. (071 133 - 1 ) Downloads The PCB artwork file is available for free download- ing from our website www.elektor.com; archive # (071 1 33-1 .zip. The source code and .hex files for this project are also available from www.elektor.com; archive # 071 1 33-1 1 .zip. Web Links AT90S2313 datasheet: www.atmel.com/dyn/resources/prod_documents/ doc0839.pdf S14K14 varistor datasheet: www.datasheetarchive.com/preview/3078060.html UGN3140 Hall-effect sensor datasheet: www.datasheetarchive.com/preview/3527952.html 7-8/2008 - elektor 111 IC2 Stefan Hoffmann For electronics enthusiasts building your own golf scorekeeper is a must (buying one is degrading - far too easy!). Then you can keep an eye on your total strokes on the course (and impress the other players naturally). This example is based on an ATtiny44 microcontroller, equipped with just two seven-segment displays and two data entry keys (to minimise power needs). The three EEPROM variables (18 arrays) used in the Bascom software are: Course- Par, the par for the course per hole, PersPar, for your personal score (par for the course plus handicap) and Score for the current total of strokes during the round. Since people play mainly at the same course and their handicap alters seldom (unfortunately far too seldom), the first two variables do not need to be entered into the EEPROM very often. Program source code and hex- file can be downloaded free of charge from www.elektor.com. At the golf course for each round you enter the number of strokes made at each hole and save this as the third array. When you get to the 'debriefing' afterwards at the nineteenth hole you can display the par for the course, your personal score and num- ber of strokes for each hole. At power-up you need to set the user mode by pressing keys as follows: 1.51 and S2 pressed: Enter Par for the Course and Personal Score 2. SI pressed: Display Par for the Course and Personal Score 3.52 pressed: Display Score (number of strokes) and Stableford points 4. No key pressed: Play a round - starts automatically, using the same mode as the last round. The middle decimal point appears when the hole number is displayed; only the upper bar is shown for the CoursePar in the left-hand display with the corresponding Par figure in the right-hand display. When PersPar is shown the middle horizontal bar appears in the left-hand display, whilst the strokes total is indicated by the bottom bar. Stableford points are signified by three horizontal bars in the left-hand display. The table gives a summary of the modes and the displays. It's a good idea to practise a bit before using the scorekeeper in ear- nest, if only to avoid irritation on the actual course... ( 080181 - 1 ) Inputs and displays Input CoursePar and PersPar Alternating input (press keys to increase or reduce): Hole/ CoursePar (e.g. 1 .1 _ 5) After 3 seconds next Hole After the 18 th Hole: Alternating input (press keys to increase or reduce): Hole/PersPar (e.g. 1.3 -7) After 3 seconds next Hole Display CoursePar and PersPar Alternating display: Hole/PersPar (e.g. 1.1 _ 5 After the 18 th Hole Alternating display: Hole/PersPar (e.g. 1.3 -7) Press keys for next/previous hole (in rotation) Score and Stableford display For each hole Alternating display: Hole/Score (e.g. 1 .1 _ 5) After the 18 th Hole Alternating display: Hole/Stableford points (e.g. 1.3 = S2) Play a round Alternating display: Hole/Score (e.g. 1.1 _5) Press keys to increase/decrease 112 elektor - 7-8/2008 STU-UK-1 Christian, 19, freshman Secure a head start in electronics with a Student Subscription!* *Only available in UK. Ask for the conditions. | Students qualify for a discount of no less than 20 % compared to the normal price of an annual subscription Subscribers get up to 40% discount on special Elektor products m 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 “Elektor is substance for professionals and those wanting to reach the level. The perfect entry to my studies!” ..■j* — mi ■ -Jr Hfc. Advantages to subscribers Electronics at all the right levels www.elektor.com/subs • Tel. +44 20 8261 4509 electronics worldwide Solar Cell Array Charger with Regulator SP1 Lars Nas This simple circuit can be used to charge batteries from a solar cell array. The circuit consists of an oscillator, a DC-DC step-up or 'boost' converter and a regulator that pro- vides regulation of the output voltage. The oscillator is built around a hex Sch- mitt trigger inverter 1C, the 40106B, one resistor, R1, inserted between the input and the output of one of the gates in the 40106 to supply charge to C3. Depending on the values of resistor R1 and capacitor C3 you're using in the circuit, the oscillator will operate at different frequencies, but a frequency below 100 kHz is recommended. By consequence, the oscillator frequency should not exceed the maximum ripple frequency of capacitor C2 connected on the output. C2 should be an electrolytic capacitor with a DC working voltage larger than the desired output voltage. Besides, it should have a low ESR (equivalent series resistance). IC1A is used as a buffer, ensuring that the oscillator sees a light, fairly constant load and so guaranteeing that the output fre- quency remains stable (within limits, of course). VCC of the Schmitt trigger can be connected directly to the battery charged, provided the charged battery voltage does not exceed the max. or min. limits of the Schmitt trigger's supply voltage. This ensures the Schmitt trigger can operate even if little power is obtained from the solar cell array. When transistor T2 is turned on, (output from oscillator buffer IC1A is high), a col- lector current flows through inductor LI which stores the energy as a magnetic field and creates a negative voltage V lv When transistor T2 is switched off, (output from oscillator buffer IC1A is low), the negative voltage V u switches polarity and adds to the voltage from the solar cell array. Con- sequently, current will now flow trough the inductor coil LI via diode D1 to the load (capacitor C2 and possibly the battery), irrespective of the output voltage level. Capacitor C2 and/or the battery will then be charged. So, in the steady state the out- put voltage is higher than the input voltage and the coil voltage V u is negative, which leads to a linear drop in the current flow- ing through the coil. In this phase, energy is again transferred from the coils to the out- put. Transistor T2 is turned on again and the process is repeated. A type BC337 (or 2N2222) is suggested for T2 as it achieves a high switching frequency. Inductor LI should have a saturation current larger than the peak current; have a core material like ferrite (i.e. high-frequency) and low-resist- ance. Diode D1 should be able to sustain a forward current larger than the maxi- mum anticipated current from the source. It should also exhibit a small forward drop and a reverse voltage spec that's higher than the output voltage. If you can find an equivalent Schottky diode in the junk box, do feel free to use it. The most important function of the shunt regulator around T1 is to protect the batter- ies from taking damage due to overcharg- ing. Besides, it allows the output voltage to be regulated. Low-value resistor R3 is switched in parallel with the solar cell array by T1 so that the current from the solar cell array flows through it. Zener diode D2 is of course essential in this circuit as its zener voltage limits the output voltage when T1 should be turned on, connecting the solar cell array to ground via R3. In this way, there is no input voltage to the boost converter and the battery cannot be overcharged. Sealed lead-acid (SLA) batteries with a liq- uid electrolyte produce gas when over- charged, which can ultimately result in damage to the battery. So, it's important to choose the right value for zener diode D2. Special lead-acid batteries for solar use are available, with improved charge-discharge cycle reliability and lower self-discharge than commercially-available automotive batteries. Finally, never measure directly on the out- put without a load connected — the ripple current can damage your voltmeter (unless it's a 1948 AVO mk2). ( 070894 - 1 ) Web Link www.electronicia.se 114 elektor - 7-8/2008 Assistance for BASCOM Programmers 2 3 4 5 6 Sregfile = AtTiny25.dat" Scrystal = 8000000 Shwstack = 24 &swstack = 16 7 8 9 Sfraiesize = 32 Dim B As Byt e 10 11 Open "CMB 3 9600.8 H .1“ For Output As £1 12 Open "CMB 1 9600,8,1 ,1" For Input As £2 13 14 Print ffl , "Hello" 15 Do 16 Print #1 17 Print #1 " press numer ic key AND return ' IS Input #2 B 19 Print #1 11 input uas n r B 20 21 Print n " press any key (no return required) 22 B = 0 23 While B = 0 24 B = Inkey ( $2 25 Wend 26 Print #1 'ASCII ii B ! equals " Chr b) 27 2S Loop 29 30 31 End 32 33 opens PB3=Pin 2 for seriel output 'opens PEli=F’isi 6 for serial input input number key -I- RETCRH BASCOM -A VIR Terminal emulator prsss uuneT io key AND re turn input uas 3 press any key sno return ireqoiieiJ t SCIl 65 equals « re$s nutteric key fiHD: metu m input was 7 fires?, anii key fna return require J) (ECII G6 equals B Jochen Bruning It is often useful to be able to display the values of certain variables or intermediate results during program execution when developing microcontroller software. This information can be invaluable especially when the program is not behaving entirely as you had anticipated. Applications using larger microcontrol- lers often already incorporate some form of liquid crystal display in the design so in this case it is reasonably easy to write a routine to display these intermediate values just for the purposes of program development. When your design uses one of the smaller microcontrollers like the ATtiny 25/45/85 series there are so few I/O pins available that it is impossible without additional hardware to provide a connec- tion to an additional LCD even by using 4- bit addressing. For designs using these tiny controllers the BASCOM programming environment can offer significant advantages; its compiler includes a software UART which provides a simple, flexible and 'reusable' solution to the problem by enabling data to be sent to and from the controller using its built-in terminal emulator program. It is only neces- sary to assign a single controller pin for the send and another for the receive serial data path. This approach gives far greater flexibility for the circuit layout when com- pared to microcontroller designs which use a hardware USART with its predefined pin assignments. The connection between the controller and PC can be made using a USB port where it will be necessary to use a USB to TTL adapter cable like the one manuf- actured by FTDI and featured in the June 2008 edition of Elektor (page 48). An even simpler solution is to use the spare serial port (RS232) on the PC, it will only be necessary to convert the signals from the TTL levels required by the controller to the RS232 levels used by the PC. A suitable circuit can be built using a MAX232 1C together with four capaci- tors. The author was able to make use of a cable taken from a redundant serial PC mouse. The 9-way D-type connector was fully encapsulated so it was necessary to solder the 1C together with the capacitors into the cable and protect the circuit with a length of heat-shrink sleeving. Details of the construction can be found in a PDF document which is available from the Elek- tor website. The only additional software required by the controller are the OPEN instructions which are used to configure the software UART. This instruction sets parameters such as baud rate, parity and the number of stop bits for the serial communication channel. In addition it defines which controller pin is used for communications and also the data direction (send or receive). Two OPEN state- ments are therefore necessary; one to set up the transmitted data path and the other for the received data. For example an instruction to configure data transfer from the controller to the ter- minal emulator: Open „COMB.3 : 9600, 8,N, 1" For Output As #1 B.3 : indicates that port B.3 is used which is pin 2 of a ATtiny25 controller. Output: indicates that data is sent from port B.3. #1 : File handle, used in the following Print command. Data can now be sent using the normal Print command: Print #1 , „ Hello" ; The variable to display #1 : references the corresponding Open statement above It is helpful to use a simple test program just to output some text. This will deter- mine whether the parameters defined in the Open-statement and the terminal emu- lator (found under 'Tools' along the top of the screen or invoked with Ctrl + t) are correctly configured and also if the cable is connected to the correct controller pin. There are different ways of sending variab- les to the controller; firstly it is necessary to use the Open statement to configure the Input and choose a different file handle (e.g. #2) in the Input or Inkey statements as in: Open "COMB. 1 : 9600, 8,N, 1" For Input As #2 ' PB1 (=Pin 6 of the ATtiny25) for the serial input Input #2 , Variable store or Variable store = Inkey (#2) The input of data must be terminated with a RETURN. Inkey will return a value of 0 if there is no character waiting i.e. no key has been pressed. For further information refer to the BASCOM online help pages. The screenshot shows a small test program listing together with the program output in the terminal emulator window. The hex file of this program is available for free down- load from the Elektor website, the file num- ber is 080370-11.zip. (080370e) 7-8/2008 - elektor 115 Volker Ludwig DDOEU Commercially available plas- tic LED spinning tops consist of one or more LEDs powered from two button cells and acti- vated using a switch actuated by centrifugal force. More elab- orate devices, according to the author's research, also include a microcontroller to provide an ever-changing light display. It is entirely unacceptable, on both pedagogical and environmen- tal grounds, that it is almost always impossible to replace the batteries without damag- ing the top. This gives us moti- vation enough to build or own version. First of all a few craft skills are called for to turn up a wooden top on the lathe. If you feel slightly unwell at the thought of show- ing off your woodworking skills to your children, then the author (e-mail address email@ddOeu.de) is willing to help you out by supplying ready-made tops like the one illustrated here which, thanks to their long handle, spin very satisfyingly. The circuit employs very few compo- nents and there is not a microcontroller in sight. The magic is down to the use of a high-brightness so-called 'rainbow LED' as mass produced for use in continuously- changing coloured 'mood' lights intended for domestic lighting applications. This device includes not only an RGB LED but also a control chip that causes it to change from colour to colour. Normally this colour changing is too slow to make a pretty effect when the LED is mounted on a spinning top. However, there is an interesting effect that occurs when using these slowly changing LEDs as the smooth colour transitions are produced using pulse width modulation. When the top is spun quickly the pulses of light give & ST2 (+) B T1 CR2025 ST1 0 - * see text an attractive visual effect, as the author's photograph shows. The circuit is very simple, with the main components being just the colour-chang- ing LED and a 3 V button cell. It is impor- tant not to forget the centrifu- gal force switch, as otherwise the recipient of the toy may be rather disappointed to discover that the battery is flat! In order to simplify construc- tion still further, the author has designed a printed circuit board for the project. Once the board is populated the central hole provided can be used to locate it correctly over the han- dle of the top. The printed cir- cuit board layout is available for download from http://www.ele- ktor.com. So that the top can be balanced correctly when construction is complete, it is important that it has no loose parts. The two terminal pins ST1 and ST2 form the contacts for the centrifugal force switch. A sprung contact can be impro- vised by soldering one end of a spring salvaged from an old ballpoint pen (you may need to try more than one to find one that works) to one of the pins and a length of tinned copper wire to the other end of the spring. The wire and the other pin then form the switch contacts, which are closed when the top is spun (see the photograph). Things should be arranged so that there is a gap of about 1 mm between wire and pin when the top is stationary. The bottom contact pad for the button cell can be made by soldering a small drawing pin in the middle of the battery holder area. The counterweight is made from an M3x10 screw with nut and a 4 mm washer, which allows for a little adjustment to be made. If more weight proves necessary, further washers or nuts can be added. ( 070916 - 1 ) 116 elektor - 7-8/2008 Cigarette-lighter Battery Charger B. Broussas This fine Summer's day, you've decided to go out for a breath of fresh air - but with- out wanting to give up your 'hi-tech toys' — whether it's your son's radio-controlled car, your daughter's MP3 player (all borrowed of course after due negotations), or your own favourite portable DVD player. All these appli- ances share the feature of usually operating on rechargeable batteries - which is of course no problem when the mains is at hand, as they all come with their own chargers. But the problem gets a bit more compli- cated out in the country, and as Murphy's Law has it, that's always just the moment you find your batteries are flat or nearly so. If your car is parked nearby, we can sug- gest a solution in the form of this very simple project - and what's more, it will cost you practically nothing, since it uses mostly components that any good elec- tronics enthusiast is likely to already have in a drawer or the junk box. Even if you did have to buy everything, the whole thing shouldn't cost more than about £ 10. As Figure 1 shows, it's a project that smacks of good old-fashioned - we almost said granddad's - electronics, as it doesn't use a microcontroller, nor even the slight- est specialized integrated circuit (1C). In spite of this, it will look after your batter- ies, especially if you are reasonable about the charging time. Whether they are old nicads (NiCd) - becoming extinct these days because of their many shortcomings and toxicity - or the omnipresent nickel-metal-hydrides (NiMH), these types of battery have to be charged at constant current. This charg- ing current should be 10% of their rated capacity (printed on the label) for a normal or slow charge, or a maximum of 100% of their capacity, if you want a fast charge. So, to recharge the NiMH or NiCd batteries in our various portable devices from a car battery - for that's what it's all about - all you have to do is build a constant current generator. To achieve this takes just two common or garden transistors, T2 and T3. The latter is turned on to a greater or lesser extent by way of R3 and T2. By virtue of the very principle of transistors, there cannot be more than about 0.6 V between the base and emitter of T2. If this voltage tends to drop, T2 will tend to turn off, which will then increase the conduction of T3 - and vice-versa. In other words, the base-emitter voltage of T2 will virtually always remain at 0.6 V. Now this voltage is produced by the cur- COMPONENTS T1 = BC557 T2 = BC547 T3 = TIP20 Miscellaneous SI = 1-pole 4-way LIST Resistors R1 = 8200 rotary switch (see R2 = IkO text) R3 = 4k07 4 solder pins R4 = 560 2 9-V batteries R5 = 10O PCB, ref. 080226- R6 = 407 1 from www. R7 = 105 thepcbshop.com Semiconductors D1 = 1N4004 LED1 = LED, red rent passing through one of the resistors R4-R7, and hence also the battery to be charged. So it's easy to see that this current is quite simply given by / ch = 0.6 / R where / ch is the desired charging current and R is one of the resistors R4-R7. As T2 turns on (and hence the battery is charging), transistor T1 increasingly satu- rates. If this current drops too much, or falls to zero in the event of a poor contact or faulty battery, the LED goes out to indi- cate a problem. Diode D1 protects the cir- cuit from possible reversed polarity of the battery being charged. We have designed a small PCB for this project with provision for direct mounting of a rotary switch to be mounted, thereby reducing the wiring needed to nothing. This switch is Lorlin part no. PT6422/BMH and is available, for example, from Farnell under product ref. 1123675. However any other equivalent may be used if it can be adapted to the circuit board. In most case, that means installing some extra wires between the PCB and the switch pole and contacts. Transistor T2 may be required to dissipate quite a lot of heat for low-voltage batteries being charged at high currents, so space has been provided to fit it with a U-shaped heatsink. The various designed charging currents are 400, 130, 60, and 10 mA for positions 1-4 of the switch. The unavoidable voltage drop across T2 means the maximum voltage of the battery to be recharged cannot exceed 9.6 V. If you want different charging currents from those designed, all you need do is simply replace one or other of R4-R7 by a resistor whose value has been calculated as above {R = 0.6 / / ch ) and whose power is given by P- 036/ R. As a constant-current generator, the circuit is naturally protected against short-circuits, but do take care all the same if you increase the charging current too much not to exceed the maximum power dissipation in T3 (65 W) and more importantly, the power allowed by the small heatsink provided for on the PCB. A current of 500 mA seems to us a reasonable maximum value to not exceed. The value should cater for most NIMH and NiCd batteries if a few hours are allowed to charge them. But then it was a sunny day so that shouldn't be a serious concern. ( 080226 - 1 ) Downloads The PCB copper track and component mounting plan can be downloaded from www.elektor.com; file # 080226-1.zip 7-8/2008 - elektor 117 AlphaSudoku - supersize mind boggier Puzzle designed by Claude Ghyselen Elektor's Summer Circuits differing widely from the regular monthly editi- ons, we thought it would make a nice change to publish a distinctly dissimilar type of puzzle this month, not just in regard of size but also complexity and diversity. We bet you've never seen one of these before and challenge you to solve it and enter a prize draw for an E- Blocks Professional starter kit and three Elektor Shop vouchers. The method of solving the AlphaSudoku puzzle is basically the same as for a classic Sudoku, with some modifications! AlphaSudoku has a 25x25 cell structure and takes numbers 1 through 9 and letters A through P (i.e. including the letter 'O', hence the absence of the 'O' in the num- bers). The puzzle is essentially a (16x16) Alphadoku comprising nine classic (9x9) Sudokus using numbers 1 trough 9. In AlphaSudoku, complete the diagram composed of 25x25 cells such that all let- ters A through P and all numbers 1 through 9 occur only once in every line, in every column and in every box (5x5; identified by a coloured outline). A number of clues are given in the puzzle and these represent the start situation. The nine embedded Sudokus have a background colour. All correct entries received for the puzzle go into a draw for a main prize and three lesser prizes. All you need to do is send us the combination of six numbers in the grey boxes. The puzzle is also available as a free download from our website. Solve AlphaSudoku and win! Correct solutions received enter a prize draw for an E-blocks Starter Kit Professional worth £ 249 and three Elektor Electronics SHOP Vouchers worth £ 35.00 each. We believe these prizes should encourage all our readers to participate! D 5 E G 2 K 7 1 O 9 P F 4 1 M A 1 1 6 8 A E H F L 2 K 4 5 9 3 2 L 9 J P 3 8 K 7 B 5 C N 9 K 1 C L M 6 5 B N 4 D G F 8 2 H B G 1 2 J P N 1 E 7 4 6 9 8 3 1 J N K G A M O C 7 O F P D A 1 B M E H M E P N 4 H C B J F 1 D O H B J A 2 L E N F 7 D G O F M B 1 P L K 8 3 9 6 7 1 J E H A C N F B D G 9 5 1 8 P O 1 D J 5 4 7 G K G H N A 8 P M 3 O J L A K M J 1 N E 9 L H O D P C 1 8 5 2 F M C P D 1 H K E 3 6 4 2 3 1 5 6 D G H J K M C E 7 O 8 4 C P G J A O 3 M B 4 L 2 1 N F K L H N 5 F A 1 E O P D J B O N K 8 6 C D L 1 A P 8 4 9 L 1 M G F B 6 2 1 5 E A 4 K L 1 6 C 2 3 G O 9 K 8 2 M 7 F G 9 1 E D 3 1 P C H J B O 6 N E A 8 7 5 1 J C 9 F 1 M 9 1 3 P B 4 G 1 8 5 A O 7 K 6 F D 3 7 C J H 5 9 M P N 4 L Participate! editor@elektor.com. Please send your solution (the numbers in Subject: alphasudoku 7-2008 (please the grey boxes) by email to: copy exactly). D A 5 C 0 2 9 8 7 3 E F 1 4 6 B 1 4 9 3 F B A D 5 6 0 2 C 8 E 7 B 7 E F 3 6 5 4 8 9 C 1 D 2 0 A 8 6 2 0 E 1 7 C 4 D B A 5 F 3 9 3 1 F B A E D 9 2 0 8 7 4 6 C 5 7 2 8 D C 0 6 5 1 4 F 3 A 9 B E 9 E 4 A 8 7 1 B D C 5 6 3 0 F 2 5 C 0 6 4 3 F 2 B A 9 E 7 D 1 8 4 F B E 7 C 2 3 A 1 D 0 9 5 8 6 2 3 6 8 1 5 E 0 C F 4 9 B 7 A D A 5 D 1 9 F B 6 3 2 7 8 0 E 4 C C 0 7 9 D 4 8 A E B 6 5 F 3 2 1 F 9 3 5 B D 4 1 6 8 2 C E A 7 0 6 8 A 7 5 9 C F 0 E 3 B 2 1 D 4 E D C 2 6 A 0 7 F 5 1 4 8 B 9 3 0 B 1 4 2 8 3 E 9 7 A D 6 C 5 F 118 elektor - 7-8/2008 Include with your solution: full name and street address. Alternatively, by fax or post to: Elektor Hexadoku Regus Brentford 1000, Great West Road Brentford TW8 9HH United Kingdom. Fax (+44) 208 2614447 The closing date is 1 September 2008. The competition is not open to employees of Elektor International Media, its business partners and/or associated publishing houses. Prize winners The solution of the May 2008 Hexadoku is: 36815. The E-blocks Starter Kit Professional goes to: Lee Archer (UK). An Elektor SHOP voucher worth £ 35.00 goes to Theis Borg (DK); Barry Cook (UK); David Chester (USA). Congratulations everybody! ( 080463 - 1 ) Automatic Car Battery Charger C. Tavernier A Summer Circuits edition on 'all things outdoors' — good, but what of all the bat- tery-powered circuits that remains indoors? Once the fine weather starts, the family car tends to remain increasingly in the garage - which is as beneficial to the owner, his/her bank account and the air that we breathe as it helps — to an extent to — reduce C0 2 emissions. However, when we come to want to use the trusty vehicle again, it often happens that the battery shows serious, deeply worrying signs of being flat, sometimes to the point of preventing the engine from starting altogether. Push- starting is no longer recommended or even possible with modern cars, so a topped up battery is highly appreciated. The solution of leaving an off-the-shelf charger permanently connected is not generally satisfactory, unless you're lucky enough to have an 'electronic' one. The majority of dirt cheap ordinary charg- ers don't include any regulation circuitry and so will over-charge a vehicle battery if you're unwise enough to leave it perma- nently connected. So our proposed project is to build a charger that can act as both a standard charger, and a float charger that you can leave perma- nently connected without the slightest risk to your battery or fear of over-charging. What's more, it doesn't use any 'exotic' com- ponents and is ridiculously cheap. Let's have a look at the circuit diagram. The voltage supplied by our charger's trans- former is rectified by diodes D1 and D2 but is not smoothed. Strange as it may seem, this is vital for it to work properly, because as a result the rectified voltage consists of a succession of sinewave half-cycles, and hence falls to zero 100 times per second. When thyristor THY2 is conducting, the battery is effectively charged, the charg- ing current being limited only by resistor R6, which has to be calculated as shown below. This thyristor is triggered via resistor R4 for each half-cycle of the mains, except when thyristor THY1 is itself triggered. In that event, THY2 turns off the first time its supply voltage drops to zero, and no fur- ther current can reach the battery. The voltage at the battery terminals is sampled by R5 and smoothed by Cl before turning on THY1 or not via PI and D3. As long as this volt- age is lower than a certain threshold, deter- mined by the setting of PI and corresponding to a battery that is not yet fully charged, THY1 is not triggered and so leaves THY2 conduct- ing for all the mains half-cycles. When the voltage at the battery terminals is high enough, THY1 is triggered and thus prevents THY2 from being triggered. This phenomenon is not in fact quite as clear-cut as we have just described, but takes place very progressively, so as it approaches full charge, the battery's average charging cur- rent gradually reduces automatically, even- tually stopping completely once the fully- charged voltage has been reached. LED1 acts as a charging indicator, while LED2 lights more when THY1 is being trig- gered frequently, thereby acting as a fully charged indicator. Three components of the circuit proposed here need to be selected according to the characteristics you want your charger to have; these are R6, THY2, and TR1. R6 needs to be calculated according to the maximum charging current you want, from: R6 =16/1 where I is the current expressed in amps. Warning! Given the value of the other ele- ments in the circuit (D1, D2, TR1, and the fuse), do not exceed 5 A. The power dissi- pated in R6 can be calculated from P R6 = 7-8/2008 - elektor 119 36 / R6 with P expressed in watts and R6 in ohms, of course. Thyristor THY2 should be a 100-V type (or more) rated at IV 2 to 2 times the desired maximum charging current. And lastly the transformer, which should have a power in VA given by: P= 18 x 1.2 x / where / is the maximum desired charging current, expressed in amps. The only adjustment to be made concerns pot PI and will require access to a well- charged battery. Connect it to the charger output and replace the 5-A fuse with an ammeter - preferably an old analogue type, better able to respond to average currents than certain modern digital types. Then adjust potentiometer PI to obtain a current of around 100 mA. Later on, when you have the opportunity to charge a very flat battery, you will be able to fine-tune this adjustment by tweak- ing PI to obtain a charging current close to the maximum you have set by means of R6. You'll need to find a compromise setting between the float charging current, which mustn't exceed around 100 mA, and this maximum current. Whatever the accuracy of your adjustment, you can be reassured that your battery will be treated better by this project than by many of its non-electronic counterparts to be found in the shops. (www.tavernier-c.com) (080224-1) Auto-off for Audio Gear Joseph Zamnit A good way to spend a relaxing afternoon is to be in a quiet place with just the right amount of sun or shade, drinks within reach and listening to your favourite songs on MP3 or CD. You doze off and by the time you wake up again the audio equipment has dropped silent due to flat batteries. What a pity! The simple circuit shown can prevent this embarrassing situation by de-actuating a relay when no audio signal is detected for about two seconds. The circuit consists of a sensitive LM358 based comparator, IC1 A, which keeps mon- ostable IC2A (a 4538) triggered as long as an audio signal is detected at the input. Via coupling capacitor Cl the circuit takes its input signal from the 'hot' side of the loudspeaker or headphones in your audio gear. The monostable will time out 2 s after mined by R6 and C3. being triggered, the delay being deter- (080420-0 Jean Claude Feltes On the author's bench lay two ICs, waiting to be tried out: an LM3404 switching regulator (only available in a surface mount package, unfortunately), and a U2352 PWM 1C. Together they could be used to make a small dimmer for LEDs. As in the case of the 'Dimmable LED lamp' elsewhere in this issue we use a 6 V lead- acid battery as our source of energy, and a Lux- eon 3 W LED as our light source. V cc therefore lies between a minimum of around 5.4 V and a maximum of around 7.2 V. The right-hand part of the circuit shows the switching regulator, which reduces the voltage from the 6 V lead-acid battery to the 4 V required by the high-power LED. As the voltage is reduced the current must increase, and so less current flows through the input power connections than does through the LED. The LM3404 includes all the necessary control electronics along with a MOSFET switch. The voltage across resistor R sns (CS, pin 5 of IC2) is proportional to the LED cur- rent and is compared against an internal reference of 200 mV. If the voltage falls below 200 mV the MOSFET is turned on for a fixed time t 0N . During this period the current through the inductor and the LED rises in an essentially linear fashion. Time t 0N is determined by R 0H and the input voltage V m : ^on = 0*1 34 (^on/^in) MS= 1 .83 ps (where /? 0N is in kQ and V m in V). 120 elektor - 7-8/2008 vcc After this time period has expired the MOS- FET is turned off and an approximately linearly-falling current flows through the flyback diode and the LED until L/ sns , the voltage across R sns/ reaches 200 mV, where- upon a new cycle begins. While the MOS- FET is off no current flows in the supply to the regulator. The minimum off time is 0.3 ps. Ripple current is inversely proportional to the inductance and to the switching fre- quency. During t 0N the current rises line- arly and the voltage across the coil is “ ^IN“^LED“^SNS = T8 V. Hence U L = L(A/ LED /At). With At = t 0N we obtain a ripple current of 66 mA. When the current reaches its lowest value the voltage across R sns is 200 mV. The aver- age value of the current is one half of the ripple current greater. With R sns = 0.3 O the average current is given by / avg = 200 mV/300 mO + 66 mA/2 = 700 mA. This is around the maximum permitted value for a 3 W LED. The LED current can be adjusted by chang- ing R sns , for which we can use a twisted length of resistance wire. More elegantly, we can use the PWM 1C to drive the DIM input of the switching regulator. The U2352 can generate a PWM signal adjustable from 0 % to 100 % using a min- imum of external components. The basic frequency of the internal triangle wave oscillator is set by Cl to around 10 kHz: fosc = 55/(C osc • ig (where f osc is in kHz, C osc in nF and V s in V). The triangle wave voltage is compared against a reference voltage set by PI, and at the output of the comparator we have our PWM signal. The signal passes through some internal control logic before reaching the output of the device to protect the output from overload. Since we do not require this function it is disabled by taking pin 5 to ground and pin 3 to V cc via R3. It is not clear from the datasheet whether resistor R4 is strictly necessary for internal voltage stabilisation. The PWM signal is taken from the output of the U2352 to the DIM input of the LM3404 and imposes a 10 kHz pulse-width modu- lation on the light produced. The 'Boost' switch (or pushbutton) forces the PWM output high and thus the LED to maximum brightness. (jean-claude.feltes@education.lu) (080373-1) Lighting Governor Peter Jansen This circuit is very handy as a timer circuit for a lamp, for lighting a staircase, for exam- ple, but can also be used as indicator for the front doorbell. A significant advantage of this circuit is that the circuit draws almost no current when in the inactive state. The circuit is activated with push button (SI), after which IC5 (a 555 timer 1C) starts to count down the set time. During this time the triac continues to conduct and the lamp is turned on. The 'on' time of the lamp is on is determined by the combina- tion of R1 and C2 and can be changed as required by your application or personal preference. R2 and C3 have been added because the 555 expects a 'negative' pulse at its trigger input. When the power supply is turned on, C3 holds the TR input of the 555 Low for a 7-8/2008 - elektor 121 short time, which triggers the timer 1C. Depending on the exact type (brand) of 555, the value of C4 (330 nF) may have to be changed to ensure a high enough power supply voltage when in the active state. Note also that you shouldn't use a 'too heavy' version of the triac. The circuit will drive at the most just a little more than 5 mA into the gate of the triac. The circuit worked properly when tested with a TIC206 and the slightly biggerTIC216. When selecting push button SI, take into account the switching current of the lamp. The switch must be able to handle that safely. In the event of a defective part, a 15- V zener diode is connected across the power supply for protection (D3). R6 and R7 have been added so that C4 will be dis- charged. In this way no dangerous voltage can remain when the circuit is unplugged. When large values for C2 are used, such as the 470 pF shown here, a good quality capacitor is required for C4. Any potential leakage resistance will then have no influ- ence on the set time. Because of an inferior capacitor in our prototype the time was considerably longer than expected... ( 080173 - 1 ) Solar Lamp using the PR4403 Burkhard Kainka The PR4403 is an enhanced cousin of the PR4402 40 mA LED driver. It has an extra input called LS which can be taken low to turn the LED on. This makes it very easy to build an automatic LED lamp using a rechargeable battery and a solar module. The LS input is connected directly to the solar cell, which allows the module to be used as a light sensor at the same time as it charges the battery via a diode. When darkness falls so does the voltage across the solar module: when it is below a thresh- old value the PR4403 switches on. During the day the battery is charged and, with the LED off, the driver only draws 100 pA. 2V4 D1 1N4148 Solar module BT1 8 © IC1 TEST VOUT LS NC NC VOUT PR4403 s s 1V2 Battery LI 4jli7 D2 white 071112-11 The PR4403 is available in an SO-8 pack- age with a lead pitch of 1.27 mm. The other components are a 1N4148 diode (or a Schottky 1N5819) and a 4.7 pH choke. Pin 2 is the LS enable input, connected directly to the solar module. According to the datasheet, it is possible to connect a series resistor at this point (typ. 1.2 M) to increase the effective threshold voltage. The LED will then turn on slightly earlier in the evening before it is not completely dark. At night the energy stored in the battery is released into the LED. In contrast to similar designs, here we can make do with a single 1.2 V cell. Pins 3 and 6 of the device must be con- nected together and together form the output of the circuit. ( 071112 - 1 ) 1 2 V Fan Directly on 230 V Ton Giesberts This circuit idea is certainly not new, but when it comes to making a trade-off bet- ween using a small, short-circuit proof transformer or a capacitive voltage divider (directly from 230 V mains voltage) as the power supply for a fan, it can come in very handy. If forced cooling is an afterthought and the available options are limited then perhaps there is no other choice. At low currents a capacitive divider requires less space than a small, short-circuit proof transformer. R1 and R2 are added to limit the inrush cur- rent into power supply capacitor C2 when switching on. Because the maximum rated R3 R4 operating voltage of resistors on hand is resistors for the current limit. The same is often not known, we choose to have two true for the discharge resistors R3 and R4 122 elektor - 7-8/2008 for Cl. If the circuit is connected to a mains plug then it is not allowed that a dange- rous voltage remains on the plug, hence R3 and R4. Capacitor Cl determines the maximum current that can be supplied. Above that maximum the power supply acts as a cur- rent source. If the current is less then zener diode D1 limits the maximum voltage and dissipates the remainder of the power. It is best to choose the value of Cl based in the maximum expected current. As a rule of thumb, start with the mains voltage when calculating Cl. The 12 V output vol- tage, the diode forward voltage drops in B1 and the voltage drop across R1 and R2 can be neglected for simplicity. The calcu- lated value is then rounded to the nearest E-12 value. The impedance of the capacitor at 50 Hz is 1 / (2tt50C). If, for example, we want to be able to supply 50 mA, then the required impedance is 4600 O (230 V/50 mA). The value for the capacitor is then 692 nF. This then becomes 680 nF when rounded. To compensate for mains voltage variations and the neglected voltage drops you could potentially choose the next higher E-12 value. You could also create the required capacitance with two smaller capacitors. This could also be necessary depending on the shape of the available space. It is best to choose for Cl a type of capacitor that has been designed for mains voltage applications (an X2 type, for example). ( 080507 - 1 ) Outside Light Controller WimdeJong This controller turns on the outside lights as soon as it becomes dark and then turns the lighting off at a set time, so that the lights are not burning needlessly all night long. It is also possible to automatically turn the lights on again in the morning at another preset time. Then once it is light enough outside they turn off again. You could obtain this functionality with an LDR and a switching time clock. The LDR senses when it is dark enough and the clock can turn the lights off again at a pre- set time, and the other way around. To keep the design simple and cheap, a different solution was chosen for this swit- ching clock. A normal clock needs to be set initially and perhaps again periodically as the clock drifts after a while. In addition, a display is required to set this clock, plus a few push buttons. Here a different approach is taken. Starting with the fact that an LDR can detect the sunrise and sunset and that the sun loops' around in 24 hours, we can use this know- ledge as an alternative method for deter- mining the time. This clock does not need to be set. The solar clock is born. The controller is built around a PIC16F628A, which runs from its internal RC oscillator at 4 MHz. When sunrise is detected, a counter is star- ted, this counter keeps running until the following sunrise (reset). At sunset, the current value of the counter is stored in the variable 'zontot'. So after sunset the time can be determined with the formula: time = counter - zontot/2 This design has two pushbuttons to set the switching times; 'Evening off' (SI) and 'Mor- ning on' (S2).The push buttons can only be operated after sunset and before sunrise. If in the evening (after sunset, the garden light are on) button SI is pushed, the lights will from now on go off at this particular time. When button 52 is pressed in the morning before sunrise, the lights, from now on, will turn on at this time and conti- nue to be on until sunrise. 7-8/2008 - elektor 123 These times are stored in the EEPROM inside the PIC so that they are not lost when the supply voltage is removed. The DS1820 temperature sensor shown in the schematic and the 433-MHz transmit- ter (a cheap transmit/receive module from Conrad Electronics) are optional. These can be used to measure the outside tempera- ture and send it to a receiver in the house. This outside temperature is sent as a byte once every minute and at a baud rate of 1200 bits/s (8 bits, no parity) with a reso- lution of half a degree. -2=-1°, 0=0°, 2=1° etc. Sensor and transmitter can be omitted without any problems if this functionality is not required. The adjustment procedure is as follows. Set the potentiometer so that the LED is on when it is dark and off when it is light. Leave the circuit alone for a 24-hour period so that the controller can synchronise with the daily sun cycle. After that you can use the two pushbuttons to set the switching times. ( 080258 - 1 ) Downloads The source and hex code files for this project are avai- lable as a free download from www.elektor.com; file # 080258-11.zip. ISO Standard for Car Radios B Group im ns HI 111 C Group 13 16 19 15 18 14 17 20 ■ A Group Power Supply 1 RPM pulse A pulsed RPM signal is used to maintain a constant volume level or to operate a navigation system. This is also known as SCV (Speed Controlled Volume) or GALA (Geschwindigkeits-Abhangige Lautstarke-Anpassung). 2 Remote control / ground / telephone mute Mutes the audio output of the radio. This requires a hands-free kit that pulls pin 2 to ground during a telephone call. 3 Remote control Strongly brand-dependent. 4 Constant 12 V in; orange (yellow) Constantly connected to the +12-V terminal of the battery. Memory settings (sta- tions, tone and time) are thus retained when the radio is switched off. 5 Switched 12 V out / antenna remote, blue The motor-driven antenna is extended when 12 V is present on this pin. It can also be used to switch accessories such as amplifiers or sound processors. 6 Lighting, yellow/black 12 V must be present on this pin to illuminate the buttons of the radio and allow the display to be dimmed. 7 Switched 12 V in, red The radio can be switched on if 12 V is present on pin 7 (via the ignition switch). 8 Ground, black (brown) Connection to the chassis and thus to the negative terminal of the battery. The assignments of pins 1 to 3 may be swapped, depending on the make or brand. Pin 3 is sometimes used for a brand-specific bus signal. The assignments of pins 4 and 7 are often swapped (for example, by VW, Audi and Opel). In recent VW models, pin 5 is used as a supplementary connection for constant +12 V. This means that if you install a different radio, you must disable this connection, as otherwise the new radio will have a short life. Giel Dols A standard for the audio connections of car radios has been generated in order to avoid having every car manufacturer devise its own solution to this common and recur- rent issue. This standard has now been adopted by the International Organization for Standardization (ISO). The mechanical construction, dimensions and shape are clearly specified, at least in principle. Here we have to say 'in principle' because some manufacturers cannot resist the tempta- tion to arrange the signals on the connec- tors according to their own ideas. The classic examples of this are Audi, Opel and VW, which practically make a tradition of exchanging the terminals for the constant sup- ply voltage and switched voltage. As a result, if you connect a new radio it will behave in a very irritating manner: every time you switch off the ignition and remove the key, all your settings will be lost. As a result, most car radio manufacturers provide a simple way to swap these connections in the cabling. The tables clearly show which signals are assigned to the various pins of the connec- tors (or how they should be assigned). It is thus very much recommended to use a multimeter to check whether everything is B Group Loudspeakers 1 Right rear + , blue 2 Right rear — , blue/black 3 Right front + , grey 4 Right front — , grey/black 5 Left front + , green 6 Left front — , green/black 7 Left rear + , brown 8 Left rear — , brown/black C Group Extensions 1 Line out, left rear 2 Line out, ground 3 Line out, right rear 4 Line out, left front 5 Antenna/remote 12 V out 6 Line out, right front 7... 10 Brand/make dependent 11 Phone in 12 Phone in, ground 13 CDID 14 Brand/make dependent 15 Ground 16 Constant +12 V 17 Switched +12 V 18 CD changer line-in ground 19 CD changer line in, left 20 CD changer line in, right The assignments of pins 1-6 are always as described here. However, recent Becker radios use pin 6 for the subwoofer output. Manufacturers can use the remaining pins as they see fit. connected as it should be, especially for the connections in the 'A' group. ( 080471 - 1 ) 124 elektor - 7-8/2008 MypHaribi Co scero iwmpa http://r-point.nnm.ru www. jo urnal-pl aza.net PR4401/02 off the Beaten Track Ernst Krempelsauer & Burkhard Kainka The well-known PR4401 and PR4402 LED drivers from PREMA have enjoyed great popularity as a result of their low cost, tiny physical size, and ready avail- ability. The device is a switching regu- lator that is specifically designed for driving white LEDs from a single dry or rechargeable cell. The only external component required is a small induc- tor (see Figure 1). For maximum out- put power a 10 pH inductor is needed in the case of the PR4401, and 4.7 pH in the case of the PR4402. With an input voltage of between 0.9 V and 1.5 V the PR4401 can then deliver a current of up to 23 mA into the white LED connected to its output; the PR4402 can manage currents as high as 40 mA. Other cur- rent-delivery applications besides driv- ing LEDs are also possible, of course. For example, the LED can be replaced by a string of between one and ten NiMH cells in series plus a series diode (see Figure 2). The cells will then be charged at a current of up to 23 mA (PR4401) or up to 40 mA (PR4402). The output of the switching regulator behaves as a kind of constant power source, always delivering (with the coil values suggested above) around 70 mW (PR4401) or 140 mW (PR4402) into the connected load. When charg- ing NiMH cells the current will be at its maximum value given above when up to three cells are connected (3.6 V), and with more cells (that is, with a higher total battery voltage) the current will fall. With ten cells (12 V) the current flow to the battery is just 6 mA (PR4401) or 12 mA (PR4402). The ICs are less suitable for applica- tions where the load characteristics are not constant. The lower the load, the higher the output voltage, and with an open-circuit output an internal zener diode limits the output voltage to approximately 18 V. This diode there- fore effectively replaces the missing load and dissipates the power output by the regulator. If the output voltage is limited to a lower value using an exter- nal zener diode then the regulator will deliver all the output power not taken by the load into the diode. The upshot of all this is that the lower the load, the poorer the efficiency of the circuit. 1 PR4401/02 1 3 top view * see text 080486 - 11 Applications of this attractive device as a voltage source are also worth a quick look. For example, you might be look- ing for an application for the printed circuit board, with PR4401 1C and coil ready fitted, that came free with the September 2007 issue of Elektor. Figure 3 shows the circuit of a sim- ple voltage regulator using a PR4401 or PR4402. The zener diode voltage is chosen according to the wanted out- put voltage, between 3 V and 15 V. These voltages can be generated from a single NiMH or alkaline cell (1.2 V or 1.5 V), which, for example, allows you to replace the expensive 12 V batter- ies found in some instruments and in remote controls for garage door open- ers. The maximum output current from the voltage regulator can be calculated as follows: / =P 'max ' 1 max/^Z P max is 70 mW (PR4401) or 140 mW (PR4402) and U z is the zener voltage, which is equal to the output voltage. The circuit is most efficient when the output current is near to / max . If nec- essary, / max can be reduced by using a higher-valued inductor to match it better to the required output load. To a reasonable approximation, doubling the inductance will halve the maximum output current. We can also use a LED driver to gener- ate a symmetrical supply from a single NiMH or alkaline cell. Figure 4 shows a practical example generating +9 V and -9 V. Because of the additional diode in the negative arm of the circuit, the negative output is about 0.7 V lower in magnitude than the positive. In our prototype, where we used a 15 pH inductor and a 1.5 V cell voltage, we obtained the measured output volt- ages of +9 V and -8.3 V (with no load), and +8.6 V and -7.9 V (with a 2.2 kO load, simulating the 4 mA current draw of a typical opamp circuit). The current drawn from the 1.5 V cell was 50 mA in the no-load case and 80 mA in the 2.2 kO load case. ( 080486 - 1 ) 7-8/2008 - elektor 125 ELEKTOR SHOWCASE To book your showcase space contact Huson International Media Tel. 0044 (0) 1 932 564999 ATC SEMITEC LTD www. atcse m itec . co . u k Thermal and current-sensitive components for temperature control and circuit protection; • NTC Thermistors • Current Diodes • Thermostats • Re-settable Fuses • Thermal Fuses • Temperature Sensors Call today for free samples and pricing Tel: 01 606 871 680 Fax: 01 606 872938 AVIT RESEARCH www.avitresearch.co.uk USB has never been so simple... with our USB to Microcontroller Interface cable. Appears just like a serial port to both PC and Microcontroller, for really easy USB connection to your projects, or replacement of existing RS232 interfaces. See our webpage for more details. From £10.00. BETA LAYOUT www.pcb-pool.com Beta layout Ltd Award- winning site in both English and German offers prototype PCBs at a fraction of the cost of the usual manufacturer’s prices. B0W00D ELECTRONICS LTD www. bowood-electronics.co.uk Suppliers of Electronic Components • Semiconductors • Opto Electronics • Passives • Enclosures • Switches • Stripboard • PCB Materials • Popular Special Offer Packs Online Store, all major cards Same day despatch upto 3.00pm Personal Service sales@bowood-electronics.co.uk Tel: 01246 200222. BYVAC ELECTRONICS www.byvac.co.uk 32Bit ARM Microcontroller, USB, built in RTC with itis own operating system, no complex tools, just a terminal emulator, start writing programs in 20 minutes. Complete with CD-ROM, Software and 100 Page Foundation book C S TECHNOLOGY LTD www.cstech.co.uk Low cost PIC prototyping kits, PCB's and components, DTMF decoder kits, CTCSS, FFSK, GPS/GSM, radio equipment and manuals. PCB design and PIC program development. DECIBIT CO.LTD. www.decibit.com Development Kit 2.4 GHz Transceiver nRF24L01 AVR MCU ATmega168 DESIGNER SYSTEMS http://www.designersystems.co.uk Professional product development services. • Marine (Security, Tracking, Monitoring & control) • Automotive (A V, Tracking, Gadget, Monitoring & control) 3 • Industrial (Safety systems, W J' Monitoring over Ethernet) • Telecoms (PSTN handsets, GSM/GPRS) • Audiovisual ((HD)DVD accessories & controllers) Tel: +44 (0)1872 223306 Hail EasyDAQ www.easydaq.biz • USB powered, 4 relays + 4 DIO channels • Will switch 240VAC @ 10 amps • Screw terminal access • LabVIEW, VB, VC • Free shipping • From £38 Design & supply of USB, USB Wireless, Ethernet & Serial, DAQ, Relay & DIO card products. info@easydaq.biz EASYSYNC http://www.easysync.co.uk EasySync Ltd sells a wide range of single and multi- port USB to RS232/RS422 and RS485 converters at competitive prices. ELNEC www.elnec.com • device programmer manufacturer • selling through contracted distributors all over the world • universal and dedicated device programmers • excellent support and after sale support • free SW updates • reliable HW • once a months new SW release • three years warranty for most programmers YOUR ELECTRONICS OPEN SOURCE http://dev.emcelettronica.com Website full of Projects and Resources for Electronics Engineers and DIY. • Tutorial • Hardware (Schematic & Gerber) ” • Firmware (Asm & C) • Reference Design Everyone can submit a story as a useful source! 'Share for life' Wrsf feehnafagy Trtirtsftf Ltd. FIRST TECHNOLOGY TRANSFER LTD. http://www.ftt.co.uk/PICProTrng.html Microchip Professional C and Assembly Programming Courses. The future is embedded. Microchip Consultant /Training Partner developed courses: • Distance learning / instructor led • Assembly / C-Programming of PIC1 6, PIC1 8, PIC24, dsPIC microcontrollers • Foundation / Intermediate FLEXIPANEL LTD www.flexipanel.com TEAclippers - the smallest PIC programmers in the world, from £20 each: • Per-copy firmware sales • Firmware programming & archiving • In-the-field firmware updates • Protection from design theft by subcontractors FUTURE TECHNOLOGY DEVICES http://www.ftdichip.com FTDI designs and sells USB-UART and USB-FIFO interface i.c.’s. Complete with PC drivers, these devices simplify the task of designing or upgrading peripherals to USB ILP ELECTRONICS LTD www.ilpelectronics.com Tel +441233750481 Fax +441 233750578 ILP have been manufacturing audio modules since 1 971 and apart from our standard range we also offer a custom design service for the OEM market. LONDON ELECTRONICS COLLEGE http://www.lec.org.uk Vocational training and education for national qualifications in Electronics Engineering and Information Technology (BTEC First National, Higher National NVQs, GCSEs and GCEs). Also Technical Management and Languages. [EC MARCHAND ELECTRONICS INC. www.marchandelec.com • power amplifier modules • electronic crossovers solid state / valve / passive • valve amplifiers • phono preamps • handheld sinewave generator • kits or assembled • software electronic instruments • custom design services 126 elektor - 7-8/2008 products and services directory MQP ELECTRONICS www.mqp.com • Low cost USB Bus Analysers • High, Full or Low speed captures • Graphical analysis and filtering • Automatic speed detection • Bus powered from high speed PC • Capture buttons and feature connector • Optional analysis classes NEW WAVE CONCEPTS www.new-wave-concepts.com Software for Hobbyists: • Livewire - circuit simulation software, only £34.99 • PCB Wizard - PCB design software, only £34.99 • Circuit Wizard - circuit, PCB and breadboard design software, only £59.99 Available from all Maplin Electronics stores and www.maplin.co.uk OBD2CABLES.COM http://www.obd2cables.com • Thousands of OBD cables and connectors in stock • Custom cable design and manufacturing • OBD breakout boxes and simulators • Guaranteed lowest prices • Single quantity orders OK • Convenient online ordering • Fast shipping Visit our website, or email us at: sales@obd2cables.com ROBOT ELECTRONICS http://www.robot-electronics.co.uk Advanced Sensors and Electronics for Robotics • Ultrasonic Range Finders • Compass modules • Infra-Red Thermal sensors • Motor Controllers • Vision Systems • Wireless Telemetry Links • Embedded Controllers ROBOTIQ http://www.robotiq.co.uk Build your own Robot! Fun for the whole family! • MeccanoTM Compatible • Computer Control • Radio Control • Tank Treads • Hydraulics Internet Technical Bookshop, 1-3 Fairlands House, North Street, Carshalton, Surrey SM5 2HW email: sales@robotiq.co.uk Tel: 020 8669 0769 RADIOMETRIX www.radiometrix.com The leading global developer of ISM band, low power radio modules for wireless data transmission: • Transmitters • Receivers • Transceivers • RF modems • Evaluation Kits SCANTOOL.NET http://www.scantool.net ScanTool.net offers a complete line of PC-based scan tools for under £50. • 1 year unconditional warranty • 90 day money back guarantee • For use with EOBD compliant vehicles • Fast shipping • Compatible with a wide range of diagnostic software Visit our website, or email us at: sales@scantool.net USB INSTRUMENTS http://www.usb-instruments.com USB Instruments specialises in PC based instrumentation products and software such as Oscilloscopes, Data Loggers, Logic Analaysers which interface to your PC via USB. VIRTINS TECHNOLOGY www.virtins.com PC and Pocket PC based virtual instrument such as sound card real time oscilloscope, spectrum analyzer, signal generator, multimeter, sound meter, distortion analyzer, LCR meter. Free to download and try. SHOWCASE YOUR COMPANY HERE Elektor Electronics has a feature to help customers promote their business, Showcase - a permanent feature of the magazine where you will be able to showcase your products and services. For just £220 + VAT (£20 per issue for eleven issues) Elektor will publish your company name, website address and a 30-word description For £330 + VAT for the year (£30 per issue for eleven issues) we will publish the above plus run a 3cm deep full colour image - e.g. a product shot, a screen shot from your site, a company logo - your choice Places are limited and spaces will go on a strictly first come, first served basis. So-please fax back your order today! _ n I wish to promote my company, please book my space: • Text insertion only for £220 + VAT • Text and photo for £330 + VAT NAME: ORGANISATION: JOB TITLE: ADDRESS: TEL: PLEASE COMPLETE COUPON BELOW AND FAX BACK TO 00-44-(0)1932 564998 COMPANY NAME WEB ADDRESS 30- WORD DESCRIPTION 7-8/2008 - elektor 127 BOOKS, CD-ROMs, KITS & MODULES Going Strong A world of electronics from a single shop! A DIY system made from recycled components Design your own Embedded Linux control centre on a PC These days a lot of options exist if you want to control home electrical appliances. This book is not about XI 0, ZigBee, Z-wave or any other system that's available commercially. Instead, it covers a do-it-your-self system made from recycled components. The main system described in this book reuses an old PC, a wireless mains outlet with three switches and one controller, and a USB webcam. All this is linked together by Linux - as it can be obtained free of charge. This book will serve up the basics of setting up a Linux environment - including a software de- velopment environment - so it can be used as a control centre. The book will also guide you through the necessary setup and configuration of a Webserver, which will be the interface to your very own home control centre. All software needed for the control centre is listed in the book and will be available for downloading from the Elektor website. Approx. 248 pages • ISBN 978-0-905705-72-9 • £24.00 • US$ 48.00 Compute Vision PrlndpkK and ftracticc Principles and Practice Computer Vision Computer vision is probably the most ex- citing branch of image processing, and the number of applications in robotics, au- tomation technology and quality control is constantly increasing. Unfortunately enter- ing this research area is, as yet, not sim- ple. Those who are interested must first go through a lot of books, publications and software libraries. With this book, how- ever, the first step is easy. The theoretically founded content is understandable and is supplemented by many examples. 320 pages • ISBN 978-0-905705-71-2 £32.00 • US$ 64.00 Silent alarm, poetry box, night buzzer and more! PIC Microcontrollers This hands-on book covers a series of exciting and fun projects with PIC micro- controllers. You can built more than 50 projects for your own use. The clear ex- planations, schematics, and pictures of each project on a breadboard make this a fun activity. You can also use it as a study guide. The technical background infor- mation in each project explains why the project is set up the way it is, including the use of datasheets. Even after you've built all the projects it will still be a valuable reference guide to keep next to your PC. 446 pages • ISBN 978-0-905705-70-5 £27.00 • US$ 54.00 v y \ y Prices and item descriptions subject to change. E. & O.E 128 elektor - 7-8/2008 More than 68,000 components ECD 4 The program package consists of eight databanks covering ICs, germanium and silicon transistors, FETs, diodes, thyristors, triacs and optocouplers. A further eleven applications cover the calculation of, for example, LED series droppers, zener diode series resistors, voltage regulators and AMVs. A colour band decoder is in- cluded for determining resistor and in- ductor values. ECD 4 gives instant access to data on more than 68,000 compo- nents. All databank applications are fully interactive, allowing the user to add, edit and complete component data. This CD- ROM is a must-have for all electronics enthusiasts. ISBN 978-90-538 1-1 59-7 • £15.90 • US$31.80 All articles published in 2007 Elektor 2007 This CD-ROM contains all articles pub- lished in Elektor Volume 2007. Using the supplied Adobe Reader program, articles are presented in the same layout as originally found in the magazine. An extensive search machine is available to locate keywords in any article. The instal- lation program now allows Elektor year volume CD-ROMs you have available to be copied to hard disk, so you do not have to eject and insert your CDs when searching in another year volume. With this CD-ROM you can produce hard copy of PCB layouts at printer resolution, adapt PCB layouts using your favourite graphics program, zoom in / out on selected PCB areas and export circuit diagrams and illustrations to other programs. ISBN 978-90-5381-218-1 • £16.90 • US$33.80 Modern technology for everyone Display Computer FPGA Course (May 2008) FPGAs have established a firm position in the modern electronics designer's toolkit. Until recently, these 'super components' were practically reserved for specialists in high-tech companies. The nine lessons on this courseware CD-ROM are a step by step guide to the world of Field Pro- grammable Gate Array technology. Sub- jects covered include not just digital logic and bus systems but also building an FPGA Webserver, a 4-channel multimeter and a USB controller. The CD also con- tains PCB layout files in pdf format, a Quartus manual, project software and various supplementary instructions. ISBN 978-90-5381-225-9 • £14.50 • US$ 29.00 r ^ More information on the Elektor Website: www.elektor.com Elektor Regus Brentford 1 000 Great West Road Brentford TW8 9HH United Kingdom Tel.: +44 20 8261 4509 Fax: +44 20 8261 4447 Email: sales@elektor.com r^lektor LT3shop Programming a graphic display is dis- tinctly more difficult than programming a text display. Our mini microcontroller board features a new display-on-glass module and a high-performance Renesas Ml 6C microcontroller. The board is avail- able fully assembled, and the microcon- troller is pre-loaded with a TinyBasic interpreter to simplify the development of graphics applications - even for novices. Populated PCB in enclosure Art.#070827-91 • £78.80 • US$ 157.60 (May & April 2008) A low-cost home automation server based on a Freescale Coldfire 32-bit mi- crocontroller. The project has been de- signed with open source in mind and doubles as a powerful Coldfire develop- ment system using free CodeWarrior soft- ware from Freescale. DigiButler activates electrical appliances in and around the home, accepting on/off commands from a WAP phone, through an Ethernet net- work or via a webpage at an allocated IP address and with full access security. Kit of parts including SMD-stuffed PCB , programmed microcontroller , all leaded parts and CD-ROM containing both Elektor articles , TBLCF documentation , datasheets , application notes and source code files. Art.# 071102-71 • £29.00 • US$ 58.00 7-8/2008 - elektor 129 PRODUCT SHORTLIST, BESTSELLERS July/August 2008 (No. 379/380) £ USS Portable Thermometer 080418-41 ....Programmed controller PIC16F684 9.00.... ....18.00 Dimmable LED light 070963-41 ....Programmed controller AVR231 3 11.90.... ....23.80 Solar-powered Automatic Lighting 080228-41 .... Programmed controller PIC1 2C671 9.00.... ....18.00 Battery Discharge Meter 070821 -41 .... Programmed controller PIC1 6F676-20I/P 5.90.... ....11.80 070821 -42 .... Programmed controller PIC1 6F628-20/P 9.00.... ....18.00 Operating Hour Counter 070349-41 ....Programmed controller PIC12F683 5.90.... ....11.80 Lamp in a Wine Bottle 080076-41 ....Programmed controller ATtiny45 5.90.... ....11.80 Energy-efficient Backlight 080250-41 ....Programmed controller ATmega32 22.50.... ....45.00 Deluxe '123' Game 080132-41 ....Programmed controller ATmega8-PU 9.00.... ....18.00 Reaction Race using ATtinyl3 0801 1 8-41 .... Programmed controller ATtinyl 3 4.90.... 9.80 Underwater Magic 071037-41 ....Programmed controller AT90S8515P 14.90.... ....29.80 Flowcode for Garden Lighting 0801 1 3-41 .... Programmed controller PIC1 6F88 11.90.... ....23.80 Tent Alarm 080135-41 ....Programmed controller ATtinyl 3V 4.90.... 9.80 Programmable Servo Driver 080323-41 ....Programmed controller PIC12F675 5.90.... ....11.80 Simple USB AVR-ISP Compatible Programmer 080161 -41 .... Programmed controller ATmega8-l 6AU 11.90.... ....23.80 Intelligent Presence Simulator 080231 -41 .... Programmed controller PIC1 2C508 5.90.... ....11.80 LiPo Manager 080053-41 ....Programmed controller PIC16F84 11.90.... ....23.80 GPS Receiver 080238-41 .... Programmed controller PIC1 6F876A 23.00.... ....46.00 Universal Thermostat 080090-41 ....Programmed controller PIC16F628 9.00.... ....18.00 DTMF-controlled Home Appliance Switcher 080037-41 .... Programmed controller ATmega8-l 6PC 9.00.... ....18.00 Solar-powered Battery Charger 080225-41 .... Programmed controller PIC1 2C671 9.00.... ....18.00 RGB Lights 08041 9-41 .... Programmed controller PIC1 2F675 5.90.... ....11.80 Microlight Fuel Gauge 080054-41 ....Programmed controller ATmega8 9.00.... ....18.00 Digital Rev Counter for (Older) Diesels 071 1 33-41 .... Programmed controller AT90S231 3 5.90.... ....11.80 Golf Tally 0801 81 -41 .... Programmed controller ATTiny44 5.90.... ....11.80 Outside Light Controller 080258-41 .... Programmed controller PIC1 6F628A 9.00.... ....18.00 June 2008 (No. 378) Thermo-Snake 070122-41 .... PIC1 8F2550, ready-programmed 13.20 26.40 SAPS -400 070688-91 .... PCB, populated and tested, ready-mounted in aluminium U profile 159.00 318.00 USB-to-TTL Serial Cable 08021 3-71 .... USB-to-TTL converter cable 1 5.90 31 .80 May 2008 (No. 377) Two-wire LCD 071035-93 ....SMD-populated board with all parts and pinheaders 22.40 44.80 Display Computer 070827-91 ....Populated PCB in enclosure 78.80 157.60 Prices and item descriptions subject to change. E. & O.E Bestsellers r \ O od 1 2 3 4 5 1 2 3 4 Computer Vision ISBN 978-0-905705-71 -2 £32.00. US$64.00 PIC Microcontrollers ISBN 978-0-905705-70-5 £27.00. USS 54.00 Visual Basic for Electronics Engineering Applications ISBN 978-0-905705-68-2 £29.00. US$ 58.00 309 Circuits ISBN 978-0-905705-69-9 £19.95. USS 39.95 Microcontroller Basics ISBN 978-0-905705-67-5 £19.50. US$ 39.00 FPGA Course ISBN 978-90-5381-225-9 £14.50. USS 29.00 Elektor 2007 ISBN 978-90-538 1-218-1 £1 6.90 .....USS 33.80 ECD 4 ISBN 978-90-5381-159-7. .£15.90. US$31.80 Et ISB Home Automation ISBN 978-90-5381-195-5 £13.90. US$ 27.80 thernet Toolbox ISBN 978-90-538 1 -2 1 4-3 £1 8.90 .....USS 37.90 1 2 3 4 5 DigiButler Art. # 071 1 02-71 £29.00. USS 58.00 Elektor Internet Radio Art.# 071081-71 £1 15.00...USS 230.00 Display Computer Art. # 070827-91 E78.80...USS 157.60 SAPS-400 Art. # 070688-91 E159.00...USS 318.00 ECIO PLC Art. # 070786-71 E76.00...USS 152.00 Order quickly and safe through www.elektor.com/shop or use the Order Form near the end of the magazine! Elektor Regus Brentford 1 000 Great West Road Brentford TW8 9HH * United Kingdom Tel. +44 20 8261 4509 Fax +44 20 8261 4447 Email: sales@elektor.com 130 elektor - 7-8/2008 «k % PIC Microcoirtrol\ej;5 Hekla* r^lektor L.~ SHOP % PIC Microcontrollers Silent alarm, RGB fader, poetry box, night bifrzer ahd more! This hands-on book covers a series of exciting and fun projects with PIC microcontrollers. You can built more than 50 projects for your own use. The clear explanations, schematics, and pictures of each project on a breadboard make this a fun activity. You can also use it as a study guide. The technical background information in each project explains why the project is set up the way it is, including the use of datasheets. All software used in this book can be downloaded for free, including all of the source code, a program editor, and the JAL open source programming language. 446 pages • ISBN 978-0-905705-70-5 • £27.00 • US$ 54.00 Elektor Reg us Brentford 1 000 Great West Road Brentford TW8 9HH United Kingdom Tel. +44 20 8261 4509 Order quickly and safe through WWW.elektor.COIn/shop Index of Advertisers Allendale Electronics Ltd www.pcb-soldering.co.uk 71 ATC Semitec Ltd, Showcase www.atcsemitec.co.uk 126 Avit Research, Showcase www.avitresearch.co.uk 126 Beijing Draco www.ezpcb.com 39 Beta Layout, Showcase www.pcb-pool.com 39, 126 Bitscope Designs www.bitscope.com 11 Bowood Electronics Ltd, Showcase www.bowood-electronics.co.uk 126 Byvac Electronics, Showcase www.byvac.co.uk 126 C S Technology Ltd, Showcase www.cstech.co.uk 126 Decibit Co. Ltd, Showcase www.decibit.com 126 Designer Systems, Showcase www.designersystems.co.uk 126 EasyDAQ, Showcase www.easydag.biz 126 Easysync, Showcase www.easysync.co.uk 126 Elnec, Showcase www.elnec.com 126 EMCelettronica Sri, Showcase www.emcelettronica.com 126 Euro circuits www.eurocircuits.com 47 First Technology Transfer Ltd, Showcase . . www.ftt.co.uk 126 FlexiPanel Ltd, Showcase www.flexipanel.com 126 FLYPCB www.flypcb.com 93 Future Technology Devices, Showcase. . . . www.ftdichip.com 51, 126 Flammond Electronics www.hammondmfg.com/uk 29 ILP Electronics Ltd, Showcase www.ilpelectronics.com 126 Jaycar Electronics www.jaycarelectronics.co.uk 2 Labcenter www.labcenter.com 136 Lektronix www.lektronix.net/about/careers 71 London Electronics College, Showcase . . . www.lec.org.uk 126 Marchand Electronics Inc, Showcase www.marchandelec.com 126 MikroElektronika www.mikroe.com 3, 13 MQP Electronics, Showcase www.mgp.com 127 New Wave Concepts, Showcase www.new-wave-concepts.com 127 Newbury Electronics www.newburyelectronics.co.uk 93 Nurve Networks www.xgamestation.com 95 Paltronix www.paltronix.com 15 Peak Electronic Design www.peakelec.co.uk 135 Pico www.picotech.com 17 Quasar Electronics www.guasarelectronics.com 31 Radiometrix, Showcase www.radiometrix.com 127 Robot Electronics, Showcase www.robot-electronics.co.uk 127 Robotiq, Showcase www.robotig.co.uk 127 ScanTool, Showcase www.obd2cables.com, www.scantool.net . . . 127 Showcase 126, 127 USB Instruments, Showcase www.usb-instruments.com 127 Virtins Technology, Showcase www.virtins.com 127 Advertising space for the issue of 22 September 2008 may be reserved not later than 26 August 2008 with Huson International Media - Cambridge House - Gogmore Lane - Chertsey, Surrey KT 1 6 9AP - England - Telephone 01 932 564 999 - Fax 01932 564998 - e-mail: p.brady@husonmedia.com to whom all correspondence, copy instructions and artwork should be addressed. 7-8/2008 - elektor 131 INFO & MARKET SNEAK PREVIEW USB-CAN Adapter This USB to CAN adapter is based on a 1 6-bit MB90F532 microcontroller sporting 1 28 kBytes internal Flash memory and 4 kB RAM. The controller is accessible through open-source software that can be extended as you wish using plugins. The software is suitable for Windows as well as Linux. The USB controller is the familiar FT232 from FTDI. CAN data may be read from the adapter using Tiny-CAN View or other CAN programs like CANopen Device Monitor and CAN-Report. DCC command station Digital Command Control (DCC) is an increasingly popular open standard for model railway systems. In the September 2008 issue we describe a home-built DCC control based on the Elektor ARMee board (March & April 2005 issues) extended with a dedicated I/O board. The project is compatible with different DCC train control programs and the combination of software and hardware allows an extensive model train layout to be controlled. ATM18 project: Light as Air Commercial levitation devices that cause a small piece of metal to hover in the air have been available for many years. Many of these devices are more expensive than need be. In this article we take a slightly different approach. Instead of a light barrier, we use a Hall sensor to detect the position of the levitated object. BASCOM-AVR Course This course is the perfect starting point for anyone wishing to write code for micros from the ATMega family, as well as program these devices. The course and Bascom-AVR allow you to realise your own projects! RESERVE YOUR COPY NOW! The September 2008 issue goes on sale on Thursday 21 August 2008 (UK distribution only). UK mainland subscribers will receive the magazine between 1 6 and 1 9 August 2008. Article titles and magazine contents subject to change, please check www.elektor.com. NEWSAGENTS ORDER FORM SHOP SAVE / HOME DELIVERY Please save / deliver one copy of Elektor magazine for me each month Name: Address: Post code: Telephone: Date: Signature: Please cut out or photocopy this form, complete details and hand to your newsagent. Elektor is published on the third Thursday of each month, except in July. Distribution S.O.R. by Seymour (NS). w.elektor.com www.elektor.com www.elektor.com www.elektor.com www.elektor. Elektor S3 the web All magazine articles back to volume 2000 are available online in pdf format. The article summary and parts list (if applicable) can be instantly viewed to help you positively identify an article. Article related items are also shown, including software down- loads, circuit boards, programmed ICs and corrections and updates if applicable. Complete magazine issues may also be downloaded. In the Elektor Shop you'll find all other products sold by the publishers, like CD-ROMs, kits and books. A powerful search function allows you to search for items and references across the entire website. Also on the Elektor website: • Electronics news and Elektor announcements • Readers Forum • PCB, software and e-magazine downloads • Surveys and polls • FAQ, Author Guidelines and Contact 5 ilnktnr April ICC* L JiSfS tern .«•« if SC Pfit W Y 5 1,1 R#s~#i># 1-fRDCE ' r Zu- mJblhAa Far t'tt TY«n«BaT! CD HOai FK.A CWM-t Ifd- A! AMnI Kfi! 132 elektor - 7-8/2008 Description Price each Qty. Total 1 Order Code Design your own Embedded Linux Control Centre on a PC (253 £24.00 Computer Vision £32.00 CD-ROM FPGA Course crtlS £14.50 CD-ROM Elektor 2007 £16.90 PIC Microcontrollers £27.00 Display Computer (070827-91) £78.80 Digi Butler ( 071102 - 71 ) £29.00 SAPS-400 (070688-91) £159.00 Free Elektor Catalogue 2008 Sub-total 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. P&P Total paid Name METHOD OF PAYMENT (see reverse before ticking as appropriate) Bank transfer Cheque (UK-resident customers ONLY) □ Giro transfer □ ^!sa 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 Address + Post code Tel.: +44 20 8261 4509 Fax: +44 20 8261 4447 www.elektor.com sales@elektor.com Tel. Email • ••••••••• EL07/08 Date Signature *USA and Canada residents may (but are not obliged to) use $ prices, and send the order form to: Old Colony Sound Lab P.O. Box 876, Peterborough NH 03458-0876. Tel. (603) 924-6371, 924-6526, Fax: (603) 924-9467 Email: custserv@audioXpress.com 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 METHOD OF PAYMENT (see reverse before ticking as appropriate) □ □ □ □ Bank transfer Cheque (UK-resident customers ONLY) Giro transfer MatfBffant 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 EL07/08 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 £42.00 £49.00 Surface Mail Rest of the World £56.00 £63.00 Airmail Rest of the World £71 .00 £78.00 USA & Canada For US$-p rices please check www.elektor.com 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 perma- nent 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 student- ship signed by the head of the college, school or university faculty. A standard Student Subscription costs £33.60, a Student Subscription- Plus costs £39.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. January 2008 I mmmm JJ k atlai £SR m j Designed h Made Atlas ESR - Model ESR60 ESR and Capacitance Analyser Feature Summary Measure capacitance and ESR. Resolution down to 0.01 ohms. Analyses at industry standard of 100kHz. Capable of In-Circuit testing. Polarity free, connect any way round. Protected against highly charged capacitors. Great for short-circuit tracing too. Auto power off. £85.00 i normal price £89.00 Features our unique constant power controlled discharge function: Atlas LCR - Model LCR40 Passive Component Analyser £79.00 inc Feature Summary • Automatically identify and measure inductors, capacitors and resistors. • Automatic frequency selection: DC, 1kHz, 15kHz and 200kHz. • Complete with battery, probes and user guide. • Polarity free, connect any way round. • Range of different probes available including SMD tweezers, crocs and double jaw clutch grabbers. Probes included Atlas DCA - Model DCA55 Semiconductor Component Analyser inc % Feature Summary • Connect your components any way round! Now with premium probes! • Automatic component identification. • Automatic pinout identification, it tells you which lead is which! • Supports Bipolar transistors, darlingtons, MOSFETs, diodes, LEDs and more. • Measures transistor gain, leakage current, MOSFET gate threshold, semiconductor junction characteristics and much more. • Identifies special component features such as fly-wheel diodes on transistors or base-emitter shunt resistors. £99,00 normal price £109.00 Atlas SCR -Model SCR100 Triac and Thyristor Analyser Feature Summary Connect your Triac or Thyristor any way round. Automatic part identification and display of pinout. Categorises gate sensitivity from lOOuAto 100mA. Load test conditions regulated at 12V, 100mA, even for a dying battery. Measures gate voltage drop. Long life alkaline battery supplied. Supplied with premium probes. Ideal for TO220, T03 and even bolt styles. New improved hardware and software. Better price too! 1 J Peak Electronic Design Limited, West Road House, West Road, Buxton, Derbyshire, SKI 7 6HF, UK Tel. 01298 70012. Fax. 01298 70046. Web: www.peakelec.co.uk Email: sales@peakelec.co.uk Prices include UK VAT, please add £1 .00 towards UK postage for whole order. Contact us for overseas pricing, or order online. Offer ends 31 st August 2008. The Proteus Design Suite Celebrating BO Years of Innovation 1988 1990 2000 2005 2008 Labcenter commences trading with PC-B for DOS 1 989. First integrated autorouter added for PCB Design. Schematic Capture added to PCB Layout package 1 99 1 . forid First Schematic Capture for Windows™ . 1 99B. Topological route editing for easier PCB layout. 1 993. Proteus offers fully integrated circuit simulation. 1 994. Autorouter enhanced with Rip-Up and Retry algorithm. Gridless, shape based power plane support 1 99G. True, mixed mode SPICE simulation introduced. 1 997. Interactive simulation - ideal for educational users. 1 998. PIC microcontroller simulation technology developed. 1 999. 8051 microcontroller simulation technology developed. Worlld First Interactive MCU co-simulation (VSM] EOOI . High level language support added for MCU simulation. EOOE. ELECTRA adaptive shape based router interface added. E003. forOd First 32 bit MCU simulation support with ARM7. E004. Integration between Proteus VSIVI and MPLAB™. Redesigned GUI across the Proteus Design Suite EOOG. 3D visualisation engine integrated with ARES PCB Design. EOD7. forid First USB schematic based USB Simulation. Coming Soon: Introduction of HDL support in simulation, ODB++ manufacturing output, improved core SPICE simulation algorithms, enhanced live DRC error checking and much more. LABCEIMTER ELECTRONICS LTD A technology pioneer in the EDA Industry since 1988 Technical Support direct from the program authors Flexible packages and pricing tailored to customer requirements. !Yean v 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