www.elektor.com July/August 2009 AUS$ 19.95 - NZ$ 24.50 - SAR 129.95 £ 6.95

& microcontrollers SUMMER CIRCUITS CIRCUS more than 100 circuits, ideas & tips

Top Act ElektorWheelie

R35            1                               

$) &#  %"              !     #      

      !  " #       "    #             

$!  %"   #            !      #    

   &#       $ !         '     %   !  #     ()  #       -        #            % !    

$! *    +   .%     !      %   &  +,)$ -.          !         (           # !         + #   "            $       /

, /0%"             

    ,                   

  !        ! !    " !    # !   !  "    $  !     %!

        &'"        ( %  

)     $*       !   !     #   *    

+    !$      ,$  ! ! $         !  # !     &  +,) $ (   .  

0907_elektor_adv_UK.indd 2 05-06-2009 13:24:24 DEVELOPMENT TOOLS mikroElektronika DEVELOPMENT TOOLS | COMPILERS | BOOKS Now you need a... OK. DEVELOPMENT TOOL EasyPIC5 &7=  ? 79443687? .? .?  .? .?  . &2)? .- '!%  1.(63(3286300*67? .8? (31*7? ;.8-? 8-*  ? "-*? $!"(& &6);&6*? 2@(.6(9.8? *'9,,*6? *2&'0*7? :*6=? *++.(.*28? 78*4? '=? 78*4 )*'9,,.2,?<&140*7?.2? ?  ?)# &2)? )) $#, 0&2,9&,*?&6*?463:.)*)?;.8-?8-*?'3&6) &7=  ?(31*7?;.8-?8-*?+3003;.2,?46.28*)?)3(91*28&8.32?&7=  ?&29&0? 0&7- ?&29&0 &2)?1./63?&29&0

      

  79443687?8-*?0&8*78    .7?&2?&):&2(*)   .7? &? 7=78*1? +36  ?&2)?@4.2? ?1.(63(32@ 7=78*1? +36? .278&00.2,? .283 .278&00.2,?.283?)*:.(*7?&7?;*00 86300*67? .8? .7? )*0.:*6*)? ;.8- )*:.(*7? &2)? +36? )*:*034.2, &7? +36? )*:*034.2,? .2)9786.&0   ? "-*6*? &6* .2)9786.&0?&2)?-31*?36?3++.(* (328630?*&896*7??6*0&=7? #!? ?32@'3&6)?463,6&1@ (328630?*&896*7? ?6*0&=7 3483(3940*)? .24987? !   1*6?32@'3&6)?1./63?&2) ? 3483(3940*)? .24987 ! ? ! ? &2)? #!?  32@'3&6)?"39(- &2*0? !  ? ! ? !*6.&0 32@'3&6)? 463,6&11*6? &2) (3286300*6 8-*62*8?*8( 1./63?32@'3&6)

 #) -+!* -     $!"(& $ ?79443687? ??&2)    .7? &? 7=78*1  #) - +!* - $!"(& ?4.2?  <<<

)  ),)  -. )  79443687?  "-*?7=78*1?79443687? ?  "-*? 7=78*1? 79443687?  &2)? @'!% )7  ?1.(63@ &2)?.'!% )7 ?1.(63(32@  &2)? - '!%-   (3286300*67? .8? (31*7? ;.8- 86300*67? .8? .7? )*0.:*6*)? ;.8-  ? )  1.(63@ )7   ?"-*6*?&6* )7    ? "-*6*? &6* (3286300*67? .8? (31*7? ;.8- #!? ?32@'3&6)?463,6&1@ #!? ?32@'3&6)?463,6&1@   ? "-*6* 1*6?32@'3&6)?1./63?&2) 1*6?32@'3&6)?1./63?&2) &6*? #!? ? 463,6&11*6 32@'3&6)?"39(- &2*0? 32@'3&6)?"39(- &2*0? &2)? "39(- &2*0? (3286300*6 (3286300*6 (3286300*6 32@'3&6)

),&    ),  "-*? 7=78*1? 79443687? ?  "-*? 7=78*1? 79443687? . "-*? 7=78*1? 79443687? ?   &2)? 4.2? !3A?1.(63@ '!% &2)? .'!% $ ? &2)? 4.2?1.(63(32@ (3286300*67? .8? (31*7? ;.8- 1.(63(3286300*67?.8?.7?)*0.:@ 86300*67? 8? .7? )*0.:*6*)? ;.8- %  ? "-*6*? &6* *6*)? ;.8-? "  " ?"-*6*?&6*?9086& 9086&?+&78?#!? ?463,6&1@ ;36/.2,? &8? >? "-*6* +&78? #!? ? 463,6&11*6 1*6? &2)? ? "39(- &2*0? (32@ &6*?9086&?+&78?#!? ?463@ &2)? ? "39(- &2*0? (3286300*6 86300*6?32@'3&6) ,6&11*6?&2)??"39(- &2*0 32@'3&6) (3286300*6?32@'3&6)

),  ),  $(* "-*? 7=78*1? .7? (314&8.'0* "-*?7=78*1?79443687? &2) $(* .7? & ;.8-? ? ? ?  &2)?   '!%)  1.(63(32@ )*:*0341*28? 8330? 8-&8? ;.00 '!% #7? .8? (31*7? ;.8- 86300*67?.8?(31*7?;.8-? -.0.47 -*04? .2? (0*&6? 92)*678&2).2, "! ?"-*6*?.7?&?+&78   ? "-*6*? &6*? 9086& 3+? !? ?  !? 8*(-2303@ #!? ? 463,6&11*6? 32@ +&78? #!? ? 463,6&11*6 ,.*7?28*22&?(&2?'*?40&(*) '3&6)? 073? 8-*6*? &6* &2)?"39(- &2*0?(3286300*6? 32@'3&6)? +36? '*88*6? 7.,2&0  ?&2)?  ? 32@'3&6) 59&0.8=?!=78*1?79443687? 73(/*87?32@'3&6) ).++*6*28?!?13)90*7

http://www.mikroe.com/ S O F T W A R E A N D H A R D W A R E S O L U T I O N S F O R E M B E D D E D W O R L D electronics & microcontrollers

Summer Circuits — made for you, by you Plus Colophon 6 As the days shorten ElektorWheelie 66 and the first autumn winds howl and buf- Hexamurai Puzzle 124 fet the castle walls, Elektor SHOP 128 the initial plans are Coming Attractions 132 drawn up. Seasons pass, autumn and winter make way for spring, and when everyone looks like they could do with SUMMER CIRCUITS 2009 (Colour of title indicates category, bold type = PCB design included) a bit more sunshine on as well as in their faces, it’s finished and ready for print- Audio, Video & Photography ing: Elektor’s Sum- mer Circuits edition! Audio Source Enhancer 94 To mark the real Automatic TV Lighting Switch 52 start of ‘SC’, howev- DMX Transmitter 108 er, we must go back Guitar Amplifier PSU 105 even further in time Guitar Pick-up Tone Extender 60 — to the beginning of the summer of 2008, when many of you Improved Hybrid Headphone Amplifier 114 were thinking up exciting new ideas for the edition and eventu- Load Protection for Audio Amplifiers 72 ally got round to sending them by email — and some even by snail mail. Sensitive Audio Power Meter 97 Summer Circuits has been a collective effort since it was first SRPP Headphone Amplifier 15 produced, now over 30 years ago. Every year we receive over Stereo Widening 38 500 entries and ideas for publication! The projects come from all S-video Converter 41 over the world, and we happily evaluate each item because the Two TV Sets on a Single Receiver 100 effort confirms the creativity and ingenuity of you, our readers. Vocal Adaptor for Bass Guitar Amp 59 All circuits in this edition have been tried and tested by Elektor Wireless S/PDIF Connection 23 Labs so repeatability should not be an issue if you read and work carefully.

ElektorWheelie Computers, Software & Internet While ElektorWheelie was mostly ‘under cover’ in the June 2009 Cheap Serial Port for the Mac 11 edition, this month we are unveiling the electronics starting Control Interface via PC Keyboard 46 on page 66 . Our DIY ‘self-balancing two-wheeler’ will take you Fan Speed Controller 49 further, both in distance and knowledge. In distance, because Network RS232 81 it is designed to take you from A to B in spectacular fashion. In One Wire RS-232 Half Duplex 24 knowledge, because ElektorWheelie is an ‘Open Development’. PC Power Saver 122 Open for students and companies to redesign or modify, to make it even faster, or to make it go farther on a battery charge. Powering a Second Hard Drive 77 Who knows, we might even organise an ElektorWheelie Com- Pseudo Fan 17 petition. Remote Control for Network Devices 120 Have fun exploring this electrifying collection of more than 100 TurboGrafx-16 (PC Engine) RGB Amplifier 48 circuits, tips and ideas. None of our competitors has ever man- USB Switch 64 aged to publish anything remotely resembling our Summer Cir- VGA Background Lighting 22 cuits edition. And don’t forget, after a long day spent reading, soldering or measuring, comes well deserved recreation.

On behalf of the Elektor Team, Hobby, Games & Modelling Wisse Hettinga International Coordinating Editor Acoustic Distress Beacon 106 Annoy-a-Tron 34 Volume 35 July & August 2009 CONTENTS no. 391/392

Braitenberg Robot 116 LEDify It! 32 / Combo 26 Lithium Charger using BQ24103 61 Full-colour Night-flight Illumination 84 Single Lithium Cell Charger 110 Going for Gold 102 Single-cell Power Supply 82 Impact Clock 74 SSR 2.0 42 Lighting Up Model Aircraft 30 Lipo Monitor 21 Low-drop Series Regulator using a TL431 22 RF (radio) Servo Driver 91 0-18 MHz Receiver 12 Speed Control 43 FM Audio Transmitter 90 Pre-emphasis for FM Transmitter 96 Home & Garden 12 V AC Dimmer 62 Test & Measurement Automatic Bicycle Light 121 Digital Sweep and Sinewave Generator 104 Automatic Curtain Opener 75 Frequency and Time Reference with ATtiny2313 56 Bathroom Fan Controller 97 Measuring Milliohms with a Multimeter 106 Chill Out Loud 92 Preamplifier for RF Sweep Generator 10 Daylight Switch 45 Quartz Crystal Tester 112 Dimmable Aquarium Light Servo Scales 28 with Simulated Sunrise and Sunset 93 Simple Temperature Measurement and Control 62 Economy Timer 83 SMD Transistor Tester 39 Long Duration Timer using ATtiny2313 111 Smoggy 85 Luxeon Logic 10 Tester for Inductive Sensors 101 Phone Ring Repeater 53 Power On Indicator 99 Power-up/down Sequencer 50 Miscellaneous Electronics & Pulse Clock driver with DCF Synchronisation 54 Design Ideas Remote Washing Machine Alert 31 Backlight Delay 98 Snail Mail Detector 107 Cut-rate Motorbike Alarm 103 Solar-driven Moisture Detector 86 Floating Message 51 Switching Delay 19 Four-component Missing Pulse Detector 44 Two-button Digital Lock 78 Freezer Trick 32 Wireless Baby Monitor 80 Frequency Divider with 50% Duty Cycle 58 Hassle-free Placement of SMD Components 44 Microcontrollers LED Bicycle Lights 30 Micropower Crystal Oscillator 52 Driver-Free USB 29 Momentary Action with a Wireless Switch 27 Easy LEGO Robotics Set Up 16 PR4401 1-Watt LED driver 47 An E-blocks IR RC5 Decoder 118 Programmable Nokia RTTL Player 18 I2C Display 88 Simple Wire Link Bender 82 Port Expander 14 Simple Wireless and Wired Emergency Stop System 35 Six-digit Display with SPI Port 20 Slow Glow 14 USB Radio Terminal 101 Start-up Aid for PCs 13 Stress-o-Meter 76 TL431 Multivibrator 40 Power Supplies, Batteries & Chargers Desulphater for Car Batteries 35 Doubling Up with the PR4401/02 95 Lead-Acid Battery Protector 75 elektor electronics worldwide

elektor international media Elektor International Media provides a multimedia and interactive platform for everyone interested in electronics. From professionals passionate about their work to enthusiasts with professional ambitions. From beginner to diehard, from student to lecturer. Information, education, inspiration and entertainment. Analogue and digital; practical and theoretical; software and hardware.

English German Dutch French Chinese

Portugal Italian Spanish Swedish Finnish

Volume 35, Number 391/392, July/August 2009 ISSN 1757-0875 Elektor is also published in French, Spanish, American English, German and Editorial secretariat: Hedwig Hennekens ([email protected]) Dutch. Together with franchised editions the magazine is on circulation in more Elektor aims at inspiring people to master electronics at any personal level by than 50 countries. Graphic design / DTP: Giel Dols, Mart Schroijen presenting construction projects and spotting developments in electronics and information technology. International Editor: Managing Director / Publisher: Paul Snakkers Wisse Hettinga ([email protected]) Carlo van Nistelrooy Publishers: Elektor International Media, Regus Brentford, Marketing: Editor: Jan Buiting ([email protected]) 1000 Great West Road, Brentford TW8 9HH, England. Tel. (+44) 208 261 4509, fax: (+44) 208 261 4447 www.elektor.com International editorial staff: Harry Baggen, Thijs Beckers, Eduardo Corral, Ernst Krempelsauer, Jens Nickel, Clemens Valens. Subscriptions: Elektor International Media, The magazine is available from newsagents, bookshops and electronics retail Regus Brentford, 1000 Great West Road, Brentford TW8 9HH, England. outlets, or on subscription. Design staff: Antoine Authier (Head), Ton Giesberts, Tel. (+44) 208 261 4509, fax: (+44) 208 261 4447 Elektor is published 11 times a year with a double issue for July & August. Luc Lemmens, Daniel Rodrigues, Jan Visser, Christian Vossen Internet: www.elektor.com/subs

 elektor - 7-8/2009 Elektor PCB Service NEW! Your professional PCBs and The advantages at a glance Elektor PCB Service is a new service from Elektor. You • The PCBs are professional quality. • No fi lm charges or start-up charges. can have your designs converted into a professional- • There is no minimum order quantity or charge quality PCBs via the www.elektorpcbservice.com for this service. website. Elektor PCB Service is intended for • Available to private and commercial customers. • We’ll fi rst check if your project is producible. builders and designers who want to have their PCBs We’ll let you know within 4 hours! made to professional standards, and for users who • In order to supply two PCBs, we make three. If the third board is also good, you receive it want customised versions of Elektor PCBs. If you need as well – free of charge. a couple of ‘protos’ with fast turnaround or a batch of • You can use our online payment module to pay easily, quickly and securely with Visa or Master- 5 to 50 units, Card. we can meet

your needs at Procedure:

a favourable 1. Create your account 2. Place your order price. 3. Your project is checked 4. Payment 5. Your order is shipped

Now available for everybody at www.elektorpcbservice.com

Email: [email protected] Email: [email protected] publication is stored in a retrieval system of any nature. Patent protection may ex- Rates and terms are given on the Subscription Order Form. Internet: www.husonmedia.com ist in respect of circuits, devices, components etc. described in this magazine. The Advertising rates and terms available on request. Publisher does not accept responsibility for failing to identify such patent(s) or other Head Office: Elektor International Media b.v. protection. The submission of designs or articles implies permission to the Publisher P.O. Box 11 NL-6114-ZG Susteren The Netherlands to alter the text and design, and to use the contents in other Elektor International Telephone: (+31) 46 4389444, Fax: (+31) 46 4370161 Copyright Notice Media publications and activities. The Publisher cannot guarantee to return any mate- The circuits described in this magazine are for domestic use only. All drawings, photo- rial submitted to them. Distribution: Seymour, 2 East Poultry Street, London EC1A, England graphs, layouts, programmed integrated circuits, disks, CD-ROMs, software carriers and article texts published in our books and magazines (other than Telephone:+44 207 429 4073 Disclaimer third-party advertisements) are copyright Elektor International Media b.v. and may Prices and descriptions of publication-related items subject to change. Huson International Media, Cambridge House, UK Advertising: not be reproduced or transmitted in any form or by any means, including photocopy- Errors and omissions excluded. Gogmore Lane, Chertsey, Surrey KT16 9AP, England. ing, scanning an recording, in whole or in part without prior written permission from Telephone: +44 1932 564999, Fax: +44 1932 564998 the Publisher. Such written permission must also be obtained before any part of this © Elektor International Media b.v. 2009 Printed in the Netherlands

7-8/2009 - elektor 

ELEK UK09078 PCB Services s7.indSec1:7 Sec1:7 03-06-2009 22:25:29 8 elektor - 7-8/2009

0907_elektor_adv_UK.indd 8 05-06-2009 13:24:44 Your source for MikroElektronika Development Tools and Accessories in the United Kingdom

We can supply all MikroElektronika development tools including compilers, development boards, add-on boards, programmers and starter packs. We aim to keep all products in stock for same-day dispatch and can offer next-day delivery within the UK as well as insured delivery by airmail post or courier worldwide.

EasyPIC5 PIC Development Board - £89 BIGPIC5 PIC Development Board - £119 LV18FJ PIC Development Board - £89

Get off to the best start with An advanced development Designed for low-voltage PIC microcontrollers with board for 64 and 80-pin PIC PICs in the LV18FxxJxx the EasyPIC5. Supports 8, microcontrollers in the 18F family with on-chip Ethernet 14, 18, 20, 28 and 40-pin family, the BIGPIC5 provides connectivity, the LV18FJ PIC10F/12F/16F/18F on-board USB programmer, incorporates USB program- devices and features built- in-circuit debugger plus mer, in-circuit debugger and in USB programmer, in- extensive I/O devices and useful I/O devices and circuit debugger and useful communications interfaces. supports 64, 80 and 100-pin I/O devices. LCD displays LCD displays and SD card- MCUs. LCD displays and SD sold separately. sold separately. card sold separately.

EasyPIC5 Starter Packs also available comprising BIGPIC5 Starter Packs also available comprising BIGPIC5, LV18FJ Starter Packs also available comprising LV18FJ, EasyPIC5, character and graphic LCDs, touch panel, tem- character and graphic LCDs, touch panel, temperature character and graphic LCDs, touch panel, temperature sensor perature sensor and either BASIC, C or Pascal compiler. sensor and either BASIC, C or Pascal compiler. and either BASIC, C or Pascal compiler. EasydsPIC4A dsPIC Development Board - £89 dsPICPRO4 dsPIC Development Board - £149 LV24-33A PIC/dsPIC Development Board - £99

A versatile development The new dsPICPRO4 is an Easily develop 16-bit PIC24 board for 18, 28 and 40-pin advanced development and dsPIC33 applications digital signal controllers in board for 64 and 80-pin with the LV24-33A. Features the dsPIC30F family, the dsPIC30F devices with built- USB programmer and in- EasydsPIC4A provides in USB programmer, in-circuit circuit debugger plus useful built-in USB programmer, debugger and extensive I/O I/O devices and supports 64, in-circuit debugger and features and communications 80 and 100-pin low-voltage useful I/O devices. LCD interfaces. LCD displays and devices. LCD displays and displays sold separately. SD card sold separately. SD card sold separately.

EasydsPIC4A Starter Packs also available comprising dsPICPRO4 Starter Packs also available comprising LV24-33A Starter Packs also available comprising LV24-33A, EasydsPIC4A, character and graphic LCDs, touch panel, dsPICPRO4, character and graphic LCDs, touch panel, character and graphic LCDs, touch panel, temperature sensor temperature sensor and either BASIC, C or Pascal compiler. temperature sensor and either BASIC, C or Pascal compiler. and either BASIC, C or Pascal compiler.

EasyAVR5A AVR Development Board - £89 BIGAVR2 AVR Development Board - £89 Easy8051B 8051 Development Board - £89

Get off to the best start with Work with 64, 80 and 100-pin Get off to the best start with AVR microcontrollers with AVR microcontrollers with the Atmel¶s Flash 8051 micro- the EasyAVR5A. Supports BIGAVR2 development controllers with the 8, 14, 20, 28 and 40-pin board. Includes built-in USB Easy8051B. Supports 14, AVRs and features on- programmer and range of on- 16, 28, 32, 40 and 44-pin board USB programmer board I/O devices. LCD 8051s and features on- and useful I/O devices. displays and SD card sold board USB programmer and LCD displays and SD card separately. useful I/O devices. LCD sold separately. displays sold separately.

EasyAVR5A Starter Packs also available comprising BIGAVR2 Starter Packs also available comprising BIGAVR2, Easy8051B Starter Packs also available comprising EasyAVR5A, character and graphic LCDs, touch panel, character and graphic LCDs, touch panel and either BASIC, Easy8051B, character and graphic LCDs, touch panel, tem- temperature sensor and either BASIC, C or Pascal compiler. C or Pascal compiler. perature sensor and either BASIC, C or Pascal compiler.

EasyARM ARM Development Board - £109 EasyPSoC4 PSoC Development Board - £89 UNI-DS3 Universal Development Board - £99

Easily develop for NXP¶s Learn about and develop for With the UNI-DS3 you can 32-bit ARM microcontrollers Cypress¶s exciting PSoC easily work with a number of with the EasyARM. mixed-signal array devices popular microcontrollers from Includes on-board USB with the EasyPSoC4. different manufacturers simply programmer and useful I/O Features built-in USB by buying optional plug-on devices and supports 64 programmer and advanced MCU cards. Devices sup- and 144-pin devices. LCD I/O devices and supports 8, ported include PIC, dsPIC, displays and SD card sold 20, 28 and 48-pin PSoCs. AVR, 8051, ARM and PSoC. separately. LCD displays and SD card MCU cards, LCD displays and sold separately. SD card sold separately.

Compilers Add-on Boards Starter Packs

mikroBASIC, mikroC and We stock an extensive Save money by buying one mikroPascal compilers now range of add-on boards that of our Starter Packs. Each available in versions for plug straight onto Mikro- includes a development PIC, dsPIC, AVR and 8051 Elektronika¶s development board with options such as microcontrollers. All feature boards including A/D, D/A, LCD displays, touch panel, user-friendly development RS-485, CAN, LIN, temperature sensor and environments, built-in Ethernet, IrDA, RTC, come with a full version of library routines and easy EEPROM, Compact Flash, either mikroBASIC, mikroC integration with MikroElek- SD/MMC, MP3, Bluetooth, or mikroPascal. Available for tronika¶s programmers and ZigBee, RFid, stepper motor PIC, dsPIC, PIC24/dsPIC33, debuggers. driver and many more. AVR and 8051.

NEW PRO versions just released for PIC and AVR - NEW range of GSM/GPRS and GPS add-on boards and NEW PIC and AVR Starter Packs now come with PRO existing mikroBASIC, mikroC and mikroPascal customers accessories just released. Contact us for details. versions of mikroBASIC, mikroC or mikroPascal. can upgrade free-of-charge! Contact us for details.

Please see our website at www.paltronix.com for further details of these and other products We also stock components, control boards, development tools, educational products, prototyping aids and test equipment

Paltronix Limited, Unit 3 Dolphin Lane, 35 High Street, Southampton, SO14 2DF | Tel: 0845 226 9451 | Fax: 0845 226 9452 | Email: [email protected] Secure on-line ordering. Major credit and debit cards accepted. Prices exclude delivery and VAT and are subject to change.

0907_elektor_adv_UK.indd 9 05-06-2009 13:24:54 Luxeon Logic

type, since the maximum rated current of the Brightness control for LED 2N2222 is 600 mA. torches With regard to the quite simple circuit, we can mention that it lacks a crystal because Oliver Micic (Germany) the clock is provided by the internal 8-MHz oscillator of the ATtiny microcontroller. The The small super-bright Luxeon LEDs from Philips firmware [1] is written in BASCOM and works are suitable for many applications, including with PWM control using the internal clock small but handy (that is, bright) pocket torches. divider (1:8). If any changes are made, this However, you don’t always need maximum should be maintained to ensure that the brightness, so it would be nice to have a sim- Features firmware runs at 1 MHz, which reduces the ple brightness control. After giving this ques- • Three selectable brightness levels current consumption. tion a bit of thought, the author designed the • One-button operation A suitable small PCB is available via the Ele- circuit described here. An ATtiny microcon- • Microcontroller control circuit ktor website, and as usual the layout can be troller enables convenient one-button opera- • Current consumption in sleep mode only 1.2 µA downloaded free of charge [1]. The author tion. Three brightness levels can be selected by [2] designed a round PCB that fits nicely pressing the button one to three times in a pocket torch with three AA in succession, and pressing it yet again batteries. switches the LED off. In this state the R1 ATtiny enters sleep mode with a cur- (081159-I) C2 C1 rent consumption of around 1.2 µA. 3R3 Internet Links 22u 100n The current consumption rises to [1] www.elektor.com/081159 LED1 around 12 mA in normal operation, 8 [2] www.dg7xo.de plus the current through the LEDs. At 1 3 PB5(RESET) PB4(XTAL2) 4.5 V, the currents measured by the T1 T2 BT1 IC1 R2 author at the three brightness settings 2 6 Downloads PB3(XTAL1) PB1(MISO) 390R 4V5 081159-1: PCB design (.pdf), from [1] were 50 mA, 97 mA, and 244 mA. ATTiny25 5 7 081159-11: Source code and hex files, from [1] The LED current can be set to other 2N2222 PB0(MOSI) PB2(SCK) 2N2222 levels by adjusting the value of R1 S1 4 in the circuit, although the maxi- Product mum operating current of the LED ON 081159-41: ATtiny25 microcontroller, ready should not exceed 350 mA. If you programmed want to use more than one LED, you 081159 - 11 will have to use a different transistor

COMPONENT LIST Resistors Semiconductors R1 = 3Ω3 (1206) T1,T2 = 2N2222 (SOT-23) R2 = 390Ω (1206) IC1 = ATtiny25-20SU (SOT-8) LED1 = Luxeon LED, 1W (SMD), white Capacitors C1 = 100nF (1206) Miscellaneous C2 = 22µF 10V (SMD) Pushbutton PCB # 081159-1 [1]

Preamplifier for RF Sweep Generator

Gert Baars (The Netherlands) sitivity of 1 µV. So, for a good receiver some required, the preamplifier consists of two more gain is required. A wideband amplifier, amplifying elements. The RF sweep frequency generator (‘wobbu- however, generates a lot of additional noise lator’) published in the October 2008 issue of as well and as a consequence will not result The input amplifier is designed around a Elektor has a receiver option that allows the in much of an improvement. dual-gate MOSFET, type BF982. This compo- instrument to be used as a direct-conversion nent produces relatively little noise but pro- receiver. This receiver does however have As an experiment, the author developed a vides a lot of gain. The output stage uses a a noise floor of only –80 dBm, which really selective receiver with a bandwidth of about BFR91A for some additional gain. should have been –-107 dBm to obtain a sen- 4 MHz. Because a gain of at least 35 dB is

10 elektor - 7-8/2009 Preamplifiers where both the gate of clicking the scan stop button and and the drain are tuned often strug- then clicking on the signal in the dis- gle with feedback via their inter- +9V play window using the right mouse nal capacitance. Here, the drain cir- C5 button. After this, the receiver cuit has a relatively low impedance, * switches directly to this frequency which prevents this from happening. 100µ 16V and you can listen to the signal. You R1 In the prototype that was tested, the C3 L2 C6 K2 can subsequently resume the scan- Ω * input and output are located at right ning so that you can continue to 470 100n 100n angles with respect to each other * 50Ω look for other signals. to prevent inductive coupling (see photo). Despite the high gain, the T2 For narrowband FM detection you amplifier was perfectly stable even need to select the FMN button in without any shielding. T1 the window for the receiver and this BFR91-A The two air-cored coils in the circuit then provides the required offset for both consist of 4 turns and have an L1 BF982 the edge detection at 25 kHz band- internal diameter of 6 mm, made K1 width. This value is adjustable via the * C1 R2 R3 C7 from 1-mm diameter silvered copper C2 C4 ‘setting’ menu (default is 12,500 Hz) Ω

50Ω 1k2 wire and with a tap after 1 turn. 220 and can be changed experimentally The amplifier is mainly intended for 22p 100n 100n 22p for best results. the 144 MHz amateur band, but with 090134 - 11 other coils can also be used for the To power the circuit you can use a 9- FM broadcast band, for example. FM V battery. It is also possible to power detection is achieved by tuning near the amplifier directly from the RF the edge of the IF filter. At an offset of 15 kHz outdoor antenna will give good results. Add- sweep generator, if output capacitor C6 is this is only a few dB lower than at the cen- ing this wobbulator/receiver option results in replaced with a link; in the ‘options’ menu tre of the pass-band, so that damping is not a nice monitor receiver. By setting the scan you will then have to select the option ‘use noticeable. The measured sensitivity in the frequencies of the spectrum analyser to 144 probe’. 2 m band was about 1 µV (6 dB). and 146 MHz (or 148 MHz where applicable), (090134-I) A good antenna always contributes to the any signal within this range is directly visible. reception, of course. A wideband (scanner) When a signal is detected it is merely a case

Cheap Serial Port for the Mac

Gerrit Polder (The Netherlands) rather than 5 V. The ±12 volt swing be 3 volts for most modern telephones; for originally specified for RS232 isn’t older models it is usually 5 volts. Many people would agree that the Apple found or indeed useful anymore. For 3. You will usually get some software for Win- Macintosh is a fantastic computer. Even so, that reason a checklist was created to dows with the cable — if you can use it you’re it’s been less popular for a good while help you add a 3 or 5 volt RS232 port to done. Congratulations! amongst electronics engineers and your Macintosh (or other computer) at 4. Mac users have to do a bit more work enthusiasts. Of course there was a ve r y lit tl e cost. though. Connect the cable to the compu- good reason for this: Apple was one of ter and have a look in the System Profiler the first companies that left out the (Applications/Utilities) under Hardware/ ever so useful RS232 port. And not USB to see what type of interface it is. only on their notebooks (sorry, Mac- As an example, you could see the Books), they also left them out from following: their desktop computers. It’s been a good 10 years since Apple started usb data cable: delivering those beautiful, futuristic Version: 1.00 iMacs in a range of colours, but unfor- Bus Power (mA): 500 tunately without an RS232 port. Speed: Up to 12 Mb/sec However, times change and Apple has Manufacturer: Silicon Labs steadily increased its market share, also Product ID: 0x10c5 amongst electronics enthusiasts. And as far Serial Number: 0001 as ‘the other brands’ are concerned, there is Vendor ID: 0x10ab virtually no laptop made nowadays that does 1. Buy a GSM USB cable from a shop or via come with an RS232 port. the Internet from Hong Kong; it shouldn’t 5. You can see from this that you have a ‘Sili- The RS232 port is still considered very use- cost a lot. con Labs’ interface. From the website of this ful by many electronics-minded people 2. Look at [2] for the pinout of the plug. It will company [1] you download the CP210x USB though. These days microcontroller circuits tell you what connections are used by RS232 to UART Bridge Virtual COM Port (VCP) driver that employ ersatz-RS232 often work at 3 V and what the operating voltage is. This will for Mac OS X.

7-8/2009 - elektor 11 6. The driver is installed by double-clicking on 8. Open a terminal session and type: tty.SLAB_USBtoUART the SLAB_USBtoUART Installer. $ sudo kextload /System/Library/Extensions/ as proof that the new COM port is available. 7. Unfortunately, the standard Product and SLAB_USBtoUART.kext (090092-I) Vendor ID of this driver do not correspond $ touch /System/Library/Extensions with those of the GSM cable, but that is easily $ ls -al /dev/tty.SLAB* rectified. The Product and Vendor ID that dis- Internet Links [1] www.silabs.com covered in step 4 can be included in the file: If all went well you should see something like [2] http://pinouts.ru /System/Library/Extensions/SLAB_USBtoUART. this: kext/Contents/Info.plist. All that’s left to do is to type a few instructions to load the driver. crw-rw-rw- 1 root wheel 9, 8 Oct 18 08:32 /dev/

0–18 MHz Receiver

+5V IC4 78L05 +9V

R1 Ω 330 ANT1 C18

L1 C3 C12 C13 220µ

10µH 100n 4µ7 100n

C17

7 6 8 F1 4µ7 45M15AU EN C1 R2 1 1 4 1 4 3 6 IN A OUT A –IN IC2 OUT 10k 8 C20 IC1 5 1n L3 C16 IC3 2 NE612 5 8 AD8307 5 2 IN B OUT B +IN INT 47µ 4 LS1 OSC 680nH 10n 7 OFS C14 C15 C19 3 7 6 P1 C2 C6 C8 C9 C10 C11 3 2 LM386N-3 3n9 3n3 68n 1n C5 10p 150p 15p 22p 1n 50k

10p +5V 090082 - 11

P3

5k BAND P2 D1 BB204 R3 25k FINE 100k T1

L2 C7 BC547B C4 R4 R5 Ω

15p 4k7 22p 820

270nH

Gert Baars (The Netherlands) In the RF bands up to 30 MHz, the majority of quency (IF). This makes the image frequency The receiver shown in the schematic has stations can actually be found below 18 MHz. large, so that its suppression is very easy, some characteristics not unlike those of the It is possible to make a receiver for this with a which contributes to the simplicity of the cir- so-called ‘world band receivers’ from the old relatively simple circuit. The simplicity of the cuit. This also means that the ratio between days, which could usually receive LW, MW circuit is therefore its primary strength, but the highest and lowest required VFO frequen- and SW up to about 20 MHz in AM and which that does not mean that the results are poor. cies remains small as well. were crammed with transistors. Because The receiver is a single superheterodyne with of the ‘low-budget’ character of this circuit the salient characteristic that the receiving The circuit starts with a NE612 mixer IC (IC1), it forgoes a tuning scale/indicator and the range from DC to 18 MHz can be tuned in a which also contains an oscillator. The oscilla- design has been kept as simple as possible. singe range. tor is a Colpitts type and is tuned here using Nevertheless, the name ‘Mini World Receiver’ a dual-varicap diode (D1). The Mixer is fol- would not be inappropriate for this design. The circuit uses a high intermediate fre- lowed by a crystal filter which has a centre

12 elektor - 7-8/2009 frequency of 45 MHz and a bandwidth of noise suppression. ered directly from the battery. The current 15 kHz. This bandwidth is a little large for consumption of the circuit without a signal AM, but the advantage of the filter, type The AF amplifier follows this filter and is is less than 20 mA and with good audible 45M15AU, that is used here, is that it is priced configured for a gain of approximately 200. audio about 50 mA. The circuit continues to quite favourably. This is enough to drive a speaker so that it work well with power supply voltages down exceeds the ambient noise. If necessary the to about 6.5 volts. This means that a 9 V bat- With an IF of 45 MHz and a receiving range volume can be adjusted with P1. tery will last extra long. from DC to 18 MHz, the VCO frequency there- To tune such a large frequency range it is cer- fore has to be IF+F0 = 45 to 63 MHz. The image tainnly preferable to use a multiturn potenti- Calibration of the circuit is simple. The tun- frequency is now 90 MHz higher than the ometer. Because of the low-budget character ing potentiometers have to be set to the desired receiver frequency, at 90–108 MHz. A of this design, a circuit around two potenti- lowest frequency first. Use trimmer capaci- single coil in series with the antenna provides ometers is used instead. A transistor config- tor C7 to find a point where AC power line sufficient suppression at these frequencies. It ured as a current source provides a constant hum becomes audible. Here the receiver really cannot be any simpler. voltage of about 1 volt across the ‘Fine’ tun- frequency is at 0 Hz. Optionally you can also After the IF filter follows an LC combination ing potentiometer (P2). The ‘Band’ poten- tune to a strong longwave station as the low- which suppresses the fundamental frequency tiometer (P3) has a negligible effect on the est receiver frequency. of the IF filter (45M15AU is a 3rd overtone voltage across the ‘Fine’ potentiometer, but type) and increases the damping. A logarith- it does allow the voltage at both extremes As a minimum a simple telescoping antenna mic detector was chosen for the IF amplifier. to be changed. In this way the ‘Band’ control with a length of 50 cm is required, which The advantage is mainly the small number can be used to select a window within which makes the receiver eminently suitable for of external components that are required for the ‘Fine’ potentiometer is used for the actual portable use. With such an antenna dozens this. The detector is an AD8307 (IC2) and has tuning. The ratio is about 1 to 5. If you pre- of stations are audible, particularly during a sensitivity of about –75 dBm, which works fer a ratio of, say, 1 to 10, you can increase the evening when propagation becomes out to about 40 μV. Together with the gain the emitter resistor R4 from 4.7 kohms to favourable. A length of wire several meters of the mixer (around 17 dB) the sensitivity of 10 kohms. long does however increase the signal the receiver ends up at about 5 μV. Because Because the VFO has to be stable, only the strength, particularly during the day, but it of the logarithmic characters of the detector, power supply to the mixer/VFO IC has been is not strictly necessary. an AGC (automatic gain control) is not neces- regulated. The power supply voltage to the (090082-I) sary. A simple RC filter subsequently provides AD8307 has been reduced with a resistor to some additional fundamental frequency and a safe value, while the AF amplifier is pow-

Start-up Aid for PCs

A VSTANDBY

A R2 R3 R 33k 100k B 8 8 4 E R 2 5 6 RSI RST THR IC1 B C IC2 D T1 C3 R4 7 6 2 3 C SEN RST TR OUT 100Ω TL7705 1n NE555 3 1 7 BC547 CT CRF DIS CV D 4 1 5 R1 C1 C2 C2 C4 C 4k7 68µ 2µ2 10n E 100n 090128- 12

090128 - 11

Egbert Jan van den Bussche (The Netherlands) standby state, but no matching BIOS set- after a power outage possible. After build- Since one of the servers owned by the author ting that allows it to start up unattended. ing in the accompanying circuit, the PC starts would not start up by itself after a power fail- Although a +5 V standby supply voltage is after about a second. Incidentally, the push- ure this little circuit was designed to perform available, you always have to push a but- button still functions as before. that task. ton for a short time to start the computer up again. Modern PCs often do have the option The circuit is built around two golden oldies: The older PC that concerned did have a in the BIOS which makes an automatic start a NE555 as single-shot pulse generator and a

7-8/2009 - elektor 13 TL7705 reset generator. The reset generator of the 1 second pulse. The NE555 reacts to Other applications that require a short dura- will generate a pulse of about 1 second after this by generating a nice pulse of 1.1RC. Dur- tion contact after the power supply returns the supply voltage appears. The RC circuit ing that time the output transistor bridges are of course also possible. between the TL7705 and the NE555 provides the above mentioned pushbutton switch of (090128-I) a small trigger pulse during the falling edge the PC, so it will start obediently.

Port Expander

Steffen Graf (Germany) rate of 26 MHz.

VCC The project page of this article [2] It can sometimes happen that even includes full listings (in the form of a when using the largest version of a D1 C1 C2 small C library) of the author’s software microcontroller for a particular design 100n 100µ implementation. This allow the ports to application there are just not enough I/ R2 36 be configured as inputs or outputs and Ω O port pins to handle all the inputs and 32 the value of the input port pins to be

330 P4 outputs. This can be the case when for 30 read or output pins to be set. P5 K2 28 example several LCDs are driven in par- P6 26 allel or when it is necessary to input val- P7 The instruction 5 P8 io_max7301(0xF, Portpins); ues from a large number of switches and 7 P9 pushbuttons. 9 selects port pins used as outputs. A P10 11 P11 macro expression such as PCONF8_11 is 6 The circuit shown here solves the prob- P12 GPIO used for Portpins to refer to port pins 8 8 lem using the I/O port expander IC type P13 to 11. The instruction IC1 10 io_max7301(0x0, Portpins); MAX7301 from Maxim [1]. This device K1 P14 12 can be powered from a supply between P15 K3 configures port pins as inputs. To output 34 13 2.5 V and 5 V which makes it suitable for DIN P16 data from the port pins use 33 14 SCLK P17 set_max7301(data, Portpins); use with both 3.3 V and 5 V controllers 35 15 CS P18 4 16 (the value of resistor shown as R2 is suit- DOUT P19 where data = binary data. And the 17 able operation from a 3.3 V supply). P20 instruction 18 The port expander uses the SPI interface SPI P21 data = get_max7301(Portpins); 19 P22 GPIO so it only requires four microcontroller 20 reads the binary value of input data. P23 pins: Data In, Data Out, Clock and Slave MAX7301 (080247-I) 21 Select. Many microcontrollers have an P24 22 P25 K4 SPI interface already implemented on- 23 P26 Internet Links chip but if not it should be relatively easy 24 P27 [1] http://datasheets.maxim-ic.com/en/ds/ 25 to implement the function in software. P28 MAX7301.pdf 1 27 We have sacrificed four pins on the inter- ISET P29 29 [2] www.elektor.com/080247 R1 P30 GPIO face but this port expander now gives 31 P31

us 28 general purpose I/O pins (GPIOs) 39k which can be configured as either inputs 2 3 Download (with or without pull-ups) or outputs. Software Providing the microcontroller is fast 080247 - 11 080247-11 source code, from [2] enough the GPIOs can be switched at a

Slow Glow Dirk Visser (The Netherlands) of the opamp is at the same voltage as the shape of an RC charging curve, and the use There are many different ways in which a inverting input, which is equal to the sup- of a transistor means that a large current lamp can be made to light up gradually. This ply voltage. However, C1 will slowly charge can be supplied. circuit presents one of them. What is spe- up, which causes the voltage on the invert- cial about this circuit is that it can be turned ing input to drop. This voltage therefore When it comes to the choice of op amp you into a power potentiometer with only a small looks like an inverted RC charging curve. have to keep in mind its common mode modification. The reduction of this voltage causes the range. In this circuit it needs to be equal to output voltage of IC1 to increase, and T1 the full supply voltage. As a voltage follower Slow Glow operates as follows: the instant is driven open harder. This in turn causes the need is therefore for a rail-to-rail opamp. the circuit is turned on, the inverting input the voltage across the lamp to follow the An LM8261 was picked mainly because it

14 elektor - 7-8/2009 combines an exceptionally small pate the maximum power for only package (SOT23-5, 2.92 x 2.84 mm) just over a tenth of a second. This with an equally exceptional supply S1 power is obviously dependent on voltage range of 2.7 V to 30 V. There the type of lamp connected up. The LA1 are very few rail-to-rail opamps C3 gate-source voltage of the MOSFET

offering such a large supply volt- 100n determines the permissible supply age range. The opamp has been C1 1 voltage range. The absolute maxi- decoupled with C3 because of its mum value here is 16 V, and there 2u2 IC1 speed (GBWP: 21 MHz). The speed 16V T1 is also a minimum voltage required 3 5 BT1 R3 isn’t critical in this case though. R3 6...15 V 1 to obtain a low channel resistance R2 LM8261 100R 4 is connected in series with the MOS- 100k (<0.05 Ω at UGS = 5 V). Hence the 2 STN4NF03L FET to prevent spurious oscillations R1 C2 supply voltage range for this circuit from occurring. D is 6 to 15 V and a 16 V rated type for S 100k 1n D It stands to reason that this cir- G C1 is sufficient. cuit is best built using SMD com- ponents. C1 can be obtained in an 090029 - 11 When C1 and R1 are replaced with 0805 package (ceramic multilayer) a potentiometer (with the slider and all other parts are also availa- connected to R2), the whole circuit ble in SMD packages. For the MOS- D2PAK package). There is a large number of behaves much like a potentiome- FET we found an SOT-223 variant made by ST, FETs available in this type of package that can ter, but one with very large output power. the STN4NF03L. It can switch more than 6 A, cope with significantly higher currents and The MOSFET is driven by IC1 such that a which is impressive considering its dimen- power. balance exists between the inputs of the sions (7 x 6.5 mm). If more power is needed The circuit can also be used with normal 12 V op amp. The voltage at the drain therefore than the maximum dissipation of 3.3 W (at halogen lighting if a bit of cooling and a TO- becomes equal to the voltage at the wiper 25 °C) permits, there is no problem if a big- 220 package is used. With the values used of the potentiometer. ger FET is used (for example, one in a larger for R1 and C1 the transistor needs to dissi- (090029-I)

SRPP Headphone Amplifier

290V 40mA K1 V2 C4 7 EL84 R5 6BQ5 D3 9 0 470R 2 F1 F2 5W R7 C5 C3 TR1 290V 3 4 5

K3 315mA T 200mA D4 R6 270k 5W K4 (630mA T) C8 C9 C10 D1 470uF 80V 230V 230V

350V 100k

4 R3 R (120V ) D5 65W R8 2V 62 470uF R4 470uF 100n 5W C11 0 10V 145V C6 400V 400V 400V

k 1W3 100k 2W 10

D2 7 100n V1 D3...D6 = 4x1N4007 D6 400V EL84 C4...C7 = 4x1n/1000V 6BQ5 9 10V 2 C7 1W3 K2 3 4 5 6V3 F3 F4 C1 1A52 200mA T TR2 4A T R9 K5 (400mA T) 220n 2V4 100R R1 R2 6V3 C2 6V3

R 40W P1 R10 62 100k

100k 4700uF 100R 10V 081151 - 11

Martin Louw Kristoffersen (Denmark) exist thick books on valve output transform- plifier stages only, employing two triodes in ers, as well as gurus lecturing on them and what looks like a cascade arrangement. Mention valve amplifiers and many design- winding them by hand. However, with some ers go depressive instantly over the thought concessions to distortion (but keeping a lot of Here we propose the use of two EL84 (6BQ5) of a suitable output transformer. The part money in your pocket) a circuit configuration power pentodes in triode SRPP configura- will be in the history books forever as eso- known as SRPP (series regulated push-pull) tion. The reasons for using the EL84 (6CA5) teric, bulky and expensive because, it says, it allows a low-power valve amplifier to be built are mainly that it’s cheap, widely available is designed and manufactured for a specific that does not require the infamous output and forgiving of the odd overload condition. valve constellation and output power. There transformer. SRPP is normally used for pream- Here, two of these valves are SRPP’d into an

7-8/2009 - elektor 15 amplifier that’s sure to reproduce that ‘warm ous voltages at switch-on, or when output capacitors C8 and C9 in a quick but control- thermionic sound’ so much in demand these capacitor C3 breaks down. led manner when the amplifier is switched days. The power supply is dimensioned for two off. Rectifier diodes D3–D6 each have an anti- channels, i.e. a stereo version of the amplifier. rattle capacitor across them. Before describing the circuit operation, it The values in brackets are for Elektor read- must be mentioned that construction of this ers on 120 VAC power. Note the doubled val- In the amplifier, assuming the valves used circuit must not be attempted unless you ues of fuses F1 and F3 in the AC primary cir- have roughly the same emission, the half- have experience in working with valves at cuits. The PSU is a conventional design, pos- voltage level of about +145 V exists at the high voltages, or can rely on the advice and sibly with the exception of the 6.3 V heater junction of the anode of V1 and the control assistance of an ‘old hand’. As a safety meas- voltage being raised to a level of about +80 V grid of V2. The SRPP is no exception to the ure, two anti-series connected zener diodes through voltage divider R7-R8. This is done rule that high quality, (preferably) new capac- are fitted at the amplifier output. These to prevent exceeding the maximum cathode- itors are essential not just for reproducibility devices protect the output (i.e. your head- heater voltage specified for the EL84 (6CA5). and sound fidelity, but also for safety. phones and ears) against possibly danger- R6 is a bleeder resistor emptying the reservoir (081151-I)

Easy LEGO Robotics Set Up

Tilo Gockel (Germany) 3. Re-install the LEGO software selecting screen Display Properties; a solution to the Quicktime 2.1. problem can be found at [2]. At the beginning of 2006 the Danish com- 4. Start / Control Panel / System / click pany LEGO introduced the NXT programma- ‘Advanced’ tab / Perform- Some practical tips for newcomers to ble brick into their ‘Robotics Invention Sys- ance click ‘Settings’ / click the LEGO system: commu- tem’. Many schools and universities all over ‘Advanced’ tab / Now on nications between the world have since recognised this as an ‘Virtual memory’ reduce the brick and ideal tool to introduce the concepts of soft- the size to 384 MB. the IR transmit- ware and hardware design. Spare parts or ter can be dis- additional components for the system can Step 4 is important, rupted by strong be purchased from on-line auction sites or otherwise Quicktime ex ternal light ordered from the LEGO web shop [1]. reports that there is sources such as If you are planning to invest in the system for too little memory table lamps and a child, teenager or even for your own per- available and does fluorescent lighting. sonal use you should be aware that you may not even start — A green LED on the IR encounter some issues when first install- a somewhat transmitter indicates ing the software. The problems can occur curious bug. that the communication on machines running Windows XP or Vista was successful. When it because the software is not officially sup- N o w a is anticipated that the sys- ported. The following tips will be helpful and change tem will not be used for a should solve the main problems you are likely i s n e c- period of time don’t forget to come across. essary to to remove the battery from the start icon the IR transmitter station. First off, try installing the software on the for Mindstorms; The IR tower needs a serial port supplied CD as suggested in the manual. right click on the LEGO but newer computers do not usu- With any luck it will be successful. Choose Mindstorms desktop icon and ally have this type of port, in this ‘complete installation’ option and then tick select ‘Properties’, now click the Shortcut case try a USB — infrared transmit- Quicktime 2.1 option and not the Quicktime tab and change the ‘Start in’ path from ‘C:\ ter dongle these can be found on Inter- 3.0 and DirectX 6.1. It is likely that there is a Program\LEGO MINDSTORMS\probe.exe’ to net auction sites and retail at relatively low more up to date version of DirectX already ‘C:\Program\LEGO MINDSTORMS’. Occasion- prices. Alternatively an even cheaper solu- installed on your machine. It is important to ally a problem will occur with the Windows tion is a USB to RS232 interface (e.g. the USB2 specify Quicktime 2.1; more recent versions installer service (error 1281) which causes Serial USB 1.1 from Reichelt in Germany). are not recognised! the computer to hang. To get round this you In some cases the computer may now ‘hang’ can either reboot before each new installa- Several alternative programming environ- when it tries to execute probe.exe, if this is tion or you can manually stop the installer ments have been developed for the LEGO the case then it is necessary to make a few by going to Start / Control panel / Adminis- system and for more adventurous projects changes to the installation: trative tools / Services / right click Windows like those described in [3] it is better to use Installer and click on the service status box a high-level compiled language rather than 1. Uninstall the LEGO software (Program files ‘Stop’. Now run the software by clicking on the LEGO graphic programming environment / LEGO MINDSTORMS / ... / uninstall) the desktop LEGO icon (make sure that the which comes bundled with the controller. A 2. Uninstall all versions of Quicktime (Start / CD is in the computer’s CD drive). Installing good choice is the free NQC (Not Quite C) Control Panel / Add or Remove Programs the older LEGO Robotics Invention Version 1.0 cross compiler [4] which uses a C-like syntax. / right click on Quicktime) can sometimes generate a problem with the (081129-I)

16 elektor - 7-8/2009 Internet Links [3] www.tik.ee.ethz. www.youtube.com/results?search_type=&search_qu [1] http://shop.lego.com/ByCatalog ch/tik/education/lectures/PPS/mindstorms/#finished ery=lego+mindstorms&aq=f http://www.lego.com/education/school www.informatik.uni-kiel. [4] http://bricxcc.sourceforge.net/nqc/ de/rtsys/lego-mindstorms/projekte/#c1798 [2] www.crynwr.com/cgi-bin/ezmlm-cgi/7/21888

Pseudo Fan

Dr. Thomas Scherer (Germany) collector output. V+ D1 The circuit diagram contains no great sur- The aim of this circuit is to trick a so-called prises. Rather than using the standard asta- ‘intelligent’ fan controller that a fan is con- SB140 ble configuration of the device, the fre- nected to it when it is not. This may sound R1 quency-determining resistance (comprising 47k like madness, yet there is method in it. the series connection of R1 and P1) is wired to P1 pin 3, which is normally used as the output. The author was so pleased with his small pri- 4 8 This has the twin advantages of leaving pin 7 R vate server (a network attached storage, or 6 THR free to use as an open-collector output and NAS, device) that he recommended it to a IC1 of giving a 50 % duty cycle. With the compo- 7 3 470k friend. The friend had found a good source of DIS OUT nent values suggested the output frequency NE555 low-cost SSDs (solid state disks) and replaced 2 can be adjusted from approximately 15 Hz to TR the spinning hard disks with semiconductor approximately 150 Hz, which should be more CV memory, with the aim of saving power. With 5 1 than enough for any application. the drives replaced, it became apparent that C3 C1 C2 It is of course possible to build a simple cir- there was an opportunity to make the unit cuit like this on a small piece of prototyping 47µ 16V 100n 10n quieter still. Since the SSDs only dissipated a board. However, a much more professional 090445 - 11 look can be achieved using the printed cir- cuit board we have designed for the job. The Characteristics layout file can, as usual, be found on the Ele- • simulates a fan of any size(!) Old hands will no doubt be able to guess ktor website on the pages accompanying this what comes next: the 555 timer, one of the article [1]. • pseudo-rotation frequency adjustable from best-selling ICs ever, is ideal for this task. It The pseudo-fan is of course not limited to 15 Hz to 150 Hz can cope with the range of supply voltages, being used in small servers. It is becoming • current consumption less than 5 mA and conveniently features a traditional open- more and more popular to build PCs that • operating voltage from 4 V to 15 V are quiet, especially if they are to be used • low noise! as media centres. This means using passive COMPONENT LIST cooling wherever possible. Unfortunately in some cases the BIOS throws its spanner in total of 5 W, surely it would be possible to dis- ktor le ©E IC1 the works by not allowing the fan rotation

C2 ktor connect the noisy internal 60 mm fan? le sensors on the motherboard to be disabled

RT D1 090445-1 Unfortunately it was never going to be that ©E individually. The pseudo-fan provides a sim- GE easy. The moment the fan was disconnected C1 ple and quick solution to this problem and C3 SW P1 an annoying buzzer started to sound contin- R1 avoids complicated BIOS patches. Some fans uously: the electronics in the NAS box does 090445-1 use a four-wire cable, and these too can be not just control the fan speed to maintain a ‘virtualised’ using this circuit by ignoring the reasonable temperature inside the unit, it Resistors fourth wire and connecting the remaining also checks that the fan is indeed spinning. R1 = 47kΩ three in the way described above. If the controller thinks the fan has stopped, it P1 = 470kΩ, small, upright If it will not be necessary to adjust the pseudo- sounds the alarm. The author was called in to fan speed P1 can be replaced by a wire link see if he could solve the problem. Capacitors and R1 chosen appropriately. The frequency C1 = 100nF C2 = 10nF is then given by f = 1.44 / (2 x R1 x C1). It immediately became clear that the fan had C3 = 47µF 16V (090445-I) a standard three-pin connector. The cable carried a voltage of between +5 V to +12 V on Semiconductors the red wire and ground on the black wire; on D1 = SB140 (Schottky diode) Internet Link IC1 = NE555 [1] www.elektor.com/090445 the yellow wire the fan produced a square- wave signal with a frequency of about 35 Hz. Miscellaneous To fool the controller into thinking that the Branched cable with 3-way plug Download fan is turning we simply needed to generate PCB # 090445-1 090445-1: PCB design (.pdf), from [1] a square wave!

7-8/2009 - elektor 17 Programmable Nokia RTTTL Player

Sajjad Moosavi (Iran) FurElise:d=4,o=6,b=125:8e, 8d#, 8e, This circuit is an easy way to play 8d#, 8e, 8b5, 8d, 8c, a5, 8p, 8c5, 8e5, monophonic music as you may 8a5, b5, 8p, 8e5, 8g#5, 8b5, c, p, 8e5, remember it (fondly or not) sound- 8e, 8d#, 8e, 8d#, 8e, 8b5, 8d, 8c, a5, ing from those good old Nokia 3310 8p, 8c5, 8e5, 8a5, b5, 8p, 8e5, 8c, 8b5, cellphones. The circuit can be used 2a5 in applications like doorbells, phone ringers, bike horns or any other alarm The string consists of three parts circuit — waves of recognition and separated by colons. The first part is cellphone wistfulness in the audi- the song name, ‘FurElise‘ (apologies ence guaranteed! from Mr ASCII to the Beethoven Her- Monophonic music is made of some itage for the non-umlauted u). The notes in a specific order with a second part contains the defaults, given duration for each note. These with ‘d=4’ meaning that each note notes are selected from a range without a duration specification is by specified in the table shown here. default a quarter note, ‘o=6’ setting Nokia developed a programming the default octave, and ‘b=125’ defin- language to transfer monophonic ing the tempo. The third part com- music to its cellphones and called it prises the notes proper. Each note is RTTTL, for Ringing Tone Text Trans- 1 separated by a comma and includes, +5V fer Language. in sequence: a duration specification, Looking at the table, each note has a standard music note (as shown in a different frequency according to first column of the table) and an selected octave. An octave is the C3 octave specification. If no duration R2 interval between two points where C2 or octave specification is present,

100n 7 Ω the frequency at the second point is 4 the default applies. 8 100µ twice the frequency of the first. So 16V The circuit shown in Figure 1 con- to select a specific note in this table, 1 7 tains an ATtiny13 microcontrol- you specify its column and row like PB5/RESET PB2 ler programmed to read the RTTTL 2 IC1 6 PB3 PB1 T1 A4 (220 Hz) or A#7 (1864.7 Hz). Two ATTiny13 R1 format (with some modification), 3 5 successive notes in the table dif- PB4 PB0/OC0A 220 Ω store strings in its program mem- fer by a factor of exactly the 12th BD139 ory and generate notes in the form 4 root of 2 (approximately 1.059). For S1 S2 of square waves. The note frequen- C1 LS1 example: E6 (1318.8) = D#6 (1244.8) cies are read from a table stored in 220n 8 Ω × 1.059 Hz. PLAY NEXT memory and durations will be cal- After selecting the note, the next culated in the program. The com- issue is its duration, i.e. how long 090243 - 11 monly used octaves 3 through 7 it should sound. In contemporary (110 Hz – 3323.7 Hz) can be played music you will typically observe by this circuit. see the following basic note dura- The microcontroller is an 8-pin tions 1/1, 1/2, 1/4, 1/8th, 1/16th. A 2 ATtiny13 Atmel microcontroller Whole Note, a.k.a. ‘1/1’ or semibreve, employing its internal oscillator. is typically equal to four beats in 4/4 The music signal generated at the time. A Beat is the basic time unit of PB0 pin applied to a simple emitter a piece of music. The real duration of follower circuit that’s open to your a beat is related to Tempo. Tempo or improvements in terms of filtering BPM (beats per minute) is the speed and amplification. Also, because the of a given piece and specifies how program puts a low demand on CPU many beats should be played in a use and resources, you can make the minute. free microcontroller I/O ports do The RTTTL format is a string divided other jobs. The microcontroller’s 1 KB into three sections: name, default program memory is good for storing value, and data. The name section consists The data section consists of a set of charac- about 20 songs. Other microcontrollers with of a string describing the name of the ring- ter strings separated by commas, where each larger memories may be used to be able to tone. The default value section is a set of val- string contains a duration, note, octave and store more songs. As a minimum hardware ues separated by commas. It describes cer- optional dotting (which increases the dura- requirement, the micro should have an 8-bit tain defaults which should be adhered to dur- tion of the note by one half). For example timer with compare/match capability. ing the execution of the ringtone. Possible here is RTTTL ringtone for the famous Für The microcontroller must first be pro- names are: d (duration), b (tempo), o (octave). Elise piece: grammed with the firmware for the project.

18 elektor - 7-8/2009 Octave Note 1 2 3 4 5 6 7 8 9 A 27.5 55.0 110.0 220.0 440.0 880.0 1760.0 3520.0 7040.0 A#/Bb 29.1 58.3 116.5 233.1 466.2 932.4 1864.7 3729.4 7458.9 B 30.9 61.7 123.5 247.0 493.9 987.8 1975.7 3951.3 7902.7 C 32.7 65.4 130.8 261.6 523.3 1046.6 2093.2 4186.5 8372.9 C#/Db 34.6 69.3 138.6 277.2 554.4 1108.8 2217.7 4435.5 8871.1 D 36.7 73.4 146.8 293.7 587.4 1174.8 2349.7 4699.5 9398.9 D#/Eb 38.9 77.8 155.6 311.2 622.4 1244.8 2489.5 4979.1 9958.1 E 41.2 82.4 164.9 329.7 659.4 1318.8 2637.7 5275.3 10550.6 F 43.7 87.3 174.7 349.3 698.7 1397.3 2794.6 5589.2 11178.4 F#/Gb 46.2 92.5 185.1 370.1 740.2 1480.4 2960.8 5921.8 11843.5 G 49.0 98.0 196.1 392.1 784.3 1568.2 3137.1 6274.1 12548.2 G#/Ab 51.9 103.9 207.7 415.5 830.9 1661.9 3323.7 6647.4 13294.8

The programming procedure comprises using Visual Basic which runs under Win- ler’s program memory (or EEPROM) using a these steps: dows operating systems. Paste or type the serial or parallel programmer. 1. Convert your favorite RTTTL format songs song data and specify the clock frequency of (090243-I) using the ‘Converter’ utility. the microcontroller in Megahertz, then press 2. Compile the ASM file using an AVR assem- the ‘Convert’ button. Note that the ATtiny13 bler like the one provided with Atmel micro uses its 9.6 MHz internal oscillator. The Downloads & Products AVRStudio. software converts the songs and copies them Programmed Controller 3. Write the HEX file to the microcontroller to a file called ‘ringtones.inc’. Next, Assemble Order code: 090243-41 (plays ‘Popcorn’ song only) using a suitable device programmer. the ‘rtttl.asm’ file with ‘ringtones.inc’ using Software an AVR assembler. The assembler outputs are File: 090243-11.zip (free download) In the first step, use the ‘Converter’ software two main files, ‘rtttl.hex’ and ‘rtttl.eep’. These Content: ATtiny13 source & hex files; ‘Converter’ utility shown in Figure 2. This utility was developed files should be written to the microcontrol- Location: www.elektor.com/090243

Switching Delay Thorsten Steurich (Germany) +12V

The circuit described here was +5V designed as an addition to a F1 R3 R6 R7 remotely-controlled garage C4 D2 10k 10k 10k door opener. The problem was IC1.A 100n 1N4148 C1 1 that a brief burst of interference, 3 2 & C2 arising from a thunderstorm or 10µ 4 8 IC1.C IC1.D K1 25V 8 R9 12 10n R 10 11 a mains spike, was enough to 7 9 & 4k7 13 & S1 R4 DIS IC1.B trigger the mechanism, and R8 Ω IC2 5 R2 3 4

4k7 OUT the author found this a nui- 100 6 & 2 +5V T1 TR 555 sance. The effect of the circuit 15k BC547 T2 6 THR is to enable the output from the CV 14 receiver module only when a R1 R5 5 1 D1 C5 IC1 = 4093 IC1 C3 relatively long pulse (more than 7 3k 3k 22µ 4µ7 about 0.5 s) is received. The cir- 25V 25V cuit can of course also be used 1N4148 BC547 081086 - 11 in other similar situations, such as electrically-powered shut- ters, alarms and the like. T1 conducts, and the output of inverter IC1. of the author’s garage door opener, this will A, and hence also pin 8 of IC1.C, go high. If we only happen if the button on the transmitter At the heart of the circuit is NAND gate IC1.C. now arrange things so that for a preset time is held down. The output of the circuit (after inverter IC1.D) the other input to IC1.C remains low, the trig- The 555 timer is used to generate the only goes high when both inputs to IC1.C are ger signal will not be propagated to the out- delayed gating signal for IC1.C. It is wired at a high level. When the circuit is triggered put until this period has elapsed. In the case as a monostable multivibrator in a similar

7-8/2009 - elektor 19 fashion to the arrangement in the ‘Economy the circuit is triggered. The RC combination When the trigger signal is removed the out- Timer’ circuit elsewhere in this issue. When at the input to IC1.D ensures that this does put of IC1.A goes low, which resets the timer: the circuit is triggered T2 will briefly conduct not affect the output. the 555’s reset input, like its trigger input, is as a result of the positive edge at the output When the period of timer IC2, as determined active low. The circuit is now again in its qui- of IC1.A. This triggers the 555 timer: its out- by R7 and C5, expires its output returns low. escent state. put will go high, and thus pin 9 of IC1.C will This allows the input signal to pass through (081086-I) go low. Because of the propagation delays IC1.C. If the button on the remote control has through the components a very short low been released before the timer expires, no pulse will appear at the output of IC1.C when signal will pass to the output.

Six-digit Display with SPI Port

VCC

R1 10k

18 19 LD1 LD2 LD3 LD4 LD5 LD6 ISET SC52-11 SC52-11 SC52-11 SC52-11 SC52-11 SC52-11 14 7 7 7 7 7 7 SEGA a a a a a a 16 6 6 6 6 6 6 SEGB b b b b b b IC1 20 4 4 4 4 4 4 SEGC c c c c c c 23 2 2 2 2 2 2 SEGD d d d d d d 21 1 1 1 1 1 1 SEGE e e e e e e K1 1 15 9 9 9 9 9 9 VCC DIN SEGF f f f f f f 17 10 10 10 10 10 10 DIN SEGG g g g g g g 24 22 5 5 5 5 5 5 DOUT SEGDP dp dp dp dp dp dp DOUT CC CC CC CC CC CC CC CC CC CC CC CC CLK MAX7219 3 8 3 8 3 8 3 8 3 8 3 8 13 CNG 2 LOAD CLK DIG0 11 GND DIG1 12 6 LOAD DIG2 7 DIG3 3 DIG4 10 DIG5 5 DIG6 8 DIG7

4 9

081154 - 11

a series resistor. Each digit also requires a An advantage of the MAX7219 is that Characteristics transistor, which again needs an output neither series resistors nor drive transistors • six-digit seven-segment display port pin to drive it. For a six-digit display, are required. Only one external resistor is • just two components, plus display modules this means a total of fourteen output port needed, which is used to set the segment • driven using software SPI emulation pins: almost two whole ports on an 8-bit current for all the digits. Since it is also • C driver routines easily adapted to any type of microcontroller. possible to adjust the segment current microcontroller Maxim offers a solution to this problem over the SPI port, a fixed 10 kΩ resistor is in the MAX7219. The device is controlled suitable. Uwe Altenburg (Germany) over an SPI port, requiring just four I/O pins The small printed circuit board is designed on the microcontroller. It can drive up to to accept Kingbright SC52-11 common There is no essential difference between eight individual seven-segment displays. cathode display modules, which have a seven-segment display and seven Contrary to popular belief, multiplexing a digit height of 13.2 mm. The display individual LEDs with either their cathodes the displays does not reduce overall power is available in a range of colours. If you or their anodes connected together. consumption: although each digit is only wish to modify the board layout to suit a Often the display will be driven by a driven briefly the LED current must be different display, the Eagle file is available microcontroller, and when several digits correspondingly increased in order to for download from the web pages for this are wanted, they are usually driven in achieve the same average brightness. article [1]. a multiplexed fashion. This involves According to the device’s datasheet the A special feature of the MAX7219 is the connecting together each segment in MAX7219 can deliver up to 500 mA per ability to cascade multiple devices, allowing a given position across the digits, with digit. The rapidly changing current draw can several display boards to be driven from a each of the seven common segment lines cause interference to the microcontroller’s single microcontroller. No extra I/O pins (plus decimal point) being driven by an power supply if adequate decoupling is are required on the microcontroller as the output port pin of the microcontroller via not provided. data bits are shifted through the chain of

20 elektor - 7-8/2009 devices: the output DOUT of one module waveforms can be generated in software. The display module is also supported by is connected to the DIN input of the next, The author has written suitable routines in the M16C TinyBrick [2] described in the and the LOAD and CLK signals are wired in C [1], which are easily adapted for any type March 2009 issue of Elektor. A simple parallel. of microcontroller. The routine SendCmd() example program can be downloaded How do we program the device? The is responsible for ‘bit banging’ the I/O ports from the project website, showing how MAX7219 contains 16 internal registers that to generate the SPI signals. easy it is to control the display using the can be serially addressed and written to. A couple of the MAX7219’s registers built-in BASIC interpreter. Each seven-segment display is configured require initialisation. The mode register (081154-I) using a separate 16 bit message, where determines whether the internal BCD-to- bits 0 to 7 carry the data to be displayed seven-segment decoder is used or whether and bits 8 to 11 carry the register address. the data stored in the registers correspond Internet Links [1] www.elektor.com/081154 Bits 12 to 15 are not used. directly to segment patterns. The latter [2] www.elektor.com/080719 Each bit is clocked into the device on option is more general but requires the the rising edge of the CLK signal. While use of a look-up table in the driver: in the the data bits are being transmitted the author’s source code this array is called Downloads LOAD signal must remain low; when it Segments. A further register sets the total 081154-1: PCB layout (.pdf), from www.elektor. goes high the message is written to the number of digits to be driven; and finally com/081154 addressed register. It is not necessary for the segment current must be set and 081154-11: source code, from www.elektor. the microcontroller to have dedicated the display enabled. Once everything is com/081154 SPI hardware: a low data rate is adequate initialised the digit registers can be written CAD files, from www.elektor.com/081154 in almost all cases and so the necessary to using the function UpdateDisplay().

COMPONENT LIST

Resistors R1 = 10kΩ

Semiconductors D1–D6 = SC52-11 (Kingbright) IC1 = MAX7219CNG

Miscellaneous JP1 = 6-way pinheader PCB # 081154-1 [1]

LiPo Monitor

Werner Ludwig (Germany) tains two comparators plus an internal 1.3 V voltage reference. The LiPo Monitor simplifies 2x Lipo 3x Lipo Each comparator has two out- voltage monitoring of Lithium R1B R1A R4

Ω puts, OUT and HYST. This ena-

Polymer (LiPo) batteries during 270k 590k 390 bles you to monitor each of the use. You clearly want to avoid D1 two inputs SET1 and SET2 for discharging them too far and 8 over and under-voltage. 1V3@6V0 1V3@9V0 3 7 another thing on your wish SET1 OUT2 OUT1 is an inverting output, R2B R2A list should be a warning when HYST2 5 BT1 whereas the other three are non- the permitted limit of safe dis- IC1 6k8 9k1 ICL7665 2 2, 3x Lipo inverting. The maximum current HYST1 1V3@6V6 1V3@9V9 charge is approaching. A green 6 1 R5 SET2 OUT1 is 25 mA per output. OUT1 and LED remains on for all the time Ω OUT2 are current sinks (open- 470 that the battery voltage remains R3B R3A 4 C1 drain outputs of N-channel adequate. If the volts drop as far D2 MOSFETS, source to ground). 68k 91k as the terminal voltage level, a 2µ2 25V HYST1 and HYST2 are current red LED lights to signal that fur- 090038 - 11 sources (open-drain outputs of ther use (and discharge) of the P-channel MOSFETS, source to battery will be harmful and not +UB). The truth table shown be- allowed. Before this happens, in monitoring the LiPo propulsion batteries of radio control models that are used pri- low provides information on the switching the lower but still OK voltage range, both behaviour of the ICL7665. LEDs illuminate to warn that the end is marily in short range operation, such as nigh. The circuit is particularly suitable for indoor model helicopters. The two comparators in the LiPo Monitor The ICL7665 device used in this circuit con- form a window discriminator (voltage range

7-8/2009 - elektor 21 sensor). The bat- ICL7665 Truth Table ging and avoids tery voltage under deep discharge observation is app- SET1/SET2 OUT1/OUT2 HYST1/HYST2 o f p r o p u l s i o n lied, via a voltage USET1 > 1.3 V OUT1 = ON = LOW HYST1 = ON = HIGH batteries. divider, to both of USET1 < 1.3 V OUT1 = OFF = high-impedance HYST1 = OFF = high-impedance (090038-I) the inputs. The vol- USET2 > 1.3 V OUT2 = OFF = high-impedance HYST2 = ON = HIGH tage dividers in this USET2 < 1.3 V OUT2 = ON = LOW HYST2 = OFF = high-impedance circuit are designed for situations using Internet Link two or three LiPo cells and are arranged so light together, lies between 3.0 and 3.3 http://datasheets.maxim-ic.com/en/ds/ICL7665.pdf that the warning range, in which both LEDs volts per cell. This makes for timely char-

Low-drop Series Regulator using a TL431

Lars Krüger (Germany) circuits (min. 10 seconds), with a voltage drop of typically no more than 1 V across the col- +15V T1 +13V8...+14V4 Like the author you may keep some 12 V lead- lector-emitter path of the transistor. R1 R2

acid batteries (such as the sealed gel cell Ω For the voltage source you can use any trans-

BD249 51k type) in stock until you come to need them. 150 TL431CP former power supply from around 12 V to 15 V A simple way of charging them is to hook up IC1 delivering a maximum of 0.5 A. By providing K1 C a small unregulated 15 V ‘wall wart’ power 2 a heatsink for T1 and reducing the value of R1 P1 supply. This can easily lead to overcharging, 1 R you can also redesign the circuit for higher 3 though, because the off-load voltage is really 1k currents. TL431CP A too high. The remedy is a small but precise R3 (090014-I) series regulator using just six components, which is connected directly between the 10k power pack and the battery (see schematic) Internet Link 090014 - 11 http://focus.ti.com/lit/ds/symlink/tl431.pdf and doesn’t need any heatsink. The circuit is adequatele proof against short

VGA Background Lighting

+5V

R3 R4 8 3 5 R9 IC2 IC3 R15 10k 3k3 2 100k 4 12 R12 IC3.A 330 Ω 4 100k R7 2 8 4 100k 1 7 R R6 IC2.A R16 2 3 R10 1 TR 100k R13 IC3.B 330 Ω IC1 6 R2 6 THR 100k 3 3k3 OUT 3k3 555 T1 5 R1 7 7 9 DIS 10k IC2.B R17 6 14 CV R14 IC3.C 330 Ω BC 8 1 5 557 100k

R5 R8 R11 C2 C3 C4 C1 IC2 = LM358 1k5 10k IC3 = LM339 100n 100k 1u 1u 1u 16V 16V 16V

090080 - 11

Heino Peters (The Netherlands) More and more people are using a PC (con- output can be used to provide a matching ventional or notebook) to view films. The VGA ‘Ambilight’ effect for this. If you restrict your-

22 elektor - 7-8/2009 self to a single RGB LED, you can also draw to opamp IC2a via R6. The frequency of the place of a single RGB LED. In this case you the power for this circuit from the VGA con- sawtooth signal is approximately 850 Hz, and will need an external power supply for the nector, along with the RGB signals. its amplitude ranges from 1.6 to 3.4 V. IC2A LEDs, but the control circuit can still be pow- subtracts approximately 1.6 V from this due ered from the PC. If you use multiple LEDs or The following pins of the 15-way VGA con- to voltage divider R4/R5. After this, voltage a LED strip, connect the cathodes (negative nector (three rows of five pins) are used for divider R10/R11 reduces the peak value of leads) of the LEDs to the comparator outputs this circuit: the sawtooth to around 1.35 V. The result- of IC3 as shown on the schematic diagram, ing sawtooth signal is buffered by IC2b and and connect all the anodes (positive leads) to Pin 1: Red video signal used to drive the three comparators in IC3. the external power supply. Resistors R15–R17 Pin 2: Green video signal The level of the red video signal is averaged are often already integrated in the LED strip. Pin 3: Blue video signal by the R12/C2 network. IC3a constantly com- There’s no harm in using an external supply Pin 5: GND pares the previously generated sawtooth sig- with a higher working voltage, such as 12 V. Pin 9: +5 V nal with the average value of the red video Remember to connect the ground terminal signal. If the image has a high red content, of the external supply to the ground of the The video signals for the red, green and the output of IC3a will be logic Low a good control circuit. blue channels are available at the RGB out- deal of the time, while with a low red content puts. These signals have an amplitude of 1 to it will be Low less often. This comparator cir- IC3 can handle a current of 15 mA on each 1.35 V, and they output the screen imagery at cuit thus implements a PWM driver for the output. If this is not enough, swap the con- the rate of dozens of frames per second. This red LED. The same arrangement is used for nections to the inverting and non-inverting produces the visible image on the screen. the green and blue channels. inputs of the three comparators in IC3 and The circuit described here drives an RGB LED connect their outputs to the bases of three according to the average values of each of Note that with a notebook computer you BC547 transistors. Connect a 10-kΩ resistor these three signals. Of course, this is not a always have to enable the VGA first, usu- between each base and the positive supply full-fledged ‘Ambilight’ system, but the RGB ally by pressing Fn-F5. If you use a desktop line (+5 V). Connect the emitter of each tran- LED will produce a nice green light during a or tower PC, you can tap off the video sig- sistor to ground, and connect the collector football match or an orange hue if a sunset is nals from an adapter connected between the to the LED strip. A BC547 can switch up to shown on the screen. video cable and the monitor. 100 mA with this arrangement, and a BC517 A sawtooth generator is built around IC1 You can also use several LEDs or a LED strip can handle up to 500 mA. and T1. It supplies a nice sawtooth signal (available from Ikea and other sources) in (090080-I)

Wireless S/PDIF Connection

Ton Giesberts (Elektor Labs) or any extra circuitry! At the video output of the receiver A question came to mind you then have a copy of the after the ‘Hi-fi Wireless Head- S/PDIF signal — well, that is set’ article was published in the theory. the December 2008 issue of Elektor: why don’t we design The bandwidth of the mod- a wireless S/PDIF connection? ules we used is just enough This would of course have to transfer the digital signal been a very useful option from a CD. We tested this (the modules in question with a Gigavideo 30 made by digitise an analogue signal in Marmitek. This is a somewhat the transmitter, which is then older version, and equiva- converted back to analogue lent devices shouldn’t cost by the receiver). much more than a few tens of pounds. The idea is therefore to cre- To reliably transfer an S/PDIF ate a digital (in other words, signal from a CD player you lossless) connection between need a bandwidth of at least two devices. As a compro- 6 MHz. The minimum pulse mise we could have added width of an S/PDIF signal of an S/PDIF input to the transmitter men- solution was found on the Internet, which 44.1 kHz is 177 ns. The video bandwidth of tioned above. However, in that case the D/A we wanted to try out in practice. It concerns 5.5 MHz (this depends very much on the qual- converter in the receiver would mainly deter- the use of wireless audio/video modules to ity of the modules used) seems to be suffi- mine the quality of the analogue signal, and transfer the signal. However, no use is made cient to create a usable link. that was something we didn’t want. of the audio section of the modules! The S/ PDIF signal is connected directly to the video The shape of the signal at the output of the Amongst lots of other things, a possible input of the transmitter, without modification receiver no longer consists of a tidy square

7-8/2009 - elektor 23 wave, but looks more like a sine wave. This ously a cheap alternative! the signal at the input of the transmitter (top is of course the result of the limited band- waveform) and the output from the receiver. width available. Everything will be fine as Something that should also be taken into This shows clearly how the shorter pulses are long as the zero crossing points (or original account is that walls can significantly attenuated (the bottom waveform has been pulse edges) haven’t shifted with respect to reduce the maximum distance between the delayed by about 440 ns compared with the each other. This is because an S/PDIF receiver transmitter and receiver. In our lab are two top one). retrieves the clock signal from the input sig- areas that are partially divided by a 1-metre nal with the help of a PLL circuit. (3 feet) thick brick wall. When this wall was We tried adding a frequency dependent between the transmitter and receiver the amplifier to compensate for the restricted Because the edges are less steep, the receiver maximum range was reduced to barely two bandwidth, but the amplitude of the atten- will be more susceptible to noise and some metres (6.5 ft). uated pulses could not be increased enough jitter could occur. If the edges start shifting without affecting the phase of the pulses. with respect to each other it is likely that the We decided to test the circuit with an S/PDIF We found out that the S/PDIF receiver just PLL can no longer cope with the signal. The signal with a sample frequency of 96 kHz couldn’t cope with this ‘improved’ signal quality of the connection is therefore not as (DVD with 24-bit audio). The minimum pulse at all. good as that provided by a coaxial cable, but width for this signal is only 81 ns. This would (081034-I) for those of you who don’t want to lay a cable, seem to be too short to be transferred reli- between two floors for example, this is obvi- ably by the modules. The oscillogram shows

One Wire RS-232 Half Duplex

Andreas Grün (Germany) connected to one line, this circuit 1 R1 R2 4k7 4k7 generates a local echo of the trans- Traditional RS-232 communication mitted characters into the sender’s TX D1 D2 TX needs one transmit line (TXD or TX) receiver section. If this is not accept- and one receive line (RXD or RX) 1N4148 1N4148 able, a more complex circuit like the RX RX and a Ground return line. The setup one shown in Figure 3 is needed allows a full-duplex communica- (only one side shown). This circuit tion; however many applications are needs no additional voltage supply using only half-duplex transmissions, either. In this circuit the transmitter GND GND as protocols often rely on a transmit/ pulls its associated receiver to logic 1 acknowledge scheme. 080705 - 11 (i.e. negative voltage) by a transis- tor (any standard NPN type) when With a simple circuit as shown in Fig- actively sending a logic 0 (i.e. posi- 2 2x ure 1 this is achieved using only two 1N4148 tive voltage) but keeps the receiver wires (including Ground). This cir- TX1 D2 RX1 ‘open’ for the other transmitter cuit is designed to work with a ‘real’ when idle (logic 1). Here a negative RS-232 interface (i.e. using positive TX2 D1 RX2 auxiliary voltage is necessary which voltage for logic 0s and negative R1 is generated by D2 and C1. Due to voltage for logic 1s), but by revers- the start bit of serial transmissions, ing the diodes it also works on TTL the transmission line is at logic 1 for based serial interfaces often used at least one bit period per charac- 080705 - 12 in microcontroller designs (where -U ter. The output impedance of most 0 V = logic 0; 5 V = logic 1). The cir- common RS-232 drivers is sufficient cuit needs no additional voltage sup- 3 to keep the voltage at C1 at the nec- ply, no external power and no auxil- RX R2 RX essary level. 4k7 iary voltages from other RS-232 pins GND (RTS/CTS or DTR/DSR). TX D1 Note: Some RS-232 converters have

Although not obvious at a first 1N4148 quite low input impedance; the val- R3 glance, the diodes and resistors form R1 ues shown for the resistors should 4k7 a logic AND gate equivalent to the T1 47k work in the majority of cases, but one in Figure 2 with the output con- adjustments may be necessary. In nected to both receiver inputs. The BC547B D2 case of extremely low input imped- default (idle) output is logic 1 (nega- 1N4148 ance the receiving input of the tive voltage) so the gate’s output fol- C1 sender may show large voltage vari- lows the level of the active transmit- ations between 1s and 0s. As long as GND 10µ ter. The idle transmitter also provides the voltage is below –3V at any time the negative auxiliary voltage –U in 080705 - 13 these variations may be ignored. Figure 2. Because both receivers are (080705-I)

24 elektor - 7-8/2009 ACCESSORY BOARDS mikroElektronika DEVELOPMENT TOOLS | COMPILERS | BOOKS

 6, /" 6, /"  6, /" ,*- !16) 0&  6, /" 4#-3(.-).-3 ('/ +- + 4#-33#').-3 3 (+30#-"3   ,23-(3('' -3,*- !1 ('' -3&.%-#)% 3 /# ,   0#-"3, +#%3 ('/ +- +3  0#-" -+', #/ +3'3 ) 0& (+30#-"3 %-3% #'-(34 3' -0(+$30#-" #'- +   , +#%3#'- +    3('-+(%% + ('' -(+   %#' 3-+', #/ +

&/##7 4'06 !!#) 6, /" #/' )61&#/+#1 ,/164- +"#/ '%'1 )6,1  #,33,&%%3-"#' ,23023-(3., 3    -'4 %(' ,23 -(3 ('' -3 (+ (+30#-"3 %(03 )(0 +3 (&)% - 3 4 +,3#'32(.+3 ,#!'3- -" +' -3('-+(%% +30#-" 0#-"3  43  4#- ,#'!% 3 43 "'' %3 #!#-% 1#,3 % +(& - + *.#,#-#('3 - 3'- +   3 1)' + )(- '-#(& - +3('4(+

Now you need a... ACCESSORY

OK./ '+6$,/61$212/# BOARD !!#00,/56 , /"0 0 + 3  ,#!' 3 -(3 %%(03 ,-. '-,3 (+ '!#' +,3-(3 ,#%23 1 +#, 3'3 1)%(+ 3-" 3)#%#-# ,3( -" 3 /+#(.,3 &#+(('-+(%% +,3 0#-"3 ) +#)" +%3  /# ,3 ,." , 3 3  3  3 1&#/+#13 / 3 3   ' &'23&(+ 

#/' )6 70#%6 * /1 '%&161,6/#. 6, /" '"6# "#/    3'- +   ( 3 .#( (+3 0#-"3  (+3 0#-"3   3 '"6 /# "#/ -(3 2(.+ 3#,)%23+#/ +,3('4 %2 +3 3  ( +3 0#-"3  %#!"-4-(4 + *. '23 +', #/ +3 0#-"3 /(%-! )+(-(-2) 3 /# 3 ,#%2 (+30#-"3 6!,**,+ - '- +  3'3 %(- ('/ +- + + !.%-(+

 05## 1#--#/6,1,/6/'3#/ *'(/,2$$#/ *'(/,/'3# ,1#+1',6, /" ('' -32(.+3 / %()& '- 3,- )) +3&(-(+3('-+(% 2$$#/ -" 3 '%(!3 ,#!'%, (+30#-"3   ,-3'%(!3#').-,3('32(.+ (+3-(30#+ % ,,3' -0(+$ -(3 2(.+3 )+(-(-2) 3  /# ('' - 3-(3 / %()& '- "#!"4.++ '-3+%#'!-('  / %()& '-3 (+3 ,#%2 .,#'!3 '%'16,"2)# 0#-"3   (+3#').-, ++2, 0#-"3 6-,1#+1',*#1#/0

http://www.mikroe.com/ S O F T W A R E A N D H A R D W A R E S O L U T I O N S F O R E M B E D D E D W O R L D Breadboard/Perfboard Combo

Based on an idea from Luc Heylen (Belgium) iron every time you make a change. It’s also to take it all apart and rebuild it on a piece of Electronic hobbyists and engineers often use a lot easier to see what you’re doing than perfboard because the circuit has to be used to experiment with small cir- when you build a circuit on a piece of perf- somewhere right away. In such cases, leav- cuits. A breadboard consists of a thick strip board, where the wiring on the copper side ing the circuit in its breadboard form is not a of plastic with an array of holes and embed- can quickly turn into a rat’s nest that isn’t long-term option. ded metal contact strips that interconnect so easy to sort out when you want to make individual rows of holes. A few long rows changes. The person who thought up the idea extending over the entire length are located described here, who is a fervent breadboard along the sides; they can be used for sup- Of course, breadboards also have their disad- user, encountered this problem regularly and ply voltages. With this arrangement of holes vantages. They can’t be used for RF circuitry, came up with the following solution. Make a and strips, you can plug all sorts of electronic which is something you always have to con- printed circuit board with the same layout, components (including ICs) into the bread- sider. The spring contacts also tend to wear hole spacing and interconnections as a stand- board and build a circuit by interconnecting or weaken over time, which can lead to poor ard breadboard. Secure this PCB on top of the them as desired with short lengths of wire. Of connections. Despite these disadvantages, breadboard, and then plug the components course, we don’t have to explain this to most breadboards are especially convenient and and interconnecting wires through the holes of our readers, since they have probably used affordable tools for electronic designers. in the PCB, mounting them the same way as a breadboard occasionally. you would normally do with the breadboard If you do a lot of work with a breadboard, you (Photo 1). Use slightly longer component The advantage of a breadboard is that you are often faced with the problem that after leads and wire ends than usual, due to the can try out different ideas to your heart’s you have managed to build and test a cir- extra thickness of the PCB. Fit ICs in sockets content without having to use a soldering cuit that works the way it should, you have with extra-long pins (wire-wrap pins). In a cir-

1 2

26 elektor - 7-8/2009 cuit built using this arrangement, the contact interconnections are exactly the same as on number of electronics retailers. Note that strips in the breadboard provide the intercon- the breadboard. other types of breadboards may have dif- nections, so there’s no need for soldering. ferent dimensions or contact arrangements, To make it easy to work with this combina- which means that they cannot be used with Once the circuit is finished and works the tion of a breadboard and a PCB, it’s a good the PCB layout shown here. way it should, you don’t have to rebuild it idea to mount the breadboard on a piece (080937-I) before you can use it somewhere else. Press of wood with four long M3 screws arranged Internet Link a sponge or a bag filled with styrofoam parti- to fit exactly through the corner holes of [1] www.velleman.be/nl/en/product/view/?id=40573 cles on top of the circuit (Photo 2) and clamp the printed circuit board. This way you can it securely in place (Photo 3). After this, you mount the PCB precisely and securely on top can pull the PCB with the components free of the breadboard. Download from the breadboard, turn it over, and then 080937-1: PCB layout (.pdf), from www.elektor. com/080937 trim all the leads protruding from the copper For the breadboard, we used a type SD12N side and solder them in place (Photo 4). The from Velleman [1], which is carried by a

3 4

Momentary Action with a Wireless Switch

Matthias Haselberger (Germany) RE1, which closes. At the same time, capacitor actuated as long as the current is sufficiently C3 charges via D5. When the contact of RE1 large. The current decreases as the voltage Many different types of wireless switch mod- switches, capacitor C4 provides the charg- on C4 rises, with the result that RE2 drops out ules with a relay for switching AC power loads ing current for C3. The charging current and the contact of RE2 (the ‘momentary’ con- are commercially available. However, some flows through the coil of RE2, which remains tact) opens again. applications require a short On or Off pulse, such as is provided by a momentary-action (pushbutton) switch. Here we describe a solu- * tion that simulates a pushbutton switch with S1 R1

a standard wireless switch. A supplemen- Ω D1, D2 = 27V, 0W5 tary circuit converts the switch module into 100 D3, D4 = 1N4004 a remotely controllable momentary-action 2W L +24V switch. D1 D2 D5 In the supplementary circuit, S1 is the switch- 230V ing contact of the relay in the wireless switch ( 120V ) 1N4148 module. This contact energises a 24-V power C4 D3 D4 supply connected directly to the AC power N C2 D6 RE1 outlet, consisting of a bridge rectifier (D1–D4) 1000µ R2 35V C1 100µ with a series resistor (R1), a series capacitor 24V 35V RE2 (C1), and a charging capacitor (C2). The two 220k C3 330n 1N4148 0W5 275V Zener diodes in the bridge rectifier (D1 and X2 1000µ 24V D2) limit the DC voltage on C2 to approxi- 35V mately 24 V.

When the wireless switch module closes con- 080912 - 11 tact S1, 24 VDC is applied to the coil of relay

7-8/2009 - elektor 27 S1 opens when the relay in the wireless to be a Class II relay. Due to the presence of switch module is de-energised, which causes Timing AC power line voltage, R1 and R2 must have RE1 to drop out shortly afterward and con- U ON OFF a rated working voltage of 250 V (150 V), nect capacitor C4 to ground. The capacitor although they can also be formed from two discharges through the coil of RE2, causing S1 resistors with half this rated working voltage its ‘momentary’ contact to be actuated again. t connected in series, each with half of the The timing diagram shows the switch-on and specified power rating. In this case, R1 con- +24V switch-off sequences of the wireless switch +14V +24V sists of two 47 Ω / 1 W resistors and R2 of two (S1 contact). 0 100 kΩ / 0.25 W resistors. Readers on 120 VAC t The duration of the ‘button press’ (engage- 60 Hz power networks should change C1 into ment time of RE2) depends on the capacitance RE2 680 nF. of C3 and C4. The equation Q = C × U = I × t The circuit can be fitted in a plastic enclosure t1 t can be used to calculate suitable capacitor 080912 - 12 with an integrated AC power plug, which can values for a specific hold time t( 1 in the tim- easily be plugged into the wireless switch ing diagram) with a given relay current. The module. The contact of RE2 can then be fed value shown in the circuit diagram (1000 µF) also means that a free-wheeling diode can- out to a terminal strip as a floating contact. corresponds to a hold time of 1 second with a not be used, but it is anyhow not necessary For adequate AC isolation, a safety clearance relay current (holding current IH) of 10 mA: due to the slow discharge of C4. RE2 should of at least 6 mm (air and creepage paths) to C = IH × t1 / U = (0.01 A) × (1 s) / 10 V = 1000 µF. be a 'Class II' relay (such as the Omron G6D- other conductors must be maintained, in A reed relay cannot be used for RE2 because 1A-ASI 24DC) to provide adequate insula- addition to using a Class II relay. the voltage across the coil reverses. This tion of the switch contact. RE1 does not have (080912_1)

Servo Scales

1 2

+6V IC2 7806 +9V...+15V Im a R8 C2 C3 R1

PWM/U R3 4k7 100n 100n PWM 220k U1 100k Servo IC1 M U2 3 7 6 TL081 2 4

R4 M1 470k R7 P1 D1 100R R5 5k 100uA FS 33k +6V R2 1N4148 R6 P2 C1 M1 b 0R1 100R 100k 100n ZERO OFFSET

PWM Servo 090086 - 12

With a bit of adeptness, you can build an rotated so that its measured position corre-

+6V electronic scales based on a servo motor. sponds to the desired position (U2 = U1). c Depending on the type of servo you use, it PWM can measure weights of up to around five kil- As can be seen from Figure 1, all you need

Servo ograms (11 lbs) with reasonable accuracy. for a scales based on a servo motor is a square-wave oscillator that supplies a sig- U(m) = U0 + K.m If you examine the operating principle of a nal at a constant frequency of around 50 Hz servo motor in more detail (Figure 1a), you with a fixed duty cycle of approximately 090086 - 11 can see that in simple terms, it consists of 10%. This defines a fixed setting for the posi- a control loop that uses a potentiometer to tion of the motor axle. If a mechanical force convert the motor position to a voltage that tries to rotate the motor axle in this situa- Gert Baars (The Netherlands) is compared to the voltage from a PWM con- tion, the servo control loop adjusts the drive verter. Based in this information, the motor is signal to the motor to counteract the rota-

28 elektor - 7-8/2009 tional force. The motor thus has to supply with 1 kg. Two kilograms would then draw Figure 2 shows a simple finished version an opposing force, and that costs power, 1 A, and so on. with a PWM oscillator and analogue read- with the result that the current through the The scales can also generate a voltage out- out. The two potentiometers can be used to motor increases. With a type RS-2 servo, this put if you measure the voltage across a sense adjust the offset and weighing range. The current can rise to as much as 1 A, while the resistor in series with the ground lead of the length of the scale arm multiplies the tor- quiescent current is no more than a few servo (Figure 1c). Due to the quiescent cur- sion on the servo motor due to the weight. dozen milliampères. If you attach an arm to rent consumption of the servo motor with no Doubling the arm length reduces the weigh- the motor axle and fit it with a weighing pan, load, this voltage is not zero with no weight ing range by half and thus doubles the accu- and then connect an ammeter in the servo on the scales, but it is low compared with the racy, but it also increases the zero offset due supply line, you have a sort of simple elec- value with a certain amount of weight. Natu- to the weight of the arm. In practice, an arm tronic scales. The scales can be calibrated rally, this offset can be compensated by using length of around 10 cm proved to be a good using a reference weight, with the length of an instrumentation amplifier. This increases compromise. the arm set to produce a certain amount of the accuracy, and you could even consider (090086-I) current with a certain weight, such as 0.5 A equipping the scales with a digital readout.

Driver Free USB

Richard Hoptroff (United Kingdom) embedded file system and data logger chips The chip takes the measurement and reports use the MSD interface. the result as a 4-byte response: 0x96 0x06 USB (universal serial bus) was supposed to A particularly flexible friend is called ‘expan- 0x02 0x36. solve a lot of problems when connecting dIO-USB’. As its name suggests, it is an I/O In this example, the voltage measured is 5 V devices to PCs, but in many ways it’s still a bit expander with a USB interface. But that’s × 0x0236 ÷ 0x03FF = 2.76 volts. Similarly, the of a pain in the plughole. Typically, each new a modest description, considering its ana- following command exchanges three bytes device needs a new driver to be installed. with a slave SPI device: Often, a COM port then gets assigned, and 1 you have to find out from the operating sys- VDD 0xAF 0x03 0x45 0x67 0x00. Command: Send

C2 C1

1µ 16V 100n 2

VDD 11.75 IC1 2.25 1.00-2.00 1.25 A RC0/AN4/C12IN+/INT0/VREF+ RST RC1/AN5/C12IN-/INT1/VREF- USB RC2/AN6/P1D/C12IN2-/CVREF/INT2 12.00 4. VSS RC3/AN7/P1C/C12IN3- 1 0.50 RC4/P1B/C12OUT/SRQ 1.00 3. D+ RC5/CCP1/P1A/T0CKI D- 2

RC6/AN8/SS/T13CKI/T1OSCI 3.00 2. D- RC7/AN9/SDO/T1OSCO D+ 3 EXPAND IO-USB 1.00 1. VDD RB4/AN10/SDI/SDA 4 RB5/AN11/RX/DT RB6/SCK/SCL B C RB7/TX/CK VUSB 090367 - 12

OSC1 OSC2 VSS

X1

C5 C4 C3

tem what the COM port number is. And with 22p 12MHz 22p 470n 0x45 0x67 0x00 to slave. some products, that COM port number can 090367 - 11 0xAF 0x03 0x00 0x00 0x89. Response: Slave change if you plug it into a different socket! sent 0x00 0x00 0x89.

A sneaky way round the driver problem is logue-to-digital inputs, interrupts, PWM, The commands are sent using the operating to use the Human Interface Device (HID), as comparators, counters, timers, SPI, I2C, UNI/ system’s HID interface, which is very similar to used by mice and keyboards, or the Mass O, etc. The USB interface is designed so that reading and writing to a file. Example source Storage Device (MSD) interface, as used by all the programming is done on the PC rather code is provided at [1]. flash drives. This is because just about all the than on the chip, which saves a lot of devel- flavours of Windows, Mac and Linux oper- opment time. For example, to measure the In the basic circuit of the driver, Figure 1, ating systems available today have HID and analogue voltage on AN6, you send the fol- only a crystal and filter capacitors are MSD drivers pre-loaded. HexWax Ltd. have lowing 4-byte command from the PC (0x pre- required in addition to the ‘expandIO-USB’ adopted this approach for their driver-free fix denotes hexadecimal): chip also described in some detail at [1]. USB chip sets. Their USB to UART, SPI and Although it is available as a through-hole I2C bridges use the HID interface and their 0x96 0x06 0x00 0x00 device, the surface mount version has the

7-8/2009 - elektor 29 advantage that it is small enough for ‘don- don’t mind a PCB 2.0–2.20 mm thick includ- vent over-insertion force. The overall PCB gle’-style applications as shown in Figure 2. ing tracks (arrow ‘A’ in Figure 2) for the width should be 16.00 mm or less. Surface mount USB plugs can be quite dif- dimensions. For best reliability, the PCB con- (090367-I) ficult to source, but an elegant, zero-cost tacts (‘B’) should be plated with hard gold Web Link solution exists. You can design one into the flash (0.25-1.27 μm) over nickel (2.6-5.0 μm). [1] www.hexwax.com printed circuit board itself, so long as you Finally, shoulders (‘C’) are required to pre-

Lighting Up Model Aircraft

Werner Ludwig (Germany) 14-stage binary counter and some minimal output selection logic. D1 +UB This circuit provides aircraft mod- Cycle time is determined by the ellers with extremely realistic bea- 1N4148 way the internal oscillator is con- C2 con and marker lights at minimum figured (resistor and capacitor on outlay. The project’s Strobe out- IC1 16 4µ7 25V LA1 LA2 pins 9/10) and can be varied within put (A) provides four brief pulses 7 quite broad limits. High-efficiency R1 CTR14 3 D2 AB 5 repeated periodically for the wing 1M 4 LEDs are your first choice for the 11 !G 4 R2 RCX 5 1N4148 (white strobe) lights. In addi- 10 6 indicators connected to the Bea- 180k RX + 6 9 14 tion the Beacon output (B) gives C1 CX 7 R3 con and Strobe outputs (remem- CT 13 T1 8 33k a double pulse to drive a red LED 15 ber to fit series resistors appropri- 4n7 9 R4 T3 1 for indicating the aircraft’s active 11 68k ate to the operating voltage Ub 12 2 BC557 operational status. On the proto- CT=0 12 and the current specified for the 3 13 T2 type this is usually a red rotating BS170 LED used).

beacon known as an Anti-Collision 8 4060 R5 Light (ACL). The circuit is equally BS170 The sample circuit is for operating useful for road vehicle modellers, 33k voltages between 5 and 12 V. Cur- who can use it to flash headlights rent flow through the two BS170 FET and blue emergency lights. 090036 - 11 devices must not exceed 500 mA. All signals are generated by a 4060 (090036-I)

LED Bicycle Lights Ian Field (United Kingdom)

Before getting started an acknowledgement L1 * D4 is due, the circuit presented here uses an 220u 1N4148 D6 ingenious method of controlling a flyback D1 D2 converter by the voltage developed on a cur- 1N4148 1N4148 D7 rent sensing resistor, this was published by R1 Andrew Armstrong in the July 1992 issue of C3 T1 NTD4815N BT1 D

4k7 D8 C1 C2 D5 C4 ETI magazine. 100p * The reworked circuit is quite simple. At the G 6V 100uF 2u2 10u D9 25V 63V T2 22V instant that power is applied only a small cur- S 1W3 63V R2 NTD4815N rent flows to charge C4 so insufficient voltage 1k R4 is developed on R3 to switch T2 on. Also, D1 BC337 D3 G S allows C2 to charge from the 6 V battery, so 1R D R3 R1 feeds enough voltage to switch on T1 — 12R* this shunts the voltage across L1 and the cur- 1N4148 080702 - 11 rent in it starts to rise. At a certain point the current which returns via R3 will develop suf- ficient voltage to switch on T2 which shunts the gate voltage to T1 causing it to switch off, tor R3, this keeps T2 turned on and T1 turned ing edges. Components D1, D2 & C2 form a initiating the flyback voltage from L1. The fly- off, so the flyback phase is not clamped until bootstrap boost circuit for the MOSFET gate, back pulse forces a current around the circuit, it has given up all its energy. Capacitor C3 although it is logic level it only guarantees charging C4 and feeding the LEDs. As the provides positive feedback to ensure reli- the stated RD-S(on) at a Vg level of about 8 V return current is via the current sensing resis- able oscillation and sharpen up the switch- — by happy coincidence the combined Vf of

30 elektor - 7-8/2009 four ultrabright red LEDs is about 8.8 V and lead inductors disguised as resistors — even and the Ultralight but there should be many this is the value that the output is normally the fat ones last only a few seconds before others that can be modified to house the clamped to. failing with shorted turns. stripboard. In many cases the hole for the On R3, this resistor is selected depending on bulb will need 4 notches cut with a round file There are some notes on the components the configuration of LEDs. A value of 20 mA so that the LEDs can be pushed far enough specified. For position T1 an n-channel MOS- is fairly typical for 5 mm LEDs, on this basis through. These can be secured in place with

FET with a very low RD-S(on) of 15 mΩ (at 10 V) four red LEDs will need about 12 Ω; five red a spot of hot melt glue. Is suggested, although its high ID rating (35 A) LEDs about 10 Ω, and four white LEDs about The battery and switch box can be surpris- is not strictly necessary. Purists may wish to 6.8 Ω. Resistor R4 (1 Ω 1%) is provided to use ingly challenging, the unit built for a fam- use Schottky barrier diodes for D2 and D4, as a temporary connection for the LEDs’ neg- ily member went on a bicycle with a wire but a quick look at the data sheet for the ative lead so the volt drop can be measured basket so it was easy to bolt a Maplin ABS

popular BAT85 shows that with a Trr of 4 ns it to indicate the current flowing during setting project box to that. With only the tubular is not actually any faster than the 1N4148. It the correct LED current by adjusting R3. frame to fix things onto, it’s not so easy. The

is doubtful whether the lower Vf would make The efficiency of the circuit depends on the authors’ battery box for the present project any noticeable difference. LED current, which also determines to some is an old Halfords lamp — the one that drops Zener diode D5 has been included as a safety extent the switching frequency. At 10 mA (4 into a U shaped plastic clip that does noth- measure in case the output should ever find white LEDs) 170 kHz was measured on the ing to deter thieves, but it’s far more secure itself open circuit. The flyback converter can prototype — and that’s about the maximum when cut down to make a battery box and develop a quite impressive voltage when normal electrolytic capacitors are able to clamped to the handlebar with a jubilee clip. run without load and would have no diffi- withstand. If more current is drawn (e.g. three It easily holds a 6 V 1.3 Ah SLA battery from culty damaging the MOSFET. If a higher volt- white LEDs at 30 mA) then the switching fre- Maplin but any nominal 6 V type can be used age MOSFET is used then C4 could easily fall quency drops to about 130 kHz and the effi- as per individual preference. Deep discharg- prey to excessive voltage if the lead to the ciency rises to around 75%. ing should be prevented. LED breaks. In the final working prototype D5 The circuit is simple enough to construct on was a 1.3-watt 22-volt zener, but any value stripboard, which can be built as a single or Please Note. Bicycle lighting is subject to between 18 and 24 V is fine. Bear in mind that double unit to suit whatever lamp housings legal restrictions, traffic laws and, addition- with four white LEDs on the output the volt- are ready to hand. The double unit should fit ally in some countries, type approval. age will be somewhere in the region of 13 V. comfortably in a 2x D cell compartment and (080702-I) L1 is a 9 mm diameter 0.56 A 220 µH inductor the single board is only a whisker bigger than with a low DC resistance (Farnell # 8094837); a single C cell. don’t even think about using those small axial Suggested lamp housings are the Ever Ready

Remote Washing Machine Alert

Götz Ringmann (Germany) on C1 starts to fall. Changing the value of R1 will increase It is often the case these days D1 U+ sensitivity if the LED is not that the washing machine R1 bright enough. and tumble dryer are When the voltage on C1 falls installed in an outbuilding 4 8 4 8 below 1/3 of the supply volt- 1M...2M2 or corner of a garage. This R R age IC1 switches its output 7 7 DIS DIS not only makes the kitchen IC1 IC2 T2 (pin 3) High, removing the R3 R5 ICM7555 3 ICM7555 3 a much quieter place but 4M7 reset from IC2. T2 conducts OUT OUT 4k7 2 2 also leaves room for a dish R2 TR TR and LED D1 is now lit, sup- 6 6 washer and gives additional 4k7 THR THR BC237 plying current to charge C2. T1 CV CV cupboard space. The prob- C1 C2 When the voltage across lem now is how to tell when 5 1 5 1 C2 reaches 2/3 supply IC2 100n 22µ the wash cycle is finished. In Tant. switches its output Low and bad weather you don’t want 081156 - 11 C2 is now discharged by pin to make too many fruitless 7 via R3. The discharge time trips down the garden path is roughly one minute before just to check if the wash cycle is finished. light output (they are often driven by a mul- the transistor is again switched on. The proc- The author was faced with this problem when tiplex signal) producing a more stable DC ess repeats as long as light is falling on T1. he remembered a spare wireless door chime voltage to inputs 2 and 6 of IC1. The circuit he had. With a few additional components is battery powered so the CMOS version of Transistor T2 is a general-purpose small sig- and a phototransistor to passively detect the familiar 555 timer is used for IC1 and IC2. nal NPN type. The open collector output is when the washing machine’s ‘end’ LED comes The output of IC1 (pin 3) keeps IC2 reset (pin wired directly in parallel with the bell push on, the problem was solved. 4) held Low while there is no light falling on (which still functions if the transistor is not T1. When the wash cycle is finished the LED switched on). Ensure that transistor output is C1 smoothes out any fluctuations in the LED lights, causing T1 to conduct and the voltage wired to the correct bell push terminal (not

7-8/2009 - elektor 31 the side connected to the negative battery transmitter battery. Alternatively a 9 V bat- range of the wireless doorbell to make sure terminal). tery can be substituted; it has much greater the signal reaches from the washing machine capacity than the original mini 12 V battery to wherever the bell will be fitted. Each timer consumes about 60 µA quiescent fitted in the bell push. (081156) and the circuit can be powered from the Before you start construction, check the

Freezer Trick

Reuben Posthuma (New Zealand) Thirdly, the low temperatures can (sort of) rejuvenate the chemicals in the battery, There are a number of explanations to why which results in a ‘good as new’ battery! putting devices in the freezer often repairs them. Firstly, cooling PCBs down to minus Although any or all of the above explana- 20 degrees Celsius or so can often repair tions may be refuted scientifically, the ‘he dry joints, because of the effects of expan- who dares, wins’ approach prevails. In other sion/contraction due to temperature change. words, no harm in giving it a try. Be sure to Although the wholesome effect of a night in use good quality plastic bags to securely the freezer may be temporary, it may help package circuit boards, components or bat- you track down rare or otherwise elusive teries before putting them into the freezer. errors in circuits. This will eliminate any risk of contaminating Secondly, with rechargeable batteries on which effectively resets corrupted memory foodstuffs. boards, the cold temperatures basically cause by causing a complete ‘factory’ reset to be (090205) the cell(s) to do a complete discharge cycle, performed.

LEDify It!

ment bulb an LED exhibits differential resist- Mobile 3-watt LED Lamp Features ance i.e. its resistance depends on the applied • Three 1 W LEDs powered from 4.8 V Jürgen Stannieder (Germany) voltage. It is necessary to supply it with a con- • Efficiency > 80 % stant current. This can be achieved (approxi- A traditional hand-held torch could hardly • Light output independent of battery voltage mately) by using a series resistor but power be described as a cutting-edge piece of tech- loss in the resistor reduces efficiency. Also, • Battery deep-discharge protection nology; in fact it’s probably the exact oppo- light output will decrease as the battery volt- site, circuits don’t come much age sinks. The LEDify design simpler! Text books have for solves both these problems: years used a battery, light firstly, a switching regulator bulb and switch to describe reduces losses and maintains just what a circuit is. We are a constant light output as the also aware of the shortcom- battery voltage falls. Secondly, ings of the filament lamp; the an adjustable constant current light dims as the battery dis- source maintains stable oper- charges and occasionally you ating conditions for the LEDs. need to replace a burned- The LM2577T-ADJ step-up out bulb. Why not treat an voltage regulator [1] forms old torch to a 21st century the centre point of the design. make-over? Replace the bulb Together with coil L1 and the with more efficient LEDs, the flywheel diode D1 it boosts 5 mm 70 mW types will not be the input voltage from 4.8 V very illuminating but 1-watt up to 10 to 12 V. The 4.8 V white LEDs are now reasona- input is provided by four bly priced. NiMH rechargeable batteries connected in series while the It’s not quite as simple as 10 to 12 V output is used to removing the bulb and replac- power three series connected ing it with an LED. Unlike a fila- white LEDs. One half of the

32 elektor - 7-8/2009 L1 D1

100uH 1N5822 K1 R5 R2 R6 R9 C9 8 A

k 100k IC2

1k 1k P3 S1 22 IC1 100n 4 K 5 4 3x 1W IN SW Lumileds 5k 3 T1 BT1 P2 1 2 P1 R11 CMPEN FB 6 1 D3 IC2A 560R 4V8 R1 7 2 C2 C3 GND C4 C5 C6 R7 IC2B C8

2 5 3 100k BD139 10k 2k LM2577T- 10k 1N4148 47u 100n 470u 470u 100p 25V 100n ADJ 16V 16V R10 R8 4k7 R4 R3 D2 R12 R13 R14 R15 C1 C7 3M9 2 1k 1R 1R 1R 1R

2k IC2 = LM358 330n 10u 2V7 0W5 25V 080585 - 11 dual op amp IC2 forms an adjustable current tors. With the LM358 even with the input at voltage of around 3 V to over 10 V. Although source while the other half switches the light zero there will be an output voltage of 0.6 V four cells are shown in the diagram the cir- off when the supply voltage sinks too low to so with P3 at a minimum a few milliamps will cuit can accommodate anything from three avoid discharging the cells too much. still be flowing through the LEDs. to six. Do not use more than six cells when IC2A is configured to generate a constant driving three LEDs in series, the input volt- current. Zener D2 supplies a reference 2.7 V The LEDs are turned off when the battery age would produce excessive dissipation in at its cathode which is divided by the R9/P3 voltage falls too low, IC2B comparing a pro- IC1 which can result in the battery voltage network to supply an adjustable voltage of portion of the battery voltage via P2 with being applied directly to L1 and D1. The volt- 0 to 128 mV to the non-inverting input of the reference voltage on D2. If the battery age step-up function of IC1 ensures that the IC2A. IC2A controls T1 so that the voltage voltage is below the reference voltage the cathode of D1 is at a higher voltage than the at its inverting input, produced by the volt- output of IC2B will go high and the current anode so D1 is not conducting. When the IC age drop across the resistors R12 to R15, is source IC2A will be switched off. The circuit output switches, energy stored in L1 is con- the same as at its non-inverting input. The still draws a few milliamps when under-volt- verted into a higher voltage but lower cur- adjustment range of P3 produces a current age is triggered so a good lower threshold to rent passing through D1 and then stored on of between 0 and almost 0.5 A through the set is around 1 V per cell. With four cells P2 capacitors C5 and C6. The 52 kHz switching 0.25 Ω resistor formed by the four parallel 1 Ω should be adjusted so that the LEDs switch frequency gives a stable output voltage with resistors. The typical operating current of a 1- off when the battery voltage falls below 4 V. very little ripple. watt LED is around 350 mA, this produces a IC1 reads the feedback voltage measured voltage of 88 mV across the four parallel resis- The adjustment range on P2 produces a at pin 2 and compares it with a reference

COMPONENT LIST Inductor L1 = 100µH axial, upright mounting, suggested types: 5800-101 (Bourns) rated 0.63A/0.2Ω (Digi- Resistors Key # M8290-ND), B82111EC25 (Epcos) rated at R1,R3 = 2kΩ2 1A/0.65Ω (Farnell # 9752102) or MESC-101 (Fastron) R2 = 22kΩ rated at 1A/0.65 Ω (Reichelt # MESC 100µ) R4,R5,R6 = 1kΩ R7,R9 = 100kΩ R8 = 3MΩ9 Semiconductors R10 = 4kΩ7 D1 = 1N5822 R11 = 560Ω D2 = 2V7 0W5 zener diode R12,R13,R14,R15 = 1Ω D3 = 1N4148 P1,P2 = 10kΩ preset, miniature, horizontal T1 = BD139 P3 = 5kΩ preset, miniature, horizontal IC1 = LM2577T-ADJ (TO-220-5 case, straight pins) IC2 = LM358 (DIP-8) Capacitors C1 = 330nF MKT lead pitch 5mm or 7.5mm Miscellaneous C2 = 47µF 25V radial, lead pitch 2.5mm, ø max. K1,S1,BT1 = 2-way PCB terminal block, lead pitch 8.5mm 5mm C3,C4,C9 = 100nF ceramic, lead pitch 5mm S1 = single-pole on/off switch C5,C6 = 470µF 16V radial, lead pitch 2.5mm, ø max. BT1 = holder for 4 NiMH batteries* 8.5 mm 3 pcs 1-watt power LED C7 = 10µF 63V radial, lead pitch 2.5mm, ø max. PCB # 080585-1 6.5 mm C8 = 100pF ceramic, lead pitch 5mm * see text

7-8/2009 - elektor 33 of 1.23 V. It adjusts the peak switch current than two hours. The circuit efficiency is over too low. Lastly adjust P2 so that the LEDs turn accordingly to maintain a constant output 82 % with a 4.8 V battery pack and around off when the supply drops below 4 V. Should voltage. The divider chain formed by R2, R3 89 % with a 5.6 V battery. the LEDs not light at all check that P2 has not and P1 allow the output voltage to be var- been set too high. ied between 3.5 V and 19 V. A typical 1 W LED The set up procedure for the completed cir- (080585-I) has a forward voltage drop of around 3.25 V. cuit is simple. Using an adjustable power Three LEDs in series gives 9.75 V, when the supply set the output voltage to 4.8 V. Con- Internet Links voltage drop across T1 and R12 to R15 are nect three LEDs in series to the anode and [1] www.national.com/mpf/LM/LM2577.html added to this we get 10 V. The adjustment cathode (A, K) contacts of K1 and adjust P1 [2] www.elektor.com/080585 range of P1 is sufficient to cater for LEDs with so that the voltage measured between the a forward voltage drop of up to 4.0 V. A connection of K1 and ground is 12 V. Now set the current by adjusting P3 until 88 mV is Download In the Elektor lab we measured a supply cur- measured across resistors R12 to R15. To oper- PCB rent of 0.87 A from the 4.8 V battery pack ate the circuit at optimum efficiency reduce 080585-1 PCB design (pdf) from www.elektor. giving a current through the LEDs of 0.35 A. the 12 V supply by adjusting P1, check that com/080585 Using 2000 mAh rechargeables you can a constant 88 mV is maintained across R12 expect a full battery pack to last for more to R15, if it starts to fall then you have set P1

Annoy-a-Tron

Tolunay Gül (The Netherlands) the code starts with a regfile that states which AVR is used. This is The idea for this circuit came followed by the Xtal/internal from the website www.think- oscillator choice. Next come the geek.com [1]. The author thought software and hardware stack, that it could be made better and the frame size and the config- simpler. A search on the Internet uration settings. First portb.3 didn’t get any results so the next is configured as an output and logical step was to design some- given the name ‘speaker’. Then thing himself. With the help of a the variable ‘seconds’ is defined small AVR microcontroller from as a ‘word’ type. the spares box and a buzzer the When the AVR is turned on it first experimenting could begin. comes to an endless loop. In this it checks if the mode jumper is The circuit consists of little more in place or not. If it’s not in place than the AVR micro, a buzzer (a logic ‘1’ caused by the pull-up and an ISP header to program resistor) the micro jumps to sub1. the code into the microcontrol- Here it comes to an endless loop ler. Apart from two resistors, a again. Within this loop it creates jumper to select the mode and a constant beeping noise. an on/off switch, the circuit just JP1 needs a battery. The author PWR R1 R2 When the mode jumper is put in

used an old battery from a Nokia 10k 10k place and the power is removed mobile phone because it had a from the circuit and then reap- large capacity, but was still fairly plied (a reset), the controller BT1 K1 small. In principle a small but- 10 1 once more comes to an endless IC1 8 ton cell and a holder will suffice 9 2 loop. However, this time it sees 8 3 1 3V6 PB5/RST/ADC0 as well, and possibly even some 7 4 6 3 a ‘0’ because the jumper pulls PB1/AIN1/CC0B/INT PB4/ADC2 6 5 5 2 solar cells from an old calculator PB0/AIN0/OC0APB3/CLKI/ADC3 the I/O pin to a low level. This 7 could work. PB2/ADC1/T0 causes the program to jump to ISP BZ1 sub2. This is again an endless 4 ATTINY13 The mode switch is used to JP2 loop, which immediately gen- choose between normal mode erates a beep. It then generates and a test mode. In the latter MODE a random number from 0 to 50, mode the Annoy-a-Tron will 090084 - 11 adds one to it and stores it in the beep constantly. In normal mode variable ‘seconds’. The number the tone generator creates irritat- in ‘seconds’ is then multiplied ing beeps with a random pause of 10 to 500 The controller obviously needs a program by 10 to obtain a longer pause before the seconds between successive beeps. written for it. As is usual for BASCOM-AVR next beep. The program then waits for the

34 elektor - 7-8/2009 required number of seconds before jumping circuit could be made very small. The soft- Internet Links back to the beginning of the loop. ware can be downloaded from the Elektor [1] www.thinkgeek.com/gadgets/electronic/8c52 website [2]. [2] www.elektor.com/090084 The circuit can be easily built on a piece of (090084) stripboard. Alternatively, an SMD board could Download be designed, which means that the resulting 090084-11: source code and hex files, from [2]

Simple Wireless and Wired Emergency Stop System

Jacquelin K. Stroble (USA) low voltage PNP and NPN switching +24V transistors respectively, for which

This circuit allows a cheap or dis- S2 many equivalents exist. carded wireless doorbell set (i.e. transmitter and receiver unit) to be MOTOR As an EMC precaution, small capaci- RESTART used as a remote emergency stop tors (100 pF) are fitted across base resi- on a high-power electrical motor D1 D2 RE1 stors R1 and R2, preventing the motor or motor controller system. from being shut down by external 2x 1N4004 electrical noise and interference. The When the button on the wireless set and reset coils of the latching relay doorbell unit is pressed, the resul- each have a flyback diode to prevent ting 0 V signal from the receiver BC557B back-emf peaks damaging T1 and T2. R1 unit (‘motor E-Stop’) causes PNP C1 The contacts of the latching relay can

transistor T1 to be turned on. Via 10k MOTOR be used to switch a more powerful E-STOP ANT1 T1 transistor T2, latching relay Re1 100p S1 relay, or a motor driver. (090148-I) then changes state. The same is +5V achieved when the wired Motor T2 E-Stop button, S1, is pressed. The R2 reset button, S2, must be pressed C2 MOTOR to reverse the state of the latching E-STOP 1k relay. 100p

The choice of T1 and T2 is not cri- BC547B 090148 - 11 tical — they are general purpose,

Desulphater for Car Batteries

Christian Tavernier (France) PbSO4 Unfortunately, with the passing of time and successive charge/discharge cycles, the sec- Even if you take great care of your car or This indicates that, in contact with sulphu- ond reaction, i.e. the one that converts the motorbike battery, you’re bound to have ric acid, the porous lead of one plate and the lead sulphate back into lead, becomes incom- noticed that its life is considerably shorter porous lead dioxide of the other are both plete, and leaves some lead sulphate on the than the high purchase price and sales pitch converted into lead sulphate and water. Dur- surface of the battery plates. As this is a poor probably led you to expect. Of course there ing charging, the following reverse chemical conductor, it tends to get thicker in places are several reasons for this, and high on the reaction occurs: where it has started to collect, and unfortu- list is the phenomenon of slow but inevitable nately this phenomenon of sulphating, for sulphating of the plates. To understand prop- PbSO4 + 2H2O + PbSO4 —> Pb + 2H2SO4 + that’s what it’s called, is cumulative and gets erly what this involves, we need to look at a PbO2 worse and worse as time goes by. bit of chemistry. Once a battery has got badly sulphated This time, the electric current being passed beyond a certain point, no standard charging A lead/acid battery exploits a chemical converts the lead sulphate and water into process is able to recover it. What happens reaction which is written as follows, when lead, lead dioxide, and sulphuric acid. In the- is that, because the lead sulphate Is a poor discharging: ory, the reaction is totally reversible, which is conductor, the battery’s Internal resistance why a battery can be charged and discharged Increases, which In turn reduces the charging Pb + 2H2SO4 + PbO2 —> PbSO4 + 2H2O + a great many times. current, and thereby the effectiveness of the

7-8/2009 - elektor 35 charging chemical reaction; cially if you use the printed cir- this in turn leaves even more +12V cuit board design suggested lead sulphate on the plates… [1], but for optimum perform- R1 and so it goes on, in a vicious C5 ance, you do need to pay care-

circle. There is a chemical 470k ful attention in choosing the 4 8 100µ process that makes it possible 25V components. R low ESR 7 to eliminate the lead sulphate R2 DIS The inductors used must IC1 T1 from a battery before it’s too R3 not be changed. They are

22k 3 D1 OUT 330 late, but it’s a tricky opera- C1 2 555 available, for example, from TR C4 tion and uses highly corrosive 6 THR Radiospares (RS Components) IRF9540 100 15V chemicals that are danger- µ CV 47n as part numbers 228-422 (L1) 25V 0W4 ous to handle. What’s more, 5 1 L1 and 334-9207 (L2). Diode D2 many of the batteries sold 220µH is a readily-available type and these days are sealed and so C3 C2 3A5 should only be replaced if this it’s impossible to gain access 2n2 100n L2 D2 is unavoidable, and then only to their electrolyte without 1mH by an ultra-fast device. Capac- damaging them. R4 1A BYW29-100 itor C5 must be a low series 220 The project we’re suggest- 081175 - 11 resistance type, such as those ing here lets you desulphate intended for switch-mode your battery electronically — power supplies. As can be and the sooner you start doing it, the more mark/space ratio of the signals produced. seen from the component overlay of the PCB effective the process will be. It is based on designed by Elektor Labs, T1 and D2 are fit- research carried out in the United States, Construction shouldn’t be any problem, espe- ted with small U-shaped heatsinks designed which showed conclusively that if you to take TO-220 packages. apply short, high-amplitude pulses to It is advisable to install the circuit into the battery, the resulting ionic agita- an earthed metal case, as it generates tion produced at the battery electrodes quite severe electromagnetic interfer- gradually breaks up the lead sulphate ence that it’s best not to allow to radi- crystals. Even if you’re a bit sceptical ate out as it is likely to upset the oper- about the effectiveness of this process, ation of other equipment. EMC regu- you can try it out for yourself without lations and recommendations apply any great financial risk, as the circuit here. required is simple and cheap. Nothing The battery connection must be ventured, nothing gained! made using short wires, of at least 2.5- The circuit used is very similar to the 3.0 mm² gauge (AWG # 12-13), securely one currently to be found in the United connected to the battery terminals, States, where this type of desulphat- since for the process to be effective, it’s ing process is popular as well as wide- important to minimise any series resist- spread. Apart from a few details, it’s ance between the circuit and the bat- pretty much like a ‘boost’ type switch- tery. If necessary, it can be left perma- mode power supply unit (SMPSU) — nently connected. i.e. one that steps up the input voltage. IC1 Some writers and pundits advise connecting is wired as an astable multivibrator running COMPONENT LIST a charger (even a low output one) to the bat- at a frequency of the order of a kilohertz and tery at the same time, to avoid the circuit’s generates very short mark/space (on/off) Resistors discharging the battery in the long term. But ratio pulses at its output. R1 = 470kΩ we would not recommend doing so, since the When T1 is turned off by the level of these R2 = 22kΩ charger’s relatively low output impedance R3 = 330Ω pulses, capacitor C5 is able to charge up to R4 = 220Ω distorts the pulses produced by the circuit the battery voltage through inductor L2. and hence diminishes its effectiveness. When T1 turns back on again, which happens Capacitors for only a very short time, given the mark/ C1 = 100μF 25 V Cautionary advice. If you use this des- space ratio of the pulses, capacitor C5 dis- C2 = 100nF ulphater directly on your vehicle battery, charges abruptly via T1 and L1. When T1 then C3 = 2nF2 remember to disconnect at least one of the turns off again, the inductor L1 means that C4 = 47nF connections to the battery, as the parallel C5 = 100μF 25 V, low ESR the discharge current can’t stop instantly. So impedance of the many devices that stay per- it is obliged to pass through the battery via manently powered in modern cars once again Semiconductors diode D2. D1 = 15 V 0.4 W zener diode diminish the effectiveness of the system. With a high-quality capacitor for C5 (mean- D2 = BYW29-100 (081175-I) ing a device with a low ESR) and a short con- IC1 = NE555 Internet Link T1 = IRF9540 nection in heavy-gauge wire from the circuit, [1] www.elektor.com/081175 we can push a peak current of some 5 to 10 A through the battery. Despite this, the power Inductors consumption of the circuit is still fairly low, of L1 = 220μF 3.5A Download L1 = 1mH 1A the order of 40 mA, because of the very low 081175-1: PCB layout (.pdf), from [1]

36 elektor - 7-8/2009 0907_elektor_adv_UK.indd 37 05-06-2009 13:25:14 Stereo Widening

Huub Smits (The Netherlands) many portable devices, ghettoblasters and also contains part of the sound from the right PC loudspeakers, even though it is usually channel, shifted a little in phase compared Although the principle is quite old, ‘widening’ called something else in these applications. to the right channel. The same is true for the of the sound image is still done these days in To generate the stereo image, the left channel right channel, where the signal from the left

+12V +12V C3 C7 +12V 100n

100n C11 L R1 3 7 6k8 R3 6 3 7 100n IC1 6k8 R22 2 6 L – R R4 IC3 6k8 4 2 3 7 6k8 R23 L 4 6 6k8 IC5 2 C8 4 C4 R25 100n 6k8 100n R24 –12V C12 –12V R7 6k8 6k8 100n

R8 –12V 470R

R9 470R

R10 S1 560R A1 A2 R11 A3 C1 560R A A4 A5 10µ R12 63V A6 510R +12V +12V C5 +12V C9 100n C13 R5 100n R R2 6k8 3 7 100n 6k8 R6 6 3 7 IC2 6k8 R26 2 6 L + R 3 7 IC4 6k8 R 4 2 6 R27 IC6 4 2 6k8 4 R13 C10 R28 C6 6k8 6k8 100n 100n C14 –12V –12V R14 100n C1 510R C2 –12V C3 C2 R15 C C4 1k1 C5 10µ R21 63V C6 1k3

R16 1k6 R20 1k8

IC1...IC6 = TL071 R17 1k1

R18 1k6

R19 2k2 090174 - 11

38 elektor - 7-8/2009 channel is slightly shifted in phase. To make the right signal is increased if the left signal the final left and right signal from the (L+R) the stereo image ‘wider’, you can amplify the reduces. To maintain a constant volume, we and (L–R) signals. difference signals of both channels. also have to make sure that the total signal For additional protection, electrolytic strength remains the same. coupling capacitors of 10 μF 16 V can be To do this you generate a sum- and a dif- added to the inputs and outputs. Each of ference signal from the left and right chan- From the schematic you can see how this the inputs of IC1 and IC2 will then also need nels. With a couple of opamps you can real- problem was solved. IC1 and IC2 are the a 10 kΩ resistor to ground, otherwise the ise a ‘left+right’ signal and a ‘left-right’ signal. input buffers. After the buffer, the left and opamp outputs will run up against power So the (left–right) signal needs to be made right signals are combined with the other supply rail. stronger with respect to the (left+right) sig- channel respectively. IC3 generates the nal. Expressed as a formula: (L–R) signal and IC4 the (L+R) signal. With The power supply requires a symmetrical two times six resistors and a multi-posi- voltage of ±12 V. This voltage can usually be (L+R) + (L–R) = 2L and (L+R) – (L–R) = 2R tion switch, the amount of the effect can found in an existing amplifier, so normally be adjusted. The values of resistors R7–R12 there is no need to build a special power With a suitable circuit, the left signal in the and R14–R21 are selected such that the supply. left channel is increased and the right signal total volume remains about the same when (090174-I) is decreased. Similarly, in the right channel changing the switch. IC5 and IC6 generate

SMD Transistor Tester

Ludwig Libertin (Austria) out the need to hook up an external transis- tor (and the extra bother). Features • Standalone SMD transistor tester No sooner said than done. The result is a • Identifies defective transistors project that’s equally useful as a simple ‘test • Distinguishes NPN from PNP connector’ hook-up for the TUT and as a sim- ple transistor tester. The very minimalist cir- cuit consists of a CD4049 (CMOS HEX inverter/ which in turn feed IC1.B and IC1.E. If no tran- buffer) and a few additional components — sistor under test is connected, LEDs D1 and naturally all in SMD form factor. IC1.D and IC1. D2 will both flash together in anti-phase and C together with R1 and C1 form a squarewave half the operating voltage will be present at generator with a frequency of around 2 Hz. base connection B. This drives inverters IC1.A and IC1.F (con- The article ‘SMD Soldering Aid’ by Gert Baars nected in parallel for higher output current), Now insert a transistor in the test device: in the December 2005 issue of Elektor [1] was the original inspiration for a truly ‘electrome- chanical’ version of this design for a transis- tor tester for SMD transistors in SOT23 case S1 D5 outline. However, Gert’s strip metal construc- BAS32 tion method was not chosen and instead an TEST alternative design was created out of strips 1 R4 R3 IC1 of soldered PCB material. Glassfibre epoxy 1k 8 1k5 resin PCB material cannot compare with strip R1 B metal for springiness so the spring from a dis- 1M carded ballpoint pen was used, which pro- BT1 IC1.D IC1.C IC1.A IC1.B C2 vides adequate clamping pressure. The key 9 10 7 6 3 2 5 4 1 1 1 1 advantage of this choice of materials is that 100n the TUT (transistor under test) is pressed hard 12V onto three PCB tracks that lead directly to IC1.F IC1.E C1 R2 14 15 11 12 sockets into which a conventional transistor 1 1 1k C tester can be plugged. It really is this simple 220n

(without any soldering) to check whether the D1 D2 TUT is flaky or worth keeping for reuse. IC1 = 4049 PNP NPN

The actual procedure for using this SMD tran- D3 D4 sistor tester is no different from checking out transistors that have wire leads. In most cases BAS32 BAS32 E all you are interested in is whether the TUT 060267 - 11 is dead or alive and also if it is of the NPN or PNP variety. This much you can discover with-

7-8/2009 - elektor 39 flashes. In similar fashion only D1 flashes for a PNP device. The circuit draws only 10 mA or so and using pushbutton S1 for opera- tion means that the battery will have a very long life.

The type GP23A 12 V battery is an inte- gral part of the mechanical structure and is clamped between the upper and lower printed circuit boards. A small section sawn from a piece of plastic pipe is used as a de facto battery clip glues to the vertical printed circuit board improves stability (2). The nail- like metal pin is passed through a small ring of brass soldered to the upper PCB. To sim- plify the task of replicating the PCBs the author has made the layout files of the three both LEDs flashing indicate an open circuit, small PCBs available on the article’s web page Internet Links in other words the transistor is defective. An [2]. To use these you will not need the full ver- [1] www.elektor.com/magazines/2005/december/ internal short circuit (connection between C sion of the Sprint-Layout software, as you can smd-soldering-aid.57995.lynkx and E) is indicated by the two LEDs glowing open the files just as well with the free Viewer [2] www.elektor.com/060267 dimly. A functional NPN transistor conducts programme [3]. [3] www.abacom-online.de/html/dateien/demos/ splan-viewer60.exe only when the voltage on C is higher than on (060267) E. LED D1 Is now short-circuited and only D2

COMPONENT LIST Semiconductors D1, D2 = LED, 3 mm D3, D4 = BAS32 Resistors IC1 = 4049 (SO16) R1 = 1MΩ R2 = 1kΩ R3, R4 = 10kΩ Miscellaneous S1 = pushbutton, push to make Capacitors 12 V battery GP23A C1 = 220nF Mechanical parts as C2 = 100nF described PCBs (see text)

TL431 Multivibrator

Gilles Clément (France) tor that ‘shorts’ the cathode to the anode. So

Here the TL431 ‘super zener’, an easily- the cathode voltage Vk has two stable states: Oscillators have a certain appeal to electron- sourced standard device, is made to oscillate. Vk = Vsupply if Vref < 2.5 V and Vk = 2 V (the Vce ics enthusiasts. They’re rather ‘alive’ because It’s a 3-pin IC: cathode, anode, and ref. input. of the transistor) if Vref > 2.5 V. A bit like a there’s something ‘beating’ inside them, An op amp compares Vref with an internal transistor that works with voltage instead isn’t there? 2.5 V reference and drives a bipolar transis- of current, so with a little effort it should

+10V

R2 R3 R4 R1 Ω Ω 42Hz 82k 82k 270 270

IC2 IC1 C2 C1

270n 270n C3 TL431A TL431A 10p

081167 - 11

40 elektor - 7-8/2009 be possible to force it to oscillate between free) LTspice simulator [2]. The frequency is not needed in the real circuit, which makes these two states. defined by R and C (and of course the sup- use of natural asymmetries. If two TL431s are wired as an astable multivi- ply voltage). It gives a very good squarewave The author’s LTspice model is available for brator you’ll find that it works! But actually, it (see scope trace) up to around 50 kHz. The free download from [3]. ought not to, since the op amp’s V+ input is signal is much better than using bipolar tran- (081167-I) unable to sink the capacitor charging current! sistors. However, the low voltage stays at 2 V, So, how does it work then? but this can be solved by using a FET on the Internet Links In fact, the current passes via a stray internal output, or by using similar ICs with lower ref- [1] www.datasheetcatalog.org/datasheet/calogic/ diode between Vref and the cathode (which is erence voltages like for example the TLV431 TL431.PDF certainly noted on some data sheets like [1], (threshold 1.24 V) or the ZXRE060 (threshold [2] www.linear.com/designtools/software/#Spice but not on all of them). 0.6 V). [3] www.elektor.com/081167 The 10 pF capacitor C3 is only there to make This was checked using the excellent (and the LTspice simulation start up correctly; it’s

S-video Converter

Christian Tavernier (France) video signal into a composite signal and so that our CRT television is expecting to see. will perhaps enable you to give a new lease In order for this recombination to be cor- With the astonishingly rapid growth in the of life to your old CRT television. rect, there is just one constraining factor market for flat-screen TVs and high-defini- to be taken into account, concerning the tion TV, many CRT television sets have been The principle of S-video is very simple, as respective levels of the components, as the consigned to the attic, even though many of it merely consists of carrying the chromi- chrominance one is only half the amplitude them were still working perfectly and could nance and luminance information, which of the luminance one. have been used as spare sets in a bedroom or form the basis of all colour video signals,

IC1 +9V...+12V 7805 D1

1N4004

C5 C6 C7 C8

10n 10µ 220n 470µ 25V 25V M R5 R7

S-VIDEO Ω 27k 470 T2

C2

470µ C3 179-1 C R3 COMP VIDEO 470 Ω 2N2907A

T1 081 R11 25V 100n 75Ω P1 C1 L R4 C4 Comp 560 Ω 2N2222A R8 1k 100n 470µ 470 Ω 25V R1 R2 R6 R9 R10 Ω Ω Ω Ω 75 75 10k 150 150

M M

081179 - 11 another room, for example. Although all cur- over separate channels. In composite video, Our circuit picks up the component signals on rent flat-screen receivers have very compre- by contrast, both these signals are com- the two standardised pins of the 4-pin mini- hensive facilities and include digital inputs via bined over a single path, and the resulting DIN socket normally used for S-video (also DVI or HDMI connectors and analogue inputs inevitable interferences between them known as an Ushiden socket), taking care to in S-video format, this was unfortunately not degrade the appearance of the image being maintain the 75 Ω impedance via R1 and R2. the case with the CRT televisions that were reproduced. Fortunately, the components The mixing of the two signals is then taken being sold only a few short years ago, which of an S-video signal, whether in the SECAM, care of by R3, R4, and P1; the latter lets you were more often than not fitted with only PAL, or even NTSC standards, are almost the adjust the respective levels of the two com- composite video inputs, either directly or same as the ones found in a composite sig- ponent signals exactly. via their SCART socket. The converter we are nal of the same standard. So it’s going to be suggesting building, very simple since it only relatively simple to combine them in order The two transistors that come next are wired uses two transistor, lets you convert any S- to reconstitute the composite video signal in such a way as to create a wideband ampli-

7-8/2009 - elektor 41 fier, the gain of which is set to 3 by the ratio that gives 9 to 12 V at 100 mA or so. Diode D1 between R8 and R9. Combining the input is there just to protect against any accidental COMPONENT LIST components has had the effect of dividing inversion of the PSU polarity that might pos- the overall amplitude of the video signal by sibly occur. Resistors a factor of 1.5, and the output impedance R1,R2,R11 = 75Ω matching resistor is going to divide the sig- The circuit itself is very easy and construction R3,R7,R8 = 470Ω R4 = 560Ω nal in half again (once the signal is terminated shouldn’t present any difficulties. It can be R5 = 27kΩ at the input of the destination equipment), built on the PCB we suggest [1] or on a piece R6 = 10kΩ all of which adds up to a total attenuation of of prototyping board, but in either case, we R9,R10 = 150Ω 2×1.5, corresponding to the make-up gain we recommend using fibreglass board, because have designed into our amplifier. In this way, of the high frequencies involved in the video Capacitors C1, C3 = 100nF inserting our converter into a video chain will signals. C2, C4, C8 = 470μF 25V have no effect on the level of the signals pass- C5 = 10nF ing through it. If you want your converter to follow the C6 = 10μF 25V The composite video output passes via 75 Ω proper standard in terms of connectors, C7 = 220nF resistor R11 in order to match the circuit’s you’ll want to use a female 4-pin mini DIN output impedance to the input impedance S-video socket for the input and a female Semiconductors D1 = 1N4004 of the composite video input on the device phono socket (a yellow one, for the purists!) T1 = 2N2222A to which it is connected. At both input and for the output. As for the power supply, all T2 = 2N2907A output, note the parallel combinations of C1 you’ll need is a simple jack to suit the mains IC1 = 7805 / C2 and C3 / C4, so that the video signals, unit you’ve chosen. with a frequency range extending from a few The circuit should work right away, and all Miscellaneous tens of Hz to several MHz, can pass through that you then have to do is to adjust the pre- 4-pin mini DIN connector these capacitors under the best possible set P1 so as to obtain a composite video sig- Cinch connector (yellow) DC supply connector conditions. nal that gives correct contrast and saturation If we want to avoid unwanted colour or on the TV receiver you are using. brightness variations, it is vital to power the (081179-I) circuit from a stabilized supply, achieved here Download by using a standard 3-pin regulator IC to pro- Internet Link 081179-1: PCB layout (.pdf), from [1] vide a 5 V rail for the circuit. So the project [1] www.elektor.com/081179 can be powered from a ‘plug-top’ mains unit

SSR 2.0

OptoMOS semiconductor AC loads and some variants include circuitry Conventional mechanical relays have been to ensure switching occurs as the AC passes around for years. They switch both AC and DC relays through zero. This reduces switching EMI but supplies and can be designed to handle high Fredi Krüger (Germany) also makes them unsuitable for phase control current and voltage. Standard semiconduc- applications. tor relays can switch high current and high OptoMOS or PhotoMOS relays are something voltage loads but are not suitable for DC sup- of a special category. Looking at a block plies and cannot be switched at high diagram the device falls somewhere frequency. between an optocoupler and a conven- Taking a closer look at the block dia- tional SSR (Solid State Relay). gram of a typical modern optoMOS relay shows an LED at the input as To compare technologies the input sig- in the a normal optocoupler, but nal to a standard analogue optocoupler this time the light is used to switch modulates the light of an LED. The light two complementary photo MOSFETs induces a current in an isolated pho- which form a bidirectional switch. This totransistor or Darlington. The out- bidirectional configuration is capable put current from this type of device is of switching both AC and DC sup- relatively small (a few milliamps) and plies at speeds of around 1 ms. Most is approximately proportional to the of the major IC manufacturers pro- input signal. duce their own versions and amongst those stocked by one supplier include Solid state relays by comparison have NEC (PS7141-2B), International Recti- a similar input LED but this time the fier (PVN012APbF), Clare (LBB110) and light is used to trigger a built-in triac Vishay Semiconductors (LH1502BB). or thyristor. They are used to switch The characteristics of these devices

42 elektor - 7-8/2009 range from a maximum load current from is described as ‘2 form B’, i.e. two normally 50 mA to 10 A with a voltage range from closed relays. The contacts are capable of 20 V up to 2 kV. The switch resistance can be switching 350 V at 150 mA. Without any cur- +CONTROL 1 4 LOAD as low as a few mΩ to 100 Ω and the input rent flowing in the LED the device is on and control current ranges from around 2 mA we measured an output resistance of 15 Ω. to 10 mA depending on the type of relay. With an LED current of 0.5 mA the resist- Some other manufacturers are Toshiba, ance starts increasing and at around 0.9 mA

Fairchild, Aromat (NAiS), Panasonic, Sharp, - CONTROL 2 3 LOAD it rises sharply giving an off resistance of Cosmo and Avago. Some of the advantages around 300 MΩ. of OptoMOS relays are: 080683 - 11 • Small package outline — also in SMD! The FOD3180 is another variant from Fair- • Long service life child; it is a high speed MOSFET gate driver • No contact wear package. When choosing a relay for a particu- optocoupler which has additional load sup- • No contact bounce lar application the description will include the ply voltage connections. It is capable of • No generation of EMI specification ‘X form Y’. X is a number indicat- switching 2 A at 250 KHz. At this speed it is • High switching speed ing how many switches are in the package necessary to take precautions to suppress • Insensitivity to vibration and Y indicates the type of contact: ‘B’ = nor- EMI generation generated in the load. • Insensitivity to magnetic fields mally closed while ‘A’ = normally open. Some (080683-I) • No magnetic field emission of these relays have both normally open and Internet link • Low control power requirements normally closed in the same package, useful www.toshiba.com/taec/components2/Datasheet_ for making a changeover switch. Sync//214/4495.pdf There are several different package outlines In the Elektor labs we took a look at the including one with eight relays in the same TLP4227G-2 from Toshiba. This 8-pin version

Speed Control

Mark Donners (The Netherlands) detection limit. After this K3 speed has been ‘stored’ via The author went for a ride in a VCC input PB1, the microcontrol- rental Citroen a while ago. This ler will generate an acous- car had a nice gadget onboard tic alarm if the set speed is that the author was unable exceeded. It produces two to find available as a separate VCC short beeps if the speed is accessory. In such cases, there’s slightly higher than the set only one option for an electron- R3 R4 R2 value, or a long, loud beep C1 ics enthusiast: do it yourself! if the speed is significantly 10k 4k7 10k The device in question mon- 100n 50V higher. itors how fast you are driv- 8 The speed is measured via

5 1 ing. An alarm sounds if you go PB0 PB5 pin 2 of connector K1. Opti- K1 faster than the preset speed. IC1 cal isolation with IC2 pro- 6 3 This gives the driver good con- PB1 PB4 tects the PB2 input of the R1 ATtiny25 trol over how fast he actually 7 2 microcontroller against 1k2 PB2 PB3 drives. You can regard it as a IC2 excessively high voltages. 1 6 5 4 pseudo cruise control. BZ1 You can tap off the speed C2 C3 This circuit is built around an input signal of the car Atmel ATtiny25 microcontroller, 100n 100n speedometer for this pur- 50V 50V which has all the features nec- 2 4 pose, or you can fit a mag- 4N35 essary for achieving the desired net and reed relay to the objective. The microcontroller driveshaft or an axle. D1 operates at 1 MHz using a clock 1N4001 The firmware is written in C signal generated by an internal and assembled using Code- IC3 oscillator. The desired speed LM7805ACZ vision. All the firmware does is set by a pushbutton switch F1 VCC is to monitor the speed connected between pins 3 input signal using an inter- 500mA and 1 of connector K1, which is K2 rupt-driven routine. The sig- connected to input PB1 of the C4 C5 C6 nal is monitored by measur- microcontroller. ing the interval between 10u 100n 100n The idea is that the driver should 63V 50V 50V two successive pulses: the push the button when the shorter this interval, the 081127 - 11 car reaches the desired speed higher the speed. If the set

7-8/2009 - elektor 43 speed level is exceeded, an alarm signal is Caution. Tapping off or altering the speed Internet Links generated. You can use connector K3 to pro- signal generated by a vehicle for use on pub- [1] www.elektor.com/081127 gram the microcontroller (1 = SCK; 2 = MISO; lic roads may be illegal and/or void manufac- [2] http://koti.mbnet.fi/jylhami/trip/speedsignal.pdf 3 = MOSI, 4 = RESET). turer’s warranties. Download Information about available speed signals in (081127-I) 081127-11 Source code and hex code, from www.ele- different makes of cars is found on the Inter- ktor.com/081127 net, for example, at [2].

Four-component Missing-pulse Detector

Lars Näs (Sweden) charge until Vth+ is reached and the output V CC pin 6 of the Schmitt trigger gate will change

A missing-pulse detector is a ‘one-shot’ trig- R1 to logic Low. gered device that is continuously retriggered * When no pulse (i.e. a logic Low state) is pres- by incoming pulses before a predefined tim- IC1.C ent on the base of T1, the transistor is driven ing cycle is completed. At room tempera- 5 6 into saturation. This allows C1 to instantly dis- 1 ture, the positive-going threshold voltage T1 charge, setting up the initial conditions for TRIGGER C1 (Vth+) for the CD40106BC hex Schmitt trig- * the next pulse. ger IC falls in the range of 60% to 86% of its The trigger signal can for instance be sup- IC1 = CD40106BC 2N3906 supply voltage (Vcc: 5 V–15 V). If we also take plied by a Hall-Effect switch set up to mea- into account that capacitor C1 takes a time 080137 - 11 sure if a wheel with a magnet is rotating or constant defined as R1×C1 [seconds] to reach not. 63% of its full charge voltage, the constant This circuit uses one gate in the CD40106BC, is roughly the time C1 takes to charge up to R1 to charge up capacitor C1, but not suffi- leaving the other gates free for use for other the level Vth+, thus changing the logic state ciently to reach the positive voltage thresh- purposes. Do take into account that CD40106 of pin 6 on IC1.C. old set at input pin 5 of the gate. Conse- devices from different manufacturers or pro- Based on the above assumption, if a pulse quently Schmitt trigger output pin 6 will duction batches may have slightly different train with a High-level period shorter than remain High. For a retriggered pulse period threshold voltages, which requires the cal- of 3 seconds (or 0.3Hz) you’d use R1 = 330 kΩ culated value of T to be adapted carefully to T = R1C1 [s] and C1 = 10 µF. match the specifications of the gate used. Now, if the High-level pulse duration on the (080137-I) is present on the base of T1, this pnp transis- base of transistor T1 is longer than T, the tran- tor will remain in the cutoff state. This allows sistor will remain cut off, but the capacitor will

Hassle-free Placement of SMD Components

Leo Szumylowycz (Germany) but if you can’t find it, a good substitute is Blu-Tack adhesive putty (or one of the several Gadgets can be very useful to assist the task similar products), which you can buy in strips, of placing components in printed circuit square or small pads. You’ll need to knead it boards. Some people clamp the PCB in a small in your hands a while for this kind of assem- vice, either the vacuum-fixing variety (with a bly work. sucker) or the type that clamps to the edge of the workbench, or else they use one of those Once you have softened a lump to a suitably ‘third hand’ devices with several crocodile elastic consistency, you can press it onto the clips. But none of these is much help when actual work preparation area and place the you are dealing with surface mount (SMD) printed circuit board on top (see photo). The components. Even the steadiest hand is of lit- underlay should be rectangular or circular, tle use if just the smallest slip causes the PCB about 20 to 25 cm (8 to 10 inches) across. This to jump out of the croc clips. In this kind of approach enables you to manoeuvre the SMD operation you cannot steady your hands on printed circuit board into the best position the work surface and they soon get tired. at any time during the parts placement proc- gummy mess out of the metal type letters on ess and fix it firmly in place with both hands. The author has discovered a better, albeit traditional typewriters (yes, some people do Using a conductive material for this underlay unconventional, solution: a substance like still use these good old machines). This sub- enables it to be earthed for discharging any modelling clay that is sold for cleaning the stance is sold in specialist stationery shops static electricity charge. Many mousepads are

44 elektor - 7-8/2009 suitable for this purpose, used with the con- although the author has not tested these per- to fix individual components onto the PCB ducting surface uppermost. sonally. Here practitioners will state that SMD tidily and ‘squarely’ before soldering, leaving printed circuits boards can also be populated both hands free for the actual soldering. Instead of Blu-Tack you could use other mate- using double sided sticky tape. Blu-Tack has (090368-I) rials such as Plasticine or even chewing gum, the advantage, however, that you can use it

Daylight Switch

Mickael Bulet (France) nal dimensions) IP55 junction box, A ® P for example, the Plexo range from This project was originally designed LA Legrand. It is easy to install; all you for lighting up an illuminated sign for have to do is cut into the cable lead- N a wine-grower. The sign was originally ing to the light and wire it in series. controlled by a simple time-switch, E The circuit is AC powered, without which had to be reprogrammed every using a transformer. The impedance day to avoid the sign’s lighting up of a capacitor is used to drop the 230 B while it was still daylight. This is time- VAC power voltage and limit the cur- P consuming, and can lead to wastage K3 rent. Resistor R1 protects the capaci- LA of electricity and other resources. A tor (C1) against surge currents when better solution would be an auto- N power is applied at lighting-up time, matic switch capable of detecting and R2 ensures that it is discharged E K1 the transition between daylight and R3 at turn-off. Readers on 120 VAC, 60 Hz night-time. In addition to that funda- K2 power should change component val- mental requirement, the specifica- LDR ues as follows: R1 = 2x 100 Ω in paral- tions also demanded a very compact lel (stacked) or 1x 47 Ω, 2 watts; C1 = unit that would be easy to install and 2.2 µF. Also note P = phase, N= neutral, 090049 - 11 not require major modifications to the P (PE) = protective earth. existing electrical installation. Rectification is achieved using a bridge The project described here is compact enough, fitting into an 80×80 mm (inter- rectifier, which makes it possible to double

COMPONENT LIST R2 470k Resistors R1 C1 R1 = 47Ω 1W 47Ω P R2 = 470kΩ K3 1W 1µ5 D2 D1 IC2 R3 = LDR 7812 R4, R5 = 100kΩ 4x +12V 1N4007 R6 =1kΩ N P1 = 1MΩ multiturn preset, vertical D3 D4 D5 C2 C3 Capacitors 1000µ 100n 15V 25V C1 = 1µF5 400V MKT E C2 = 1000µF 25V axial C3 = 100nF LCC 63V C4 = 10µF 25V radial R4 R5 Semiconductors 100k 100k IC1 D1–D4, 6 = 1N4007 1 3 7 T1 D5 = 15V 1.3W zener diode 5 R6 6 K1 µA741 1k T1 = BC547 or equivalent R3 2 IC1 = μA741 or equivalent 4 BC547 IC2 = 7812, or low-drop equivalent

D6 RE1 LDR C4 P1 Miscellaneous 12V 10µ 1M K2 RE1 = relay, 12V coil, 1x 10A, 250V c/o contact 25V 1N4007 LA K1,K2,K3 = 2-way PCB terminal block, 5mm (0.2”) lead pitch Type IP55 electricity junction box, internal dimensions 80 x 80 mm (3.15” x 3.15”) e.g. plexo LEGRAND # 922-06 090049 - 12 20 mm length of electricity conduit, diam. 20 mm (0.8”)

7-8/2009 - elektor 45 the usable current compared with to pass through from the LDR, which the conventional rectification often you will need to glue to the lid. In front encountered in this sort of power sup- of the LDR, fit a piece of 20 mm diam- ply. A zener diode of around 15 V (min- eter plastic conduit about 20 mm long imum, as the 12 V regulator needs to as a shield, so that the LDR won’t be be allowed enough headroom to do its affected by the light coming from the job properly) limits the voltage in the light you are trying to control. Install first instance; it is then smoothed by the switch as far away as possible from C2, then more accurately regulated by the light it is operating, to avoid end- IC2 and finally decoupled by C3. The ing up with a flasher! stable 12 V supply is required above all Last of all, adjust P1 for the light level for the voltage divider that acts as a at which you want the relay to switch reference for the comparator. on. The darkness is detected by an LDR, which in conjunction with R4 forms a Cautionary Notice voltage divider, the output voltage of which is A printed circuit board has been designed (the When you’re handling the circuit for testing inversely proportional to the intensity of the design is available free from [1]) to make build- etc., be really careful to avoid getting a shock, light falling on the LDR. Capacitor C4 absorbs ing the switch easier. Don’t forget to tin the as there is live AC power present over most of rapid changes in this voltage, in order to tracks switched by relay RE1 so they can carry the PCB. Never connect the circuit’s internal avoid unwanted triggering. R5 and P1 form a as much current as possible to the light to be ground rail to the protective earth (E) line. voltage divider for the comparator (IC1) refer- controlled. In some cases, it may be necessary (090049-I) ence voltage — this is what determines the to beef up the tracks with pieces of solid cop- threshold for the light to be turned on. When per wire. Internet link the voltage on pin 3 of IC2 is higher than the The circuit fits into a sealed IP55 box, like an [1] www.elektor.com/090049 voltage on pin 2, the comparator activates electricity junction box, for example. Drill a the relay via T1, and the sign is lit up. hole in the lid of the box to allow the leads

Control Interface via PC Keyboard

Jacob Gestman Geradts These switches are scanned

(France) IC2.D IC2.C many times per second in V L1 DD 8 9 10 11 a matrix in order to detect One of the more difficult the potential press of a key. D1 D2 D3 aspects when making a 6 12 The number of columns is 3 control or security system LED LED LED usually eight (C0–C7 in the SCRL NUM CAP VDD 12 that uses a PC (a burglar C7 schematic); the number of 32 11 CAP C6 alarm using a PC, for exam- 10 IC2.A rows varies for each type IC1 C5 1 31 9 ple), is the connection of NUM C4 CTRL A of keyboard and can range 8 13 the sensors to the compu- C3 from 14 to 18 (R0–R17 with 30 7 ter. In addition to typically SCRL C2 the HT82K28A keyboard 40 2 C1 requiring specialist inter- 39 encoder mentioned in the C0 face expansion boards, the DATA HT82K28A example). To each switch 38 35 writing of the program that DATA R17 there is a single column- and 33 R16 IC2.B includes interrupts is often 37 27 3 a single row connection. CLK R15 also an insurmountable 26 CTRL B The intention of the circuit CLK R14 5 5 24 obstacle. But when only a IO0 R13 is that sensor A will ‘push’ 6 15 simple system is concerned IO1 R12 4 the letter A, when it senses 14 R11 consisting of, for exam- C1 C2 25 13 something. This requires NC R10 ple, four light barriers or, if 34 29 IC2 = 4066 tracing the keyboard wir- NC R9 10u 100n 36 28 need be, trip wires giving a NC R8 ing to figure out which col- 23 digital on/off signal when R7 umn and which row is con- 22 R6 uninvited guests enter, then 1 21 nected to the A key. One of OSC1 R5 VDD R1 20 a much cheaper but never- R4 the four analogue switches 19 theless effective interface is R3 from the familiar CD4066 18 possible. R2 CMOS IC is then connected 2 17 14 VSS R1 16 between these two con- R0 IC2 For this interface we use an VSS nections; that is, in paral- 4 7 (old) computer keyboard. GND lel with the mechanical A This contains as many key on the keyboard. When 090379 - 11 switches as there are keys. the Control-A input of the

46 elektor - 7-8/2009 CD4066 is activated by sensor A, the letter could, for example, shunt the ‘next chan- example only, and each ‘typed’ letter has to A will be sent to the computer by the key- nel’ button using one of the 4066 switches, be determined by the user for the specific board. The PC can then act appropriately, which itself is activated by a 1-Hz square keyboard that is used. It is important that for example by entering the alarm phase. wave generator. each CD4066 switch is always connected between a row- and a column connection. The system is not limited to (burglar) detec- In the schematic only switches A and B of the The output signal from the sensors has to be tion using a PC. The remote control of a TV CD4066 are connected to the keyboard. You suitable for the CD4066 and the power sup- set or other electronic devices can also be can, of course, use all four of the switches ply voltage of 5 volts used by the keyboard. operated with a 4066 in the same way; for and if you need more than four you can use The power supply for the CD4066 may be example to scan through a number of TV multiple CD4066 ICs. The indicated wiring obtained from the keyboard. channels in a cyclical fashion. To do this, you between the keyboard IC and the 4066 is an (090379-I)

PR4401 1-Watt LED Driver

Where Tdis is the discharge time of inductor L2 through the LED. The LED’s brightness can be increased or decreased by varying the induc- tance of L2. In practice, any value between 10 and 56 µH will work just L1 D1 fine. The inductor current increases on each cycle until T1 goes out of saturation, hence a small resistance (R1) is required at the base of IC1 22µH T1. Without the ‘stopper resistor’, the final current goes out of control PR4401 T1 R1 due to the DC gain of T1. A transistor with a high DC current gain and 1 2 low collector-to-emitter saturation voltage is the best choice if you FF want to tweak the circuit for efficiency. Regarding L2, make sure the BD140 BT1 peak current through it is below the saturation level. L2 * (080825-I) 1V5 3 Advertisement

080825 - 11

T.A. Babu (India)

The PR4401 chip from Prema can be used to drive an LED directly, but not a high-power LED like one of the popular 1-watt types cur- rently available on the market. The circuit shows that the drive sig- nal at the Vout terminal of the PR4401 chip (pin 2) turns a medium- power PNP switching transistor (T1) on and off. When T1 is switched into conduction, inductor L1 is charged. When T1 is switched off, the inductor discharges its stored energy through the LED during flyback with enough current to allow a one-watt LED to light up at nominal brightness. During the ‘on’ time of transistor T1, the current through inductor L2 China PCB Supplier ramps up linearly to a peak value as expressed by. (Prototype thru Production)

IL2(pk) = [(Vbatt – VCEsat(T1)) ×Ton ] / L2 ✓ 1-layer up to 30-layer ✓ Cost and quality where VCEsat(T1) is the collector-to-emitter saturation voltage of T1 (here, a type BD140 is suggested). ✓ On time delivery ✓ Dedicated service During T1’s ‘off’ time, the inductor voltage reverses, forward-biasing ✓ Instant Online Quote & Order the LED and discharging through it at a constant voltage roughly equal to the forward voltage of the LED, while its current ramps down . . . . . Day and Night to zero. Because this cycle repeats at a high rate, the LED appears to be always on, its brightness depending on the device’s average No minimum quantity – 1 piece is welcome current, which is proportional to the peak value. The LED current is roughly a triangular pulse with a peak current approximately equal Check our low price and save big $$$... to the inductor’s current because of the finite turn-off time of T1. The 86(571)86795686 [email protected] estimated average current may be calculated from www.pcbcore.com ILED(avg) = 1/2 × IL2peak × [Tdis / (Ton + Toff)]

7-8/2009 - elektor 47 TurboGrafx-16 (PC-Engine) RGB Amplifier

Marco Bettiol (France) loscope, and calculator! The principle of this circuit is very simple and The PC-Engine, also marketed under the is based around a single IC, the LT6551 from name TurboGrafx-16 [1] is an 8-bit games Linear Technology. The package contains four console made by NEC/Hudson Soft which independent video amplifiers with a fixed appeared in Japan in 1987. In terms of units gain of 6 dB. This IC is available in MSOP for- sold, for some time it exceeded Nintendo mat, which means the overall size of the cir- and its famous Famicom (NES in Europe). cuit can be kept down. The RGB + sync sig- Despite this success, it was never officially nals are picked up directly from the expan- distributed in Europe. Sodipeng was the sion port. only company to market it, but it remained The input impedance of the circuit is set at a pretty well kept secret. 10 kΩ so as not to overload the HUC6260. R9 Nowadays, people who want to play again for the sync circuit, R10, 11, and 12 for the RGB. with this excellent machine are faced with Next, we need to eliminate the 3.6 V DC com- a problem of incompatibility of the video ponent and set the RGB signals at a more suit-

B G R SYNC +5V SR SL

+5V R13 R14 R15 R16 C2 C16 C11 39k 39k 39k 39k

22u 47u 47u C12 C13 C14 C15

+5V 10u 10u 10u 10u C6 R12 R5 R11 R6 R10 R7 R9 R8 R17 100n R4 C5

10k 8k2 10k 8k2 10k 8k2 10k 8k2 75R

10 270R 220u VCC K1 R3 C4 1 IC1 9 6 IN1 OUT1 75R 8 7 2 8 IN2 OUT2 220u 3 1 3 7 IN3 OUT3 R2 C3 4 IN4 6 OUT4 75R 5 2 4 LT6551 220u PE PE GND R1 C1 5 MAB8SH 75R 220u

090041 - 11

signals, as the PC-Engine’s NTSC video out- available on the machine’s rear expansion able level. If the signal were to be amplified put may not be compatible with some PAL/ port. This port also provides the left and as is, the amplifier would be bound to satu- SECAM television sets. The only way to be right audio signals, along with a 5 Vdc power rate. So the choice of a proper level is vital able to use this console and obtain a colour rail. Even though the RGB signals are at the in order not to distort the reproduction of picture is to connect directly to the HUC6260 standard level of 0.7 V p-p, they still can’t be the image being amplified. Capacitors C12– video processor which provides the red, fed to the TV set directly, as the HUC6260 is C16 provide coupling, and only the wanted green, and blue primary signals plus sync. As not capable of driving into a 75 Ω load. This AC component of the signal passes on to the luck would have it, these signals are directly is where you get out our soldering iron, oscil- next stage.

SCART socket wiring [2] PC‑Engine expansion port (resembles DIN 41612) [3] Ground 4, 5, 9, 13, 17, 18, 21, (14) A1 Audio Left R 15 C1 Audio Right G 11 C2, 20 ground B 7 A2, 21 +5 V dc Video/Sync 20 A23 Red Audio Left 6 B23 Green Audio Right 2 C23 Blue RGB switching 16 C22 sync

48 elektor - 7-8/2009 This AC signal needs to be fixed or ‘clamped’ for PAL/SECAM). So let’s take 30 Hz as the we need to use an amplifier with a gain of to an optimum level. The specifications of the cut-off frequency. The formula for the cut-off 6 dB.

LT6551 offer an input range from 0 to 2.5 V frequency of a first-order filter fc = 1/(2πRC) An 8-pin DIN socket carries the RGB + sync maximum with a 5 V supply (see data sheet). gives C = 3.9 µF (with R = R5//R13 = 6,775 Ω signals. The sound signals are filtered of any

R5/R13 and the three other identical pairs of and fc = 3 Hz) and so you’ll choose the DC component and the RGB switching signal resistors create voltage dividers. By choosing slightly higher value close to this: 4.7 µF for needed by the SCART input is also provided. the values of 8.2 kΩ and 39 kΩ, you obtain an example. All that remains is to make up the cable with operating point around 0.86 V. A little calcu- The LT6551 amplifies the video signal by a the correct pin-outs. lation just to check: 0.7 V plus 0.86 V gives a factor of two (+6 dB) and so we find at its This little project helps us remember that maximum input signal of 1.56 V. output terminals a signal of 1.4 V, together video games can generate very serious activ- It’s important to choose the coupling capaci- with a DC component. A capacitor (C1, C3, ities, and that in electronics nothing is ever tor value correctly, according to the value of C4, C5) removes this unwanted DC compo- chosen by chance. Enjoy your gaming! these resistors. Together, they form a high- nent and the output impedance is set to the (090041-I) pass filter that attenuates the lower frequen- standard value of 75 Ω by a resistor (R1–R4). cies of the wanted signal. As a rule-of-thumb, This 75 Ω output impedance is effectively Internet links you need to calculate this filter in such a way in series with the 75 Ω impedance of the TV [1] http://en.wikipedia.org/wiki/PC-Engine as to set the cut-off frequency at one tenth of set’s input stage, which divides the voltage [2] http://en.wikipedia.org/wiki/SCART the lowest frequency to be passed, which in by two, bringing the video signal back down [3] http://www.gamesx.com/misctech/pcebp.php this case is 30 Hz, the NTSC frame rate (25 Hz to its standard value of 0.7 V. And that’s why

Fan Speed Controller

Andreas Vogel (Germany) 12V Anyone who uses a computer for long peri- ods will appreciate the benefits of a silent 5V PC. Quite a few websites now sell compu- R1 R2 R3 R4 ter accessories specifically designed to make C1 7 7 k k 4k 4k 10 your desktop run more quietly. The CPU 10 100n fan is often the main culprit in a noisy PC; 8 VCC K1 in many cases it can be replaced by a large K3 IC1 MISO 12V 1 7 5V passive heat sink to dissipate the heat more PB5 (PCINT5/RESET/ADC0/dW) (SCK/ADC1/T0/PCINT2) PB2 K2 GND 2 6 SCK PB3 (PCINT3/CLKI/ADC3) (MISO/AIN1/OC0B/INT0/PCINT1) PB1 NTC1 3 5 MOSI efficiently. The heat sink fins are arranged to PB4 (PCINT4/ADC2) (MOSI/AIN0/OC0A/PCINT0) PB0 NTC2 RST make optimum use of air blown through the 5V ATtiny13 GND case by the power supply fan. GND 4 R5 R6 220R The specification of Intel’s ATX type PC form 7 4k T1 factor even suggests that the cooling air

C2 T2 should be used in this way but to be success- BC850 ful on modern machines it is necessary to 1u pay careful attention to a number of factors. 25V BCX56

Firstly it is important to use a processor which 070579 - 11 has the lowest possible power consumption (especially in idle mode), the lower cost 45 nm technology chips are a good place to start ing. This approach ensures that everything and NTC2 are proportional to the measured here. Secondly it is important to pay atten- remains cool. temperatures. These are sampled by the ana- tion to the air flow in the case to ensure that With this in mind the author built this versa- logue inputs ADC2 and ADC3 of the micro- it is ducted efficiently from the PSU through tile fan speed controller using little more than controller. The controller will select one of ten the passive CPU heat sink. The main draw- a small microcontroller, a few transistors and fan speed settings depending on the meas- back with this setup is that fan speed is only two NTC thermistors. The main circuit ele- ured values of temperature. The higher of controlled by the temperature of the PSU, not ment IC1 is an 8-pin 8-bit ATtiny13 microcon- the two temperature readings will always be the processor. troller from Atmel. This controller has more used. The output from pin 6 is a pulse modu- than enough 10-bit resolution analogue lated waveform to control fan speed. The out- The solution of course is to install a new inputs for the job. put Darlington configuration of T1/T2 drives fan speed controller and fit a temperature The circuit diagram is not so complicated: the fan from the PWM waveform integrated sensor to the CPU heat sink. The controller Two thermistors are connected between by R6/C2. This low pass network filters out the senses the air temperature in the PSU as well NTC1 and NTC2 of K3 and ground. Together 15 Hz fundamental of the PWM output signal as the processor heat sink and adjusts the with R1 and R2 they form two voltage divider to reduce any PWM noise generated in the fan speed according to the warmest read- networks. The voltages produced at NTC1 fan windings.

7-8/2009 - elektor 49 The power connections to 12 V and 5 V on K3 electrically insulated from the heat sink). The other variants of the ATtiny microcontroller can be supplied from an unused floppy disk other thermistor can be positioned in the air family. drive or spare hard disk power cable. K1 pro- flow from the PSU so that air can pass freely (070579-I) vides the connection for the in-circuit pro- around it. The PSU fan can now be connected gramming cable for the microcontroller. R4 to the new fan speed controller. Some fans should ensure that the fan is switched on if have a built-in thermistor which regulates Download & Product the microcontroller hangs or a fault occurs. the fan speed autonomously. In this case Programmed controller The circuit is so simple that it can comfort- remove the thermistor and replace it with a 070579-41 Controller ATtiny13 ably fit on a square of perforated stripboard fixed resistor to make sure it runs at full speed Software and housed in a small plastic enclosure. Fix (try 1 kΩ). 070579-11: source code and hex files, from www.ele- one of the thermistors onto the heat sink The firmware for IC1 is written in assembly ktor.com/070579 (doesn’t matter which one but make sure it is language and would also run in principle on

Power-up/down Sequencer

Christian Tavernier (France) create a strip of light (bar) that is longer or Resistor R7 connected to pin 7 of the LM3914 shorter according to the input voltage. This is sets the current fed to the LEDs by the LM3914 Whether you’re talking about a home cinema the mode selected for the LM3914 in the cir- outputs. Here, it’s been set to 20 mA, since or a computer system, it’s very often the case cuit described in some detail below. that is the value expected by the solid-state that the various elements of the system have relays chosen. The input voltage applied to to be turned on or off in a quite specific order, So as to be able to control the AC powered pin 5 of the LM3914 is none other than the or at least, automatically. Constructing this equipment our sequencer is intended to voltage present across capacitor C1 — and sort of automation system is well within the manage, we are using solid-state relays — this is where the circuit is ingenious. When capability of any electronics enthusiast wor- four, in our example, though you can reduce the switch is set to ‘on’, C1 charges slowly thy of the name, but in this ‘all-digital’ age, or increase this number, up to a maximum through R5, and the LEDs of the solid-state most of the circuits of this type to be found of ten. Since the input devices in solid-state relays on the outputs light one after another in amateur electronics magazines or web- relays are LEDs, they can be driven directly as this voltage increases; in this way, the units sites use a microcontroller. Even though that by the LM3914 outputs, since that’s exactly being controlled are powered up in the order is indeed a logical solution (in more ways than one!), and you might even say the easiest one, it +9V...+12V D1 RS1...RS4 = S216S02* RS1 F1 does pose problems for all those 3 2 * people who don’t (yet) have the 1N4004 S1A C2 R1 facilities for programming these VDR 470 S1B types of IC. So we decided to µ 4 1 250V 25V offer you now an approach that’s very different, as it only uses a RS2 F2 3 2 * simple, cheap, commonly-avail- R6 S2A able analogue , R2 3

4k7 VDR which of course doesn’t have to S2B 9 1 4 1 250V be programmed. Our project in MODE L1 6 18 fact uses as it’s ‘brain’ an LM3914, RHI L2 ON 17 IC1 L3 RS3 F3 a familiar IC from National Sem- S1 16 3 2 * R5 L4 5 15 iconductors, usually used for 470k SIG L5 S3A 14 R3 driving LED VU (volume unit) LM3914 L6 13 VDR OFF L7 S3B meters. 7 12 4 1 250V REFOUT L8 4 11 RLO L9 R7 8 10 Before taking a look at the cir- C1 REFADJ L10 RS4 F4 Ω * cuit for our project, let’s just 3 2 560 2 100µ 25V S4A remind ourselves that the IC has R4 one analogue input and ten out- VDR S4B puts intended for driving LEDs. 4 1 250V It can operate in ‘point’ mode, 081180 - 11 where the LEDs light up in turn, from first to last, depending on the input voltage, but only one LED is lit at what they’re designed for. As only four relays you’ve chosen. To power-down, all you have any given time. Alternatively it can operate are available, these are spread across out- to do is flip the switch so that C1 discharges in ‘bar’ mode (this is the mode normally used puts L2, L4, L6, and L8, but you can choose through R5, and the LEDs go out in the for VU meters), and in this case, the LEDs light any arrangement you like to suit the number reverse order to that in which they were lit, up one after the other, in such a way as to of relays you want to use. in turn powering down the units connected

50 elektor - 7-8/2009 to the solid-state relays. Easy, isn’t it? also have the advantage of being compact, any particular difficulty, but as the solid- If you’re not happy with the sequence speed, and their switching capacity of 16 A means state relays are connected directly to AC all you need do is increase or reduce the you can dispense with a heatsink if you’re power, it is essential to install it in a fully- value of R5 in order to alter the speed one using them for a computer or home cinema insulated case; the case can also be used to way or the other. system, where the current drawn by the vari- mount the power outlet sockets controlled ous units can be expected to remain under by the circuit. Note that sockets are female The circuit needs to be powered from a volt- 1 A. These solid-state relays must be pro- components. age of around 9 to 12 V, which doesn’t even tected by a fuse, the rating of which needs to Let’s just end this description with the sole need to be stabilized. A simple ‘plug-top’, be selected according to the current drawn restriction imposed by our circuit — but it’s ‘wall wart’ or ‘battery eliminator’ unit will be by the devices being powered. very easy to comply with, given the intended perfect, just as long as it is capable of supply- use. In order to remain triggered, the solid- ing enough current to power all the LEDs. As Also note the presence across the relay ter- state relays must carry a minimum holding the LED current is set by R7 to 20 mA per LED, minals of a VDR, also known as a GeMOV or current, which is 50 mA in the case of the it’ll be easy for you to work out the current SiOV, intended to protect them from any spu- devices we’ve selected. In practical terms, required, according to the number of solid- rious voltage spikes. You can use any type this just means that each of the devices pow- state relays you’re using. that’s intended for operation on 250 VAC ered by our sequencer must draw at least without any problem. The values of fuses F1 50 mA, or in other words roughly 12 VA at In our prototype the type S216S02 relays to F4 are of course going to depend on the 230 VAC, or 25 VA at 120 VAC. from Sharp were used, mainly because they load being protected. (081180-I) proved readily available by mail order. They Construction of the circuit shouldn’t present

Floating Message

Ludovic Voltz (France) use a very common 7 line × 5 column character style. The columns are dis- R8 This project lets you display a R1 D1 played sequentially by the seven LEDs 1 message floating in the air using 560 Ω arranged in a column: first column 1, 100k R2 D2 just seven LEDs, a microcontrol- 13 then 2, and so on up to 5. If the LEDs BT1 IC1 RA0 560 Ω ler, and the movement of your 12 are moved on slightly before display- RA1 R3 D3 1V5 11 5 arm. How can that be possible? RA2 RC5 560 Ω ing the next column, the eye thinks 4 6 RA3 RC4 R4 D4 it is seeing the whole character. The 2x AAA 3 7 RA4 RC3 560 Ω The human eye and brain can’t 2 8 LEDs flash at a frequency of the order RA5 RC2 R5 D5 resolve a moving object, and the BT2 9 of 200 Hz, and so all you have to do RC1 560 Ω 10 RC0 same applies to anything that 1V5 R6 D6 is move the circuit around to see the changes rapidly. It is by exploit- PIC16F616SL 560 Ω message appear as if it were floating S1 R7 D7 ing this shortcoming (or capac- 14 in mid air. Here’s a little gadget that 560 Ω ity, depending on which way you will amuse young and old alike on look at it!) that we are able to see summer evenings. videos and all types of footage, clips, visual effects and so on, 080441 - 11 For simplicity and compactness, this on the many screens around us. project uses a PIC16F616 microcon- When the images on the screen troller from Microchip, capable of appear at a rate of at least 24 per second, that the author has exploited in creating this working off no more than 2 V. This allows humans can no longer make them out as project. the circuit to be powered from two AAA individual images and perceive the result as a rechargeable batteries (2 × 1.2 V), a good moving object. It’s this ‘persistence of vision’ The characters of the message to be displayed compromise between battery life and the

7-8/2009 - elektor 51 space taken up. What’s more, this solution is ding constant. Naturally, this file is available in (up to the limit of its capacity, of course). To environmentally-friendly, as the batteries can the download accompanying this article [1]. move on to the next word, you must press the be recharged, unlike CR2035 button cells, for Using the circuit is as simple as its operating button for at least 0.6 s. The reproduction will example. principle. A brief press of the button starts be clearer if the background lighting is low. the sequence for displaying the word. Then (080441-I) The messages are created with the help of all you have to do is synchronise your move- an Excel file, where all you have to do is fill ments with pressing the button. In order to Internet Link in the cells with 0’s or 1’s according to the be able to read the word properly, it’s best to [1] www.elektor.com/080441 character you want to display. This file then repeat the operation more than once. You can directly gives the hex code for the correspon- store several words in the PIC’s Flash memory

Micropower Crystal Oscillator

Rainer Reusch (Germany) middle setting will suit us fine. Pin 8 is there- ICC VCC fore connected to the voltage divider R1/R2. Crystal oscillators for digital circuits are The current consumption of the entire circuit R1 X1 +3V3...+5V

normally built as Pierce oscillators with an 5 is impressively modest and at 5 V this is just

inverter. The inverter operates as a linear 1M 56 µA! The oscillator also functions astound- amplifier and thus requires extra current. But R3 32768Hz ingly well at 3.3 V. At the same time the cur- you can also build a crystal oscillator using an 1M rent drops to a more battery-friendly 41 µA. A operational amplifier (op amp for short)! If a prototype built in the Elektor Labs produced very low frequency is involved, for instance IC1 the slightly higher values indicated in the cir- C2 8 32.768 kHz (commonly used for clocks), you 2 7 cuit diagram. 6 can get away with a comparatively ‘slow’ 100p 3 5 micro power op amp. 4 The output signal delivered by this circuit has 1 admittedly scant similarity to a square wave. TLC271 R2 In the sample circuit shown a widely avail- C1 Nevertheless some cosmetic surgery will tidy

able TLC271 is used. On pin 8 we have the 1M this up, with treatment in the Schmitt trigger opportunity to set the ‘bias mode’, with three 100n following. To save current (naturally) we use

choices ranging between fast operation with ICC = 85µA @ +3V3 090320 - 11 a CMOS device such as the 74HC14. higher current consumption and slower oper- ICC = 100µA @ +5V0 (090320-I) ation at low current. For our clock crystal the

Automatic TV Lighting Switch

Piet Germing (The Netherlands) R1 ground light on and off along The author is the happy 10Ω with the TV set. The entire owner of a television set D1 D2 D3 D4 TV circuit is fitted in series with with built-in Ambilight light- 230V the mains cable of the TV set, (110V ) ing in the living room. Unfor- D5 so there’s no need to tinker L tunately, the television set in with the set. 5x 1N5408 the bedroom lacks this fea- TRI1 It works as follows: R1 senses F1 ture. To make up for this, the 230V the current drawn by the TV author attached a small lamp (110V ) D6 2A set. It has a maximum value to the wall to provide back- N of 50 mA in standby mode, 1N4007 R2 230V ground lighting, This makes (110V ) rising to around 500 mA 100 Ω watching television a good when the set is operating. C1 D7 deal more enjoyable, but S202TD1 The voltage across R1 is lim- it’s not the ideal solution. 220µ 1N4007 ited by D5 during negative Although the TV set can be 16V half-cycles and by D1–D4 switched off with the remote during positive half-cycles. control, you still have to get The voltage across these out of bed to switch off the 090071 - 11 four diodes charges capaci- lamp. tor C1 via D6 during positive Consequently, the author devised this auto- matic lighting switch that switches the back- half-cycles. This voltage drives the internal

52 elektor - 7-8/2009 LED of solid-state switch TRI1 via R2, which will switch on when the TV set is in standby the TV background light remains on all the causes the internal triac to conduct and pass mode. time. the mains voltage to the lamp. Some TV sets have a half-wave rectifier in the If you build this circuit on a piece of perf- Diode D7 is not absolutely necessary, but power supply, which places an unbalanced board, you must remove all the copper next it is recommended because the LED in the load on the AC power outlet. If the set only to conductors and components carrying solid-state switch is not especially robust draws current on negative half-cycles, the cir- mains voltage. Use PCB terminal blocks with and cannot handle reverse polarisation. Fuse cuit won’t work properly. In countries with a spacing of 7.5 mm. This way the separa- F1 protects the solid-state switch against reversible AC power plugs you can correct tion between the connections on the solder overloads. the problem by simply reversing the plug. side will also be 3 mm. If you fit the entire The value of used here (10 Ω) for resis- Compared with normal triacs, optically cou- arrangement as a Class II device, all parts of tor R1 works nicely with an 82-cm (32 inch) pled solid-state relays have poor resistance the circuit at mains potential must have a LCD screen. With smaller sets having lower to high switch-on currents (inrush currents). separation of at least 6 mm from any metal power consumption, the value of R1 can be For this reason, you should be careful with enclosure or electrically conductive exterior increased to 22 or 33 Ω, in which case you older-model TV sets with picture tubes (due parts that can be touched. should use a 3-watt type. Avoid using an to demagnetisation circuits). If the relay fails, (090071-I) excessively high resistance, as otherwise TRI1 it usually fails shorted, with the result that

Phone Ring Repeater

Christian Tavernier (France) quency vary somewhat between countries, sen to suit the maximum power of the load but always with comparable orders of magni- you want to control using this circuit. Even though cordless phones have invaded tude except in the case of exchange systems Resistors and capacitors R5 and C3 on the one our homes and offices, you don’t always have used in large companies. However, when the hand, and R6 and C4 on the other help, serve them at hand, and as their ringtones are usu- line is quiescent or a call is in progress, it car- to suppress the switching transients, which ally very much quieter than the old rotary-dial- ries only a direct voltage. Capacitor C1 makes are already inherently low because of the AC type analogue phones, it can happen that you it possible to pick off just the AC ringing volt- zero-crossing switching provided by IC1. miss a call you’ve been waiting for while you’ve age, which is then rectified by D2 and ampli- Construction is not at all difficult, but does been going about your daily business. tude-limited by D1. The resulting DC voltage require a few precautions in choosing some Until quite recently, you could still find remote ringers that could be plugged into LA1 any standard phone socket in order to have C1 R1 D2 R2 R5 an additional ringer, but it seems as if these 1k 220 Ω 470 Ω R4 1 D3 µ 1N4004 240V accessories are currently being phased out as 250V Ω (120V) everyone is ‘going cordless’. So we decided 390 to suggest something better, with this phone IC1 ring repeater that makes it possible to con- D1 1 6 C2 trol any device connected to the AC power C3 C4 47µ TRI1* outlet using the ringtone available on any 6V8 25V X2 22n X2 10n 0W4 250V 250V 230V subscriber line, and naturally, with all the 2 4 (120V ) R6 guarantees of safety and isolation that are 400V R3 (200V) Ω of course rightly expected. So it’s capable of 47 1k driving a ringer, or indeed even a high-pow- ered sounder to alert you when you are in the garden, for example; but it is equally able to MOC3041 081171 - 11 light a lamp for a ‘silent ring’ so as to avoid waking a sleeping baby or elderly person. This circuit has been designed to be com- charges capacitor C2, which makes it possi- of the components. First of all, capacitor C1 patible with all phone systems the author is ble to light LED D3 as well as the LED in the must be an MKT type, mylar or equivalent, aware of and also to be totally stand-alone. optocoupler IC1. This is no ordinary optocou- with a 250 V operating voltage because of What’s more, the circuit can be connected pler, but is in fact an AC power zero-crossing the relatively high amplitude of the ringing to the phone system without any danger — detecting opto-triac, which allows us to con- voltage. For safety reasons, it is essential that though in some countries, it is forbidden to trol the chosen load while generating no, or capacitors C3 and C4 are self-healing types connect non-approved devices to the public less, interference, which would not be the intended for AC power use at 250 VAC. These switched telephone network (PSTN). Check case using a standard opto-triac. capacitors are generally known as Class X or local regulations in this respect. The output triac it contains is not powerful X2 capacitors. In order to understand the principle of it, enough to drive a load directly connected As for the triac, it should have a 400 V oper- we just need to remember that the ringtone to the mains, so it is used to drive the trig- ating voltage (but see below for users on 120 present on a phone installation is an alter- ger of triac TRI1, which is a totally standard VAC power) and maximum current slightly nating voltage, whose amplitude and fre- 400 V device, rated at x amps, where x is cho- greater than the maximum current drawn by

7-8/2009 - elektor 53 the load being driven. As this will usually be lated housing, for obvious safety reasons. rights is reduce the value of resistor R1. a sounder or a common lamp, a 2 A type will Make sure you cannot touch any part when usually be more than adequate in most situa- the circuit is in use. The circuit as shown was dimensioned for tions. As the circuit can be expected to oper- operation from 230 VAC power. Readers on ate for short periods only, there is no need to The circuit should work at once and without 120 VAC power should modify the following mount the triac on a heatsink. any problems, but if you notice that D3 doesn’t component values: R4 = 180 Ω; R5 = 220 Ω; One final important point: as the right-hand light up fully, and hence incorrect or erratic TRI = 200 V model; IC1 = MOC3031. Option- part of the circuit is connected directly to AC triggering of the triac, because of too low a ally, C3 and C4 may be rated at 120 VAC. power, it is vital to fit this inside a fully-insu- ringing voltage, all you need to put things to (081171-I)

Pulse Clock Driver with DCF Synchronisation

Hans Oostwal (The Netherlands)

LCD1 Sometimes you can pick up a nice office clock or station clock at a bargain price. To ensure that these clocks all show the same 2 x16 D S

time inside an organisation such as the rail- W VS VD VO RS R/ E D0 D1 D2 D3 D4 D5 D6 D7 A K way system and avoid hassles with changing +5V 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 between winter time and summer time or R5 replacing empty batteries, these clocks are 10R S1 D1 D2 normally connected to a clock pulse network C3 that is driven by a master clock or radio sig- P1 ERR SYNC 10k nal. The master clock generates a pulse every R2 R3 R4 10n 14

minute, with successive pulses having oppo- 10k 330R 330R site polarity. VDD 17 6 RA0 IC1 RB0 18 7 RA1 RB1 1 8 If you want to use a clock of this sort, you RA2 RB2 2 9 naturally want it to keep good time. This is RA3 RB3 3 10 RA4 RB4 handled by the circuit described here, which 4 11 RA5 RB5 15 12 offers the following features: RA6 RB6 +5V 16 13 R1 RA7 RB7 PIC16F648A • it is synchronised to the DCF77 time refer- VSS 6 10k ence signal at 77.5 kHz (from Mainflingen, 5 VDD 2 IC3 7 Germany) so the time is always correct; INA OUTA C4 * • it is inexpensive – by using a microcon- 4 5 10n INB OUTB R6 +5V troller (in this case a PIC16F648A), the cir- TC4427A 100R GND cuit requires only a few components, and R7 3 it can easily be assembled on a piece of 3 IC2

perfboard; +9V...+18VDC 7805 +5V 2 • it generates pulses at one-minute intervals C6 DCF77 with alternating polarity; Module 4u7 • it also shows the time and date on an alpha- 1 16V C1 C2 C5

numeric LCD module; 10n 10n 2200u 16V • automatic switching between winter and 0 summer time; 090035 - 11 • time data is backed up in case of power fail- ure (stored in PIC EEPROM). PIC16F648A clocked by its internal 4-MHz nected directly to the TI4427A MOSFET When using a clock of this sort, note that oscillator. A standard two-row LCD (HD44780 driver IC that drives the clock coil. This some models have jumpers that can be fitted compatible) is connected to the microcon- driver IC has a operating voltage range of or removed to configure the clock for differ- troller to display operating instructions or 4.5 to 18 V and a maximum rated output ent working voltages. If you have this type of the date and time. current of 500 mA (1.5 A peak). This is ade- clock, select the lowest voltage (usually 24 V). quate for most clocks. If you need more Based on the author’s experience, clocks from The circuit can be powered from an AC current, you can add a transistor or relay to the Dutch PTT (former postal and telecommu- mains adapter that supplies a DC voltage the output stage. The clock coil has a fairly nication authority) also work OK at 12 V. in the range of 9 to 18 V. A voltage regu- high inductance, so the supply voltage has lator (IC2) generates a stable 5-V supply extensive decoupling in the form of several Figure 1 shows the schematic diagram of voltage for the electronics from this. The ceramic capacitors (C1–C4) and an electro- the hardware. The circuit is built around a supply voltage from the adapter is con- lytic capacitor (C5).

54 elektor - 7-8/2009 Advertisement A DCF77 receiver/decoder module from Conrad Electronics (p/n 641138) provides the time reference signal. It is also pow- ered by the 7805 voltage regulator. The non-inverted output of this module is connected to port RA4 of the microcontroller. As reception of the long-wave signal from the DCF transmitter The new PicoScope 4000 Series may not be good in some locations, especially if you fit the cir- cuit in a metal enclosure, it is advisable to fit the DCF module high-resolution oscilloscopes in a separate plastic box that can be placed a certain distance away from the clock.

The source code of the software is written in Flowcode 3 Pro and is available free on the Elektor website for downloading (item number 090035-11). It is based on the software for the E- Blocks DCF clock published in the December 2007 issue (075094- 11). The original software has been adapted to this applica- tion and extended with code that generates a pulse signal on ports B6 and B7 with a period of 1 minute and alternating pulse polarity. Pushbutton switch S1 is used for most of the operator functions. This button is connected to port A1 and has several functions:

- if S1 is not pressed when the power is switched on, the micro- controller executes a warm start. This is the normal situation. In PicoScope 4000 Series the event of a power failure, the analogue time and the polar- ity are saved in EEPROM, and they are restored after the next warm start; - if S1 is pressed when the power is switched on, a cold start is The PicoScope 4224 and 4424 High Resolution executed. This must be done the first time the circuit is used (see Oscilloscopes have true 12-bit resolution inputs below for more information); - if S1 is pressed during normal operation, the variables ‘a_hrXX’ with a vertical accuracy of 1%. This latest and ‘a_minuteXX’ are shown on the display, which enables the generation of PicoScopes features a deep memory user to set the analogue clock. of 32 M samples. When combined with rapid trigger mode, this can capture up to 1000 trigger In order to synchronise the analogue clock to the digital clock, events at a rate of thousands of waveforms per the analogue clock must first be set to exactly 12 o’clock. If second. you have a clock that can only be operated electrically, which means it does not have any mechanism (such as a knob) to set • PC-based - capture, view and use the acquired the time manually, you can hold S1 pressed after the cold start to waveform on your PC, right where you need it cause the circuit to generate a continuous series of clock pulses. • Software updates - free software updates for the life of Release S1 when the clock reaches exactly 12 o’clock. If you have the product a clock that can be set manually, first set it to 12 o’clock and then • USB powered and connected - perfect for use in the switch on power to the circuit with S1 held pressed. Release S1 field or the lab when the message ‘cold start… done’ appears on the LCD. If the • Programmable - supplied with drivers and example code DCF signal is being received properly, the date and time will be shown on the display after a few minutes and the analogue clock will be set to the right time.; Resolution 12 bits (up to 16 bits with resolution enhancement) If the time shown by the analogue clock differs from the time Bandwidth 20 MHz (for oscillscope and spectrum modes) shown on the LCD by one minute, the polarity of the pulses does not match the state of the stepper motor in the clock. This can Buffer Size 32 M samples shared between active channels be corrected by first setting the clock to the right time and then Sample Rate 80 MS/s maximum swapping the two leads. This action must be completed within Channels PicoScope 4224: 2 channels one minute. (090035-I) PicoScope 4424: 4 channels Connection USB 2.0 Internet Link Trigger Types Rising edge, falling edge, edge with hysteresis, [1] www.elektor.com/090035 pulse width, runt pulse, drop out, windowed

Product 090035-41: Programmed PIC www.picotech.com/scope1019 01480 396395 Download 090035-11: Flowcode (.fcf) and hex files, from [1]

7-8/2009 - elektor 55 Frequency and Time Reference with ATtiny2313

Vladimir Mitrovic (Croatia) frequency may be calculated from: The program, which was written in ­BascomAVR, constantly monitors switches In this project an AVR microcontroller type f = 8,000,000 / [2 × system_clock_prescale × S1–S5. It is available as a free download [1]. ATtiny2313 acts as a variable frequency (1 + OCR1A_value)] If any change in the switch settings occurs, divider, giving a sequence of very stable ref- the ‘Set_f’ subroutine is called to set a new erence frequencies with a 50% duty cycle and For the lower frequencies, 8-bit Timer/Coun- frequency. The subroutine will stop timers, covering a frequency range of 0.1 Hz – 4 MHz reconfigure them, set proper values in var- in 1, 2, 4 or 8 steps. The circuit is very simple ious registers to obtain the proper division because everything is done inside the micro- factor and restart the timers. The values for controller. In the program 31 different fre- the registers are written in three tables. quencies are predefined and may be selected by switches S1–S5 according to Table 1. 1. ‘Clock_prescale_table’ contains the values The ATtiny2313 has two timers/counters: 16- in the range of 1 to 256 (only values 2n are bit Timer/Counter1 and 8-bit Timer/Counter0, allowed) which will be used to calculate the both offering various modes of operation. proper value for the Clock Prescale Register, The ‘Clear Timer on Compare Match’ CLKPR. (CTC) mode is the most appropriate for generating a waveform output. In CTC 2. ‘Ocr1a_table’ contains the values in mode Timer/Counter1 counts the sys- +3V ... +5V the range of 1 to 65535 which will be tem clock or external pulses up to the C4 C1 used to calculate the proper value for value given in the OCR1A (Compare1A) the Timer/Counter1 Output Compare 100n 100µ n register. When the counter value 16V Register OCR1A. Only values 5 (1, 5, matches the OCR1A value the coun- 25, 125, 625, 3125 and 15625) are used ter is cleared to zero and the OC1A in this design. A zero (0) entry denotes pin (PB3) toggles. In CTC mode Timer/ 20 that Timer/Counter1 is stopped for

Counter0 counts the system clock or 1 19 this frequency. Note that the value in RST PB7 18 external pulses up to the value given S1...S5 PB6 fo the table is decremented by 1 before 11 IC1 17 in the OCR0A register. When the coun- PD6 PB5 being written into the OCR1A. 8 16 PD4 PB4 ter value matches the OCR0A value, 7 15 PD3 PB3 the counter is cleared to zero and the 6 14 3. ‘Ocr0a_table’ contains the values in PD2 PB2 3 13 OC0A pin (PB2) toggles. Division fac- PD1 PB1 the range of 1 to 255 that will be used 2 12 tors up to 2 x 65536 (for Timer1) or 2 PD0 PB0 to calculate the proper value for the ATTiny2313 x 256 (for Timer0) can be obtained 9 Timer/Counter0 Output Compare Reg- by setting appropriate values in the PD5 ister OCR0A. Only values 0 and 5 are XTAL2 XTAL1 OCR1A and OCR0A registers. Besides 10 4 5 used in this design: a ‘0’ entry denotes X1 by the timer division factor, an output * that the Timer/Counter0 is stopped frequency is also determined by the for this frequency, while ‘5’ produces C2 system clock, the system clock pres- C3 20MHz division of the system clock by 10. If caler (1-2-4-8-16-32-64-128-256) and even lower frequencies are needed, 22p 47p the timer prescaler (1-8-64-256-1024). other type-5n values (25 and 125) can In this design, an 8 MHz or a 20 MHz 080754 - 11 be used to produce division factors of crystal may be used in position X1 100 and 1000. Note that the value in (20 MHz shown in circuit diagram) but the table is decremented by 1 before not indiscriminately because matching being written into the OCR0A. firmware should reside in the ATtiny. ter0 is used as an additional prescaler (divi- sion factor: 10) between the prescaled system The Fref_ATtiny2313_Elektor_8MHz.bas pro- There are obviously several appropriate set- clock and Timer/Counter1. The latter is set in gram should be compiled and the resulting tings for producing a given frequency. As the the counter mode and now counts pulses at hex code programmed into the ATtiny2313 system clock and the system clock prescaler the Timer/Counter0 output pin OC0A (PB2); microcontroller before first use. Be sure to set setting determine the overall current con- hence, the OC0A pin (PB2) and the external the Flash Fuse bits to the proper value for an sumption as well (lower frequency = lower input pin T1 (PD5) are interconnected. The external crystal resonator (CKSEL3...0 = 1111) consumption), we will always choose the low- output frequency can be calculated as: because the internal RC Oscillator is selected est possible CPU clock. Assuming X1 = 8 MHz, by default. The hex file for 8 MHz is also avail- for the 1 Hz to 4 MHz frequency range, only f = 8,000,000 / [2 × system_clock_prescale × able straight away in the download at [1]. A Timer/Counter1 is used. It counts the (pres- (1 + OCR1A_value × 2 × (1+OCR0A_value)] variable capacitor C2 is provided to tune a caled) system clock pulses and the output crystal frequency to exactly 8.000 MHz, if

56 elektor - 7-8/2009 possible. If you are satisfied with the crystal’s Raising the supply voltage to 5 V will approx- The frequencies supplied by the 20 MHz accuracy, replace C2 with a fixed capacitor. imately double the supply current to 15 mA version are given in Table 2. The two low- Set the configuration switches according to (max.), but it will also allow you to raise the est frequencies, marked by an asterisk (*) Table 1 to obtain the wanted frequency. clock frequency to 20 MHz and obtain some in the table, could not be obtained exactly, Powered at 3 V, the 8-MHz version of the higher frequencies from the circuit. If current but the division error is well under the crys- frequency reference may still be used with consumption is not an issue, you may con- tal tolerance and therefore may be totally most logical families running at 5 V: CMOS, template the use of a precision quartz oscil- neglected. LSTTL, HC, HCT and so on. However, be care- lator to drive the microcontroller. (080754-I) ful and do not allow any current to flow from 5 V powered circuits back into the micro- The program Fref_ATtiny2313_Elektor_20MHz. Internet Link controller through the PB3 pin. This could bas will produce reference frequencies in the [1] www.elektor.com/080754 cause battery charging through the micro- 0.001 Hz – 10 MHz frequency range in steps controller’s clamping diodes with unpre- of 1, 2 or 5. The main difference with the Downloads & Products dictable results for both the battery and the 8 MHz program is that the timer prescaler microcontroller. If such a risk exists, connect for Timer/Counter0 is used here in order to Programmed Controller a 3 V zener diode between PB3 and GND to produce frequencies under 0.01 Hz. A table 080754-41 ATtiny2313, ready programmed, 20 MHz configuration effectively limit the voltage to a safe value. called “Timer0_prescale_table” is added to Caution: ready-programmed device 080754- the program. It contains values ‘0’ (if Timer/ Software 41 from the Elektor Shop is programmed for Counter0 is not used), ‘1’ (if it is used but not 080754-11 Source and hex files for 8 MHz and 20 MHz the 20-MHz configuration and does not work prescaled) or ‘8’ (if it is used and prescaled by Location: www.elektor.com/080754 down to 3 V. the factor of 8).

Table 1. DIP switch settings for X1 = 8 MHz Table 2. DIP switch settings for X1 = 20 MHz S5 S4 S3 S2 S1 PD4…PD0 Output freq. S5 S4 S3 S2 S1 PD4…PD0 Output freq. on on on on on 00000 4 MHz on on on on on 00000 10 MHz on on on on off 00001 2 MHz on on on on off 00001 5 MHz on on on off on 00010 1 MHz on on on off on 00010 2 MHz on on on off off 00011 800 kHz on on on off off 00011 1 MHz on on off on on 00100 400 kHz on on off on on 00100 500 kHz on on off on off 00101 200 kHz on on off on off 00101 200 kHz on on off off on 00110 100 kHz on on off off on 00110 100 kHz on on off off off 00111 80 kHz on on off off off 00111 50 kHz on off on on on 01000 40 kHz on off on on on 01000 20 kHz on off on on off 01001 20 kHz on off on on off 01001 10 kHz on off on off on 01010 10 kHz on off on off on 01010 5 kHz on off on off off 01011 8 kHz on off on off off 01011 2 kHz on off off on on 01100 4 kHz on off off on on 01100 1 kHz on off off on off 01101 2 kHz on off off on off 01101 500 Hz on off off off on 01110 1 kHz on off off off on 01110 200 Hz on off off off off 01111 800 Hz on off off off off 01111 100 Hz off on on on on 10000 400 Hz off on on on on 10000 50 Hz off on on on off 10001 200 Hz off on on on off 10001 20 Hz off on on off on 10010 100 Hz off on on off on 10010 10 Hz off on on off off 10011 80 Hz off on on off off 10011 5 Hz off on off on on 10100 40 Hz off on off on on 10100 2 Hz off on off on off 10101 20 Hz off on off on off 10101 1 Hz off on off off on 10110 10 Hz off on off off on 10110 0.5 Hz off on off off off 10111 8 Hz off on off off off 10111 0.2 Hz off off on on on 11000 4 Hz off off on on on 11000 0.1 Hz off off on on off 11001 2 Hz off off on on off 11001 0.05 Hz off off on off on 11010 1 Hz off off on off on 11010 0.02 Hz off off on off off 11011 0.8 Hz off off on off off 11011 0.01 Hz off off off on on 11100 0.4 Hz off off off on on 11100 0.005 Hz off off off on off 11101 0.2 Hz off off off on off 11101 0.002 Hz* off off off off on 11110 0.1 Hz off off off off on 11110 0.001 Hz* off off off off off 11111 standby

7-8/2009 - elektor 57 Frequency Divider with 50% Duty Cycle

Roland Heimann (Germany) VCC In digital circuit design, especially in micro- processor or measuring applications, it is 16 often necessary to produce a clock signal 2 C

MR VC VCC 15 VCC by dividing down a master clock. The 4-chip PE 9 solution suggested here is very versatile; it PL 1 CP takes a 50% duty cycle input clock and out- S1 14 12 IC1 J Q Q puts a 50% duty cycle clock selectable (via 1 16 4 P0 IC2A 2 15 5 14 1 an 8-way DIP switch) for every divisor from P1 TC CLK 3 14 6 P2 74HC73 1 to 255. 4 13 7 3 13 P3 K Q Q 5 12 10 CL P4 74HC40103 6 11 11 2 The most complex chip in this design is IC1, an P5 7 10 12 VCC P6 8-bit down-counter which is ‘programmed’ 8 9 13 by the binary value set up on the eight DIP P7 2 3 4 5 6 7 8 9

3 D switches. An edge detector circuit made up R1 TE 4 14 14 GN 8x 4k7 IC2 IC4 of IC3 and IC4 produces a pulse at every ris- 8 IC3 ing and falling edge of the input clock f . Each 11 7 7 0 1 IC3 = 74HC86 time the counter reaches zero a flip flop is IC4 = 74HC04 toggled to produce a 50:50 mark/space ratio IC3B 5 6 output signal. >_1 4 It does not matter if the gates used in the edge detector circuit are inverting or non- f0 IC3D inverting; the only important points are that 12 IC3C IC4A IC4B IC4C IC4D 11 10 IC3A 13 >_1 8 1 2 3 4 5 6 9 8 1 the correct number of gates are used and the _> 1 1 1 1 9 1 >_ 3 delay time produced by each gate. The total 2 1 propagation delay through seven HC type 080436 - 11 gates will be enough to generate a pulse of sufficient width to reliably clock the counter. Propagation delay is the time taken for a sig- ever the counter reaches zero the terminal ‘1’) the outputs Q and Q change state (toggle) nal at a gate’s input pin to affect the output, count pin (TC) generates a negative pulse, on each rising edge of the TC output of IC1. and this is given in the data sheet. The edge reloading the counter (via parallel load PL) The DIP switches are used to set up the divi- detector produces a pulse on both the pos- with the binary switch setting. The counter sion ratio, to divide the clock by 23 for exam- itive and negative edges of the input clock continues counting down from this value. ple, set the DIP switches to the binary value signal. of 23 i.e. 00010111 (setting P4, P2, P1 and P0 The down-counter decrements its value each The JK flip flop IC3 is configured as a toggle to high). time it receives a clock impulse on CP. When- type flip flop (both inputs J and K wired to a (080436-I)

PIC Detects Rotation Direction

Lionel Grassin (France) In the field of robotics, along with many other to follow high speeds and speed variations. applications involving a motor (printers, for This can be achieved using programmable example), it is often necessary to measure a motor’s speed and acceleration or direction of rotation. One simple technique is to fit a quadrature encoder to the shaft of the motor to be monitored. A quadrature encoder (see photo) is a device that produces two square- wave signals 90° apart as it turns. The direc- tion in which the encoder rotates determines which of these two signals is in advance (compared with the other), thereby making it possible to detect the rotation direction. An algorithm for detecting the rotation direction doesn’t need to be complicated, but it does need to be fast enough to be able

58 elektor - 7-8/2009 logic (FPGA, GAL, PAL, etc.), but the author tion. And all this for two motors/encoders at wanted to use a small, cheap microcontrol- IC2 the same time! You can find all the details of ler. He opted for the PIC12C509A from Micro- K1 7805 +5V the algorithm — and more — on the (French) chip, an 8-pin microcontroller with six I/Os. +UIN website of the Fribotte team to which the

Two inputs and one output are all the rota- C1 C2 C3 author belongs [1]. tion direction sensor needs, so the little PIC 10u 10n 100n The program (source code and hexadecimal is able to handle two quadrature encoders at file) is available on free download from the the same time. +5V web page for this article [2]. The algorithm developed by the author (081164-I) operates asynchronously, which ensures a ENC1 1 very wide operating range, dependent on SENS1 CHA1 2 IC1 7 CHA GP5 GP0 Internet Links the capabilities of the microcontroller. The CHB1 3 6 CPU CHB GP4 GP1 [1] http://fribotte.free.fr/bdtech/detectsens/detect- CHA2 4 algorithm loop time is 20 µs for a PIC12C50X GP3 SENS2 CHB2 5 sens.html using the internal 4 MHz clock, so it is theo- GP2 GHM-01 PIC12C509A [2] www.elektor.com/081164 optional (Lynxmotion) retically possible to follow a pulse signal of 8 up to 50 kHz. This corresponds to a speed 081164 - 11 of 3,000 rpm for a motor fitted with a quad- Download rature encoder giving 1024 pulses per rota- 081164-11: source code and hex file, from [2]

Vocal Adaptor for Bass Guitar Amp

Jérémie Hinterreiter (France) response of the amp doesn’t need to be as noise dual FET op-amp, which offers good wide or as flat as in hi-fi (particularly at the value for money. The NE5532 can be used These days, music is a major hobby for the high end), and so this sort of amplifier won’t with almost the same sound quality, but young — and not-so-young. Lots of peo- permit faithful reproduction of the voice. If at (slightly) higher cost. The circuit breaks ple enjoy making music, and more and you build an adaptor to compensate for the down into two stages. The first stage is used more dream of showing off their talents on amp’s limited frequency response by ampli- to match the input impedance and amplify stage. But one of the major problems often fying in advance the frequencies that are the microphone signal. For a small 15 W gui- encountered is the cost of musical equip- then attenuated by the amp, it’s possible to tar or bass amplifier, the achievable gain is ment. How many amateur music groups sing improve the quality of the vocal sound. That’s about 100 (gain = P1/R1). For more power- through an amp borrowed from a guitarist just what this circuit attempts to do. ful amplifiers, the gain can be reduced to or bass player? The adaptor is built around the TL072CN low- around 50 by adjusting P1. The second stage amplifies the band of fre- This is where the technical quencies (adjustable using problems arise — not in P2 and P3) that are attenu- C4 terms of the .25” (6.3 mm) ated by the guitar amp, so jack, but in terms of the P1 3n3 as to be able to reproduce sound quality (the words P2 R3 the (lead) singer’s voice 250k 6k8 K1 C1 R1 are barely understanda- 2 1M as clearly, distinctly, and 4k7 C2 C3 1 6 ble) and volume (the amp 10µ IC1.A C5 K2 accurately as possible. To 3 7 seems to produce fewer 3n3 3n3 IC1.B refine the adaptor and tai- MIC 5 decibels than for a guitar). R2 10µ lor it to your amplifier and 1k What’s more, unpredicta- IC1 = TL072 AMP speaker, don’t be afraid to ble feedback may cause experiment with the com- damage to the speakers P3 ponent values and the type and is very unpleasant on S1 4k7 of capacitors. the ear. This cheap little easy-to-build project can The circuit can readily be help solve these technical +4V5 powered using a 9 V bat- R6 R4 problems. C6 tery, thanks to the voltage 10k 100k 100µ divider R4/R5 which con- A guitar (or bass guitar) 8 verts it into a symmetrical BT1 IC1 9V amplifier is designed first 4 ±4.5 V supply. R5 and foremost to repro- D1 C7 (080188-I) duce the sound of the gui- 100k 100µ tar or bass as faithfully as –4V5 090188 - 11 possible. The frequency

7-8/2009 - elektor 59 Guitar Pick-up Tone Extender

David Clark (United Kingdom) The standard ‘Stratocaster’-style guitar fea- This project allows up to four tures three pick-ups and a five-way switch pick-ups to be employed, This design extends the basic sonic possibili- that allows the player to select one of the fol- since the bridge pick-up on ties of an electric guitar without the use of lowing combinations: a ‘Stratocaster’ is often a so- any electronic ‘effects’. The expanded num- called ‘humbucker’ type, ber of tone possibilities is brought about by • neck pick-up which can be split into mixing continuously-variable amounts of the • neck and middle pick-up in parallel two independent pick-ups, output from each of the guitar’s pick-ups, • middle pick-up shown here as Bridge 1 (L3) along with switching the phase of each pick- • middle and bridge pick-up in parallel and Bridge 2 (L4). up. This effectively gives an infinite range of • bridge pick-up The really intrepid among tones as opposed to the five available for a you may decide to build the normally switched set-up. This is not a proj- Guitarists keen to find new sounds from their circuitry in SMD and incor- ect for the faint-hearted, however; it involves instrument sometimes alter the wiring and porate a tiny board into the modifying the wiring to the guitar’s pick-up add other switches to this arrangement, but guitar. However, having coils and switches, and possibly the scratch- this is of course not a flexible arrangement, four switches and four pots plate itself, depending on the chosen loca- and certainly not something that could be on the guitar may be too tion for the replacement for the standard altered mid-performance playing for a crowd, much of a good thing. 0.25-inch (6.3-mm) jack connector. Use of a no matter if a dozen or so in a pub or 20 k at The alternative is to wire the cheap ‘copy’-style guitar is recommended! Glastonbury! guitar pick-ups individually to

V+ D1 R2 K6 1N4001 10k 2 R14 R1 S5 K1 1 6 C1 L1 IC1.A 10k 3 7 10k IC1.B NOR 470µ S1 5 P1 R9 16V 10k K9 K7 IC4 9VDC 7 100k 3 INV PHASE 1 lin 6 Neck TS921 2 4

R4 K8 BT1 C2 10k

13 10k R3 9V 470µ K2 14 9 R15 16V L2 IC1.D 10k 12 8 IC1.C NOR 10 R10 S2 P2 10k V-

100k V+ INV PHASE 2 lin Middle R13 10k

R6 IC3 10k 1 2 2 7 K5 R5 5 K3 1 6 6 L3 IC2.A 10k TL071 AUDIO 3 7 3 IC2.B NOR S3 5 P3 R11 4 10k

100k INV PHASE 3 lin Bridge 1

V- R8 V+ 10k 13 R7 K4 14 9 L4 IC2.D 10k 12 8 IC2.C 4 4 NOR 10 R12 S4 P4 IC1, IC2 = TL074 IC1 IC2 10k 11 11 100k INV PHASE 4 lin Bridge 2

080523 - 11 V-

60 elektor - 7-8/2009 a 9-pin sub-D type connector that is output signals of all four opamp sections are added either to the guitar body or its summed by IC3 (a TL071) which provides a scratchplate. The connector is linked suitably low output impedance to drive the to the input sub-D connector on the guitar amplifier. control unit via a long ‘straight- Opamp IC4 splits the supply voltage through’ serial interface com- obtained from 9 V (PP3) battery BT1 into puter cable. The Tone Extender symmetrical rails V+ and V–. Alternatively, circuitry may be built in a Vero a battery eliminator with a regulated out- style box, of which an exam- put voltage of 9 V DC may be connected ple is shown in the photo- to K9, when the battery is automatically graph. Connection from disconnected. the unit to an unmodified guitar amplifier is via a Whatever method of construction is cho- standard guitar lead. sen, the unit effectively provides the guitar- Each pick-up sec- ist interested in experimenting with unusual tion consists of two pick-up configurations a flexible way of opamps from a TL074 quickly setting up and trying probably all package, one inverter possible variations, without having to get (e.g. IC1.A) and one buf- out the soldering iron and hard-wire each fer (e.g. IC1.B). Each has a nor- new idea. As such it should be an invaluable mal/invert switch (NOR/INV, e.g. aid to allowing all manner of sonic possibili- S1) to select the phase of the signal compo- ties to be realised. nent, and a 100-kΩ linear law potentiome- (080523-I) ter at its output to set the desired level. The

Lithium Battery Charger using BQ24103

Steffen Graf (Germany)

The BQ24013 is a simple-to-use charge con- VCC* troller suitable for use with lithium-ion and lithium-polymer batteries. A major advan- R8 tage it has is that it includes integrated power D2 D1 C1 10k MOSFETs capable of working with charge cur- 10µ 16V rents of up to 2 A. Its switching frequency is R4 R3

high, at 1.1 MHz, and so only a small external 1k 1k 3 6 4 coil is needed. In comparison to linear charg- JP1 IN1 VCC IN2 L1 R5 A+ 2 1 ing circuits the switching topology offers a STAT1 OUT1 * 4µH7 much higher degree of efficiency. 150m Ω 19 20 STAT2 OUT2 5 * PG IC1 13 15 A further benefit is that it is capable of charg- CELLS SNS 14 ing battery packs consisting of either a sin- BAT 7 BQ24103A gle cell or of two cells wired in series. Two TTC R6 8 11 ISET1 VTSB 1k LEDs indicate when the battery is being 9 A- ISET2 16 12 charged (D1 lights) and when the battery is CE TS fully charged (D2 lights). The charge current PGND1VSS PGND2 R1 R2 R4 is set by the choice of external resistors [1]. C2 17 10 18 C3

There are three currents to set: the initial (pre- 10k 10k 10k 10µ charge) current, the charge current and the 100n 25V charge termination current. 081147 - 11

With the component values given the pre- charge current is 67 mA, the charge cur- rent is 667 mA and the termination current cells. Even more important is to note that The minimum supply voltage for charging a is also 67 mA. The IC of course ensures that jumper JP1 should be fittedonly in the case single cell is 5 V; for charging two cells it is 9 V. the charging process is carried out correctly where two cells are being charged. When According to its datasheet, the IC is specified and in particular that the maximum permis- charging a single cell the jumper must not be for supply voltages of up to 16 V. sible cell voltage is never exceeded: this is fitted, or there is a risk ofexplosion or fire as Unfortunately the IC is only available in a extremely important for lithium chemistry the charging voltage will be too high. QFN20 package, which is rather tricky to

7-8/2009 - elektor 61 solder. In compensation, the tiny package with a DCR of less than 0.025 Ω (25 mΩ) and that are available can be found at [2]. For our does make it possible to build a complete a current rating of 4 A or more should be cho- prototype we used a type BQ24103A. 2 A charging circuit on less than 2.5 cm2 of sen. For R5 we used a Vishay 150 mΩ SMD (081147-I) printed circuit board. resistor in an 0805 package (available, for example, from Farnell), and for C3 a ceramic For the prototype, with a charging current of barrier-layer capacitor with a working voltage Internet Links [1] www.ti.com/lit/gpn/bq24103a 670 mA, we selected for L1 a 4.7 µH inductor of 25 V. If an electrolytic capacitor is used it [2] http://focus.ti.com/docs/prod/folders/print/ with a DC resistance (DCR) of 0.082 Ω (82 mΩ) must have a very low ESR. bq24103a.html rated for a current (DCI) of 1.72 A. If a charge current of up to 2 A is wanted, an inductor An overview of the various versions of the IC

12 V AC Dimmer

Peter Jansen (The Netherlands) diode starts to conduct. Then cur- rent starts to flow, driving T1 and R1 P1 The circuit described here is 470 Ω T3 into conduction. This produces derived from a conventional 10k a pulse at point B. The same prin- LA1 design for a simple lamp dimmer, A ciple applies to the negative half as you can see if you imagine a 4V7 of the sine wave, in this case with R3 TIC225 0W5 100W diac connected between points A max. D1, T2 and T4 as the key players.

and B. The difference between this T1 T2 12k The trigger angle can be adjusted circuit and a normal diac circuit is D1 with P1 over a range of approxi- that a diac circuit won’t work at mately 15 degrees to 90 degrees. 12 V. This is the fault of the diac. C2 provides a certain amount of

T3 T4 MT1 G 12V Most diacs have a trigger voltage MT2 noise decoupling. Depending in the range of 30 to 40V, so they on the load, the triac may need a can’t work at 12 V, which means D2 heat sink. You can use practically C1 TRI1 MT2 C2 the dimmer also can’t work. 12k any desired transistors; the types 1µ R2 4V7 R4 100n 0W5 G MT1 indicated here are only exam- The portion of the circuit between 27Ω ples. If the circuit does not dim T1, T4 = BC559 B TIC225 points A and B acts like a diac with T2, T3 = BC550 far enough, you can change the

a trigger voltage of approximately 090370 - 11 value of P1 to 25 kΩ. This allows 5.5 V. The network formed by R1, the trigger angle to be increased P1 and C1 generates a phase shift to 135 degrees. relative to the supply voltage. The ‘diac equivalent’ circuit outputs a phase- tive half of the sine wave. C1 charges when Note: this circuit works fine with normal shifted trigger pulse to the triac on each posi- the voltage starts to rise, with a time constant transformers, but not with ‘electronic’ tive and negative half-cycle of the sinusoidal determined by C1, R1 and P1. T1 does not transformers. AC voltage. start conducting right away. It waits until the (090370-I) This works as follows. First consider the posi- voltage across D2 reaches 4.7 V and the Zener

Simple Temperature Measurement and Control

Jochen Brüning (Germany) gram) is based around an ATmega48 micro- a wide linear temperature range from –50 °C controller with a 2-by-16 LCD panel and a to +150 °C and the TO220 package is particu- The circuit described here and its accom- rotary encoder. The base-emitter junction of larly convenient because it has a handy fix- panying BASCOM software arose from the an ordinary NPN power transistor in a TO220 ing hole and heatsink to allow good thermal need to control the temperature in a lami- package is used as the temperature sensor. contact. Note that the heatsink is electrically nator. The laminator does include its own Although this technique is not often seen, connected to the collector of the transistor, temperature controller, but it was not suit- it is far from new: decades ago Elektor pub- so it may be necessary to use an insulating able for the author‘s purposes (making lished a digital thermometer design with an washer. printed circuit boards using a thermal trans- NPN transistor pressed into service as the fer method [1]). The result (see circuit dia- sensor. The approach has the advantage of The BD243C is wired as a diode by connecting

62 elektor - 7-8/2009 LCD1

2 x 16 +5V +5V S L1 W

K1 VS VDD VO RS R/ E D0 D1 D2 D3 D4 D5 D6 D7

2 1 MOSI 10uH +5V 1 2 3 4 5 6 7 8 9 10 11 12 13 14 C2 C3 4 3

6 5 RST 100n 100n 8 7 SCK P1 10 9 MISO 7 20 VCC AVCC 1 2 10k ISP PC6(RESET) PDO(RXD) 3 IC1 PD1(TXD) +5V +5V 23 4 PCO(ADC0) PD2(INT0) 24 5 DB5 PC1(ADC1) PD3(INT1/OC2B) R1 25 6 E PC2(ADC2) PD4(T0/XCK) 26 11 R/W

4k7 PC3(ADC3) PD5(T1/OC0B) 27 12 PC4(ADC4/SDA) PD6(AIN0/OC0A) 28 13 DB7 PC5(ADC5/SCL) PD7(AIN1) K2 ATmega48 S1 C1 DIL28 R 14 PB0(ICP1/CLKO/PCINT0) ROTARY WE ENCODER 47u 15 PO PB1(OC1A/PCINT1) 16V R4 R3 R2 16 PB2(SS/OC1B) 17 * PB3(MOSI/OC2A)

330R 330R 330R 18 PB4(MISO) 19 PB5(SCK) 21 9 DB4 AREF PB6(XTAL1/TOSC1) 10 DB6 T1* PB7(XTAL2/TOSC2) D3* D2 D1 C4 GND AGND S1 = ALPS EC11E15244BY 100n 8 22 BD243C

TEMP. PROBE OPTPOCOUPLER LED 090204 - 11 its collector and base together and powered line shows the current set point (upper and from the 5 V rail via a 4.7 kΩ resistor. A cur- lower temperature switching thresholds). P1 Details of the control process can be found rent of approximately 1 mA therefore flows adjusts the contrast of the LCD. by inspecting the BASCOM source code. Cali- through the diode. The voltage across the The two LEDs show the state of the controller bration of the temperature measurement, as diode has a reasonably constant negative at a glance. If the blue LED (D2) is lit, the tem- mentioned above, is done by directly mod- temperature coefficient of around –2 mV/K, perature is too low (below the lower switch- ifying the software. Remove the comment and so the plot of voltage against temper- ing threshold); if the red LED (D1) is lit, the characters (‘) from lines 105 to 107 of the ature is reasonably straight. The voltage is temperature is too high (above the upper program, and comment out lines 108 to 110 measured using the ATmega48’s internal switching threshold); and if both LEDs are lit by adding a single inverted comma at the A/D converter using input ADC5 on pin 28. the temperature is just right (between the start of each. The display will now show the A point to note is that we can use the 1.1 V lower and upper switching thresholds). conversion results from the A/D converter internal reference voltage to obtain good Since at least one LED is always lit there is no in the ATmega48. Immerse the sensor in a precision when converting the diode voltage need for a power indicator LED. mixture of ice and water and wait until the drop, which is around 0.6 V. Not all AVR-series The output of the controller is the logic level reading stabilises. Note down the conversion microcontrollers have the 1.1 V internal refer- on pin 27 (PC4). The author used this to drive result (or take a number of results and aver- ence for the A/D converter, which should be a solid state relay (SSR) in his application age them for better accuracy). Now immerse borne in mind if modifying the design to use which in turn controlled the heating element the sensor in boiling water and repeat the a different microcontroller. in the laminator. The circuit diagram shows procedure. Replace the number 546 in line The set point for temperature control is this as LED D3, which is intended to represent 86 of the source code with the conversion entered using the rotary encoder in one the LED in the optocoupler in the SSR. result for the ice-water mixture. Now sub- degree steps. Turn the encoder to the right to tract the conversion result for boiling water increase the set point, to the left to decrease ISP connector K1 is optional and can be dis- from the ice-water result and divide by 100: it. It is possible to set upper and lower thresh- pensed with if a ready-programmed micro- substitute the answer for the value 2.460 in olds for switching. If the rotary encoder has controller is used (see ‘Downloads and prod- line 87 of the source code. a pushbutton function, this can be used to ucts’). It will then not be possible to calibrate select between setting the upper and lower the temperature reading, as this can only As indicated at the start, we assume in this thresholds; if not, a separate button must be be done in the software using the ISP inter- calibration that the conversion result versus fitted. face. However, for many one-off applications temperature relationship is linear. We can it will be sufficient to determine the upper write this in the form y = mx + c, where c is The display consists of the LCD panel and and lower switching thresholds experimen- the A/D conversion result at 0 °C (the inter- two LEDs. The upper line of the LCD shows tally, including compensation for any error in cept of the A/D conversion result axis) and the measured temperature and the lower the temperature measurement. m is the (negative) slope of the base-emit-

7-8/2009 - elektor 63 ter junction voltage-temperature character- Internet Links Download istic, calculated by dividing the difference [1] http://thomaspfeifer.net/direct_toner_pcb.htm 090204-11: source code files, from [2] between the conversion results at 0 °C and [2] www.elektor.com/090204 100 °C by 100. These two numbers allow you map any conversion result into a correspond- Product ing temperature. 090204-41: ready-programmed ATmega48 microcontroller (090204-I)

USB Switch

before the data signals are Rainer Reusch (Germany) connected. The electronic switch does not suffer from Anyone experimenting or the same contact problems developing USB ported as the physical connector peripheral hardware soon so these measures are not becomes irritated by the required in the circuit. The need to disconnect and simple circuit can quite eas- connect the plug in order ily be constructed on a small to re-establish communica- square of perforated strip- tion with the PC. This proc- board. The design uses the ess is necessary for exam- 74HC(T)4066 type analogue ple each time the peripheral switch, these have better equipment is reset or a new characteristics compared to version of the firmware is the standard 4066 device. installed. As well as tiresome The USB switch is suitable it eventually leads to exces- for both low-speed (1.5 MBit/ sive contact wear in the USB s) and full-speed (12 MBit/s) connector. The answer is to USB ports applications but build this electronic isolator the properties of the ana- which disconnects the peripheral device at data lines and switching the MOSFET on. The logue switches and perf-board construction the touch of a button. This is guaranteed to PC now recognises the USB device. Pressing will not support hi-speed (480 MBit/s) USB reduce any physical wear and tear and restore S1 disconnects the device. operation. calm once again to the workplace. The circuit does not sequence the connec- tions as a physical USB connector does; the The IRFD9024 MOSFET can pass a current of The circuit uses a quad analogue switch type power supply connection strips are slightly up to 500 mA to the peripheral device with- 74HC4066. Two of the switches in the pack- longer than the two inner data carrying strips out any problem. age are used to isolate the data path. The to ensure the peripheral receives power (080848-I) remaining two are used in a classic bistable flip-flop configuration which is normally built IRFD9024 using transistors. A power MOSFET switches T1 the power supply current to the USB device. IC1.B Capacitor C2 ensures that the flip flop always USB PC 3 4 device powers-up in a defined state when plugged D+ 5 K2 into the USB socket (‘B’ in the diagram). The K1 3 IC1.A +5V 1 peripheral device connected to USB socket ‘A’ 2 D– 2 1 D– 2 will therefore always be ‘not connected’ until 1 +5V D+ 3 13 GND 4 R3 R4 pushbutton S2 is pressed. This flips the bist- USB-B 4 GND USB -A able, turning on both analogue gates in the 10k 10k

9 IC1.D IC1.C 11 R1 R2 R5 IRFD9024 14 C1 6 12

IC1 1M 1M 1M 100n 7 8 10 C2 D1 S1 S2 IC1 = 74HC4066 1n S G 080848 - 11 D

64 elektor - 7-8/2009 COMPILERS mikroElektronika DEVELOPMENT TOOLS | COMPILERS | BOOKS

Now you need a... mikroC mikroBasic OK. COMPILER mikroPascal

($$#%'"- "- !$%&&)- %"- #- !%##"'%# %&-   - ("%&- #- %,.'#.(&   "-!",-"'%'-'## &-! &- %#  '%#" -#!$ %&-#"-#-'-&'-#&-#" '- !% '- '#,- &&-  - ! %#  '%#" - #!$ %&- #%- -     - &!( '#%-    #%-%$-&$ ,&-.&!"'-&$ ,-#")%&#"-'## - -'   #- +$#%'-    #%-   -    '%"'- "-  -  -$%#%!!"-!#-!"!"'-'- ( '."-"-%%,-#('"&-*'-+!$ &

43  3& , ,2 43  3& , ,23 43#2+ "3& , ,23 43 3& , ,23 43 )!%#-.#,3 *"#3& , ,23 43 3& , ,23 43 3& , ,23 43/'.&3#"& 3 ,"3& , ,23 43 3 /-.*(3& , ,23 43 *(+ !.3' -%3& , ,23 43)#&,#3& , ,23 43.&'3& , ,23 433& , ,23 433& , ,23 433 3& , ,23 43.%#,)#.3  11 3& , ,23 433& , ,23 433  3& , ,23 433.%#,)#.3& , ,23 434 3& , ,23 433, +%&!3 3& , ,23 43' -%3#(*,23& , ,23 43*$.0 ,#3 3& , ,2 43*,.31+ )"#,3& , ,23 43, +%&!3 3& , ,23 43*/)"3& , ,23 43*$.0 ,#3 3& , ,23 43  3, +%&!3 3& , ,23 433& , ,23 433  3, +%&!3 3& , ,23 43 3& , ,2 43 3& , ,23 )"3( )23(*,#

http://www.mikroe.com/ S O F T W A R E A N D H A R D W A R E S O L U T I O N S F O R E M B E D D E D W O R L D projects electric vehicle ElektorWheelie The electronics behind a rather special kind of vehicle

Chris Krohne (Germany)

In this first article describing our DIY self-balancing single-axle vehicle we look at the electronics modules. An ATmega32 processes the controls and sensor data and drives the two electric motors via power driver stages. It keeps the vehicle balanced and can drive it in any desired direction at any desired speed from stationary to about 11 mph.

The electronics in the ElektorWheelie trols the magnitude and direction of enough information to allow the vehi- processes input signals from a control the torque applied to the wheels via cle to maintain its balance over its full potentiometer, an acceleration sen- two motors using PWM signals and range of speeds, and it can even spin sor and an inclination sensor. It con- MOSFET drivers. The sensors provide on the spot.

Characteristics Sensors: • Two 500 W DC drive motors • Invensense IDG300 (or IDG500) gyroscope • Two 12 V lead-acid AGM batteries, 9 Ah • Analog Devices ADXL320 accelerometer • Two fourteen-inch wheels with pneumatic tyres • Allegro ACS755SCB-100 current sensor • H-bridge PWM motor control up to 25 A • Automatic power off on dismount Microcontrollers: • Fail-safe emergency cutout • ATmega16 (motor control) • Battery charge status indicator • ATtiny25 (current monitoring) • Maximum speed approx. 11 mph (18 km/h) • Range approximately 5 miles (8 km) Compiler: • Weight approximately 35 kg • BASCOM-AVR Basic compiler

66 elektor - 7-8/2009 A delicate balance For the vehicle to be able to balance successfully it is essential that the sensors provide reliable information about the inclination of the platform and its angular velocity. This is in addition, of course, to ensuring that the control system, motor drivers and motors themselves are properly designed. Balancing itself is relatively straightforward. If the rider leans forwards the platform tilts and the motors are driven so as to bring the whole sys- tem (vehicle plus rider) back towards balance. That means that the rider’s feet are pushed forwards under the centre of gravity of the whole sys- tem, opposing the rider’s leaning and reducing the tilt angle. The system therefore tilts as a whole, which requires both a strong mechanical construction and a carefully designed and experimentally tested filter function. The damping characteristic of the filter is set just short of the point where the system starts to become unstable. Steering is performed by applying differential acceleration or braking to the two motors. Note that at higher speeds the tightness of the turning circle has to be limited. In the ElektorWheelie the limit is set so that the rider cannot overturn the vehicle by trying to change direction suddenly. No motor has an infinite amount of power. In the case of the ElektorWheelie there is the potential for serious consequences for the rider if a mo- tor does not have enough power headroom to allow for balance to be maintained. For this reason the motors are normally only driven up to approximately 70 % of their maximum power. This keeps a little in reserve so that, when top speed is reached, the wheels can be given a small extra acceleration. This throws the rider back slightly, which automatically leads to a reduction in speed. Leaning back slows the vehicle down, leaning forwards speeds it up.

The drive train is based on two In normal operation the ATtiny25 will controller to attempt to reduce the cur- 500 watt DC electric motors, with also notify the ATmega32 when the rent by limiting the range of the PWM power being provided by two 12 V motor current exceeds a preset value control signals. AGM (absorbed glass mat) lead-acid of around 25 A, which will cause the The ATmega32 receives sensor inputs batteries. Most of the electronics is located on a control board, with a sen- sor board mounted on it. The control system uses dynamic sta- 2x 12V 9 Ah bilisation. The vehicle senses the atti- AGM-Lead battery tude of its platform in an analogous way to the human sense of balance. If the platform starts to tilt forwards or emergency backwards, the vehicle makes a pro- stop breaker portional acceleration to oppose the tilt using both motors. By applying different amounts of drive to the two motors, the vehicle can turn. current sensor

Block diagram voltage regulator voltage regulator 15V Central in the block diagram of the 5V ATtiny25 with ‘enable pin’ attitude control and motor drive unit shown in Figure 1 is an Atmel ATmega32 microcontroller. This has two PWM outputs that are used to foot- PWMOC1A power H-bridge 24VDC drive the two 24 V DC motors via a switch Motor A pair of MOSFET H-bridges. A second microcontroller, an Atmel ATtiny25 this ATmega32 time, monitors the motor current using battery a Hall effect sensor. If an excessive cur- indicator rent (over 80 A) should flow because of a short circuit in the system, the 24VDC PWMOC1B power H-bridge ATtiny25 interrupts the 15 V power ADC Motor B supply to the H-bridge driver circuitry using the shutdown input of its regula- tor. In the event of a total failure of the control electronics the battery current Invensense ADXL320 pot / handlebar can also be interrupted using a purely gyroscope accelerometer electromechanical emergency stop 090248 - 13 device, providing the ultimate protec- tion against the vehicle running out of control. Figure 1. Block diagram of the motor controller.

7-8/2009 - elektor 67 projects electric vehicle

using its ADC (analogue-to- nector K4 and to the digital converter) from the VCC three LEDs, LED1 to gyroscope and the acceler- LED3, that show the VCC ometer on the sensor board 14 29 34 battery status. K2 K1 VDD VDD VDD and from the high-reliabil- AREF (3V) The sensor board is 32 IC1 17 ity potentiometer that is VREF CPOUT connected to K2 on R3 mechanically connected to 28 23 the control board. The GYRO-Y 75R Y-RATE OUT YAGC the steering control of the GYRO-X R4 IDG-300 X-axis and Y-axis out- 3 8 ADXL-X 75R X-RATE OUT XAGC ElektorWheelie. The ADC ADXL-Y puts of the sensors inputs are sampled around are connected to A/ GND GND GND GND GND GND

100 times per second. 2 22 25 38 39 40 D converter inputs C11 C12 C9 C2 C10 As a further safety fea- +5V ADC2 to ADC5 on ture a footswitch is con- 1u 1u 220n 220n 100n the ATmega32, and nected to an input of the pin 32 (AREF) is fed ATmega32. If this switch +5V VCC with 3 V from the volt-

is not held down (because IC3 age regulator on the 1 5 the rider has dismounted) VIN VOUT sensor board. The 3 V LP2980 3 the microcontroller will ON/OFF supply is also taken

interrupt the motor current 2 to K3 where it pro- 14 15 VCC after two seconds. This VS VS vides power to the 10 also helps to prevent the IC2 YOUT steering potentiome- ADXL320 12 vehicle from running away C1 XOUT ter. The wiper of this C14 C15 C16 ST COM C4 C3 on its own. 2µ2 2 3 5 6 7 potentiometer thus 16V 100n 100n 4u7 The battery voltage is 2n2 2n2 6V provides a voltage to also monitored by the 090248 - 12 analogue input ADC6 ATmega32 using its ADC, on the ATmega32 and used to drive three that depends on the LEDs that indicate the Figure 2. Circuit diagram of the sensor board with gyroscope and accelerometer. position of the steer- remaining available run- ing control. Analogue ning time to the rider. is important to determine the attitude input ADC0 measures the battery of the platform as accurately as pos- voltage via the voltage divider com- sible at each instant in time. The out- prising R10 and R11, and ADC7 moni- Sensors and stabilisation put of the accelerometer is therefore tors the position of the footswitch via The attitude sensors are mounted on integrated over a relatively long time K3. The fault detection signal (CURR- their own small printed circuit board period to obtain a smoothed signal. To FLAG) is taken to pin 16 (INT0) of the that plugs into the main control board. this smoothed result is added the out- ATmega32 from the ATtiny25 current Figure 2 shows the circuit of the sen- put of the gyroscope, in proportions monitor IC10, which in turn is con- sor board, which includes an Inven- that have been empirically optimised. nected to current sensor IC5. IC5 is an sense IDG300 [1] two-axis gyroscope The acceleration signal delivered to integrated Hall effect sensor from Alle- and an Analog Devices ADXL320 [2] the motor controller is calculated as a gro Microsystems offering linear oper- two-axis accelerometer. Voltage reg- preset linear combination of the atti- ation up to 100 A. CURRFLAG is set ulator IC3 provides the required 3 V tude error (the difference between the if the current reaches approximately supply for the sensors; this voltage actual inclination angle and the tar- 25 A and causes the motor current to also serves as the reference voltage get inclination angle) and the angular be limited by bounding the range of for the ATmega32’s A/D converter on velocity with which the platform is tip- the PWM drive signal. the main board. ping. In essence, the greater the atti- We now turn to the output signals of The output of the gyroscope is a volt- tude error and the greater the angular the ATmega32. The result of process- age proportional to the rate at which velocity, the greater the motor accel- ing the various inputs to the microcon- it is turning (its angular velocity). If eration required for stabilisation. troller appear as the signals on the four the platform is tipping rapidly there outputs PWM-L, PWM-R, CW/CCW-A will be a large and rapid swing in the and CW/CCW-B, on pins 18 to 21. CW/ gyroscope’s output voltage. When sta- Motor control CCW-A and CW/CCW-B are logically tionary the output voltage of the gyro- The circuit diagram of the main printed combined with the PWM outputs PWM- scope is approximately half its supply circuit board in Figure 3 contains all L and PWM-R in IC8 and IC9 is such voltage. of the control circuitry of the Elektor- a way that they determine the direc- The accelerometer measures the com- Wheelie, including the power driver tion of rotation of the motors, while the ponent of the acceleration due to stages. Only the attitude sensors, as PWM signals control the current deliv- gravity in its own plane. If the sen- mentioned above, are mounted on a ered to the motors via the H-bridges. sor is tilted this will affect the angle separate board. Each motor thus has two control sig- at which gravity acts relative to the It is fairly easy to identify the com- nals and a complete H-bridge driver, device, which therefore operates as an ponents corresponding to the vari- inclination sensor, delivering an out- ous parts of the block diagram. In the put depending on the attitude of the centre is the ATmega32, clocked at platform. 16 MHz. It is directly connected to 10- Figure 3. Circuit diagram of the main board, To obtain the best possible stability it way in-system programming (ISP) con- including control and power electronics.

68 elektor - 7-8/2009 +15V

C7 C32

+24V-BATT 4u7 100n 100V C3 C35

D1 D2 470u 63V 470n

C6 C34 T5 T7 C33 C8 IC8, IC9 = 4001N 1N4936 1N4936 +5V 4u7 100n 2x 100n 4u7 100V IRF1405 100V 5 8 8 5

14 C26 14 C27 VCC VB R26 R24 VB VCC 1 7 M 7 1 IC8 IC9 IN HO 4R7 4R7 HO IN 7 100n 7 100n R21 IC3 IC4 R19 6 MOTOR A+ MA+ MA– MOTOR A– 6 VS VS

4k7 IR2184 R25 R23 IR2184 4k7 2 4 K5 4 2 SD LO 4R7 T6 T8 4R7 LO SD COM COM

IC8.D 3 2x 3 3 12 IC8.B 4 IC8.A 11 IRF1405 13 ≥1 ≥1 ≥1

IC9.D 6 5 2 1 12 11 ≥1 13 IC8.C 8 10 9 ≥1 R18 +15V 4k7 C4 C29

+24V-BATT 4u7 100n 100V C1 C37

D3 D4 470u 63V 470n

C9 C31 T1 T3 C36 C5 1N4936 1N4936 4u7 100n 2x 100n 4u7 C2 100V IRF1405 100V 5 8 8 5 470u 63V VCC VB R30 R28 VB VCC 1 7 M 7 1 IN HO 4R7 4R7 HO IN +5V R22 IC1 IC2 R20 6 MOTOR B+ MB+ MB– MOTOR B– 6 VS VS C23 4k7 IR2184 R29 R27 IR2184 4k7 2 4 K6 4 2 SD LO 4R7 T2 T4 4R7 LO SD 1u 63V COM COM K7 1 3 2x 3 BATT+ VCC IC9.B 4 IC9.A 3 4 IRF1405 IP+ IC5 ≥1 ≥1 (+24V) (Allegro) R17 3 USHUNT VOUT 1k 6 5 2 1 ACS755-SCB 5 -100 IP– C24 IC9.C 8 GND 10 9 ≥1 2 100n

R1 +5V +5V

4k7 C22 R10 UBATT R12 68k 100n 15R R11 CURRFLAG C28 C15 C13 IC10 8 VCC

10k 100n 100n 1 2 100n PB5(RESET) PB3(ADC3) 3 6 10 30 PB4(ADC2) PB1(MISO) 5 7 VCC AVCC PB0(MOSI) PB2(SCK) 14 22 PD0(RXD) (SCL)PC0 GND 15 23 PD1(TXD) (SDA)PC1 4 16 24 IC6 PD2(INT0) (TCK)PC2 ATTINY25PDIP 17 25 R16 7805 +5V PD3(INT1) (TMS)PC3 PWM-L 18 26 150R PD4(OC1B) (TDO)PC4 PWM-R 19 27 PD5(OC1A) (TDI)PC5 CW/CCW-A' 20 28 +5V PD6(ICP1) (TOSC1)PC6 C11 C12 C10 CW/CCW-B' 21 29 PD7(OC2) (TOSC2)PC7 K2 K1 47u +5V R15 IC7 100n 100n 1 40 UBATT 63V +5V 10k PB0(XCK/T0) (ADC0)PA0 2 39 PB1(T1) (ADC1)PA1 3 38 ADXL-Y PB2(INT2/AIN0) (ADC2)PA2 +15V K4 4 37 ADXL-X PB3(OC0/AIN1) (ADC3)PA3 2 1 MOSI 5 36 GYRO-X PB4(SS) (ADC4)PA4 4 3 6 35 GYRO-Y IC11 PB5(MOSI) (ADC5)PA5 R3 4 5 R2 6 5 RST 7 34 IN OUT C25 PB6(MISO) (ADC6)PA6 C14 C20 8 7 SCK 8 33

10k MIC2941 PB7(SCK) (ADC7)PA7 2 1 100k 10 9 MISO SHTDWN ADJ 4u7 ATMEGA32-PDIP 100n 100n 100V 9 32 RST AREF GND R5 ISP GND XTAL1 XTAL2 GND 3 R7 R8 R9

6k8 11 13 12 31 K3 X1 FOOTDETECT

240R 240R 240R AREF C30 R4 R6 C21 R14 LED3 LED2 LED1 16MHz 2k2 4k7 C17 C18 C19 C16 POT K8 4k7 4u7 R13 BATT– 100n 63V 100n 27p 27p 100n 4k7

(GND) ENABLE 090248 - 11

7-8/2009 - elektor 69 projects electric vehicle

the two lead-acid AGM batteries in series via current sensor IC5. The half-bridge driver ICs receive their own 15 V supply from the MIC2941 voltage regulator IC11. This IC has a shutdown input (pin 2) that is con- nected to the ‘enable’ output signal from the current monitoring circuit (pin 5 on IC10). When excess current is detected this signal shuts down the regulator and hence also the bridge driver ICs. The MOSFETs then block and the motor current is interrupted. All the other ICs are powered with 5 V from IC6, a standard regulator.

A compact module Figure 4 shows the metal chassis of the vehicle. The electronics module (Figure 5), comprising the main board (Figure 6) and the sensor daughter board (Figure 7) is mounted on the underside of the platform. The eight MOSFETs are positioned in a row on the reverse of the main board and are cooled using a specially- designed common heatsink. The heat- sink is bolted to the printed circuit board and the MOSFETs are held on to the heatsink using spring clips. A self- Figure 4. The batteries and electronics module are mounted on the underside of the metal chassis. adhesive thermally conductive sheet between the MOSFETs and the heat- sink provides electrical isolation. and each H-bridge is composed of two to T4, while the right wheel motor is The main board contains only leaded half-bridge driver ICs type IR2184 and driven by IC3, IC4 and T5 to T8. devices, in contrast to the SMD-popu- four IRF4105 MOSFETs. The left wheel The MOSFET bridge circuits are pow- lated sensor board. The printed circuit motor is driven by IC1, IC2 and T1 ered from the 24 V supply derived from board layouts are as usual available for free download from the project web pages [3] as PDFs, along with associ- ated parts lists.

Software The firmware for the two microcontrol- lers was written using BASCOM-AVR. Figure 8 gives an overview of the main functions involved in controlling the motors, which will be described briefly below.

Function Init: This function initialises and configures Timer0, Timer1 and the PWM outputs, initialises variables and calibrates the gyroscope, accelerometer and steering potentiometer.

Function Get_Angle: This function reads values from the analogue inputs (gyroscope, ADXL320, potentiometer, battery voltage and footswitch). The gyroscope, ADXL320 and battery voltage readings are inte- Figure 5. The compact electronics module comprises the main board with heatsink and sensor daughter board. grated over a period of fifty samples.

70 elektor - 7-8/2009 Then the angular velocity (Angle_Rate) and absolute angle (Tilt_angle) are calculated. Function Init

Function Filter: - variable initialization This function calculates the change - configure Timer0 for interrupt in acceleration required of the motors - configure Timer1 as PWM (Balance_Diff) and the overall motor - read calibration values speed (Drive_Speed). - activate interrupt

Function Process: Main routine This function uses the current speed and the position of the steering control Idling… everything taking place to calculate the necessary modification in the interrupt routine … to the speed of the motors to turn the vehicle as requested. It checks to see if the ATtiny25 has reported an overcur- rent condition and reduces the motor Function Get_Angle Function Interrupt speed (Drive_speed) if needed. The overcurrent condition and footswitch - read A/D channels - calculate angular rate and angle deactivate interrupt alarm states are indicated by the LEDs - integrate gyro value flashing. - integrate ADXL value gosub Get_Angle The function calls Get_speed_batt. gosub Filter gosub Process gosub PWM_Out Function Get_speed_batt: Function Filter This function adds a value Angle_Cor- activate interrupt - calculate balance moment rection in the case where the maxi- - calculate Drive_Speed mum speed is exceeded. It also sets the state of the three LEDs according to the battery voltage. Function Process

Function PWM_Out: - calculate steering movement - calculate motor speed This function configures the PWM - check current flag outputs according to the acceleration - gosub Get_speed_batt required for motors A and B, and sets the other outputs to reflect the desired rotation direction. Function Get_speed_batt The function also imposes a limit on the yes maximum drive power (PWM_MAX). speed > activate angle correction max_speed? Function interrupt: no This function is called 100 times per deactivate angle correction second. In turn it calls Get_Angle, Fil- ter, Process and PWM_Out. display battery status 090248 - 14 Mechanics In the second and final part of this Figure 6. Control software functions. series we will look at the mechanics of the ElektorWheelie. We will describe the construction of the vehicle and out- DISCLAIMER & CAUTIONS line how it is assembled and wired. Finally we will give a few tips on how • The ElektorWheelie vehicle is an Open Development. The buyer is free to drive the vehicle and some further to make changes and modifications to the hardware or software of the practical suggestions. ElektorWheelie kit, at his/her own risk. (090248-I) • The use of ElektorWheelie on public roads or in public spaces may be illegal and/or subject to legislation and type approval. No type approval has been applied for and owners are advised to check local or national legislation for Internet links any use other than on private land, or with the land owner’s permission. Elektor International media BV accepts no responsibility in this respect [1] http://www.invensense.com/shared/pdf/ whatsoever. DS_IDG300.pdf [2] http://www.analog.com/static/imported-fi- • Under the terms of an Open Development Elektor International Media les/data_sheets/ADXL320.pdf cannot be held liable for any damages, penalties or injuries caused by, or arising from, the use, ownership or assembly of the ElektorWheelie vehicle. [3] http://www.elektor.com/090248

7-8/2009 - elektor 71 Load Protection for Audio Amplifiers

Joseph Kreutz (Germany) 1 As soon as the relay control sig- +VSS(RE) nal goes high and the relays turn In order to be effective, any pro- on, the IC1d oscillator is disabled tection device connected between B1 A D1 R1 +10V and LED remains constantly lit. The 2k2 an audio amplifier output and the D4 LED is powered directly from the 1N4007 1W speakers needs to connect the +5V HT rail across C1, and 3.3kΩ resis- load only after a few seconds’ 5V1 tor R8 limits the current through it delay, disconnect it immediately to 10 mA. As shown in Table 1, the D5 14 C1 C2 the mains supply is turned off, C5 IC1 value of R8 depends on the supply

470u 10u 7 100n and prevent any high-level DC 63V 5V1 25V voltage and hence on the power of component from being able to D6 the amplifier to which the protec- C3 C4 IC1 = 74HCT132 R8 damage the loudspeakers. As the tion circuit is to be connected.

100u 10u 3k3 63V 5V1 25V circuit suggested here can read- 1W As soon as the mains is turned off, D7 ily be ‘grafted’ onto any existing D8 IC1a output goes high and capaci- circuit, it merits the title ‘univer- tor C6 discharges rapidly through R2 5V1 sal’. The circuit diagrams in Fig- 1k2 D2, which then causes IC1b out- R3 1W –10V ures 1 and 2 relate to a prototype C6 R6 put to go low and the relays RE1 1M 1M fitted to an amplifier producing 4u7 63V and RE2 to turn off almost imme- IC1.D T1 IC1.A IC1.B IC1.C 12 R7 50 W into 8 Ω, with a ±35 V power 1 B R5 4 10 11 diately. So the amplifier load is 3 6 8 13 & 10k 2 & 680k 5 & 9 & supply. This circuit can be readily D2 BC639 isolated instantly and the circuit adapted to other supply voltages, R4 re-armed so as to produce the C7 D3 C8 and hence to other audio power 2x required delay next time mains 470k 1N4148 outputs. The appropriate values 220n 220n power is applied. for R1, R2, R8, R15, and R19, along RE with the operating voltages for C1 090236 - 11 Detection of any DC component is and C3 and the choice of semicon- performed by IC2, an LM339 quad ductors D9, D10, T1, T2, and T3 are comparator. The networks C9/R12 given in Table 1. V rail. This circuit works by determining volt- and C10/R16 act as low-pass filters: they atten- age thresholds: this means that we need to uate the audio signal very heavily, but if any Circuit operation is simple: when the ampli- choose an SN74HCT132 quad Schmitt NAND DC voltage is present on the amplifier output, fier is turned on, the voltage at the junction gate for IC1. it will be fed to IC2’s comparator inputs. If it of bridge rectifier B1 and diode D1 quickly exceeds ± 3.75 V, at least one of the compa- charges capacitor C7 via resistor R3. Capacitor Gate IC1c inverts the relay control signal and rators will output a ‘low’ signal, and thus turn C7 avoids mains zero crossings causing spu- feeds it to one input of IC1d, which then oper- off the corresponding relay control transistor. rious triggering. When the upper threshold ates as an oscillator, making LED D8 flash at The load will remain isolated as long as the voltage of IC1a is reached, its output goes low. around 4 or 5 Hz during the delay period. fault condition continues. This signal will also At this moment, cause current to C6 is gradually flow in the LEDs charged via R5, 2 +VSS(RE) D11 or D12, indi- and once the cating that the voltage across RE protection has it reaches the R15 R19 been activated. +10V required value, Zener diodes D13

680R 1W 1W 680R IC1b output goes R9 to D16 provide RE1 RE2 D9 R14 R18 D10 high and turns 68k over-voltage

3k3 5 9 3k3 relays RE1 and 2 14 protection for IC2.A IC2.C RE2 on via tran- 1 1N4148 4 8 1N4148 2 the comparator T2 R10 T3 sistors T2 and R13 R17 inputs. It’s wise T3. This process 1k5 82k 1k5 to make sure CHANNEL CHANNEL BC639 D11 7 11 D12 BC639 produces a delay 1 13 that R12 and R16 IC2.B IC2.D of around 5 s. In 6 10 are indeed cor- R11 order for us to be R12 R16 rectly connected 470k 470k certain that IC1b D13 68k D15 to the amplifier AMP +10V AMP output starts off outputs and not C11 low, the initial C9 5V1 –10V 5V1 C10 to the relay con- 100n 3 D14 D16 2u2 2u2 voltage across IC2 IC2 = LM339 tacts feeding the C6 must be zero. C12 12 loudspeakers. 5V1 5V1 So this capaci- 100n The choice of 090236 - 12 tor is connected –10V r e l a y s i s n o t directly to the +5 really critical: any

72 elektor - 7-8/2009 Table 1. Stereo (2-channel) amplifier Supply voltage [V] 27 35 47 56 64 70 76 Power into 4 Ω [W] 50 100 200 300 400 500 600 Power into 8 Ω [W] 25 50 100 150 200 250 300 Working voltage for C1 (470 μF) & C3 (100 μF) [V] 40 63 63 80 80 100 100 Value for R1 1k8, 0,25 W 2k2, 1 W 3k3, 1 W 4k7, 1 W 4k7, 1 W 5k6, 1 W 5k6, 1 W Value for R2 820 Ω, 1 W 1k2, 1 W 1k8, 1 W 2k2, 2 W 2k7, 2 W 2k7, 2 W 3k3, 2 W Value for R3 2k7, 0,25 W 3k3, 1 W 4k7, 1 W 5k6, 1 W 6k8, 1 W 8k2, 1 W 8k2, 1 W Value for R15 & R19 (*) - 680 Ω, 1 W 1k2, 1 W 1k8, 1 W 2k2, 1 W 2k7, 2 W 2k7, 2 W D9 et D10 1N4148 1N4148 1N4148 1N4148 1N4148 BAV21 BAV21 T1, T2, T3 BC639 BC639 BC639 BC639 BC639 2N5551 2N5551 * for 24 V relays drawing a current in the region of 15 mA. type that has a high enough break- for the circuit directly from the ing capacity, works from 24 V, and 3 amplifier’s power transformer only needs around 15–25 mA to terminals, before the rectifier and drive it will do. The relays fitted smoothing capacitors, as shown AMP PROT to the prototype are RT 314024 in the connection diagram in Fig- RE1 ones made by the Austrian com- ure 3. This voltage is rectified by pany Schrack [1]. They can switch bridge rectifier B1 and applied via 16 A, which is enough for ampli- D1 to the 470 µF smoothing capac- fiers with pretty reasonable pow- R12 itor C1. The power for the relays ers. The prototype is fitted to a and LED D8 is taken from directly 50 W per channel stereo ampli- across this capacitor. Diode D1 fier, whose 35 V supply voltage is RE2 allows capacitor C1 to be iso- higher than the relays’ rated oper- lated as soon as the mains power ating voltage. So it was necessary goes off: so when the amplifier is to fit series resistors R15 and R19 in turned off, there is zero voltage R16 order to drop the excess 11 V. As at IC1a input , and the relays are the relay coil resistance is 1,450 Ω, guaranteed to be off. The +10 V these series resistors need to be and +5 V rails are regulated by 680 Ω and rated for a dissipation of V- 0V V+ 0V zeners D4 and D5, while D6 and 1 W. Naturally, the value of R15 and D7 stabilize the −10 V rail feeding R19 depends on the type of relay TR IC2. Using two zeners in series lim- chosen and the amplifier’s supply its the power each of them has to B voltage, as shown in Table 1. How- 230V dissipate. (120V ) ever, the value isn’t critical, as the C relays are pretty tolerant about F It is perfectly simple to extend the their operating voltage. Besides, C circuit for 5+1 or 7+1 channel audio it’s easy enough to find out the systems, as used on an increasing resistance of a relay coil: just meas- 090236 - 13 number of computers. And it’s ure it with an ohmmeter! all the more advisable because the sound cards often produce It’s essential to pick up the power erratic signals when the computer

Table 2. System with 5+1 or 7+1 channels Supply voltage [V] 27 35 47 56 64 70 76 Power into 4 Ω [W] 50 100 200 300 400 500 600 Power into 8 Ω [W] 25 50 100 150 200 250 300 Working voltage for C1 (2200 µF) & C3 (470 µF) [V] 40 63 63 80 80 100 100 Value for R1 820 Ω, 1 W 1k2, 1 W 1k8, 1 W 2k2, 2 W 2k7, 2 W 2k7, 2 W 3k3, 2 W Value for R2 270 Ω, 2 W 390 Ω, 2 W 560 Ω, 5 W 680 Ω, 5 W 820 Ω, 5 W 820 Ω, 10 W 1k, 10 W Value for R3 2k7, 1 W 3k3, 1 W 4k7, 1 W 5k6, 1 W 6k8, 1 W 8k2, 2 W 8k2, 2 W Value for R15 et R19 (*) - 680 Ω, 1 W 1k2, 1 W 1k8, 1 W 2k2, 1 W 2k7, 2 W 2k7, 2 W D4 - D7 BZV85C5V1 or 5V1 device capable of dissipating 1 W D9 & D10 1N4148 1N4148 1N4148 1N4148 1N4148 BAV21 BAV21 T1, T2, T3 BC639 BC639 BC639 BC639 BC639 2N5551 2N5551 * for 24 V relays drawing a current in the region of 15 mA.

7-8/2009 - elektor 73 is powered up or down, which when ampli- 4 tem. Refer to Table 2 for the component val- fied can be at best unpleasant, and at worst, A ues for a protection circuit for a 5+1 or 7+1 damaging for the loudspeakers. channel system. The modifications mainly R3 affect the following points:

As shown in Figure 4, the +5 V supply rail 1M - The values of R1 and R2 are reduced, but present on the computer’s USB bus is applied their dissipation increased, as shown in Table to one of the inputs of gate IC1a, the other R4 2; C7 input being used to check the presence of the - C1 and C3 are also increased to 2,200 µF and 470k amplifier supply voltage. So both the compu- 220n IC1.A 470 µF respectively; 1 3 ter and the amplifier have to be running for 2 & B - Zener diodes D4 to D7 change to type the speakers to be connected after a 5-sec- BZV85C5V1 or equivalent, capable of dissi- ond delay. The 100 nF capacitor C13 avoids R20 pating 1 W. K1 47k unwanted triggering. Turning off the compu- 1 +5V R21 2 C13 ter or the amplifier disconnects the speakers D– (090236-I) 3

D+ 470k immediately. 4 GND 100n USB 090236 - 14 Internet Link The Figure 1 delay circuit, modified as per [1] www.schrack.com the circuit in Figure 4, is common to all chan- nels, and provides the relay control signal for them all. But the DC component switching to be repeated 3 or 4 times, so as to be able and protection unit shown in Figure 2 has to control the number of channels in the sys-

Impact Clock

G. van Zeijts (The Netherlands) (ground) is tied to the ground line 1 +12V 2N3055 of the control circuit. Use a hefty AC The read/write heads of a hard-disk mains adapter for the power supply; it drive are moved back and forth over L1 must be able to deliver at least 2 A. the magnetic platters by a linear * K1 motor. This motor consists of a coil * T1 E The mechanical design of the clock is R1 C 2mA0 2 B that moves in a strong magnetic field, 2k2 rather unusual. It consists of a length combined with some sophisticated of curtain rail arranged at an oblique TIP47 TIP47 electronics that drives it such that angle, along which a steel ball from a the read/write heads are quickly posi- T2 ball bearing can be propelled upward tioned to the desired location. and roll back down under its own R2 2N3055 weight. If the ball is struck by a blow By now enough hard-disk drives have whose strength depends on the time 4k7 crashed that every hobbyist should of day, it will travel for a certain dis- 19 GND have no trouble getting his or her B E tance along the curtain rail. By observ- 090121 - 11 hands on one and using it for other C ing the motion of the ball, you can purposes. read the time (approximately) from an hours scale marked along the length As the head motor has a fairly long of the rail. The previously mentioned stroke and can supply considerable head motor from a discarded hard disk force, we used it in this project to build drive is used to generate the impact a special sort of clock. on the ball. The ball rests against the If you simply apply a DC voltage to arm of the motor when it is at its low- the coil, the arm jumps from one end est point on the rail. The computer to the other one with a bang. If you calculates the force of the impact and reverse the polarity of the voltage, the drives the motor for a certain length arm moves in the opposite direction. of time. The voltage applied to the coil can be controlled by a PC with the aid of a The program for the clock is writ- Darlington circuit (Figure 1). We used ten in Visual Basic and has a simple one of the pins of the Centronics port design. The software is extensively on the computer (K1 in the schematic documented. drawing) to drive the circuit. Here the control signal is provided by pin 2 of Now for some practical details on the the Centronics connector, which cor- clock: responds to bit 0 of port H378. Pin 19

74 elektor - 7-8/2009 - Rail length approx. 160 cm - Coil voltage 5–12 V (depending on coil reaches the highest point of the rail. - Height difference (top/bottom) approx. resistance) (090121-I) 10 cm Download - Ball diameter 17 mm The hours scale on the rail must be deter- 090121-11: Visual Basic program, from www.elektor. - Head motor coil resistance 5–15 Ω (depend- mined experimentally after first adjusting com/090121 ing on hard-disk model) the impact for 12 o’clock so the ball nearly

Lead Acid Battery Protector

Jürgen Stannieder (Germany)

The circuit described here can be used to S1 D1 ensure that a 12 V sealed lead acid (SLA) R4 gel battery isn’t discharged too deeply. The 1N4148

R1 R3 3 3k principal part of the circuit is a bistable relay, k 10k 100 D3 which is driven by the output of an op amp. IC1

BT1 1 P1 3 7 The battery voltage is first reduced via D1, R1, 5 P1 and R2, and then continuously compared CA3140 6 2 RE1 with a reference voltage set up by diode D2. 4 12V 2k5 12V When the battery discharges too much and R2 D2 R S K1 its terminal voltage drops below the level C1 5V6 100k 1u set by P1, the output of the opamp becomes 0W5 High, which causes the relay to toggle. This 63V in turn isolates the load from the battery. The 080583 - 11 battery can be reconnected via S1 once the battery has been replaced or recharged. the battery voltage rises above the reference the zener diode used and the tolerance. The relay used in the prototype is a 5 V bist- voltage again, the reset coil will no longer be able type made by Omron (G6AK-234P-ST-US powered and the current consumption drops For a greater span you can use a larger value 5 VDC). The two windings of the relay each back to about 2.5 mA. for P1 without any problems. With the poten- have a resistance of 139 Ω (for the RAL-D 5 tiometer at its mid setting the circuit switches W-K made by Fujitsu this is 167 Ω). When the The range of P1 has intentionally been kept at about 11.6 V. battery voltage starts to become too low and small. With a reference voltage of 5.6 V (D2) (080583-I) the relay is being reset the current consump- and a voltage drop of 0.64 V across D1, the cir- tion of the circuit is about 45 mA. Shortly cuit reacts within a voltage span of 11.5 V and after the load has been disconnected, when 11.8 V. This range is obviously dependent on

Automatic Curtain Opener Ton Smits (The Netherlands) and reed switches acting as limit switches. When the timer clock applies power to the This circuit can be used with a timer clock to The mechanical drive is provided by a small 230-V (120-V) relay RE3, the voltage at the open and close curtains or (vertical) Vene- DC motor with a reduction gearbox and pul- junction of C1 and R1 goes high. IC1 (a 555) tian blinds. The curtain or blind is driven by ley (all from Conrad Electronics). then receives a trigger pulse on pin 2, which an electric motor with a reduction gearbox It was later modified to work automatically causes its output (pin 3) to go High and ener- fitted to the control mechanism of the cur- with a timer clock. The timer operates a small gise RE1, which in turn causes the motor to tain or blind. This circuit is ideal for giving 230-VAC (or 120-VAC) relay with a changeo- start running. When the magnet reaches reed your home an occupied appearance while ver contact. Thanks to the two timers, the switch S1 (‘Open’), the 555 is reset. If the reed you are away on holiday or for some other motor stops after a few seconds if one of the switch does not operate for some reason, reason. In the author’s house, this arrange- reed switches is missed due to a mechanical the relay is de-energised anyhow when the ment has provided several years of trouble- defect. monostable times out (time delay = 1.1 RC; free service on a number of windows fitted The circuit works as follows (see Figure 1). approximately 5 seconds). with Venetian blinds. In the quiescent state, relays RE1–RE3 are de- Close the blind: The original design was a simple relay circuit energised and the motor is stopped. The timer clock removes power from RE3, with pushbuttons for opening and closing Open the blind: which causes a trigger pulse to be applied to

7-8/2009 - elektor 75 the other 555 timer (IC2) via R5 and C4. Now +12V the motor starts running in the other direc- R1 R2 R3 R4 tion. The rest of the operation is the same as D1 1M described above for opening the blind. 10k 4k7 10k Diodes D2 and D5 prevent the outputs of the S1 555 ICs from being pulled negative when the 8 4 OPEN R relay is de-energised, which could otherwise 6 THR cause the timer ICs to malfunction. IC1 D2 7 3 DIS OUT C1 555 2 All components of the mechanical drive TR RE1 come from Conrad Electronics [2]: a motor 100n CV D3 OPEN 1 5 with a reduction gearbox (type RB32, order C2 C3 number 221936) and a pulley (V-belt pulley, 230V 4µ7 100n order number 238341) on the output shaft. RE3

An O-ring is fitted to the pulley to provide +12V sufficient friction with the drive chain of the R5 R6 R7 R8 Venetian blind. The magnet for actuating the D4 1M 10k 4k7 10k reed switches is a rod magnet with a hole in M1 the middle (order number 503659), and the CLOSED S2 M chain of the Venetian blind is fed through 8 4 CLOSED R 6 this hole. THR (090150-I) IC2 D5 7 3 DIS OUT Internet Links C4 555 2 [1] www.elektor.com/090150 TR RE2 [2] www1.conrad-uk.com 100n CV D6 1 5 C5 C6

4µ7 100n

090150 - 11

Stress-o-Meter

Markus Bindhammer (Germany)

The common meaning of the term ‘stress’ is distinctly different from what specialists understand by the term, and even they disa- gree with each other. The Wikipedia entry for this term [1] gives an impression of its com- plexity. Consequently, it’s a good question whether it is even possible to measure stress. However, it is certainly possible to measure how our bodies respond to stress. No matter whether something is especially pleasant or instead triggers anxiety or aggres- sion, if there is a strong stimulus, our bodies are prepared to act accordingly. Jumping for joy, fleeing, and attacking all cost a lot of energy. One the many consequences is thus DIY electronics. By contrast, the variation in ing). A bright red LED or even a white LED can an increase in the heart rate, which is prob- blood flow can easily be sensed using light be used in place of the IR LED. It’s even possi- ably the most easily measured response to transmission, since the absorption of the ble to use an LDR as the photosensor. Ready- stress. transmitted light depends on the blood flow. made clips are also available commercially as The resting heart rate of a healthy person is Ear lobes and fingertips are especially suita- medical accessories (expensive) or accesso- around 50 to 100 beats per minute (bpm). A ble for light transmission measurements. ries for ergometers and similar sports equip- person’s pulse can be measured either elec- The author converted an ordinary plas- ment (inexpensive). trically with an ECG instrument or by sensing tic clothespin into a finger or ear clip. To do With a 5-V supply, the current through the IR the periodic variation in blood flow through so, he first drilled a 5-mm hole in each arm LED is around 30 mA. The sensor signal (with the body tissue. The first method requires of the clip and then glued an IR LED (type its small voltage variations) passes through a electrical contact between electrodes and SFH487) in one hole and a phototransistor high-pass filter (C1/R3), which removes slow the skin, which is not especially advisable for (type SFH309FA) in the other hole (see draw- drift, to the non-inverting input of opamp

76 elektor - 7-8/2009 IC1a. The combination of C2 and R5 forms T1 a low-pass filter that decouples high-fre- SFH309FA quency noise. IC1a amplifies the signal in the passband, which is centred at 100 bpm, by a factor of 100. A similar combination of filter and amplifier is built around IC1b, in this case with a gain of 500. The LM348 dual opamp is especially suitable for this circuit because it D1 can handle small-signal inputs close to 0 V, SFH487 even when powered from a single-ended supply. The overall gain of the two stages can be adjusted with P1. The output of IC1b drives +5V T2 and T3 in parallel, so D2 blinks at the same R10 rate as the variation in blood flow through R1 R2 C2 C4 Ω Ω

the ear or finger between D1 and T1. 220 39k

120 100n 100n R5 R7 The ‘excess rate’, or stress, is indicated by D2 IC2, a conventional 555 timer IC. Transistor 1M 560k T3 shorts out capacitor C6 when D2 is on. IC1 = LM358N 2 6 T2 R9 This resets the internal flip-flop of the 555 1 7 C1 IC1.A C3 IC1.B 2k2 and causes pin 3 to go High, which in turn 3 5 BC547 causes D4 to light up. When D2 is off, C6 can 1µ 1µ charge via R12. If the charging interval is long T1 R3 R4 R6 R8 enough for the voltage on C6 to rise to two- D1 P1 1k 68k 68k thirds of the supply voltage, the output of 8k2 10k the 555 changes state, LED D4 goes dark, and SFH487 SFH309FA D3 flashes briefly. This means that the user’s pulse rate is low as long as D3 blinks peri- +5V odically. C6 and R12 are dimensioned such that D3 remains dark at heart rates above R13 R12 R11 Ω 2k2

100 bpm. 220 250k For safety reasons, an AC mains adaptor 8 4 D3 R should not be used as the power source. The 6 THR circuit works properly with a supply voltage C5 8 IC2 3 7 of 4.5 to 7 V, so a set of four alkaline, NiCd or IC1 OUT DIS NiMH cells forms a perfectly adequate power 100n 4 D4 NE555 2 T3 source. TR CV (080831-I) R14 1 5 C7 C6 Ω BC547 220 Internet Link 10n 2µ2 [1] http://en.wikipedia.org/wiki/Stress 080831 - 11

Powering a Second Hard Drive

Leo Szumylowycz (Germany) minal strip and the job’s done. It works ade- the pins as far out of the retaining mount as quately (for a while) but it doesn’t look partic- needed to solder onto the rear of these pins Just about every hands-on computer builder ularly attractive, reliable or professional. additional wires for the accessory device you knows the problem: you’ve acquired an extra wish to install. hard drive or cooling fan but there are no A more elegant solution would be to sol- spare cables or connectors to power these der the new power cable direct to the cor- We need two types of sleeves, 4 mm (0.16”) for additional components inside the computer responding connector of the existing device. the plugs and 6 mm (0.24”) for the sockets. case. In situations like this splitter cables, also Elegant, yes, but not particularly straightfor- First of all the contact on the cable is pressed called Y-cables, can be a blessing. But what if ward, since the power supply rails are seldom hard into the plastic retainer to ensure the you don’t have one of these to hand and the easy to get at, whilst the metal pins of indi- restraint spring grips cleanly and fully. local computer shop is closed? There’s only vidual power connectors are of course buried Next we attach wire sleeves to the pin that one thing for it — DIY! As tasks go, splicing inside their plastic shell. we are extracting and push it carefully and in an extra cable is not particularly difficult, as slowly into the plastic retainer as far as the long as you have sharp eyesight. All you need A little trick involving the sleeves that go on latch and end stop. Just before this point is is a second power cable and a choc block ter- the ends of wires will enable you to extract reached you will feel some resistance, with

7-8/2009 - elektor 77 a click sound heard after you have overcome one sleeve. For assured reliability, however, it is der wick). Finally we need to bend the con- the pressure. Exactly as this click is heard you recommended to use several sleeves. tact springs gently outwards and press each need to remove the wire in question, with its The free ends of the additional cable should pin back into its right position. You will find pin, from behind out of the plastic housing. be soldered (using great care and as little sol- the longer sizes of sleeve are easier to han- If this doesn’t work exactly as desired, it can der as possible, as shown in the photo) to cor- dle, also that the individual parts of the con- help to twist the sleeve around while you are responding pins close up against the exist- nectors move around more easily if you spray pulling. ing cable. Any unwanted solder blobs are them first with contact lubricant. Normally you can release about four pins using best removed with desoldering braid (sol- (090201-I)

Two-button Digital Lock

Francis Perrenoud (Thailand) D1 lights for 2 seconds and the relay is ener- microcontroller’s EEPROM memory before gised for 2 seconds. If the code is wrong, the programming it, so you can be sure that Now here’s a digital lock unlike any other, as red LED D2 lights for 2 seconds, and the relay the default code is 1234 and not some- it has only two buttons instead of the usual is not energised. thing unknown that was left behind in the numeric keypad. The way it works is as simple To change the code, fit a jumper to J1 and EEPROM. as its keypad. Button S1 is used to enter the enter the current code. When the green LED A little exercise for our readers: convert this digits of the secret code in a pulsed fashion D1 has flashed twice, enter the new 4-digit project into a single-button digital lock — for — i.e. the number of times you press the but- code. D1 will flash three times and you will example, by using a long press on S1 instead ton is determined by the digit to be entered. need to confirm the new code. If this con- of pressing S2 to detect the end of a digit. A dial telephone uses the same type of cod- firmation is correct, D1 will flash four times. (090127-I) ing (now maybe there’s an idea?). Press four If the red LED D2 flashes four times, some- Internet Link times for a 4, nine times for a 9, etc. Press- thing’s wrong and you’ll need to start all over [1] www.elektor.com/090127 ing button S2 indicates the end of a digit. again. To finish the operation, remove the For example, to enter the code 4105, press jumper and turn the power off and on again S1 four times, then press S2, then S1 once, S2 — the digital lock is now ready for use with Download once, then without pressing S1 at all, press S2 the new code. 090127-11: Source codes and Hex file, from www.ele- ktor.com/090127 again, then finally S1 five times and S2 once The software can be found on the webpage to finish. If the code is correct, the green LED for the project [1]. Don’t forget to erase the

R1

20 470R D1 5 PA0 4 19 PA1 IC1 PB7 1 18 PA2 PB6 D2 RE1 K2 ATTiny2313 17 6 7 8 K1 2 PB5 PD0 /V 16 +5V C1 C2 3 PB4 PD1 15 6 PB3 PD2 10u 100n 14 GND 7 DIL20 PB2 PD3 13 8 PB1 PD4 12 9 PB0 2 1 14 PD5 J1 11 S1 S2 PD6 READ DIL 5V/1A 10

090127 - 11

78 elektor - 7-8/2009 Characteristics • Two 500 W DC drive motors • Two 12 V lead-acid AGM batteries, 9 Ah ElektorWheelie • Two fourteen-inch wheels with pneumatic tyres Elektor’s DIY self-balancing vehicle • H-bridge PWM motor control up to 25 A • Automatic power off on dismount • Maximum speed approx. 11 mph (18 km/h) Order before 1 September 2009 • Range approximately 5 miles (8 km) Everyone agrees; the internal combus- and get £85 DISCOUNT! • Weight approximately 35 kg tion engine is coming to the end of (s 100 / US $150) The kit comprises two 500-watt DC drive its life cycle. However you don’t need motors, two 12-V lead-acid AGM batteries, to go to the expense of a Prius or Tesla to experience two 14-inch ABS wheels, casing, control lever the future of transportation devices. If you would prefer and assembled and tested control board with something more personal (and don’t mind turning sensor board fi tted on top. a few heads) why not build the astonishing ElektorWheelie? Art.# 090248-71 • £1380 • € 1599 • US $2275* First take two electric motors, two rechargeable batteries (reduced price till 1 September 2009: £1295 • € 1499 • US $2125)*

and two sensors, now add two micro- * Incl. VAT, excl. shipping costs. controllers and the ElektorWheelie is ready to transport you in style Elektor to your destination. Regus Brentford 1000 Great West Road Brentford TW8 9HH United Kingdom Actual product may Tel. +44 20 8261 4509 differ from illustration. Further information and ordering at www.elektor.com/wheelie

7-8/2009 - elektor 79

0907_elektor_adv_UK.indd 79 05-06-2009 13:27:50 Wireless Baby Monitor

Wolfgang Papke (Germany) Ton Giesberts (Elektor Labs)

Walkie-talkies (also known as handheld or PMR, Personal Mobile Radio) can be bought at low prices even from department stores, and they can be operated without a licence in many countries. Considering the low cost, such a set would be very suitable for use as a wireless baby monitor, with the addition of several external components. These are connected to the jack sockets for an external loudspeaker/microphone and an external PTT (Push-To-Talk) switch, which are often found on these devices.

The walkie-talkie with the extra electronics and microphone is placed in the baby’s room. When the PTT switch on the other walkie- talkie is actuated for about a second the ‘baby’ walkie-talkie produces a series of tones, which the external electronics can detect. This then activates its own PTT switch for about 5 sec- that can be obtained from Conrad Electron- When there is a call it charges up via R3 and onds, so it switches over to transmit. During ics (PMR Pocket Comm Active Pair, order the base-emitter junction of T1. If the walkie- this time the other device can hear what the number 930444). These walkie-talkies have talkie is called often there would be a dan- external microphone picks up. separate jack sockets for the LS/Mic and PTT ger that the output capacitor would remain Figure 1 shows the circuit that the author connections. charged and the DC offset of the audio sig- designed for this. It has been designed spe- When there is a call a series of tones is pro- nal would no longer be sufficient to turn on cifically for a Tevion 3000 PMR sold some time duced that is used to turn on T1 via R3. T1 T1. To prevent this, D1 is connected in reverse ago by Aldi. This type of PMR has a combined then activates the PTT function and the across the base-emitter junction of T1, pro- jack socket that includes all the required microphone amplifier is turned on. How- viding a discharge path for the output capaci- connections. ever, it’s not just the audio signal that is tor. To keep the circuit active for a minimum The voltage present on the PTT connector is used, but also the DC offset produced when amount of time the microphone voltage is used to generate the supply voltage for the the internal output stage is turned on. Both used to provide an extra base current. This is circuit via R3, D1 and C1/C2. When the loud- the internal as well as external loudspeaker done by charging C1 via R1. When the trans- speaker output presents a series of tones are driven via an output capacitor of 100 µF. mitter is turned off the microphone and R2/ (when the PTT switch on the other walkie- talkie is held down), it causes T1 to conduct. 1 This also turns on T2 and T3, so that the exter- nal microphone is connected to ground. The 2.5m*m resulting current that flows through the microphone should be sufficient to activate ext. R8 MIC1 the PTT circuit in the walkie-talkie, causing D1 R3 * * it to transmit. If the external microphone 4k7 1k 1N914 doesn’t draw sufficient current, a resistor R4 900 Ω C1 C2 C3 (R8) should be connected in parallel. Some 91k experimentation with the value of this resis- 10n 470µ 150µ tor may be required. If you want to make use of the internal microphone then R8 should be T2 replaced with a wire link. R5 When the walkie-talkie switches to trans- 43k R1 mit the built-in amplifier stops producing a 2N3906

signal and T1 turns off. However, since elec- 4k7 T1 T3 trolytic capacitor C3 has been charged up in R7 56k the mean time, transistors T2 and T3 will keep R2 R6 conducting for several seconds until C3 has 2N3904 2N3904 56k been almost discharged via R4. 82k In the Elektor labs a simpler version with the same functionality (Figure 2) has been 080701 - 11 designed for use with a cheaper PMR set

80 elektor - 7-8/2009 D1 provide a discharge path for the capaci- 2 tor. C2 ensures that the circuit won’t react to K1 spikes caused by interference. As can be seen K1' MIC/LSP C1 from the second circuit diagram, use is made 2.5mm of two connectors, a 2.5 mm jack plug for an MIC2 100µ 25V external headset and a 3.5 mm plug for the R1 PTT function. These connectors are particu- lar to the walkie-talkies we used here. With 100k other types of walkie-talkie you should first check the connection details of the connec- R3 tors before you connect the circuit up. 10k

K2 R4 When the circuit is used as a baby monitor 1k K2' PTT you should check that the microphone you’re 3.5mm using can pick up all the sounds. In our case the microphone didn’t appear to be very sen- T1 sitive. The microphone amplifier has proba- R2 D1 C2 bly been designed for a voice that is near the BC547B 1M PMR unit. When used as a baby monitor the 1n BAT85 microphone should therefore be positioned as close to the baby as possible. 080701 - 12 (080701-I)

Network RS232

Marcos Agra-Trillo (United Kingdom) start and stop bits with no flow +5V control. When idle, all the mod- With an ever increasing number ules are listening for commands of off the shelf electronic mod- from the master and have their ules and boards available at low C1 transmitters disabled. Each mod- prices, designers are inclined to 100n ule is configured with an identi- use these instead of making all 15 fier consisting of a number that VCC their electronics from scratch. 12 10 the master sends as a single line FORCEONINVALID In many cases this makes sense 2 (e.g. ‘2/n’ selects module 2). If a C2 C1+ as developing say, a PID motor 3 module receives an identifier that IC1 V+ 4 C4 controller or a GPS receiver from 100n C1- J1 matches its own, it is selected and 5 C3 C2+ 1 scratch requires considerable skill, ICL3221 7 100n can decode commands and drive V- 6 time and effort. A surprising num- 100n 6 its transmitter for the duration of C2- 2 SERIAL_TX 11 13 ber of modules still have an inter- T1IN T1OUT 7 the reply. Conversely, if the iden- SERIAL_RX 9 8 face based on RS232. No wonder, R1OUT R1IN 3 tifier does not match it must not 1 16 as RS232 is easy implemented on EN FORCEOFF 8 decode commands and ensure its a microcontroller with two I/O GND 4 transmitter remains disabled. 14 9 SERIAL_TX_ENABLE pins and a line driver such as the 5 R1 MAX232. In the case where the In addition to some firmware sup- master is a PC, the serial port is 22k SUB D9 port, the RS232 driver electronics relatively easy to access on both must be able to tri-state the trans- Windows and Linux. Usually mod- 090326 - 11 mitter while keeping the receiver ules implement a text terminal operational. Sadly, the classic interface that decodes single line MAX232 driver is unsuitable but commands with arguments and generate a ber of RS232 modules in a project, as each the ICL3321 and MAX242 are possible can- reply like this: requires a serial interface at the master. A didates for our purpose. These have low- hardware solution in the form of an RS232 power shutdown modes that power-down Tx: cmd arg0 arg1 ... argX/n multiplexer would be a solution but wouldn’t the charge pump and transmitters but keep Rx: cmd arg0 arg1 ... argX/n replyline0/n it be nice to get this functionality for free! the receivers enabled for monitoring RS232 replyline1/n By deviating from the original aim of RS232 as activity. … a point-to-point link, we can have an RS232 The number of modules in your RS232 net- replylineY/n network in which all the modules share both work is limited by the (nominal) 5 kΩ pull- transmit and receive lines to one master inter- down at the receiver input of the line driver A complication occurs when there are a num- face. All modules operate at the same speed, device. Multiple modules increase the loading

7-8/2009 - elektor 81 on this signal, reducing the maximum operat- O pins are scarce, by storing the configuration ules can be tweaked to support ‘network’ ing speed and cable length. Using the circuit in the user EEPROM/Flash provided by many RS232 unless the vendor has used a suitable shown here, running an application with five microcontrollers. If the latter is done, it is rea- RS232 line driver and is prepared to provide modules at 9,600 bps located within 1 meter sonable to assume the module will only be the firmware code. However, it is possible of each other did not present any problem. configured with normal RS232. Special con- to implement on DYI modules and perhaps figuration commands can then be provided module designers can take note and enhance Modules need a means of enabling the net- that are always decoded irrespective of the the functionality of their future designs. work mode and setting the unique identifier. identifier match. (090326-I) This can be done via switches, jumpers or, if I/ It is unlikely that commercially available mod-

Simple Wire Link Bender

Louter van der Kolk (The Netherlands)

When you want to mount components on a PCB or a piece of prototyping board, you not only want to do this quickly, but also tidily. ״The bending of really tidy wire links with the 0.1 ״correct pitch is often a tedious chore. The fol- 0.2 ״ lowing is a handy aid for doing this. 0.3 ״0.4 Using a small piece of 0.1 inch (2.54 mm) pro- totyping board, you can very easily make a handy bending jig for wire links. With a jig- saw, cut the piece of prototyping board into a staircase shape as shown in the drawing. 090369 - 11 You can make it as big as you need. Make sure that the horizontal cuts are slightly towards the outside with respect to the a piece of wire and fold it sharply around the much better and they are also mounted much holes, so that clear indentations remain in indentations corresponding to the selected more quickly. the horizontal sections. pitch. A neat wire link is the result, with Tof course he bender is also suitable for resis- exactly the right pitch and ready for solder- tors with leads. Bending a wire link is now very easy: choose ing tightly into the PCB or prototyping board. (090369-I) the desired pitch on the jig (dashed line), take With close-fitting wire links the board looks

Single-cell Power Supply Harald Broghammer (Germany) Characteristics and with the help of just five external capaci- Many modern electronic devices and micro- • Input voltage from 0.7 V to 5 V tors, one resistor, a diode and a coil, can gen- controller-based circuits need a 5 V or 3.3 V • Output voltage from 2.5 V to 5.5 V erate a fixed output voltage of 3.3 V or 5 V. power supply. It is important that these • Maximum output current 2 A With two extra resistors the output voltage voltages are constant and so a regulator of • Can run from a single cell can be set to any desired value between 2.5 V some kind is essential, including in battery- and 5.5 V. powered devices. The simplest approach is The technical details of this integrated cir- to select a (perhaps rechargeable) battery ing regulator, and if we use a regulator with cuit can be found on the manufacturer’s whose voltage is rather higher than that a step-up topology then we can simultane- website [1], and the full datasheet is avail- required by the circuit and use an ordinary ously reduce the number of cells needed to able for download. An important feature of linear voltage regulator. Unfortunately this power the circuit. Fortunately it is not too dif- the device is that it includes an internal refer- solution is rather wasteful of precious energy ficult to design a step-up converter suitable ence and integrated power switching MOS- and space: for a 5 V circuit at least six NiCd or for use in portable equipment as the semi- FET, capable of handling currents of up to 5 A. NiMH cells would be required. conductor manufacturers make a wide range It is, for example, possible to convert 2 V at of devices aimed at exactly this kind of appli- 5 A at the input to the circuit into 5 V at 2 A at Both these disadvantages can be tackled cation. The Maxim MAX1708 is one exam- the output, making it feasible to build a 5 V using a little modern electronics. A good way ple. It is capable of accepting an input volt- regulated supply powered from just two NiCd to minimise energy losses is to use a switch- age anywhere in the range from 0.7 V to 5 V, or NiMH cells. With a single cell the maximum

82 elektor - 7-8/2009 possible current at 5 V would is that the input voltage must be reduced to around 1 A. be lower than the output volt- VIN D1 VOUT The example circuit shown L1 age. For example, it is not pos- 2µH2 here is configured for an out- SS16 +5V sible to use a 3.7 V lithium- R2 put voltage of 5 V. The capaci- polymer cell (with a terminal Ω 2 tor connected to pin 7 of the IC 3 voltage of 4.1 V fully charged) LX CLK 16 enables the ‘soft start’ feature. 4 15 at the input and expect to be LX IC1 3.3/5 5 R2 provides current limiting LX able to generate a 3.3 V out- 7 10 at slightly more than 1 A. For SS/LIM OUT put, as diode D1 would be C1 11 C5 maximum output current R2 MAX1708 FB permanently conducting. On 8 12 150µ REF PGND 150µ can be dispensed with. Pins 1 1 13 the other hand, there is no 25V ONB PGND 25V and 2 are control inputs that 2 14 difficulty in generating a 5 V ONA PGND R1 allow the device to be shut C2 C3 GND GND C4 output from a lithium-poly- 6 9

down. To configure the device 60k mer cell. 100n 220n 100n for 3.3 V output, simply con- (090070-I) nect pin 15 to ground. 090070 - 11

The coil and diode need to be Internet Link [1] www.maxim-ic.com/quick_ selected carefully, and depend view2.cfm/qv_pk/3053 on the required current output. To minimise For L1 a fixed power inductor, for example losses D1 must be a Schottky type: for a 1 A from the Fastron PISR series, is needed. A fun- output current the SB140 is a suitable choice. damental limitation of the step-up converter

Economy Timer

Stefan Hoffmann (Germany) ingly) indicates that the timer is run- ning (pin 3 is logic High). The output

Windows should be opened only a R4 of the second 555 IC, which config- few minutes for ventilation, and due ured as a Schmitt trigger, also goes 33k to the risk of break-ins, you shouldn’t High when its trigger input is pulled leave windows open for hours on Schmitt-Trigger to ground. As a result, the DC buzzer end or when nobody is at home. 4 8 connected between the outputs of S1 R 6 the two 555 ICs is not energised THR This circuit detects when a window NS because both outputs are High. IC1 D1 7 3 is open (it can also be used with a DIS OUT If the window is closed within the door), indicates that the window 555 1N4148 time interval determined by the 2 is open by means of a red LED or TR R3/C2 network, the output of the CV a blinking LED, and emits a loud BT1 Schmitt trigger returns to the Low 5 1 acoustic signal from an intermittent BZ1 state. If the output of IC2 is still High, electronic buzzer to remind you to diode D1 prevents any current from R2 R3 close the window. 5V flowing through the DC buzzer. 4V5 Monoflop The active components consist of 1M After the monostable times out, the 100k 4 8 a pair of type 555 timer ICs. Switch R outputs of both 555 ICs are Low and 6 S1 is a reed switch that is attached THR the buzzer remains silent. IC2 to the window frame, and when 7 3 Things are different if the window DIS OUT the window is closed the switch is C1 555 R5 is still open when the monostable 2 closed by a magnet attached to the TR times out. The Schmitt trigger out-

10n CV 150R window casement. R1 put remains High, but the monos- 5 1 When the window is closed, the reed C2 D2 table output goes Low. As a result, switch connects resistor R1 to the 22k a positive voltage is applied to the 470u 16V 4.5-V supply voltage. If the window buzzer, and it generates an acoustic is opened, S1 opens as well and the 090109 - 11 signal until the window is closed. As voltage on R1 drops immediately to befits an intermittent buzzer, it gen- 0 V. As a result, the trigger input of erates an intermittent signal. IC2 is briefly pulled to ground via C1. The time-out interval of the monos- IC2 is wired as a monostable flip-flop, and it is prevents retriggering and allows the monos- table can be calculated reasonably accurately triggered by this pulse. After C1 charges, the table to time out normally. with the formula supply voltage is again present at the trigger The red LED or blinking LED (user option; input of the monostable flip-flop (via R2). This select the value of the series resistor accord- t = 1.1 × C2 × R3

7-8/2009 - elektor 83 With the indicated component values (1 MΩ with a trimpot and adjust it so that the mon- definitively answer the age-old question of and 470 µF), the alarm sounds after approx- ostable is triggered when the refrigerator whether that refrigerator lamp actually goes

imately nine minutes if the window is still lamp goes on (when the refrigerator door is off when the fridge door is closed ;-) . open. opened), after the monostable times out the (090109-I) Instead of the reed switch, you can use a light- buzzer will remind you to close the refrigera- dependent resistor (LDR) to detect the light tor door (which is often left open). A nice side from the refrigerator lamp. If you replace R1 effect here is that you can use this circuit to

Full-colour Night-flight Illumination

Steffen Schütte (Germany)

There are various types of night-time illumi- nation available for model aircraft. The cir- cuit described here is special in that it allows the colour of the RGB LED that is used to be controlled remotely. The circuit can be con- nected to a spare receiver output channel or in parallel with a channel already in use for other purposes. The colour of the RGB LED changes according to the servo position for the selected channel and according to the selected mode of operation. Mode 1 Mode 2 Mode 3

080060 - 11 Characteristics • Supply voltage: 4.8 V (4.5 V to 5.5 V) • Maximum current for each output: 150 mA

• Maximum current per LED module: 150 mA LED2 LED1

(50 mA per colour) K4 R11 K5 R8 A3 3x A2 A3 3x A2 • Operating modes: 3 82R 82R C3 C2 C3 C2 R10 R7 • Servo range: ±100 % C1 A1 C1 A1 180R 180R • Dimensions (prototype): RGB RGB 32 mm x 25 mm x 7 mm LED CON2 R9 LRTB G6TG LED CON1 R6 LRTB G6TG • Controller weight: 5 g 120R 120R • LED module weight: 0.7 g K1 RC CON

At the heart of the circuit is a PIC12F675 R5 microcontroller (IC1), which is connected to 1k one output channel of the radio receiver: K2 this allows it to measure the corresponding servo position. Depending on its operating D2 D1 mode, the microcontroller generates pulse- 1N4148 1N4148 width modulated waveforms on three out- R1 ISP 1 puts, which in turn drive the connected RGB

4k7 2 7 LED (or LEDs) via transistors T1 to T3 to pro- GP5/CLKIN GP0 IC1 duce a range of colours. The other main com- 3 6 T1 ponents are the mode button S1 and a four- GP4/CLKOUT GP1 R2 PIC12F675SN 10k 4 5 way connector (K2) used for in-system pro- GP3 GP2 K3 gramming (ISP) of the microcontroller. D1 and BC847C 8 D2 are required to prevent a connected radio T2 receiver from interfering with the program- R3 1k ming operation. BC847C LEDS

In contrast to the simplicity of the hardware, S1 T3 R4 the software running in the microcontrol- 1k ler is rather complex. Commented source code is available for free download from BC847C the project page at www.elektor.com. The 080060 - 12 most important parts of the program are the

84 elektor - 7-8/2009 initialisation code, the interrupt routine and operation modes (see also the accompany- The upper part of the circuit diagram shows the main loop. ing figure). In mode 1 the colour changes how the RGB LED can be connected to con- from blue (minimum servo position) to red nector K3. It is possible to connect multiple The interrupt routine is triggered by a level (maximum position). A press of S1 advances LED units in parallel. An extra pin on K3 is change on the input port pin connected to to mode 2, where the colour changes simi- taken to ground in order to allow perma- the radio receiver. It tests whether the edge larly from green to red. A further press enters nently-lit LEDs to be connected alongside is rising or falling: if rising, Timer1 is set to mode 3, where the colour changes continu- the RGB LEDs. It is of course necessary to zero to allow the time to the following falling ously, with the speed of the change depend- keep within the maximum permissible cur- edge to be measured. The pulse width corre- ing on the servo position. Finally, pressing rent draw from the receiver or battery elimi- sponds to the servo position and is output by the button once more returns to mode 1. nator circuit (BEC). the receiver every 20 ms. The 20 ms timebase The most recently used mode is stored in (080060-I) derived from the receiver signal is also used the microcontroller’s EEPROM while power to orchestrate the polling of the mode but- is not applied. ton. When the mode button is pressed (the When power is applied to the receiver the Download 080060-11: source code and hex files, from www.ele- input port pin going from High to Low) the channel that has been selected for use ktor.com/080060 device changes mode. must be set to its minimum position. This is If the device is not in continuously-changing because the circuit uses the initial value of mode the new colour for the RGB LED is cal- the pulse width to ‘learn’ the minimum posi- Product culated in the interrupt routine by calling the tion. If the channel is not set to its minimum 080060-41: ready-programmed PIC12F675 routine ‘calcResult’. If the device is in contin- position, the device will never fully reach the microcontroller uously-changing mode the relevant calcula- colour red (in modes 1 and 2) or the maxi- tions are performed in the main loop. mum possible colour-changing speed (in Pressing S1 cycles through the following mode 3).

Smoggy use your Walkman to connection of the amplifier circuitry. As detect electrosmog ANT***3ANT2 ANT1 we are dealing with a stereo amplifier, L3* we are listening into both channels and Tony Ruepp (Germany) thus both RF ranges at the same time.

Even if your good old (Sony) Walkman One channel of the amplifier can also be sees little use nowadays it would be a K1 used to demodulate low-frequency mag- shame to get rid of it altogether. The more netic alternating fields via a capacitor C5 so when just removing the tape head (C3) bypassing diode D1 and connect- C3 would allow the built-in audio amplifier 4n7 ing either a third coil (L3, for instance; to become an outstanding electrosmog 1µ a telephone recording adapter) as the detector for a variety of purposes. D1 R pickup device or else a long piece of wire for acquiring low frequency AC electri- AA112 R1 Looking at the schematic, readers with RF L1 C1 cal fields. Sources like this are discerni-

experience will have no difficulty in rec- 15k ble mainly by a distinct 50 Hz (or 60 Hz) ognising the diodes and coils of the two 250µH 1n humming in the earphones. detector-receivers, which serve to cap- ture and demodulate RF signals. With its D2 L Predicting what you may hear down to coil of four turns (L2) one receiver cov- the very last detail is difficult, since every AA112 ers the higher frequency range of the R2 locality has its own, individual interfer- L2 electromagnetic waves, whilst the sec- C4 C2 ence sources. Nevertheless, with practice * 15k ond detector takes care of the lower fre- 470p 1n users will succeed in identifying these quency range. For this reason a coil with a interference sources by their particular greater number of turns is required: L1 is audio characteristics. an RF choke of about 250 µH. The precise A value is not critical and it could equally be To sum up, four different ‘sensors’ can be 220 µH or 330 µH. 090151 - 11 connected to the inputs of this circuit: ANT1 (approx. 50 cm long whip antenna), The outputs of both detector-receivers ANT2 (3.5 cm short stub antenna), ANT3 are connected to the cables disconnected man’s audio amplifier. Please note here that (approx. 1 m long wire antenna for low fre- previously from the tape heads, feeding the the screening of the tape head cable does not quency electrical fields) and a coil for mag- right and left channel inputs to the Walk- have to be absolutely identical to the ground netic fields. Finally, two more tips:

7-8/2009 - elektor 85 1. Use only ‘good old’ germanium diodes for 2. Smoggy does not provide an absolute indi- detect electromagnetic signals and compare D1 and D2. Sensitivity will be much reduced if cation of field strength and even more so can- their relative magnitude. silicon diodes are used, as these have a higher not provide any guidance whether anything (090151-I) threshold voltage. it detects might be harmful. Its function is to

Solar-driven Moisture Detector Christian Tavernier (France)

When we think of solar cells or panels, what V+ springs to mind immediately is producing R3 power — only natural, given the primary 14 purposes of such devices; but we don’t nec- IC1 = 4093 IC1 47k essarily think of using them in applications 7 P1 S3 where the fact they don’t produce power R1 100k R2 1M in the absence of light may actually be use- BZ1 10k lin* ful. Yet this is just the case in the project dis- IC1.A * 1 IC1.B V+ > 3V cussed here. 3 5 IC1.C BT1 2 & 4 8 3V 6 & 10 S2 * 9 & The project, then, is BZ2 intended for detect- E1 C1 V+* < 3V ing moisture here on C2 IC1.D 12 S1 3V 100n * 11 Earth using solar 22µ 13 & power. It’s pri- 25V E2 marily aimed it at those of you who like to 081174 - 11 brighten up their house or f lat with pot plants, but are afraid of is remarkably simple, using just a single 4093 pass through IC1c, which can only happen if inadvertently let- CMOS logic chip, which contains four 2-input E1 and E2 are not connected, allowing the ting them die of Schmitt trigger NAND gates. corresponding input to be pulled up to logic thirst. The first gate, IC1a, is wired as a very low fre- High. You will have realised that E1 and E2 quency astable oscillator. When its output is are the electrodes stuck into the soil and so Using its two elec- at logic high, which occurs at regular inter- will not be connected if the latter is not suf- trodes, formed from two vals, it enables IC1b, which is also wired as an ficiently conductive, i.e. when it starts to dry stiff pieces of bare copper wire, it can be astable oscillator, but this time at an audible out. The threshold at which gate IC1c turns on stuck into the pot of any plant you want to frequency. The signal from IC1b then has to is obviously adjustable using P1. monitor. As long as the plant isn’t thirsty, i.e. the soil in the pot is moist enough, it will just sit there and do nothing at all. But when COMPONENT LIST the soil dries out below a certain threshold (which you can adjust to suit the soil used Resistors and the plant being monitored), it starts R1 = 100kΩ ‘squealing’ to tell you it is time to give the R2 = 10kΩ poor plant a drink. R3 = 47kΩ But so that your husband/wife/girlfriend/ P1 = 1MΩ linear potentiometer boyfriend (as applicable!) won’t throw your plant out of the window because the detec- Capacitors C1 = 22μF 25V tor has started squealing in the middle of the C2 = 100nF night, we obviously want it to work only dur- ing the day. This is where the solar cell comes Semiconductors in handy: on the one hand, it is used to power IC1 = 4093 the circuit, making it totally stand-alone; and on the other, the lack of power produced Miscellaneous when in darkness means the circuit is auto- Solar cell (see text) matically silenced at night. Piezo buzzer 2 copper wire electrodes PCB no. 081174-I Once we’ve adopted this principle, the circuit

86 elektor - 7-8/2009 Depending on whether or not the circuit is and WW the width, in mm. Equivalent cells directly onto the glass of the cell and so are supplied from a voltage greater or less than from other suppliers may work equally well pretty fragile. 3 V — which depends on the solar cell used, though. As soon as the cell is connected, if the two as we’ll be seeing in a moment — the piezo Although in theory standard CMOS logic ICs electrodes E1 and E2 are ‘in mid-air’, the cir- sounder can be connected either directly only work above 3 V, the majority of those cuit should start ‘squealing’, as long as it is between IC1c output and the positive sup- we tried in our circuit did actually work with getting enough light. You can then solder ply, or between the outputs of IC1c and IC1d, a lot less, which means that if you’re on a two stiff copper wires onto E1 and E2 (e.g. which is wired as a simple inverter and so tight budget (or have a lot of plants to moni- stripped offcuts of 1.5 mm² / AWG16 domes- enables you to double the output voltage. tor!), you can use the cheapest cells, part no. tic wiring cable) and spike the circuit into the 05/048/016. plant you want to monitor. Then all you have The circuit is very simple to build, and you to do is adjust P1 so that the circuit cries for can just as easily use the suggested board If your budget is a little higher, and you help when the soil has reached the level of design [1] or build it on a piece of prototyp- don’t want to bother selecting the 4093 dryness you have chosen. ing board. The sounder used must of course CMOS ICs, go for a 07/048/016, or better still If the frequency of the sound produced be one without built-in electronics, as here a 07/048/032, which will allow the circuit to doesn’t suit you, you can change it by it is just being used as a simple transducer. If work under excellent conditions as soon as increasing or reducing C2 and/or R2. Like- it’s a large-diameter flat type, you could, for the illumination reaches around 1,000 lux. wise, if you don’t like its repeat frequency, example, glue it onto the casing of IC1, while You can also cannibalize such cells from you can change that by adjusting C1 and/ if it’s a small-diameter type with rigid pins, it solar-powered garden lights, which can often or R1. can be soldered directly onto the end of the be found at giveaway prices in the big DIY (081174-I) PCB where its connection pads are located. stores. Internet Links As for the solar cell, for the prototype Solems [1] www.elektor.com/081174 devices were used, available for example Given the size of the suggested PCB, the [2] www.selectronic.fr from Selectronic France [2]; these are marked Solems cells can be soldered directly onto with a very simple 3-figure code in the form the copper side of it. But when connecting NN/LL/WW, where NN is the number of ele- the cell up, do take care to be very quick sol- Download 081174-1 PCB layout (.pdf), from [1] ments in the cell (each element producing dering the leads to the two silvered pads at around 0.5 V), LL is the length of the cell, each end of it. They are actually metallised

Advertisement

7-8/2009 - elektor 87 I2C Display

R. Pretzenbacher (Austria)

Pretty graphical simulators are all very well when developing circuits using microcontrol- lers, but sometimes there is no substitute for a proper display connected to real hardware. LCD panels based on the Hitachi HD44780 controller are popular as they are cheap and, at least in principle, easy to use. Unfortu- nately they require a large number of control signals, which in turn means bulky cables and losing the use of many of the microcontrol- ler’s I/O pins.

Here we present a solution to the problem in just three characters: I2C!

Characteristics • Universal LCD module for microcontrollers • Requires just two I/O port pins • Multiple displays on one I2C bus • Simple to use with AVR firmware

With the addition of just one extra chip to system: SCL and SDA. This makes the job of rather than using a microcontroller to drive bridge the gap between the I2C bus and the interfacing to a display much more straight- these seven lines we use a simple I2C bus port LCD panel’s parallel interface, we can make forward. The Hitachi controller can be oper- expander device offering eight I/O pins. This a universal display module on a simple com- ated in its ‘four-bit mode’, where only four even leaves us one spare output which we pact printed circuit board. Besides ground data lines are connected along with three can use to switch the LCD’s backlight (or any and +5 V power, the module needs just two control signals: ‘E’, ‘R/W’ and ‘RS’. And now other LED) on and off. control lines from the host microcontroller we come to the elegant part of this design: We selected the PCF8574, which is available in

LCD1

+5V A C D S D+ D- K3 W +5V VS VD VL RS R/ E D0 D1 D2 D3 D4 D5 D6 D7 LE LE 1 2 3 4 5 6 7 8 9

SCL 10 11 12 13 14 15 16 SDA P1 C2 C3

5k 100n 10u 16V +5V K2 +5V 1 +5V 2 SDA C1 SCL 3 R5 4 R2 R3 100n R

5 39 8 8 16 1k 6 1k

C T1

VC R4 J1 J2 1 4 A0 P0 1k8 +5V 2 5 A1 P1 3 IC1 6 BC807 K1 A2 P2 1 7 P3 2 SCL 14 9 SCL P4 +5V 3 SDA 15 10 SDA PCF8574 P5 4 11 P6 13 12 INT P7 D GN 8 080525 - 11

88 elektor - 7-8/2009 COMPONENT LIST Resistors Miscellaneous P1 = 5kΩ, SMD (Murata) LCD with HD44780 compatible controller R2,R3,R4 = 1kΩ8, SMD 0805 K1 = 4-way SIL pinheader, lead pitch 0.1” R5 = 39Ω, SMD 0805 (see text) (2.54mm) K2 = RJ11 socket, PCB mount Capacitors K3 = solder islands C1,C2 = 100nF, SMD 0805 J1,J2 = 2-way pinheader with jumper, 0.1” C3 = 10µF 16V, SMD (Vishay), diam. 4mm lead pitch 20-way pinheader, 0.1” pitch, for LCD connection Semiconductors PCB # 080525-1 IC1 = PCF8574 (PCF8574A) (see text) T1 = BC807, SMD SOT23

two variants. The variants differ in the regions • i2cCheck test whether a slave is responding 3) User-level display functions 2 of the I C address space to which they can • i2cSend send data over the I2C bus (for use in applications) be configured to respond: see [2]. As shown • i2cReceive read data over the I2C bus • Ddisp write character at current cursor the circuit is arranged so that the device position responds to he highest address in its range: • DClear clear display in the case of the PCF8574 this address is 0x4E 2) Low-level display functions • Dpos set cursor position and in the case of the PCF8574A the address (not normally used in applications) • Dinit initialise display is 0x7E. Using these two chips it is possible to • whNibb send data nibble to display: call twice to • DBcd2 output a two-digit BCD value make two display modules that can be con- send a byte • DHexByte output a byte in hexadecimal 2 nected to the same I C bus simultaneously • rdsyB read status byte from display (for • DWord output an unsigned 16-bit value without address conflict and without any example, to determine if the display is • DLong output an unsigned 31-bit value modifications to the circuit. If it is desired to busy) • DInt output a signed 16-bit value use one of the other seven possible device • cntrB send control byte to display (for example, addresses (for example if there is a conflict to shift the display left or right) The user-level functions can be changed as required with another I2C device on the same bus) the • dataB send data byte to display without needing to know the low-level details of how wiring of the address bits (pins 1 to 3) needs • wBusy test whether display is busy the display is driven. to be changed appropriately. (080525-I) The circuit itself is straightforward. The Internet Links signals from the port expander are taken Control byte constants [1 www.elektor.com/080525 directly to the pins of the LCD panel, with (for use with ‘cntrB’) [2] www.nxp. the exception of output P0 which controls • dshr 0b00011100 // shift display one position com/acrobat_download/datasheets/PCF8574_4.pdf the backlight via PNP driver transistor T1. The to the right value of R5 must be chosen according to the • dshl 0b00011000 // shift display one position current rating of the backlight, which can be to the left Downloads 080525-1: PCB layout (.pdf), from [1] determined from the LCD panel’s datasheet. • curon 0b00001110 // cursor on 080525-11: source code files, from [1] The value of 39 Ω shown is suitable for a typ- • curoff 0b00001100 // cursor off ical one-line panel with a rated LED current • curblk 0b00001111 // cursor blinks of 30 mA. Preset P1 is used to adjust the dis- play contrast: frequently the display is only visible over a narrow range of contrast set- tings. Jumpers J1 and J2 enable the standard pull-up resistors on the SCL and SDA lines: there should only be one pair of such pull- up resistors over the whole bus. The printed circuit board offers a range of possibilities for connection to the bus: header K1, RJ11 socket K2 and solder pads K3. To simplify using the display the author has written driver software in C, suitable for use with AVR microcontrollers. As usual this is available from the Elektor web page for this article [1] and can of course be modified to suit your own requirements. The software is divided into three parts as follows.

1) I2C functions (may be modified to suit particular AVR microcontrollers) • i2cInit initialise I2C master

7-8/2009 - elektor 89 FM Audio Transmitter

Design: Mathieu Coustans (France)

When the author started thinking about this project he had a simple VHF FM transmit- ter in mind that could be used to play audio files from an MP3 player or computer on a standard VHF FM radio. The circuit shouldn’t use any coils that would have to be wound at home, as is often the case with other FM transmitter designs, because it would add an unwanted level of complexity to the project. Such an FM transmitter can be used to listen to your own music throughout your home. There is also an advantage when you use this connected in series with the USB connections has been placed at the edge of the board. transmitter in the car, as there is no need for a in order to avoid interference between the In practice we achieved a range of about separate input to the car stereo to play back circuit and the PC supply. There is not much 6 metres (18 feet) with this. There is also the music files from your MP3 player. else to the circuit. The stereo signal con- room for a 5-way SIL header on the board. nected to K1 is combined via R1 and R2 and Here we find the inputs to the 3.5 mm jack To keep the circuit simple as well as compact, is then passed via volume control P1 to the plug, the input to P1 and the supply voltage. it was decided to use a chip made by Maxim Tune input of IC1, where it causes the carrier The latter permits the circuit to be powered Integrated Products, the MAX2606 [1]. This wave to be frequency modulated. Filter R6/C7 independently from the mains supply, via for IC from the MAX2605-MAX2609 series has is used to restrict the bandwidth of the audio example three AA batteries or a Lithium but- been specifically designed for low-noise RF signal. The setting of the frequency (across ton cell. Inductor L1 in the prototype is a type applications with a fixed frequency. The VCO the whole VHF FM broadcast band) is done made by Murata that has a fairly high Q fac- (Voltage Controlled Oscillator) in this IC uses a with P2, which is connected to the 5 V sup- tor: minimum 60 at 100 MHz. Colpitts oscillator circuit. The variable-capac- ply voltage. Take care when you solder filter choke L2, itance (varicap) diode and feedback capaci- since the connections on both sides are very tors for the tuning have also been integrated close together. The supply voltage is con- on this chip, so that you only need an exter- Specifications nected to this, so make sure that you don’t nal inductor to fix the central oscillator fre- • Easy to build thanks to the use of a MAX2606 short out the USB supply! Use a resistance quency. It is possible to fine-tune the fre- • Can be powered from a USB port on a computer meter to check that there is no short between quency by varying the voltage to the vari- • Current consumption of just 2 to 4 mA, supply the two supply connectors before connect- cap. Not much is demanded of the inductor, voltage of 2.7 to 5.5 V ing the circuit to a USB port on a computer a type with a relatively low Q factor (35 to 40) • Can be expanded with a pre-emphasis circuit or to the batteries. is sufficient according to Maxim. The supply P1 has the opposite effect to what you voltage to the IC should be between 2.7 and The PCB designed in the Elektor Labs uses would expect (clockwise reduces the vol- 5.5 V, the current consumption is between 2 resistors and capacitors with 0805 SMD ume), because this made the board layout and 4 mA. With values like these it seemed a packaging. The size of the board is only 41.2 much easier. The deviation and audio band- good idea to supply the circuit with power x 17.9 mm, which is practically dongle-sized. width varies with the setting of P1. The max- from a USB port. A common-mode choke is For the aerial an almost straight copper track imum sensitivity of the audio input is fairly

K2 C5 +5V 4u7 10V C4 +5V K3 P2 R3 2n2 1 K1 4k7 L2 R4 R5 1 2 C8 2 100k C3 C2 C1 R1 4 3 3 22k 1k 1k 100n 4 100n 4u7 10V 4u7 10V R2 6 5 22k 5 VCC C6 R6 P1 3 IC1 6 270R TUNE OUT+ 470n 1 MAX2606 4 IND OUT- 10k L1 C7 GND 2 2n2 390n 080727 - 11

90 elektor - 7-8/2009 1206 type(DLW31SN222SQ2L Murata, Farnell # COMPONENT LIST 1515599)

Resistors (all SMD 0805) Semiconductors R1,R2 = 22kΩ IC1 = MAX2606EUT+, SMD SOT23-6 (Maxim R3 = 4kΩ7 Integrated Products) R4,R5 = 1kΩ R6 = 270Ω P1 = 10kΩ preset, SMD (TS53YJ103MR10 Vishay Miscellaneous K1 = 3.5mm stereo audio jack SMD (SJ1-3513-SMT Sfernice, Farnell # 1557933) C4,C7 = 2nF2 CUI Inc, DIGI-Key # CP1-3513SJCT-ND) P2 = 100kΩ preset, SMD(TS53YJ104MR10 Vishay C6 = 470nF K2 = 5-pin header (only required in combination Sfernice, Farnell # 1557934) wsith 090305-I pre-emphasis circuit) Inductors K3 = USB connector type A, SMD (2410 07 Lumberg, Capacitors (all SMD 0805) L1 = 390nF, SMD 1206 (LQH31HNR39K03L Murata, Farnell # 1308875) C1,C2,C5 = 4µF7 10V Farnell # 1515418) C3,C8 = 100nF L2 = 2200Ω @ 100MHz, SMD, common-mode choke, large. With P1 set to its maximum level, a This should really have been much lower. stereo input of 10 mVrms is sufficient for the With a low-impedance source connected Notice. The use of a VHF FM transmit- sound on the radio to remain clear. This also to both inputs the bandwidth varies from ter, even a low power device like the one depends on the setting of the VCO. With a 13.1 kHz (P1 at maximum) to 57 kHz (with the described here, is subject to radio regula- higher tuning voltage the input signal may wiper of P1 set to 1/10). tions and may not be legal in all countries. be almost twice as large (see VCO tuning In this circuit the pre-emphasis of the input (080727) curve in the data sheet). Above that level is missing. Radios in Europe have a built-in Internet Links some audible distortion becomes appar- de-emphasis network of 50 µs (75 µs in the [1] http://datasheets.maxim-ic.com/en/ds/MAX2605- ent. If the attenuation can’t be easily set by US). The sound from the radio will therefore MAX2609.pdf P1, you can increase the values of R1 and R2 sound noticeably muffled. To correct this, and [2] www.elektor.com/080727 without any problems. also to stop a stereo receiver from mistakenly Measurements with an RF analyzer showed reacting to a 19 kHz component in the audio Download that the third harmonic had a strong pres- signal, an enhancement circuit Is published 080727-1 PCB layout (.pdf), from ence in the transmitted spectrum (about elsewhere in this issue (Pre-emphasis for FM www.elektor.com/080727 10 dB below the fundamental frequency). Transmitter, also with a PCB).

Servo Driver

Gert Baars (The Netherlands) +9V ... +20V IC2 IC3 When it comes to driving a servo you typi- 78L06 7806 cally have to send a PWM signal to the servo input. The frequency of this signal is about 4 C5 C6 C7 C8 50 Hz and the duty cycle is variable. The duty IC1 Servo cycle is usually between about 5 and 10%, 11 100n 100n 220µ 100n R1 10V corresponding with a pulse width of about 1

to 2 ms. The conversion of a resistance value 220k IC1 = LM324N into a PWM signal is fairly straightforward when a variable RC time constant circuit is R4 used. Converting a voltage into a PWM signal 220k is a bit more difficult, but it does offer some 9 3 R3 8 12 1 6 useful advantages. IC1.C 47k R7 IC1.A K1 10 14 2 7 1 IC1.D 47k IC1.B 13 5 2 When the position of a servo can be control- C3 3 led via a voltage, it can be implemented via R5 470k 10n a potentiometer acting as a voltage divider. D1 However, you could also use the output of R6 1N4148 a sensor such as a Hall sensor, an LDR or an 39k R2 Uin NTC. That way you could easily create a feed- C1 C2 C4

back loop that takes account of the position, 220k 100n 100n 220µ light intensity or the temperature, and use 10V this to control the servo. This can in turn be 090046 - 11 used to open or close a gas or water valve, for example. The circuit can therefore be said to

7-8/2009 - elektor 91 be reasonably versatile. is fixed and set to a value slightly higher than 50 Hz and the duty cycle can be varied from

the maximum 10%. just under 5% to a good 10% when Uin var- There are special purpose PWM modula- ies from 0.5 to 4 V. The servo, an RS-2 in our tor ICs available, but it’s just as easy to use This is followed by an integrator that changes prototype, reacts to this with an angular rota- a quad op amp such as an LM324. In the cir- the waveform of the pulse into a triangular tion of about 200 degrees. The transfer func- cuit op amp C is configured to output a bias form. Op amp B is configured as a compara- tion in this case is therefore 200 / (4–0.5) = 57 signal of half the supply voltage. Op amp D tor that compares this triangular wave with degrees per volt.

is set up as a square-wave oscillator, with its the DC voltage Uin. The output of the compa- (090046) frequency set to about 50 Hz, which is the fre- rator is a PWM signal that is suitable to drive quency required by the servo. The duty cycle the servo directly. The frequency is about

Chill Out Loud

Andrew Denham (United Kingdom) an ability to deliver power at low temperatures. Everyone knows that when the An obvious choice to make refrigerator door is casually closed a squawk is a piezo sounder, it sometimes bounces open again again cheap and easily obtained. just a little. Enough to put the This can be driven from the PIC fridge light on, but that’s often directly across two ports and will un-noticeable even at night unless withstand 3 Vp-p drive easily. After one looks closely. After a day out, some testing, a Kingstate KPEG827 you may come home to sour milk [3] proved a worthy candidate. and dodgy chicken. After several It makes sufficient racket at 3 V mornings with debatable milk, drive from about 2.0 kHz to about the author decided that some- 4.5 kHz. thing would have to be done, and The PIC program was developed came up with this little gizmo. The using MikroElektronika products light in his fridge always comes only: a fully paid up MikroBasic on even with a 2 mm door open- +3V compiler and the BigPIC 4 board. ing, so that’s a promising place to However the final program is start. so small that it can be compiled C1 C2 The TEMT6000 phototransistor using the free version of MikroBa- device from Vishay will ‘see’ vis- 10µ 100n sic (free up to 2 K of code, down- ible light, and is both cheap and load at [4]). readily available. It has negligible For the simple reason of ease, the dark current and can sink a few R1 R2 R3 PIC used is the 8-pin DIL version. * 1

µA happily. Since a battery pow- 100k 100k 100k This can be re-programmed easily 2 5 ered device is required, the cur- GP5 GP2 using a simple DIL socket adapter. IC1 BT1 BZ1 rent for the entire circuit has to 3 6 ICP is OK if you have to use SMD GP4 GP1 be as low as possible. A PIC with PIC12F629 but the socket takes up a lot of 4 7 ‘sleep’ mode is a good choice, GP3 GP0 room and negates the purpose and the 12F629 fits the bill nicely: T1 CR2032 of SMD in the first place on a very C3 KPEG827 small, cheap, easily obtained, with 8 Lithium small PCB. I used the PicFlash2 an internal RC oscillator on board, 100n programmer again from MikroE, and up to five I/O pins as well. but could have used the on-board According to the PIC12F629 data- TEMT6000 080700 - 11 EasyPIC4 programmer. The source sheet [1] all pins have to be set as code used is available free from inputs and pulled high for best the Elektor website [5]. low power operation, and every The type CR2032/1HF Lithium cell has a rated The timer will work with anything peripheral in use will add some drain. Since capacity of 230 mAh and a nominal voltage that can pull the GPIO.3 input Low and hold the unit is permanently powered from a bat- of 3 V [2]. On this basis with the typical cur- it Low, so could be used with bi-metallic tem- tery, there is no need for brown-out protec- rent in sleep mode the battery would last peratures sensor, or the software adapted to tion. No A/D or comparators are required, over 250 years, or effectively for its shelf life, read a One-Wire temperature sensor. It could and no watchdog timer either, allowing the so a CR2032 with tags is worth soldering in also be used to sense over- or under-voltage lowest power settings in Sleep mode to be to a PCB. Even at the maximum Sleep cur- etc. with some adaptation. The delay before exploited. Typical current here is shown as rent, it would last for over 30 years — cer- the alarm sounds is adjustable from about 1 1.2 nA with a guaranteed maximum of 770 nA tainly longer than the fridge! One advantage to 255 seconds in software. at a 3 V supply, reducing to 700 nA at 2 V. of a Lithium battery is its long shelf life, and One word of warning: there are many PIC pro-

92 elektor - 7-8/2009 grammers out there. If you use other than the the ambient light sensor is a type TEPT5600 Once the sensor detects light, it takes 60 sec- MikroE programmer with the code from the (which looks like a UV LED). As opposed to onds before the alarm sounds. When in the Elektor website, make certain that the PIC TEMT6000, the TEPT5600 has to be pointed fridge with the door closed (or the sen- oscillator configuration is correct. Not all directly to the light source due to its narrower sor covered) the unit goes back to sleep… software reads the Configuration correctly; ‘viewing angle’. It also requires the value of peace! it needs to be set for INT RC OSC, with GPIO.4 R1 to be doubled (approximately). Of course the fridge does have to have a and GPIO.5 as I/O. Anything else will stop the Even on perfboard the circuit is compact light that works or the unit will think it is in oscillator and may damage the PIC! Some enough to be fitted in a small ABS case, pref- the dark all the time. programmers need these parameters to be erably one with a battery compartment (080700-I) set manually before blowing the chip. In case because that’s the ideal place for the sounder. Internet Links of doubt, consult the source code listing. A small hole in the end should allow the sen- [1] http://ww1.microchip.com/downloads/en/ After some tweaking with the port settings, sor to ‘see’ the light. This hole was filled with devicedoc/41190c.pdf the sample chip consumed an estimated clear epoxy resin to act as a window with- [2] www.panasonic.com/industrial/battery/oem/ 0.02 µA in Sleep mode. Once triggered the out allowing too much moisture into the images/pdf/Panasonic_Lithium_CR2032_CR2330.pdf unit consumes about 500 µA for the timer case. The latter was achieved by fixing tape [3] www.farnell.com/datasheets/16396.pdf period of 1 minute, then about double that over the inside then filling the hole flush. It [4] www.mikroe.com once the sounder is operating. This is well was then allowed to set whilst the box was [5] www.elektor.com/080700 under the maximum current for the cell fixed upright. The circuit board may be fixed used (10 mA max. pulsed) and would bleat in place with a little hot melt glue. The unit Downloads & Products for about 10 days with a fresh battery, which could be mounted to the fridge wall using hopefully will never happen. With a fridge double-sided adhesive foam strip or Velcro, Programmed Controller 080700-41: programmed PIC12F629 opened say 20 times a day for less than a min- but space allowing it may equally sit on the ute, the battery life expectancy reduces to shelf. Software about 9 years, still a reasonable longevity. To start the microcontroller for the first time, 080700-11.zip: MikroBasic source code and hex files. The photograph shows a prototype built on a or when the battery is replaced, the fridge Location: www.elektor.com/080700 small piece of perfboard by Elektor Labs. Here door should be closed or the sensor covered.

Dimmable Aquarium Light with Simulated Sunrise and Sunset

Jürgen Ollig (Germany) the interface has several features that will be of particular interest to Electronic ballasts (EBs) for flu- aquarium owners. RE1 orescent lamps, also known as The circuit is connected across the S1 electronic control gear (ECG), have P1 control input of the EB and there- advantages over their conven- Electronic* fore the control voltage appears tional cousins: higher efficiency, Ballast across it. The brightness of the (EB) 100k flicker-free start-up, no 50 Hz log R1 tube can be adjusted using P1. S1 C1

(60 Hz) flicker and longer tube life. 2k allows electrolytic capacitor C1 to 10 000u Moreover, they allow the light to 16V be connected across P1: the charge be dimmed. Suitable EBs with a 1– current (0.6 mA) is very small and 10 V analogue control interface are 090025 - 11 the capacitor very large (10000 µF) available from all the usual man- and so it charges very slowly. This ufacturers, including Osram and means that the voltage across it, Philips. An internet search for ‘dimmable EB’ is a constant current source with an open-cir- and hence the brightness of the fluorescent will turn up a large number of on-line sales cuit voltage of 10 V. If a resistor is connected tube, will increase only slowly. The larger the outlets for the devices. For the purposes of across the interface then the lower its value, value of C1, the slower the rate of brightness this circuit EBs with a digital interface (known the lower will be the voltage across it, and increase; with the suggested value the sim- as DALI, for Digital Addressable Lighting Inter- this controls the dimming of the connected ulated sunrise takes around 12 minutes to face) are not suitable. lamp. When the control input is open circuit complete. As can be seen, the circuit does and the voltage across it is 10 V, the lamp is not need its own power supply. When the EB Osram provides an excellent technical driven at full brightness (100 % of nominal is switched off C1 discharges into P1 (assum- description of the 1–10 V interface on their power). If the control input is shorted the ing S1 is closed); when it is next switched on website at [1]. The interface provides an control gear dims the lamp to 3 % of nominal the brightness of the tube will rise slowly as interference-proof DC voltage of up to 10 V, power. Between 3 % and 100 % the behav- before. which, when loaded, delivers an essentially iour of the controller is logarithmic. An optional extra is the circuit consisting of constant current of 0.6 mA: in other words, it The very simple circuit described here to drive relay RE1 and resistor R1. If the contacts of

7-8/2009 - elektor 93 RE1 close C1 will be slowly discharged into One possible arrangement is to plug the R1. The control voltage will fall gradually aquarium light into one timeswitch and drive Internet Link and the tube will slowly dim. The larger the RE1 from a mains adaptor plugged into a sec- [1] http://www.osram.co.uk/_global/pdf/Professional/ value of R1, the slower the simulated sunset ond timeswitch. The relay contact is made to ECG_%26_LMS/ECG_for_FL_and_CFL/QUICKTRONIC_ will be. When the contacts of RE1 are closed close say 30 minutes before the first times- DIM_Technical_Guide130T003GB.pdf the value of R1 will also affect the maximum witch turns the aquarium light off. When the brightness that can be achieved by adjusting simulated sunset is complete the relay con- P1: the greater the value of R1, the higher the tact can be allowed to open again. maximum brightness. (090025-I)

Audio Source Enhancer

Thorsten Steurich (Germany)

Vinyl or CD: which has the better sound? It’s C2 R3 a question still hotly debated among audi- 10n C3 R1 100R 22p ophiles everywhere. We will try to shed a lit- 100k C8 R4 tle light on what lies behind the question and 10k 2 C7 P1 look at a simple circuit that can significantly 1 * 6 R K1 C1 IC1A C4 R5 K2 R enhance the sound from a CD player. 3 7 10u 10k IC1B 100R 5 1u 63V 10u 63V R6 Sometimes, on first hearing a new low- to R2 100k mid-range CD player, the sound is not alto- 100k gether convincing when compared to a record player. It is worth looking at the recording and replay processes as a whole C10 R11 10n C11 for both CDs and records to see why this R9 100R 22p might be. Assuming that we start from the 100k C14 R12 10k same source, or master recording, of a given 9 C13 * P2 piece of music, the differences are broadly as 8 13 L K3 C9 IC1C C12 R13 K4 L 10 14 follows. 10u 10k IC1D 100R 63V 12 1u 10u 63V R14 Records and CDs use very different record- R10 ing technologies. For records the signal 100k 100k first undergoes pre-emphasis similar to that used in FM radio, where the higher +10V...+30 V frequency components of the signal are R7 amplified. The resulting signal is cut into k the lacquer master disc that will be used 10 4 C5 for pressing. Unlike CD manufacture, this is IC1 IC1=TL084 R8 an entirely analogue process, and it intro- C6 11 10u

k 63V duces a phase shift into the signal. To com- 10 10u pensate for the pre-emphasis the preampli- 63V 0 fier in a record player includes a de-empha- 081083 - 11 sis (or ‘RIAA’) filter which attenuates the higher frequency components. The pur- pose of pre-emphasis is to improve the overall signal-to-noise ratio of the signal as greatly attenuated output at higher frequen- output impedance of 1 kΩ or more the differ- played back, reducing hiss and crackle. De- cies, and the circuit therefore also offers the ence between cheap cables and more expen- emphasis introduces further phase shifts, facility to boost these components to taste. sive low-capacitance cables can be noticea- and as a result the final signal is rather dif- The value of capacitors C8 and C14 may be ble. This circuit has an output impedance of ferent from that produced by a CD player. anywhere between 100 pF and 10 nF accord- just 100 Ω and so cheaper cables should nor- The processing involved in CD manufacture ing to the frequency response desired. mally be more than adequate. and playback can be entirely digital (in the case of ‘DDD’ recordings) and phase errors At the low-frequency end the response is The circuit can of course also be used with are reduced practically to zero. more than adequate, thanks to the large cou- other digital audio sources such as minidisc The circuit shown here uses a quad opamp pling capacitors used. The circuit also func- players, hard disk recorders, DAB tuners, dig- (two opamps per channel) to produce ‘record- tions as a buffer or impedance converter, ital terrestrial and satellite television receiv- like’ phase shifts. In the author’s experience which can help to reduce the effect of cable ers and so on. The supply voltage can be any- low- and mid-range CD players tend to have capacitances. With CD players that have an where from 10 V to 30 V. It will often be possi-

94 elektor - 7-8/2009 ble to take power from the CD player’s own supply; if not, a separate

AC power adaptor can be used. Advertisement Driving your loudspeakers The output signal for each channel is inverted (i.e., is subjected to a 180 degree phase shift) by the second opamp (IC1.B and IC1.D). This to a higher end does not affect the operation of the circuit. By changing the value of feedback resistors R4 (for IC1.B) and R12 (for IC1.D) the overall gain of the circuit can be adjusted so that the output level matches that of other components in the audio system. (081083-I)

Doubling Up with the PR4401/02 Leo Szumylowycz (Germany)

Among the many interesting applications for the PR4401/02 devices from Prema, some have already appeared in the 2008 edition of Ele- Visit our website ktor Summer Circuits. Over and above their unbeatable performance, dependable operating range from 0.8 V upwards and minimal reliance for more details on on peripheral components all we might ask for might be greater out- our new program put current, in order to be able to fully exploit a 4-chip LED with 80 mA. It would be handy too if one could replace the 9 V ‘block’ batteries used in the more sophisticated LCD multimeters. With the fully tested circuit tel. +31 (0)595 49 17 48 presented here both problems can now be eliminated. EUROPEAN DISTRIBUTOR fax +31 (0)595 49 19 46 In the schematic shown two of these ICs are connected in parallel via [email protected] www.eltim.eu diodes to a single charge capacitor. If the need arises you can connect even more of these ICs in parallel in the same way. The value of inductance required is calculated in the same way as for standard applications of the IC; 10 µH for the PR4401 with a current advertentie En.indd 1 28-05-09 16:18 of 20 mA and 4.7 µH for the PR4402 with a current of 40 mA. SMD inductors such as Murata LQH3C-4.7µH for L1 and L2 (available To power an 80 mA LED with a single 1.5 V battery the circuit shown from RS Components, Farnell and Anglia Components). needs to be equipped with PR4402s and 4.7 µH inductors. If you feel (090129-I) like constructing the entire project with SMDs, you will need SMD Internet Link tantalum electrolytics (4.7 µF, 35 V) of style ‘A’ for C1 and C2 plus www.prema.com/pdf/

+0V8...+1V8

D1

1N4148 D2

1N4148 L1 * L2 * IC1 * IC2 * PR4401/02 PR4401/02

1 2 1 2 80mA

FF FF C2 C1 D3

4u7 4u7 16V 16V

3 3

PR4401/02 090129 - 11

1 3 GND

2

7-8/2009 - elektor 95 Pre-emphasis for FM Transmitter

Ton Giesberts (Elektor Labs)

Specifications • Correction network for FM Transmitter 080727 • Also includes a 19-kHz filter • Current consumption of 3 mA

This circuit was specially designed to be used with the FM Audio Transmitter found else- where in this issue, but it can also be useful as an addition to other transmitters. The circuit uses a dual opamp. The first opamp (IC1A) functions as a mixer and a buffer for the following correction net- work. The input sensitivity can be adjusted with the help of R3 (a lower value reduces of the FM transmitter board also played a part as aerial and connected to the transmitter the sensitivity). The 50 µs correction for the here. To make it easier to connect this circuit board (it just so happens there is a via next pre-emphasis is carried out by C5 and R6. to the transmitter board, a connector was to C4). IC1B buffers the signal before it is fed to the included on this board. The supply voltage To measure the effect of the pre-empha- transmitter via K1. and audio signals are carried via this connec- sis circuit we first measured the frequency tor. The board has been designed in such a response of the output of a small radio. The Since the FM transmitter is a mono version, a 19 kHz filter has been included to prevent a stereo FM receiver from mistakenly switching C3 C6 to stereo mode due to the presence of 19 kHz +5V 47p 47p components in the received signal. Any sig- R3 L1 R4 R5 R7 10k 100R 15k 15k nals around 19 kHz are blocked with the help 33mH R8 of a simple tuned circuit (L1/C4). R4 ensures K1 R1 C1 2 22k C4 R6 C5 that the Q isn’t too large. Due to tolerances 100k 1 6 8 C8 R2 4u7 IC1A 3k3 10V 3 7 you may find that the frequency can deviate IC1 22k 2n2 2n7 IC1B R9 5 from 19 kHz (in our prototype the resonance 4 100n C2 C7 frequency was closer to 20 kHz). In view of the 100k IC1=TLC082CD value of the inductor, a through-hole version 100n 4u7 has been used for this (see component list). 10V Without the parallel circuit the crossover 090305 - 11 point of the correction network is about 16.7 kHz. This is more than enough for audio via VHF FM. The addition of the parallel cir- way that it can either be mounted behind the result of this can be seen in the graph (1 = cuit causes the amplitude around 10 kHz to FM transmitter or alongside it. without pre-emphasis, 2 = with pre-empha- increase a little, and the –3 dB point is then sis). It can be clearly seen that the higher fre- reached at 13.5 kHz. In the prototype this cut- When the pre-emphasis board is used R1 and quency components are attenuated by the off point was about 1 kHz higher due to com- R2 should be removed from the transmitter de-emphasis filter in the radio. When the pre- ponent tolerances. board. When the circuit is mounted behind emphasis circuit is connected to the transmit- The board designed for this circuit has been the transmitter board it was found that the ter the result is an almost flat response above kept as small as possible through the use of FM signal strength was clearly reduced, so it 1 kHz. The ‘bump’ around 100 Hz is caused by SMDs for most components. The dimensions would be better if a length of wire was used a type of bass-boost in the radio to improve

C2,C8 = 100nF COMPONENT LIST C3,C6 = 47pF C4 = 2nF2 Resistors (all SMD 0805) C5 = 2nF7 R1,R2 = 22kΩ R3 = 10kΩ Inductors R4 = 100Ω L1 = 33mH, e.g. 22R336C Murata Power Solutions R5,R7 = 15kΩ (24kΩ for 75 µs) (Farnell # 1077046) R6 = 3kΩ3 (3kΩ6 for 75 µs) R8, R9 = 100kΩ Semiconductors IC1 = TLC082CD SO8 (Farnell # 8453713) Capacitors C1,C7 = 4µF7 10V

96 elektor - 7-8/2009 the quality of the sound. The low cut-off + 9 point has risen slightly due to the inclusion + 8

of two extra coupling capacitors in the pre- + 6 1

emphasis circuit, but in practice this will be + 4 2 hardly noticeable. The current consumption + 2

of the transmitter is increased by this circuit + 0

from 2 to just over 5 mA. -2 d B -4 r

The component values in the circuit diagram -6 A are for 50 µs pre-emphasis. For adaptations -8

to 75 µs as used in the USA and other coun- -10

tries, please refer to the parts list. -12

(090305) -14 Download -16

090305-1: PCB layout (.pdf), from www.elektor. -18 20 50 100 200 500 1k 2k 5k 10 k 20 k com/090305 Hz 090305 - 12

Sensitive Audio Power Meter

Michiel Ter Burg (The Netherlands) level of 1 watt, the transistor limits the current C1 R3 through the green LED and the red LED con- 1k As a follow-up to the simple audio power 10µ ducts enough to produce an orange hue. The meter described in [1], the author has devel- red colour predominates above 5 watts. BC547B T1 oped a more sensitive version. In practice, R1 Of course, you can also use two separate, you rarely use more than 1 watt of audio 10k ‘normal’ LEDs. However, this arrangement R2 power in a normal living-room environment. D1 D3 cannot generate an orange hue. For any test-

The only time most people use more is at a 2k2 ing that may be necessary, you should use a party when they want to show how loud their generator with a DC-coupled output. If there stereo system is, in which case peaks of more 2x D2 is a capacitor in the output path, it can cause than 10 W are not uncommon. 1N4148 misleading results. R4 DUO-LED (090203-I) With this circuit, the dual LED starts to light up 1k green at around 0.1 watt into 8 ohms (0.2 watt 090203 - 11 into 4 ohms). Naturally, this depends on the specific type of LED that is used. Here it is Reference [1] Simple Audio Power Meter, Elektor July & August essential to use a low-current type. The capaci- via the green LED. This voltage-doubler effect 2008. tor is first charged via D1 and then discharged increases the sensitivity of the circuit. Above a

Bathroom Fan Controller

Heino Peters (The Netherlands) tinues to run for a few minutes after the line we first use the opamps in IC2 to improve cools down, so that you have considerably the control range. Otherwise we would have Many bathrooms are fitted with a fan to vent fewer problems with humidity in the bath- an unstable circuit because the voltage dif- excess humidity while someone is shower- room without having the fan run for no rea- ferences at the output of IC1 are relatively ing. This fan can be connected to the light son. Naturally, this is only possible if you can small. switch, but then it runs even if you only want fit a temperature sensor somewhere on the IC2a subtracts a voltage of exactly 3.0 V from to brush your teeth. A better solution is to hot water line and the line does not become the output voltage of IC1. It uses Zener diode equip the fan with a humidity sensor. A disad- warm if hot water is used somewhere else. D1 for this purpose, so this is not depend- vantage of this approach is that by the time ent on the value of the supply voltage. The the humidity sensor switches on the fan, the We use an LM335 as the temperature sensor. value of R2 must be selected according to room is already too humid. It generates an output voltage of 10 mV per the actual supply voltage so that the cur- Kelvin. The output voltage is 3.03 V at 30 °C, rent through D1 is approximately 5 mA. It is Consequently, we decided to build a circuit 3.13 V at 40 °C, 3.23 V at 50 °C, and so on. 600 Ω with a 6-V supply (560 Ω is also okay), that operates by sensing the temperature of We want to have the fan switch on at a tem- or 2400 Ω (2.2 kΩ) with a 15-V supply. If you the hot water line to the shower. The fan runs perature somewhere between 40 and 50 °C have to choose between two values, use the as soon as the water line becomes hot. It con- (approx. 100–150 °F). To do this accurately, lower value.

7-8/2009 - elektor 97 +6V...+15V

R1 R2 R11 R12 R14 D2 RE1 * 8 8 3k3 IC2 IC3 1k 10k 3k3 R6 4 4 R10 100k P1 100k 1N4001 R4 10k 2 3 100k 1 5 1 6 T1 R3 IC2.A R9 IC3.A 3 7 2 7 100k IC2.B 1k IC3.B 6 R7 5 BC517 15k

IC1 D1 R5 R8 IC2 = LM358 R13 IC3 = LM393 1k 1k 15k 3V0 LM335 0W5 090078 - 11

IC2b amplifies the output voltage of IC2a IC3 goes Low. by a factor of 16 ((R7 + R8) ÷ R8). As a result, R10 provides hysteresis at the output of The circuit does not draw much current, and the voltage at the output of IC2b is 0.48 V at IC3a by pulling the voltage on the wiper of the supply voltage is non-critical. A charging 30 °C, 2.08 V at 40 °C (104 °F), and 3.68 V at the setting potentiometer down a bit when adapter from a discarded mobile phone can 50 °C (122 °F). Comparator IC3a compares this the output of IC3a goes Low. IC3b acts as an thus be used to power the circuit. If the sup- voltage to a reference voltage set by P1. Due inverter so that relay Re1 is energised via T1, ply voltage drops slightly when the relay is to variations resulting from the tolerances of which causes the fan to start running. After energised, this will not create any problem. the resistor values, the setting of P1 is best the water line cools down, the relay is de- In this case the voltage on the wiper of P1 will determined experimentally. A voltage of 2.5 V energised and the fan stops. If this happens also drop slightly, which provides a bit more on the wiper should be a good starting point too quickly, you can reduce the value of R11 hysteresis on IC3a. (in theory, this corresponds to 42.6 °C). When (to 33 kΩ, for example). This increases the (090078-I) the water line is warm enough, the output of hysteresis.

Backlight Delay

Clemens Valens (Elektor France) here has been designed for just such cases.

Lots of devices are fitted with a VCC liquid crystal display (LCD). Now A device using an LCD usually LCD implies backlighting — that has at least one button that, rather useful option that enables R6 * R2 R5 in most cases, pulls one of the us to read the message being dis- * microcontroller inputs down to 10k played! For devices where there’s T1 0 V when it is pressed. If no such uC D1 R1 no need to read the display con- 10k button exists, one can always D4 tinuously, the backlight doesn’t 1N4148 be added. We can use the signal S1 BC557

D2 CKLIGHT need to stay lit up all the time — R3 from this button to control the

BA several seconds is often all you T2 backlight. As soon as the button 1N4148 need to read the display. This 100R is pressed, the backlight is acti- saves a little power and lengthens vated, then extinguished a few R4 the life of the backlight. Devices C1 BS170 seconds later by the timer. Using

* 7 Dn fitted with an LCD also have a 2M an OR gate, it’s possible to use processor, and so it’s possible to 10u several different buttons to trig- employ a function to control the 1N4148 ger the timer. backlight directly from within the 090454 - 11 processor software. But some- It doesn’t take many components times it’s not possible to imple- to build a timer like this. The OR ment this sort of function within gate consists of a pull-up resistor the microcontroller, because all the control- don’t have the source codes or tools needed R1+R2 and as many diodes as there are but- ler’s pins are already in use, or because you to modify the software. The circuit described tons. Thanks to these diodes, transistor T1

98 elektor - 7-8/2009 conducts while the button is pressed, and through R4 alone, since T2 has a very high applications too, and can be used to switch hence capacitor C1 is charged, the MOSFET input impedance. When T2’s gate voltage things other than an LED — for example, a T2 conducts, and the backlight comes on. falls low enough, it turns off and the back- relay. The value of R5 depends on the load Because R3 has a very low value, capacitor light goes out. The time the backlight stays being switched. For an LED running off a C1 charges very rapidly, so even a very brief lit after all the buttons have been released is 5 V supply, a value of around 300 Ω will be press of one of the buttons is enough to trig- roughly R4 (Ω) × C1 (F) seconds. about right. ger the timer. Once the button is released, (090454-I) T1 turns off, and C1 then discharges slowly Of course, this circuit can be used for other Power On Indicator

Ton Giesberts (Elektor Labs) around two transistors to implement a high-efficiency LED flasher. It is dimen- Some types of electronic equipment do sioned to minimise the drive current of not provide any indication that they are the transistors. The average current con- actually on when they are switched on. sumption is approximately 0.5 mA with a This situation can occur when the back- supply voltage of 3 V (2.7 mA when the light of a display is switched off. In addi- LED is on; 0.2 mA when it is off). C4 and tion, the otherwise mandatory mains R4 determine the on time of the LED (0.5 power indicator is not required with to 0.6 s, depending on the supply volt- equipment that consumes less than age). The LED off time is determined by 10 watts. As a result, you can easily forget C3 and R3 and is slightly less than 5 sec- to switch off such equipment. If you want onds. The theoretical value is R × C × ln2, to know whether equipment is still draw- but the actual value differs slightly due to ing power from the mains, or if you want the low supply voltage and the selected to have an indication that the equipment component values. is switched on without having to mod- Diodes D1-D6 do not have to be special ify the equipment, this circuit provides high-voltage diodes; the reverse volt- a solution. age is only a couple of volts here due K1 D1...D6 = FR606/PR6006 K2 the reverse-parallel arrangement. This One way to detect AC power current and voltage drop is negligible compared to generate a reasonably constant voltage D1 D2 D3 the value of the mains voltage. The only independent of the load is to connect a thing you have to pay attention to is the string of diodes wired in reverse paral- D4 D5 D6 maximum load. Diodes with a higher lel in series with one of the AC supply R1 C1 D8 current rating must be used above 1 kW. leads. Here we selected diodes rated 22R V+ In addition, the diodes may require cool- 100u BAT85 at 6 A that can handle a non-repetitive 10V ing at such high power levels. peak current of 200 A. The peak current D7 C2 Measurements on D1–D6 indicate that rating is important in connection with BAT85 1000u the voltage drop across each diode is switch-on currents. An advantage of 16V approximately 0.4 V at a current of 1 mA. the selected diodes is that their voltage Our aim was to have the circuit give a V+ drop increases at high currents (to 1.2 V D9 reasonable indication at current levels at 6 A). This means that you can roughly of 1 mA and higher, and we succeeded R2 R3 R4 R5 R6 estimate the power consumption from nicely. However, it is essential to use a k k 15 560R the brightness of the LED (at very low 150k 1M5 15 good low-current LED. C3 C4 power levels). The voltage across the diodes serves as 100u 470n Caution: the entire circuit is at AC 10V the supply voltage for the LED driver. To T1 T2 power potential. Never work on the cir- increase the sensitivity of the circuit, a cuit with the mains cable plugged in. The cascade circuit (voltage doubler) consist- BC550C BC550C best enclosure for the circuit is a small, ing of C1, D7, D8 and C2 is used to double translucent box with the same colour as 090400 - 11 the voltage from D1–D6. Another benefit the LED. Use reliable strain reliefs for the of this arrangement is that both halve- mains cables entering and leaving the waves of the AC current are used. We use box (connected to a junction box, for Schottky diodes in the cascade circuit to example). The LED insulation does not minimise the voltage losses. approximately 5 seconds off and 0.5 second meet the requirements of any defined insu- The LED driver is designed to operate the LED on. If we assume a current of 2 mA for good lation class, so it must be fitted such that it in blinking mode. This increases the amount brightness with a low-current LED and we can cannot be touched, which means it cannot of current that can flow though the LED when tolerate a 1-V drop in the supply voltage, the protrude from the enclosure. it is on, so the brightness is adequate even smoothing capacitor (C2) must have a value of (090400-I) with small loads. We chose a duty cycle of 1000 µF. We use an astable multivibrator built

7-8/2009 - elektor 99 Two TV Sets on a Single Receiver

Heino Peters (The Nether- 1 a new signal for driving lands) the infrared LED at the digital receiver location is With the advent of dig- shown in Figure 2). ital television, it’s often necessary to use a sepa- The infrared signal from rate receiver. If you have the remote control unit several television sets consists of short pulse in your house, you have trains of modulated infra- TV1 TV2 to buy a digital receiver red light. The modulation (and accompanying sub- frequency varies from scription) for each set. PCB one brand to the next and The solution described lies in the range of 30 to TV SCART VCR SCART here lets you watch tel- AUDIO-L 56 kHz (B&O, different as evision in two or more AUDIO-R always, uses 455 kHz). Fre- VIDEO places in your home using quencies in the 36–40 kHz a single digital receiver, IR-LED range are most often used while allowing the digital IR 090077 - 12 in practice. The modu- receiver to be controlled lation frequency of an from both locations. The infrared sensor is usu- circuit needed for this is 2 ally indicated in its type powered from one of the +5V number. For example, two television sets (see the TSOP1736 responds

Figure 1). T1 P1 to IR light modulated at R2 C2 36 kHz, the TSOP1738 10k 1k You’ll need a length of 10u 16V likes 38 kHz, and so on. four-way shielded cable BC555 Figure 4 shows a few (such as Conrad Electron- IR receivers and their ics # 606502) for the con- 4 8 pinouts. Infrared sensors R 7 nection between the dig- DIS also have adequate sen- R1 ital receiver and the sec- D1 IC1 R4 sitivity to other frequen- 3 OUT 10k 22R ond TV set. Two shielded 2 cies close to their design TR D2 6 555 conductors are used to THR frequency. Consequently, 1N4148 transmit the audio sig- CV we assume a modula- R3 C1 5 1 nals (L and R) from the LD274 tion frequency of 38 kHz 10k receiver to the second TV 10n here, which covers the full set, another one is used to range from 36 to 40 kHz. transmit the video signal, 090077 - 11 The IR receiver demodu- and the last one is used lates the infrared signal. to transmit the remote The demodulated signal control signal from the remote control for already in use, you can always take the audio forms the input to our circuit, which uses it the second TV set to the digital receiver and video signals from the Cinch connectors to generate a new modulated signal for the IR located next to the first TV set. The infrared (if present). LED located next to the digital receiver. sensor of the second TV set receives the sig- nal from the remote control unit for the dig- The circuit necessary for converting the infra- The author opened up his second TV set ital receiver and sends it via a small circuit to red signal received by the second TV set into (watch out for possible sources of high volt- an IR LED aimed at the infrared sensor of the age inside the set!) in order to use the set’s digital receiver near the first TV set. With this built-in IR receiver and tap off power for the

3 IN arrangement, it’s convenient to buy a second L modulator circuit. However, you can also fit (programmable) remote control unit so you the circuit with its own IR receiver and use a AUDIO AUDIO GND AUDIO R IN don’t have to carry the original remote con- 20 VIDEO IN 6 4 2 separate power supply (AC mains adapter). trol unit of the digital receiver back and forth all the time. The output signal of the IR receiver is used to trigger an astable multivibrator built around Most digital receivers have two SCART con- our old friend, a 555 timer IC. The data line of 1 nectors for connecting a television set and a 3 the IR sensor is High in the quiescent state video recorder. The second SCART connector and goes Low when it receives an modu- OUT can be used quite nicely for the signals to be L lated IR signal. As the Reset input of the 555 VIDEO OUT 19 sent to the second TV set (see the connec- VIDEO GND 17 responds to an active-low signal, an inverter AUDIO 090077 - 13 AUDIO R OUT tion diagram in Figure 3). If this connector is is built around T1, R2 and R3. The modulation

100 elektor - 7-8/2009 frequency for IR LED D2 is set to approxi- 4 Place IR LED D2 in front of the dig- mately 38 kHz by P1, R1 and C1. Diode D1 ital receiver so it shines on the receiv- allows the duty cycle of the output sig- er’s IR sensor. Use the screen of the nal to be less than 50%, which cannot be fourth shielded conductor of the cable achieved otherwise. The rise time of the TSOP1736 TSOP1836 TSOP4836 between the receiver and TV2 for SFH506 SFH505A PIC12043S IS1U60 NJL61H380 SFH5110 oscillator signal on the Threshold input TFMS5360 the negative lead of D2. Resistor R4 is of the 555 is set by P1 and C1, while the dimensioned for a current of around fall time is set by R1 and C1. 100 mA through the IR LED. If you use a 3.3-V supply voltage, R4 must be The ratio of P1 to R1 determines the reduced to 3.3 Ω.

duty cycle, which is approximately 30% 090077 - 14 in this case. With a 5-V supply voltage, You can also use this circuit for the P1 is set to 1 kΩ, but it must reduced to a remote control of audio or video equip- lower value (around 500 Ω) with a lower sup- (period: 26.3 μs). To generate a test signal at ment located inside a closed cabinet. ply voltage. If possible, use an oscilloscope the 555 output, temporarily connect the cir- (090077-I) to adjust the oscillator frequency to 38 kHz cuit input to ground.

Tester for Inductive Sensors

Hugo Stiers (Belgium) wave signal with a pattern matching the teeth of the gear wheel, with a fre- +9V This tester uses a LED to indicate quency equal to the frequency of the whether an inductive sensor is gen- AC signal generated by the sensor. R4 8 erating a signal. It can be used to test R2 You can also use this tester to check IC1 the inductive sensors used in ABS and 820k 10k the polarity of the connecting leads. 4 EBS systems in cars, with engine cam- R1 To do this, first dismount the sensor 2 shafts and flywheels, and so on. 1k and then move it away from a metal- 1 5 IC1.A The circuit is built around an LM358 3 7 lic object. The LED will go on or off IC1.B 6 dual opamp IC. The weak signal com- R6 while the sensor is moving. If you now ing from the sensor (when the wheel reverse the lead connections, the LED IC1 = LM358 2k2 is turning slowly, for example) is an R3 R5 should do exactly the opposite as AC voltage. The first opamp, which D1 before when the sensor is moved the 1k is wired here as an inverting ampli- 4k7 same way. fier, amplifies the negative half-cycles of this signal by a factor of 820. The 090316 - 11 The circuit has been tested extensively second opamp is wired as a compa- in several workshops on various vehi- rator and causes the red LED to blink cles, and it works faultlessly. regularly. slowly, with the result that the LED will remain The author has also connected the tester to In order to judge the quality of the signal dark, but it will generate a signal if the wheel sensors on running engines, such as the cam- from the sensor, you must turn the wheel is turned faster and the LED will thus start shaft and flywheel sensors of a Volvo truck very slowly. If the red LED blinks, this means blinking. Irregularities in the blinking rate can (D13 A engine). With the camshaft sensor, the that the sensor is generating a signal and the be caused by dirt on the sensor or damage to LED blinks when the engine is being cranked distance between the sensor and the pole the pole wheel (gear wheel). for starting, but once the engine starts run- wheel (gear wheel) is set correctly. If the dis- ning you can’t see the LED blinking any more tance (air gap) is too large, the sensor will not If you connect an oscilloscope to the LED with due to the high blinking rate. generate a signal when the wheel is turned the engine running, you will see a square- (090316I-I)

USB Radio Terminal Rainer Schuster (Germany) ple example listings in BASCOM demon- here connects an RFM12 radio module to the In the January 2009 issue of Elektor we saw strated how to communicate data using the R8C/13 microcontroller board used in the how straightforward it is to connect a low- modules [1]. ‘Transistor Curve Tracer’ project described in cost RFM12 868 MHz ISM (licence-free) radio the February 2009 issue [2]. The populated module to an ATmega microcontroller. Sim- The ‘USB radio terminal’ circuit described board, complete with USB interface connec-

7-8/2009 - elektor 101 tor, is available from the Elektor shop. The circuit can be used to transfer data (for example from a PC terminal emulator pro- SDO gram) wirelessly to another microcontroller and vice versa. Of course, the remote micro- controller also needs to be equipped with a radio module. As ready-made and tested boards are avail- able (even the radio module is available D V SDI +5 SEL ANT SCK from Elektor [3]) building the circuit does not GN present any great difficulty. All that is neces-

sary is to connect a total of six pins of K1 on P1.1 P1.0 P1.2 P1.3

20 the R8C/13 microcontroller board to pins on 2 the radio module. The 5 V and ground pins 1 19 are connected directly to their namesakes so that the radio module draws its power from the microcontroller board. The SPI port on the radio module is driven from port pins P1.0 to P1.3 on the microcontroller: see the ‘circuit diagram’. The microcontroller module will receive its power over the USB cable when it is con- 090372 - 11 nected to a PC. The author has written R8C firmware in C, available for download in source or hex for- the sequence is received the line As configured, the software uses a data trans- mat from the Elektor website. The C source of characters is sent to the radio module fer rate of 9600 baud with 8 data bits, 1 stop can be edited and compiled using the ‘High transmitter using a special protocol. bit, no parity and no handshake. The terminal Performance Embedded Workshop’ IDE by On the receive side, the program waits for program (for example, Hyperterminal) must Renesas [2], and further information is avail- characters from the radio module receiver. be configured to match these settings. able from the R8C pages of the Elektor web- When the control code (‘start of text’, (090372-I) site [4]. The Motorola hex file can be down- 0x02) is received, the subsequent characters Internet Links loaded over the USB port using the Flash are buffered until the stop code (‘end [1] www.elektor.com/071125 Development Toolkit [2][4]. To enter pro- of text’, 0x03) is received. The transmitted [2] www.elektor.com/080068 gramming mode jumper JP1 must be fitted message includes a trailing checksum, so the [3] www.elektor.com/090372 on the microcontroller board and the reset complete sequence of characters is [4] www.elektor.com/service/r8c---information.78378. button pressed briefly. After programming is . If the check- lynkx complete, don’t forget to remove the jumper sum is correct, it, along with the and and press the reset button again. characters, is discarded, is Products The firmware mostly consists of the BASCOM appended, and the resulting string sent out 071125-71: 868 MHz radio module, populated and routines written by Burkhard Kainka [1], mod- over the USB port to the PC. tested, available via [3] ified and converted into C. Extra functions Of course, strings and commands can be 080068-91: R8C microcontroller board, populated and have been added to handle the UART1 inter- sent over the radio link to other applications. tested, available via [3] face, which is connected to the USB interface In some cases the protocol will have to be chip. adapted. In particular, because of the limited On the transmit side, the program waits for available RAM on the R8C/13 (1 kB) the inter- Download characters to arrive over the USB port and mediate buffer is only 200 bytes long. This 090372-11: source code and hex files, from [3] stores them in an intermediate buffer. When should be adequate for most uses.

Going for Gold Joseph Kopff (France) their button, and so is allowed to answer the The diagram shows three buttons: S2 and S3 The title refers to a popular TV game show question. The project described here shows are the buttons for the two contestants, S1 is where the contestants each have a big but- how to build a similar sort of refereeing the button for the host, which allows them to ton. The gameshow host asks a question device yourself, using simple resources and reset the circuit before each fresh question. and the first contestant to press their but- without needing a microcontroller, which is The ‘brains’ of the circuit is IC1, a 4013 dual D- ton makes an illuminated indicator light up pretty rare these days! The basic circuit is for type flip-flop, of which only the Set and Reset on their desk. The other contestants’ buttons just two contestants, but the modular design inputs are used here. This circuit can handle are automatically inhibited, so that everyone means it can easily be expanded. quite a wide supply voltage range, from 3 to can see who was the first contestant to press 15 V, and so the project can easily be run off

102 elektor - 7-8/2009 a 4.5 V battery pack (the power consumption is minimal). +4V5 +VDD

IC1 is armed by pressing S1 (reset). In this R1 R5 R8 14 state, the non-inverting outputs (pins 1 and Ω Ω IC1 IC1 = 4013 10k 330 330 13) are at 0 and the inverting outputs (pins 12 7 D1 D3 and 12) are at 1. Hence line A is pulled high by R1, since diodes D2 and D4 are not biased A

T1 T2 on. If contestant 1 presses button S2, the S2 S3 non-inverting output of flip-flop IC1a goes

to logic 1, and LED D1 lights via T1 to indi- R4 2N R7 2N 4k7 6 2222 8 4k7 2222 cate that contestant 1 has pressed the but- S1 5 S 1 D2 9 S 13 D4 ton. At the same time, the flip-flop’s invert- D D IC1.A IC1.B RESET 3 2 11 12 ing output goes to logic 0, making diode C C D2 conduct. Line A is now pulled down to 0, R 1N4148 R 1N4148 4 10 B and consequently contestant 2’s button S3 can no longer trigger the second flip-flop. R2 R3 R6 10k

The reverse happens if it is contestant 2 who 100k 100k presses their button S3 first.

081183 - 11 The circuit can be extended to 4 or 6 contest- ants (or even more) by adding a second or third (or more) 4013 IC. All you have to do is connect to the A, B, Vdd, and 0 V lines on the (081183-I) repeat the circuit (minus R1, R2, and S1) and right-hand side.

Cut-rate Motorbike Alarm

T.A. Babu (India) A * Motorbikes are often a target for thieves. Here is an alarm that’s loud, cheap and simple to build. Arming and disarming the alarm is B * done with a hidden switch, S1. This tiny circuit does not unduly load the battery, as it draws very little current in the standby condition. To activate the alarm, turn or press the hid- S1 den switch S1 to the ‘on’ position. If anyone attempts to start the motorbike, +12 volts R1 R2

from the ignition switch (connected to ‘B’) 10k 10k T2 causes transistor T1 to conduct and switch on T2. The siren (LS1) then sounds for about 20 BT1 TR1 seconds, the period being determined by FET BC557 T1 D1 D2 RE1 T3 wired as a monostable timer. The siren is 12V a high-power ready-made piezo horn of the 1N4148 12V BC547B self-oscillating type. R3 1N4148 Another piezoelectric component in the cir- Ω cuit has a different purpose — Bz1 detects BZ1 470 LS1 attempts to tamper with the vehicle, or move R4 C1

it without starting the engine. The piezo trans- 5

1M T3 ducer element should be mounted in such a 10µ way as to faithfully pick up vibration from the 16V motorbike frame due to tampering. One set of contacts on relay RE1 is used to BS170 effectively disconnect the ignition coil to pre- 090338 - 11 vent the bike from functioning when some- one tries to steal it. Usually, there is a wire running from the alternator (point A) to the ably a miniature type or its electrical equiv- driver/timer circuit when the ignition key is ignition coil (TR1), which has to be routed alent. To deactivate the alarm, the hidden turned… by the lawful owner! through the N/C (normally closed) contact switch should be flipped to the ‘off’ position (090338-I) of the relay. The hidden switch S1 is prefer- to disable the movement sensor and the siren

7-8/2009 - elektor 103 Digital Sweep and Sinewave Generator

‘*12000#’. The usable frequency with range runs from around 10 Hz to direct frequency entry 500 kHz. In order to ensure that a clean out- put signal is produced the timer interrupt is disabled during sine- Wilfried Wätzig (Germany) wave generation. If a button is pressed a pin change interrupt is The Parallax SX28-based ‘Fre- triggered which enables the timer quency Response Sweep Oscilla- so that a new frequency value can tor’ project published in the April be entered. 2008 issue of Elektor inspired the author to develop a similar circuit The sinewave frequency accuracy based on the ATmega48 microcon- and stability are determined by troller. As it turns out, the ATmega- the quality of the 25 MHz crystal. based circuit is nearly as capable There may also be a small error in as the original. absolute frequency resulting from An important characteristic of the rounding errors in the calculation design is the maximum direct dig- of the DDS phase accumulator ital synthesis (DDS) sample rate increment value. that can be achieved when gen- The DDS phase accumulator incre- erating a sinewave. The specifica- ment value is derived from a set of tions are comparable: values stored in a look-up table:

24 SX28 design: fDDS = 50 MHz / increment = freq * 2 * cycles / fosc 28 cycles = 1.78 MHz ATmega48 design: for freq = 2k, k = 0 to 19. The total

fDDS = 25 MHz / increment value is calculated to 24 18 cycles = 1.39 MHz bits of precision.

At 25 MHz, the ATmega48 is some- The main features of the unit are what overclocked in this circuit. listed in the text box, and the func- The maximum specified clock fre- tions of switches S1 to S3 are given quency according to the datasheet is 20 MHz. In sinewave generation mode the desired in Table 1. In practice, however, this does not seem to frequency is entered directly on the keypad The digital outputs on Port B are protected lead to problems. in Hertz. For example, to enter 12 kHz, type from short circuits by series resistors. The The other important part of the cir- amplitude of the sinewave out- cuit is the digital-to-analogue con- put can be set between 0 VPP and verter (DAC) connected to Port D Characteristics 4.5 VPP using P1. of the microcontroller. This takes Digital sweep function: the form of an R-2R network and The ATmega48 chip can be pro- • Frequency ranges: 100 Hz to 100 000 Hz or 50 Hz to 15 000 Hz, can approximate a sinewave with grammed using the 10-way ISP • logarithmic scale with 256 steps a sample rate of 1.39 MHz. The dig- interface connector provided. The • 2 sweep rates: 0.2 ms or 0.4 ms per frequency value ital values are read from a look-up firmware for this project was writ- (phase accumulator increment value changed every 0.2 ms or 0.4 ms) table. ten in assembler using the Atmel A passive sixth-order Butter- Outputs in sweep mode: AVR Studio 4 development sys- worth low-pass filter with a cor- • sine output tem, version 4.14. The project files ner frequency of 500 kHz is used • marker frequency (rectangular wave) (source code and hex) are avail- to smooth the DAC output. This • marker position pulse able for free download from the is particularly necessary at higher • trigger pulse at start of each sweep Elektor website [1]. The zip file also frequencies. includes a screenshot showing Digital sinewave operation: the fuse settings required for the The user interface is principally • Direct frequency entry in Hertz via keypad microcontroller in AVR Studio 4. As provided via a twelve-button tel- • Format: ‘*’ = start of entry an alternative to the program-it- ephone-style keypad. In sweep digit(s) 0 to 9 yourself route, ready-programmed mode the four rows of buttons ‘#’ = end of entry, start sinewave generator microcontrollers are available from (1-2-3, 4-5-6, 7-8-9 and *-0-#) are Outputs in sinewave mode: the Elektor Shop. (080577-I) used to adjust the marker fre- • sine output (0 VPP to 4.5 VPP) quency up and down in coarse or • frequency/marker pulse (rectangular wave) Internet Link fine steps.

104 elektor - 7-8/2009 [1] www.elektor.com/080577 Table 1. Function of switches S1 to S3 Downloads and products Open Closed 080577-41: ready-programmed ATmega48 S1 (frequency sweep range) 50 Hz to 15 kHz 100 Hz to 100 kHz microcontroller S2 (sweep rate) 0.2 ms 0.4 ms 080577-11: source code and hex files, from www. elektor.com/080577 S3 (sinewave/sweep output) sinewave output sweep output

+5V +5V +5V

R27 R25 2 K6 C7 L1 L2 L3 220k 1 2 1 R1 IC4.A

10k 2mH2 2mH2 1mH 100n 3 4 3 20k P1 R9 6 5 C11 C12 C13 8 7 10k 10 9 R2 4k7 K2 21 7 20 120p 75p 15p Marker 20k Frequency AREF VCC AVCC R10 IC4 = CA3240 ISP R17 14 IC3 1 K3 4k7 PB0(ICP) PC6(RST) 10k Sweep R18 15 R3 +5V PB1(OC1A) Trigger 4k7 R19 16 20k 4k7 PB2(SS/OC1B) R11 17 R28 K4 PB3(MOSI/OC2) Marker 18 13 6 0 1 2 PB4(MISO) PD7(AIN1) 10k C14 Display K5 470k R2 R2 R2 19 12 R4 7 PB5(SCK) PD6(AIN0) R26 IC4.B 11 20k 5 Keyboard PD5(T1) R12 10k 10µ R29 Output 4k7 4k7 4k7 6 K7 PD4(XCK/T0) ROW4 28 5 10k 1 2 3 PC5(ADC5/SCL) PD3(INT1) 100k ROW3 27 4 R5 PC4(ADC4/SDA) PD2(INT0) ROW2 26 3 20k IC1 4 5 6 PC3(ADC3) PD1(TXD) R13 ROW1 25 2 K1 D1 7805 +5V PC2(ADC2) PD0(RXD) COL3 24 7 8 9 PC1(ADC1) 10k COL2 23 R6 +12V PC0(ADC0) DC 1N4007 COL1 20k C1 C3

3 4 C2 C4 0 # ATmega48-20 R14

* R2 R2

D2 D3 D4 GND XTAL1 XTAL2 AGND 100µ 100n 47µ 100n

3x 8 9 10 22 10k 10k 1N4148 10k R7 X1 +8V 20k R15 IC2 78L08 +8V

25MHz 10k S3 S2 S1 C9 C8 R8 8 C10 20k 20p 20p R16 IC4 C5 C6 4 100n Wobbulator/ Wobbulator Frequency Sine wave gen. rate range 20k 47µ 100n

080577 - 11

Guitar Amplifier PSU

Malcolm Watts (New Zealand) tre-tapped HT winding on the power

TR1 transformer but this has a number of Tubes (thermionic valves) have never R1 +HT drawbacks for an adequately rated core D1 departed from the amplified instru- 1 V1 3 size including increased voltage stress, ment scene and the majority of gui- 4 small wire size and a poor utilisation of 5 D2 tarists, including very young ones, 260V the available winding window. 7 EZ81 wouldn’t use anything else. Some die- 6CA4 The example arrangement shown here hards think that the H.T. (high tension) reduces both of these problems and for 230V rectifier should also be a piece of glass- 110V a given core increases the current deliv- ware and some manufacturers are still ery capability of the winding by allow- 6V3 producing amplifiers incorporating ing the use of a heavier wire gauge. Nor- 1A one. The nett effect is really that a rec- mally some resistance is added in series tifier tube acts as a relatively effective to each anode to limit peak cathode heat-dissipating resistor, causing the current to minimise cathode-stripping HT rail to sag as output signal loading 6V3 during the high current pulses deliv- increases, generating a compressive ered to the input filter capacitor at each characteristic which is fundamentally voltage peak. Even if one includes such added distortion (‘crunch’). 081067 - 11 resistance (and a single resistor in series The traditional arrangement uses a cen- with the cathode or winding achieves

7-8/2009 - elektor 105 the same end albeit with double the device Alternatively, a smaller winding window (6CA4) tube its maximum output current is dissipation) the benefits to the transformer (reduced core size) may be employed with- about 100 mA. Higher currents call for a more of reduced voltage stress and increased wire out diminishing power-handling capacity. powerful rectifier tube and diodes to match. insulation thickness (which scales with wire The circuit shown here should is typically (081067-I) diameter) along with decreased heating in intended for the amplifier preamp and phase the windings, are obvious. splitter stages. Due to the use of the EZ81

Acoustic Distress Beacon

Werner Ludwig (Germany)

An ELT (Emergency Locator Transmitter, also R2 BZ1 14 C3 known as a distress beacon) is an emergency IC1 = 74HCT132 IC1 10M 7 4µ7 radio transmitter that is activated either man- 25V 5VDC ually or automatically by a crash sensor to aid BT1 the detection and location of aircraft in dis- K1 IC1.A T1 1 D1 IC1.B 3 5 IC1.C tress. This acoustic ELT project is intended for 2 & 6 10 4 & 8 6V radio-control (RC) model aircraft, which every 1N4148 9 & now and then decide to go their own way and R3 R4 BS170 disappear into the undergrowth. 100k 10M GP11A D2 R1 J1 The audio locating device described here C1 C2

68K 1N4148 enables model aircraft that have landed ‘off 10n 4µ7 25V limits’ to be found again and employs its own 090037 - 11 independent power supply. The small cam- era battery shown in the circuit activates an acoustic sounder when radio contact is lost and produces a short signal tone (bleep) MOSFET transistor T1. All the time that the RC Internet Link every ten seconds for more than 25 hours. receiver output is delivering positive pulses, http://en.wikipedia.org/wiki/Emergency_Position- Current consumption in standby and pas- the oscillator is blocked by IC1.A and diode Indicating_Radio_Beacon sive (with jumper J1 set) modes is negligible. D1. Setting jumper J1 parallel to C2 also disa- The timing generator for the alarm tone is bles the oscillator and serves to ‘disarm’ the the Schmitt trigger AND-gate IC1.B; its asym- distress beacon. metric duty cycle drives a 5 V DC sounder via (090037-I)

Measuring Milliohms with a Multimeter

Klaus Bertholdt (Germany) multimeter. The circuit consists R1 of little more than a 6 V voltage Low values of resistance can be 120R regulator and a mains adapter troublesome especially when R2 capable of supplying around 120R S1 large currents flow through R3 300 mA at 9 to 12 V. them. A current of, say, 10 A 1k2 passing through a terminal with K1 IC1 R4 The circuit supplies a fixed cur- 7806 1k2 a contact resistance of 50 mΩ 1 3 rent output of 100 mA or 10 mA will produce a voltage difference selected by switch S1. This con-

2 M1 of 0.5 V. This resulting power loss 9 VDC C1 C2 D1 R nects either the 60 Ω or 600 Ω 300 mA x of five watts is dissipated in the resistor into the constant current 1u 10u 1N4004 termination and can give rise to 63V 63V generator circuit. The resistor a dangerously high temperature values are produced by parallel- which may degrade insulation 080851 - 11 ing two identical resistors; 120 Ω around the wires. and 1.2 kΩ from the E12 stand- ard resistor range. Two test leads Measuring low values of resistance is not ist equipment is expensive. The simple cir- with probes are used to deliver current to the easy. Low cost multimeters do not include a cuit described here allows milliohm meas- test resistance. The resultant voltage drop is milliohm measurement range and special- urements to be made safely on a standard measured by the multimeter (M1). With the

106 elektor - 7-8/2009 test current set to100 mA a measurement probes close together on the same lead of supply level and of course the accuracy of of 1 mV indicates a resistance of 10 mΩ. At the test resistance and note the reading, now the measuring voltmeter. 10 mA (with S1 in the position shown in the place the probes across the test resistance diagram) a measurement of 1 mV indicates a and note the reading again. The first read- For optimum decoupling C1 should be fitted resistance of 100 mΩ while 0.1 mV is equal to ing measures just the test leads and probes as close as possible to pin1 of IC1. An addi-

1 mΩ. Diode D1 protects the meter from too while the second includes the resistance RX. tional electrolytic capacitor of around 500 µF high an input voltage. Subtract the first measurement from the sec- can be used at the input to the circuit if the

With the voltmeter connected as shown in ond to get the value of RX. input voltage from the AC power adapter the diagram it measures not only the voltage exhibits excessive ripple.

drop across RX but also that produced by the The accuracy of the measurements are influ- (080851) resistance of the test leads, and probes. To enced by the contact resistance of switch make a true measurement, first touch the S1, the precision of resistors R1 to R4, the 6 V

Snail Mail Detector

Philippe Temporelli (France) tion, according to the following logic: LA S Since his letter-box is outdoors and quite some way from the - Both half-cycles present: no house, the author was looking * change in the status of the mail for a simple means of knowing if detector. the postman had been without - An interruption (even brief) of having to go outside (contrary one half-cycle: indicator lights to popular belief, the weather permanently. isn’t always fine in the South of - An interruption (even brief) of France). Circuits for this kind of the other half-cycle: the indica- ‘remote detection’ come up reg- tor goes out. ularly, but always involve run- ning cables between the letter- Note that the signal is tapped off TR box and the detection circuit in B * across the doorbell coil via R6 230V the house. Seeking to avoid run- (120V ) and the pair of diodes connected ning any extra cables, the author in inverse-parallel (to limit the had the idea of using the exist- * signal, particularly when the ing cables going to the doorbell, 090481 - 11 bell is rung). The signal is then conveniently located adjacent to filtered by R2/C1, before being his letter-box. used by IC1, which is wired as a comparator with hysteresis. The The letter-box has two doors: trigger threshold is adjusted by S1 S2 one on the street side for the ** P1, using a pair of inverse-paral- postman, and one on the gar- D2 D1 lel diodes as a voltage reference den side for collecting the post. (positive or negative according * R1 LA S A microswitch is fitted to the to the output state): street-side door, to light an indi- 180R For the detection to work, there cator in the house showing that * has to be continuity in the bell- the postman has been. A second push circuit — this is generally microswitch is fitted to the door D8 ensured by the little lamp illumi- D9 on the garden side, to turn off C3 nating the bell-push. Resistor R1 the indicator once the post has 100u R5 is added just in case the lamp is IC1 been collected. The only diffi- R6 R2 blown or not present. 7 1k8 2 1k1 100k culty then remains to connect 6 To keep things simple, the cir- LF357 C5 3 these detectors to a remote cir- R4 cuit is powered directly from the 4 cuit in the house that remem- D7 100u doorbell transformer itself (230 V 100k bers whether the postman’s / 8 V). The author managed to fit TR R3 been or not. B * 100k the little circuit within the door- 230V P1 bell unit, with the LED poking (120V ) D3 D4 C1 D5 D6 C2 50k The idea was to use the alternat- ADJ through a hole in the casing so 1u ing half-cycles of the AC signal * 100n it is readily visible in the hall of on the cable going to the door- 090481 - 12 his house. bell to transmit the informa- (090481-I)

7-8/2009 - elektor 107 DMX Transmitter

Gerald Weis (Austria) because the MSP430 has an internal oscillator. As with every project, this one also has room If you use the internal oscillator, it’s important for improvement. If you use the internal oscil- Lighting effects are always popular at special to adjust the frequency precisely using resis- lator of the MSP430, the DMX bus may not events, whether large or small. For example, tor R6 = ROSC (also shown in the schematic operate at the right speed if the temperature a spotlight with a moving head can be used diagram). The microcontroller data sheet [3] changes. However, this could be compen- to project a company logo or other image on lists the appropriate values. To check the fre- sated by measuring the temperature with the the wall or ceiling. These special-effect light quency of the internal oscillator, it should be temperature diode in the MPS340 and mak- sources are controlled by the widely use fed out to an I/O pin and measured. ing suitable adjustments. A display would DMX protocol [1], for which many PC-based also be a nice addition. Anyone who is inter- programs are available. However, providing A LED that indicates that the transmitter is ested in expanding on the current design is some sort of PC and setting up the USB and operating is driven via port pin P2.0. Exten- welcome to contact the author [7]. DMX hardware involves a certain amount of sive information on the DMX driver (IC3) and (081158-I) extra effort and expense. Consequently, the its circuitry is available on the Web [4].

RESET IC2 +3V3 TEST LM317LB +3V3 +3V3 R5 R1

47k R6 adj. C4 K1

1% 220R 100k 100n +9VDC C1 C2 C3 2 R2 K2 0 100n 1u 10n VCC 1 28 TDO_TDI 1 2

TEST P1.7/TDO/TDI 330R 3 27 TDI_CLK 3 4 P2.5/Rosc P1.6/TDI/TCLK +3V3 5 26 TMS 5 6 X1 XOUT/P2.7 P1.5/TMS 6 25 TCK 7 8 XIN/P2.6 P1.4/TCK 7 IC1 24 9 10 +3V3 RST-NMI P1.3 8 23 11 12 P2.0/ACLK P1.2 C5 32.768kHz 9 22 13 14 P2.1/SMCLK P1.1 +3V3 10 21 P2.2/CAOUT P1.0 100n 11 20 JTAG P3.0/UCA0CLK P2.4 8 D1 12 19 P3.1/UCB0SDA P2.3 VCC K3 13 18 1 2 P3.2/UCB0SCL P3.7 R 7 R7 R3 14 17 2 IC3 B P3.3/UCA0STE P3.7 R 1 R4 16 3

P3.5/UCA0RxD DE 6 120R

100R 15 4 SN65HV A P3.4/UCA0TxD D 2k7 D10QD 3 T1 MSP430F2112TPW S3 S2 S1 GND XLR VSS 5 4 BC337

081158 - 11

author built a small stand-alone DMX trans- The author wrote the firmware for the micro- mitter that can easily be configured using controller, which must be adapted to the Internet Links three buttons. actual DMX device that is used. The author’s [1] http://en.wikipedia.org/wiki/DMX512-A C source file for this project can be down- [2] www.ti.com The entire circuit is based on a Texas Instru- loaded from the Elektor website [5]. IAR Kick- [3] http://focus.ti.com/lit/ds/symlink/msp430f2112.pdf ments MSP430F2112 microcontroller, along start Edition, which can also be downloaded [4] http://focus.ti.com/docs/prod/folders/print/ with an SN65HVD10QD RS485 transceiver IC from the Elektor website [6], can be used as sn65hvd10.html from the same manufacturer (note: both ICs the development environment. [5] www.elektor.com/081158 can be obtained from TI as samples). [6] www.elektor.com/081041 The code for initialising the serial interface is [7] [email protected] In addition, it requires a small circuit board, also shown on the TI website. The program a female XLR connector, three pushbutton transmits 25 DMX channels at once. Inter- switches, and a few resistors and capacitors. rupts are used to handle pushbutton input The circuitry around the MSP430 (including and transmit the DMX data. In the author’s Download the JTAG port) is standard. More information example software, one button is configured Software about the microcontroller is available on the for the tilt motion of the Futurelight MH-640 081158-11: source code files, from [1] Web [2]. The schematic diagram shows a moving head unit, while the other two but- quartz crystal, but it can be omitted if desired tons are unused.

elektor - 7-8/2009       " -7-"- -     $-""-     )1.- "- ! -1- $-"!"- %- "- ! -1      -* +-1- --(!-   0  -! --  -  - $-" 0-- "#$$$ ( -" -"!!-&"- 3 '-"2-" -  3 8- ""'! - "## %%#  -""-! 2- -! -6,245-#2--  "      ! ! " ---! - - -- "!-- -,44-/- "!    !  /-&! -"- '!"2- --'!- " 2- 7    

         & 1 1 %&1& 11            # $ )((7  (7CD7 <   . ) 7()7'7(  7 7)7! 7)7'7 7 7  ((7) 7 7)7! 7)7'7 77  ((7) 7 ) 7- 7  (7 >7 $7- (7 7 :7 :7& ()@ ()7 ))7)  7) 7  (7 7'7)$>7 " (7 7- -)>7C4-67  7-  7) 7$ 7-  >77 7'.7 7 ((7 )(>7 ).(7&7 )>7CCD,CDD-->7 (?7CD* @B>47 '.7 7 ((7)7) 7 )(>7  7)((7 ?7 7 7&224789>=47 +7 7 ?70C2D+"7<72/787/1 -.( 7 7 ?70C2D7<720787/1 (  1 %% 1:1& &% 1# 6 56 1 &%1 %& 1 :1 %&1 % 1 1 %&1 11! 1 - 7  (( 7;< $41-6 & %1 &%11 ( & 11 $7)74<04* 74:757 7 )(7()7. ) >747 1=1 %% 1 %&1& 1 ;<() 7  ()7 7 -)7) 7()7  >727 27)(7 - 7 -  7) 7 7 757- >7  () 7 )(7 >7& (7 )(7 7- ) 7  $ 7  7) 7 < 7)7$)7 7  (7) 7 -  7) 7()7 <  7  (>7 )77) <)( 7 7 < 7) () >7 <  ((7'7 7 7   (( 7- 7 7 7 >7 7 7 7  (( 7$)7)(7 7 7  )--71 7  7)(()7C;DB7 7 ,70C9=7 $7. ) 7 7)7(7 ))(((7 7'7/ '7):7-)(7- ()< C;DB7 )(7< >7 ) 7 (?7=* >7 ?7;B,4B-->7  7 7.)7(3>7#( 7 ()7)7 - -7 7180>=47)3>7 747 +7 7 ?70C9=+"7<727 '7 (?7 ) 7()7)(7  $ 7  7  (>7 -.( 7 7 ?70C9=7<72??87/1 CD* @4BB->7 ()7)7   7 7 7)(:7 1 +7 7 ?70CB;+"7<720-87/1 )(( '7(,.(7 7 77(%)77)7 (  1 %% 16%&1 1 -.( 7 7 ?70CB;7<723787/1 ')7 7 >7 --) 7 7) 7 1! 1 1 - ) 7) 7()7  (77$)77 $7)74<4B* :747- 7 (  1 ( & 1&&1 1 D0D7)7 7- (7,7>7 .< ()7 7-  7 < 2<)(7- ) 7( <  (7 7)7- (7-)(7@7 --7 7,)((7 ( 74*7 7 7)(7 >7F 7 7F>7  )-71/ '7  "-)(37 7 7 ($(7 7"7) 7#<  (7( 7 7 727 7/ '7) () 7 ')>71  "# 7  (>7  <  ))7 7( ) 7 +7 7 ?70C=B+"7<720787/1  () 7 7-)%77 )(7 7 7) ()< DBB-67 -7. ) >7/ 7 1  7 7)7 7 7 ).(7 ')>7 )7 77 ')7) () 7 7 <  ) 7 (?7;<0B* >7 ?794,;4-->7 @ 7 ))>7 7! 724,24-->7 ' 7      +7 7 ?70C4;+"7<72?+87/1 .7 >7#( 7 7C;DB7 >7  -.( 7 7 ?70C4;7<72++87/1 +7 7 ?70C24+"7<72<787/1 /7)$7)7' 7)7 7( '7 7# 7) 7 7 -.( 7 7 ?70C247<72?087/1 "7 )-->7 - (7)7) 7 6 &%1 11 %% 1,!?.1   )(7C;DB7 7<72+87/1 &1  -) 7)$)().(7 -7 7'.7>7   (77  7 7 1     - 7 -- 7 7 %%1  1-6 & %1#1 ( 1 -;6 1* 1 1" 1, -;*.12<-87/1 -  71) 7 7 7 )< <<>7 7 >7 <5' 1$ 1 %1,#7 -)7 7  & 91 &%1, --<.12+87/1:1#1 7 ') 7) 7< ()7()7  >7)7 , 0--.12?87/1 $7  >7"7 7 72B->7& 7 7C47",E7)7 1 )7 7  (77 -7 ((77 7 ((7 7 .7()7.7 7,71%7< 1 7. 7  >7"7  7) 7  7 ( 7 7",7. 7- 7)$)(< #1=1 &%11 1&(( 1 )7  (( 7 7)7(7  ->7 ).(7 ))(3>727 ) 77E>7,?7 7 &@)(7  >7 ) 7).(7 7 '7-)(7.( %7 7  >7 99,;4--:7CD* @5-71) .3>7  # >77/ '77 ')>7/ 7 +7 7 ?70C55$D+"7<72??87/1         )7 7  7# 7<77'.7 7 -.( 7 7 ?70C55$D7<72+?87/7 +7 7 ?70C;B+"7<72-787/11  - (7(>7#7 %@&77() 7 7 1 -.( 7 7 ?70C;B7<72/787/1 (  >7 (?7C57  11 1 %% 1,<;;':38/.1 1 +7 7 ?70C2=+"7<72-787/1  (77  7 7  1 %  1 %&1$ 7 -.( 7 7 ?70C2=7<72/787/1 )(- 7)7 -- 7 )((7 7  7 -< 7  7-  7) 7 7 7 .7 7)7"7 #1>%%6%&>1 1&(( 1 CBB*@9>4>7 (7' 7  7 -7)'7 &7# 7  )--7 7)((7 - () 7  7 7 77' ( 7) 7< A()E7 $>7 7,)(7 -),- -7-  7  7 - (7 7 @ 7)7 '7 (7-)%77 (7 )7)((7  >7 (?747 ,7 ( >7 7727()7)7 < ).(>7 ( 7'7. ,7) 7 - 71--3?75B/,CBB,5B >7  >7&7).(7 7)'  :7< / '7 ')>7#7 %7 +7 7 ?70B59+"7<72<387/1 ")- :77 7':7  7 )< 7) 7 ) 7&7() 7 7(  >1 -.( 7 7 ?70B597<72?-87/7  % >7#( 7 ()7)>7 7"7) < -.( 7 7 ?70CD;7<72-787/1  $ >7C0B,CCB,0B-->7 '?7CD* >7 1             +7 7 ?70C2B+"7<723-87/1  1$ ) 11%%1& 11 1=1 1          -.( 7 7 ?70C2B7<725787/1 &(( 1& 1 ! % ( 1%81

 7

              Single Lithium Cell Charger

Steffen Graf (Germany) the input voltage should be no greater than sense the temperature of the lithium cell and 5.3 V to ensure that the maximum allowable which is wired in parallel with R3 via connec- Using the BQ24002 from Texas Instruments it power dissipation of the IC is not exceeded. tor K2. Pin 12 (CR) carries a reference voltage is possible to build a simple and small charger With a charge current of 0.5 A (R1 = 0.2 Ω), the of 2.85 V; so that charging is possible under module for single lithium-ion (Li-ion) cells. maximum allowable input voltage is 7.6 V. normal conditions the thermistor and the The device is available in a SSOP20 package The circuit offers a charge time limit and cell voltage divider of which it forms a part must and so does not require heroic assembly and temperature monitoring. The charge time be dimensioned so that the voltage on pin 7 soldering skills. limit is set using JP2. If the jumper is not fitted lies within the comparator’s voltage window charging will always stop within three hours, when the cell is running at a safe tempera- Individual cells are becoming available from even if the cell has not reached its final volt- ture. The values shown for R2 and R3 will the main catalogue suppliers, but a much age. If the jumper is fitted to pull pin 13 to VCC allow charging as long as the resistance of cheaper option is to rescue cells from defunct notebook batteries. In most cases only a couple of cells are faulty and the others can R4 R5

C2 500R 500R

100n Characteristics D1 D2 4 • Designed for a single Li-ion cell VCC 14 • Suitable for all lithium chemistry cells with a STAT1 8 15 final voltage of 4.1 V or 4.2 V (lithium-cobalt, EN STAT2 IC1 lithium-manganese and lithium-polymer) 2 19 R1 IN OUT DC+ 3 18 PACK+ • Configurable 4.1 V or 4.2 V final voltage 0R1 IN OUT 5 17 1W ISNS VSENSE JP2 • Input voltage from 4.5 V to 10 V (depending on 3h* BATTERY JP1 9 13 4h5 charge current) VSEL TMR SEL BT1 4V2 C5 6h • Charge current up to 1.2 A K1 bq24002PWP K2 4V1 1 12 10p • Charge current configurable via shunt resistor NC CR C1 6 R2 C4 • Linear regulator topology 5VDC NC 11 NC * 10u 1u 20 18k7 • Precharge function for deeply-discharged cells NC 7 TEMP • Charge status indicated by two LEDs APG/THM R3 GND AGND - • Two package options: SSOP20 or QFN C3 Θ * 10 16 * NTC 95k3 220n

DC– PACK– 080286 - 11 still look forward to a long and useful life. A single cell is ideal for any equipment that needs a 3.3 V power supply, and will gener- (the supply voltage) the time limit is four and the thermistor lies between 4.8 kΩ (upper ally give a good operating life. The charger a half hours, and if pin 13 is pulled to ground temperature limit) and 26.6 kΩ (lower tem- circuit requires a 5 V input, which can readily the time limit is six hours. If the final voltage perature limit). Using a typical 10 kΩ thermis- be obtained from a USB port or from any 5 V is reached early, charging will of course cease tor (such as the Vishay 2381 640 63103) this power supply. before expiry of the time limit. The LEDs allow means that charging will occur as long as the The charge process begins with a trickle the charge process to be monitored. Red LED cell temperature is between approximately charge current. When the cell terminal volt- D1 lights during charging and flashes to indi- 5 °C and approximately 43 °C. A 12 kΩ ther- age is sufficiently high the charger switches cate that a fault has been detected. When the mistor from the same series gives an upper to a higher constant charge current. Charging cell is more than 90 % charged the red LED is limit of 48 °C: this is the arrangement used in is terminated when the cell voltage reaches a extinguished and the green LED lights. Texas Instruments’ evaluation module [1]. preset limit (the ‘final voltage’). The charger Pin 7 (APG/THM) is the input to a window described here is suitable for cells with a final comparator with a lower threshold of 0.56 V Formulae are given in the datasheet [2] to voltage of 4.1 V or 4.2 V, configured using and an upper threshold of 1.5 V. If the volt- help with the calculation of component jumper JP1: pin 9 is taken to ground to select age on this pin is over 1.5 V or below 0.56 V values in the voltage divider. Alternatively,

4.1 V or to VCC to select 4.2 V. the IC regards this as a fault and aborts the the TempSense Designer software [3] can be charging process. Charging can only occur if used: it offers a graphical user interface and It is important never to exceed the maximum the voltage on the pin lies between the two a number of other features. permissible cell voltage: if in doubt, consult thresholds. The window comparator can be (080286) the manufacturer’s specifications for the used either to monitor the IC’s supply volt- definitive value. age or to monitor the temperature of the lithium cell. In the circuit shown we have Internet Links [1] http://focus.ti.com/lit/ug/sluu113/sluu113.pdf The charge current is determined and moni- used the input in a temperature monitoring [2] http://focus.ti.com/lit/ds/slus462e/slus462e.pdf tored by input shunt resistor R1. A value of configuration: the voltage on pin 7 is deter- [3] http://focus.ti.com/docs/prod/folders/print/ 0.1 Ω gives a charge current IL of 1 A: the gen- mined by a voltage divider comprising R2, R3 bq24002.html eral formula is IL = 0.1 V / R1. In this example, and an NTC thermistor, which is arranged to

110 elektor - 7-8/2009 Long Duration Timer using ATtiny2313

Jürgen Stannieder (Germany) module that uses an HD44780-compatible controller. Note that P1 is used to adjust the This timer circuit is designed to switch on contrast of the LCD: if the display appears a 12 V load in a solar-powered installation blank it is worth checking the contrast set- for a preset period at the press of a button. ting before suspecting a more serious prob- When the period has expired a latching relay lem! If desired, the LCD can be dispensed disconnects both the load and the control- with, along with the corresponding parts of ler circuit from the 12 V supply. The length the source code. of the period can be configured by making The upper line of the LCD shows the total suitable changes to the microcontroller’s time period, in seconds, for which the soft- source code. ware is configured, while the lower line shows the time, in seconds, since the button When button S1 is pressed a voltage appears can also of course be configured by changing was pressed. across relay coil L1, and the relay switches the the software. load on. Since the relay is a latching type, it When the full time interval has elapsed the The screendump shows the LCD settings remains in this state when the button is microcontroller sets an output (pin 7) high, under BASCOM-AVR. The source code for the released. There is now a supply to the 78L05 which triggers the CNY 17-3 optocoupler and program is available for download at [1]. voltage regulator (a low-dropout type such in turn drives relay coil L2. The relay returns to as the LP2950CZ-5.0 may also be used) and its initial state, disconnecting the load as well (080584) the microcontroller is powered up. In the as the controller (which is also powered via Internet link microcontroller the timer program runs until the relay contact) from the 12 V supply. [1] www.elektor.com/080584 the configured time interval has elapsed. The author used a miniature 16-by-2 LCD Around 90 % of the way through the time panel type HMC16223SG in his prototype, period LED D2 lights as a warning that the measuring just 52 mm by 20 mm. It is of Download load will shortly be switched off, and this time course possible to use any standard LCD 080584-11: source code, from www.elektor/080584

LCD1 IC3 +5V 2 x 16 +12V D 78L05 S W VD VO R/ D1 D4 D7 VS RS E D0 D2 D3 D5 D6

1 2 3 4 5 6 7 8 9 10 11 12 13 14

S1 C1 C2

100n 100n

P1 RE1 25k L1 L2 20

1 11 RESET PD6 12V 2A IC2 12 PB0 13 PB1 2 14 +12V* PD0 PB2 3 15 PD1 PB3 6 16 PD2 PB4 7 17 PD3 PB5 R1 8 18 PD4 PB6 9 19 PD5 PB7

330R R2 ATTiny2313 IC4 XO XI 5 6 1

330R 4 5 10 X1

4 2 D2 C4 C3 D1

33p 33p 1N4148

CNY17-3 TIMER 90% X1 = 3.6864MHz 080584 - 11

7-8/2009 - elektor 111 Quartz Crystal Tester

Christian Tavernier (France) we have suggested for you [1],

+9V or on a piece of prototyping Although most passive com- board (perfboard, +9V R1 ponents are usually fairly easy LED1 etc.). In either case, it is essen- to test, the proper function- tial for the base material to 22k ing of a quartz crystal cannot T1 be fibreglass and not paxolin, R3 be checked using any stand- CN1 because of the high frequen- Ω

ard measuring instrument. 680 cies that may be involved. BF494 A quartz crystal is actually a C1 To achieve the connection to T2 C3 D1 very simple device in princi- X1 1n C5 the crystal to be tested, two ple, since all it consists of is HC6/U and HC18/U sockets 2n2 1N4148 100n a slice of quartz, accurately R2 BC547 can be soldered in parallel to cut, of course, held between C2 D2 C4 accommodate crystals using 1k two metal electrodes, or with 100p 10n these pin-out formats. Crystals metallic contacts deposited on CN2 M that have wire leadouts can 1N4148 it to serve the same purpose. 081178 - 11 easily be connected to one or But sadly, owing to its being other of these two sockets. made like this, an ohmmeter or capacitance meter will not The power supply is provided measure anything across a crystal, since it will it was made, or one of its harmonics (see by a source of 9 V. A simple 9 V PP3 battery is have a resistance of several megohms (MΩ) below). If it’s important for you to measure ideal, given the circuit’s low power consump- and a stray capacitance of only a few picofar- this frequency, you can connect a frequency tion and above all the fact that it’s only ever ads (pF) — regardless of whether it’s working used for a relatively short time. or not. So the only solution available to us is to fit the crystal into a circuit, i.e. an oscilla- As previously explained, the circuit works tor, and see if it oscillates or not. This is just for any crystal with a frequency between 1 what our tester does — and at a ridiculously 1 178- 081 and 50 MHz — i.e. virtually all the crystals on low cost. the market. It’s important to appreciate that, even though you do find crystals marked with As the frequencies of the crystals we deal frequencies higher than 50 MHz, they rarely with may cover a very wide range — the vast actually operate directly at this frequency, majority of them will be typically between which is in fact the harmonic frequency to 1 MHz and 50 MHz — we need to build an which the oscillator in which they are fit- oscillator that will be capable of working ted needs to be tuned. So their fundamen- over a very wide frequency range. This task tal oscillating frequency is in fact normally is given to transistor T1, which is arranged as meter or oscilloscope across resistor R2. below 50 MHz, by a ratio of 2 or 3, depend- an aperiodic oscillator — i.e. it is not tuned to The circuit itself is very simply and can be ing on which harmonic (or overtone) is to any particular frequency. If you are familiar built on the little dedicated PCB whose design be used. The reason for this curious way of with this type of oscillator circuit, you’ll note going about things lies in the manufacturing that the feedback capacitor C1 has an unusu- technology for these devices, which requires ally high value, which enables this circuit to COMPONENT LIST the slice of quartz to be finer and finer as cope with almost any type of crystal with a the actual operating frequency (or ‘funda- frequency between 1 and 50 MHz. Resistors mental frequency’) is increased. And so, if R1 = 22kΩ R2 = 1 Ω they try and go too high with direct oscilla- So if the crystal is good enough, a pseudo- R3 = 880Ω tion at the fundamental frequency, the slice sinewave signal at the crystal’s fundamental becomes so fragile that it may break all of its frequency will be present at the emitter of Capacitors own accord. T1. This signal is rectified by D2 and charges C1 = 1nF (081178-I) C2 = 100pF capacitor C4 via D1. As soon as the voltage C3 = 2nF2 across this reaches a high enough value, tran- C4 = 10nF Internet Link sistor T2 turns on and lights the LED in its col- C5 = 100nF [1] www.elektor.com/081178 lector circuit, thereby indicating that the crys- tal is usable. Semiconductors D1, D2 = 1N4148 T1 = BF494 Download Clearly, because of its operating principle, this T2 = BC547 PCB circuit doesn’t let us check the actual operat- LED1 = LED 081178-1: PCB layout (.pdf), from [1] ing frequency of the crystal, but experience shows that, when a crystal is faulty, it will fail Miscellaneous to oscillate at all, but that when it does oscil- Socket for HC6/U and/or HC 18/U type xtal late, it will do so at the frequency for which

elektor - 7-8/2009 Prototype & small series PCB specialists

New PCB prototype service Instant online pricing and ordering - 2 boards in 2, 3 or 5 days - No tooling charge Low order-pooling prices - 1–8 layers - Low PCB-Proto prices Full options service On demand - 1-16 layers E.g. 2 x 100 x 80 mm: 2 layers 38.12€ each* Deliveries from 2 days 4 layers 77.23€ each* Stencil service - Immediate online ordering - No minimum order charge

Call us: 020 8816 7005 Email: [email protected] *excluding transport and VAT www.eurocircuits.com

Elektor SMT Oven

Multi-purpose and indispensable SMT Starter Kit andg 115 voucher to professional and enthusiast worth £100/ TOTALLY FREE • Selected, tested & certifi ed by Elektor with your oven! • Including Elektor-produced user manual

• Fully menu controlled Art. # 080663-91 • Price: £962.00 • € 1195.00 • US $1665.00 (Excl. VAT) • SMT Expert Tip: Double-sided Soldering

• Demovideos available on the Elektor website Main technical specifi cations • Ideal for R&D laboratories, schools, small companies and… Line voltage: 230 VAC / 1650 W electronics enthusiasts Line frequency: 50-60 Hz • Product support from Elektor Customer Services Size: 418 x 372 x 250 mm (16.5 x 14.6 x 10 inch) Weight: 16.7 kg (net) Effective PCB area: 280 x 280 mm (11 x 11 inch)

Further informationmation and ordering at www.elektor.com/smtoven

7-8/2009 - elektor 113

0907_elektor_adv_UK.indd 113 05-06-2009 13:28:12 Improved Hybrid HeadPhone Amplifier

Tuck Choy, PhD (Singapore)

Jeff Macaulay’s excellent single valve ECC82/ 12AU7 ‘Hybrid Headphone Amp’ (HHA) pub- lished in [1] spurred the author to implement some modifications culminating mainly in an additional input preamp. The resulting project was then slightly reworked in the Elektor Audio Labs and the result is shown here, along with a PCB design to Elektor standards.

Specifications • Warm up time: min. 30 minutes • Load impedance: 33 Ω • Supply voltage: 12.1 VDC • Current consumption: 235 mA • Gain (33 Ω load): 4.5 • Max. output voltage: 730 mV (THD = 3%, clipping audible) • THD + N: 0.13 % (1 mW/1 kHz/B = 80 kHz) • S/N: 87 dB (ref. 1 mW, B = 22 kHz) • Bandwidth: 17 Hz – 3.5 MHz (at 1 mW) • Output impedance: 2 Ω • DC output voltage: 1 mV (33 Ω load) 3 mV (150 Ω load)

1 D2

R7 1N4004 k

T5 39 T4 12V C5 BC517 BD139 1000u 25V

R18 R6 R4 R12 R14 R24 C11 C2 C7 C13 k k 1k 1k 91 91 560R T10 T12 560R 100u 100n 100n 100u 25V 25V 6 C1 1 C6 BC550C BC550C 2u2 2u2 T3 T8 C10 2 7 C12 3 8

10u R16 R1 R22 10u BC517 D1 R9 D3 BC517 k k 1k 1k

R 10 10 L T9 T2 4 9 5 T7 T11 C4 C9 V1 BC550C BC550C 2200u T1 ECC82 T6 2200u R20 25V R26 25V 12AU7 8k06 8k06 R17 R21 R5 R2 R3 R11 R10 R13 R27 R23 C3 C8 R k k k k R 1k 1k 22 91 15 15 91 22 560R 560R 100u 25V 25V 100u

2x BC550C 2x BC550C R19 R8 R15 R25 33k 10k 10k 33k

R L 080310 - 11

114 elektor - 7-8/2009 The original HHA was designed for line inputs the Specifications listed here were obtained from the project webpage. You’ll notice that of the order of 1 Vrms and an output imped- with feedback in place. Without feedback, the solder side of the board has large copper ance of about 35 ohms. Unfortunately there the outputs carry no direct voltage. The fill areas to maximise the ground plane sur- do not seem to be hard and fast international negative feedback feature was found quite face, which helps to keep noise and all sorts standards for headphone output levels or useful such as with the AKG K701 to further of interference down to a minimum. The impedances. Higher end headphones such boost performance, but this is a rather sub- valve socket has a rather spacious footprint as the AKG type K601 (impedance 125 ohms) jective feature you might like to experiment as well as large holes to allow sockets from and K701 (impedance 62 ohms), coupled a hi- with for yourself. Capacitor C1 (C6) gives the different suppliers to be used. fi preamplifier system like the author’s Rega circuit a reasonable specification for its low- (080310-I)

Mira (which supplies only 600 mVrms out) frequency roll-off. resulted in a compromised dynamic range and low loudness performance especially In the prototype of the amplifier, the ECC82/ on older CD recordings. 12AU7 required about 15 minutes of warming

Initial experiments with modifying the BC517 2 Darlington output of the HHA were rather unsuccessful. The low anode current from the valve requires this specialized gain stage and any efforts to boost the output seems to modify the system from a valve based amplifier into a transistor one and the result- ing audio performance was also not encour- aging. The main problem with the original HHA is both its strength and weakness, as the unity-gain valve cathode follower does not offer any voltage gain in the first place. The low noise and distortion due to the valve is no doubt offered by its low anode voltage and hence low noise and distortion characteristics.

Referring to the circuit diagram in Figure 1 a

Measurement data 8.5 mm max. Component List C4,C9 = 2200µF 25V, lead pitch 7.5mm, diam. 18mm Voltages measured w.r.t. circuit ground max. T1/T6 base 0.7 V Resistors C5 = 1000 µF 25V, lead pitch 5mm, diam. 10 mm R1,R8,R9,R15 = 10kΩ max. T2/T7 base 1.4 V R2,R4,R10,R12 = 91kΩ (E96: 90kΩ9) T3/T8 base 3.8 V R3,R11 = 15kΩ Semiconductors R5,R13 = 22Ω D1,D3 = red LED T3/T8 Emitter 2.8 V R6,R14,R16,R17,R22,R23 = 1kΩ D2 = 1N4004 R7 = 39kΩ ECC82 grid 4 V T1,T2,T6,T7,T9,T10,T11,T12 = BC550C R18,R21,R24,R27 = 560Ω T3,T5,T8 = BC517 T10/T12 Emitter 6.2 V R19,R25 = 33kΩ T4 = BD139 R20,R26 = 8kΩ06 T9/T11Base 0.67 V Miscellaneous ECC82 anodes 10 V Capacitors V1 = ECC82 or 12AU7 C1,C6 = 2µF2 100V, lead pitch 22.5mm (WxL = 10 x ECC82 pin 5 9.4 V 9-pin (‘Noval’) PCB mount socket, e.g. Conrad 26 mm abs. max.) Electronics # 120529 D2 (across device) 0.8 V C10,C12 = 10µF 63V, lead pitch 22.5mm (WxL = 10 x PCB, # 080310-1 from www.thepcbshop.com 26 mm abs. max.) T5 VCE 1.3 V C2,C7 = 100nF, MKT, lead pitch 5mm or 7.5mm R6/R14 (across device) 6.85 V C3,C8,C11,C13 = 100µF 25V, lead pitch 2.5mm, diam. stereo amp is shown, as opposed to a mono- up before normal operation was obtained. block for the original HHA. The hunt for a This is due to the relatively low heater volt- Reference suitable input voltage amplifier to slightly age of about 9.4 V from the BD139 series [1] Hybrid Headphone Amp, Elektor July & August 2006; www.elektor.com/050347 boost the voltage gain resulted in the use pass element. The functions of T5/C5 and T4 of a dual BC550C inverting shunt feedback are explained in some depth in the original amplifier with a voltage gain of about 8. article. Downloads & Products Being an inverting amplifier it conveniently PCB design allows some negative feedback (about 3%) to The single-sided circuit board design shown No. 080310-1 (.pdf) at www.elektor.com/080310 be introduced using 33 kΩ resistor R19 (R25). in Figure 2 allows a stereo amplifier to be The feedback causes a direct voltage of a built. The copper track layout for making your few millivolts at the amplifier outputs, and own PCB can be downloaded free of charge

7-8/2009 - elektor 115 Braitenberg Robot

Abraham Vreugdenhil (The The program, written by the Netherlands) author for this purpose, can be downloaded from the Ele- In 1984 Valentino Braitenberg ktor website [1]. A general published a nice demonstra- overview of what the pro- tion to show the behaviour of gram does is given here. After robots. The question is: what it starts up it first waits for a IS behaviour or what do we second in the INIT routine. If a THINK behaviour is. This dem- bumper is pushed during this onstration uses simple robotic time, the light seeking behav- vehicles, each of which con- iour is activated. If the bumper tains a very simple program. is not pushed then the behav- Each robotic vehicle has two iour will be light avoiding. driven wheels and two light After a short beep it waits to sensors at the front. These check whether the number sensors look towards the front and each drive ago the company Arexx [2] introduced a trim of the robot has be changed or not. This is a motor. The robots also have a bumper to robot construction kit onto the market, the done by pushing the bumper a number of sense whether they have hit anything. This Asuro. This robot is available from Conrad times. If not, the EEPROM is checked to see if can be either a wall or another robot. Now, in Electronics [3], among others. The Asuro con- it already contains a number. If a valid entry the simplest form of the robotic vehicle, the tains an Atmel ATmega processor with a built- is found then that number will be used, oth- left front light sensor is connected with the in hex loader. You can write programs for the erwise the number 10 is used. The main loop right rear wheel. Likewise the right front light Asuro in C or (simpler) in Bascom [4]. Using an consists of three parts: a bumper part (A), a sensor is connected to the left rear wheel. If IR interface (with the supplied RS232 IR trans- light avoiding/seeking part (B) and a random we now place the robotic vehicle in a space ceiver) the hex program can be sent to the component (C). with a light source, the robotic vehicle will Asuro. A USB IR transceiver is also available. move towards the light source. The program is written in Bascom AVR. For The Asuro also has an experimenting board more information refer to the program list- There are, however, also vehicles where the available. Here the board is used for three ing (download # 090348-11). The Bascom AVR left front sensor is connected to the left purposes. You connect two bumper sup- generated hex file is transferred to the Asuro rear wheel and the right front sensor to the ports, mount two light sensors and finally add using the Flash.exe program supplied with right rear wheel. Such a robotic vehicle will a piezo-element (according to Figure 1). For the Asuro. You can then start again, deter- avoid a light source instead. Now, suppose the light sensors on the experimenting board mine the behaviour by pushing the bumper, you have multiple light sources which are you use the two IR diodes normally mounted followed by entering a number by pushing repeatedly turned on and off, as well as mul- underneath the Asuro (these are T9 and T10). the bumper a few times and the Braitenberg- tiple robotic vehicles with different behav- Fit these with a little plastic tube. Vehicle is on its way. Get ready for long dis- iours, what will happen? You will first see cussions on what these robots are doing and that all the light seekers go towards the light On the expansion board you use the con- what behaviour is taking place. source and all the light avoiders move away. nections for the red LED D11 to connect the When the light sources subsequently move, piezo element. To distinguish between the To produce the random light changes on the all the robots will spring into action and this different robotic vehicles you give each a dif- playing field, the author designed a circuit results in new activity. If you’re an outsider ferent colour by wrapping the battery com- with a 98C2051 and a few solid-state relays, or you do not know in advance what sort of partment in paper of different colours. You which ensures that four incandescent lamps program is contained in the robotic vehicles, can also give each robotic vehicle an unique at the side of the playing field light up in dif- then it is nice to discuss what is happening number internally. While driving around the ferent combinations every 25 seconds. This here. People have the tendency to attribute robots can continuously transmit their behav- effect ensures that the robotic vehicles will various kinds of human behaviour to certain continue to search and avoid. devices and robots. This one is ‘aggressive’, (090348-I) C12 the other ‘evasive’ or passive. Whole discus- PD.6 R29 47Ω sions are started based on a few robotic vehi- 10µ 16V cles driving around with each ultimately con- BZ1 taining a very simple program. Perhaps this Internet Links says more about the method of thinking or [1] www.elektor.com/090348 the behaviour of the spectators then it does [2] www.arexx.com about the behaviour of the robotic vehicles 090348 - 11 [3] www.conrad-int.com themselves. [4] www.mcselec.com

How can this experiment be repeated in a iour, i.e. decisions via the IR transceiver. If you simple way? You need a number of small and mount an IR transceiver above the ‘playing Download cheap robots that can easily be programmed field’ you can follow everything the robots Software and changed to suit your needs. A few years ‘do’ on the computer. 090348-11: Bascom and hex file, from [1]

116 elektor - 7-8/2009 Demo video at Profi ler Pro www.elektor.com/profi lerpro Order now: New processor board, increased software 3D controller-board (assembled and tested) capabilities and mechanical upgrades £339.00 / US $494.00 / e 380.00 incl. ColiDrive en ColiLiner update Upgrade your Profi ler to a PRO milling New Z-axis with fl oating head machine with: (assembled) New 3D controller £404.00 / US $590.00 / e 454.00 Requested by many and now Professional grade engraving head available! £263.00 / US $384.00 / e 295.00

ColiDrive Prices include VAT, The control software has been exclude postage and packing. expanded with quite a few new options. Elektor New Z-axis with fl oating head Regus Brentford 1000 Great West Road More stable and easier to mount and calibrate. Brentford TW8 9HH Professional engraving head United Kingdom With this head the milling depth Tel. +44 20 8261 4509 can be set very accurately!

More information, demo video and ordering at www.elektor.com/profi lerpro

Elektor’s Components

Database 5 More than Completely updated 69,000 components NEW! The program package consists of eight databanks covering ICs, transistors, diodes and optocouplers. A further eleven applications cover the calculation of, for example, zener diode series resistors, voltage regulators, voltage dividers and AMV’s. A colour band decoder is included for determining resistor and inductor values. Each databank contains ISBN 978-90-5381-159-7 the following on (almost) any component: enclosure drawing, pin connections, tech- £24.90 • US $39.50 nical data (as far as known). Also included is a search engine acting on user supplied parameters. The ECD gives you easy access to design data for over 5,400 ICs, more than Elektor Regus Brentford 35,800 transistors, FETs, thyristors and triacs, just under 25,000 diodes and 1,800 opto- 1000 Great West Road couplers. All databank applications are fully interactive, allowing the user to add, Brentford TW8 9HH edit and complete component data. This CD-ROM is United Kingdom a must-have for all electronics enthusiasts! Tel. +44 20 8261 4509

Further information and ordering at www.elektor.com/shop

7-8/2009 - elektor 117

0907_elektor_adv_UK.indd 117 05-06-2009 13:28:23 An E-Blocks IR RC5 Decoder

José Basilio Carvalho (Portugal) 1 10 = SAT, 11 = Hi-Fi. +5V The program was designed with Flow-

The infrared (IR) decoder described here R1 R2 R6 code, the graphical software design util- was designed to enable an E-Blocks ity for E-blocks. A part of it is shown in 100k 100k development system [1] to process com- 100R Figure 2. The resulting .fcf file is availa- mands from RC5 (compatible) remote ble free of charge from the Elektor web- controls typically used for Philips audio/ C1 site [2]. IC1 video equipment. The E-blocks comple- 47u 16V The main flowchart allocates the LC dis- K1 2 ment consists of R3 play to PORTA, initialises ports, reads the 1 3 22k 6 state of bits 6 and 7 into variable ‘mode’, 1 x PICmicro USB Multiprogrammer EB- 2 enables RB0/INT interrupts and starts a R4 1 7 006 with 4 MHz xtal; 100R TSOP1736 loop. 3 1 x EB-007 (8 push to make switches) con- R5 A 1 to 0 transition on the RB0/INT pin will 8 100R TSOP1736 nected to PORTC; 4 call the ‘start’ macro, which is only used to 1 x EB-005 imitation LCD board (16x4) con- 9 set a variable and call the ‘ir_dec’ macro. nected to PORTA; 5 Inside the ‘ir_dec’ macro, some delays are S2 S1 1 x EB-004 LED board or 8-Relay board present to read RB0 near the end of the S1 connected to PORTD; SUB-D9 1 3 bit, as well as during the start and second

1 x EB-004 LED board connected to 2 half of the S2 bit. If they are ‘010’, the sig- PORTE (or just one LED and a 470 Ω resis- 080996 - 11 nal is recognised as coming from a valid tor on RE1). RC5 remote control. Some more delays effectively skip the toggle bit (not used The original EB-005 E-Block has a 16x2 here) and start to read the five address LCD. For the purpose of this project, an 2 bits and six command bits into the ‘adr’ EB-005 was reverse-engineered and rep- and ‘cmd’ variables respectively. Dur- licated on prototyping board and wired ing the ‘ir_dec’ macro, 14 300-µs pulses to accommodate a 4x16 LCD. The home are generated on the RE0 pin to enable made board has a SIL socket strip that also an oscilloscope to show detailed timing accepts 16x1 and 16x2 LCDs, all of which of the RC5 preamble and address/com- were found to be pin compatible. Photos mand bits. of the author’s DYI EB-005 are available at [2]. The proposed IR decoder board is After a successful IR decoding, the ‘ir_dec’ connected to PORTB. macro calls the ‘output’ macro. Inside the Once fully debugged and tested in terms ‘output’ macro the display shows address of hardware and software, an E-blocks and command values in decimal notation, system may be ‘undressed’ and replicated compares ‘adr’ and ‘mode’ variables to as a stand-alone circuit with just the basic 3 validate the device mode used, and sends elements and running firmware. In most the value of the ‘cmd’ variable to PORTD, cases, the circuit boils down to no more displaying the output state in binary. than a (PIC) micro with some I/O devices A blinking LED on the RE1 pin reveals around it like switches, sensors, relays the activity of any non-RC5 remote con- and LEDs. If changes or extensions are trols (like Sony, Panasonic, etc.). The main required, you build up the E-blocks con- loop also calls the ‘sw_key’ macro to read stellation again, do whatever is neces- PORTC switches to control the PORTD sary to get it all to work, save the new .fcf outputs manually. and make the system blow a fresh PIC for (080996-I) inserting into the stand-alone system. Here the PIC16F877microcontroller runs at 4 MHz to decode signals matching the Internet Links [1] www.elektor.com/eblocks Philips RC5 protocol. The complete E-Blocks eight bits of PORTD individually, switching on [2] www.elektor.com/080996 layout can be used to test remote controls or off any AC or DC devices by way of an 8- with suspected faults, and to switch 8 devices way relay board or similar. The Standby key using a ‘known good’ control. The address is used to switch all eight outputs on and off. Downloads and command decimal values appear on a There are also eight push-to-make switches Software 16x4 LCD display. The decoder proper (Fig- to manually toggle the state of any output. 080996-11.zip: Flowcode (.fcf) file, from www.elektor. ure 1) is just a standard application circuit of By pressing switch 1 and 2 at the same time com/080996 the TSOP1736 IR decoder IC with some com- you switch all outputs on or off. The state of Supplementary Information ponents around it for connectivity with the E- the outputs is shown on the LC display. Bits 6 080996-12.zip: Photos of DIY EB-005, from www.ele- blocks PORTA (based on sub-D connectors). and 7 of PORTB are used to select the address ktor.com/080996 Keys 1 to 8 of the remote are used to control mode of the output control; 00 =TV, 01 = VCR,

118 elektor - 7-8/2009 Photo: Siegfried Springer / PIXELIO Photo: Things of the past

Elektor is now & tomorrow

Secure a head start in electronics with a subscription!

Advantages to subscribers

Cheaper than 11 issues from the newsstand

With every issue subscribers get up to 40% discount FREE 3-in-1 welcome on selected Elektor products gift: 2GB MP3 player, USB Stick and As a welcome gift you get a free 2GB MP3 player Voice Recorder worth £31.50 + No queues, travelling, parking fees or ‘sold out’ Elektor is supplied to your doorstep every month Always up to date – read your copy before everyone else PLA-UK-1

www.elektor.com/subs · Tel. +44 (0) 20 8261 4509 electronics worldwide Or use the subscription order form near the end of the magazine.

0907_elektor_adv_UK.indd 119 05-06-2009 13:28:35 Remote Control for Network Devices

Werner Rabl (Germany)

Many devices connected to a local area net- R4 work (LAN) are left on continuously, even 33k T1 when they are not needed, including DSL R2 R3 and cable modems, routers, wireless access R1 100 Ω 680 Ω 330 points, networked hard drives, printer serv- Ω BC557 IC1 1 4 V1 ers and printers. The power consumption of D1 RE1 all these devices can add up to a considerable 60 fraction of one’s electricity bill. With the sim- Ω 5V ple circuit described here we can ensure that 2 3 1N4148 PC817A all these devices are only powered up when at least one selected host device (such as a PC or a streaming media client) is turned on. R8 We insert a relay in the mains supply to the devices whose power is to be switched, along 33k T2 R6 R7 with a driver circuit controlled from the host R5 100 Ω 680 Ω device over a two-wire bus. Optocouplers 330 Ω BC557 IC2 provide galvanic isolation. One way to imple- 1 4 V2 ment the bus is to use the spare pair of con- D2 RE2 ductors that is often available in the existing 60Ω LAN cable. 5V 2 3 1N4148 PC817A The circuit diagram shows an example con- figuration where there are two controlling host devices (a streaming media client and a R12 PC) and three network devices (a DSL router, 33k T3 a networked hard drive and a networked R10 R11 printer). We will assume that all the media R9 100 Ω 680 Ω 330 Ω files are held on the networked hard drive. BC557 IC3 1 4 The DSL router (to provide an internet con- D3 RE3 nection) and the hard drive are to be pow- ered up when either the PC or the media cli- 60Ω ent is powered up; the printer only when the 2 3 1N4148 PC817A PC is powered up. 090096 - 11 We can think of the devices as being in two groups, the first group consisting of the DSL router and the hard drive, the second just the printer. An optocoupler is powered from each Optocoupler IC3 controls the networked provide both voltages. Another possibility of the controlling host devices: these ensure device in group 2, namely the printer. This is would be to add a third wire to the bus to that the devices are isolated from one another switched by relay RE3. carry power: this would allow all relays, wher- and from the rest of the circuit. The relay cir- ever they were located, to be powered from cuit, located close to the networked devices, The connections between the optocouplers a single supply. is controlled from the outputs of the opto- and the relay stages can be thought of as a couplers. The relay circuits are powered from kind of bus for each group of devices. The It is worth noting that network attached stor- (efficient) mains adaptors: modified mobile devices in a given group can be switched on age (NAS) devices such as networked hard phone chargers do an admirable job. by simply shorting its bus, and this gives an drives normally require an orderly shutdown easy way to test the set-up. Resistors R2, R6 process before power is removed. Devices In the circuit shown a 5 V supply from the and R10 at the collectors of the transistors in that use Ximeta’s NDAS technology do not controlling devices is used to drive each opto- the optocouplers protect them in case power suffer from this problem. coupler. Host 1 (the streaming client) drives should accidentally be applied to the bus. optocoupler IC1, host 2 (the PC) drives opto- (090096-I) couplers IC2 and IC3. The supply voltages V1 and V2 shown in the example circuit diagram are derived from the Optocouplers IC1 and IC2 both control the mains adaptors as mentioned above and are networked devices in group 1: networked used to power the relays. We have assumed device 1 is the DSL router, switched by relay that the networked hard drive and the printer RE1, and networked device 2 is the hard drive, are located near to one another, and so it is switched by relay RE2. possible to use a single mains adaptor to

120 elektor - 7-8/2009 Automatic Bicycle Light

Ludwig Libertin (Austria) made of SMD components. Most of them come in an 0805 pack- This automatic bicycle light age. C2 comes in a so-called makes cycling in the dark much chip version. The board is sin- easier (although you still need gle-sided with the top also act- to pedal of course). The circuit ing as the solder side. takes the ambient light level The print outline for the LDR (R5) into account and only turns on isn’t exactly the same as that of the light when it becomes dark. the outline of the LDR men- The light is turned off when no tioned in the component list. cycling has taken place for over The outline is more a general one a minute or if it becomes light because there is quite a variety again. The biggest advantage of of different LDR packages on the this circuit is that it has no man- market. It is therefore possible ual controls. This way you can to use another type of LDR, if for never ‘forget’ to turn the light example the light threshold isn’t on or off. This makes it ideal for quite right. The LDR may also be children and those of a forgetful mounted on the other side of the disposition. board, but that depends on how the board is mounted inside the To detect when the bicycle is light. used (in other words, when the wheels turn), the circuit uses a For the MOSFET there are also reed switch (S1), mounted on many alternatives available, +3V the frame close to the wheel. such as the FDS6064N3 made A small magnet is fixed to the by Fairchild, the SI4864DY spokes (similar to that used with R1 R2 C3 made by Vishay Siliconix, 1M most bicycle speedometers), 100k 100n the IRF7404 made by IRF or T1 which closes the reed switch C1 R3 the NTMS4N01R2G made by once for every revolution of the BT1 1k ONSEMI. The reed switch also 1u T2 wheel. Whilst the wheel turns, 3V 16V BC807 comes in many different shapes pulses are fed to the base of T1 S1 R4 R6 and sizes; some of them are 100k 1k via C1. This charges a small elec- R5 even waterproof and come with NS STS6NF20V trolytic capacitor (C2). When it is C2 the wires already attached. dark enough and the LDR there- 10u For the supply connection and 16V fore has a high resistance, T2 the connection to the lamp you 090102 - 11 starts conducting and the lamp can either use PCB pins or sol- is turned on. With every revolu- der the wires directly onto the tion of the wheel C2 is charged board. The soldered ends of the up again. The charge in C2 ensures that T2 pins can be shortened slightly so that they keeps conducting for about a minute after don’t stick out from the bottom of the board. the wheel stops turning. Almost any type of This reduces the chance of shorts with any light can be connected to the output of the metal parts of the light. circuit. Do take care when you use a dynamo to With a supply voltage of 3V the quiescent power the circuit — the alternating voltage current when the reed switch is open is just must first be rectified! The same applies to 0.14 μA. When the magnet happens to be in hub dynamos, which often also output an a position such that S1 is closed, alternating voltage. the current is 3 μA. In either case C3 = 100nF (SMD 0805) there is no problem using bat- COMPONENT LIST teries to supply the circuit. The Semiconductors Please Note. Bicycle lighting supply voltage can be anywhere Resistors T1 = BC807 (SMD SOT23) is subject to legal restrictions, from 3 to 12 V, depending on the R1 = 1MΩ (SMD 0805) T2 = STS6NF20V (SMD SO8) traffic laws and, additionally in R2,R4 = 100kΩ (SMD 0805) type of lamp that is connected. R3,R6 = 1kΩ (SMD 0805) some countries, type approval. Since it is likely that the circuit R5 = LDR e.g. FW150 Conrad Miscellaneous (090102-I) S1 = reed switch (not on board) + Electronics # 183547 will be mounted inside a bicy- 2-way right angle pinheader cle light it is important to keep BT1 = 3–12V (see text) an eye on its dimensions. The Capacitors Download C1 = 1µF 16V (SMD 0805) 090102-1 PCB layout (.pdf), from www. board has therefore been kept C2 = 10µF 16V (SMD chip type) elektor.com/090102 very compact and use has been

7-8/2009 - elektor 121 PC Power Saver

Wolfgang Gscheidle (Germany) L This circuit is designed to help minimise the quiescent power consumption of PCs and notebooks, using just our old friend the 555 L TR1 timer and a relay as the main components. The circuit itself dissipates around 0.5 W in oper- ation (that is, when the connected PC is on); R1 B1 3k3 when switched off (with the relay not ener- S1 * gised) the total power draw is precisely zero. R2 D1 A prerequisite for the circuit is a PC or note N C1 C2 C3 C4 D2 RE*1 book with a USB or PS/2 keyboard socket that 10k 230V/18V/0VA5 B50C800 33n 47u 33n 1u (120V/18V/0VA5) 24V is powered only when the PC is on. 50V 12V 16V 0W5 1N4148 The power saver can be used to switch PCs D5* or even whole multi-way exten- sion leads. The unit can be built P1 R4 D3 into an ordinary mains adap- 4 8 100k tor (which must have an earth R 470k 2 TR IC1 pin!) as the photograph of the R3 1N4148 T1 R5 3 author‘s prototype shows. The OUT 22k 10k 7 TLC555 PC is plugged in to the socket +5V R6 R7 DIS 6 at the output of the power saver 470R IC2 1k THR BC546B 1 6 5 unit, and an extra connection CV USB; PS/2 C5 5 1 is made to the control input of C6 C7 C8 10n the unit from a PS/2 (keyboard or 22u 1u 33n GND D4 2 4 mouse) socket or USB port. Only 16V 16V CNY17/3 the 5 V supply line of the interface is 1N4148 080581 - 11 used. When button S1 on the power saver is pressed the unit turns on, and the used to supply power to the device monostable formed by the 555 timer is itself, and the other contact carries triggered via the network composed by all the current for the connected R4 and C7. This drives relay RE1, whose con- PC or for the extension lead to tacts close. The connected PC is now tenta- which the PC and peripherals are tively powered up via the relay for a period connected. determined by P1 (approximately in the range from 5 s to 10 s). mains. There is no need to switch anything Pushbutton S1 must be rated for 230 VAC If, during this interval, the PC fails to indicate else off: just shut down the system and the (US: 120 VAC) operation: this is no place to that it is alive by supplying 5 V from its USB or power saver will take care of the rest. It is also make economies. The coil current for the relay PS/2 connector (that is, if you do not switch possible to leave the machine as it updates its flows through LED D5, which must therefore it on), the monostable period will expire, the software, and the power saver will do its job be a 20 mA type. If a low-current LED is used, relay will drop out and any connected device shortly after the machine shuts down. a 120 Ω resistor can be connected in paral- will be powered down. No further current will Power for the unit itself is obtained using a lel with it to carry the remaining current. be drawn from the supply, and, of course, it simple supply circuit based around a minia- The Fujitsu FTR-F1CL024R relay used in the will not be possible to turn the PC on. When- ture transformer. Alternatively, a 12 V mains author’s prototype has a rated coil current of ever you want to turn the PC on, you must adaptor can be used, as long as a relay with a 16.7 mA. always press the button on the power saver 12 V coil voltage is used for RE1. In his proto- Optocoupler IC2 provides isolation between shortly beforehand. type the author used a relay with a 24 V coil the circuit and the PC, and is protected from If, however, 5 V is delivered by the PC to the connected as shown directly to the positive reverse polarity connection by diode D4. input of optocoupler IC2 before the monos- side of reservoir capacitor C2, the 555 being The power saver should be built into an insu- table times out (which will be the case if the powered from 12 V regulated from that sup- lated enclosure and great care should be PC is switched on during that period), the ply using R1 and D1. A fixed resistor can of taken to ensure that there is proper isolation transistor in the optocoupler will conduct course be used in place of P1 if desired. If the between components and wires carrying the and discharge capacitor C6. The monostable adjustment range of P1 is not sufficient (for mains voltage and the other parts of the cir- will now remain triggered and the relay will example if the PC powers up very slowly) the cuit. In particular, the connection to the PC remain energised until the PC is switched off monostable period can be increased by using and associated components (R6, C5, D4 and and power disappears from its USB or PS/2 a larger capacitor at C6. IC2) should be carefully arranged with at least interface. Then, after the monostable time The relay must have at least two normally- a 6 mm gap between them and any part of period expires, the relay will drop out and the open (or changeover) contacts rated at at the circuit at mains potential. power saver will disconnect itself from the least 8 A. The contact in parallel with S1 is (080581-I)

122 elektor - 7-8/2009 DVD LED Toolbox More than 100 Elektor articles included!

This DVD-ROM contains carefully-sorted comprehensive technical documentation (optical properties, electrical characteristics, mounting, life expectancy, etc.) about and around LEDs. For standard models (through-hole, SMD), and for a selection of NEW! LED modules (ribbons, light bars, bargraphs, and other LED clusters), this DVD gathers together data sheets from all the manufacturers, application notes, design ISBN 978-90-5381-245-7 £28.50 • US $54.00 guides, white papers and so on. It offers several hundred drivers for powering and

controlling LEDs in different confi gurations (buck, boost, charge pump, constant Elektor Regus Brentford current, and so on), along with ready-to-use modules (power supply units, DMX 1000 Great West Road controllers, dimmers, etc.). In addition to optical systems, light Brentford TW8 9HH United Kingdom detectors, hardware, etc., this DVD also addresses the main Tel. +44 20 8261 4509 shortcoming of power LEDs: heating. Further information and ordering at www.elektor.com/shop

INDEX OF ADVERTISERS

Allendale Electronics ...... www.pcb-soldering.co.uk ...... 79 London Electronics College, Showcase . . . www.lec.org.uk...... 126

APD, Showcase ...... www.apdanglia.org.uk...... 127 MikroElektronika...... www.mikroe.com ...... 3, 25, 65

Avit Research, Showcase...... www.avitresearch.co.uk ...... 126 MQP Electronics, Showcase...... www.mqp.com ...... 127

Bitscope Designs ...... www.bitscope.com ...... 2 Netronics, Showcase ...... www.cananalyser.co.uk...... 127

Black Robotics, Showcase...... www.blackrobotics.com ...... 126 Newbury Electronics ...... www.newburyelectronics.co.uk...... 113

ByVac, Showcase ...... www.byvac.com ...... 126 Nurve Networks ...... www.xgamestation.com ...... 113

C S Technology Ltd, Showcase ...... www.cstechnology.co.uk...... 126 Paltronix...... www.paltronix.com ...... 9

Decibit Co. Ltd, Showcase ...... www.decibit.com ...... 126 Parallax ...... www.parallax.com...... 87

Designer Systems, Showcase ...... www.designersystems.co.uk...... 126 PCBCORE ...... www.pcbcore.com ...... 47

EasyDAQ, Showcase ...... www.easydaq.biz ...... 126 Peak Electronic Design...... www.peakelec.co.uk ...... 135

Easysync, Showcase ...... www.easysync.co.uk...... 126 Pico...... www.picotech.com/scope1019...... 55

Elnec, Showcase ...... www.elnec.com ...... 126 Quasar Electronics...... www.quasarelectronics.com ...... 109

Eltim Audio ...... www.eltim.eu ...... 95 Robot Electronics, Showcase...... www.robot-electronics.co.uk...... 127

Eurocircuits ...... www.eurocircuits.com ...... 113 Robotiq, Showcase ...... www.robotiq.co.uk ...... 127

First Technology Transfer Ltd, Showcase . . www.ftt.co.uk ...... 126 Showcase ...... 126, 127

FlexiPanel Ltd, Showcase...... www.flexipanel.com ...... 126 USB Instruments, Showcase ...... www.usb-instruments.com ...... 127 Future Technology Devices, Showcase. . . . www.ftdichip.com...... 37 ,126 Virtins Technology, Showcase ...... www.virtins.com ...... 127 Good Will Instruments ...... www.gwinstek.com...... 8

Hameg, Showcase...... www.hameg.com ...... 126 Advertising space for the issue of 24 September 2009 may be reserved not later than 25 August 2009 HexWax Ltd, Showcase ...... www.hexwax.com ...... 126 with Huson International Media - Cambridge House - Gogmore Lane -

Labcenter...... www.labcenter.com...... 136 Chertsey, Surrey KT16 9AP - England - Telephone 01932 564 999 - Fax 01932 564 998 - e-mail: [email protected] to whom all Lcdmod Kit, Showcase ...... www.lcdmodkit.com ...... 126 correspondence, copy instructions and artwork should be addressed.

7-8/2009 - elektor 123

0907_elektor_adv_UK.indd 123 05-06-2009 13:28:48 infotainment puzzle

Hexamurai – Who’ll be the one to beat it?

Game designer: Claude Ghyselen (France)

Following our usual tradition, we’re offering you an outsize game each of the grids separately — you have to solve them all together, in this double issue. Hiding behind what looks like a pretty col- obeying the Hexadoku rules for each grid in turn. oured flower lurks a fearsome Hexadoku Samurai, or Hexamu- rai for short. Those who enjoy Hexadoku (and modern art) are The instructions for solving this puzzle are the same as for a standard bound to appreciate this grid that goes beyond tough. And in Sudoku (with a few modifications!) the (unlikely) event you can’t manage to solve it, at least you’ll Like Hexadoku, Hexamurai uses the figures of the hexadecimal sys- always be able to hang it on the wall. tem, namely 0 to F. Fill in the grid in such a way that all the hexadecimal figures from 0 to The Hexamurai is a Hexadoku grid based on the Samurai model, i.e. F (0–9 and A–F) are used once and only once in each row, column, 4 standard Hexadoku grids linked to a fifth one in the middle. But and square of 4×4 boxes (identified by different colours) of a sub-Hex- unlike a normal Samurai game, the Hexamurai doesn’t let you solve adoku (identified by a thicker line). Certain figures are already entered

D 2 5 3 8 0 9 4 B 3 D 4 8 2 F 5 B 1 E F 5 8 8 7 E B 4 F 9 1 A 5 0 6 8 C A F 9 C 0 5 E 6 3 A 8 7 F 4 0 5 2 C 9 1 A 3 4 B 5 A B 1 6 2 3 F D A 6 C 5 8 2 0 D A 4 B B F 5 E 9 1 7 8 D B E E 6 D 1 C 3 8 2 A 5 C 8 D 2 7 F 1 9 6 2 3 B A 0 9 D 7 3 B E 6 4 D 1 7 6 9 4 3 C F 2 B 7 C 7 6 D 1 F A 5 B D A 8 5 E D 9 0 1 5 E 4 0 9 4 C F 7 6 8 D 0 9 6 1 D F 4 C A 1 B 5 F 7 4 8 3 9 A C 6 B 9 E 5 3 E 6 2 0 9 3 D 8 7 1 B 8 7 1 8 2 8 F A 5 8 F 3 6 3 4 B 2 F 7 4 3 B 1 9 1 F A D C 6 2 3 0 5 B 2 F 9 6 D E 7 E C 1 7 4 E 6 1 E D C 7 4 0 F 8 7 3 1 0 2 5 2 C B 4 9 0 8 F A 8 B 6 2 D A A 8 3 C 2 8 0 A 6 E 9 3 E 2 B 1 7 0 B 8 4 C 7 9 A D 3 6 4 B 2 8 E 9 C 4 8 0 A D 1 A 7 C E B 9 4 0 6 3 4 F 5 6 0 9 5 F A 0 7 D 1 B 2 7 9 E C 5 1 3 6 2 F 4 9 B 3 C 9 D 2 1 4 F 8 A 2 7 C 9 E 5 A 4 0 6 8 9 E D 5 A 4 C E 2 5 D A 6 7 C 8 9 5 0 8 4 2 D F 9 3 1 7

124 elektor - 7-8/2009 into the grid, defining the start- Alternatively, by fax or post to: ing point for you. Elektor Hexadoku If you can solve this puzzle, there c/o Regus Brentford are some nice prizes to be won. 1000, Great West Road All you have to do is send us the Brentford TW8 9HH five figures in yellow, reading United Kingdom. from top to bottom. Fax (+44) 208 2614447 The puzzle is also available as a free download from the Elektor The closing date is website. 1 September 2009.

The competition is not open to employees of Solve Hexamurai and win! Elektor International Media, its business partners Correct solutions received from and/or associated publishing houses. the entire Elektor readership automatically enter a prize draw Prize winners for an E-blocks Starter Kit Profes- The solution of the May 2009 sional worth £ 300 / € 375 (rrp) Hexadoku is: 857C9. and three Elektor Electronics The E-blocks Starter Kit SHOP Vouchers worth £ 40.00 / Professional goes to: € 50.00. We believe these prizes Marcel Delomenede (France). should encourage all our readers An Elektor SHOP voucher to participate! goes to: Adrian Bradshaw Subject: hexamurai 07-2009 (please copy (UK); Thomas Raith (Germany); Heinz- Participate! exactly). Dieter Richter (Germany). Please send your solution (the numbers in the grey boxes) by email to Include with your solution: full name and Congratulations everybody! [email protected] street address. (081169-I)

See your project in print! Elektor magazine is looking for Technical Authors/Design Engineers

If you have a an innovative or original project you’d like to share with Elektor’s 140 k+ readership and the electronics community a above average skills in designing electronic circuits a experience in writing electronics-related software a basic skills in complementing your hardware or software with explanatory text a a PC, email and Internet access for efficient communications with Elektor’s centrally located team of editors and technicians then don’t hesitate to contact us for exciting opportunities to get your project or feature article published. Our Author Guidelines are at: www.elektor.com/authors.

Elektor Jan Buiting MA, Editor Regus Brentford, 1000 Great West Road, Brentford TW8 9HH, United Kingdom Email: [email protected]

7-8/2009 - elektor 125 ELEKTOR SHOWCASE To book your showcase space contact Huson International Media Tel. 0044 (0) 1932 564999 Fax 0044 (0) 1932 564998

AVIT RESEARCH EASYDAQ FUTURE TECHNOLOGY DEVICES www.avitresearch.co.uk www.easydaq.biz http://www.ftdichip.com USB has never been so simple... • USB powered, 4 relays + 4 DIO channels FTDI designs and sells with our USB to Microcontroller Interface cable. • Will switch 240VAC @ 10 amps USB-UART and USB-FIFO Appears just like a serial port to both PC and • Screw terminal access interface i.c.’s. Microcontroller, for really easy USB connection to Complete with PC drivers, your projects, or replacement of existing RS232 • LabVIEW, VB, VC interfaces. • Free shipping these devices simplify the task of designing or See our webpage for more • From £38 upgrading peripherals to USB details. From £10.00. Design & supply of USB, USB Wireless, Ethernet & Serial, DAQ, Relay & DIO card products. [email protected] BLACK ROBOTICS www.blackrobotics.com Robot platforms and brains for EASYSYNC research, hobby and education. http://www.easysync.co.uk EasySync Ltd sells a wide • Make your robot talk! range of single and multi- • TalkBotBrain is open-source port USB to RS232/RS422 • Free robot speech software and RS485 converters at competitive prices. • Robot humanisation technology • Mandibot Gripper Robot ELNEC www.elnec.com BYVAC • device programmer www.byvac.com manufacturer • USB to I2C • selling through contracted • Microcontrollers distributors all over the world • Forth • universal and dedicated device programmers HEXWAX LTD • Serial Devices • excellent support and after sale support www.hexwax.com • free SW updates World leaders in Driver-Free USB ICs: • reliable HW • USB-UART/SPI/I2C bridges C S TECHNOLOGY LTD • once a months new SW release • TEAleaf-USB authentication dongles www.cstechnology.co.uk • three years warranty for most programmers • expandIO-USB I/O USB expander Low cost PIC prototyping kits, PCB's and • USB-FileSys flash drive with SPI interface components, DTMF decoder kits, CTCSS, FFSK, • USB-DAQ data logging flash drive GPS/GSM, radio equipment and manuals. FIRST TECHNOLOGY TRANSFER LTD. PCB design and PIC program development. http://www.ftt.co.uk • Training and Consulting for IT, Embedded and LONDON ELECTRONICS COLLEGE Real Time Systems http://www.lec.org.uk DECIBIT CO.LTD. • Assembler, C, C++ (all levels) Vocational training and education www.decibit.com • 8, 16 and 32 bit microcontrollers for national qualifications in • Development Kit 2.4 GHz • Microchip, ARM, Renesas, TI, Freescale Electronics Engineering and • Transceiver nRF24L01 • CMX, uCOSII, FreeRTOS, Linux operating Information Technology (BTEC First National, • AVR MCU ATmega168 systems Higher National NVQs, GCSEs and GCEs). Also • Ethernet, CAN, USB, TCP/IP, Zigbee, Bluetooth Technical Management and Languages. programming DESIGNER SYSTEMS http://www.designersystems.co.uk FLEXIPANEL LTD LCDMOD KIT Professional product development services. www.flexipanel.com http://www.lcdmodkit.com • Marine (Security, Tracking, Monitoring & control) TEAclippers - the smallest Worldwide On-line retailer • Automotive (AV, Tracking, PIC programmers in the world, Gadget, Monitoring & control) • Electronics components • Industrial (Safety systems, from £20 each: • SMT chip components Monitoring over Ethernet) • Per-copy firmware sales • USB interface LCD • Telecoms (PSTN handsets, GSM/GPRS) • Firmware programming & archiving • Kits & Accessories • AudioVisual ((HD)DVD accessories & controllers) • In-the-field firmware updates • PC modding parts Tel: +44 (0)1872 223306 • Protection from design theft by subcontractors • LCD modules

126 elektor - 7-8/2009

0907_elektor_adv_UK.indd 126 05-06-2009 13:29:00 products and services directory

ROBOT ELECTRONICS USB INSTRUMENTS http://www.robot-electronics.co.uk http://www.usb-instruments.com www.elektor.com Advanced Sensors and Electronics for Robotics USB Instruments specialises • Ultrasonic Range Finders in PC based instrumentation • Compass modules products and software such • Infra-Red Thermal sensors as Oscilloscopes, Data MQP ELECTRONICS • Motor Controllers Loggers, Logic Analaysers www.mqp.com • Vision Systems which interface to your PC via USB. • Low cost USB Bus Analysers • Wireless Telemetry Links • High, Full or Low speed captures • Embedded Controllers • Graphical analysis and filtering VIRTINS TECHNOLOGY • Automatic speed detection www.virtins.com • Bus powered from high speed PC PC and Pocket PC based virtual instrument such • Capture buttons and feature connector ROBOTIQ as sound card real time • Optional analysis classes http://www.robotiq.co.uk oscilloscope, spectrum Build your own Robot! analyzer, signal generator, Fun for the whole family! multimeter, sound meter, • MeccanoTM Compatible distortion analyzer, LCR meter. RFID COMPONENTS • Computer Control Free to download and try. http/www.apdanglia.org.uk • Radio Control For DIY, OEM's & Experimenters • Tank Treads • EM4100 Cards .99 p (Prices inc vat) • Hydraulics CANDO – CAN BUS ANALYSER • Keyfobs £1.09 Internet Technical Bookshop, http://www.cananalyser.co.uk • R/W Keyfobs £1.65 1-3 Fairlands House, North Street, Carshalton, • USB to CAN bus interface • RFID Coils £2.95 Surrey SM5 2HW • USB powered • RFID PCB email: [email protected] Tel: 020 8669 0769 • FREE CAN bus analyser S/W with RS232 port • Receive, transmit & log. • RFID IC’s EM4095 - U2270B CAN messages • microRFID module (similar to Core ID12) • ISO11898 & CAN • Free Reader download - Technical pages 2.0a/2.0b compliant Order online 24 hrs - Tel: 01244 520684 www.elektor.com • Rugged IP67 version available

SHOWCASE YOUR COMPANY HERE Elektor Electronics has a feature to help • For just £242 + VAT (£22 per issue for image - e.g. a product shot, a screen shot customers promote their business, eleven issues) Elektor will publish your from your site, a company logo - your Showcase - a permanent feature of the company name, website address and a choice magazine where you will be able to showcase 30-word description your products and services. • For £363 + VAT for the year (£33 per Places are limited and spaces will go on issue for eleven issues) we will publish a strictly first come, first served basis. the above plus run a 3cm deep full colour So-please fax back your order today!

I wish to promote my company, please book my space: • Text insertion only for £242 + VAT • Text and photo for £363 + 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/2009 - elektor 127

0907_elektor_adv_UK.indd 127 05-06-2009 13:29:21 SHOP BOOKS, CD-ROMS, DVDS, KITS & MODULES Going Strong

A world of electronics Bring your microcontroller to life Artifi cial Intelligence from a single shop! This book contains 23 special and excit- ing artifi cial intelligence machine-lear- ning projects, for microcontroller and PC. Learn how to set up a neural network in a microcontroller, and how to make the net- work self-learning. Or discover how you NEW! can breed robots, and how changing a fi tness function results in a totally diffe- rent beha vior. Several artificial intelli- gence techniques are discussed: expert system, neural network, subsumption, emerging behavior, genetic algorithm, cellular automata. roulette brains etc.

256 pages • ISBN 978-0-905705-77-4 £32.00 • US $46.00

Limited Period Offer for Subscribers! £5 DISCOUNT www.elektor.com/july ConnectFully elaborated your mouse electronics into new projects embedded applications Mouse309 Circuits Interfacing Creative solutions for all areas of electronics ThisThe presentbook describes tenth edition in-depth of thehow popular to con- 310 Circuits nect‘30x the Circuits’ mouse series into new of books embedded once againappli- The 30x series of Summer Circuit compilation books have been bestsellers for many years. The 11th cations.contains It a details comprehensive the two main variety interface of cir- volume is available now! 310 circuits, tips and design ideas in one book form a treasure trove for methods,cuits, sub-circuits, PS/2 and tips USB, and and tricks offers and appli- de-

Books every area of electronics: audio and video, hobby and modelling, RF techniques, home and garden, cationssign ideas guidance for electronics. with hardware Among and many soft- test and measurement, microcontrollers, computer hardware and software, power supplies and wareother examples inspiring plustopics, tips the on interfacingfollowing cat- the chargers – plus of course everything else that does not seem to belong in any of these categories. mouseegories to are typical well microcontrollers.presented in this A book: wide 310 Circuits for the fi rst time has a section exclusively on robots and robotics. This book contains rangetest & ofmeasurement; topics is explored, RF (radio);including com- USB many complete solutions as well as useful starting points for your own projects. Both categories and descriptors,puters and aperipherals; four-channel, audio millivolt-preci- & video; anything in between represent a veritable fountain of inspiration for cultivating your own ideas and sionhobby voltage and modelling; reference all microcontrollers; with fully docu- learning about electronics. This is a must-have book for every creative electronics enthusiast, be it mentedhome & source-code. garden; etcetera. professional, enthusiast or student. 256432 pages • ISBN 978-0-905705-74-3978-0-905705-69-9 544 pages • ISBN 978-0-905705-78-1 • £29.90 • US $45.00 £26.50£19.95 • US $53.00$39.95

Prices and item descriptions subject to change. E. & O.E

128 elektor - 7-8/2009

ELEK UK09078 shop.indd 128 03-06-2009 22:30:08 Incl. searchable i-TRIXX archive Bestseller! New! DVD i-TRIXX Freeware Collection 2009 Learn by doing Learn more about C# programming and .NET This DVD contains 100 nifty freeware C Programming C# 2008 and applications, tools and utilities for the Win- for Embedded Microcontrollers .NET programming dows PC. And as a free extra, it contains the full and searchable (!) i-TRIXX archive, If you would like to learn the C Program- for Electronic Engineers with all the editions up until week 8 of ming language to program microcon- This book is aimed at Engineers and 2009 from i-TRIXX, the e-magazine pub- trollers, then this book is for you. No pro- Scientists who want to learn about the lished by Elektor. Do you feel the need for gramming experience is necessary! You’ll .NET environment and C# programming a decent and reliable antivirus program? start learning to program from the very or who have an interest in interfacing A bandwidth monitor which keeps track of fi rst chapter with simple programs and hardware to a PC. The book covers the your current up and download rate? An slowly build from there. Initially, you pro- Visual Studio 2008 development environ- application for recording, editing and con- gram on the PC only, so no need for de- ment, the .NET framework and C# pro- verting video to any conceivable format? dicated hardware. This book uses only free gramming language from data types and Anonymous surfing from any internet or open source software and sample pro- program fl ow to more advanced concepts access point from a USB stick? Checking, grams and exercises can be downloaded including object oriented programming. It optimizing and cleaning up your com- from the Internet. continues with program debugging, fi le puter? Keeping track of your privacy? You 324 pages • ISBN 978-0-905705-80-4 handling, databases, internet communi- can expect that and much more in the £32.50 • US $52.00 cation and plotting before moving to hard- i-TRIXX Freeware Collection 2009. ware interfacing using serial and parallel ports and the USB port. It includes a hard- ISBN 978-90-5381-244-0 • £27.50 • US $39.50 ware design for a simple oscilloscope us- ing a parallel port and inter facing to analogue and digital I/O using the USB port. This book is complete with many pro- gram examples, self assessment exercises and references to supporting videos. 240 pages • ISBN 978-0-905705-81-1 Bestseller! £29.50 • US $44.50 Completely updated Elektor’s Components 45 projects for PIC, AVR and ARM More information on the Database 5 Microcontroller Elektor Website: The program package consists of eight databanks covering ICs, germanium and Systems Engineering www.elektor.com silicon transistors, FETs, diodes, thyristors, This book covers 45 exciting and fun Flow- triacs and optocouplers. A further eleven Elektor code pro jects for PIC, AVR and ARM applications cover the calculation of, for ex- Regus Brentford microcontrollers. Each project has a clear ample, LED series droppers, zener diode

description of both hardware and software 1000 Great West Road series resistors, voltage regulators and CD/DVD-ROMs with pictures and diagrams, which explain Brentford AMVs. A colour band decoder is included not just how things are done but also why. TW8 9HH for determining resistor and inductor val- As you go along the projects increase in United Kingdom ues. ECD 4 gives instant access to data on difficulty and the new concepts are ex- more than 69,000 components. All data- Tel.: +44 20 8261 4509 plained. You can use it as a projects book, bank applications are fully interactive, al- Fax: +44 20 8261 4447 and build the projects for your own use. lowing the user to add, edit and complete Or you can use it as a study guide. Email: [email protected] component data. This CD-ROM is a must- have for all electronics enthusiasts. 329 pages • ISBN 978-0-905705-75-0 £29.00 • US $52.00 ISBN 978-90-5381-159-7 • £24.90 • US $39.50

Incl. sea

7-8/2009 - elektor 129

ELEK UK09078 shop.indd 129 03-06-2009 22:30:25 SHOP BOOKS, CD-ROMS, DVDS, KITS & MODULES

New! The 32-bit Machine (April 2009) Bestseller! See the light on Solid State Lighting With this attractively priced starter kit you Experimenting get everything you need for your fi rst hands- DVD LED Toolbox on experiments with the new R32C/ This DVD-ROM contains carefully-sorted with the MSP430 111 32-bit microcontroller. The power sup- CD/DVD-ROMs comprehensive technical documentation (May 2009) ply is drawn from your computer via the about and around LEDs. For standard USB connection, which simplifies things models, and for a selection of LED mod- All the big electronics manufacturers su- rather nicely. The starter kit consists of an ules, this Toolbox gathers together data pply microcontrollers offering a wide ran- R32C carrier board (a microcontroller sheets from all the manufacturers, ap pli- ge of functions. Texas Instruments supplies module equipped with the R32C/111 chip) cation notes, design guides, white papers handy USB evaluation sticks with related and a software CD-ROM containing and so on. It offers several hundred dri- software for its low-cost MSP430 contro- the necessary development tools. As with vers for powering and controlling LEDs in llers. Unfortunately the I/O facilities are the earlier R8C/13 ‘Tom Thumb’ project in different configurations, along with somewhat limited. These can be substan- Elektor Electronics (November 2005 ready-to-use modules (power supply tially enhanced with the help of the Elektor through March 2006), the R32C carrier units, DMX controllers, dimmers, etc.). In MSP430 board. board is an in-house-development of Glyn, addition to optical systems, light detec- an authorised distributor for Renesas in tors, hardware, etc., this DVD also ad- PCB, populated and tested Germany. dresses the main shortcoming of power Art.# 080558-91 • £35.00 • US $55.00 LEDs: heating. Of course, this DVD con- R32C/111 Starterkit (32-bit-Controller- tains several Elektor articles (more than TI eZ430-F2013 Evaluation Kit board & CD-ROM) 100) on the subject of LEDs. Art.# 080558-91 • £24.50 • US $35.00 Art.# 080928-91 • £27.00 • US $42.50 ISBN 978-90-5381-245-7 • £28.50 • US $54.00

Automotive CAN controller M16C TinyBrick (April 2009) (March 2009)

Since cars contain an ever increasing A TinyBrick is a small self-contained mi- All articles published in 2008 amount of electronics, students learning crocontroller module fi tted with a power- DVD Elektor 2008 about motor vehicle technology also need ful Renesas 16-bit M16C microcontroller. Kits & Modules to know more about electronics and mi- A BASIC interpreter is installed in the This DVD-ROM contains all editorial arti- crocontrollers. In collaboration with the module to simplify software develop- cles published in Volume 2008 of the Timloto o.s. Foundation in the Nether- ment. Beginners will fi nd it an ideal start- English, Spanish, Dutch, French and Ger- lands, Elektor designed a special control- ing out point while more experienced man editions of Elektor magazine. Using ler PCB, which will be used in schools in users will appreciate its power and con- Adobe Reader, articles are presented in several countries for teaching students venience. With this evaluation board (to- the same layout as originally found in about automotive technologies. But it can gether with a TinyBrick) you can build an the magazine. The DVD is packed with also be used for other applications, of intruder alarm that sends SMS texts. features including a powerful search en- course. The heart of this board is an Atmel gine and the possibility to edit PCB layouts AT90CAN32 with a fast RISC core. Kit of parts incl. TinyBrick-PCB with SMD with a graphics program, or printing hard parts and microntroller premounted plus copy at printer resolution. Kit of parts, incl. PCB with SMDs prefi tted all other parts

ISBN 978-90-5381-235-8 • £17.50 • US $35.00 Art.# 080671-91 • £52.00 • US $79.00 Art.# 080719-91 • £54.00 • US $87.50

Prices and item descriptions subject to change. E. & O.E

130 elektor - 7-8/2009

ELEK UK09078 shop.indd 130 03-06-2009 22:30:34 July/August 2009 (No. 391) £ US $ + + + Product Shortlist July/August: See www.elektor.com + + + June 2009 (No. 390) Bestsellers Campsite AC Monitor C# 2008 and .NET programming 060316-1 ...... Printed circuit board ...... 21.50 ...... 30.00 1 ISBN 978-0-905705-81-1 ...... £29.50 .....US $44.50 ATM18 = RFID Savvy 080910-91 ....PCB, partly populated PCB populated with all SMDs ...... 16.50 ...... 26.00 C Programming for Embedded Microcontrollers 2 ISBN 978-0-905705-80-4 ...... £32.50 .....US $52.00 May 2009 (No. 389) Experimenting with the MSP430 Artifi cial Intelligence 080558-91 ....PCB, populated and tested ...... 35.00 ...... 55.00 Books 3 ISBN 978-0-905705-77-4 ...... £32.00 .....US $46.00 080558-92 ....TI eZ430-F2013 Evaluation Kit ...... 24.50 ...... 35.00 RGB LED Driver Microcontroller Systems Engineering ISBN 978-0-905705-75-0 ...... £29.00 .....US $52.00 080178-41 ....Programmed controller ...... 8.90 ...... 13.75 4

April 2009 (No. 388) Mouse Interfacing Books 5 ISBN 978-0-905705-74-3 ...... £26.50 .....US $53.00

Product Shortlist Product The 32-bit Machine 080928-91 ....R32C/111 Starterkit (32-bit-Controllerboard & CD-ROM) ...... 27.00 ...... 42.50 ECD 5

CD-ROMs ISBN 978-90-5381-159-7 ...... £24.90 .....US $39.50 Automotive CAN Controller 1 080671-91 ....Kit of parts, incl. PCB with SMDs prefi tted ...... 52.00 ...... 79.00 DVD i-TRIXX Freeware Collection Automatic Running-in Bench 2 ISBN 978-90-5381-244-0 ...... £27.50 .....US $39.50 080253-71 ....Kit of parts incl. PCB-1 with SMDs prefi tted ...... 185.00 ...... 270.00 090146-91 ....ARMee plug-in board mk. II ...... 50.00 ...... 74.00 DVD Elektor 2008 March 2009 (No. 387) 3 ISBN 978-90-5381-235-8 ...... £17.50 .....US $35.00 M16C TinyBrick 080719-91 ....Kit of parts: TinyBrick-PCB with SMD parts and DVD LED Toolbox Kits & Modules & Kits ISBN 978-90-5381-245-7 ...... £28.50 .....US $54.00 microntroller premounted; plus all other parts ...... 54.00 ...... 87.50 4

February 2009 (No. 386) DVD Elektor 1990 through 1999 CD/DVD-ROMs ISBN 978-0-905705-76-7 ...... £17.50 .....US $35.00 Model Coach Lighting Decoder 5 080689-1 ...... PCB, long (l = 230 mm) ...... 7.30 ...... 10.95 080689-2 ...... PCB, medium (l = 190mm) ...... 7.30 ...... 10.95 MSP430: PCB, populated and tested 080689-3 ...... PCB, short (l = 110mm) ...... 5.80 ...... 8.95 1 Art. # 080558-91 ...... £35.00 .....US $55.00 080689-41 ....PIC12F683, programmed ...... 6.20 ...... 9.50 : TI eZ430-F2013 Evaluation Kit Transistor Curve Tracer MSP430 080068-1 ...... Main PCB ...... 26.50 ...... 42.00 2 Art. # 080558-91 ...... £24.50 .....US $35.00 080068-91 ....PCB, populated and tested ...... 55.00 ...... 82.50 The 32-bit Machine January 2009 (No. 385) 3 Art. # 080928-91 ...... £27.00 .....US $42.50 Radio for Microcontrollers 071125-71 ....868 MHz module ...... 7.20 ...... 9.95 Automotive CAN controller 4 Art. # 080671-91 ...... £52.00 .....US $79.00 ATM18 on the Air 071125-71 ....868 MHz module ...... 7.20 ...... 9.95 Meeting Cost Timer Modules & Kits 5 LED Top with Special Effects 080396-41 ....ATmega168, programmed ...... 8.50 ...... 12.50 Art. # 080678-71 ...... £42.00 ....US $59.00 Capacitive Sensing and the Water Cooler 080875-91 ....Touch Sensing Buttons Evaluation kit ...... 27.50 ...... 39.95 080875-92 ....Touch Sensing Slider Evaluation kit ...... 27.50 ...... 39.95 Three-Dimensional Light Source Order quickly and securely through 080355-1 ...... Printed circuit board ...... 24.90 ...... 39.90 Moving up to 32 Bit www.elektor.com/shop 080632-91 ....ECRM40 module ...... 32.00 ...... 46.50

December 2008 (No. 384) or use the Order Form near the end PLDM 071129-1 ...... Printed circuit board ...... 5.80 ...... 9.50 of the magazine! Hi-fi Wireless Headset 080647-1 ...... Printed circuit board: Transmitter ...... 7.90 ...... 15.80 080647-2 ...... Printed circuit board: Receiver...... 7.90 ...... 15.80 Elektor Regus Brentford LED Top with Special Effects 1000 Great West Road 080678-71 ....Kit of parts incl. SMD-stuffed PCB Brentford TW8 9HH • United Kingdom and programmed controller ...... 42.00 ...... 59.00 Tel. +44 20 8261 4509 Fax +44 20 8261 4447 Email: [email protected]

7-8/2009 - elektor 131

ELEK UK09078 shop.indd 131 03-06-2009 22:30:40 info & market coming attractions next month in elektor

GPS Datalogger There are plenty of projects that deal with GPS and microcontrollers, many of which covering navi- gation only. But what if you wanted to log the path of a bike or car trip? Sure, you could export the data for processing into some other application that does this, but you could also make use of a very popular application called Google™ Earth. This is made possible by the combination of a GPS module, a BASIC Stamp® microcontroller module , a Parallax Memory Stick Datalogger and some clever software enabling GPS coordinates to be stored as a KML file on an ordinary USB memory stick — and read back on your PC.

New: E-Labs Inside Starting this September Elektor Labs, the hub & foundry of all technical wizardry you can read about every month in Elektor will occupy the centre four pages of the magazine. There we will cover all issues our laboratory workers first fuss about and then care to make public like equipment reviews, tips and tools of the trade and techno talk. For the first instalment the intention is to report on practical experience with a new Yokogawa oscilloscope our lab guys got on loan for a month or was it a bit longer. What did they like and dislike about the instrument? Read all about it in the next issue of Elektor.

ATM18 Mini Chess Computer The Elektor ATM18 microcontroller system can be used to make a surprisingly simple and effective chess computer. The only additional hardware required is a few low-cost pushbut- tons. The software for the project is written in C, and it was far from an easy task to fit the program in the 8 kB of program memory offered by the ATmega88.

Article titles and magazine contents subject to change, please check ‘Magazine’ on www.elektor.com The September 2009 issue comes on sale on Thursday 20 August 2009 (UK distribution only). UK mainland subscribers will receive the issue between 15 and 18 August 2009. www.elektor.com www.elektor.com www.elektor.com www.elektor.com www.elektor.com Elektor on 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 downloads, 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

132 elektor - 7-8/2009

ELEK UK09078 Orderform.indd 1

✁ ✁

SubscriptionOrder Form07/08-2009 Order Form07/08-2009 EL07/08 Tel. Postcode + Address Name O.E. & E. issues. previous in those supersede here shown descriptions item and Prices notification. prior without prices change to right the reserve publishers The change. to subject descriptions item and Prices EL07/08 Tel. Postcode + Address Name Description Free ElektorFreeCatalogue 2009 CD-ROM5 ECD DVDLED Toolbox forEmbedded Microcontrollers ProgrammingC 2008C#and.NET Circuits310 forElectronic Engineers 2GB MP3 player MP3 2GB to Elektor to subscription annual an out taking Yes,am I I would like: would I See reverse for rates and conditions.reverseand forrates See availability.months.to 12 Offersubject last the during Elektor to subscription a held havenot who OfferavailableSubscribers to * (11 issues plus the Elektor the Volumeplus issues CD-ROM) (11 2009 Subscription-Plus issues) (11 Subscription Standard

and receive a free a receive and

Date – – – – Date Date – – – – Date programming

c ribers who have not held a subscri a held havenot who ribers * .

NEW NEW NEW NEW NEW Signature Signature Email mi Email Totalpaid Price each Qty. Total Order Code Order Total Qty. each Price Sub-total £ £ £ £ £ p tio 24.90 28.50 32.50 29.50 29.90 n P&P

United Kingdom United Brentford9HH TW8 Great WestRoad 1000 BrentfordRegus Elektor conditions) for reverse (see to* form order this send Please [email protected] [email protected] www.elektor.com 4447 8261 20 +44 Fax: 4509 8261 20 Tel.:+44 Kingdom United Brentford9HH TW8 Great WestRoad 1000 BrentfordRegus Elektor to form order this send Please [email protected] E-mail: 603-924-9467 Fax: 603-924-9464 Phone: 03458-0876 NH Peterborough 876 Box PO US Elektor to: form order the send and prices, $ use should residents Canada and *USA [email protected] www.elektor.com 4447 8261 20 +44 Fax: 4509 8261 20 Tel.:+44

appropriate) as ticking before reverse (see PAYMENT OF METHOD appropriate) as ticking before reverse (see PAYMENT OF METHOD

Giro transfer transfer Giro Cheque transfer Bank Giro transfer transfer Giro Cheque transfer Bank (UK-resident customers ONLY)customers (UK-resident (UK-resident customers ONLY)customers (UK-resident Verification code: ______code: Verification ______date: Expiry Verification code: ______code: Verification ______date: Expiry 03-06-2009 22:24:02 ✁ ORDERING INSTRUCTIONS, P&P CHARGES

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 should send orders, except for subscriptions (for which see below), to the USA address given on the order form. Please apply to Elektor US for applicable P&P charges. Please allow 4-6 weeks for delivery. Orders placed on our Brentford office must include P&P charges (Priority or Standard) as follows: Europe: £6.00 (Standard) or £7.00 (Prio rity) Outside Europe: £9.00 (Standard) or £11.00 (Priority)

HOW TO PAY

All orders must be accompanied by the full payment, including postage and packing charges as stated above or advised by Customer Services staff.

Bank transfer into account no. 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. January 2009

SUBSCRIPTION RATES FOR ANNUAL SUBSCRIPTION CONDITIONS SUBSCRIPTION The standard subscription order period is twelve months. If a Standard Plus permanent change of address during the subscription period means United Kingdom £49.00 £58.00 that copies have to be despatched by a more expensive service, no extra charge will be made. Conversely, no refund will be made, Surface Mail nor expiry date extended, if a change of address allows the use of Rest of the World £63.00 £72.00 a cheaper service. Student applications, which qualify for a 20% (twenty per cent) Airmail reduction in current rates, must be supported by evidence of stu- Rest of the World £79.00 £88.00 dentship signed by the head of the college, school or university USA £64.95 See www.elektor-usa.com faculty. A standard Student Subscription costs £39.20, a Student Canada £75.95 for special offers Subscription-Plus costs £48.20 (UK only). Please note that new subscriptions take about four weeks from HOW TO PAY 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, Bank transfer into account no. 40209520 held by Elektor Electronics. whichever is the higher, plus the cost of any issues already with ABN-AMRO Bank, London. IBAN: GB35 ABNA 4050 3040 2095 20. dispatched. Subsciptions cannot be cancelled after they have BIC: ABNAGB2L. Currency: sterling (UKP). Please ensure your full name run for six months or more. 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. January 2009

ELEK UK09078 Orderform.indd 2 03-06-2009 22:24:04              /  /  / / %& 5 % +9   &! )   &%  >0.17<=/' ,      +))(( ) +)   .) ) )  1    +) ( 2 .4% .4-% ) 533% 1  + (',).  ,)   1   (). )')  1  )    ,)$)(),(( '.  *  ) ,(!)'( ),,1 % %&  5 % --    )  )   &%  >0+.74:/' ,      + )')  / '' + +  ,/    +) +  ) 1    +)   ) .(( '() '/    ()) . )( .".  .) + 1  ) ) ).()%) ." ) ( .+    !  ))) + + 1  #  )( + )  )(0'(   )   "3 $*  % 3 ,)0+  1 %& 5 % :99   &&  &%  >04+7<./' ,      ")  " )')  1    +) ) ) )  ()   1  ) )$ +433   433+1   )     () )45*.433+.$ ) ,)1  ) )$ ()  1   ()(%)(,) ( 1   ( ' + +  ,1# )(  "553. "6) $, ((1 "3 $*  % 3 %&5 %.9 & & && &%    >01-71+/' ,     &     ) ) ))) 1 %% & 8   (   ' 3134 +1  )() ) ) 433% 1  ) ),( #0  1   (). )')  1    ))() ) ) 1  )  0 ) 1  % $% %& 3    )31, %&&&"5  (<    &   / & >0:947.6/' ,    () )$ +  )(1  ()  +    +  )(1   ,) (  ),)1  + + )  ))1  &  (  1

  # +%   # +%   +%  +%  +"+"+ $ +!2*(+!+ $ +!2*(+!  /123.-*1123/ /123.-*1123/ "/123.-*11&(/% $0/ "/123.-*11&(/% $0/  // //##  0 0 ' '  // //    % % #(' 2 % & #(' 2 % & & 0<799$&  & 0<799$&  #( & $% #( & $%  7  7 & &   !  & !  & 2 2  % 7   % 7   &  &)  7;7)  7;7

0907_elektor_adv_UK.indd 135 05-06-2009 13:29:33 GO FASTER WITH PROTEUS PCB DESIGN

The latest version of the Proteus Design Suite harnesses the power of your computer’s graphics card to provide lightning fast performance. Together with unique transparency options it’s now easier than ever to navigate and understand large, multi-layer boards.

PROTEUS DESIGN SUITE Features:

All levels of the Proteus Design Suite include a world class, fully integrated shape-based autorouter at no additional cost - prices start from just £150 exc. VAT & delivery

Visit our website or phone 01756 753440 Labcenter Electronics Ltd. 53-55 Main Street, Grassington, North Yorks. BD23 5AA. for more details Registered in England 4692454 Tel: +44 (0)1756 753440, Email: [email protected]