JANUARY 2006 £3.80 www.elektor-electronics.co.uk Engineering • Attic Window - with weather-dependent control • Laptop PSD Adaptor - 12V-to-19V at 5A 1 R8C Micros - 16-bit power for everyone £3 irr\T jJTjTA TT Yes, that's right, down town, down under in Sydney Australia. We are a bunch of electronics enthusiasts who sell a great range of goodies through our FREE 400 page catalogue. Don't be frightened! You can purchase on the Net from us 24/7/365 through our secure encrypted system. Post and packing charges are modest and you can have any of 8000+ unique products delivered to your door within 7-10 days of your order. Some specific products are shown below. KC541 4 Lead-Acid Battery Zapper Kit KC-5414 £11.75 + post & packing This kit uses high-energy pulses to reverse the damaging effects of plate sulphation and extends the life in wet-cell batteries. Supplied with case, leads, and all electronic components. "Clock Watcher's" LED Clock Kits KC-5416(blue) £55.25 + post & packing KC-5404(red) £41.75 + post & packing These clocks are hypnotic! They consist of an AVR driven clock circuit, that also produces a dazzling display with the 60 LEDs around the perimeter. It looks amazing, but can't be properly explained here. We have filmed it in action so you can see for yourself on our website www.iavcarelectonics.co.uk ! Kit supplied with double sided silkscreened plated through hole PCB and all board components as well as the special clock housing! Available in Red (KC-5404) and Blue (KC-5416). Choke A Chicken GT-3095 £8.50 + post & packing Relieve stress with a bit of violence! This annoying chicken dances around and squawks. Funny for about one second! Grab him by the throat and he screams and gags. Funny forever! (not recommended for children) •Approx 300mm tall. •Requires 4 x AA batteries (not ind Theremin Synthesiser Kit KC-5295 £14.75 + post & packing The Theremin is a weird musical instrument that was invented early last century but is still used today. The Beach Boys' classic hit "Good Vibrations" featured a Theremin. By moving you hand between the antenna and the metal plate, you can create strange sound effects. Kit includes a machined, silk screened, and pre drilled case, circuit board, all electronic components, and clear English instructions. 9VDC wall adaptor required (Maplin #GS74R £9.99). Universal High Energy Ignition KC-5419 £27.75 + post & packing Now with PIC. , A high energy 0.9ms spark burns fuel faster and more efficiently to give you more power! This versatile kit can be connected to conventional points, twin points or reluctor ignition systems. Includes PCB, case and all electronic components. : L\rnp* oV - -V *- .) We Stock... Electronic Components, Sub-Assemblies & Electronic Kits Power Products & Accessories Audio & Visual Equipment & Accessories Computer & Telecoms Accessories Burglar Alarms & Surveillance Equipment Lighting Products & Accessories Gadgets 6L Unique Gifts High Performance Electronic Projects for Cars BS-5080 £7.00 + post & packing Australia's leading electronics magazine Silicon Chip, has developed a range of projects for performance cars. There are 16 projects in total, ranging from devices for remapping fuel curves, to nitrous controllers The book includes all instructions, components lists, colour pictures, and circuit layouts. There are also chapters on engine management, advanced systems and DIY modifications. Over 150 pages! All the projects are available in kit form. Smart Fuel Mixture Display KC-5374 £8.95 + post & packing This new 'smart' version has a few additional touches such as, auto dimming for night driving, emergency lean-out alarm, and better circuit protection. Another great feature, is the 'dancing' display which operates when the ECU is operating in closed loop. Kit supplied with PCB and all electronic components. • Car must be fitted with air flow and EGO sensors (standard on all EFI systems) for full functionality. Recommended box UB3 £1.40 each High Performance Timer KC-5379 £12.95 + post & packing This sophisticated timer can be adapted for two modes of operation. The first is 'one shot' operation, which can be used to keep electric windows active, or a thermo fan running for a period after ignition is switched off etc. The second is a 'pulse' type operation, which can be used to squirt water spray for 1 second every 9 seconds. The time is adjustable via easy to use (and accurate) digital switches. Kit supplied with PCB, and all electronic components. A w 400+ page Catalogue aycar Post and Packing Charges: Order Value Cost £20 - £49.99 £50 - £99.99 £100 - £199.99 £200 - £499.99 £500+ Cost £5 £10 £20 £30 £40 Max weight 121b (5kg) - heavier parcels POA. Minimum order £20. Log on to www.jaycarelectronics.co.uk/elektor for your FREE catalogue! 0800 032 7241 (Monday - Friday 09.00 to 17.30 GMT + 10 hours only). For those who want to write: 100 Silverwater Rd Silverwater NSW 2128 Sydney AUSTRALIA MikroEtaktronika MICROCONTROLLER DEVELOPMENT TOOLS HCniicru Easy ^ 3 plCmicro Starter Pack £99.00 4 Kjuylily di)vuk»pirtviTfl I.KMiU 4 OuilMn USB 2. ft programmer * Winctawa9a^i , ?00(J.^P oompatfele - SUppoflg 8. 14. 18. 26 and 4flpm DIP niKiioci5fiirDii^i^rforntnenpf. 12#-. 16 F and 18 F P ICmicro Families « Qn-befltf'd le d*. switch®, 7- segment displays- polemiomelm RS-23E mis riaoe USB and PS 2 come do is * AM I'D lines Available lor expansion 4 Ea&yPlC3 Slide-1 Pack ihcHrd**: - PtCiaF452 microcontroller < 16x2 characlar LCD ■■' 126*64 pixel graph*; LCD ^ DG1S320 Eomporalurt terser J USB pf-ogramminqi power load *' Programming software and examples Easy sPIC2 dsPIC Starter Pack £9900 * Hgh qiMhty dwekHmwl bowd 4 Built-in USB 2.0 progiammer * Windows Ha*MEt!200a:>EF' J comp/ilibla * Support 18. 28 and 40-pm Dip tkqdal cMiro«eni Irqm cfePlC30 fanny 4- QrhtKwudLED*. switches. peiertti omfllfitf* Rs-232 inferlae#. PS^E and ICD;-? conoedoiE, a nd MMC-SD card Biol * All ID Unas available lor expq Soil waiu and samples BIG' 3 80-pin PlCmicro Starter Pack £119.00 V ' ■■.■ t. ■ ■ - JL - >. ■ - •-«.- ' * High quality cfcrvefcpnwnt board ■ BuiR-n USB 2,0 p logrummar ■ Window* ®t'M£ i'2000/XP- compatfclfl * Supports Ihfl 1316*1 SQ-pln tifl4»W iFdrn |he 18f PlCnucro lamily * Cn board LEDs, *w4ch«s. poRonti- orhfllbl^, Iwn FIS 232 !rH 0 ifflCfl&, PS-2 connedor, and MMC'SD and Corn- pad Flash caid dots ■ Alt ID lines available tor expansion ■ BKJPIC3 Slartar Pit*, UndudR: ^ PtClsFB52D MCU module i 1 5x2 charade r LCD J 126X84 pixel graphic LCD * DSl852flterhpemlur6 mmtu ■ USB programming.'power lead ■' Pragrammng softwaie and examples IsPK PRO 64/80-pin dsPIC Starter Pack £14900 * High Quality devflidprne m tenid * BuiH in USB 2.0 progiarnniei * Windf'jws- 93 HI ?itO" XI 1 compair.’lo ■ Suppofl* 64 JWKl W-piri chgMal SKjnif 11 tfinlmlEflr& trnm the d*PlC?b limtly - Orhbowd LCD*. * wile he*, iwe Fts 232 inlarlaew. fiS-485 menace 1WO CAN interfaces, real- time dock 12-bfl AD and DA and C F card skn ■ All 1*0 bnas available lor axpanston 4 rfcPICPF&O srortflf PmM mciludw: dsFIC30F6D14 DSC module *' 16x2 character LCD r 128x64 pixel graphic LCD - DS18S20 Iflmfflrsturfl Sfln&5r k' USB pforjramniiingfjciwfir lead ■■■ Programming software and examples- BIG M i 64-pin AVR Starter Pack £119.00 « High q*. :-.lil y davalopmarrl boaid ■ Suit- m USB J.&piogrsmmflr ■ Wndows Sfl-'ME *2806 XP compalbla « ^uppoils 64 -pin AVR m ic rocord rotters ■ Qn-b04td LED*. tWflCNSt, pfltfllllp- flPMrtett, l wo FiS-232 iintflrlncflt. ps-? Cfjfinflddr am MHCi^D and Coni- pad Flash card slots -■ All LD Rnas available loi expansion - Si^AVFt Siader Padc indutfw: * ATffl*gal2&MCU mflduto 16x2 diarader LCD 128x64 pixel graphic LCD osi8S20tflmi>tiF3tute sof *■' U$8 pfbgfamruwi^powflf l&sd « Programming! software and examples PSoC Starter Pack £119.00 » High quaMy baufllqpmerK board * Birfl ‘Hi USB 2,8 prcpniim«f ■■ WmxIowe W campalibUe * Supports B, 20, ?i and 4fl-pm DIP PSoC mixfld sAjnfli'Mntrollfli* * Dn-board LEDfi SMrtche*. polenli- emetofs. RS-232 IfMitooa, R^-485 mlarTace. CAM pttariace. real-time dock, and MMCiBD and CF card slots r An ID lines available lor expansion ■ Ea*yP$oC3$lartflrPflcif includes v 45 pm PSoC mrcroooniroler * 1 6x2 character LCD ^ 126x84 pfXat graphic LCD v DS 1 8 S 26 lempflrfliiKfl 4 USB programming-power lead ^ Piogr3mnnng *Oltwaae ^hd examples ^readboarcung System* ean supply al MikroE tettrarnkfi prcwhicfcs frem, ntocR cradfl and *bfl tards accepi&d Pnee* shewn extf nde daiivflry and VAI Bread boarding Systems Software and hardware development tools Tel: 0845 226 9451 Web i www.b read boardi ng .co.uk Miscellaneous matters News from www.elektor-electronics.co.uk Unfortunately, on 18 and 19 Novem- ber last, our Webserver was over- loaded to the extent of being inacces- sible for about 20 hours. We apolo- gise to our customers who were unable to use the website at that time. With the publication of this January 2006 issue we should have an addi- tional Webserver up and running to handle the increasing amount of traffic our website is generating, mainly due to overseas customers downloading entire issues. Below is a Top-1 0 list for your amusement! Jan Buiting, Editor Top- 10, Paid Downloads (magazine articles) 1 Design Your Own 1C, Part 2 2 OBD-2 Analyser 3 PPP HiFi Valve Power Amplifier 4 Delphi for Electronic Engineers (1) 5 ClariTy 2x300W Class-T Amplifier (1 ) 6 High-End-Preamp, Part 1 7 Build Your Own DRM Receiver 8 Delphi for Electronic Engineers (2) 9 GPS Receiver on USB 10 Delphi for Electronic Engineers (3) Publisher's Announcement Effectively from 1 November 2005 we have a new, central, address for edito- rial, subscriptions and sales: Elektor Electronics (Publishing) Regus Brentford 1 000 Great West Road Brentford TW8 9HH United Kingdom Tel. (+44) (0)208 2614509 Fax (+44) (0)208 2614447 All company email addresses remain unchanged; please see our website at www.elektor-electronics.co.uk. We also take this opportunity to inform you of our new bank account: Elektor Electronics (Publishing) / Segment bv ABN-AMRO Bank, London Account no.: 40209520 IBAN: GB35 ABNA 4050 3040 2095 20 BIC: ABNAGB2L We thank all customers and sub- scribers for using the new address and bankers' data. Paul Snakkers, Publisher. ding th w V It's usually possible to solder 'ordinary' SMD components using a low- power soldering iron and small-gauge solder. However, it's a completely different story when you have to solder a component in a BGA, CSP or similar package. Such components can actual y only be soldered using a reflow soldering oven. Here we describe how a normal, inexpensive oven can be transformed into a reflow oven. ii W>! [J jfjj i j r i [i [i 1 1 i K jj j r iT jj noiiH IVfi H | l j ■ j# , ifl m The EU has taken two significant steps in the fight against toxic elec- tronic waste. In this article we look at what 'RoHS' and 'WEEE' mean for equipment manufacturers, distributors and users. CONTENTS Volume 32 January 2006 no. 350 Free Visual Basic for Electronics booklet with this issue (secured to magazine outside covers) know-how 16 Part Mining 22 The Battle against Electronic Waste 1 6 Part Mining Now is the time to step into action if you are after that one elusive part for your project or repair job. Concentrate on What and Where, surf, dig, unearth, bar- gain and rummage around. The Old Curios- ity Shop may be closer to you than you think. 42 95-watt Laptop PSU Adaptor Laptop or notebook computer users will invariably need to plug into a mains outlet from time to time to top up the batteries. The car cigarette lighter socket in the car is also an electrical outlet but it can only supply 1 2 V. That's no problem for the Lap- top PSU Adaptor described here; it can deliver ample voltage and cur- rent for today's portable computers from a car battery. hands-on 28 SMD Reflow Soldering Oven 36 The R8C Family 4 ' 95-watt Laptop PSU Adaptor 50 Shutter Time Meter 56 Automatic Attic Window Controller 6 ' A 'Retro' Mobile Phone 66 Timer Switch for Washing Machine Design Tips Four Steps to LEDs on the Mains Christmas Tree Lighting with LEDs Poor Man's CRT Demagnetizer technology 54 E-blocks in Cyberspace info & market 6 Colophon 8 Mailbox Corrections & Updates News & New Products 84 Sneak Preview infotainment 26 Qu izz Away (1 1 -2005 solution) 49 LabTalk: Charred PCBs 62 A 'Retro' Mobile Phone 76 Retronics: Return to Antique Modulation 79 NEWHexadoku (1) lektor lectronics Volume 32, Number 350, January 2005 ISSN 0268/45 1 9 Elektor Electronics aims at inspiring people to master electronics at any person- al level by presenting construction projects and spotting developments in elec- tronics and information technology. Publishers: Elektor Electronics (Publishing), Regus Brentford, 1000 Great West Road, Brentford TW8 9HH, England. Tel. (+44) (0) 208 261 4509, fax: (+44) (0) 208 261 4447 www.elelctor-electronics.co.uk. The magazine is available from newsagents, bookshops and electronics retail outlets, or on sub- scription. Elektor Electronics is published I I times a year with a double issue for July & August. Under the name Elektor and Elektuur, the magazine is also published in French, German and Dutch. Together with franchised editions the magazine is on circulation in more than 50 countries. International Editor: Mat Heffels (m.heffels@segment.nl) Editor: Jan Buiting (editor@elektor-electronics.co.uk) International editorial staff: Harry Baggen, Thijs Beckers, Ernst Krempelsauer, Jens Nickel, Guy Raedersdorf. Design staff: David Daamen (head of design), Ton Giesberts, Paul Goossens, Luc Lemmens, Karel Walraven Editorial secretariat: Hedwig Hennekens (secretariaat@segment.nl) Graphic design / DTP: Ton Gulikers, Giel Dols Managing Director / Publisher: Paul Snakkers Marketing: Margriet Debeij (m.debeij@segment.nl) Subscriptions: Elektor Electronics (Publishing), Regus Brentford, 1000 Great West Road, Brentford TW8 9HH, England. Tel. (+44) (0) 208 26 1 4509, fax: (+44) (0) 208 26 1 4447 Internet: www.elektor-electronics.co.uk Email: subscriptions@elektor-electronics.co.uk Rates and terms are given on the Subscription Order Form Head Office: Segment b.v. RO. Box 75 NL-6I90-AB Beek The Netherlands Telephone: (+31)46 4389444, Fax: (+31)46 4370161 Distribution: Seymour, 86 Newman Street, London Wl P 3LD, England UK Advertising: Huson International Media, Cambridge House, Gogmore Lane, Chertsey, Surrey KTI 6 9AR England. Telephone: +44 (0) 1 932 564999, Fax: +44 (0) I 932 564998 Email: r.elgar@husonmedia.com Internet: www.husonmedia.com Advertising rates and terms available on request. International Advertising: Klaas Caldenhoven, address as Head Office Email: advertenties@elektuur.nl Advertising rates and terms available on request. Copyright Notice The circuits described in this magazine are for domestic use only. All drawings, photographs, printed circuit board layouts, programmed integrated circuits, disks, CD-ROMs, software carriers and article texts pub- lished in our books and magazines (other than third-party advertisements) are copyright Segment, b.v. and may not be reproduced or transmitted in any form or by any means, including photocopying, scanning an recording, in whole or in part without prior written permission from the Publishers. Such written permis- sion must also be obtained before any part of this publication is stored in a retrieval system of any nature. Patent protection may exist in respect of circuits, devices, components etc. described in this magazine. The Publisher does not accept responsibility for failing to identify such patent(s) or other protection. The submission of designs or articles implies permission to the Publishers to alter the text and design, and to use the contents in other Segment publications and activities. The Publishers cannot guarantee to return any material submitted to them. Disclaimer Prices and descriptions of publication-related items subject to change. Errors and omissions excluded. © Segment b.v. 2006 Printed in the Netherlands NEW GEARED DC MOTOR JUST RELEASED! £4.99 - £*twme!y small package ■ Only 2 5cm lenglh 1 - H^h quality machined gear* - High torque - Operating VCftHQt ■ Perfect to r serves G roboto biii'piy ihr ben war buy e&nfiixrftencs from lhe be*i Mi suppatr. Mari PSP: I2.5D (Ff « UK PSP for vv* £20h fcA fof -Dur FREE 2006 caulc^u*. Qij-di* jprryftK ibMf fceyward: f&'StW a 'id fiM t j Junta IOHl Vi ntbr'.Ccr I W in Iv.Vr Fvj.id VY.iUpn on ■Thjrnr* fcirrry.PiTIJ 5RH Unified Kinqdn-m Tri: mtO ™ +4 Mi Flc I V Qrd&r and browse onfine &t: www r fa stcompon ents . ca uk fa stcomponents ine basf way lo buy cdmpcirienls Your price conscious PCB supplier EURO CIRCUITS Online Price calculation Online Ordering Online Order tracking Online 24/24H and 7/7D a la carte www.eurocircuits.com pooling for prototypes and small series from 1 till 1.000 pieces from 4 working days onwards up to 6 layers - wide range of technological capabilities - up to 20 layers - from 1 piece onwards - from 2 working days onwards pooling for series 250, 500 or 1.000 pieces medium series at prices of MEGA series MEGApool 6 elektor electronics - 1/2006 SERIAL COMMUNICATIONS SPECIALISTS Test and Measurement Solutions featured products = = = Bronze Prize Winner = = NASA Tech Briefs 2004 Products of the Year £125.00 DS1 Ml 2 USB Scope / Logger 2x1 MS/s Input Channels + waveform generator output. EasyScope & EasyLogger s/w included. Affordable CAN Bus Solutions CANUSB is a very small dongle that plugs into any PC USB Port and gives an instant CAN connectivity. This means it can be treated by software as a standard COM Port (serial RS232 port) which eliminates the need for any extra drivers or by installing a direct driver DLL for faster communications and higher CAN bus loads. CAN232 is a very small dongle that plugs into any PC COM Port, or any other RS232 port in an embedded system and gives an instant CAN connectivity. This means it can be treated by software as a standard COM Port (serial RS232 port) which eliminates the need for any extra drivers. Sending and receiving can be done in standard ASCII format. priced from £61 .00 (CAN-232) USB Instruments - PC Oscilloscopes & Logic Analyzers Our range of PC Instruments may be budget priced but have a wealth of features normally only found in more expensive instrumentation. Our DS1M12 and PS40M10 oscilloscopes have sophisticated digital triggering including delayed timebase and come with our EasyScope oscilloscope / spectrum analyzer / voltage and frequency display application software and our EasyLogger data logging software. We also provide Windows DLLs and code examples for 3rd party software interfacing to our scopes. OurANT8 and ANTI 6 Logic Analyzers feature 8/16 capture channels of data at a blazing 500MS/S sample rate in a compact enclosure. priced from £125.00 ( DS1M12 & ANT8 ) * £36.00 USB-2C0M- 2 Port Industrial USB RS232 Serial with wall mount bracket and DC auxiliary output 1 to 16 port USB to Serial Adapters With over 16 different models available, we probably stock the widest range of USB Serial Adapters available anywhere. We offer converter cables, multi-port enclosure style models in metal and plastic, also rack mount units with integral PSU such as the USB- 16COM-RM. Serial interfaces supported include RS232, RS422 and RS485. We also supply opto-isolated RS422 and RS485 versions for relaible long distance communications. All our USB Serial products are based on the premium chipsets and drivers from FTDI Chip for superior compatibility, performance and technical support across Windows, MAC-OS, CE and Linux platforms. priced from £20.00 ( US232B/LC ) UPCI Serial Cards Discover our great value for money range of multi-port UPCI serial cards. Supporting from two to eight ports, the range includes RS232, RS422, RS485 and opto-isolated versions. Our 4 port and 8 port models can connect through external cables or the innovative wall mounting COMBOX. priced from £21.00 ( UPCI - 200L ) EasySync Ltd 373 Scotland Street Glasgow G5 8QB U.K. Tel: +44 (141)418-0181 Fax: +44 (141)418-0110 Web : http://www.easysync.co.uk E-Mail: sales@easysync.co.uk Prices shown exclude carriage and VAT where applicable 7 INFO & MARKET MAILBOX Rejektor Under this heading we will occasionally publish circuits, ideas and suggestions that did not make it to full publication in this magazine for various reasons (like lack of space). Photoelectrical Oscillator This circuit of a photoelectrical oscillator (PEO) sent to us by Marcus Bindhammer is an example of an original design approach. Although we're actually looking at a variant of the astable multivibrator, remarkably there are no capacitors in the circuit. The time constant is not determined by a resistor- capacitor combination as would be expected but by resistance alone. The resistance is formed by a light dependent resistor (LDR) rather than a normal resistor or potentiometer. Oscillation, then, is obtained from the time constant exhibited by an LDR. Marcus described the function as follows. The PEO works without any kind of quartz crystal, R-C or L-C network. This oscillator is entirely resistance dependent, employing the slowness of light dependent resistors. Particularly with a fast reduction of the ambient light intensity, the ohmic resistance of an LDR will rise relatively slowly. Values for Dt of up to one second have been observed. The LDR presents a non-linear semiconductor resistance. It is usu- ally made from cadmium-sulphide applied as thin, meandering track on an isolating carrier and electrically connected between two copper electrodes. In response to incident light, electrons are released from molecules. As you will be able to imagine, photons will destroy crystal junctions, causing the number of free electrons and 'hole' to increase. The resultant increase in charge carriers causes the relative conductivity to increase. If the supply voltage is applied to the circuit, the output of the first NAND gate, IC1 .A (configured as an inverter) swings logic High (+5 V). This causes LED 1 to light and T1 to conduct. Next, the output of iCl .B goes High, LED2 lights and T2 starts to con- duct. Next, the output of ICl .Cgoes High while that of ICl .A goes Low. However, T1 still conducts (due to the slow response of LDR1). When T1 switches off after Dt, or the High level for ICl .B is reached, its output switches to Low (-5 V) and LED2 goes out. T2, too, conducts for a period Dt. When the High level is reached at the input of the third inverter, its output drops Low and the output of ICl .A, swings High. This means the cir- cuit has returned to the initial state, and the cycle recommences. With the component values shown, an oscillation frequency between about 5 Hz and 50 Hz is obtained, which is adjustable with preset P2. Preset PI enables fine adjust- ment, if necessary, and may be replaced by a 1 00-k£2 fixed resistor. The 4017 driven by the oscillator divides the fre- quency by 10. With some experimentation and patience the oscillator may be adjusted for the LED at the output to flash at a one-second rate, that is, 1 Hz. ■T. , - r Because LEDs produce heat and LDRs are temperature-depend- ent, the LDR-LED pairs are mounted in sealed aluminium tubes in order to aid their dissipation. A suggested construction of the LED/LDR optocoupler is illustrated in the second drawing. The author's photoelectrical oscillator is functional in a digital clock. As shown by the photograph of time readout, the clock is as unusual as the PEO, the time being indicated in binary format! For the sake of legibility however the display was designed to show hours and minutes as tens and units, just as on a regular clock. If you are interested in the design of the complete clock, the author's complete description of it includ- ing circuit diagrams and the display artwork is available as a free download from the Elektor Electronics website at www.elektor-electronics.co.uk, under Magazine, January 2006, Mailbox. The information is presented 'as is'. Finally, we should mention that there is as yet no indication of the long-term stability of the PEO. It is however safe to assume that the accuracy of the PEO clock is about the same as that of a mechanical alarm clock. If you need better accuracy, go for a quartz crystal oscillator or divide the 50-Hz mains down to 1 Hz to drive the clock. 8 elektor electronics - 1/2006 Wrong diode Dear Editor — in your article 'Slave Flash with Red-Eye Reduction' (July/August 2005) I found sensor diode D1 labelled as a type TLRH180P. Having looked up the device specifications, I noticed that this is just an ordinary (albeit red) diode, is it correct? Jeremy Deakin (UK) It is not , sorry for the misprint . D 1 may be a BPW40 phototransistor ; with its collector (at the bevelled edqe of the enclosure) con- RF wattmeter Dear Sir — a few days ago I sent you an email in which I described a problem with the Menu button in the RF Wattmeter (October 2002). The button simply does not what it's supposed to do. In the mean time I managed to find the solution. In the hex file on your website (and that of the author, OZ2CPU), add ress 2007h (configura- tion word) reads 3375h. Consequently bit 1 1 is set, causing the background debugger to be enabled. However, pin 27 (Menu but- RS232 component for Delphi 3-7 Dear Editor — I really enjoyed reading the Delphi for Electronic Engineers course (published over the previous ten issues, Ed.). However I noticed that lots of hobbyists still run into problems if they want to control a simple electronic circuit on the RS232 (COM) extended with CPortLib which in turn contains com- ponents Comport, ComDataPacket, ComComboBox, ComRadioGroup, Comled and ComTerminal. See Figure 1. Comport is the essential • ComPort WriteStr(Str) for transmission of data (Str for String); • Com Port. ReadStr(Str, Count) for receiving data (Str for string, Count is an inte- ger; Count indicates the num- ber characters read into Str). r * H If*.' 1 port, using a program to be written by themselves. For quite some time now, I've been using a 'component' that's freely downloadable from the Internet. This com- ponent, it seems to me, makes an excellent add-on to the course. Very easy to use, it is compatible with Delphi versions 3 through 7. Mr Dejan Crnila's highly interesting ComPort Library may be found at http:/ / sourceforge. net/ projects/ comport . It allows a program to be written for easy communication with equipment or an elec- tronic device via the serial port. The zip file cport3.0.zip contains two folders: Source and Example. The latter holds a number of examples like a ComPort Library and Mini Terminal, all with full source code files supplied. There's also a readme text file giving details on the installation of the various components. I would heartily recommend reading this file. Once you've installed the files in the right locations, the Component Palette is component, requiring only a few modules to be added to make up a com- munications program for transmission and reception of information. Settings FVut Baud rate Dci!q bi!s Stop bks Pfljtty flow conflrof COM! ......JH j 1200 T 3 Js d h d (None 3 jNnne 3 There's also a procedure called ComPort.ShowSetupDialog (Figure 2) which pops up a dialogue window allowing users to configure a number of settings like port, bau- drate, number of data bits, parity and flow control. This, by the way, is also possible with the component's Properties. Comled is another interesting component. It allows activity on the CTS, DSR, RLSD, Tx and Rx lines to be visualised. 2£J OJf Gance! The essential procedures include: • Comport. Open and ComPort. Close with their obvious functions; Figure 3 shows the example called ComExample, which is supplied complete with its source code listing and a number of other examples. It took me less than half an hour to control and read a Fluke 45 multimeter using my PC. A similar program for EEDTs model train, semaphore and points control should be with- in easy reach. *JQ]£J Ctt*l &nJ J P Ir^a- • * • 4 cl’j Dill Fj-.] r. 4 Kl LHd All in an, an interesting com- ponent to experiment with. H. Jorissen (Netherlands) 1/2006 - elektor electronics 9 INFO & MARKET MAILBOX ton), is then erroneously assigned to debugging instead of controlling the menu. Proposed solution: Change address 2007 to 3F75h and the problems are over (bit 10 is also set, but it is not implemented, see datasheet). p.s. I am using the Galep programmer so I do not have a menu to define the PIC con- figuration word. Robin Beaman (UK) Thanks for the tip Robin. Welcome to AutoTRAK AuteTRAX EDA Aim TFi-X'f I J ' 'l ijbli4-i-i )■> hiiuj jk-i^ip ill : n c nrL'ik'ih ■ Hiipkrm-ril I-aIj|> H pkii f kVFlillK I 1 *' fk iV 5 . ,- m L XTUT ^1 i-i.’ I i. lli>IH4 < 1 ■' l'i"* IV LUrt I kihutiliivi rule dim fl Ukv-al. lari iilp uucrfi^ 'T3i Li^IiLpjiiMi aru.l C^nfijiifr A L Lf-i I M > II V I JLI LV II .* •■'i hr ili>.'r >ckj rkfiV - jAMI-'TR-VX EDA. HJi^Vrt. Mi ■ uu .-■■ i ■>--*.• Ii:vrra'iii hm li j y ’ "-’l Jl !i«L’ Jl hr *■ Mn ■ 1 1. . .1 *i km f-r>4 i"*w' jn*l IV" fi ip h'li: WP HJilIl ■.'riE-.'li.'i-U-i. |"|i' twh Mil "* I|W M|Ih B. n — Wth ««■ fr*r i"'V uirmna.JP- i yl> in ^ui-p'lk 'kSc I J>A ll“*j hj.Hr jm 4JJAK -V - ■ b JIM M IM -HV iK y-^il #4 ^PHTKAX k I PA ivprr«rni ji ike rrj jiiSnr par [wrafarti jiU ■ pifiV <4ill BP- II kJtyAtlllMfJ ■ ■ ■!¥■ Ill lUllhTH 4XH? A ITk' lM-*: Ill'll ■ hijfl LMIIidl- Ti-MI 541 JH Kk-Ph | xri 1 II m ti | ki id k-' •L'wniR vid A uupthLA SC in him ■ PpTNI L priV'lA 111 \ ILiItpI k \ Prujrrl 'iIjMLkjif r iirnild IhiIjJK fri 1 * 1 Ei p um-ft ofAukiTKAX liD \ DOWNLOAD Replacement for BD91 1/912 Dear Jan — are you aware of direct replacements for the BD91 1 and BD912 transis- tors originally used for the 1 990 PowerAmp in your magazine? My suppliers tell me these transistors are no longer available. A van Niele (Netherlands) As far as we know the BD91 1 and BD912 are still being pro- duced. They may be obtained from , among others , Schuricht in Germany (www.schuricht.com) Free electronic GAD tools DVD ( 1 ) Dear Jan — what a terrific idea to enclose a free DVD with your November 2005 issue. I did however miss one program (or hyperlink): Autotrax EDA (currently at version 7.2) by II ja Kovacevic. The program suite may be downloaded from www.autotraxeda.com and requires about 40 MBytes on the hard disk. Franz Hrubes (Germany) Thanks for the pointer ; in the hec- tic of compiling and producing the DVD Autrotrax was somehow overlooked \ our apologies. Free electronic GAD tools DVD (2) Dear Editor — I received the November issue yesterday, and I found the article on electronic CAD tools very Corrections & Updates ESR/G Meter September 2005, p. 30, 040259-1. Resistor R10 is shown as 1 to in the circuit diagram and 10 k^l in the parts list. The latter value is correct, although not critical in this application. Readers are advised that an FAQ on the ESR/C Meter is available in our online Forum. interesting. I would like to add a comment though. One aim of the article is claimed to be to guide the average l-need-to-do-a-small- PCB-in-an-hour hobbyist to the most suitable tool. Well, if this is indeed the case then I think an important option has been left out: The DOS version of Protel's Schedit and Autotrax tools. These tools are now 'aban- don-ware' and can be down- loaded as such free of charge from Protel's website. www.altium.com/Community /Support/Downloads/ (look for "Freeware Downloads") An electronics company in Australia appears to be using these tools, and among other things they have offered to the public domain hi-res Vesa drivers, an updated footprint library for Autotrax, and a "print-to-PCX" printer driver. www.airborn.com.au/ layout/easytrax.html www.airborn.com.au/ layout/autolibl .html www.airborn.com.au/ ayout/ printdrv.html From a strictly professional point of view these program might be obsolete, but they are still perfectly suitable for getting a small design done in a jiffy. I use them myself as a hobbyist and I can only recommend them. Klaus Klug Christiansen Nice to hear from yu again Podcast converter Dear Editor — as someone who does not have a PC at home, I was wondering if you were considering a dedi- cated unit to enable ana- logue audio to be converted to a format suitable for down loading into i-pods etc.? I have been reading Elektor since the 1970s; always interesting and informative. Keep up the good work! Howard Thompson Thanks for the suggestion Howard \ we will study the feasi- bility. Mind the GAP Dear Jan — tube lovers like myself revelled at the photo- graph of the GAP/R tube opamp device at the start of your article on opamp selec- tion criteria (November 2005). Those who want to know more should have a look at the archive of 'AnalogDialogue' e- zine at www.analoq.com , look for 'GAP/R'. Roy Marks (UK) Mail Box Terms - Publication of reader’s correspon- dence is at the discretion of the Editor. - Viewpoints expressed by corres- pondents are not necessarily those of the Editor or Publisher. - Correspondence may be translated or edited for length, clarity and style. -When replying to Mailbox correspondence, please quote Issue number. - Please send your MailBox correspondence to: editor@elektor-electronics.co.uk or Elektor Electronics, The Editor, P.0. Box 190, Tunbridge Wells TN5 7WY, England. 10 elektor electronics - 1/2006 Lichfield Electronics www.LichfieldElectronics.co. uk 3 , " Digital Multimeter AM/FM Radio Shortwave Receiver A do-it-yourself test meter with volt, ohm & current meter And diode test. £16.99 A kit to make an AM/FM Buil d yourself a shortwave radio in an attractive case, receiver to listen to transmissions from around the world. £16.99 £9.99 Aoyue All In One Looking for the ultimate soldering equipment? The Aoyue 909 includes a temperature controlled iron, hot air rework gun and a 0-15V 1.5A PSU. £99.99 Aoyue Soldering Iron The Aoyue 936 is a temperature controlled soldering iron with a 240-360C range and a high quality stand and a spare ceramic heating element. £24.99 a : /// 1 2/9/3 V DIY PSU A Do-It-Yourself 12V, 9V & 3V regulated power supply. Plugs into a 110V or 240V mains supply. Suitable for up to 200mA. £17.99 Lichfield Electronics, The Corn Exchange, Conduit St, Lichfield. Staffs. WS13 6JU (01543) 256684 Postcard Radio A small crystal radio to build. Requires no soldering. Picks up AM radio stations. £6.99 ecial Christ Saver packs Available! See Website. Shop open Mon-Sat City centre location 9:00-5:00 ■«n miih 421 USB has never been so simple... •HL- i - H V y USB to YTL Serial Cable * Ss-Kt- 4" tfiff Etay -My IS flfve USB luppu'l to yuui 1 driOW- I CcMtr#dS 4 iJttrHtf m Ufcfff Of lO pm* < PC ccmrrurvcaln as a slandand smial devtcn- ■ Ai crcu by into alwfc nc-.idM USS plug * * Dc«1he^£^ (Grid. TX ihd + 5^ * Supple wth PC dmwiv *«an^0(i cod* unp cutonstf I Special Price ol only £9 S3 mcfuding VAT AVlT Research also supply: PC Bus Tool - Allows your PC to monitor and control the PC Blj& 1 InvflflVElblfi IW-i for dfrvfllQpflfS !*C Birt » Sea .wibfisi far I lH dnlaia lectromcs Home Automation This CD-ROM provides an overview of what manufacturers offer today in the field of Home Networking, both wired and wireless. Anton IfICVOR ISBN 90-5381-195-8 £12.95 / US$ 22.90 A about Home Automat on The CD-ROM contains specifications, standards and protocols of commercially available bus and network systems. For developers, there are datasheets of specific components and various items with application data. End-users and hobbyists will find ready-made applications that can be used immediately. The documents included on the CD-ROM have been classified according to communication media: mains (power line), coaxial cable, telephone line and wireless (RF). Order now using the Order Form in the Readers Services section in this issue. Elektor Electronics (Publishing) / Segment B.V. Regus Brentford 1000 Great West Road Brentford TW8 9HH United Kingdom Tel. +44 (0) 208 261 4509 See also www.elektor-electronics.co.uk 1/2006 - elektor electronics 11 INFO & MARKET NEWS & NEW PRODUCTS Computer-On-a-Stick with fingerprint sensor Swipe F i h§er Atmel Corporation and Fin- gerGear, the consumer products division of biometrics leader Bio- nopoly LLC, jointly released their Bio Computer-On-a-Stick™ USB Flash Drive now with fingerprint security. The Computer-On-a- Stick is the world's first bootable USB flash drive. The OS and all Desktop Software applications come preinstalled and occupy as little as 200 MB of flash mem- ory. The device also features Atmel's FingerChip® sensor for convenient and accurate one- swipe secure data access, and a large font LCD display for the ultimate user-friendly experience. The FingerGear Computer-On-a- Stick also includes an Office Pro- ductivity Suite, along with many of the most commonly used home and office applications. The Office Suite, developed by OpenOffice.org, is compatible with Microsoft Office™ applica- tions, including Word™, Excel®, PowerPoint®, and Outlook®. The Computer-On-a-Stick also bundles the increasingly popular Mozilla FireFox® web browser, as well as a PDF Creator, a zip compression utility, and an Instant Messenger which commu- nicates with Yahoo® IM, MSN® Messenger, AIM, and Napster®, among others. The FingerGear Bio Computer- On-a-Stick features both public and private partitions. The pub- lic partition is accessible on any Windows®, Linux®, or Macin- tosh® PC with a standard USB port, thus making it easy to share non-sensitive files. The encrypted private directory can only be accessed when booting from the device, by using a login password or fingerprint authen- tication. Data is protected with the help of Atmel's FingerChip due to the following combina- tion; small size, low cost, high accuracy, low power consump- tion and portability for proven system security benefits. The Bio Computer-On-a-Stick includes a USB 2.0 extension cable, a neck lanyard, and a mini boot CD. The device is bootable from any PC using an x86 processor, which can be found on nearly every Windows and Linux desktop shipped over the past 5 years. Recent PCs allow the user to configure their system to boot directly from a USB Flash Drive without the need for a CD. The Computer- On- a Stick Standard and Bio- metric Editions are currently in stock and shipping now. The Computer-On-a Stick pricing starts at only $99, and the Bio- metric Edition starts at $149. (06700 1 - 3 ) Further information from: www.atmel.co/products/ Biometrics www.fingergear.com Create Electronic Utility Meter Applications Microchip announces its new online Utility Meter Design Cen- tre. This comprehensive web site provides engineers with techni- cal tools and resources needed to simplify the design process and speed the design cycle for creating accurate, reliable, and low-cost utility metering applica- tions, including energy, water, gas, and heat meters. An "Introduction to Metering" section supports those who are new to electronic design, offer- ing an overview of the migration from mechanical meter designs to electronic-based solutions. The Design Centre also features charts that take the user through all of the building blocks and considerations in creating a util- ity metering design, whether it is gas, water, heat or power. The website also offers complete access to all of Microchip's metering application notes, ref- erence designs, and other tech- nical documentation addressing critical design features, such as accuracy, low cost displays, low power consumption, remote communication and billing. Specific products include the new MCP3905 and MCP3906 - stand-alone energy-measure- ment integrated circuits that out- put average and instantaneous real power. These analogue front-ends can also be paired with a microcontroller to pro- vide highly accurate solutions for single-phase®PIC electronic energy-measurement in residen- tial power meters and industrial applications. Examples of ideal companion devices include the PIC 1 8F8490 and PIC16F917 series of 8-bit microcontrollers. Both device families offer Flash program memory, low power consumption, and integrated liquid-crystal-display control with a variety of features and package options, for high per- formance, cost-effective meter- ing applications. Microchip also offers evaluation and reference design boards specifically tailored for the cre- ation of metering designs. (06700 1 - 3 ) Further information at www.microchip.com/meter 12 elektor electronics - 1/2006 1 2- and 1 4-bit ADCs break the 1 00 mW power barrier Xignal Technologies AG has launched the industry's lowest power, 14-bit and 12-bit, 40 MHz analog-to-digital converters (ADCs). Based on the company's recently announced break- through in Continuous Time Delta Sigma (CT ' -*V k n ■' Easy-PC version 9 just gets better Winning accolades the world over, Easy-PC for Windows V9 is another major milestone in the evolution of this extremely popular software tool. Try a demonstration copy of Easy-PC and prepare to be amazed at the power, versatility and remarkable value for money. Version 9 fetaures ■ 3D Board View ■ New Win XP User Interface ■ Reverse Engineer SCM from PCB ■ Track Fattening ■ Interactive Schematic Routing ■ New Sliding Toolbars ■ Component Clearance Checks ■ Alphanumeric Pin Names Plus many more exciting features Fully integrated Schematics & PCB layout in a single application complete with forward and back annotation. Design and rules checks at all stages ensure integrity at all times. Professional manufacturing outputs allow you to finish the design process with ease. Stop press... Stop press... Stop press... Stop press... Easy-PC imports Eagle files as well asTsien Boardmaker 2 files call for a brochure, prices & CD on +44 (0) 1684 773662 or e-mail sales@numberone.com you can also download a demo from www.numberone.com Number One Systems - Oak Lane - Bredon - Tewkesbury - Glos - United Kingdom - GL20 7LR UK Microsoft® Windows®XP, 2000, ME, 98, Windows NT® PicoScope 3000 Series PC Oscilloscopes the PiccS cfl pc 3000 series o^citloscdp^ are tbc latest offering's from the market; leader in PC tiSCillti£ copes combining high handw-idths with large buffer memories. Using the latest advances In electronics, the oscilloscopes connect to the USB port of any modern PD, making full use of the PCs' processing capabilities, large screens and familiar graphical user m He liners * High perform a net : 1QG5 * sampling rate &. 200MHz bandwidth * 1 MB buffer m £ mo ry - High USB interface * Advanced display & trigger modes * Compact S portable ■ Supplied with PicoScope & Pico Log software Tel: 01480 396395 www. picotech .com/sco pe3 2 2 ■ nwKi'Vhi |UP-|'| tflO.1 J . ItkKi IOOMKi hM.'m 1IMIMI5 ■ i(4At BOfWJiS* ~ tihi^ u Stilt iitr e.mi k vSmjh, 2 SiTrCn jf , L ■! !>■■■■" S* *#■ p« IntvUilhlN Em * Hi *t.- 0 1* Si VKI: IsbVn- ca L'lK Cn, tmminr Mu ihith ;sfcs IK^U UStKl 0UAH1 1 iv-vn-hliJ Technology Limited 1/2006 - elektor electronics 15 KNOW-HOW ELECTRONIC ARCHAEOLOGY CMOS ICs in static protective tubes. Be careful, the A gem and a rare find, this Philips 1 966 databook. Valves, surprisingly, are still around in good type labels are handwritten so the devices are not The smell alone beats any datasheet from the quantities. If possible go for new, boxed types genuine surplus from a distributor, test house or Internet, if you can find it in the first place for a from reputable suppliers. With some experience, manufacturer. That's not to decry the value, though. device that's 40-ood years old. RCA, Philips, Mullard, Volvo, Siemens and GEC cartons can be spotted from a mile. Part Mining what's junk to some, is gold to others Jan Buiting It's been said that within a few years the home constructor will be totally dependent on salvaged electronic equipment for even the commonest of parts. Others have faith in the combined power of the Internet and two or three mail order giants remaining after an slow but certain market shakeout. Whatever the outcome, now is the time to step into action if you are after that one elusive part for your project or repair job. Concentrate on What and Where, surf, dig, unearth, bargain and rummage around. The Old Curiosity Shop may be closer to you than you think. Vibrators for portable or semi-mobile valved equipment are often dead or worn out. Even new ones may not 'start' owing to internal contact oxidation. Be sure to know the voltage and base pinout. At just one pound, this discarded cassette recorder was good value for its 6 V DC motor, electret microphone, audio playback amp, loudspeaker and a few PCB mount jack sockets. These large electrolytics rated for 63 V are NOS and may look great for your restoration work on a 1 980's PSU but be warned — their ESR was found to be poor due to dried out electrolyte inside. 16 elektor electronics - 1/2006 Exact replacements for potentiometers for front Heatsinks are (1) expensive and (2) often at the A fine specimen of valuable industrial automation panel mounting — impossible to find because rear of equipment so who cares if it has a few surplus, this hours counter unit. Apparently it was they're equipment specific in most cases. holes drilled by the previous owner? The small one never used. The operating voltage is uncertain and Her are a few high-spec encapsulated pots with shown here came with a free BYX-something may require some careful dust ingress protection. power diode attached. experimenting to establish. The days are long gone when you could pop out on a Saturday afternoon, run down the street to the local elec- tronics store and get two resistors and a trannie to finish your experiment or repair job before teatime. Since the mid-1980s, electronic parts retailers have gradually disappeared even from mid-size cities. Initially, it seemed that some closed their shops and went ‘mail-order’ but only a few have sur- vived and now find themselves strug- gling against largely anonymous mail order companies originally set up to supply professional users and the industry. That is not a problem in itself, after all, the parts can still be obtained, but with a few exceptions remaining there’s no longer a counter, a shop owner to ask advice from, books to browse or a fellow enthusiast to chat to in the shop while you’re waiting your turn (and there’s a lot to learn from that!). Industrial progress About 30 years ago, devices like the humble BC107 transistor had a prod- uct lifetime of at least 10+ years and would be generally available for a few pence from five shops within 20 miles radius. Today, we’re talking of lifetime in terms of months rather than years and designers tell us that certain ICs are declared obsolete before you can finish reading the colourful brochure. Apparently, in such cases the manufacturer has long since had an order for the product that’s tall enough to close the produc- tion line and move on to the next device to turn into hard cash. Today, production lines are shut done rather more efficiently than, say, 25 years ago, when it was quite common to have huge ‘overshoot’ stocks or ‘mislaid’ back orders. And that’s exactly where we are after: NOS (new old stock), NIB (new in box) and HUO (home use only). What to look (out) for Unfortunately, there’s no such thing as a guide to finding just your compo- nent from the tens of thousands devices already declared obsolete over the past 60 years or so. A lot of valuable components get thrown away when you would have paid a good price to get your hands on just one of them. In the case of integrated circuits, you need to be aware of manufacturer- specific prefixes, infixes and suffixes that forever seem to clutter up the functional type code. One famous example is an IC identified by some- one as “an MC14093BC-M04/85, must be very rare”, when this is just Motorola’s way of selling you an industry standard device like the CMOS 4093 that may lie dormant in your very own junkbox. The same with, for example, an UMC62LC64- 30NBCA, which with some decoding translates into a plain vanilla CMOS 6264 64 kbit static RAM. While there are applications that will only work with just one specific IC installed, most likely things on the hobby desk will also function if you have a rea- sonable substitute available from a competitor. Contrary to popular belief, PC junk has little to Anything that's' large and bulky is now generally Classic moving coil meters like these give a offer in the way of useful parts. This serial I/O shunned by buyers. However at 21 V, 1.2 A this nostalgic, professional look to equipment. The thing board might be persuaded to give up its brand new mains transformer has just the right about these meters is that you must be sure of 1 8.432MHz UART xtal, DIP switch specs to go into your first homemade benchtop their f.s.d. current specification — there's likely a and sub-D connectors. PSU. Add two feet and Bob's your uncle. shunt or series resistor inside. 1/2006 - elektor electronics 17 Save the 1C! "A short guide to removal and re-use of soldered integrated circuits" contribution by Jeroen Baars A commonplace occurrence in the world of electronics that's equally applicable to the hobbyists and the high-end developer (confess it!): That One 1C You've Been Struggling To Get Your Hands On For Years — there it is, in full view BUT securely soldered on a cir- cuit board. Desoldering the chip is not usually an option at it often results in a 'dead' 1C in your hands and an hour or so wasted. So, faithful to the saying "he who dares, wins" but also wary of another motto which goes "there's no crying over spilt milk", we present a few tips, mostly in pictures, that will enable you to 'un-board' an 1C without damaging it, and to happily re-use the chip in your own project. The first method pictured in photographs A through D employs the fact that print- ed circuit board tracks and pads used with SMD (surface mount devices) are often very thin and can be made to dislodge with no effort at all. This, by the way, is often the cause of board malfunctions! Of course, when applying this method you have to bear in mind the subtle interaction of forces — after all, if the tracks or pads do not come off the board surface the 1C will 'die". With really rare or expensive ICs, it's often worthwhile to practice on a 'lesser specimen" elsewhere on the board. Although your chances of success are pretty good, the method is a last resort. With some practising, even smaller ICs can be removed successfully and electrically intact too! In general, try to lift the ICs off the board as vertically as you can, as that minimises the force exerted on the pins. Do not prise or bend — it is a sure way to failure. Provided you remove the track and pad debris from the device pins and do the odd bit of straightening and cleaning, PLCC-housed ICs salvaged in this way can be inserted in a socket again without problems and SMD DIL ICs are ready for soldering the second time round — on your own board! Method #2 is for DIL (dual in line) ICs. The 1C may be cut loose using extremely sharp precision cutters (photograph E). The cut- ting edge method results in an 1C with... yes, much shorter pins, which subsequently need to be redressed a bit. Now, for yet another method that looks crude at first blush but actually works better than cutting. Not for the faint-hearted: hack- ing! Use a chisel to carefully dislodge the pins. The PCB should be firmly secured while the force of the mini chisel should be used with care. If necessary, work pin by pin (see photographs G and H). The method effectively turns this type of 1C into a kind of oversize SMD chip (photograph I). The final tip is to attack the 1C pins with a scalpel or hobby knife, but this may not always work as some 1C pins are simply too thick. F Ughh, what colours! Dappled, two-tone coloured Sensors are in great demand simply because they Switching transistors and power transistors from a wire like this was common in the 1 970s. This are specialist components and expensive to buy as Bargain Lot. The only thing you have to do is picture was only taken to test our photographer new items from manufacturers. research the type codes to deduct the electrical and printers. What do you think? Don't tell the seller — these two Figaro gas functionality. Do not be afraid of a BCX863ABC. sensors are definitely a rare find. Avoid unlabelled devices. Broadly speaking, in the case of inte- grated circuits, the critical factors to know are: 1. the device may be a factory or test- house reject! 2. device supply voltage; not generally detectable from the type number alone. 3. device access speed; (-10 or -15 does not necessarily mean 100 ns and 150 ns respectively!) 4. device family like C (CMOS), low power CMOS (LC), low voltage (LV) etc. Essential to know for your interfac- ing. 5. confront ‘expert sales staff’ with actual samples of your defective devices, and present a datasheet. 6. do your homework: understand the functional type code and invest some time in finding possible equivalents. Be very cautious about ‘scoop pur- chases’ of new, tube-packaged ICs especially of the memory chip type (EPROMs, EEPROMs and Flash devices) as there is a lot of rejected and imitation stuff around (see also Ref. 1). Also, beginners should not buy ‘good as new’ ICs from dubious Inter- net sources. Where to look The next step is to discover where you stand a fair chance of finding the elu- sive part or equipment — assuming of course it’s no longer listed by Dixons and the likes. That brings us to our first possible source. Shops from the past Given the subject matter of this article, older readers of this magazine have an advantage because they may remem- ber retailers that seem to have van- ished simply because their adverts no longer appear in the electronics press. The good news is not only that some of these may still be around, but they will also happily sell you a one-off older device (like a Germanium power tran- sistor) they no longer actively adver- tise. Four examples relative to this magazine are Grandata, Cricklewood, Viewcom and Electrovalue. Give them a try, you’ll find that although stocks are much smaller these days, and there may no longer be a shop to visit, staff are generally much more knowledge- able than the temp on the phone at Mail Order & Co. Usenet Why not go underground and tap into the largest network of electronics hob- byists in the world? It’s probably wise to first set up a new, temporary email account as unfortunately there’s a lot of flack, off-topic drivel and spam in these areas. The best place to begin asking around is probably alt.electron- ics. components, but do use Google’s Usenet search function to find other groups with similar coverage. Internet Be bold for a change and type the com- plete part number into Google’s search box. If necessary, make the search nar- rower by adding words like ‘IC’, ‘obso- High voltage solid capacitors look bulky and dated in this day and age of low-voltage miniature portable equipment. For supply decoupling purposes, the value is not terribly important, so why not use that 0.068jiF / 250Y block capacitor? Displays are a source of hot debates and a lot of research because the manufacturer is never known so no-one ever seems to know the pin functions. These two beauties contain LED elements and were carefully salvaged from a 1 980s alarm clock. While most publications including Elektor now seen to assume everyone's on 1 % metal film, there are still a number of good reasons to have a small stock of carbon resistors. For one thing, you can read the value in the blink of an eye! 1/2006 - elektor electronics 19 KNOW-HOW ELECTRONIC ARCHAEOLOGY Just a curiosity, this bundle of wires that never Germanium transistors with their funny AC and OC Intact equipment of the NIB variety! Watch 23cm made it to the wire loom stage. The individual type codes have a ring of nostalgia around them. A amateur television (ATV) or Hotbird channels using wires are multi-strand, highly flexible and colour few have been rescued from the landfills. Scratch this analogue satellite-TV receiver. But then, at a coded. Might reach Flog It status a bit later. off the black varnish on some of them and you fiver you get a nice display, remote control, switch- have a photo sensor. mode PSU and a bunch of connectors. lete’, ‘old stock’, ‘electronic’, ‘compo- nent’ or ‘part’. Unfortunately, eBay links among Google search results may be out of date but with some effort the seller may still be contacted (through ‘‘View seller’s other items’ or similar). You’re not necessarily in luck if you find an active eBay link listing the component you’re after, the intricacies and pitfalls of eBay trading are how- ever beyond the scope of the article. Radio amateur markets, rallies, car- boot and jumble sales Highly recommended, even if you do not have affinity with RF. Almost all items pictured in this article were obtained at radio surplus markets open to the general public. The range of goods offered on these semi social gatherings now extends well beyond transceivers, morse keys and anten- nas. Today’s markets are a treasure trove for anyone with an active inter- est in electronics, reverse engineer- ing, experimenting and modding. Fortunately, PC junk now seems to have vanished from most rallies, the once hopeful sellers of complete office networks having discovered that the value is nil in these devel- oped countries. The local Council’s Waste Disposal Centre This source may not be viable in all cases and success will depend on your ability to get friendly with staff willing to give you a ring if an interesting bit of equipment arrives. Companies Many companies these days will hap- pily part with equipment ‘surplus to requirements’ as it may save them a penny or two in waste disposal fees and administrative work. Here, too, you need to know the right persons. On boards and in equipment Provided the price is reasonable, go for that bulky piece of equipment or circuit board if only for the one com- ponent you’re after. Many spoilt hob- byists still believe parts should be supplied new and individually pack- aged, and give up if they can’t find them like that. Actually, with a little effort, five off of the very same part, say, a Flash memory chip, are just waiting to be removed from a board picked up for one pound — see the Save the IC! inset. Conclusion Successful part mining depends on creativity, initiative, unconventional methods and general skills in electron- ics developed over the years. As with real mining, the resources are scarce, waste is high and competition is fierce if you do not protect your sources. The art is expanding rapidly however and not just for the thrill of striking ‘gold’ — very common parts are bound to go underground soon. ( 050320 - 1 ) Reference: 1 . Bogus Electronic Parts, Elektor Electronics September 2004. 4004 and 8008 MPUs hit eBay Old microprocessors are now among the most spectacular items sold on eBay, at least for those with an interest in electronics and early computing. Intel processors like the 4004, the world's first microprocessor from the early 1970s, and its 8-bit follower the 8008 seem to have reached the hype status. Original D4004 chips from Intel as well as second source devices like National Semiconductor's INS4004D pop up every now an then, fetching prices between 100 and 600 US dollars depending on the exact device specification and packaging (the ones with gold-plated pins and ceramic cases are the most valuable). Besides selling these historic chips on eBay, Chipscapes also kindly provides links to background infor- mation on these golden oldies. A while ago an original chip topology chart of the SC/MP microprocessor was auctioned off at 650 dollars. Unfortunately here at Elektor we are not aware of any mass-produced equipment with a 4004 or 8008 inside; else we could start part mining. Perhaps our readers can help in this area, suggestions and pointers welcomed. The craze for early Intel processors has spread across other brands, too, like early Motorola 6800s and even RCA's 1 802, the first microprocessor to actual- ly leave the earth and go in orbit. 20 elektor electronics - 1/2006 QUASAR electronics □uAiar Electronics Limrled Posiag* 4 Packing Opucn* {Up ta ?Kg gms* wtpighn UK Standard PO BOm E935 StoftfcHd w *h«wr* -£ltt UK BfafritamJ Htii Bay Delivery ‘£4 05. CM2 3 4 WP. United Kingdom i w tsu i - w ». n«. M Kfc« - r Mr T el: u&70 W> a£CI spi >■ cradilidebil cards. Hah* tbuju.UPO * payabla Fee: 0171 277 272B in Quaur Hao/onlc*. PHcw Include ir.f% VAT. E-mail: sa lc“s@quas a relectronics.co m c jH now for mir FREE CATALOGUE *Ui doi»ili □! mm 300 kin, We br WWW, OuaSarEleCtreniCS .CGffi P«J»Cte> nwdulrt a nd publlcaHo-ns , Dia counts far bulk quantities. ED IP il * CREDIT CARD SALES 17 7169 Ho! Ho! Hot Christmas 2005 is on its way BUT DONT PANIC!! We have some fantastic |fft ideas for young *» Shod Wa^KK?£4 $5 Order Code EERKSWKT Cryslal Radio KH - £5.35 Order Code ERKWfKT 500 nt ONE £134 35 Order Cod* EPL5O0K.T E l se ironic Belt £» M Order CodeEMEBKT Electronic Motor - £I J£ Order Code 1AKEMKT Generator - £6 M Order Cude EAKEOVCT Roqoii Alarm - £*Jf Ordof Cade EAKRAKT Hand Held Metal Detector - £9 .15 Order Cdde EU4D*mf Metal Delector - £9 35 Order Code ELMDKT Wood #.n Kite Future engineers can Seam about Ibe opera- tion of transmissions steered through fears ur pulleys. Easy to build, no glue or sol- dering required. Autorneth - £12,4 S Order Code C31 -46SKT Cdniennech - £i I f 5 Order CodtC21-H4KT Traltimech - £12.94 Order Code C31-fiMKT Ruitomecti -£U2.ff Order Code C21-I43KT Slegont icn * £12.95 Order Code CZ1402KT Tyran notn ec h * £l20C Order Code C21401ICT Failiw* Blectrrtntc Pro|art Kilt Musical LEO Jingta Balls -£tf 9S Order Guile 1175KT Hi -tech MiCroCOrtlTDlier Mu Id -Coloured Cirri s Imas Tree ■ £11.94 Order Code 3103KT www.quasarelectronics.com TECHNOLOGY LEGISLATION The Battle against Electronic Waste Protecting the environment with RoHS and WEEE Jens Nickel The EU has taken two significant steps in the fight against toxic elec- tronic waste. In this article we look at what 'RoHS' and 'WEEE' mean for equipment manufacturers, distributors and users. 'WEEE man' was assembled by a London designer from the appliances thrown away by the average British citizen during his lifetime. Source: www.weeeman.org All electrically-powered devices, from washing machines and PCs to electric toothbrushes, eventually come to the end of their useful life. Until now, most have then ended up as household side waste or have been fly-tipped. This makes for an immense burden on the environment: the quantity of electronic waste is estimated to be growing three times faster than that of other household waste: one only needs to think of how many PCs, hard drives and printers one has ever owned. Germany, for example, has produced two million tonnes of electronic waste this year: taking all the countries of the EU together, the total is over six million tonnes. Furthermore, many electronic devices also contain toxins such as lead, mercury or cadmium. Since electronic components are often imported and 22 elektor electronics - 1/2006 Proscribed toxins The following substances may only be present in extremely low concentrations in any materials used to make RoHS compliant components or appliances [1]. Substance Lead (Pb) Cadmium (Cd) Mercury (Hg) Hexavalent chromium (Cr(VI)) PBB, PBDE Concentration in % by weight max. 0.1 % max. 0.01 % max. 0.1 % max. 0.1 % max. 0.1 % used in solder, glass paints, plastics, anti-corrosion coatings switches, sensors anti-corrosion coatings flame retardants in plastics and printed circuit boards Cadmium and hexavalent chromium (chromate ions) are carcinogenic. With prolonged exposure cadmium can lead to dam- age to bones and the kidneys, while lead and mercury can lead to damage to the nervous system and other organs. Heavy metals are accumulated in the food chain. PBBs (polybrominated biphenyls) and PBDEs (polybrominated diphenyl ethers) are related to PCBs (polychlorinated biphenyls) and dioxins. These substances are carcinogenic and damage the liver and other organs. Every regulation has its exceptions: mercury is permitted in fluorescent lamps in specified maximum quantities; lead can also be used in glass, in certain solders and as an alloying element in steel (see annex to the RoHS directive [1]). For exempt appli- ances, see the text box 'What is an appliance exported, and much waste is transported across national boundaries, it is necessary to approach this problem at a European level. In 2002 the European Parliament and the Council of the European Union, representing the national governments, enacted two directives, 2002/95/EC and 2002/96/EC, which became known as 'RoHS' and 'WEEE 7 [1][2]. RoHS, or the 'restriction of the use of certain hazardous substances in electrical and electronic equipment 7 , is a broad ban on toxins such as lead, mercury and cadmium in electrically-powered equipment. The directive on 'waste electrical and elec- tronic equipment 7 puts liability on the manufacturers of such equipment even after purchase. The manufacturer must mark the appliance, take the appliance back at his own expense, and then recycle it as far as possible and prepare the residual waste for disposal. Lead-free, please Of course, regulations like these cannot be introduced overnight. The European directives must first be incorpo- rated into national law: for the RoHS directive the dead- line for adoption is 1 July 2006. From this point on no electrical or electronic device may be put on the market Figure 1. Waste printed circuit boards have until now contained toxic heavy metals such as cadmium and lead. This will change under RoHS. 1/2006 - elektor electronics 23 TECHNOLOGY LEGISLATION What is an appliance? Almost all electrical and electronic appliances will have to be taken back in the future by their manufacturer. Appliances are defined by being powered by electric current or by an electric field in their chief function [ 1 ] [2] . The appliance may not be a part of a larger device which is not an appliance for WEEE purposes. There are ten WEEE appliance categories and various exemptions. All clear so far? With the following alphabetical list of examples we will try to shed a little light on the question. r “ — — — — — — — — = — ■ Appliance WEEE? Remarks n 1 Battery (separate) no may fall under other regulations 1 Car radio no part of the car (which falls under different regulations) 1 ■ Cash machine category 1 0 'automatic dispensers' 1 ■ Dialysis machine category 8 'medical device'; RoHS does not apply to this category i ■ Disk drive category 3 device with independent function, 'IT and telecommunications' i 1 Drinks machine category 1 0 'automatic dispensers' ■ | ■ Electric drill (hand tool) category 6 'electric tools' 1 g Electric drill (large industrial machine) no large fixed industrial tools do not fall under WEEE 1 | Electric hob category 1 'household appliance' 1 1 Electrically-controlled gas hob no primary function is cooking, which is not electrically-powered 1 I Electronic component 1 only RoHS not an appliance for WEEE purposes, since it has no independent function 1 1 Fluorescent tube 1 category 5 'lighting equipment'; to remain in ordinary waste for private households 1 1 Fruit machine category 7 'toys and sports equipment' 1 Iron category 2 'small household appliance' 1 | Lightbulb only RoHS to remain in household waste 1 ■ Multimeter 1 category 9 'monitoring and control instruments'; RoHS does not apply to this category l 1 I PC category 3 'IT and telecommunications' I 1 Radio category 4 'consumer equipment' (but not car radios!) 1 | Refrigerator category 1 'household appliance'; refrigerators will be collected separately 1 1 Smoke alarm 1 category 9 'monitoring and control instruments'; RoHS does not apply to this category 1 1 1 Solar array (roof-mounted) no does not fall into any of the appliance categories 1 Solar-powered toy 1 category 7 electrically-powered, and hence WEEE applies: 'toys and sports equipment' 1 1 ® Soldering iron category 6 'electrical tools' 1 Teddy-bear with sound effects no primarily a toy which also 'functions' without electricity 1 | Telephone category 3 'IT and telecommunications' 1 ■ Television category 4 'consumer equipment' i I Toaster category 2 'small household appliances' ■ | ■ Transformer (high voltage) no WEEE only applies to appliances up to 1000 VAC or 1500 VDC | 1 Washing machine category 1 'household appliance' 1 1 Weapons computer ii — B — — — — — — ® no military devices are not covered by RoHS or WEEE 1 j which contains any of the materials proscribed by the RoHS rules. Exactly which substances are affected is described in the text box. To keep the technical diffi- culty of purifying and analysing materials to an eco- nomically feasible level thresholds have been set, below which a material will be deemed 'free' of a certain sub- stance. For example, solder which contains less than 0.1 % lead by weight will be considered (for the pur- poses of RoHS) lead-free'. These limits are applicable to all 'homogeneous' materi- als from which a device is made. (A 'homogeneous' material is one which can only be further decomposed by chemical rather than mechanical means.) Examples are the metal used for an enclosure, copper printed cir- cuit board tracks, solder, the plastic housing of a compo- nent and so on. It is therefore necessary that not only the equipment, but also the boards and components used in it, are RoHS compliant. If a single chip or resistor con- tains more than the allowed amounts of lead or one of the other proscribed substances, the whole appliance may not legally be sold. Manufacturers of appliances should therefore ensure that their stocks of components are properly RoHS compliant. The well-known distribu- tors are offering considerable support in this [3]. Non- compliant components and printed circuit boards may, however, be used after 1 July 2006 as spare parts for, or for repairing, appliances which were sold before the critical date. Green production Production methods must also be RoHS compliant. The most important new restriction is that circuit board mak- 24 elektor electronics - 1/2006 ers and equipment manufacturers must no longer use sol- der that contains lead, which has a particularly low melt- ing point (1 83 °C). Higher temperatures are thus required in soldering. Unfortunately it is not possible to deduce from the fact that a component is declared as 'RoHS compliant' that it can withstand higher soldering temperatures! RoHS compliance means only that, for example, the coating on the leads of a component is lead-free tin. There is much information on the Internet on this problem, including specialist reports and empirical tests [3] (see Figure 2). The well-known distributor Far- nell recommends the use of a lead-free tin-based solder containing silver and copper, with a melting point of 2 1 7 °C. It is worth pointing out that joints made with RoHS compliant solder do not have the same sheen as joints made with a solder containing lead, and so it is harder to identify dry joints. For end users there is no change. If you build a device solely for your own use, it is not 'on the market' and so older components and solder containing lead can still be used. Compulsory registration The switchover to RoHS will be a considerable amount of work for all equipment manufacturers. New parts will have to be introduced, and production processes changed to suit. Manufacturers will also have obligations long into the future from the WEEE directive. Each will now be responsible for an appliance from 'cradle to grave'. To police this, individual EU member states have drawn up registers of manufacturers. Each country decides separately where and by when registration is required (see text box and [5]). Any firm selling equipment produced by another manufac- turer under their own brand is also considered a 'manu- facturer'. Also, anyone importing an appliance to sell it within the country, or who sells an appliance to a cus- tomer in another EU state (including via the Internet), is also a 'manufacturer' for the purposes of RoHS and WEEE. Distributors should also be aware that if they sell an appliance made by a non-registered manufacturer they themselves will automatically acquire these obligations! These obligations are considerable, since the manufac- turer is responsible for the taking back, recycling and dis- posal of its appliances. Imagine the work involved when every shaver and every computer mouse has to be sepa- rately returned to the manufacturer! Various recovery sys- tems are being put in place in the EU countries. Regula- tions coming into force [4] distinguish between commer- cial owners of old equipment from private households: in the case of a business, manufacturer and owner can agree contractually on the recovery of old appliances. In cases of doubt, the owner is responsible for appliances purchased before a threshold date; 'newer' old appli- ances must be disposed of by the manufacturer. A full container: now what? Appliances bought by end users are in any case the responsibility of the manufacturer, whose products must be marked with a crossed-through wheelie-bin symbol. By 24 March 2006 electronic waste will be collected sepa- rately from the main household waste in Germany: collec- tion points for private households are being set up, and recovery schemes are being organised. The arrange- ments are similar in the Netherlands and Austria [5]. Electronic waste is temporarily stored in large containers, Figure 2. Many component distributors have set up special RoHS web pages. crudely sorted: IT, telecommunications and consumer electronics devices end up in the same container, and a separate container is reserved for refrigeration appli- ances. It is the manufacturers' responsibility to set up and take away these containers. Of course, the items in one container will not all be of the same make. Many countries are considering a sys- tem where all the manufacturers make proportional con- tributions. If a manufacturer brings goods onto the mar- ket, he must report the quantity (in kilograms) to a cen- tral point. Full containers are then allocated to appliance producers in proportion to these quantities. Alternatively, the proportion can be arrived at statisti- cally. Full containers must be taken away by the manu- facturer or by a disposal company. Recycling to the fore The EU has specified ambitious recycling quotas for the treatment processes described below, which will come into force by 31 December 2006. Large appliances such Figure 3. Electrolytic capacitors are a problem for waste disposal. Older types can contain harmful substances such as PCBs. 1/2006 - elektor electronics 25 TECHNOLOGY LEGISLATION Adoption in EU countries All EU member states are obliged to incorporate the WEEE and RoHS directives into their national legislation and set up take- back systems. Here are a few examples (see [5]): United Kingdom: Registration will take place in January and February 2006. The responsible authority in England and Wales is the Environment Agency (www.environment-agency.gov.uk), and in Scotland it is the Scottish Environment Protection Agency (www.sepa.org.uk). Manufacturers' obligations are expected to come into force in June next year. Germany: The 'ElektroG' law was passed in Germany, obliging registration from 24 November 2005 and the taking back of old appliances from 24 March 2006. Manufacturers have to register on the Elektro-AItgerate Foundation Register (www.stiftung-ear.de/index_eng.html), which was founded by BITKOM (Federal Association of the Information Industry, Telecommunications and New Media) and ZVEI (Central Association of the German Electrical and Electronic Engineering Industry). City, municipality and district authorities collect electronic waste from private households, and the manufacturers are responsible for disposal in proportion to their market share. Distributors may also voluntarily take waste back and recycle it. Austria: WEEE and RoHS have been incorporated into various legal instruments. Since 30 September 2005 all manufacturers have been obliged to register with the environment ministry. Household electronic waste is collected by local authorities and the producers make a per-unit payment. Manufacturers may also set up their own take-back systems. Any distributor with a sell- ing floor area of greater than 150 m2 is obliged to take appliances back. The system has been in full operation since 13 August 2005. France: The decree enacting WEEE and RoHS was made in July 2005. Manufacturers register with the Environment and Energy Management Agency ADEME (www.ademe.fr/anglais/vadefault.htm), and the deadline will probably be set at June 2006. Manufacturers must pay a proportion of the costs of public disposal of household electronic waste corresponding to their market share. "he Netherlands: The 'BEA' legislation on electrical and electronic appliances came into force on 13 August 2004. Manufacturers must register by 13 August 2005 with two private registrars: the Netherlands association for the disposal of 'Metalectro' products (www.nvmp.nl) and ICT Milieu (www.ictmilieu.nl). Electronic waste from private households can be left at collection points in cities and communities; this must be 'at least free' for citizens. Manufacturers are obliged to take back this waste without charge. Appliance producers may also set up their own take-back systems. Figure 4. The EU has established ambitious quotas for recycling electrical appliances: for televisions, for example, the quota is 65 % by weight. Source: German Federal Ministry for the Environment/Rupert Oberhauser as refrigerators, washing machines and cash machines must have at least 75 % by weight of their components reused or recycled. For consumer electronics and IT and telecommunications devices the figure is 65 %; for small household appliances, power tools and electric toys at least 50 % is to be recycled. The remainder has to be prepared for final disposal. Here also there are clear directions [4]. All fluids and critical parts such as batteries, electrolytic capacitors containing PCBs (not printed circuit boards, this time, but polychlorinated biphenyls), cathode ray tubes and switches containing mercury must be removed. The same goes for all printed circuit boards in mobile phones and for any printed circuit boards bigger than 1 0 cm 2 in other devices. The rest can be disposed of as ordinary or hazardous waste, again at the expense of the manufacturer. The cost of consumption All manufacturers that supply to private households are obliged to provide an insolvency-proof financial guaran- tee; otherwise the costs would fall on the taxpayer in the event of a company becoming insolvent. Registration (for which there is a fee), reporting of quantities of goods sold and making arrangements with waste disposal com- panies can all be handled on a producer's behalf by a 26 elektor electronics - 1/2006 Web links [1] Official site for RoHS and WEEE: http://europa.eu.int/comm/environment/waste/weee index.htm [2] FAQs on the directives: http:/ / europa.eu.int/ comm/environment/waste/pdf /fag weee.pdf [3] Distributor information on RoHS (selection): http://rswww.com/ http:/ / uk.farnell.com/ static/ en / rohs/index.html [4] Department of Trade and Industry information on RoHS and WEEE: http://164.36.164.20/sustainability/weee/index.htm [5] Current state of adoption of the directives in various EU states: http://164.36.164.20/sustainability/weee/Perchardsreport July05.pdf [6] EU Directive on eco-design: http://europa.eu.int/comm/enterprise/eco design /directive 2005 32.pdf special service provider, also, of course, for a fee. In Germany the total cost has been estimated at between 350 and 500 million euros (approximately 200-350 mil- lion pounds), most of which will passed on to the con- sumer in increased prices. Otherwise the taxpayer will have to foot the bill for the disposal of electronic waste, to say nothing of the costs of cleaning up landfill sites. Manufacturers are also under pressure to design their products to be recyclable as a step on the way to more comprehensive legislation [6]. The aim of so-called 'eco- design' is to use as little energy and raw material as pos- sible along the entire chain from the production of an appliance to its use and finally to its recycling. As energy becomes scarcer and more expensive this seems to become a more and more sensible idea. ( 050318 - 1 ) A useful clue to solving the prob- lem is obtained by examining the microcontroller port signal on an oscilloscope. The resultant oscillogram shows that the pulse edges are not always spaced 8 jis apart but 'jit- ter' by about 1 jis. This jitter is the cause of the modified frequency spectrum. The effect proper is caused by a certain time elapsing before the microcontroller responds to an interrupt ('interrupt latency'). The 8051 has a number of instructions with a length of either one or two machine cycles. Depending on the exact timing of the interrupt pulse in the cycle, a variance of plus or minus one cycle occurs before the interrupt routine is actually executed. In the original version of the program, the interrupt and main program are interlocked in such a way that a constant interrupt latency is cre- ated, resulting in a 'clean' signal. With the extra NOP inserted, a variable latency time is created resulting in periodic jitter (one period last- ing 7 x 1 6 = 1 1 2 |is). This in turn produces additional spectral lines with a distance f = 1/1 12 |is = 8928.57 Hz. With more realistically structured programs the jitter is far less clearly structured, in fact it will be random, causing a spectrum like the one shown here. A wide noise floor is seen. The jitter does not affect the average number of pulses in a second, so the fre- quency counter will continue to indicate 62.5 kHz. ( 065005 - 1 ) 1/2006 - elektor electronics 27 HANDS-ON DIY REFLOW OVEN SMD boards hot from the oven It's usually possible to solder 'ordinary' SMD components using a low-power soldering iron and small- gauge solder. However, it's a completely different story when you have to solder a component in a BGA, CSP or similar package. Such components can actually only be soldered using a reflow soldering oven. Here we describe how a normal, inexpensive oven can be transformed into a reflow oven. 28 elekfor electronics - 1/2006 Figure 1. A ball grid array (BGA). It hardly needs saying that it doesn't lend itself to hand soldering. The designers in the Elektor Electronics lab do a lot of soldering. It’s thus hardly surprising that they aren’t put off by a difficult soldering task. Never- theless, our esteemed designers were briefly perplexed when they had to sol- der a FPGA in a BGA package (Fig- ure 1). It was clearly impossible to tackle that task using a soldering iron. After a bit of experimenting (see the LabTalk article elsewhere in this issue), they decided it was high time to equip the lab with a reflow oven. Naturally, as true Elektor Electronics adepts they’d rather come up with something on their own than buy a ready-made solution. As a result of their efforts, our beloved pizza oven has now been converted into a gen- uine reflow oven. The reflow method The reflow method can be used to sol- der components whose leads are inac- cessible to a soldering iron. In the reflow method, a layer of solder paste is first applied to solder pads for the SMD components on the printed cir- cuit board. The SMD components are then placed on the board with their leads in the solder paste. The actual soldering takes place in a reflow oven in five stages. The soldering must be performed using a rather strict procedure. In the first stage, the temperature inside the reflow oven is raised to approximately 125 °C. This heating must be relatively gradual, as otherwise the solder paste will start bubbling and splatter tiny balls of solder over the circuit board. A rate of approximately 2 °C per second is fairly safe. This stage is called the ‘pre-heat stage’. The second stage is called the ‘soak stage’. During the soak stage, the tem- perature is very slowly raised to approximately 175 °C. The purpose of this stage is to ensure that the circuit board and all the components on it are at nearly the same temperature. That prevents cracking or warping of the PCB or components during soldering. This stage also causes the flux to become activated. Activation of the flux means that it liquefies and coats the pads better. Now that everything is nicely pre- heated, the actual soldering can start. The stage that comes next is called the ‘reflow stage’. During this stage, the temperature in the oven is raised to the soldering temperature as quickly as possible. The ‘dwell stage’ starts when the soldering temperature is reached (guideline value 220-240 °C). The soldering temperature is maintained for several seconds during this stage. The balls of solder in the solder paste, which is now liquid, start melting and are drawn together by surface tension. The flux is forced outward by the sur- face tension, so only liquid solder is present between the SMD compo- nents and the circuit board, and the two layers of solder melt together. A pleasant side effect is that the com- ponents are usually pulled nicely flat against the pads by the surface ten- sion of the solder. Any SMD compo- nents on the board that may be slightly tilted will thus level out dur- ing the soldering process. The final result is a trim, attractive circuit board with practically all of its com- ponents perfectly flat. After the dwell stage, which lasts 10 to 15 seconds, it’s time for the final, ‘cool-down’ stage. Not surprisingly, the temperature slowly decreases to room temperature during this stage. This must also take place fairly slowly, as otherwise there’s a risk of cracks developing in the components and/or circuit board during this stage as well. DIY saves money The price of a commercial reflow oven is outside the budget of most DIYers, but as we already mentioned, an ordinary oven can be converted into a reflow oven as explained below. For this pur- pose, you will need a (small) stand- alone oven dedicated to this use. Preparing food in an oven that is also used for reflow soldering is definitely a ‘no-go’. When purchasing an oven, you should look for one with inner volume as small as possible but still large enough for the boards you plan to sol- der, and with the highest possible heating capacity. That makes it possi- ble to raise the temperature inside the oven quickly, which is very important during the reflow stage. The oven we used for this purpose has a volume of 18 litres and a rated power 1/2006 - elektor electronics 29 HANDS-ON DIY REFLOW OVEN +5V © jn ^ToOn <3 1 Lrv + \ r _r\. J , i +5V © C15 lOOn 1 © A0 SDA A1 IC6 SCL A2 WP 24LC64 x k +5V 1 +5V © +5V © © T- SO IC1 cs T+ SCK MAX6675 R4 X C14 10|a 8x 10k ■j|Q 1 1|6 fljl flio rj y C9 10^1 K2 o- o o- o- o- C6 r 10fx 14 7 13 3 8 SUB D9 J T 10^1 I V + _ C1 + © IC3 Cl- TIOUT T1 IN RUN RIOUT R2IN R20UT T20UT T2IN C2+ MAX232 C2- V 16 11 12 9 10 15 +5V ■© C8 ID 10fx C5 lOOn T- Js I C4 lOOn 24 25 26 10 R6 33 1 12 _ 23 9 8 15_ 14 13 11 44 © P2.0/A8 EA/VP P2.1/A9 PSEN P2.2/A10 IC2 T0/P3.4 RST T1/P3.5 ALE/P WR/P3.6 RD/P3.7 NC AT89LS51 PLCC NC P0.7/AD7 P0.6/AD6 NC P0.5/AD5 SCK/P1.7 P0.4/AD4 MISO/P1.6 P0.3/AD3 MOSI/P1 .5 P0.2/AD2 PI .4 P0.1/AD1 PI .3 P0.0/AD0 PI .2 P1.1 P2.7/A15 P1.0 P2.6/A14 P2.5/A13 INT1/P3.3 P2.4/A12 INT0/P3 2 DO Q/A1 1 TXD/P3.1 RXD/P3.0 NC -L. XI X2 22 C2 27 p 21 XI I I 12MHz 35 32 16 17 18 19 29 28 27 34 20 C3 27 p IC7 +5V ©- 7805 4 4 Cl 3 lOOn (i i i o Cl 2 C11 1 ■ 1= :□ c= lOOn 470|a CIO 470|J, +5V 1 R5 — (t-m-n- 4x 1 1 2 3 l D3 11+21 5 D2 D1 \+2V +5V ©- I / +5V ©■ V PI 10k IC4 R1 H 150 ^ | +5V ©- S202S12 IC5 R2 H 150 0 | — I I c S202S12 Trl B80C1500 Monacor VTR-3106 +5V © R3 K6 O O LCD backlight LCD1 36 14 37 13 38 12 39 11 40 10 41 9 42 8 43 7 6 31 5 30 4 D7 D6 D5 D4 D3 D2 D1 DO E R/W RS VO VDD VSS <0 X CM >. ro o. (0 b O K5 r© HEATER 1 K4 L@ -© HEATER 2 L@ K3 -© 230V 'Xj -© 050319-11 Figure 2. Our controller circuit is built around an Atmel AT80C52. It controls the entire process. The temperature can be read out on a PC via an RS232 interface. of 1.8 kW. That amounts to a hefty 100 watts per litre. Such ovens are surpris- ingly inexpensive; our model cost only about 60 pounds. The standard controller fitted in such ovens is totally useless for our purpose. It must be replaced by the circuit shown in Figure 2. A new controller Although the controller we developed for the oven is relatively simple, it is highly effective and has several con- venient extra features. As usual, the circuit is built around a microcontroller - in this case a member of the 8051 family (Atmel AT89C52). This microcontroller contains 4 KB of flash memory for the firmware and the usual peripheral functions found in practically every 8051 derivative. A thermocouple (see inset) is used as the temperature sensor. It is fitted in the oven with its tip located roughly in 30 elektor electronics - 1/2006 About the controller Controlling the oven temperature may appear to be rather easy. To put it simply, you might think that all you have to do is switch on the heating elements when the temperature is too low. Otherwise the heating elements must be switched off. But as so often happens, there's more to it than meets the eye. A simple 'on-off' control is far from ideal in actual practice. The heating elements do not immediately stop radiating heat when they are switched off. The internal temperature of the elements is higher than the air temperature, so they keep transferring thermal energy until both temperatures are the same. That causes the temperature in the oven to continue rising for a while. This undesired temperature increase is called 'overshoot'. When the temperature subsequently drops below the set temperature, it takes a little while before the switched-on heating elements become hot enough to raise the tempera- ture. The temperature thus continues to drop for a while before it heads back toward the set temperature. That is called 'undershoot'. These phenomena are well known to measurement and con- trol engineers. The most obvious way to deal with this sort of situation is to use what is called a 'PID controller'. Such a controller requires at least three parameters to adjust the control loop. However, both of the above-mentioned types of control (sim- ply switching the elements on and off or using a PID con- troller) are unsuitable for this application. The first approach causes excessive overshoot, with the result that the tempera- ture cannot be controlled with sufficient accuracy. The sec- ond approach requires a certain amount of understanding of control circuits, because the user must provide the three parameter values needed to properly adjust the controller for his or her particular oven. That's not exactly what we call 'user-friendly'. The solution we finally devised in our lab takes a different approach. It provides surprisingly good results without requiring the user to have any understanding of control sys- tems. First, we measure the magnitude of the overshoot when the oven is heated from 50 °C to 100 °C. When a temperature of 100 °C is reached, we measure how fast the temperature is rising at that instant (the slope of the curve, in other words). The heating elements are switched off at that point, and we measure how much the temperature continues to increase. The amount of overshoot is divided by the slope of the curve at 100 °C, and the result is stored in memory. For readers who want to examine the source code, this value is found in the variable with the somewhat misleading name 'overshoot'. We also assume that if the temperature increases less quick- ly while the oven is heating up, which can occur for various reasons, the overshoot will be proportionally smaller. Once per second, our controller circuit attempts to estimate how much the temperature would continue to rise if the heat- ing elements were switched off at that instant. For this pur- pose, we measure the rate of rise of the temperature using a simple digital filter. This rate of increase is stored in the vari- able 'deltaT'. The value of deltaT is then multiplied by the calibration value (held in 'overshoot'). That gives a reason- ably accurate estimate of the anticipated overshoot at any given time. As soon as the anticipated final temperature is equal to or greater than the desired temperature, the heat- ing elements are switched off. If the estimated final tempera- ture is less than the desired temperature, the heating ele- ments are switched on (or remain on). Besides reducing or eliminating the overshoot of the oven, this technique also counteracts undershoot. That's because the value of deltaT becomes negative when the oven is cool- ing down, so the routine calculates the undershoot instead of the overshoot. Devising a control technique is only half the battle; it still has to be tested to see whether it works properly in practice. In our tests, we measured a maximum overshoot of 2 °C, and in many cases it was only 1 °C. At relatively high tempera- tures (above 200 °C), the overshoot was actually less than 1 °C. That's more than adequate for our purposes. Besides having good operational characteristics, this control technique makes it easy to automate the calibration process. It thus occurs fully automatically in our oven when the user selects and runs CALIBRATE in the main menu. And that's what we call 'user-friendly' 1/2006 - elektor electronics 31 HANDS-ON DIY REFLOW OVEN 70 % COMPONENTS LIST Resistors: R 1 ,R2 = 150D R3 = 1 Cto R4 = SIL array 8 x 1 0k£2 R5 = SIL array 4 x 1 k£2 R6 = 1 OkD PI = lOkfl Capacitors: Cl ,€4,05,01 2,C1 3,C1 5 = lOOnF C2,C3 = 27pF C6-C9,C14 = 1 OjiF 16V radial 010,011 = 470 jiF 16V radial Semiconductors: B1 = B80C1500 bridge rectifier, 80V piv, 1 .5A D1,D2,D3 = LED, red, low-current 1C 1 = MAX6675 IC2 = AT89C52/24JI, programmed, order code 050319-41 IC3 = MAX232 IC4,IC5 = S202S12 IC6 = 24LC64 IC7 = 7805 Miscellaneous: K1 = connector for thermocouple Thermocouple, K-type K2 = 9-way sub-D socket (female), PCB mount K3,K4,K5 = 2-way PCB terminal block, lead pitch 7.5mm K6 = connection for LCD backlight LCD1 = LCD module, 2x16 characters, e.g. order code 050319-72 or PLED version 050319-73 S1-S6 = pushbutton, ITT type D6-R Trl = mains transformer, primary 230V, secondary. 6V (e.q. Monacor/Monarch VTR-3 1 06) XI = 12 MHz quartz crystal PCB, ref. 030519-1 from The PCBShop Disk, source and hex code files, order code 030519-11 1 7 wire links the middle of the oven. Ensure that the thermocouple remains electrically iso- lated from the rest of the oven, in order to avoid creating a hazardous situation. The two leads of the thermocouple are connected to IC1, a MAX6675. This IC computes the temperature at the tip of the thermocouple based on the voltage generated by the thermocouple and the ambient temperature. The micro- controller can query the temperature via a serial interface. IC4 and IC5 are connected to the microcontroller via resistors. These two ICs are optotriacs with integrated zero- crossing detection and snubber net- works. That makes them very easy to drive from the controller. Power is applied to the two heating elements as necessary via these two ICs. The controller contains several set- tings that must be stored in an EEP- ROM. IC6 is included for that purpose. Alert readers may quickly come to the conclusion that 64 KB is rather gener- ous for the number of settings to be stored. That’s certainly true, but the circuit does in fact need that much memory because it is also used to store the measured temperature once per second during the soldering process. That allows the operation of the oven and the corresponding tem- perature profile during soldering to be examined afterwards. This information must be sent to a PC in some way or another. Here we use an old faithful: the RS232 serial port. As usual, the port is implemented using a MAX232 IC and associated components. Pushbutton switches S1-S6 provide the operating controls for the oven controller. LEDs D1-D3 and LCD1 keep the operator informed while the oven is in use. Not much needs be said about the power supply. It is very basic and per- fectly ordinary. Note that no fuse is included on the circuit board. An external fuse must be used for the input voltage. Besides a normal fuse, which is usually located at the rear of the equipment, a thermal cutout is also necessary. It must be fitted such that it switches everything off if the temperature of the oven becomes too high. That prevents the oven from overheating if something goes wrong, which in turn prevents everything from catching fire. The (fused) 230-V supply voltage is connected to K3. The two heating ele- ments are connected to K4 and K5. Installation Installation of the controller in the oven will be different for each type of oven. 32 elektor electronics - 1/2006 That means we can’t provide installa- tion instructions along the line of ‘first loosen the four screws on the bottom’, etc. In this regard, you’ll have to rely on your own talent for improvisation. That also applies to the printed circuit board. Of course, you can use our design (Figure 3), but it probably won’t fit in oven models (and it’s any- way rather large; its full-size artwork files can be downloaded free of charge from our website). That means you will most likely have to design your own circuit board to fit in your oven. We assume that anyone who wants to sol- der components in BGA packages and the like is also capable of designing a circuit board for the controller circuit. In any case, our board design can serve as a starting point. As regards safety, this circuit operates at 230 VAC, which means it can pose a fatal hazard if it is built or used improperly. As already mentioned, the mains voltage must be fused before it enters the circuit, and the fuse must be selected based on the maximum rated power of the heating elements. A sep- arate thermal cutout is also essential. Operation We’ve kept the user operation aspects of our controller quite simple. When the unit starts up, a welcome message appears on the LCD and the microcon- troller performs various checks. For instance, a warning message will be displayed if the EEPROM is missing, and a check is made to verify that a valid calibration value is stored in the EEPROM. If a valid calibration value is not found, the controller must first be calibrated. A message will be dis- played to indicate that automatic cali- bration can be started by pressing ENTER. If everything goes properly, the main menu will be displayed after calibra- tion is finished. In the main menu, you can use the T and i buttons to select START, EDIT, LOG or CALIBRATE. Press the ENTER button to start the selected function. Calibration The CALIBRATE function performs a fully automatic measurement of the most important characteristic of the oven: its overshoot (see the About the controller’ inset). Before you start a cal- ibration, make sure the oven door is tightly closed and nothing is inside the oven. The controller will heat the oven Figure 3. Our prototype circuit board isn't likely to win a prize for pretty design. The true-size artwork (pdf) files are available free of charge from our website. Figure 4. The actual temperature curve (blue) and the desired temperature (red). We added extra rock-wool insulation to the oven to increase its heating rate. 1/2006 - elektor electronics 33 HANDS-ON DIY REFLOW OVEN Thermocouples A thermocouple is a sensor that generates an electrical potential related to the temperature. The operating principle of the sensor is base on the fact that any electrical junction between two different metals generates an electrical poten- tial that depends on the temperature and the metals that are used. The principle applies equally well if three metals are used. In that case, there are two junctions in series, and the net potential results from the series addition of the two indi- vidual potentials. For example, if a copper-iron junction is in series with an iron-tin junction, the net potential is the same as for a copper- tin junction. However, that is only true if both junctions are at the same temperature. With a 'K-type' thermocouple, which is what we used for this design, the metals forming the thermocouple are always Chromel (on the positive side) and Alumel (on the negative side). The voltage generated by this combination is approxi- mately 4 mV / 100 °C. K-type thermocouples can withstand temperatures of 1000 °C or more without suffering any damage. However, thermocouples also have an inherent drawback: connecting a thermocouple to a circuit inevitably creates additional junctions between different metals, which natural- ly generate their own thermal potentials. Strictly speaking, the potential at the output of a thermocouple is not a func- tion of the absolute temperature at the measurement point, but instead a function of the difference between the tempera- ture at the measurement point (the hot junction) and the tem- perature at the connection point (the cold junction). In our circuit, the cold junction is located on the circuit board. If we measure the temperature of the circuit board, we can calculate the actual temperature at the measurement point from the voltage generated by the thermocouple and the temperature of the circuit board. Fortunately, the MAX6675 1C used in the circuit automatical- ly looks after all that for us. It measures the voltage from the thermocouple and converts it into a temperature difference between the hot junction and the cold junction. We assume that the temperature inside the 1C is essentially the same as the temperature of the circuit board (the cold junction). If we add the chip temperature to the computed difference between the temperatures of the hot junction and the cold junction, we obtain the temperature of the hot junction, which it the temperature at the point we want to measure. This assumption regarding the cold-junction temperature is why it's important for the thermocouple leads (which are made from Chromel and Alumel) to be soldered to the cir- cuit board as close to the 1C as possible. That also means that if you have to extend the thermocouple leads, you must use Chromel wire for the positive side and Alumel wire for the negative side. If you use normal copper wire, the junc- tions with the copper wire will form additional measurement points. That will create a measurement error if the tempera- tures of those junctions are not the same as the temperature of the circuit board. It's thus best to buy a thermocouple with sufficiently long leads. It shouldn't be necessary to say this, but well say it anyhow for good measure: make sure your thermocouple is made from Chromel and Alumel. In other words, ensure that it is a K-type thermocouple. Other types of thermocouples generate different potentials, which will result in incorrect measure- ments. In case of doubt, you can easily check the measurements. If you put the thermocouple in ice water, the circuit should indicate a temperature of approximately 0 °C. If you put the thermocouple in boiling water, the circuit should indicate a temperature of approximately 100 °C. If you have any doubt, we definitely recommend making this test. to 100 °C and switch off the heating elements. The temperature inside the oven will continue rising for a short while until it reaches some maximum value. When the temperature has just about stopped rising, the microcon- troller calculates the associated over- shoot value. That value is stored in the EEPROM, so the calibration routine does not have to be repeated every time the oven is used. Edit Different types of solder paste may have different rated soldering temper- atures. The melting temperature and the temperature needed to activate the flux depend on the composition of the solder paste. You also have to consult the data sheets of the components you use to determine the requirements for the temperature profile (in other words, the settings). You can deviate from the STAGE , TEMPERATURE, DESIRED TEMPERATURE, HEATER 1, HEATER 2 STAGE: 0 = COOL 1= PREHEAT 2 = SOAK 3 = REFLOW 4 = DWELL 5 = COOL HEATING : 0 = OFF 50 = ON Figure 5. The format of the data sent to the PC. 'Stage' indicates the progress of the process, Temperature' indicates the current temperature in the oven, 'Desired temperature' is self-explanatory, and 'Heater 1 ' and 'Heater 2' indicate whether the heating elements in question are switched on. 34 elektor electronics - 1/2006 IE runui E7 1 ? Figure 6. The four stages in PCB form: without solder paste, with solder paste, components not yet soldered, and finished circuit board. manufacturer’s requirements in actual practice, but if you do, there’s no guar- antee that the components will still be intact after soldering. The temperature profile generated with the settings we used for our con- troller is shown in Figure 4. The values shown in the figure are guidelines; we have achieved good results with them on our lab. Log The LOG menu lets you enable or dis- able the built-in temperature logging function. The logging function is dis- abled by default when the unit is switched on. That avoids rewriting the contents of the EEPROM any more often than necessary, which helps pro- long the useful life of the EEPROM. You can enable logging with the T but- ton and disable it with the i button. If you press the -> button, the content of the temperature log for the most recently logged soldering cycle will be transmitted via the serial port. The settings used for the serial port are 4800, 8, N and 1 for the baud rate, number of data bits, parity, and num- ber of stop bits. The stored values are separated by [RETURN] codes. You can use HyperT- erminal or any other suitable communi- cations program to store the data stream in a file. It’s a good idea to assign the extension ‘.csv’ to the file name. That makes it possible to open the file using a spreadsheet program. In a program such as Excel, you can then generate a chart from the data to show the actual tem- perature plot (temperature profile). Press [ESC] to return to the main menu. Start The START function does exactly what it says: it starts the soldering process. The display provides a convenient indi- cation of the progress of the process. If anything goes wrong, you can always stop the soldering process by pressing the [ESC] button. Another way to modify the process is to use the T and i buttons. You can use these buttons to increase or decrease the desired temperature while the oven is operating. Another handy feature is that the most significant data is transmitted via the serial port during the soldering process. The same settings are used here as for reading out the EEPROM, namely 4800, 8, N and 1 for the baud rate, number of data bits, parity, and number of stop bits. The format of this data is shown in Fig- ure 5. The data can also be stored on hard disk using HyperTerminal and then processed in a spreadsheet pro- gram. The temperature profile shown in Figure 4 was generated in this manner. Practical experience We’ve used our SMD oven successfully several times already for soldering pro- totypes. However, each time we had to open the door at the end of the solder- ing process to reduce the cool-down time. Most inexpensive ovens don’t have a fan to help cool down the oven. There’s also no provision in our circuit for a fan. For people who only want to solder the occasional circuit board, it shouldn’t cause a big problem if someone has to keep an eye on the oven and open the door when the process is finished. It’s a good idea to make sure the sol- der paste you buy is suitable for use at the lowest possible temperature. New solder paste compounds comply with the RoHS requirements, which among other things means they do not contain any lead. That makes the melting point of the solder somewhat higher. The sit- uation in this area is currently rather dynamic, so you should remain on the lookout for solder paste compounds with relatively low melting points. And while we’re on the subject of sol- der paste, it’s recommended to store solder paste in a refrigerator to prolong its useful life. ( 050319 - 1 ) This circuit operates at 230 VAC, which means it can pose a fatal hazard if it is built or used improperly. 1/2006 - elektor electronics 35 HANDS-ON MICROCONTROLLERS 1 6 -bit power for the masses Gunther Ewald and Burkhard Kainka Starting next February, we will be offering a small but elegant R8C microcontroller board in cooperation with Glyn, along with a wealth of software, at a simply unbeat- able price. This little board is fully ready to use. Here we take the opportunity to first introduce the microcontroller. Microcontrollers from the Japanese company Renesas have quietly captured a position in the European mar- ket. They are typically used in applications such as automobile sensor systems, fire detectors, door openers, heating system controllers, measuring equipment, and stereo systems. We've reason to believe practically all readers of Elektor Electronics are familiar with the 8051 and AVR microcon- troller families, but quite a few of them have never heard of the Ml 6C and the R8C. That's a pity, because the small R8C microcontroller is particularly suitable for applications that challenge the capabilities of the more familiar devices. Besides that, it's actually quite easy to use. The internal flash memory can be programmed via the serial port, so no special programming device is nec- essary. In many cases, you can manage without a clock crystal in the ultimate application. And finally, all the soft- ware you need to develop your own applications is freely available. The origins In 1996, Mitsubishi Electric started replacing its success- ful MELPS7700 microcontroller with its successor, the Ml 6C/60. The new device had the same peripherals but a significantly faster processor, and with 100 pins it outscored its predecessor by 20 pins. The driving forces at that time were the Japanese manufacturers of ink-jet printers and photocopiers. Thanks to its large complement of timers and very low current consumption, the new microcontroller quickly found its way into industrial equipment manufactured by European companies. The M16C became even more popular in late 1998 with the introduction of DINOR flash memory, which does not need a special program- ming voltage. A data retention time of 1 0 years was guaranteed. The standard Ml 6C/62 has been updated three times over the years. Starting with the Ml 6C/62, it evolved into the Ml 6C/62A and then into the current Ml 6C/62P. Each time the internal dimensions were reduced, a few new features were added, and the device became faster and more modern, with reduced current consumption and a lower cost. However, it always remained pin- and function-compatible. Derivative devices in smaller and larger packages started appearing in 1 999, along with the R8C family and the M32C, which rounded out the top end of the family. These microcontrollers were initially manufactured by Mit- subishi Electric, but in 2003 Hitachi and Mitsubishi Elec- tric merged to form a new company christened 'Renesas'. All of the family members and their data sheets can be found via the home page www.ml 6c.de. As can be seen from the summary in Figure 1 , once 36 elektor electronics - 1/2006 In cooperation with Glyn (www.qlyn.de) , the leading distributor of Renesas microcontrollers, starting in February 2006 Elektor Electronics will be offering a fully assembled R8C/13 circuit board and a comprehensive software CD, all at a special price. you've mastered the R8C you have a lot of opportunities for further growth. The transition to the next higher deriv- ative device is fully seamless. Besides the fact that you can continue using the same compiler, all existing appli- cations can easily be used and extended with the new device. Even moving to a data width of 32 bits doesn't cause any headaches. All in all, that means it's worth tak- ing a closer look at the smallest member of the powerful Renesas family. The family The R8C was developed in 2003 as a pin-compatible, cost-optimised version of the Ml 6C/10. The entire Mit- subishi series, including the M16C/10, has an internal 1 6-bit data path to the flash memory and SRAM. In order to save silicon area, Renesas simply reduced the bus width to 8 bits and integrated the new 'Hyper New Dinor'(HND) flash memory. The addressable internal memory space was also reduced from 1 MB to 64 KB. In addition, the new 4-wire debug interface was added to the R8C. That made the R8C itself and application pro- gram development very economical. With its smaller package size (20 pins instead of 32), the R8C microcontroller is also suitable for applications such as model building, instrumentation sensors and data loggers. We'll be devoting our attention to the R8C (or more H8C Advantages - M16C platform compatibility Low cost downgrade path fJn Ml pin 1 ifl24K HtfU ".uV 100 pin 12U prin « pm pin 42 pin 42 44*1 r« H” pin iu pin M32CSX 5I3R Lp4K I2EK 4tk - lh Mhl tn 144fMn| - 1 li ha M2 MHz (up In 24 UiK^ * DMA 4 Ch MlGCSx - -4-UH s parotid In 17Bpin) ■ I Ci Ed £4 MHz (up la 1 L MIPS) * DMA 2 th MI&C/Tiny ■ snL'di pnekjga^ to DOpi-isJ - iQt&20 MH^upig IlMIPSl - DMAS ch 33K i« RSC Tiny SK ■ V-vry miihEI paukugv £20 lu 3Z|>anal ■ 10 1 c SO Mtf r {up to 5 MIPS) - KinQlr-chifi- 16blt CPU Same CPU core S»mw CPU cun? without DMA Figure 1. The R8C and the other members of its family make upgrading easy. 1/2006 - elektor electronics 37 HANDS-ON MICROCONTROLLERS Figure 2. A LED blinker using the R8C/13 - no crystal necessary! specifically the R8C/1 3) in the conning issues of Elektor Electronics. We have planned articles on how to use the software and some typical application examples. Naturally, a user competition also forms part of the pic- ture. Here we'd like to whet your appetite a bit by describing the principal features of this small but ele- gant microcontroller. The core The CPU achieves a processing performance of 8 MIPS at a 20-MHz clock frequency and boasts 89 native instructions. Of that number, 20 are single-cycle instruc- tions, and three quarters of the instructions execute in five clock cycles on average. Mathematical operations, such Figure 3. The model E8 hardware debugger (optionally available) has a true real-time mode. as a 16-bit by 16-bit multiplication, are completed in 250 ns, and division of a 32-bit quotient with a 1 6-bit dividend takes 1248 jjs. The instruction set includes an RMPA instruction (calculate sum of products), which can be used to compute digital filter algorithms. The instruction set has special space-saving instructions that allow short data words (with a length of 1 , 2, 4 or 8 bits) to be stored in one, two or three bytes along with the instruction opcode. The same capability is also avail- able for addresses. The Compare function has been extended to enable MOV instructions to load data depending on flag states without requiring a prior com- parison. The peripherals The R8C/1 3 has three 8-bit timers, one 1 6-bit timer, a watchdog timer, a very fast 1 0-bit A/D converter with twelve inputs and a conversion time of 3.3 pis, two UARTs (one of which can also be used synchronously), flash pro- gram memory, flash data memory in the form of a virtual EEPROM, SRAM, eight I/O lines with a rated current of 20 mA (for directly driving devices such as LEDs), an undervoltage detector, two integrated oscillators (calibrat- able 1 25-kHz and 8-MHz ring oscillators), and a crystal oscillator. The reset peripheral is also integrated using a 5-bit counter. As with other Renesas microcontrollers, the current con- sumption is very low. It is 7.9 mA at 5 V and 1 6 MHz, dropping to 4 mA at 5 V for operation using the 8-MHz ring oscillator or 470 \jA at 5 V for operation using the 1 24-kHz ring oscillator. In Stop mode the current con- sumption is only 0.7 |jA. A particularly attractive feature for model builders is the IC's ability to boot using the low-speed oscillator. As can be seen from Figure 2, all you need to implement a mini- mal application (such as a LED blinker) is a programmed R8C/1 3 and a resistor. The debug interface The R8C family has an integrated debug interface with asynchronous and synchronous serial interfaces for easy, inexpensive debugging. The asynchronous mode is espe- cially easy to use, because all you have to add is an RS232 level converter. For debugging you will need the KD30 debugger program, which first flashes a monitor program into the R8C and then starts it automatically. The debug interface is also suitable for downloading a fully developed program in the flash ROM of the micro- controller. You can use the Flashstart or FDT program for this purpose. These programs, as well as all other software mentioned here, are available free of charge from www.renesas.com orwww.ml6c.de. Naturally, the pro- grams are also located on the software CD-ROM avail- able from Readers Services. The tools Renesas supports developing small, medium-sized and large projects using corresponding software. In that regard, a distinction must be made between three levels, which differ in cost, scope and capability. At the first level, the potential user can manage entirely without pur- chased software. There is even a GNU C compiler avail- able now for the Ml 6C family. 38 elektor electronics - 1/2006 Preliminary exercises The following programs can be used to check whether a particular task can be handled using the R8C. Program installation should not present any problems for experienced microcontroller users as long as they follow the instruc- tions. Detailed instructions will be provided in the February 2006 issue. Note that these programs must be installed in the proper sequence. I The Renesas KD30 monitor and debugger program is part of the HEW program, but it can also be used sepa- rately for debugging. The KD30 and HEW programs are compatible with the NC20 compiler, the GNU C compil- er, and the IAR or Tasking C compilers. The software can be found under www.renesas.com _ Global Site _ Software and Tools _ Download. Confirm the licence conditions with 'Agree' and then click on 'Evaluation Software'. Next, click on 'Monitor Debuggers and Others' under 'Upgrades' and then select 'KD30 UART'. After that, the full set of programs (with a size of 5.6 MB) can be downloaded. 2 The free version of the Renesas NC30 C compiler, including HEW, can generate up to 64 KB of code, which can be debugged using the KD30 or HEW pro- gram. You can download the software from www.renesas.com _ Global Site _ Software and Tools _ Download. Here again, confirm the licence conditions with 'Agree' and then click on 'Evaluation Software'. You will find 'M3T- NC30WA' under 'C/C++ Compilers and Assemblers', and once again you have to confirm by clicking on 'Agree'. The size of the file is approximately 65 MB. The HEW (High-Performance Embedded Workshop) program is a user interface for generating, debugging and flashing proj- ects. The debugger is compatible with the NC30 compiler and the GNU C compiler. 3 The 'Debugger Package' is the software for linking KD30 into the HEW, and it is also available at www.renesas.com _ Global Site _ Software and Tools _ Download. Here you should confirm with 'Agree' as usual and then click on 'Upgrades'. Under 'In-circuit Emulators and Compact Emulators', you can then select 'PC7501 for M16C Family' and download the 'Debugger Package', which has a size of approximately 81 MB. "-5* R~~M~r ■n IIIT I H- I i .r ...-ri ‘ ■■ Hill ih| ■vi P=-±hL-t iMWirnr i If*"! 'll 4c* .W^.‘4Q Mrntp Y-pri -T-vpi-i j|*.1 |S| KM. Hi-M-emr =>ik»r.-l,-i- Eiij. 4 Mmvi# hJwiMi tn f i ■ LU Pvg’ft'-r mbm Hl&r La ■! H-. Ij.r C mmrit tai I i ■ l»Lf I 1-aL.J Pia.LrLa-4 H f I 1 TP , ■i a N'M n n ji-w ■ ■ 4 The KPIT GNU C compiler does not have any operational restrictions, and the code it generates can also be debugged using the KD30 or HEW program. The compiler is available at www.kpitgnutools.com. You can download the software (size: 27 MB) after completing a registration form. 5 The Renesas FDT (Flash Development Toolkit) can program the flash memories of near all Renesas MCUs. It is available at www.renesas.com _ Global Site _ Software and Tools _ Download. After clicking on 'Agree', you can click on 'Evaluation Software', select 'Flash Development Toolkit' under 'Flash and PROM Programming', and download the software (size: approximately 27 MB). 6 Flashstart is a well-known flash program dating from the days of Mitsubishi Electric. It can flash all MCUs in the R8C/M1 6C/M32C family. The program is located at www.renesas.com _ Global Site _ MPU&MCU _ R8C/Tiny (upper table). There you have to select 'Software and Tools', go to 'Flash and PROM Programming', click on the 'M3A-0806' product, go to 'Software Update' on the left, and confirm by clicking on 'Agree'. Here you can download the source file (which you don't need) and the .exe file (size: 334 kB). 7 Header files and assembler 'include' files are located at www.renesas.com _ Global Site _ Software and Tools Download. After clicking on 'Agree', you can select 'M16C Family' under 'Sample Codes' and download the desired files. 1/2006 - elektor electronics 39 HANDS-ON MICROCONTROLLERS Figure 4. You can actively program an R8C via the Internet. Level 1: On the hardware side, the simplest option only requires a level converter for the RS232 interface, as pre- viously mentioned, and a serial interface cable. To that you can add the free Renesas NC30 compiler with its integrated development environment (HEW). Although the compiler is restricted to 64 KB, that does not impose any restriction on projects using the R8C, since it can anyhow only address a maximum of 64 KB. Besides C projects, it's also possible to develop assembly- language programs. The debug output format is IEEE 695. The HEW program or the KD30 program (also free of charge) can be used for debugging. Code generated by Figure 5. And experimental prototype circuit using the R8C/13 board. This circuit will be presented in the February 2006 issue. the GNU C compiler can also be debugged using this tool. All you have to do is to change the debug format to IAR/ELF Dwarf2. You can use Flashstart or FDT to flash the finished application into the microcontroller. Level 2: If you want to perform debugging using a syn- chronous serial interface, independently of the crystal fre- quency and without using a monitor, you need Renesas's smallest hardware debugger, the model E8 (Figure 3). For the duration of this series of articles, it can be obtained from Glyn GmbH & Co. KG at a special price of € 1 1 0 (ex VAT) instead of the regular price of € 1 50. The E8 can generate breakpoints at data location as well as addresses, and it supports genuine real-time program execution and extended trace levels. The PCB pads for connecting this tool are already present in the free area of the circuit board described in the December issue. All you have to add is a few header pins. The integrated development environment (HEW) is also used for debugging at this level, because it is the only one that supports the E8. Here again, either the NC20 compiler or the GNU C compiler can be used. Flashstart or FDT can then be used to flash the finished application into the microcontroller. Level 3: For professional software development, R8C software can also be debugged using the Renesas PCC7501 real-time emulator, which naturally comes at a higher price. The PC7501 is connected to an emulation probe and provides countless features for searching for errors. It can measure program execution times and record the individual steps executed before a bug. It can also record digital signals from the application circuit 'on the side' with a resolution of 1 |js. The outlook If your curiosity has been aroused by now, you can already start doing a few 'preliminary exercises' with the R8C. The www.renesasinteractive.com website is a good resource for this. There you can even program a genuine starter kit via the Internet (see Figure 4), and you can naturally learn more about the features of the R8C. The only software you need to have installed on your com- puter for these functions is a web browser. The NC30, NEW and KD30 programs run entirely on the remotely controlled computer. Besides this, you can also use your own computer to check whether specific tasks can be handled using this microcontroller. However, that does require installing a few programs before you start (see inset). It must be admitted that the necessary software takes up a certain amount of space and requires some familiarisation. Natu- rally, all of the programs will be provided on the software CD-ROM available from Readers Services, and detailed installation instructions will also be provided with the pro- grams. All of that will be topped off with simple projects to make your first steps with the R8C/1 3 even easier. Figure 5 shows an experimental prototype of a circuit planned for the February 2006 issue. It doesn't require much more than a voltage regulator and a pair of transistors for the serial interface! ( 050179 - 1 ) 40 elektor electronics - 1/2006 f^llektor L ~ E lectronics Order now using the Order Form in the Readers Services section in this issue. Elektor Electronics (Publishing) / Segment B.V. Regus Brentford • 1000 Great West Road Brentford TW8 9HH • United Kingdom Telephone +44 (0) 208 261 4509 Fax +44 (0) 208 261 4447 Email: sales@elektor-electronics.co.uk Step into the fascinating world of microcontrollers Microcontroller Basics Burkhard Kainka Microcontrollers have become an indispensable part of modern electronics. They make things possible that vastly exceed what could be done previously. Innumerable applications show that almost nothing is impossible. There’s thus every reason to learn more about them, but that raises the question of where to find a good introduction to this fascinating technology. The answer is easy: this Microcontroller Basics book, combined with the 89S8252 Flash Board project published by Elektor Electronics. This book clearly explains the technology using various microcontroller circuits and programs written in several different programming languages. In the course of the book, the reader gradually develops increased competence in converting his or her ideas into microcontroller circuitry. ISBN 0-905705-67-X Flash Microcontroller Starter Kit Elektor Hardware & Software Step into the fascinating world of microcontrollers with the Elektor Electronics Flash Microcontroller Starter Kit. Order now the ready-assembled PCB incl. software, cable, adapter & related articles. Contents of Starter Kit: • 89S8252 Flash Microcontroller board (ready-assembled and tested PCB) • 300-mA mains adapter • Serial cable for COM port • Software bundle on CD-ROM • Article compilation on CD-ROM 230 Pages £18.70 / US$ 33.70 £69.00 /US$112.50 More information on www.elektor-electronics.co.uk HANDS-ON POWER SUPPLIES Anyone who regularly uses a laptop or notebook computer while they are away from the home or office knows that sooner or later they will need to plug into a mains outlet to top up the batteries. The car cigarette lighter socket in the car is also an electrical outlet but it can only supply 1 2 V. That's no problem for the Laptop PSU Adaptor described here; it can deliver ample voltage and current for today's portable computers from a car battery. It's also simple to build and has excellent efficiency. Modellers will also be interested in this design to recharge their battery packs in the field. 42 elektor electronics - 1/2006 Adapter specification • Output current: • Output voltage: 5 A (10 A momentarily) 19 V ± 0.5 V (adjustable) • Input range: • Minimum input voltage: 10 V to 15 V 9.2 V • Switching frequency: • Maximum continuous output power: 42 kHz 95 W • Efficiency: • PCB dimensions: 95 % (typical) 59 mm x 98 mm The laptop adapter described here plugs into a car cigarette lighter socket and produces a 19 V nominal output voltage adjustable by ± 0.5 V. The input voltage range is from 9.2 V to 15 V and the output voltage shows good regu- lation even with large fluctuations of the input voltage. The output can sup- ply 5 A continu- ously with brief excursions up to 10 A. The power semiconductor heatsinks are dimensioned for 5 A contin- uous so extended oper- ation up to 10 A will increase dissipa- tion in the adapter and in extreme cases will cause the input fuse to complain. The high effi- ciency of this design (typi- cally 95 %) reduces loading on the car battery and also dissi- pation within the adapter unit. At 60 mm _ 100 mm the PCB out- line is not much bigger than the mains adapter unit that was supplied with the laptop or notebook PC. The step-up Converter The majority of laptops require a sup- ply voltage in excess of the 12 V avail- able at the cigarette lighter output socket, even with the engine running the supply will not rise much above 13.8 V and this is still too low for most laptops which typically require 19 V. The 12 V supply can be boosted with the help of a step-up converter design. The basic principle is simple: an induc- tor is repeatedly ‘charged up’ and ‘dis- charged’ and the resultant induced voltage is added to the supply voltage to produce an output voltage higher than the supply. Unlike a standard transformer inverter the basic circuit requires just three components: a coil, a power switch (in this case a MOS- FET) and a diode. All the control func- tions are performed by IC1, this device produces the pulse width modulated (PWM) switching signal for the power switch. The input and output voltages are smoothed by a series of low-loss capacitors. The principle of the step-up converter operation is shown in Figure 1 . When the power switch (MOSFET T) con- ducts (Figure la) current flows through the coil and produces a mag- netic field. The anode of the diode (D) will be at ground potential (almost) so it will not be conducting and any energy previously stored in the capac- itor C will be supplied to the load (R L ). The coil core has a 1 mm air gap to ensure that the core material is not driven into saturation during this phase of the cycle. When saturation occurs it is not be possible to store any more energy in the magnetic field and the coil effectively becomes just a low impedance resistor which would short- circuit the input voltage. When T turns off (Figure lb) current through the coil no longer has a path to ground through T, the magnetic field starts to collapse inducing a voltage across L of the opposite polarity to the switch-on phase. The induced voltage rises above the supply voltage, for- ward biasing D and transferring energy to C and R L . Energy stored in C during this phase is transferred to the load during the next switch-on phase. a •iN l0UT b •in •out Figure 1 . The step-up converter principle: Switch-on phase (a) and Switch-off phase (b). 1/2006 - elektor electronics 43 HANDS-ON POWER SUPPLIES Figure 2. Output voltage control using PWM. Figure 2 shows the correspondence between the output voltage V 0 ut an d the transistor switching time (t 0N and topF)- With short t 0 FF times it is impor- tant to use low loss devices for the diode and capacitors to ensure they do not exceed their SOA (Safe Operating Area), otherwise the high energy transfer may lead to over heating and component failure. From a design point of view if you need an output more than about three to four times the input voltage it would be better to use a transformer in the design. This would reduce the current ripple and lower the switching current peaks. The step-up regulator current and volt- age waveforms are shown in Figure 3. Waveform C shows the coil ripple cur- rent, increasing the coil size would reduce ripple but would also increase the physical size of the unit. It is important to ensure that the coil is not made so small that it cannot supply sufficient energy during the switch- off phase; this would produce an output voltage with very poor regulation. The 56 jjH coil used in this design produces a ripple current of around 2 A which is approximately 40% of the maximum output. Just one 1C The input voltage in the range from 10 to 15 V is connected to terminals K1 and K2 in the circuit diagram (Figure 4). A PCB mounted fuse is fitted in line with the positive supply and the spec- ified fuse holder is equipped with two solder tags for each of the two fuse contact clips, these help to reduce the resistance of the fuse assembly which is particularly important because it passes a high current. Four electrolytic capacitors (Cl to C4) buffer the input voltage. The adapter circuit switches the supply current very quickly and requires special low-loss capacitors suitable for use in switched mode power supplies, the internal imped- ance of normal electrolytics is too high, they would overheat and may burst. C5 decouples any high frequency sig- nals on the supply voltage. The coil (LI) is made up from several lengths of enamel covered wire con- nected in parallel to reduce the skin effect which becomes a problem with high switching speed. The high power switching element is a HEXFET made by International Rectifier. This device has source/drain resistance of just 8 mfl when it is conducting. The low resistance ensures very low power dis- sipation in the device and allows it to switch a hefty 104 A maximum which should ensure reliable operation in our application. Both the HEXFET and diode are fitted with finned heat sinks. Schottky diode D1 has a TO 220 pack- age outline. It has a 45 V maximum operating voltage and a current of 16 A which gives a forward voltage drop of around 0.63 V, again for reliability the device is conservatively rated. Low ESR type electrolytic capacitors are specified again for output smoothing capacitors C6 to C9. Capacitor CIO is used for high frequency decoupling and the regulated 19 V is output from connectors K3 and K4. A block diagram of the UC3843 (IC1) is shown in Figure 5. It contains a pulse width modulated (PWM) controller out- put signal and an internal voltage refer- ence. The adapter output voltage is divided down by Rl, R2, R3 and PI and connected to the voltage feedback input (pin 2) of the controller IC (the error amplifier inverting input). C2 improves the amplifier stability as does R4, R5 and C12 connected between Figure 3. Current and voltage waveforms with 50% on/off switching, (a) The PWM signal; (b) Voltage across the MOSFET (V T ); (c) Current through the coil (l L ); (d) Current through the diode (l D ). 44 elektor electronics - 1/2006 Figure 4. The laptop PSU adaptor circuit diagram. the output (Pinl) and non inverting input of the difference amplifier. The IC clock frequency is defined by the RC network formed by R8 and C13. The component values shown give an oper- ating frequency of around 42 kHz. C14 provides decoupling of the internal ref- erence voltage at pin 8. The supply decoupling network formed by R12, C15 and C16 on the supply pin 7 is important for reliable operation of IC1. The current sense input (pin 3) is not used in this application. The power FET has a gate capacitance of around 5,000 pF which must be charged and discharged 42,000 times per second if the FET is to be switched successfully. It is important that the transition between on and off occurs as quickly as possible so that there is minimum dissipation in the FET. It is therefore necessary to use a low impedance driver (T2 and T3) between the PWM output of IC 1 and the gate pin of the FET. The BD139 and BD140 complimentary pair can handle around 1.5 A limited by resistors R9 and R10. Rll will turn off T1 if for any reason both T2 and T3 become non-conduct- ing or IC1 is defective. Printed circuit board The complete circuit fits on the single- sided PCB (Figure 6) without the need for any wire links. Before any of the components are fitted it is best to con- struct the coil. The PCB layout also includes pads for an off-the-shelf 56 jlxH inductor but it must be able to handle the high switching currents. The pro- totype circuit used a coil with an ETD 29 core and was constructed as fol- lows: The coil has a total of urns but to make things a bit more interesting the wire consists of 10 strands of 0.5 mm diameter enamelled copper wire (ECW) connected in parallel. The effec- tive cross sectional area of all the strands is 1.96 mm 2 . This method of construction produces a coil with much better properties at this switch- ing speed than would be achieved with a single wire with a cross sec- tional area of 1.96 mm 2 (the skin effect has less influence). The strands are first carefully twisted together before they are soldered to the coil termination posts, if the twist- ing is too tight the there will not be enough space to fit all the 21 turns. Each strand is 2 m long so overall 20 m of 0.5 mm enamel covered wire will be Vcc Output Power Ground Current Sense Input GND 050029-15 Figure 5. Block diagram of the PWM IC UC3843. 1/2006 - elektor electronics 45 HANDS-ON POWER SUPPLIES | COMPONENTS ! ; LIST ; Resistors: R1 = 5k^6 R2 = 5 Ikfl (51kfll) R3 = 9k^l (9kfl09) R4 = 1 Mn R 5 = 4k Q7 ■ R6,R8 = 15kfl ■ ■ R7 = 27kfl I I R9,R 1 0 = 6fl8 I I R1 1 = lOkfl I I R 1 2 = 100 a I I PI = 5k£l preset I I Capacitors: I I C1-C4 = 3300jiF 16V, radial, low | ■ ESR, diam. 12.5 mm, e.g. ■ Panasonic EEUFC1C332 (Farnell) - C5,C10 = 1 jlxF MKT, lead pitch 5mm . or 7.5mm (larger version preferred) Cl 2 = IjiF MKT, lead pitch 5 mm C6-C9 = 2200 jiF 25V radial, low ESR, diam. 12.5mm, e.g., 1 EEUFC1E222 (Farnell) 1 Cl 1 = 22nF, lead pitch 5mm Cl 3 = 2nF2, lead pitch 5mm I Cl 4, Cl 5 = 1 OOnF ceramic, lead I I pitch 5mm I I Cl 6 = 1 OjlxF 63V radial I | Inductors: I | LI = 56jiH, 2 1 turns 1 0 x 0.5 mm | | ECW, parallel I I 1 x ETD 29 coil forner, vertical | mounting, Epcos B66359X1 01 4T1 (Schuricht # 33 1 622) 2 x ETD 29 clamp, Epcos B66359- A2000 (Schuricht# 333862) 2 x ETD 29 core half, material # N67, air gap 0.5mm, Epcos B66358-G500-X1 67 (Schuricht # 1 333840) 1 Semiconductors: I D1 = MBR1 645 (International I I Rectifier) (e.g. Reichelt, Segor) I I T1 = IRL2505 (International Rectifier) I I TO-220AB case, (e.g., RS I | Components) I | T2 = BD139 | I T3 = BD140 I I IC1 = UC3843N (Texas Instruments) | (e.g. Reichelt, Segor) Miscellaneous: K1-K4 = 2-way spade terminal, vertical, PCB mount FI = fuse, 1 0A/T (slow) 6.3 x 32 mm [/a x 1 /a inch) + 2 fuse holders for 6.3 mm diameter and PCB mounting I 2 x heatsink type SKI 04-STC (or STS) I I TO220 38. 1 mm, 1 1 K/W (Fischer I I Electronic)lsolating washers for T1 I I and D1 (TO-220AB) + isolating I I bushes I | PCB, order code 050039-1 (see | | Elektor Shop pages or www.elektor- | | electronics.co.uk) I required. The start of the windings are soldered to the first four pins on one side of the coil former and after wind- ing the ends are soldered to the first four pins on the other side of the for- mer. It will be necessary to remove the enamel covering and tin the ends of the wire before they are soldered to the pins. Be careful here because the plas- tic coil former is not particularly tolerant to high temperatures and the pins may move out of position if the plastic is allowed to get too hot. The seven pins can be supported while soldering by fitting them into a spare strip of perfo- rated prototyping board. For the proto- type three layers were necessary for the 21 turns, the first and second layer both comprise of eight turns with five turns left for the last layer. Once the windings are finished and before the end of the windings are soldered in place try assembling the core pieces to make sure there is enough room. When there is insufficient space you can leave off the final turn; 20 turns instead of 21 will not make a lot of difference to the unit’s performance. Alternatively, you can remove one strand from the coil wire so that there are nine rather than ten strands. The coil can also be wound with 16 strands of 0.4 mm ECW (effective cross sectional area of 2.01 mm 2 ) or RF braid provided that the cross sectional area is around 2 mm 2 . When the winding is complete a layer of insulating tape is wound around the coil. Standard insulating tape is suit- able here; the coil temperature never exceeds hand-warm during operation. The parts list specifies two identical core halves with a 0.5 mm gap, once the coil is assembled the total air gap is 1 mm. If you use core halves without any air gap it will be necessary to sep- arate the two halves with some 0.5 mm thick non-conducting material 46 elektor electronics - 1/2006 Test results and efficiency Input voltage (V) Input current (A) Input power (W) Output voltage (V) Output current (A) Output power (W) Efficiency r| (%) 10.8 4.25 45.9 18.93 2.32 43.9 95.7 10.8 5.59 60.4 18.92 3.05 57.7 95.6 10.8 8.49 91.7 18.90 4.59 86.8 94.6 10.8 11.23 121.3 18.88 5.99 113.1 93.2 12.0 3.84 46.1 18.93 2.34 44.3 96.1 12.0 5.06 60.7 18.92 3.08 58.3 96.0 12.0 7.63 91.6 18.90 4.62 87.3 95.4 12.0 10.00 120.0 18.89 6.00 113.3 94.5 13.2 3.48 45.9 18.94 2.33 44.1 96.1 13.2 4.56 60.2 18.93 3.06 57.9 96.2 13.2 6.91 91.2 18.91 4.61 87.2 95.6 13.2 9.03 119.2 18.89 5.99 113.2 94.9 14.4 3.18 45.8 18.95 2.33 44.2 96.4 14.4 4.16 59.9 18.94 3.05 57.8 96.4 14.4 6.29 90.6 18.92 4.61 87.2 96.3 14.4 8.24 118.7 18.90 6.00 114.4 95.6 in order to achieve the 1 mm air gap. Larger outline capacitors were chosen for C5 and CIO with a lead spacing of 7.5 mm, these are better at handling high current and have lower losses. Begin assembly by fitting the resistors to the PCB then the fuse holder, next comes the spade connectors then the preset followed by the electrolytic capacitors (observe correct polarity) and the coil assembly. Before the FET and diode are soldered into the PCB a bend should be intro- duced in the leads to help reduce the mechanical stresses on the soldered joints when the device heats up. Both semiconductors must be insulated from their heat sink using insulating wash- ers and an insulated bush for the M3 mounting bolts and don’t forget to apply a little thermal compound. Ensure that these devices are well sol- dered in place because the leads will be carrying several amps. The heatsink Figure 7. All components including the wound coil fitted to the prototype board. 1/2006 - elektor electronics 47 HANDS-ON POWER SUPPLIES can be taller, i.e., 50.8 or 63.5 mm with 9 K/W or 8 K/W respectively. The proto- type is fitted with 38.1 mm high heat sink at 11 K/W. From the efficiency viewpoint it would be better if the diode had a smaller heat sink because the diode’s forward conduction voltage decreases with increasing temperature. However a smaller heat sink may lead to overheating if the output is over- loaded. A 20TQ045 diode from IRF can be substituted for Dl; this device has a slightly smaller forward voltage drop. There is no advantage in letting the FET run warmer, its channel resistance (R D son) increases with increasing tem- perature. Finally fit transistors T2 and T3 along with IC 1 and take the oppor- tunity to double check all the compo- nents and soldering before you move on to the next phase and connect power to the adapter. Power on Before the unit is powered up for the first time turn the preset PI fully clock- wise to produce the minimum output voltage. For testing use either a power supply capable of supplying 12 V at 10Aoral2V vehicle battery. Initially adjust the power supply current limit to 200 mA or, if you are using a battery, connect a 5 W resistor (47 or 56 Q) in series with the positive supply lead to the adapter. Double check that the pos- itive lead of the power supply is con- nected to K1 and the negative lead to K2 (nearest to the PCB corner). When no obvious malfunction occurs with the power connected (no excess current drawn from the supply and no smoke signals...) the current limit can be increased (or the series resistor removed). Connect a multimeter to the adapter output connections K3 and K4 (the negative terminal is nearest the board corner again) and check that the output voltage lies in the range of 18 to 19 V. With no load connected to the adapter slowly adjust PI to ensure that it can achieve an output voltage of 19.4 V. Now use either an electronic load or a combination of high power resistors (4.8 £2 at 100 W) and adjust PI for 19 V output voltage at full load (5 A). You may notice that when the adapter is operating under full load conditions the output voltage will bounce up briefly by 1 V whenever the load is discon- nected. The output quickly returns to its regulated level and in practice this design ‘feature’ is not a problem for a laptop adapter application. The finished unit can be mounted in an enclosure. The high efficiency achieved by this design means that very little heat is produced by the unit and there is no need for a fan. A few holes in the case will be sufficient just to allow a little air circulation. Before the unit is connected to the cigarette lighter socket make sure that it (and the plug) are capable of handling 10 A. Connect the adapter to the PC with a suitable lead and connector, double check that the plus and minus are con- nected to the correct input pin of the laptop or notebook PC — never assume that it is equipped with reverse voltage protection! (050029-1) Michael Schon schoen.michael@inode.at Advertisement Servicing Your Complete Prototype Needs Prmtyjfts sf u# cost Totting mtSutit'A An ¥ contm met ILfiJUFIJ EURQCABD nm irmsfrY stvrt&tf qmsy Fttitm ii’jj Shifts / CAD raa^V.fvr + JiJUiV.ng 1 + Atatptaft 4 VAT £ 29 . 89 * 'SMW0 tt!OS r.i'r Pt-Cfi - ► 40 h ah« it -mj gw m I* es®0- .PC8-POOL.COM 01% ' tprnr>h DON'T LOSE YOUR TEMPER Before phoning us - if you are looking for a hard-to-find part. We have over 20,000 items in stock - including obsolete and up-to-date parts. WHY NOT VISIT OUR WEBSITE www.cricklewoodelectronics.com 2N 2SA 2SB 2SC 2SD 2P 2SJ 2SK 3N 3SK 4N 6N 17 40 AD ADC AN AM AY BA BC BD BDT BDV BDW BDX BF BFR BFS BFT BFX BFY BLY BLX BS BR BRX BRY BS BSS BSV BSW BSX BT BTABTB BRWBU BUK BUT BUV BUW BUX BUY BUZ CA CD CX CXA DAC DG DM DS DTA DTC GL GM HA HCF HD HEF ICL ICM IRF J KA RIAL LA LB LC LD LL LM M M5M MA MAB MAX MB MC MDAJ MJE MJL MM MN MPS MPSA MPSH MPSU MRF NJM NE OM OP PA PAL PIC PN RC S SAA SAB SAD SAJ SAS SDA SG SI SL SN SO STA STK STR STRD STRM STRS SV1 T TATAA TAG TBA TC TCA TDA TDB TEA TIC TIP TIPL TEA TL TLC TMP TMS TPU U UA UAA UC UDN ULN UM UPAUPC UPD VN X XR Z ZN ZTX + many others We accept Mail, telephone & email orders. Callers welcome. Opening hours Mon-Sat 9:30 - 6:00 ■ i VISA Connect Cricklewood Electronics Ltd 40-42 Cricklewood Broadway London NW2 3ET Tel: 020 8452 0161 Fax: 020 8208 1441 sales @ cricklewoodelectronics.com 48 elektor electronics - 1/2006 LABTALK INFOTAINMENT Luc Lemmens Now and again something goes amiss in a circuit: one or more components overheat and the circuit board becomes partly charred or burnt. Such overheating normally results from too much current flowing through components that cannot handle the load. Recent research in the Elektor Electronics lab has shown that the same effect can also be achieved without connecting power to the circuit. What's more, the process has been perfected, so it's not limited to a localised charred or burnt area. The impetus for the experiments came from the constantly increasing miniaturisation in electronics. Here in the Elektor Electronics lab, we're not afraid of soldering even the smallest SMD components by hand, but with some components (such as modern ball grid array pack- ages) it's simply impossible to reach the contacts with a nor- mal, old-fashioned soldering iron. Although special equipment is available for this sort of solder- ing work, such as rework sta- tions and reflow ovens, the prices are rather steep for a rela- tively small laboratory. According to professional col- leagues at a major light-bulb company, it's completely unnec- essary to buy that sort of equip- ment if you only need to build the occasional prototype. They said an old-fashioned electric hotplate worked just fine for them. Fully convinced of their profes- sional expertise (and even more of our own), and following the motto 'whatever they can do, we can do too', on a pleasant autumn day we placed our first prototype PCB with a BGA on a hotplate. The temperature regu- lation of such devices is usually fairly crude, so to be on the safe side we started with the lowest setting. That proved to not yield the desired result, even after a relatively long time - the solder paste simply refused to melt. We drew the logical conclusion: the temperature was too low. Setting the heat a bit higher was also no help. Then we though that per- haps the board wasn't making good thermal contact with the hotplate. Although the bottom of the board heated up quite quickly, the top didn't. Maybe it would be better to put the circuit board on a sheet of aluminium spaced a bit above the hotplate, so it would heat up more evenly? That turned out to finally generate results. More specifically, the result was that our experiment was even noticed in the reception area, which is one floor down and at the other end of the building. We received an agitated phone call asking whether something was burning upstairs. Yes, there was, even if it was only some evil-smelling substance smoulder- ing on the hotplate. Staff Man- agement and other officials paid us a personal visit to let them- selves be informed about the rev- olutionary new development in the lab. Naturally, the situation was basically amusing, but as someone from Staff correctly remarked, it wasn't entirely harmless, even aside from the actual fire hazard. You never know what nasty vapours may be released when that sort of experimenting gets out of hand. In any case, things didn't smell all that fresh, and we decided to discontinue that line of study for the sake of safety en the environ- mment. Anyhow, we'd already used up our stock of PCBs. All of this led to the decision to take a more serious approach to the question, which ultimately resulted in the reflow oven described elsewhere in this issue. That amounted to convert- ing an off the shelf, inexpensive electrical oven into a highly use- ful piece of equipment that we now regard as essential for building prototypes. The temper- ature is kept nicely under con- trol, precisely according to the specified heating and cooling curves. And beside that, ovens are useful for more than just bak- ing circuit boards! (050356-1) Figure 2. Even if the oven temperature is well regulated, you still have to make sure that the components can handle it. 1/2006 - elektor electronics 49 HANDS-ON TEST & MEASUREMENT Accurate to 1 0 Ton Giesberts Despite the digital revolution there continue to be many photographers who still prefer to work with an Analogue' SLR camera. While most of these cameras have a reliable mechanical construction, after years of use it is worthwhile to check and, if necessary, to adjust the shutter time. With this circuit we offer the ability to measure the shutter time accurately so that you can do this calibration yourself. We have already published a schematic for a shutter time meter in Elektor Elec- tronics on an earlier occasion. At that time (1981), electronics was only just making an appearance in the world of photography These days, it is impossi- ble to imagine photography without electronics, when just about everything is electronically driven. However, the ‘old’ cameras do not have to be written off just yet. Many an enthusiast swears by their reliable, familiar equipment. It is obvious that this equipment also requires maintenance to keep it in opti- mal working order. That is why we now present a revised circuit, which contains ICs that are more easily avail- able than the MK50398N, among oth- ers, used in 1981. We have selected a counter IC from Maxim, the ICM7217AIPI, which was originally marketed by Intersil. This IC has a built-in 4-digit presettable up/down counter as well as a driver for four 7-segment displays. In addition we use a dual BCD counter type 74HC4518 to divide the clock signal. Circuit description As already mentioned, we use the ICM7217. The current source outputs on this IC would under normal circum- 50 elektor electronics - 1/2006 +5V © +5V © IC2 = 74HC4518 IC2.B ION 15 CTRDIV10 E >1 0 + >C 1 2 CT=0 3 7 ^C6 220( ^6V ^^ OOn R12 12 . © ■>? IC2.A CTRDIV10 E >1 0 + >C 1 2 CT=0 3 IC3 = 74HCU04 R8 H 10M h RIO IC3.A v2 XI 1 1 C2 IC3.B R9 V±_ 100kHz R11 lOp X C3 lOp T P TP1 r A SI. A 13 S2 . N RESET 13 14 10_ 11 _ 12 20 24 BCD1 ^ 5 SA BCD2 SB BCD4 IC1 SC BCD8 SD SE CNT SF SCAN SG RESET C/B UP/DWN ZERO LR/OFF EQUAL ICM7217A LC/IOF D4 DSP C D3 D2 STORE Dl 23 R13 27 R14 25 28 R16 22 R17 26 21 R19 68 a 68 £1 68 a 68 a 68 a 68 n 68 a 1 2 _ 3_ 15 16 17 18 19 +5V a o D1 TP2 0 R6 HSDL-5420 X BC557B R4 H 1M5 | — <> LD4 LTS4301 E LD3 LTS4301E LD2 LTS4301E LD1 LTS4301E 10 a 10 g a 10 g a 10 g a 7 5 :/T/7 7 5 7 5 •LI g 4 2 1 ■Lllo g 4 2 1 ■Lllo g 4 2 1 ■Lllo g dp CC CC 6 dp CC CC 6 dp CC CC 6_ dp CC CC +5V © 1 12 S1B R20 +5V — n^n— © A IC3.F ^rn^rr IC3.E IC3.D QO 9 1 IC3.C Ja 1 1 T2 — (n R 3 R 5 y\y BC547B T3 BS170 rUf IC4 +5V © D2 >9V ©~ g M t 1N4004 7805 0 » C9 □ 10(1 63V C8 IC2 10(1 63V A 04 IC3 C5 100n lOOn 050199-11 Figure 1. The schematic shows a number of similarities as well as differences compared to the design from 1981. The basic idea is the same, but the implementation is clearly different. stances make series resistors unneces- sary. However, the present generation of LEDs require less current, so we decided it would be better to limit the current through the LEDs with R13 through R19 (see Figure 1). The IC also contains a leading zero blanking function (suppressing leading zeros). We have permanently enabled this function, because it makes the read-out a little clearer. While the counter is being reset (S2) all displays are off, except for the decimal point. This decimal point will therefore always provide an indication whether the circuit is switched on or not. Range switch SI is a rotary switch with two poles, which has to be (mechani- cally) limited to three positions. The first pole determines the input signal for the counter, the second pole selects the correct decimal point for the dis- play. The ranges we have selected are 99.99 ms, 999.9 ms and 9.999 s. To allow the counter to count to its maximum value in each range, three different clock frequencies are neces- sary. They are 100 kHz, 10 kHz and 1 kHz. The 100-kHz clock is generated using a 100-kHz crystal and a standard un-buffered inverter from the HC- series (IC3, a 74HCU04). The other two clock frequencies are generated using two decade counters in series. For this we use a dual BCD-counter (IC2, a 74HC4518). The most important part of the circuit is the method that translates the shut- ter time into a usable signal for the counter. This is realised by placing a small, fast IR-photodiode (Dl, a type HSDL-5420) at the rear of the camera, the side that normally holds the film. Via a discrete amplifier stage (Tl, T2), the light received by the diode is used as the measuring window. R1 protects the amplifier stage in the event that the connections to the diode are acciden- tally short-circuited or have a voltage applied. The amplifier has a small amount of hysteresis added (R4), which improves the switching of the two tran- sistors and makes the circuit less sen- sitive to noise. Since the counter with its multiplexed display is a source if quite a bit of noise, the combination of R7/C1 provides additional decoupling of the power supply voltage. The output of the amplifier (collector of T2) is used to gate the clock pulse to the counter input. This is realised quite simply by using a MOSFET (T3) to either short, or not short, the clock sig- nal via a series resistor (R10) to ground. This way, the two decade counters also do, or do not, have a clock signal and the photodiode there- fore determines whether the counter receives clock pulses or not. As soon as the photodiode receives enough light, that is, when the shutter opens, the counter starts to count and the display indicates the number of milliseconds. You need to check your- 1/2006 - elektor electronics 51 HANDS-ON TEST & MEASUREMENT Figure 2. These photos clearly show how the top and bottom sides of the PCB are assembled. In order to make the PCB as compact as possible the parts are quite densely mounted. self that the range of the counter is not exceeded. This does no harm, because the counter simply starts from the beginning again, but the total shutter time is then not displayed properly Table 1 shows a number of common shutter times converted to millisec- onds, so that you can immediately compare the displayed value with what it should be, according to the camera. For shutter times from 1/1000 to 1/15 the smallest range provides the greatest accuracy. For 1/8 to 1/2 use the 1000 ms range. And for shutter times greater than 1 second, use the largest range (up to 10 s). The power supply for the circuit is reg- ulated with a 7805. The current con- sumption of up to 80 mA makes a mains adapter a logical choice (for example 9 V DC ). It is also possible to use four AA-size batteries as the power supply, because the circuit is likely to be used for a limited time only. With 2000 mAh capacity per battery, the circuit should theoretically work for about 25 hours. Note that in this case the voltage regulator needs to be a low-drop version and D2 (reverse polarity protection) needs to be omit- ted. Construction The construction of the PCB requires more attention than usual. We have kept the circuit as compact as possible and therefore have not designed for a specific enclosure. We leave a suitable housing to your imagination. Note the order of placing the components. The Figure 3. The PCB is double sided to save space. 52 elektor electronics - 1/2006 layout is double sided and components are also mounted on both sides. This has been done because of the position of the displays on the PCB. These are on the solder side under IC1. Naturally, the most appropriate place for the rotary switch is on the same side as the display, and the same goes for the reset-switch (S2). All the other parts are mounted the usual way, on the component side of the PCB. Use single-in-line socket strips for the displays and IC1. This is necessary for the displays because no IC-sockets are available for the 2x5 contact arrange- ment. For IC1 this is necessary because otherwise the plastic cross supports for the IC socket will get in the way of the connections for the dis- plays. For the displays it is better to stack the sockets two high, because the rotary switch SI is quite tall. S2 will also have to be mounted a little higher. To save space, it is possible to mount the voltage regulator IC4 flat on the component side of the PCB (as a continuation of the PCB). Connecting and measuring For the measurement setup only the camera, the measuring circuit and a 100-W incandescent lamp are required. The lamp is placed 10 cm in front of the axis of the lens. The aperture is fully opened. The rear of the camera is also opened. If required, D1 can be con- nected to the PCB with as short a screened cable as is possible. Connect the screen to the anode because that is the ground connection. The cathode of the diode can, according to the datasheet, be recognised by a mark- ing, however in practice we deter- mined that this indicated the anode instead. To be sure that the diode is connected the right way around, meas- ure the voltage drop across the diode. This should be about 4.5 V. If that is not the case, the diode is connected the wrong way around. Place the rounded side of the photodiode in the middle behind the shutter where the film normally is. Put the camera in manual operation and reset the counter before making a measurement. The display indicates a cumulative result. For an average you could, for example, make ten measure- ments without resetting the counter in between. Subsequently, you need to divide the end result by ten, resulting in average value. Practice We have made some measurements using an older SLR camera. These measurements provided some interest- ing results. For each of the five shutter times we made ten measurements and took the average. This gave the follow- ing results: / 000 produced Mbo produced Zo produced Mb produced 1 produced 0.99 ms 4.168 ms 16.04 ms 83.739 ms 0.95 s. A clear exception is the 1/15 setting which is wrong by 25%. A deviation like this is not all that bad in practice. A deviation of up to 20% is still con- sidered good and even a deviation of Table 1. Shutter Time Conversion Table 1 /2000 0.50 ms 1/1000 1 .00 ms 1/500 2.00 ms 1/250 4.00 ms 1/125 8.00 ms 1/60 16.67 ms 1/30 33.33 ms 1/15 66.66 ms 1/8 1 25 ms 1/4 250 ms 1/2 500 ms 1 1 000 ms 30% is usually not visible in the ulti- mate prints. Conclusion Except for the 4-digit counter, the new circuit contains only standard parts. The LED displays follow an industry stan- dard and can be replaced by other types if necessary. The revised shutter time meter is, just like its predecessor, a very accurate measuring instrument, which could also be used for other applications that require exact time measurements. ( 050199 - 1 ) COMPONENTS LIST Resistors: R1 = lkD R2 = 47kD R3 = 470kQ R4 = 1 R5,R6,R 1 0,R 1 2 = 4kD7 R7 =] on R8 = 1 0 R9 = 270kD R1 1 = lOkfl R13-R20 = 68D Capacitors: Cl = IOOjiF 25V radial C2,C3 = lOpF C4 ,05,06 = lOOnF 07 = 220|iF 16V radial C8, C9 = IOjiF 63V radial Semiconductors: D1 = HSDL-5420 (Agilent) (Farnell) D2 = 1 N4004 T1 = BC557B T2 = BC547B T3 = BS170 IC1 = ICM721 7AIPI (Maxim) (Digi-Key) IC2 = 74HC451 8 103 = 74HCU04 104 = 7805 Miscellaneous: 51 = rotary switch, 6 positions, 2 poles 52 = 6mm pushbutton, 1 make contact LD1-LD4 = LTS-4301 E (LiteOn) (Digi-Key: LTS4301-B, JR, JS, JF) common cathode 1 2.9 x 9.7 mm, 1 0-pin device XI = 1 00kHz quartz crystal PCB, ref. 050199-1 from The PCBShop 1/2006 - elektor electronics 53 TECHNOLOGY E-BLOCKS David Daamen Many readers who have bought a starter kit asked us about the rest of the E-blocks. There are quite a lot of them and it would be tedious if we just gave you a list of the modules. There is only room to describe one module in this article, but on our website you can find a comprehensive catalogue. But first we'll give an answer to the all-important question what the situation is regarding the circuit diagrams for the E-blocks. Figure 1. EB023, the E-blocks Internet board with a hardware TCP/IP stack. We’ve had a lot of positive feedback to the E-blocks articles, for which we’re grateful. One question stood out because it was asked by so many of you: Are there any circuit diagrams available for the E-blocks? The answer to this is ‘yes’. On the ‘ELSAM’ mini-CD, which is included with all ‘upstream-boards’ (program- mers and such like), is a section that contains the data sheets, including circuit diagrams, for all E-blocks. If you don’t have an upstream board and you buy an E-block separately, you can obtain the circuit diagram from us on request via email. We are aware that some of the circuit dia- grams on the mini-CD are not very clear. At this moment Matrix Multi- media are working on a solution to this problem. We would advise you to keep an eye on our website, since any news on this subject and other information regard- ing E -blocks will always be shown on the Internet first! Get online And talking about the Internet, did you know that there is an E -block that can be used to connect your system to the Internet? This becomes a piece of cake when you use the EB023 E-blocks Internet module (see Figure 1). It is even easier when you use Flowcode Professional, since a free expansion module is available for this version from our website. This gives you access to all the macros required to use this board. It’s the same as for the other E -blocks: you don’t have to worry about hard -to -get parts or configuring individual registers and the like. All that’s left to do is to decide on the details of the program operation! Specifications The E -blocks Internet board is based on the W3100A made by WizNET. This module has a complete TCP/IP stack on board, which makes it easy to add TCP/IP functionality to an existing microcontroller application, without having to write a software stack. 54 elektor electronics - 1/2006 The board has a 10/100 Mbps Ethernet connector (in a normal configuration, so a crossover cable is needed for a direct connection to a PC, see Fig- ure 2) and supports UDR IR ARR ICMR DCHR ARR DLC and MAC. This board communicates with the microcontroller board via I 2 C. The jumpers on the PCB can be set for dif- ferent I 2 C addresses, making it possible to connect several modules to one bus. All in all, this module is perfect to quickly add a simple webpage to your embedded system. This then permits (measurement) data to be inspected remotely. And in combination with Flowcode this board is ideal for teach- ing the basics of the Internet and embedded computing. In the inset John Dobson from Matrix Multimedia tells us about his experiences with E- blocks and the Internet board in an educational environment. The E-blocks Internet board is available For more details go to: (065029-1) from Elektor Electronics for £ 71 .95. http://www.elektor-electronics.co.uk/ PC RJ45 CAT 5 crossover cable 't v P E- blocks system ■HP Ol Figure 2. A crossover UTP coble is needed for a direct network connection to a PC. E-blocks in education E-blocks are not just ideal for Vapid prototyping', but are also very useful in an educational environment. Matrix Multimedia has had a lot of positive experience with E-blocks in educa- tion. John Dobson explains: "The Internet board that you're using here is a very good example. Most students are very interested in the Internet and now they can do that as part of their studies. For example, one of the first tasks given to them is to create a temperature monitoring system that operates via the Internet. This system consists of a temperature sensor that is connected to a PIC multiprogrammer via a sensor interface. Apart from the Internet board, an LCD board is also connect- ed to the multiprogrammer. In this way the temperature can also be shown locally (see Figure 3). The temperature sensor is in fact just a simple NTC resistor, which has the following formula for the temperature: Figure 3. E-blocks temperature logger via the Internet using a multiprogrammer, sensor interface, LCD, temperature sensor and Internet board. T = [KO + Kl(lnlOOOR) + K2 (In 1 000R) 3 ] 1 -273.15 KO = 1.021 19 x lO- 3 K1 = 2.22468 x 10-4 K2 = 1.33342 x 10‘ 7 In this formula R is the resistance of the NTC. The NTC and a 10 kOhm resistor form a potential divider. The output of this potential divider is connected to the A/D-converter and then converted into a 10-bit digital value (via the sensor interface and microcontroller board). The students are then given the following tasks: 1 . Create a program (using Flowcode) that reads the 10-bit value from the temperature sensor and then displays it on the LCD display as a decimal value between 0 and 1023. 2. Add a web page to the program where this value is also displayed. 3. Use JAVA to create a web application (running on the PC) that takes this value and converts it into the correct temper- ature, using the above formula. These tasks can be given to students at different levels of dif- ficulty, depending on their knowledge and the available time. Somebody who is already familiar with Flowcode should be able to complete tasks 1 and 2 in about an hour with the help of the Internet macros. If that is too easy for them, you could ask the students to develop a web server themselves, using the TCP transport-layer macros, which are also available for use with Flowcode. It then becomes a com- pletely different story!" 1/2006 - elektor electronics 55 HANDS-ON HOME AUTOMATION Electronic engineers are often ardent collectors. "Throwing these old parts away would be a waste", is an often-heard phrase. This results in attics and garages that are overflowing with boxes full of the things, much to the dismay of the other occupants of the house. A fair number of these items can be used in this design, reducing the size of your spare parts mountain. The design for the attic window con- troller is based around the well-known PIC16F84. This versatile, and inexpen- sive, microcontroller has almost become a standard workhorse for pro- jects like these. The program is written in a language called ‘JAL’, which we’ll cover later on. An old windscreen wiper motor is used to open and close the window. Description Figure 1 shows all the electronic modules used in this design. With the help of the circuit diagrams in Figure 1 we’ll explain how the circuit works 56 elektor electronics - 1/2006 and describe the part played by the different modules. At the hart of the circuit is IC2, a PIC16F84. This microcontroller uses a rain sensor and a temperature sensor to keep in touch with the outside world. The signals from these sensors affect what the controller shows on the display and what the motor does. The temperature is read every 30 seconds, whereas the rain sensor is monitored continuously. For the display a standard 2x16 cha- racter LCD is used (also available from Elektor Electronics, order code 030451- 73; see Figure 5). T1 and T2 have to deal with the relati- vely large current of the motor. They may of course be different types than those specified in the parts list, as long as they can withstand the current (minimum 3 A, and preferably more because of the large peak currents of the motor). The driving voltage (12 V) probably won’t be a problem. RB6 and RB7 on the microcontroller are used to drive the gates. T1 and T2 are connec- ted to the ground side of the motor, since in this configuration there is no need to use a level-shifter. Figure 2 shows how the windscreen wiper motor is set up. In Figure 3 you can see the mechanical construction made by the author. It isn’t overly dif- ficult, but it helps if you don’t have two left hands. The function of switches SI and S2 depends on the mode. During automa- tic mode the temperature at which the window is opened is increased by SI and decreased by S2. When manual mode is selected and SI is pressed the motor will turn on for a certain time, which has been defined in the soft- ware. This causes the skylight to open. How far the window opens depends on how long the motor is turned on. When S2 is pressed during manual mode the window will be closed. This is because the motor will stay on until the slider stops making contact with the slip-ring. At that instant the motor is in its original position and the window will therefore be shut. S3 is used to switch between manual and automatic operation. It is worth mentioning that a little trick +12V +5V © © +5V © RAIN SENSOR K5 O TEMP. SENSOR K2 O R1 SCLK SDA ri .1 C11 100n R7 © MCLR RA1 RAO IC2 RB5 RA2 RB4 RA3 RB3 RA4 RB2 PIC16F84 RBI RB0 RB6 RB7 OSC2 OSC1 JL +12V © K4 +12V 0 o- O- L1 I 22, liH C2 27p IC4 15 XI 1^1 16 Cl 4MHz ^27p 1 C3 R4 C4 □ lOOn 100n / 25V 1 7805 0 * / I S14K25 +5V -© C5 lOOn TEMP. SENSOR K1 Tr2 Tr3~ SCL SDA OS © IC1 LM75 AO A1 A2 C6 lOOn 18 17 11 10 12 13 R5 T FI +12V © 3A K6 +12V OPEN CLOSE o s IRFZ O o 34N O T— I S IRFZ 34N SI +5V © R8 S2 pi \ CONTR 10k RB4 RB5 RB0 RBI RB2 RB3 D1 H D2 H 2x 1N4148 S3 UP/ OPEN DOWN/ CLOSE MANUAL/ AUTO RAIN SENSOR R9 1 18k H IC5.A 3 y C9 &T\. K8 SE1 R12 1 5W tf K9 O lOOn K10 CIO 1h lOOn IC5 = 4093B IC5.C 8 JT& QQ D3 & 11 1N4148 IC5.D 12 C7 lOn R11 13 R10 LCD1 K3 i \~r 2 _r\_ 3 _r\. 4 ^ r _r\. 5 _r\. 6 ^ r _r\ 7 vr 8 r\_ 9 10 _r\. 11 _r\. 12 ^ r _r\. 13 14 vss VDD VO RS R/W E DO D1 D2 D3 D4 D5 D6 D7 IC5.B M & I C8 lOOn R13 X 6 mm. 8. Use the correct type, size and current-carrying capacity of cables and wires - see shaded table below. 9. A printed-circuit board like all other parts should be well secured. All joints and connections should be well made and soldered neatly so that they are mechanically and electrically sound. Never solder mains-carrying wires directly to the board: use solder tags. The use of crimp-on tags is also good practice. 10. Even when a Class II transformer is used, it remains the on/off switch whose function it is to isolate a hazardous voltage (i.e., mains input) from the pri- mary circuit in the eguipment. The primary-to-secondary isolation of the transformer does not and can not perform this function. approved switch, the contact gap in the off position is not smaller than 3 mm. The on/off switch must be fitted by as short a cable as possible to the mains entry point. All components in the primary transformer circuit, includ- ing a separate mains fuse and separate mains filtering components, must be placed in the switched section of the primary circuit. Placing them before the on/off switch will leave them at a haz- ardous voltage level when the equip- ment is switched off. If the equipment uses an open-con- struction power supply which is not separately protected by an earthed metal screen or insulated enclosure or otherwise guarded, all the conductive parts of the enclosure must be protec- tively earthed using green/yellow wire (green with a narrow yellow stripe - do not use yellow wire with a green stripe). The earth wire must not be daisy- chained from one part of the enclosure to another. Each conductive part must be protectively earthed by direct and separate wiring to the primary earth point which should be as close as pos- sible to the mains connector or mains cable entry. This ensures that removal of the protective earth from a conduc- tive part does not also remove the pro- tective earth from other conductive parts. Pay particular attention to the metal spindles of switches and potentiome- ters: if touchable, these must be protec- tively earthed. Note, however, that such components fitted with metal spindles and/or levers constructed to the rele- vant British Standard fully meet all insu- lation requirements. The temperature of touchable parts must not be so high as to cause injury or to create a fire risk. Most risks can be eliminated by the use of correct fuses, a sufficiently firm construction, correct choice and use of insulating materials and adequate cool- ing through heat sinks and by extractor fans. The equipment must be sturdy: repeatedly dropping it on to a hard sur- face from a height of 50 mm must not cause damage. Greater impacts must not loosen the mains transformer, elec- trolytic capacitors and other important components. Do not use dubious or flammable materials that emit poisonous gases. Shorten screws that come too close to other components. Keep mains-carrying parts and wires well away from ventilation holes, so that an intruding screwdriver or inward falling metal object cannot touch such parts. As soon as you open an equipment, there are many potential dangers. Most of these can be eliminated by discon- necting the equipment from the mains before the unit is opened. But, since testing requires that it is plugged in again, it is good practice (and safe) to fit a residual current device (RCD)*, rated at not more than 30 mA to the mains system (sometimes it is possible to fit this inside the mains outlet box or multiple socket). * Sometimes called residual current breaker - RCB - or residual circuit cur- rent breaker -RCCB. These guidelines have been drawn up with great care by the editorial staff of this magazine. However, the publishers do not assume, and hereby disclaim, any liability for any loss or damage, direct or consequential, caused by errors or omissions in these guidelines, whether such errors or omissions result from negligence, accident or any other cause. 3-core mains cable to BS6500 1990 with three stranded conductors in thick PVC sheath Max current 3 A 6 A 13 A conductor size 16/0.2 mm 24/0.2 mm 40/0.2 mm Norn cond area 0.5 mm 2 0.75 mm 2 1.25 mm 2 overall cable dia. 5.6 mm 6.9 mm 7.5 mm Insulated hook-up wire to DEF61-12 Max current 1.4 A 3 A 6 A Max working voltage 1000 V rms 1000 V rms 1000 V rms PVC sheath thickness 0.3 mm 0.3 mm 0.45 mm conductor size 7/0.2 mm 16/0.2 mm 24/0.2 mm Norn cond area 0.22 mm 2 0.5 mm 2 0.95 mm 2 overall wire dia 1.2 mm 1.6 mm 2.05 mm 3-flat-pin mains plug to BS 1363A 1/2006 - elektor electronics 61 HANDS-ON MODDING elektor electronics - 1/2006 Thijs Beckers Old-fashioned bakelite telephones are becoming increasingly rare in living rooms, but they're still common enough at rummage sales. We like convenience in our lives and our tools, and a phone that isn't attached to the wall by a cord is simply more convenient. So it's 'out with the old, in with the new' where phones are concerned. Stop! Don’t throw away your old phone! You can give it a second life using the circuit described in this arti- cle. That makes a nice Christmas pres- ent (maybe a bit belated) or gimmick, although it’s naturally a bit too heavy to carry around wherever you go. How- ever, it’s perfect on your desk at work or in the pub. You’re bound to draw a second glance or be accused of being off your head, but that will change when the phone rings - despite not having the usual cable - and you start having a lively conversation. What's inside Old phones are primarily based on mechanical systems, because there weren’t any PICs or microcontrollers fifty years ago. The mechanism behind the dial is no longer used, but that doesn’t mean it wasn’t a well-consid- ered design, far from it. Figure 1 shows how it works. When you dial a digit, the small, grey oval wheel (arrow 1) rotates once for every two digit positions while the dial is returning to its starting point. As a result, the contacts (arrow 2) generate a pulse for each digit position on the dial. The microcontroller uses these pulses to determine which number you dial. Figure 2 shows the mechanism with the dial in the rest state. The other set of contacts (marked by the arrow) is open in this state. That tells the micro- controller that the dial has stopped rotating. We use a 16LF88 microcontroller here. Figure 3 shows how it is connected to the rest of the circuit. The firmware can be downloaded free of charge from our website. A 3.7-V lithium polymer battery pro- vides the supply voltage. Although the minimum supply voltage is specified as 4 V in the 16LF88 data sheet, it still Figure 1. Good news: the mechanical construction of a 50-year-old phone is compatible with modern microcontrollers. The small grey wheel generates a series of pulses after you turn and release the dial. Figure 2. The lower set of contacts (see arrow) provides an electrical indication that the dial is at rest. 1/2006 - elektor electronics 63 HANDS-ON MODDING PIC STATUS © RAO/ANO RA1/AN1 RA2/VREF- RA4/AN4 © IC1 RBO RBI RB2/RX RB3 RB4 RA3/VREF+ 16LF88 SSOP RA5/VPP RB5/TX RA6/OSC2 RB6/AN5/PGC RA7/OSC1 RB7/AN6/PGD TX RX K5 I hook contact rotary dial (number) rotary dial (rest contact) Rio JPl |-o o| +3V8 (+) Tfm lal D2 +3V8 x. 13 5 7 ©©©© CHARGE EARHF+ EARHF- MIC_HF- MICHF+ ON/OFF SIMIO MODI PWRCTL RST MONICAM CCIN CTS GPIOI DSR EMMITX RX GM862 STATUS EMMIRX DTR RTS GPI04 GPI06 EARMT- EARMT+ MIC_MT+ MICMT- AXE TX SIMVCC SIMRST SIMCLK GPI02 Rl PDO PD1 DCD PD2 PD3 PD4 PD5 GPI03 GPI05 GPI07 GM862 STATUS 4 6 +3V7 + LiPoly o +3V8 © IC2 TPS73133 C2 lOOp C4 □ 100(.L (S V-REG * LDO 150mA EEN NC Cl loudspeaker lOOn C9 1 1 220n h microphone +3V3 -© C8 □ lOp 050317- 11 +3V8 © C5 C6 C7 ■ ■■ lOOn lOOn lOOn Figure 3. The schematic diagram of the control unit for the circuit. Most of the circuitry is contained in the GM82 and 16LF88, so only a few external components are necessary. +u works at 3.7 V (actually 3.8 V). The GSM module draws a peak current of around 2 A, which is more than most voltage regulator ICs like to provide, but a LiPo battery simply shrugs its shoulders. The GM862 module comes from Spark Fun Electronics. It is a GSM module that can handle three bands: 900 MHz, 1800 MHz and 1900 MHz. The micro- phone and speaker of the telephone are connected to it via K2. The module can drive most types of speakers directly. The sensitivity of the micro- phone input is 50 mV, so you can prob- ably manage without amplifying the microphone signal. A coupling capaci- tor and a resistor connected to the sup- ply voltage to power the electret micro- phone should be sufficient. Connect the dial contacts to K3 and the ‘off- hook’ contact to K5. The GSM module can be controlled by the PIC using AT commands. CONI and CON2 provide convenient debug access. K6 and I<7 were added for con- necting an optional keyboard, and they can be omitted. The ringer circuit is energised via K4 (see Figure 4). It has the difficult task of converting a 3.8-V DC signal to an AC voltage at around 60 V. A boost converter followed by an H bridge is used for this purpose. The relatively high voltage is necessary to make the clappers strike the bells with sufficient force. The frequency of the AC voltage determines how fast the bell rings. The ringer coil and C2 form a resonant cir- cuit with a frequency of approximately 22 Hz. Of course, the value of C2 can be adjusted to suit the electromagnetic ringer used in your phone. If all of this is a bit too much work for you, you can visit the Spark Fun web- site to order a ready-made telephone. ( 050317 - 1 ) Figure 4. The schematic diagram of the boost converter. This circuit generates the relatively high voltage needed to drive the electromagnetic ringer. Web link: www.sparkfun.com 64 elektor electronics - 1/2006 s two Starter Kits E-blocks Starter Kit professional 4 Switch board £19.30 Contains 8 push to make switches with upstream and downstream D-type connectors. Further E-blocks can be connected to this Switch board. 1 Flowcode for PICmicro MCUs V2 CD ROM Pro version £ 1 1 8.00 Flowcode is a very high level language programming system for PIC- micro microcontrollers based on flowcharts. Flowcode allows newcomers 5 LCD board £ 1 9.30 16 character, 2 line alphanumeric LCD display on a 4 wire serial bus. Flowcode macros for driving this E-block are available. to programming to design and simulate complex robotics and control systems in a matter of minutes. The use of macros allows students to control highly complex electronic devices without getting bogged down in understanding the programming involved. Flowcode is a powerful rapid development tool and is also useful as a means of introducing the need for C and assembly programming. Pro versions include RS232 comms, IDRA comms, Keypad control, multiple servo control, on-board EEPROM routines. Dutch and German language pack available. • Extra: PIC16F877 microcontroller E-blocks Starter Kit professional \ 33% L / d' sC ° U Special offer: £ 166.00 2 USB Multiprogrammer £ 77.30 This new PICmicro microcontroller programmer connects to your PC via USB to provide you with a low cost flexible PICmicro microcontrol- ler programmer for development and programming use. This board can be used with Assembly, C or Flowcode programming utilities provided by Matrix Multimedia. The board will program a range of 8, 18, 28 and 40 pin PICmicro® microcontroller devices from the 12, 16 and 18 series PICmicro range, using the programming software provided. A PIC16F88 device is included. 3 LED board £ 1 4.65 Contains 8 LEDs with upstream and downstream D-type connectors. Further E-blocks can be connected to this E-block. E- blocks Starter Kit basic Special offer: £ 96.00 Learn more about E-blocks? For more information, visit www.elektor-electronics.co.uk/eblocks Ordering Use the order form at the back or go to www.elektor-electronics.co.uk E-blocks will be shipped after receipt of payment. Prices are exclusive of postage. HANDS-ON HOME AUTOMATION Many households have a utility supply with a separate day /night tariff, where the electricity board delivers cheaper power during the night and weekends. It can be economical to use, for example, the washing machine at that time. That is, as long as you're actually there to turn it on at the right time, because modern electronically driven washing machines cannot be delayed with a simple timer switch. But with a handful of components you can build yourself a circuit than can actually do this! Timer for Washin Switching on command Goswin Visschers 66 elektor electronics - 1/2006 +5V© R3 R2 17 18 10k 10k 10k 10k R17 R16 R15 R14 14 X I- T3 T2 L® 4D © MCLR RBO RBI RAO IC2 RB2 RA1 RB3 RA2 RB4 RA3 RB5 . PIC16F84 RA4 RB6 RB7 OSC2 OSC1 C4 15 XI I I HOURS MINUTES 100p^ 16 C5 LD1 10 11 12 13 150 Q 1500 1500 1500 1500 1500 1500 1500 1 2 13 R6 11 10 7 HI 2 8 6_ 13 BC558 14 LD2 CA CA f b 9 c e d dp o LBo 13 11 10 BC558 T5 T4 €> € D8 14 CA CA f b 9 c e d dp o LBo MAN4710A MAN4710A LD3 2 13 11 10 7 8 BC558 14 LD4 CA CA f b g c e d dp o LBo 13 11 10 13 BC558 14 CA CA f b g c e d dp o BJo D7 MAN4710A MAN4710A f Toop | r XI = 32.768kHz If IC1 K1 230V 'V FI S 100mA TR1 9 V'V START K2 'o B40C1500R # » 1 RE1 in? 78L05 ■> * T1 47^ 16V C2 lOOn +5V © m <> lOOn D2 1N4148 BC547 +5V +5V D1...D6 = 1N4148 K3 K3' OUT D4 l /-I V Cl j o o D5 D3 GND GND OUT Jr D6 050058-11 Figure 1. The schematic for the timer switch consists of two parts, each of which has its own PCB. This electronic timer switch starts the washing machine by bridging the pushbutton for the start button for a few seconds using a relay. This does, however, require a small change to the washing machine. It is necessary to solder a wire to each side of the start pushbutton on the washing machine control PCB and to connect these wires to the relay contacts. The timer switch is built on two circuit boards. The power supply PCB with the relay will go inside the washing machine. The PCB with the microcon- troller is mounted in a separate enclo- sure and is attached to the outside of the washing machine. The connection between the two PCBs (switch signal and power supply) is achieved with a 3.5-mm stereo jack plug and mating socket. The design Figure 1 shows the schematic for the complete timer switch. The top section is the control part with a PIC16F84 and four seven-segment displays. The bot- tom section is the power supply and switching part that will be built into the washing machine. Power supply PCB The power supply PCB is a straightfor- ward design. A small mains trans- former provides an AC voltage of about 9 V. The direct voltage resulting from rectification and filtering is regulated by IC1 into a supply voltage of 5 V for the entire circuit. The relay, whose contacts bridge the start button, is energised with the aid of switching transistor Tl. The purpose of diodes D2 and D4 is to protect the base of Tl when the jack plug is either connected or disconnected. If the washing machine has an on/off- switch instead of a start button, then this switch can be bridged with a big- ger relay instead (however, take note of the maximum power rating of the washing machine). This also requires a small change to the software: after the washing machine has been switched on by the timer switch, the relay needs to remain energised until the clock is reset. 1/2006 - elektor electronics 67 HANDS-ON HOME AUTOMATION Control PCB In this part of the timer switch, the objective was to use as few electronic parts as feasible and integrate as much functionality as possible into the microcontroller. Diodes D3, D5 and D6 have the same purpose as D2 and D4, that is, protec- tion for the ports when the jack plug is connected or disconnected. XI is a 32.768 kHz quartz crystal, the same type as those used in watches. This frequency is a power of two, which makes it easy to divide it down to a half second (half the time period of the colon). The pins from the microcontroller are used as follows. Pins RBO through to RB6 are used to drive the seven seg- ments of the displays in multiplexed fashion. Resistors R4 to R13 limit the current through the LED -segments. Pin RB7 is for the colon (LEDs D7 and D8). Pins RAO through RA3, via driver tran- sistors T2 to T5, generate the multiplex drive signals for the displays. In addi- tion, RA2 and RA3 are read once per cycle of the ‘main loop’ to test the state of the two pushbuttons SI and S2. In case you would like to modify the software yourself, it is possible to use RAO and RA1 in the same manner as RA2 and RA3 and allow for two more pushbuttons. RA4 is used to switch the relay via Tl. Since this is an open-collector output, the purpose of R3 is to supply the drive current for Tl. Construction and Installation Figure 2 shows the PCB layout that has been designed for this timer switch. Here, the two parts are joined together, but normally the two PCBs will be mounted in different locations. The assembly of the PCBs is mostly routine, but don’t forget the three wire links on the control PCB. The construction and installation of this circuit has already been men- tioned at the start of this article. You can choose to keep the two parts com- pletely separate. That is, the power supply PCB inside the washing machine and the control PCB outside. The front of the washing machine could be fitted with a jack socket for the interconnection with the control PCB. The control enclosure can then be fastened on the washing machine somewhere (for example with mag- Figure 2. The two PCBs are shown here joined together, but in practice each one will be mounted in a different location. netic stickers). It is also possible to fit the entire cir- cuit inside the washing machine, but this is a much more challenging task because of the available space and the openings that are required for the front Figure 3. The prototype shown here differs slightly from the final printed circuit boards. 68 elektor electronics - 1/2006 ! COMPONENTS ! ! LIST ! Resistors: R1 ,R 1 8 = lkfl R2 = 1 00D R4-R7,R9 / R1 0,R1 2,R1 3 = 150D R8,R1 1 = 470fl R3,R 1 4-R 1 7 = lOkD Capacitors: Cl = 47 jiF 16V radial €2,03,06 = lOOnF 04, 05 = lOOpF Semiconductors: B1 = B40C1500R bridge rectifier (40V piv, 1 .5 A) D1-D6 = 1N4148 D7,D8 = LED, red, 3mm diam. IC1 = 78L05 IC2 = PIC16F84, programmed, order code 050058-41 LD1-LD4 = 7-segment display, e.g. Fairchild type MAN471 OA T1 = BC547B T2-T5 = BC558 Miscellaneous: FI = fuse, lOOmAT (slow) with PCB mount holder K1 ,K2 = 2-way PCB terminal block, lead pitch 7.5mm K3,K3' = 3.5mm stereo jack plug with socket R1 = 12V relay (e.g. Siemens V2 3 05 7- 12V) S1,S2 = pushbutton (e.g., ITT D6-R-90) Trl = mains transformer, 230V primary, secondary 9V @ 1 VA (e.g. Block VB1, 0/1/9) XI = 32.768kHz quartz crystal PCB, order code 050058-1 Disk, PIC source and hex code, order code 050058-11 panel. This is why the author chose for the solution with the jack socket. Operation The operation is extremely easy. After the circuit is switched on, four dashes are shown on the display (‘ ‘). With one pushbutton (S2) you can increase the minutes in steps of 10 minutes, with the other pushbutton (SI), the hours in steps of 1 hour. Once the buttons have not been pressed for 1 second, the timer will begin to count down automatically. During the countdown, the time remaining is visible on the displays. 050058-12 Figure 4. This flowchart shows the design of the main program. 1/2006 - elektor electronics 69 HANDS-ON HOME AUTOMATION When the time is up, the relay is ener- gised and the display is turned off. After the relay is turned off again, the four dashes reappear on the display. If both pushbuttons are pressed at the same time, the timer switch will be reset and the four dashes will appear on the display. Software The code in the microcontroller has been designed to be as general-pur- pose as possible, so that this circuit can be used for other applications by changing a few constants. The code comprises two files: clock. asm that contains the machine code and clock.inc, which contains the constants and register definitions. These files are available free of charge from the Elektor Electronics website (and on floppy disk, order code 050058- 11 , for those without access to the Internet). The heart of the machine code file nat- urally consists of the main loop (lines 105 to 118). The bits in the ‘action_reg’ register are tested in the ‘main loop’ in order to determine the next action (see com- ments in the code). The seven-segment displays are driven in turn, after which the pushbuttons are tested. Then, depending on whether an interrupt has taken place, the time is updated. If the output has to remain energised permanently, instead of momentarily, the ‘goto acti_time’ command has to be replaced with ‘return’. A few constants can be changed: active_time Duration that the output is ener- gised in half seconds, (not rele- vant if the output has to stay on permanently.) hold_but_cyc Number of cycles to wait before a button can be operated again. Zero Jed. ..Err Jed Bit values that display a number on the seven-segment display. In the event the seven-segment displays are connected differently, the numbers can be displayed correctly via Port B by suitably changing these values. dubjdotjoit Bit value which represents the location of the colon. In this case the value is such that the two LEDs for the colon are driven via Port RB7. setmjout and sethjout Port numbers for Port A to which the minutes and hours pushbut- tons are connected. For further clarification, Figure 4 shows a flow chart of the main pro- gram. The charts for the various pro- gram parts referred to may be down- loaded as a PDF file from the Elektor Electronics website. You can find more details in the source code file supplied to us by the author. ( 050058 - 1 ) CONSTRUCTIO Elektor Electronics (Publishing) does not provide parts and components other than pcbs, fornt panel foils and software on diskette or ic (not neces- sarily for all projects). Components are usually available form a number of retailers - see the adverts in the magazine. Large and small values of components are indicated by means of one of the following prefixes : E (exa) = 10 18 P (peta) = 10 15 T (tera) = 10 12 G (giga) = 109 M (mega) = 10 6 k (kilo) = 10 3 h (hecto) = 10 2 da (deca) = 10 1 a (atto) = 10“ 18 f (femto) = 10“ 15 p (pico) = 10“ 12 n (nano) = 10“ 9 /x (micro) = 10“ 6 m (milli) = 10“ 3 c (centi) = 10“ 2 d (deci) = 10 _1 In some circuit diagrams, to avoid confusion, but contrary to iec and bs recommandations, the value of components is given by substituting the rel- evant prefix for the decimal point. For example, 3k9 = 3.9 kn 4/x7 = 4.7 /xF Unless otherwise indicated, the tolerance of resistors is ±5% and their rat- ing is l A- l A watt. The working voltage of capacitors is > 50 V. In populating a pcb, always start with the smallest passive components, that is, wire bridges, resistors and small capacitors; and then ic sockets, relays, electrolytic and other large capacitors, and connectors. Vulnerable semiconductors and ics should be done last. Soldering. Use a 15-30 W soldering iron with a fine tip and tin with a resin core (60/40) Insert the terminals of components in the board, bend them I slightly, cut them short, and solder: wait 1-2 seconds for the tin to flow 1 smoothly and remove the iron. Do not overheat, particularly when solder- ing ics and semiconductors. Unsoldering is best done with a suction iron or special unsoldering braid. 1 Faultfinding. If the circuit does not work, carefully compare the populated | board with the published component layout and parts list. Are all the com- IM GUIDELINES ponents in the correct position? Has correct polarity been observed? Have the powerlines been reversed? Are ah solder joints sound? Have any wire bridges been forgotten? If voltage levels have been given on the circuit diagram, do those meas- ured on the board match them - note that deviations up to ± 10% from the specified values are acceptable. Possible corrections to published projects are published from time to time in this magazine. Also, the readers letters column often contains useful comments/additions to the published projects. The value of a resistor is indicated by a colour code as follows. ( color 1st digit 2nd digit mult, factor tolerance black 0 brown 1 1 xlO 1 ±1% red 2 2 xlO 2 ±2% orange 3 3 xlO 3 - yellow 4 4 xlO 4 - green 5 5 xlO 5 ±0,5% blue 6 6 xlO 6 - violet 7 7 - - grey 8 8 - - white 9 9 - - gold - - xlO- 1 ±5% silver - - xlO- 2 ±10% none — — — ±20% Examples: brown-red-brown-gold = 120 Q, 5% yellow-violet-orange-gold = 47 kD, 5% j 70 elektor electronics - 1/2006 INFO & MARKET EMC GUIDELINES EMC DIRECTIVE From 1 January 1996, home-made equip- ment must take into account emc Directive 89/336/eec (emc = ElectroMagnetic Compatibility). Basically, the directive states that no equipment may cause, or be susceptible to, external interference. Here, interference means many phenomena, such as electromagnetic fields, static dis- charge, mains pollution in the widest sense of the word. Legislation Home-made equipment may be taken into use only when it is certain that it complies with the directive. In the United Kingdom, the dti (Department of Trade and Industry) will, in general, only take action against offenders when a complaint has been made. If the equipment appears not to com- ply with the directive, the constructor may be sued for damages. ce label Home construc- tors need not affix a ce label to their equipment. 965001 - 1-52 Elektor Electronics and the Directive The publishers of Elektor Electronics intend that designs published in the magazine comply with the directive. Where necessary, additional guidelines will be given in the arti- cle. However, the publishers are neither obliged to do so, nor can they be held liable for any consequences if the constructed design does not comply with the directive. This column gives a number of measures that can be taken to ensure that EE- designed equipment complies with the directive. However, these are needed only in some designs. Other measures, particularly in case of audio equipment, are not new and have been applied for some time. Why emc? The important long-term benefit for the user is that all electrical and electronic equipment in a domestic, business and industrial envi- ronment can work harmoniously together. Radiation The best known form of emc is radiation that is emitted spuriously by an apparatus, either through its case or its cabling. Apart from limiting such radiation, the directive also requires that the apparatus does not impart spurious energy to the mains — not even in the low-frequency range. Ferrite through-filters as illustrated are used for feeding cables through a panel. Immunity The requirements regarding immunity of an equipment to emc are new. Within cer- tain limits of ambient interference, the apparatus must be able to continue work- ing faultlessly. The requirements are fairly extensive and extend to a wide range of possible sources of interference. Computers Computers form the prime group for appli- cation of the directive. They, and micro- processors, are notorious sources of inter- fering radiation. Moreover, owing to the way in which their internal instructions are carried out sequentially, they are also very sensitive to interference. The notorious crash is but one manifestation of this. Enclosures A home-made computer system can comply with the emc directive only if it is housed in a metal enclosure. A minimum requirement is that the underside and rear of the enclosure is an l-shaped frame. All cabling must con- verge on this area or be filtered. If there are connectors on the front panel, a u-shaped metal frame should be used. Even better results are obtained if a 20 mm wide, 1 mm thick copper strip is fixed along the whole width of the rear wall with screws at 50 mm intervals. The strip should have solder tags at regular distances for use as earthing points. A closed case is, of course, better than an l-shaped or u-shaped frame. It is important that all its seams are immune to radiation ingress. Power supplies In any mains power supply, account should be taken of incoming and outgoing interfer- ence. It is good practice to use a standard mains filter whose metal case is in direct con- tact electrical contact with the enclosure or metal frame. Such a filter is not easily built at home. It is advisable to buy one with integral mains entry, fuse holder and on/off switch. This also benefits electrical safety in general. Make sure that the primary of the filter is ter- minated into its characteristic impedance — normally a series network of a 50 Q, 1 W resistor and a 10 nF, 250 V capacitor. Mains transformers must be provided with rc-networks at the primary and sec- ondary side. Bridge rectifiers must be filtered by rc-networks. The peak charging current into the reservoir capacitor must be limited by the internal resistance of the transformer or by additional series resistors. It is advis- able to use a 250 V, 2 W varistor between the live and neutral mains lines. At the sec- ondary side, it is sometimes necessary to use a transient suppressor, preferably fol- lowing the reservoir capacitor. If the supply is used with digital systems, a common-mode inductor in the secondary a.c. lines may prove beneficial for limiting radiation. For audio applications, an earth screen between primary and secondary is advisable. This screen must be linked via a short wire with the earthing strip. The supply must be able to cope with a mains failure lasting four periods and with mains supply variations of +10% and -20%. Peripheral equipment and earthing All cables to and from peripheral apparatus, such as measurement sensors, control relays, must be fed through the metal wall of the enclosure or frame. The earth lines of such cables must be connected directly to the earthing strip at the inside of the enclo- sure or frame via a wire not longer than 50 mm. When plugs are used, the cable earth, if any, must be connected to the earth pin or the metal surround of the connector. Basically, all non-screened signal lines must be provided with a filter consisting of not less than a 30 mm ferrite bead around the cable or bunch of wires. This bead may be outside the enclosure (for instance, around the pc-to-monitor cable). Leads that may have a resistance of 150 Q. must be provided with a 150 Q series resistor at the inside of the connector shell. If technically feasible, there should also be a capacitor from this point to earth. Commercial feed-through t-filters or 7i-filters may, of course, be used. In all other cases, screened cable must be used for connec- tions within the enclosure. Symmetrical lines must consist of twisted screened cable and be earthed at both ends. The earth plane of printed-circuit boards must be linked as firmly as feasible with the earthing strip, for instance, via a flexible flat metal strip or flatcable. Electrostatic discharge (esd) All parts of an equipment that can be touched from outside must preferably be made from insulating, antistatic material. All parts that can be touched and enter the enclosure, such as potentiometer and switch spindles, must be earthed securely. All inputs and outputs whose wires or con- nector pins can be touched must be provid- ed with an earth shield, for instance, an earthed metal surround via which any elec- trostatic discharge are diverted. This is most conveniently done by the use of connectors with sunken pins, such as found in sub-d connectors, and a metal case. Audio equipment Immunity to radiation is the most important requirement of audio equipment. It is advisable to use screened cables through- out. This is not always possible in case of loudspeaker cables and these must, there- fore, be filtered. For this purpose, there are special high-current t-filters or n - -filters that do not affect bass reproduction. Such a fil- ter must be fitted in each loudspeaker lead and mounted in the wall of a metal screen- ing box placed around the loudspeaker connections. Low-frequency magnetic fields Screened cables in the enclosure do not provide screening against the low-frequen- cy (< a few kHz) radiation of the mains transformer. Therefore, these cables must run as close as possible to the walls of the enclosure. Moreover, their braid should be linked at one end to the earthing strip. In extreme cases, the power supply should be fitted in a self-contained steel enclosure. Special transformers with a shading ring that reduce the stray field can lower the hum even further. High-frequency fields High-frequency fields must not be allowed to penetrate the metal enclosure. All exter- nal audio cables must be screened and the screening must be terminated outside the enclosure. This again necessitates the use of all-metal connectors. All cable braids must be linked to the earthing strip inside the enclosure. Owing to the skin effect, it is important to choose an enclosure with a wall thickness > 2 mm to ensure that internal and external fields are kept separate. Any holes must be either small (<20 mm) or be covered with a metal mesh. Heat sinks Heat sinks should preferably be inside the enclosure and be earthed at several points. Non-earthed heat sinks in switch-mode power supplies often create problems. If possible, place an earth screen between transistor and heat sink. Ventilation holes Standard mains filters built into a mains entry together with an on /off switch. The metal shell must be in firm contact with the enclosure. must be covered with metal mesh unless they are smaller than 20 mm. Ventilators should be fitted inside the case. Cables Cables often function as transmit/receive aerials. This applies equally well to screened cables. The braid of a coaxial cable must be terminated into a suitable connector such that it makes contact along the whole circumference. The braid may be used as the return path to obtain r.f. mag- netic screening. For a.f. magnetic screening it is better to use twisted-pair screened cables. In a ribbon (flat) cable, each signal wire should be flanked, if at all possible, by earthed wires. The cable should be screened along one surface or, preferably, all around. Cables that carry signals > 10 kHz that are not filtered in the enclosure, must be provided with a ferrite bead func- tioning as a common-mode inductance. Printed-circuit boards Elektor Electronics printed-circuit boards are provided with coppered fixing holes that are connected to the earth of the circuit. This arrangement, in conjunction with metal spacers, ensures good contact between the board and the circuit earth. Where this is important, boards have a special earth plane that can be connected, where feasi- ble, to the earthing strip via a flatcable. These boards normally have no other earth- ing points and their fixing holes are, there- fore, not coppered. (960006) T-filters and n-fi Iters ensure that interference cannot em te from, or enter, the equipment via signal lines. They are available in various cur- rent ratings and for various frequency ranges. 1/2006 - elektor electronics 71 HANDS-ON DESIGN TIPS Four Steps to LEDs Dr Thomas Scherer A guided approach Sure, there are many ways to power an LED from the mains. However, in good philosophical (and GPRS) tradition, the shortest way to success or any target for that matter is not necessarily the fastest — or, in ff-speak, the simplest circuits are not always the best. A lot can go wrong: a too small series resis- tor can vastly reduce the lifetime of the LED, while designing too many components into the circuit makes for a lot of wasted heat resulting in a really saddening efficiency figure. Here's a four-step design guide we publish in reply to a ques- tion we hear a lot lately: how do I make an LED light from the mains? Read and think along with us, 'mind the steps' here and there and find inspi- ration for your own designs! * V«A Warning. Components in the four circuits shown in this series are connected directly to the mains. To avoid electrification and risk of shock, the complete circuits must be encapsulated and insulated in accordance with all relevant electrical safety regulations. All component values are for a 240 VAC, 50 Hz mains voltage. Step #1: free heating included Running an LED from a dedicated power supply is not just inelegant, it is also, because of the trans- former, a rather bulky and heavy solution. Where no low-voltage DC power is available and full isolation between the mains and the LED is not absolutely neces- sary, it is possible to avoid that extra supply. To operate an LED directly from the mains we can, naturally enough, use a series resistor. Since the maximum reverse volt- age of an LED is typically around 5 V, a mains-voltage rectifier diode is also required in series. Because the mains rectifier diode will exhibit some leakage, and to be on the safe side we also wire a 1 00 kn resistor in parallel with the LED which helps to prevent excessive reverse voltage appear- ing across the LED: the power dis- sipation of this resistor will be negligible. The simplest circuit therefore consists of four compo- nents, including the LED. If we assume an LED current of 20 mA, we can calculate that the required series resistor is 240 V divided by twice 20 mA = 6 k£2 (the factor of two arising because we are only using one half-cycle of the AC waveform). A practical value is 6.8 k£2 (Fig- ure 1). The total power dissipa- tion will then be around 4.8 W, almost all used in heating the series resistor: the fraction used by the LED is less than 1 %. We might prefer to think of this cir- cuit as primarily a generator of heat rather than of light, but nev- ertheless in principle it works. We can derive some comfort from the fact that operation from a power supply is not particularly energy-efficient either. A quick back-of-the-envelope calculation: a typical small commercially-avail- able transformer will be rated at 0.5 VA with a secondary voltage of 6 V; unloaded, the transformer will deliver nearer 7.5 V. After a bridge rectifier and smoothing we will have a DC voltage of about 9.5 V. If the LED is to be supplied with 20 mA with a forward volt- age drop of 2 V, we must drop 7.5 V across the series resistor. The losses in the secondary side of the power supply total around 210 mW, when losses in the bridge rectifier are taken into account. Of this the LED sees only 2 V times 20 mA, or 40 mW. Things are actually even worse than this: the typical efficiency of such a small transformer at full load is only about 55 %. Here, at less than full load, efficiency is worse, possibly only 45 %. Thus 2 1 0 mW at the secondary side corresponds to 467 mW at the primary, meaning that 427 mW, or 91 % of the total input power, is lost as heat! ( 040287 - 1 ) 72 elektor electronics - 1/2006 Step #2: series capacitor To operate an LED directly from the mains we can, naturally enough, use a series resistor; this will, however, lead to about 99 % of the power used being dissipated as heat. So how about using the impedance of a capac- itor instead of the resistor? If we assume an LED current of 20 mA, we can calculate that the required series resistance is 240 V divided by twice 20 mA = 6 (the factor of two arising because we are only using one half-cycle of the AC waveform). The impedance of the series capacitor Cl must therefore also be 6 to (Figure 2). Using the formula for the cutoff frequency of an RC-network, here set to 50 Hz, we arrive at a value of 530 nF for Cl . We do not wish to overdrive the LED, and we choose the next available value in the E3 series for Cl : 470 nF. The effective current through the LED over a full cycle of the mains waveform will be about 15 mA when the effect of protection resis- tor R1 is taken into account. This will generally give enough bright- ness. What then is the purpose of Rl? Imagine switching on the circuit, with Rl missing, at the instant when the mains voltage reaches its peak value. A large current spike will pass through the LED via Cl , and it will light brightly — but only very briefly, before it turns into a wire link, or possibly a firecracker. Modern LEDs can only withstand a maximum cur- rent peak of around 0.5 A, and then only for a few microseconds. Exceeding this value will reduce the life expectancy of the LED, which rather cancels out its advantage in terms of long life in comparison with its incandescent cousins. Since this current surge can occur each time the circuit is switched on, we should limit it for safety to half of the maximum per- mitted value. Cl must therefore have a series resistor added to limit the surge current to around 250 mA. The peak value of the mains voltage is around 340 V, and so a resistance of 1 360 £1 is suitable. A sufficiently accurate value for Rl from the El 2 series is 1 .2 to. Anyone familiar with this type of circuit will immedi- ately see that this value is higher than usual: 330 £1 is a more com- monly-seen value. It is easy to appreciate that the LED will from time to time be driven outside its specification. Rectifier diode D1 is logically con- nected in parallel with the LED. R2 is a discharging resistor for Cl, preventing the pins of the pulled mains plug carrying enough energy to cause an elec- trical shock when touched. At 4.7 M£l, R2 is able to discharge Cl to about 2/3 within about two seconds. The resistor has to be dimensioned for 350 V mini- mum! In case of doubt, it is best to connect two 2.2 -M£2 resistors in series. Because Cl must carry alternat- ing current, D1 is connected in parallel with the LED, rather than in series. Since no more than about 2 V will appear across D1 in the reverse direction, we can use a low-voltage type such as the 1 N4001 . We can now take a look at the energy budget. Twice the LED current flows through Rl , and so a voltage of about 36 V is dropped across it. Rl thus dissipates almost 1 .1 W and so over 97 % of the total power taken by the circuit is lost as heat: not exactly a stunning performance! This is also a reason why lower values are frequently seen for Rl . At 330 £1, for example, the losses are practically divided by four, although the LED is then driven outside its specification: this affects reliability, leading to a greater probability of failure and shortened operating life. The the- oretical lower limit for Rl , without leaving any significant safety mar- gin, is 680 Q. In this case 0.5 W of power is dissipated as heat. A metal film resistor should not be used for Rl . With a value of 1 .2 to the peak dissipation will be nearly 1 00 W for a period of a few hundred microseconds: car- bon film resistors are better able to withstand this treatment. The most tolerant are the ceramic wirewound types: the small 4 W versions are suitable. Even if a value of 680 £1 is used, the ceramic 4 W types are preferred. Resistors rated at less than 0.5 W generally do not have a suffi- ciently high working voltage. What happens if we use a low current LED? Our remarks on peak currents still apply, but Rl can be made even smaller. The capacitance of Cl must be adjusted to suit the LED. A low current LED will operate on about 5 mA, corresponding to a value of 1 00 nF for Cl . ( 040287 - 2 ) Step #3: flicker-free R6 1N4001 Apart from their low efficiency, both the ohmic and the capaci- tive Voltage dropper' suffer from another major deficiency. Because a rectifier diode is required in series or anti-parallel with the LED (the allowable LED reverse voltage being limited to about 5 V) a decisive disadvan- tage is created: current flows through the LED only during one half-cycle of the mains wave- form, leading to a somewhat flickery light. Since LEDs do not share the thermal inertia of light bulbs, the 50 Hz flicker is clearly visible to many people. This is annoying if a white LED is to be used as a night light. First we turn to the problem of low efficiency. The circuit shown in Figure 3 limits the maximum surge current by connecting a capacitor in parallel with the LED. A diode (D2) is therefore also required. Now the value of the protection resistor R2 can be made small. Ideally we would reduce it as far as we can while protecting the other components adequately. First of all we need to consider the surge tolerance of the two diodes. Typical rectifier diodes in the 1 N4000 series have a half-cycle surge tolerance of 30 A. In order not to overly stress conductors, fuses (if any) and switches we should keep the current to less than 10 A. With Rl at 4 7 £1 we have a peak cur- rent of around 7 A. The diodes and C2 can all cope with 7 A. Rl now dissipates only 50 mW. Because of the peak power, which is over 1 kW (!) for around 1 |js, a ceramic wire- wound type is absolutely essen- tial. A carbon film resistor rated at, for example, 0.5 W will be destroyed in the blink of an eye in this application. Now to the problem of flicker- ing: the capacitor value can be chosen to be sufficiently large that it produces a reasonably smooth DC voltage. Resistor R2 linearises the resistance of the LED and thus stabilises the cur- rent through it. The dynamic resistance of an LED is relatively 1/2006 - elektor electronics 73 HANDS-ON DESIGN TIPS low: only a few ohms. Choosing a value of 1 00 £2 for R2 gives an acceptably steady current. When choosing C2 we observe that in order to limit the peak current through the LED to, for example, 250 mA, we need a value of roughly speaking twenty times that of C 1 . If C 1 is 470 nF, (see under 'Series capacitor') then 1 0 piF is ade- quate for C2. When smoothing a half-wave rectified AC voltage a larger capacitor would usually be used: the rule of thumb states that we should use at least 2 jjF per mA. This would give a theo- retical value of 33 pi F for C2, and in practice we would choose 100 |jF from the E3 series in order to have some- thing in reserve. Note that for a low current LED a current of 5 mA suffices: Cl should then be 100 nF and R2 should be increased to 270 £2. Of course, everything has its price: electrical energy is wasted as heat in R2. With a voltage drop of 1 .65 V and an average current of 16.5 mA we are spending an extra 27 mW for the sake of a steady light. To this we can add the losses in the two diodes, which at 0.75 V and 16.5 mA come to about 25 mW. In total the circuit there- fore takes around 1 34 mW and del ivers about 33 mW to the LED for its operation. With about 75 % of the power wasted as heat the efficiency of the circuit is already considerably better than using just a series resistor or capacitor. This advance requires a grand total of eight components. The upshot is that although the circuit might be a little more expensive, it does not generate significant quantities of heat yet produces a steady light. ( 040287 - 3 ) Step #4: the 1 00 Hertz LED 'Why use one component when a dozen will do?' might be your first thought on seeing this circuit. After all, we only need a series resistor to connect an LED to the mains. Simple circuits unfortu- nately have decisive disadvan- tages, including poor efficiency and flickering (see the other cir- cuit descriptions). Compared to the 'Flicker-free' circuit, Step #4 (Figure 4) is improved in an important way: the supply to the LED is full-wave rectified. The supply voltage for the LED pulses at 100 Hz in this circuit. Flicker at this frequency is almost imperceptible to the human eye. Because we are using 100 Hz, we can halve the value of smoothing capacitor C2. But there is a more attractive alterna- tive: we can leave C2 at 1 00 |jF and instead halve the value of R2 to 47 £2. As a consequence of the improved rectification using both half-cycles of the waveform we have to halve the series resist- ance, or halve the value of Cl . Film capacitors with suitable working voltage are easier to come by at 220 nF than the the- oretically correct 270 nF (under 'Step #2' we calculated a value of 530 nF for an LED current of 20 mA), and so we use that value. The LED current, with the reduced value for R 1 , will still be around 16.5 mA. Note that for operation with a low current LED around 5 mA is required. A value of 47 nF will then be suitable for Cl, and R2 should be increased to 1 50 £2. R2 now dissipates only about 1 3 mW. The diodes together have a total forward voltage drop of around 1 .5 V, and so at 16.5 mA about 25 mW is dissi- pated. Rl, at 47 £ 2 , also dissi- pates approximately 1 3 mW. The LED itself takes 33 mW. The over- all efficiency is thus considerably improved: at 51 mW only 60 % of the total power is lost to heat- ing the environment. What part do R3 and R4 play in this circuit? R3 is a discharge capacitor for Cl . This prevents, for example, the possibility of a finger receiving a dangerous shock from the pins of the plug after it has been removed from the wall. Using a value of 4.7 M£2 for R3 means that Cl is two-thirds discharged within one second. Do you remember the 2- times-2.2-M£2-in-series-trick in Step #2? Good! R4, on the other hand, ensures that C2 is discharged when power is applied so that it can have full effect in limiting the surge current through the LED. Its dissipation is negligible at under 1 mW. A small potted bridge rectifier (such as type B40C1000; 40V piv, 1 A) can of course be used in place of D1 to D4. The circuit is designed to be especially suitable for use as a low-power, flicker-free night light for a child's bedroom. In this case three series-connected high- efficiency white LEDs can be used in place of LED1 . Each of these LEDs will drop a voltage of about 3.6 V. Maximum light is obtained with an operating cur- rent of 25 mA, for which Cl will need to have a capacitance of 330 nF. Since values in the E3 series are easier to obtain, it is possible to use a 220 nF capac- itor in parallel with a 100 nF capacitor instead. The working voltage given for C2 is adequate, but in the interests of reliability might be increased to 25 V. There will be 1 1 V across the LEDs at 24 mA, for a total power of 260 mW, adequate for a normal-sized bedroom. The energy budget is as follows: Rl and R2 together dissipate about 52 mW. Adding the 1 2 mW dis- sipated by discharge resistor R3 and we reach 64 mW. The total operating power is therefore about 324 mW, of which less than 20 % is wasted. Total energy consumption is only 2.85 kWh per year. At only a few pence in estimated electricity cost per year, even our most par- simonious reader should be happy to leave the circuit plugged in. Finally, a note on safety: not forgetting general-pur- pose safety guidelines and regu- lations, electronics installed in a child's bedroom should be child- proof! ( 040287 - 4 ) elektor electronics - 1/2006 Christmas Tree Lighting with LEDs IC1 LM317T ADJ 050235 - 1 1 Peter Lay This design for a Christmas tree lighting system employs ten red light emitting diodes (LEDs) instead of the usual lamps. The LEDs are powered at a constant current from a 20-volts source. The current source is the familiar LM3 1 7T integrated voltage regu- lator. If the Adjust input of the LM317T is connected to a resis- tor carrying the regulator's output voltage, the 1C will strive to main- tain a constant 1 .2 V across the resistor. In this way, the resistor value allows a certain amount of constant current to be set up. A value of 1 20 ohms is required for the 1 0 mA we want for the LEDs. To be able to adjust the current, the 1C requires a minimum volt- age drop of 2 V between input and output. Because each red LED needs about 1 .6 V (and some, up to 1 .8 V) to light, about 20 V looks like a safe value at the input side of the regulator. If more LEDs are included in the string, the input voltage has to be increased by 1 .6 V to 1.8 V per additional LED. The maximum number of LEDs you can use in this way will be about 20, requir- ing an input voltage on the regu- lator of about 36 V (again, allow- ing for some headroom). The absolute maximum in this respect for the LM3 17 is 40 V. We should also observe the maximum power dissipation of about 20 watts stated in the LM317 datasheets — suitable cooling should be provided! At a LED cur- rent of 1 0 mA, for example, and a voltage drop of 4 V across the LM317 the dissipation is just 40 mW so cooling will not be required. In case of a short-circuit on the output, an integrated over- load protection is automatically activated to prevent damage. The length of the wire will be determined by the distance between the LEDs clipped on to the tree branches. In view of the constant current source used here, and the low actual current of about 10 mA, the wire length is not a factor. Single-core flexible hookup wire with an outside diameter of 0.8 mm will have a typical specification of 236 £1 per km. Even if you use 1 00 m of this wire, at 10 mA of current the entire length causes a voltage drop of just 236 mV. ( 050235 - 1 ) Poor man's CRT demagnetiser Klaus Rohwer The author recently moved house and in the hubbub of packaging and storing the highly valued con- tent of his electronics workshop a relatively heavy, vintage, millivolt- meter was placed on top of an oscilloscope, to remain there for a couple of days, or was it weeks? At some point, but always too late, you're sure to discover the hard way that a large moving-coil meter has a relatively strong mag- net inside with ditto field.. Soon, it was discovered that although the oscilloscope still worked, the picture was slanting and could not be straightened by any of the front panel controls. The upshot was that demagnetising the CRT was required. A couple of 'junk' coils that once belonged to an magnet-operated valve were found in a drawer. The valve probably came from a dishwasher, a washing machine or similar, and had been replaced owing to membrane leakage (the most likely cause of failure of these devices). Study should always precede experimentation, so one of the valve coils was carefully con- nected up to AMP plugs and then to a mains cord, observing all due safety precautions in respect of the electrical isolation and the presence of mains voltage. With a couple of paper sheets below it, the coil was slowly moved around the oscilloscope case. The case responded to the strong nearby ac field by produc- ing a loud buzzing sound. After this bit of therapy, the CRT in the 'scope once again produced a normal, straight picture and the problem had been solved. Finally, we should not forget to mention that the mains cord or the mains plug used in combina- tion with the demagnetizing coil should have a properly rated switch and fuse. ( 050235 - 1 ) 1/2006 - elektor electronics 75 INFOTAINMENT RETRONICS A pile of grimy and not so complete MX293 radios and ditto microphones to work on. Cleaning, repairing and discovering is fun. My own set, complete with its original loudspeaker. The fist microphone has the nickname Philishave and despite its dated look, supplies terrific modulation quality. Jan Buiting, PE1CSI Having talked a good deal with fellow radio amateurs on the air or in person, I am now lead to believe that an increasing num- ber of hams is turning away from new-fangled multimode microprocessor controlled trans- ceivers with controls so so tiny, a magnifying class should have been included in the box. Also, the number of bells and whistles of these 'computers disguised as radios' is often found to be off putting rather than encour- aging. No wonder many of my friends on the aether are turning to simpler stuff and the roots of ham radio, like low-power working (QRP) and conversion of commercial transceivers. The latter has become something of a cult hobby, thanks to the mar- ket being inundated with cheap VHF and UHF gear dumped by companies and governments in their move to mobile phone net- works. This class of radios is generally referred to as PMR (for personal mobile radio), and the first to turn a newly arrived PMR mobile or portable into a useful transceiver is a hero in radio amateur land, as it enables many to scoop a bar- gain and get on the air for a tenner or so. In the past, PMR conversion was usually limited to xtal recalcula- Heatsink Transmitter PA Cables and connectors ■ * . Modulator RF front end coils VCO section PROM socket Demodulator and AF Control head connectors A look inside an MX293 mobile, with the control head removed. This is all sound 1 980s technology. tion, coupled with some TX and RX pulling to down to 144 MHz (VHF) or 430 MHz (UHF). Today, the issue is much more complex as PMRs are usually software controlled. MX293: AM on VHF The Philips MX 293 PMR is an oddball transceiver in that it employs AM (amplitude modula- tion) rather than far more usual FM (frequency modulation). The MX 293 was chiefly used in (huge) UK police networks over a period of about 1 0 (!) years start- ing in 1985-87, probably as a continuation of other, partly valved AM mobiles. I guess AM was being used in preference over FM because of the absence of the 'threshold' effect and the ability to hear really weak sig- nals. On the down side, AM is wasteful of power and far more susceptible to interference from static, pulse and engine noise so I wonder what the constables were hearing all day. The ten or so MX 293 radios I got for my radio club were 143- ish MHz TX, 151-ish MHz RX types, which was convenient because with 144.550 MHz as the calling frequency in mind no TX retuning would be required. The radios being synthesized, I had to look at retuning the VCOs and pulling the RX front end down to 144. 76 elektor electronics - 1/2006 Night of the PROM This issue of Elektor Electronics is on reverse engineering and here's a fine example how it's done. The heart of the MX 293 is a 4-bit wide PROM type 82S185A which contains 'code' for 80 for- mer police channels. So, how to crack the PROM and get our- selves five channels around 144.5500 MHz? What follows is a quick summary of my activities to solve the riddle, burning mid- night oil. Step 1 . Establish the exact TX and RX frequencies of the origi- nal channel 1 on a radio. Test the RX and TX on lab equipment. Understand how the radio was originally operated. The RX has 10.7 MHz IF and low-side injec- tion. Step 2. Paperwork: get copies of the MX 293 service manual and the 82S1 85 PROM. Get a suitable programmer. Step 3. Locate the PROM, remove it, dump its contents on paper and into a binary file. Get the 82S185 datasheet. Step 4. Calculate, think and scribble until you understand the relation between the PROM codes and the actual TX/RX fre- quencies. This is the hardest part. Without going in too much detail, the end result was a QBa- sic program that does all the number crunching for me — see the Listing. Ancient QBasic was used because I wanted to fight old stuff with old stuff. Run the program for the target frequen- cies 144.5250, 144.5375, 144.5500, 144.5625 and 144.5750. Write down the five code words produced by the program. Step 5. Real ise you can't erase and reprogram a bipolar PROM, and new ones are impossible to get at reasonable prices, so get on to Step 6. Find free space to store code for my five channels. This proved easy enough as 'page two' of the PROM, address range 0400-07FF, was left blank (00)1 Pull a PROM address line high to permanently select the higher page. Step 7. Enter the five code words at free locations on PROM page 2, to coincide with channels 25, 37, 50, 62 and From frequency to PROM code 5 CLS 7 REM Jan Buiting PE1CSI 10 PRINT "PROM ENCODER FOR MX294" 20 INPUT "ENTER: SYNTH. STEP SIZE IN KHZ"; RASTER 25 RASTER = RASTER / 1000 30 INPUT "ENTER: 1ST INTERM. FREQUENCY (10 .7 OR 21.4)''; 35 PRINT 40 45 50 60 70 80 90 100 110 120 130 140 145 150 160 170 180 190 200 210 220 INPUT "ENTER: CHANNEL FREQUENCY (IN MHZ), 000 TO QUIT"; FREQ If FREQ = 0 THEN END INPUT "REPEATER CHANNEL? (Y/N) (+600 kHz shift assumed)"; REP$ If REP$ = "N" THEN TXNUMBER = (FREQ / RASTER) - 3840 If REP$ = "Y" THEN TXNUMBER = ((FREQ - 0.6) / RASTER) - 3840 RXNUMBER = ((FREQ - IFl) / RASTER) - 3840 TX$ = HEX$ (TXNUMBER) RX$ = HEX$ (RXNUMBER) D$ = LEFT$ ( RX$ , 1) C$ = MID$ ( RX$ , 2, 1) B$ = MID$ ( RX$ , 3, 1) A$ = RIGHT$ ( RX$ , 1) RXCODE$ = B$ + C$ + A$ + D$ PRINT "RX CODE WORD:"; RXCODE$ D$ = LEFT$ ( TX$ , 1) C$ = MID$ ( TX$ , 2, 1) B$ = MID$ ( TX$ , 3, 1) A$ = RIGHT$ ( TX$ , 1) TXCODE$ = B$ + C$ + A$ + D$ PRINT "TX CODE WORD:"; TXCODE$ GOTO 35 75. This was the only way to create a meaningful channel readout as only two 7-segment displays are available on the 'TEDx', the MX293's plug-on control head. Several mistakes were made at this point mainly with the PROM addresses but I was successful after three rounds and just two valuable PROMs wasted. Fingers crossed: burn the master PROM. Step 8 . Trouble! With the repro- grammed PROM and control head fitted I cannot reach the VCO and RX adjustment points in the radio. Step 9. Reverse-engineer a 'dummy control' that allows the radio to work with only its bare functions: volume, PTT and one fixed channel I know the address of. The result: two connectors, a wire and a preset. Step 10. Align the VCOs and RX front end at the test channel (in this case, 144.5250 MHz). Test the TX for power and modu- lation quality. Step 11. Fit the TEDx control head. Everything seems to work and I have a 5-channel AM rig on 2 metres that puts out 7 watts or so and has a reasonably sen- sitive receiver. Step 12. Document what I've done, save the QBasic program. Discover differences between radios available for distribution in the group. Reprogram all PROMs from the radios. The club project Originally I intended to supply the unconverted MX293 radios with just the reprogrammed PROMs in place. Consequently club members would have to tune the VCOs into lock, pull a jumper and align the RF front end. The latter in particular is tricky as the small ferrite cores are often stuck in their formers due to the use of a fixing sub- stance by the manufacturer. If just one core is damaged by improper handling (and the fer- rite is brittle!) the entire radio is worthless as it will never reach the sensitivity we need. All cores were 'gently approached' with top-class adjustment tools and only two proved stuck. I used a syringe needle to apply just the tiniest amount of baby oil on the top of the core thread, allowing it to work its way down for about 24 hours. The oil effectively released the cores and the radios could be aligned successfully. We now have about 1 0 users in a small weekly net on 144.5500 MHz all cheerfully using a long forgotten mode called AM. MX293 users are joined by those with heftier equip- ment ranging from a Kenwood TS700 to a 50-watt base station for aircraft VHF AM communica- tions. Besides extending the num- ber of active users we hope to contact amateurs across the bor- ders one day — it is just feasible as AM (or A3E as it's officially called) has been allowed all these years as a radio amateur mode on 2 metres. ( 065001 - 1 ) 1/2006 - elektor electronics 77 This Issue: FREE VISUAL BASIC 2005 BOOKLET reverse engineering - part mining - re-use of equipment & components Next Issue: h BRUSHLESS MOTORS in practice Want to know everything each month? Select your own annual subscription and receive a free 1 W Luxeon LED Torchlight Available options: • Elektor Electronics annual subscription (standard) You receive 1 1 issues, including the July/August double issue. • Elektor Electronics annual subscription-PLUS You receive 1 1 issues, including the July/August double issue, plus a copy of the Elektor Electronics Volume 2005 CD-ROM (normal price £16.25). Your saving: approx. £10.00! Please fill out the Order Form with this issue. Subscription rates and conditions may be found at the back of this issue. PUZZLE INFOTAINMENT Hexadoku Puzzle with an electronic touch If you like solving puzzles, no doubt you have noticed the recent hype around the 'Sudoku' puzzle. Millions of people every day rack their brains arranging numbers 1 thorough 9 in a diagram. Elektor Electronics now presents its own version of the Sudoku, the Hexadoku. Our monthly puzzle challenge employs the hexadecimal numbers 0 through F, rather than just numbers 1-9 usually found in the daily papers. Entering the competition Please send the numbers in the grey boxes by email, fax or post to Elektor Electronics Hexadoku Regus Brentford 1 000 Great West Road Brentford TW8 9HH United Kingdom. Fax (+44) (0)208 2614447 Email editor@elektor- electronics.co.uk Subject: hexa- doku 01-2006. The closing date is 1 February 2006. Competition not open to employees of Segment b.v., its business partners and/or associated publishing houses. E A 5 6 F 8 6 5 E 1 8 F 0 3 A 3 7 B 6 5 D 2 8 B 3 4 5 0 7 1 9 2 9 B 2 0 F 7 8 D 6 5 E 7 F B D 1 6 C D 6 3 2 0 A 7 D C 2 8 7 7 3 B E 9 C 0 A 8 2 6 A 1 7 E B 9 2 9 0 6 4 D A 4 7 6 F A 0 2 B C 3 A 5 4 8 0 E F D E 9 0 C 2 4 F 5 1 8 F 5 B 1 9 4 D 3 Solve Hexadoku and win! Correct solutions qualify for an E-blocks Starter Kit Professional worth £ 248.55 and three Elektor Electronics Shop Vouchers worth £35 each. We believe these prizes should encourage all our readers to participate! As of this month we present Hexadoku, a novel brain teaser for the electronics enthusiast and keen reader of this magazine. Although the instructions for the puzzle are straightforward, solving it is much harder than it looks like at first blush. In the diagram composed of 16x16 boxes, enter numbers in such a way that all hexa- decimal numbers 0 through F (that's 0-9 and A-F) occur once in every row, once in every column, and in every one of the 4x4 boxes (marked by the thicker black lines). A number of clues are given in the puzzle and these determine the start situation. Your solution may win a prize and requires only the num- bers in the grey boxes to be sent to us. ( 065033 - 1 ) 1/2006 - elektor electronics 79 ELEKTOR SHOWCASE To book your showcase space contact Huson International Media Tel. (0) 1 932 564999 Fax 0044 (0) 1 932 564998 ALLGOOD TECHNOLOGY www.allgoodtechnology.com Low-medium volume sub-contract assembly. SMT specialist since 1990. Customers include military, aerospace etc. 0402 to BGA capabilities, automatic assembly and hand built prototypes. ATC SEMITEC LTD www.atcsemitec.co.uk Thermal and current-sensitive components for temperature control and circuit protection; • NTC Thermistors • Current Diodes • Thermostats • Re-settable Fuses • Thermal Fuses • Temperature Sensors Call today for free samples and pricing Tel: 0870 901 0777 Fax: 0870 901 0888 DESIGN GATEWAY bn I fcll/rW 1 www.design-gateway.com e ■ - - ^ , j ■ ■ ■ i PalmLogic II .... US$ 399.00 • Compact Logic Analyzer (L1 1 6mm x W73.3mm x T3mm) • High sampling rate (400 MHz/ 8ch, 200 MHz/1 6ch, 100 MHz/32ch) • USB 2.0 high speed mode | • 8MB memory storage 1 * • Bus Analyzer function • Multiple waveform windows • Waveform save/restore DESIGN GATEWAY www.design-gateway.com True PCI Starter Kit .... US$135.00 • PCI Development Kit • Based on 200,000 gates FPGA • Extension connectors for 72 pin 1/0 • Configuration support for JTAG and slave serial • Free PCI Core for Target Mode 1RJUE FOi DESIGN GATEWAY pesjen www.design-gateway.com j . .flTj VariClock... US$163.00 • Adjustable clock signal synthesizer • 3 rotary switches for frequency setting • Standard DIP pin arrangement • Support both 3V/5V by on-board regulator VC250M14P Frequency range : 25-400 MHz Frequency setting : 1 MHz step VC100M14P Frequency range : 25-100 MHz Frequency setting : 1 00 kHz step for 25- 50 MHz : 200 kHz step for more than 50 MHz GATEILIAM E ..... . J . - , I . J DESIGN GATEWAY www.design-gateway.com Ethernet 10 .... US$115.00 • 8 bits embedded network microcontroller • 6 channels available for 10 bits ADC • Ethernet 1 0 BASE T 1 0 Mb • UART port RS232/RS485, Max Speed atl 1 5200bps 35 bits general purpose 1/0 500 bytes user area flash memory BETA LAYOUT www.pcb-pool.com Beta layout Ltd Award- winning site in both English and German offers prototype PCBs at a fraction of the cost of the usual manufacturer’s prices. BURN TECHNOLOGY LTD http ://www. b u rntec . co m Test & Measurement Equipment Distributors • Anemometers • Clamp Meters • Light Meters • LCR Meters • Sound Meters • Multimeters • Device Programmers Burn Technology Limited, Winfrith Technology Centre, Dorchester, Dorset, DT2 8DH Tel: (01305) 852090 Fax: (01929) 463214 COMPUCUT http://www.compucutters.com Computer Numerical Control from your home PC. Great for tricky jobs, and accurate repetitive work. We supply: - Software - Interface - Manual - Support Price £250 plus postage. CONFORD ELECTRONICS http://www.confordelec.co.uk Lightweight portable battery/mains audio units offering the highest technical performance. Microphone, Phantom Power and Headphone Amplifiers. Balanced/unbalanced signal lines with extensive RFI protection. DANBURY ELECTRONICS http://www.livinginthepast.demon.co.uk Here you will find our mains and output transformers in Mike Holme’s range of valve/tube amplifiers (PP & SE). Also circuits, parts lists, chassis, advice. EAGLEPICS http://www.eaglepics.co.uk Embedded Internet Solutions • Stand alone TCP/IP module • Platform independent • Simple "AT-like" command set • GPRS or modem connection • E-Mail, FTP, HTTP, UDP • Development board available • Free development utilities • Free UDP-only stack EASYSYNC http://www.easysync.co.uk EasySync Ltd sells a wide range of single and multi- port USB to RS232/RS422 and RS485 converters at competitive prices. ELNEC www.elnec.com • device programmer manufacturer • selling through contracted distributors all over the world • universal and dedicated device programmers • excellent support and after sale support • free SW updates • reliable HW • once a months new SW release • three years warranty for most programmers FUTURLEC http://www.futurlec.com Save up to 60% on • Electronic Components • Microcontrollers, PIC, Atmel • Development Boards, Programmers Huge range of products available on-line for immediate delivery, at very competitive prices. FUTURE TECHNOLOGY DEVICES http://www.ftdichip.com FTDI designs and sells USB-UART and USB-FIFO interface i.c.’s. Complete with PC drivers, these devices simplify the task of designing or upgrading peripherals to USB IPEVA LIMITED http://www.ipeva.com IPEVA sell low cost USB FPGA development boards. IPEVA provide Design Consultancy for Embedded Systems, OpenCores-IP, FPGA, ASIC, HDL translation and migration. Tel. 0870 080 2340. JLB ELECTRONICS www.jlbelectronics.com Suppliers of electrical / electronic parts and consumables. Including: • Cable ties / bases • Tools / hardware • Bootlace ferrules • Connectors • Solvent sprays & cleaners • PVC Tape • Heat Sink compound KMK TECHNOLOGIES Ltd. http ://www. km k. co m . h k Low Cost DIY Robotic Kits and Computer Controller Boards. 80 elektor electronics - 1/2006 products and services directory LONDON ELECTRONICS COLLEGE OLD COLONY SOUND LAB ROBOT ELECTRONICS i http://www.lec.org.uk Vocational training and education for national qualifications in Electronics Engineering and Information Technology (BTEC First National, Higher National NVQs, GCSEs and Advanced Qualifications). Also Technical Management and Languages. MQP ELECTRONICS http://www.mqpelectronics.co.uk Leaders in Device Programming Solutions. • Online shop • Low Cost Adapters for all Programmers • Single Site and Gang Programmers • Support for virtually any Programmable Device NEW WAVE CONCEPTS www.new-wave-concepts.com Software for hobbyists: • Livewire circuit simulation software, only £34.99 • PCB Wizard circuit design software, only £34.99 Available from all Maplin Electronics stores and www.maplin.co.uk. www.audioXpress.com Premier source for DIY audio for 35 years! New catalog features: • Books •CDs •Test & Measurement • Kits Full range of products and magazines for the DIY audio enthusiast! PCB WORLD http://www.pcbworld.org.uk World-class site: Your magazine project or prototype PCB from the artwork of your choice for less. Call Lee on 07946 846159 for details. Prompt service. QUASAR ELECTRONICS www.QuasarElectronics.com Over 300 electronic kits, projects and ready built units for hobby, education and industrial applications including PIC/ATMEL programming solutions. Online Tel: +44 (0) 870 246 1826 Fax: +44 (0) 870 460 1045 Email: sales@QuasarElectronics.com QUASAR a I * drome* ordering facilities. SHOWCASE YOUR COMPANY HERE Elektor Electronics has a feature to help customers promote their business, Showcase - a permanent feature of the magazine where you will be able to showcase your products and services. • For just £220 + VAT (£20 per issue for eleven issues) Elektor will publish your company name, website adress and a 30-word description • For £330 + VAT for the year (£30 per issue for eleven issues) we will publish the above plus run a 3cm deep full colour image - e.g. a product shot, a screen shot from your site, a company logo - your choice Places are limited and spaces will go on a strictly first come, first served basis. So please fax back your order today! I wish to promote my company, please book my space: • Text insertion only for £220 + VAT • Text and photo for £330 + VAT NAME: ORGANISATION: JOB TITLE: ADDRESS: .TEL: PLEASE COMPLETE COUPON BELOW AND FAX BACK TO 00-44-(0)1932 564998 COMPANY NAME WEB ADDRESS 30- WORD DESCRIPTION http://www.robot-electronics.c o.uk • Ultrasonic rangefinders • Motor H-Bridge controllers • Magnetic Compasses • RC servos and controllers • PIC programmers and components • Electronic Design/Development and Manufacturer to industry SK PANG ELECTRONICS CurTmtti http://www.skpang.co.uk • ELM OBDII 1C • VAG-COM Interface • OBDII connector and cable • Modtronix Micro X board • Embedded Ethernet Controller • PIC Microcontroller, CAN Bus driver Major credit cards taken online. SYTRONIC TECHNOLOGY LTD www.m2mtelemetry.com Supplier of wireless modules and accessories for remote monitoring M2M applications. •GSM/GPRS TCP/IP modules • Embedded GSM/GPRS modem • Development Kits • GPS modules • GSM/GPS antennas • Adapter cables Online ordering facilities. Tel (01 394) 210911 ULTRALEDS U1 U'zleds,** http://www.ultraleds.co.uk tel: 0871 7110413 Large range of low cost Ultra bright leds and Led related lighting products. Major credit cards taken online with same day depatch. USB INSTRUMENTS http://www.usb-instruments.com USB Instruments specialises in PC based instrumentation products and software such as Oscilloscopes, Data Loggers, Logic Analaysers which interface to your PC via USB. VIRTINS TECHNOLOGY www.virtins.com PC and Pocket PC based virtual instrument for electronics enthusiasts, students, professionals and scientists, including sound card real time oscilloscope, spectrum analyzer, and signal generator. Free to download and try. ELECTRONIC ENTHUSIASTS Only one magazine tests its projects and circuits in its own lab before publication ELECTOR ELECTRONICS THE ELECTRONICS & COMPUTER MAGAZINE Service Ltd, Ticehurst TIM5 7HE 'ww.elektor-electronics.co.uk Contact: Worldwide Subscription Unit 4 Gibbs Reed Farm, Pashley Road, Telephone: 01580 200657 Fax: 01580 200616 w 1/2006 - elektor electronics 81 lektor K]©[? Order o www.elektor-el Order now using the Order Form in the Readers Services section in this issue. CD-ROM ECD Edition 3 Elektor’s Components Database gives you easy access to design data for over 5,000 ICs, more than 35,000 transistors, FETs, thyristors and triacs, just under 25,000 diodes and 1 ,800 optocouplers. All databank applications are fully interactive, allowing the user to add, edit and complete component data. £12.95 (US$ 22.90) Robotics A large collection of data- sheets, software tools, tips, tricks and Internet links to assorted robot constructions and general technical infor- mation. All aspects of modern robotics are covered, from sensors to motors, mechanical parts to microcontrollers, not for- getting matching programming tools and libraries for signal processing. £12.05 (US$ 21.25) Toolbox 2 The second Toolbox CD-ROM contains a vast collection of carefully selected software tools for, and infor- mation about, microcontrollers. This CD-ROM gives specific attention to technical docu- mentation about protocols, field buses, as well as modern information carriers which find increasing use. The hardware side of things is not forgotten either. Toolbox 2 is a must-have for all electronics enthusiasts. £12.05 (US$ 21.25) More information on www.elektor-electronics.co.uk 308 Circuits This book contains a wide range of circuits, tips and design ideas. The book has been divided into sections, making it easy to find related subjects in a single category. 308 Circuits covers the following disciplines and interest fields of modern electronics: test & measurement, radio and television, power supplies and battery chargers, general interest, computers and micro- processors, circuit ideas and audio & hi-fi. ISBN 0-905705-66-1 367 pages £18.20 (US$ 37.00) PC-Interfaces under Windows PC Interfaces can be used for more than just the printer, mouse, modem and joy-stick! While it was relatively easy to directly access PC interfaces using a DOS com-puter, under Windows things are not all that simple. This book (CD-ROM incl.) shows you how it can be done. The authors describe the DIY construction and programming of a number of highly interesting circuits. WlN£>DbVlfi r ISBN 0-905705-65-3 265 pages £25.95 (US$ 22.90) BESTSELLING BOOKS Top-5 Microcontroller Basics ISBN 0-905705-67-X £18.70 (US$ 33.70) 308 Circuits ISBN 0-905705-66-1 £18.20 (US$ 37.00) PC-Interfaces under Windows ISBN 0-905705-65-3 £25.95 (US$ 22.90) Modern High-end Valve Amplifiers ISBN 0-905705-63-7 £25.95 (US$ 52.00) Build your own Audio Valve Amplifiers ISBN 0-905705-39-4 £15.55 (US$ 31.00) Mkrocqntrqlier 8 ASICS CjH a LJ B More information on www.elektor-electronics.co.uk nline at ectronics.co.uk Due to practical constraints, final illustrations and specifications may differ from published designs. Prices subject to change. See www.elektor-electronics.co.uk for up to date information. ESR/C Meter Elektor Electronics (Publishing) / Segment B.V. Regus Brentford 1000 Great West Road Brentford TW8 9HH United Kingdom Tel.: +44 (0) 208 261 4509 Fax: +44 (0) 208 261 4447 Email: sales@elektor-electronics.co.uk Kits & Modules (September 2005) Kit of parts including PCB, default LCD module, 2x16 characters and programmed controllers. Enclosure not included. 040259-71 £63.99/$ 119.95 Matching enclos 040259-72 £6.99/$ 12.95 OBD-2 Analyser (July/August 2005) Kit of parts including PCB, programmed controller, compo- nents (including IC7 ; IC3 = PCA82C250, 12 V), enclosure and RS232 cable. OBD cable not included. 050092-71 £52 .50/ $96.95 OBD cable 050092-72 £27.55/ $51 .95 Electrosmog Tester (June 2005) Ready-built PCB (excl. enclosure) 050008-91 £ 50.00 / $ 94.25 Matching enclosure 050008-71 £ 10.25/$ 19.30 GPS Receiver on (June 2005) Complete kit (not inclu- ding IC3) with Lassen iQ-receiver and extra long cable, CD with software and water- proof antenna case. 040264-71 £77.65/$ 146.25 USB Further products from Elektor Electronics: READY-BUILT PROJECTS ClariTy 300-W Class-T Amplifier 030217-91 Amplifier board with SMDs pre-fitted; cores for LI & L2 34-50 Flash Microcontroller Starter Kit 010208-91 ready-assembled PCB incl. software, cable, adapter & related articles 69-00 Gameboy Digital Sampling Oscilloscope (GBDSO) 990082-91 ready-assembled board, incl. the PC software and related articles 103-00 Micro Webserver with MSC1210 Board 030060-91 Microprocessor Board, ready-assembled 044026-91 Network Extension Board, ready-assembled 044026-92 Combined package (030060-91 & 044026-91 & related articles) LPC210x ARMee Development System 040444-91 Processor board, ready-made and tested m NO. 350 JANUARY 95-watt Laptop PSU Adaptor 050029-1 PCB Automatic Attic Window Controller 0501 39-1 1 Disk, PIC source & hex code 050139-41 PIC1 6F84A-20I/P, programmed 030451-72 LCD Modue 2x16 characters 030451-73 PLED Module 2x16 characters SMD Reflow Soldering Oven 050319-1 1 Disk, source and hex code 050319-41 AT89C52/24JI, programmed 030451-72 LCD Modue 2x16 characters 030451-73 PLED Module 2x16 characters Timer Switch for Washing Machine 050058-1 PCB 050058-1 1 Disk, PIC source & hex code 050058-41 PIC16F84, programmed NO. 349 DECEMBER 2005 From A to D via USB 050222-1 PCB 050222-41 IOW24-P, programmed 55.70 112.50 183.00 75-90 142.95 44-50 83.95 117-50 220.95 25-50 48.05 4-80 9.05 5-20 9.75 13-10 24.65 7-25 13.65 25-50 48.05 5-20 9.75 7-60 14.25 7-25 13.65 25-50 48.05 8-90 16.70 5-20 9.75 13-10 24.65 7-95 14.95 9-40 17.75 Telephone Supervisor 050039-41 PIC1 6F628-20/P, programmed 8-20 15.55 050039-81 CD-ROM, PIC hex & source codes, LCM First Server 6-90 12.95 NO. 348 NOVEMBER 2005 Remote Control by Mobile Phone 040415-1 PCB 6-20 11.65 04041 5-1 1 Disk, PIC source & hex files 5-20 9.75 040415-41 PIC1 6F84A-20/P, programmed 10-30 19.50 Synchronous Servos 020031-1 1 Disk, project software 5-20 9.75 020031-41 AT90S2313-10PC, programmed 7-85 14.85 NO. 347 OCTOBER 2005 27C512 Emulator 030444-1 1 Disk, project software 030444-31 EPM7064SLC84-15, programmed 030444-41 AT90S8515-4PC, programmed Colossus Jr. 040267-11 Disk, PIC source code 040267-41 PIC1 2F675-C/P, programmed Flash Lock for PCs 050107-41 PIC16F628A-I/SO, programmed 050107-81 CD-ROM, project software NO. 346 SEPTEMBER 2005 ESR/C Meter 040259-1 PCB, bare 12-40 23.35 040259-11 Disk, PIC source & hex codes 5-20 9.75 040259-41 PIC1 6F877-20/P, programmed 15-50 29.25 040259-42 PIC1 6F84A-20/P, programmed 10-30 19.45 Products for older projects (if available) may be found on our website www.elektor-electronics.co.uk home construction = fun and added value 5-20 9.75 27-50 51.95 15-10 28.35 5-20 9.75 4-10 5.35 5-00 9.45 6-90 12.95 INFO & MARKET SNEAK PREVIEW Brushless Motor Controller Brushless motors are marked by their excellent power/efficiency ratio and are frequently used in modelling. A brushless motor does however require a special piece of electronics to generate the rotational field. Our circuit handles input voltages between 5.5 V and about 20 V and is capable of supplying a hefty 18 A. The miniature control is built around an ST7 series microcontroller. Also... Piezo Motors; The Making of a 2 x 200- watt Audio Amp; Router Conversion Experi- ments; Hexadoku Puzzle Get Cracking with the R8C Micro This article is the sequel to January's introduction of the R8C, a small but powerful 16-bit microcontroller from Renesas. An exclusive deal with Renesas distributor Glyn allows us to supply a ready-to-go R8C Starter Kit at an unbeatable price. The kit should enable a number of mini projects to be developed on the fly. Sparks and Arcs A quick search around the Internet shows that not a few hobbyists have specialised in generating loud sparks and arcs under more or less controlled conditions. The Tesla generator seems to be the most sought after for these experiments. Most project are however extremely dangerous and not suitable for 'DIY in the garage'. That is why we publish a simpler circuit that's none the less capable of drawing sparks and arcs between two conductors: the so-called Jacob's Ladder. Theme Plan for 2006 January Recycling / Reverse Engineering February . . . .Motors / Propulsion March Development/ Microcontrollers April Power Supplies / Safety May Soldering / Etching June Satellites July/ August . . . .Summer Circuits September Esoterics / Test & Measurement October e-Simulation November Chipcards / Protection December Electromechanical / Enclosures RESERVE YOUR COPY NOW! The February 2006 issue goes on sale on Saturday 21 January 2006 (UK distribution only). UK subscribers will receive tbe magazine a few days before this date. Article titles and magazine contents subject to change. NEWSAGENTS ORDER FORM SHOP SAVE / HOME DELIVERY Please save / deliver one copy of Elektor Electronics magazine for me each month Name: Address: Post code: Telephone: Date: Signature: lektor lectronics I e a -d i n g the ■vw a y Please cut out or photocopy this form, com- plete details and hand to your newsagent. Elektor Electronics is published on the third Friday of each month, except in July. Distribution S.O.R. by Seymour (NS). www.elektor-electronics.co.uk www.elektor-electronics.co.uk www.elektor-electronics Elektor Electronics 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, cir- cuit boards, programmed ICs and corrections and updates if applicable. Complete magazine issues may also be downloaded. lektor “ L In the Elektor Electronics Shop you'll find all other products sold by the pub- lishers, 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 Electronics website: • Electronics news and Elektor announcements • Readers Forum, • PCB, software and e-magazine downloads • Surveys and polls • FAQ, Author Guidelines and Contact ■ Ur M i Ur Si- 84 elektor electronics - 1/2006 Please supply the following. For PCBs, front panel foils, EPROMs, PALs, GALs, microcontrollers and diskettes, state the part number and description; for books, state the full title; for photocopies of articles, state full name of article and month and year of publication. PLEASE USE BLOCK CAPITALS. Description Price each Qty. Total Order Code CD-ROM ECD Edition 3 £ 12.95 CD-ROM Home Automation £ 12.95 Microcontroller Basics £ 18.70 b-biocks starter Kit basic £ 96.00 E-blocks Starter Kit professional £ 1 66.00 Flash Microcontroller Starter Kit £ 69.00 Sub-total Prices and item descriptions suhject tn change The publishers reserve the right to change prices p&p without prior notification. Prices and item descriptions rotr shown here supersede those in previous issues. E. & O.E. Total paid Name METHOD OF PAYMENT (see reverse before ticking as appropriate) □ □ □ □ Bank transfer Cheque (UK-resident customers ONLY) Giro transfer Expiry date: Verification code: SWITCH ONLY: Start date: Issue number: Please send this order form to * (see reverse for conditions) Elektor Electronics (Publishing) Regus Brentford 1000 Great West Road Brentford TW8 9HH United Kingdom Address + Post code Tel. Email Date - - 2006 Signature EL01 Tel.: (+44) (0) 208 261 4509 Fax: (+44) (0) 208 261 4447 Internet: www.elektor-electronics.co.uk sales@elektor-electronics.co.uk *USA and Canada residents may (but are not obliged to) use $ prices, and send the order form to: Old Colony Sound Lab P.O. Box 876, Peterborough NH 03458-0876. Tel. (603) 924-6371, 924-6526, Fax: (603) 924-9467 Email: custserv@audioXpress.com Yes, I am taking out an annual subscription to elektor electronics and receive a free 1 W Luxeon LED Torchlight. I would like: Standard Subscription (11 issues) Subscription-Plus (11 issues plus the Elektor Volume 2005 CD-ROM) * Offer available to Subscribers who have not held a subscription to Elektor Electronics during the last 12 months. Offer subject to availability. See reverse for rates and conditions. Name METHOD OF PAYMENT (see reverse before ticking as appropriate) Bank transfer Cheque (UK-resident customers ONLY) Giro transfer Expiry date: Verification code: SWITCH ONLY: Start date: Issue number: .... Address + Post code Please send this order form to Tel. Email Date - - 2006 Signature * cross out what is not applicable EL01 Elektor Electronics (Publishing) Regus Brentford 1000 Great West Road Brentford TW8 9HH United Kingdom Tel.: (+44) (0) 208 261 4509 Fax: (+44) (0) 208 261 4447 Internet: www.elektor-electronics.co.uk subscriptions@elektor-electronics.co.uk ORDERING INSTRUCTIONS, P&P CHARGES Except in the USA and Canada, all orders, except for subscriptions (for which see below), must be sent BY POST or FAX to our Brentford address using the Order Form overleaf. On-line ordering: http://www.elektor-electronics.co.uk Readers in the USA and Canada may (but are not obliged to) send orders, except for subscriptions (for which see below), to the USA address given on the order form. Please apply to Old Colony Sound for applicable P&P charges. Please allow 4-6 weeks for delivery. Orders placed on our Brentford office must include P&P charges (Priority or Standard) as follows: UK: £4.00 Europe: £5.00 (Standard) or £7.00 (Priority) Outside Europe: £8.00 (Standard) or £12.00 (Priority) HOWTO PAY All orders must be accompanied by the full payment, including postage and packing charges as stated above or advised by Customer Services staff. Bank transfer into account no. 40209520 held by Elektor Electronics (Publishing) / Segment b.v. 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 (Publishing) / Segment b.v.. 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 (Publishing) / Segment b.v. 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, Access, MasterCard, JCBCard and Switch cards 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 Electronics 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 Electronics (Publishing) 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 Electronics (Publishing) 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 Electronics (Publishing) 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 Electronics (Publishing) other than to supply goods as described or, at the option of Elektor Electronics (Publishing), 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 Electronics (Publishing) shall be determined in all respects by the laws Of England. January 2006 SUBSCRIPTION RATES FOR ANNUAL SUBSCRIPTION United Kingdom Standard £41 .90 Plus £48.80 Economy Mail Rest of the World (excluding Europe) £54.50 £61.40 Priority Airmail Europe & Eire £54.50 £61.40 Outside Europe £68.90 £75.80 Airfreight USA & Canada only US$95.50 US$106.50 HOWTO PAY Bank transfer into account no. 40209520 held by Elektor Electronics (Publishing) / Segment b.v. 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 (Publishing) / Segment b.v.. 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 (Publishing) / Segment b.v. 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, Access, MasterCard, JCBCard and Switch cards can be processed by mail, email, web, fax and telephone. Online ordering through our website is SSL-protected for your security. SUBSCRIPTION CONDITIONS The standard subscription order period is twelve months. If a perma- nent change of address during the subscription period means that copies have to be despatched by a more expensive service, no extra charge will be made. Conversely, no refund will be made, nor expiry date extended, if a change of address allows the use of a cheaper service. Student applications, which qualify for a 20% (twenty per cent) reduc- tion in current rates, must be supported by evidence of studentship signed by the head of the college, school or university faculty. A standard Student Subscription costs £33.50, a Student Subscription- Plus costs £40.40 (UK only). Please note that new subscriptions take about four weeks from receipt of order to become effective. Cancelled subscriptions will be subject to a charge of 25% (twenty- five per cent) of the full subscription price or £7.50, whichever is the higher, plus the cost of any issues already dispatched. Subsciptions cannot be cancelled after they have run for six months or more. January 2006 leading the way lectronics CD-ROM ECD Edition 3 *rn*« Now with a new user interface! Elektor’s Components Database gives you easy access to design data for over 5,000 ICs, more than 35,000 transistors, FETs, thyristors and triacs, just under 25,000 diodes and 1 ,800 optocouplers. All databank applications are fully interactive, allowing the user to add, edit and complete component data. ISBN 90-5381-159-1 £12.95 (US$ 22.90) Order now using the Order Form in the Readers Services section in this issue. Elektor Electronics (Publishing) / Segment B.V. Regus Brentford 1000 Great West Road Brentford TW8 9HH United Kingdom Tel. +44 (0) 208 261 4509 lectronics Audio Collection 2 A unique CD-ROM for the true audio lover, containing no fewer than 75 audio designs from the past five year volumes of Elektor Electronics magazine. The articles on the CD-ROM cover test & measurement equipment, amplifiers, digital audio and loudspeaker technology. Highlights include the Crescendo Millennium Edition, Audio-DAC 2000, Audio-ADC 2000 and the IR-S/PDIF Transmitter and Receiver. Using the included Acrobat Reader you are able to browse the articles on your computer, as well as print texts, circuit diagrams and PCB layouts. ISBN 90-5381-176-1 £12.05 (US$ 21.25) Order now using the Order Form in the Readers Services section in this issue. Elektor Electronics (Publishing) / Segment B.V. Regus Brentford 1000 Great West Road Brentford TW8 9HH United Kingdom Tel. +44 (0) 208 261 4509 More information on www.elektor-electronics.co.uk See also www.elektor-electronics.co.uk Index of Advertisers Allgood Technology, Showcase www.allgoodtechnology.com .80 ATC Semitec Ltd, Showcase www.atcsemitec.co.uk .80 Audioxpress, Showcase www.audioxpress.com .81 Avit Research www.avitresearch.co.uk 11 Beta Layout, Showcase www.pcb-pool.com 48, 80 Breadboarding Systems www.breadboarding.co.uk 3 Burn Technology LTD, Showcase www.burntec.com .80 Compucut, Showcase www.compucutters.com .80 Conford Electronics, Showcase www.confordelec.co.uk .80 Cricklewood www. crickle woodelectronics. com .48 Danbury, Showcase www.iivinginthepast.demon.co.uk .80 Design Gateway, Showcase www.design-gateway.com .80 Eaglepics, Showcase www.eagiepics.co.uk .80 Easysync, Showcase www.easysync.co.uk 7, 80 Elnec, Showcase www.elnec.com .80 Euro circuits www.thepcbshop.com Fast Components www.fastcomponents.co.uk 6 Future Technology Devices, Showcase . . .www.ftdichip.com 80 Futurlec, Showcase www.futurlec.com .80 Ipeva Limited, Showcase www.ipeva.com .80 Jaycar Electronics www.jaycareiectronics.co.uk 2 JLB Electronics, Showcase www.jlbelectronics.com .80 KMK Technologies Ltd, Showcase www.kmk.com.hk .80 Labcenter Lichfield Electronics London Electronics College, Showcase MQP Electronics, Showcase New Wave Concepts, Showcase Number One Systems Nurve Networks PCB World, Showcase Pico Quasar Electronics, Showcase Robot Electronics, Showcase Showcase SK Pang Electronics, Showcase Sytronic Technology, Showcase Ultraleds, Showcase USB Instruments, Showcase Virtins Technology, Showcase .www.iabcenter.co.uk 88 . www. lichfieldelectronics. co.uk 11 .www.lec.org.uk 81 . www. mgpelectronics. co.uk 81 .www.new-wave-concepts.com 81 .www.numberone.com 15 . www.xgamestation. com 6 . www. pcb world, org. uk 81 .www.picotech.com 15 .www.guasarelectronics.com 21, 81 . www. robot-electronics, co.uk 81 80, 81 .www.skpang.co.uk 81 . www. m2mtelemetry. com 81 .www.ultraleds.co.uk 81 .www.usb-instruments.com 81 .www.virtins.com 81 Advertising space for the issue of 14 February 2006 may be reserved not later than 17 January 2006 with Huson International Media - Cambridge House - Gogmore Lane - Chertsey, Surrey KT 1 6 9AP - England - Telephone 01 932 564 999 - Fax 01 932 564998 - e-mail: r.elaar@husonmedia.com to whom all correspondence, copy instructions and artwork should be addressed. 1/2006 - elektor electronics 87 Schematic & PCB Layout JLU ! JL J ■ a 1 • I E i Mm Schematic i f jf i V 1 ■ 1 u I 1,1 ■! .1 » * i, m i jf CFU Wodeff Auto Routing naMptufufti ^ Virtual System Modelling New Features £-4 in Version 6.8 Interactive Design Rule Check, Mitring / Unmitring. Enhanced track editing. The Complete Electronics Design System Powerful & flexible schematic capture. Auto-component placement and rip-up/retry PCB routing. Polygonal gridless ground planes. Libraries of over 8000 schematic and 1000 PCB parts. Bill of materials, DRC reports and much more. Mixed Mode SPICE Circuit Simulation • Struct/Array expansion. • ELF/DWARF file loader. • Berkeley SPICE3F5 simulator with custom extensions for true mixed mode and interactive simulation. • 6 virtual instruments and 14 graph based analysis types. • 6000 models including TTL, CMOS and PLD digital parts. • Fully compatible with manufacturers’ SPICE models. • Expanded model libraries. Call Now for Upgrade Pricing Proteus VSM - Co-simulation and debugging for popular Micro-controllers Supports PIC, AVR, 8051, ARM7 and BASIC STAMP micro-controllers. Co-simulate target firmware with your hardware design. Includes interactive peripheral models for LED and LCD displays, switches, keypads, virtual terminal and much, much more. Compatible with popular compilers and assemblers from Microchip, Crownhill, IAR, Keil, and others. Electronics 53-55 Main Street, Grassington. BD23 5AA Tel: 01756 753440 Fax: 01756 752857 Contact us for Free Demo CD ARM/LPC2000 MODELS FOR PROTEUS VSM NOW AVAILABLE www.labcenter.co.uk info@labcenter.co.uk Free booklet with Elektor Electronics January 2006 lektor lectronics H V* W * w 770268 451128 0 1 E-blocks are small self-contained electronic circuits and printed circuit boards that can be combined to create fully functional electronic applica- tions and systems. From very simple to highly complex and sophisticated. Using E-blocks, you work a lot faster and get results you never dreamed about, in relatively little time. For example, you could use E-blocks to con- trol and monitor the entire microclimate in your aquarium. Or build your E-blocks Starter Kit basic • Flowcode student/home £ 59.90 • USB Multiprogrammer £ 77.30 own bugging device, using GSM technology of course. Many electronics enthusiasts have already discovered the countless possibilities of E-blocks. And apply them every day. With truly amazing results. Get to know E-blocks at 30% discount? Simply order one of our E-blocks Starter Kits. ^.7 # ^05 % E-blocks Starter Kit professional Flowcode professional USB Multiprogrammer • LED board • Switchboard • LCD board Extra: PIC16F877 microcontroller Total value: \ 33 0/o disco' £118.00 £ 77.30 £ 14.65 £ 19.30 £ 19.30 £ 248.55 £166.00 icr\LLM lectronics E-blocks will be shipped after receipt of payment. Prices are exclusive of postage. Contents by subject Subject Page Introduction 3 Starting Visual Basic 2005 4 The Integrated Development Environment of VB 2005 5 Programming through a simple example: Ohm's Law 5 Placing controls on the form 6 Attaching code to controls 9 Saving programs 10 Running the program 10 Program Resistors in Series and in Parallel. ...11 Variables 11 Program Resistor Values 15 Conditional statements 17 Program Vibration/Oscillation systems 19 Loops 19 Program OP-Amp Database 22 Creating a file on a mass storage device 22 Loading information from a file 25 Adding items in the program Resources 25 Executable files 26 elektor electronics Visual Basic for the Electronics Enthusiasts This short course on Visual Basic 2005 programming is designed especially for the electronics enthusiasts. These are people most likely to be interested in learning computer pro- gramming. Modern electronics technology pushes more and more towards programmable devices and many of these, need to communicate with personal computers. Many enthusiasts get stuck in the early stages of their efforts to learn programming in spite of the trend and their willingness. This is due to various reasons. Firstly, even though programming languages, like Basic, were designed initially for simplicity of use, are now complex tools that present the beginner with formi- dable starting hurtles. Secondly, manuals and text books on the subject lose their readers in the early chapters by delving too deeply into the workings of the language. This series of lessons will get you started with hands on practical experience immediately without long-winded jargon filled talk. We will try to explain things in the simplest possible way, focus- ing on the essential and the important, through plenty of exam- ples relevant to electronics. Even though Visual Basic is now a very powerful and complex language, it is also easy to use, provided one is led through the early stages. The built-in power of Visual Basic will enable you to write simple programs that produce professionally-looking VB2005 3 results that would seem unimaginable to those whose experi- ence goes only as far as the early versions of Basic of some years ago. Visual Basic Net is the latest version of Visual Basic developed by Microsoft and enables the user to produce Windows and Web applications. The example programs presented in this course were developed using Microsoft Visual Basic Express (beta 2 version). A later ver- sion of the program may exist at the time of publishing this book- let. Visual Basic Express may be downloaded from http://msdn.microsoft.com/vstudio/express/vb/default.aspx Having downloaded and installed the software on your hard drive you have 30 days to register the product. To do this go to Help — ► Activate Product and follow the instructions. The program files for the examples presented in the course are available for free downloading from the Publishers' website at www.elektor-electronics.co.uk. The files are accessible from Magazine -t January 2006 -4 Visual Basic 2005. Free booklet with Elektor Electronics January 2006 ISSN 0268/4518 © copyright Segment b.v. 2005 Printed in the Netherlands 4 VB2005 Starting Visual Basic After installation start the language by double clicking the short- cut icon or click: • Start -► Visual Basic 2005 Express (The start up screen is presented) • File — ► New Project — ► Windows Application • Type in the name of the project. The path where the project will be stored will be asked by the system when you first save the project. elektor electronics The Important parts of the Visual Basic development screen The following screen (called the Integrated Development Environment, or IDE in short) should now appear on your screen: 3 WudHnJLj^ Ir Ifttnmfl Vtajwl Jlqran Kin J apim 1 rita KfU _ - ’ X Ib w IripiT flhJrf frihg :Uu lidi wriVn • The Toolbox contains controls that we can place on the form e.g. text boxes containing text or numbers. • The Form is what is presented to the user when the program is run and contains the controls placed on it by the programmer. • The Solution Explorer window shows the files created by the program. elektor electronics VB2005 • The Properties window contains information about each item on the form and the form itself. Notes. • If for some reason any of the above windows are missing from your screen then from the menu select: View — ► Toolbox View — ► Solution Explorer, or View — ► Properties Window • To bring into view the Form double click the Form file in the Solution Explorer window. Our first program. We will introduce Visual Basic programming through a simple example. Program title: Ohm s law. Program specification: 1 . Program to display a simple circuit with a resistance R and a voltage V applied across it. 2. The user to be allowed to enter the values of the resistance and the voltage applied. 3. The program to calculate and display the current flowing through the circuit. Program operation: You will notice from the program specification that for the pro- 5 gram to work, three important things must be defined as shown below. Note that this is a general requirement for any type of program. The INPUT The PROCESSING The OUTPUT (In case of the (In the case of the (In the case of the example, the val- ► example, the calcu- * example, the dis- ues of the lation of the cur- play of the current resistance and the rent passing passing through voltage applied.) through the circuit.) the circuit.) Writing Visual Basic programs involves the following: • Picking objects or controls from the toolbox and placing them on the form. • Sizing and arranging the objects in the required position. The screen below shows one possible arrangement that satisfies the program specification. US Forml BE 'x OHM’S LAW • Changing the properties of objects as required. • Attaching code to objects or controls. The objects or controls on the form Picture box: Picture boxes are controls that enable the programmer to place pictures on the form. 6 VB2005 elektor electronics • Use a program like Microsoft Paint to draw a picture like the one above and save it. • Pick a Picture box control from the toolbox and place it on the form and size it to suit. • Select the picture box by clicking on it once. In the proper- ties window click on the button with the three dots next to the Backgroundlmage property. • Select the file which contains your picture and click Open. • Adjust, position and size the picture box so that the image is completely visible. Labels: Labels contain text and are usually placed on a form to help the user to understand the contents of the form. (e.g. the title of the pro- gram). Labels can also be used by the program to display data. R (Ohms) | OHM'S LAW v (Volts) V = I R I (Amps) Pick labels from the toolbox and place five of them on the form. Select each one in turn and change their properties as shown in the table below. Some controls like labels have their AutoSize property set to True by default. This means that they will adjust in size automatically as text is typed into their text property. To adjust their size man- ually set the AutoSize property to False. Text OHM'S LAW Label 1 Font Size 24, Bold BackColor Choose from palette TextAlign Middle centre Text R (Ohms) Label2 Font Size 1 4, Bold BackColor Choose from palette TextAlign Middle centre Text V (Volts) Label3 Font Size 1 4, Bold BackColor Choose from palette TextAlign Middle centre Label 1 (Amps) Label4 Font Size 1 4, Bold BackColor Choose from palette TextAlign Middle centre Label V=IR Label5 Font Size 24, Bold BackColor Choose from palette TextAlign Middle centre elektor electronics VB2005 7 Text boxes: Text boxes are controls that enable the program to display results but also allow the user to input data. The property Readonly for the last text box is set to True so that the user will not be allowed to enter values in this text box. It will be used only for outputting the result. 2000 12 0,006 Pick three text boxes from the toolbox and place them on the form next to the appropriate labels. Select each one in turn and change their properties as shown in the table below. Control Property Name txtR Text Box Font Size 1 2, Bold BackColor Choose from palette Text R Name txtV Text Box Font Size 1 2, Bold BackColor Choose from palette Text V Name txtl Font Size 1 2, Bold Text Box BackColor Choose from palette Text 1 Read Only True Command buttons: Command buttons are controls whose function is to execute a command or a series of commands when clicked. In our example the program will end when the button END is clicked. END Click once on the control and change the following properties: Control Property Setting Name btnEND Font Size 1 6, Bold Button BackColor Choose from palette Text END TextAlign Middle centre 8 VB2005 elektor electronics Attaching code to the controls Now that all the controls are in place on the form, we are ready to attach code to them. 1 . Double click the END command button. (The code window will open ready for you to insert command lines within the subroutine start and end statements which are automatically written for you). 2. Simply type in the command End as shown highlighted below. Private Sub btnEnd_Click ( ByVal sender As System. Ob ject , ByVal e As System. EventArgs ) Handles btnEnd. Click End End Sub 3. Return to the form by clicking on the View designer button above the Solution Explorer window or double clicking the Forml in the Solution Explorer window. 4. Double click the txtR text box (next to the R(Ohms) label). Type in the following (highlighted) code inside the subrou- tine. Private Sub txtR_TextChanged ( ByVal sender As System. Object , ByVal e As System. EventArgs ) Handles txtR . TextChanged txtl.Text = Val (txtV.Text) / Val (txtR. Text) End Sub 5. Double click the txtV text box (next to the V(Volts) label). Type in the same (highlighted) code inside the subroutine. Private Sub txtV_TextChanged ( ByVal sender As System. Ob ject , ByVal e As System. EventArgs ) Handles txtV . TextChanged txtl.Text = Val (txtV. Text ) / Val (txtR. Text) End Sub Notes on the code: • Notice the first line of the subroutine in paragraph 2 above. (Private Sub btnEnd_Click) "Click" is the event which will trigger the execution of this subroutine when the command button END is clicked at RUN time. Visual Basic is said to be an "event driven language" because it is designed to respond to events. Visual Basic is also said to be an "Object Oriented elektor electronics VB2005 9 Programming language", or OOP in short, because it treats everything as objects which have properties that can be changed using predefined methods. The End command is obvious. It simply means, end the pro- gram execution. Notice now the first line of the subroutine in paragraph 4 above. (Private Sub txtR_TextChanged) TextC hanged is the event that will trigger the execution of this subroutine. This means that every time the user types something inside the text box "txtR", then the command line txtl.Text = Val(txtV.Text) / Val(txtR.Text) will be exe- cuted. This statement means, change the text property of the text box "txtl " (which is the current flowing through the cir- cuit) with the result of the division to the right of the equal sign. Val is a function which takes the numeric value of the text inside the text boxes "txtV" and "txt R" The same instruction is executed if the user changes the text in the Voltage text box "txtV" as you can see from paragraph 5 above. The events that are displayed when you double click controls on the form are the default events. You can change the type of event to suit your program. Saving the program It is good practice to save your work regularly, as Visual Basic does not save it automatically for you. You can save by select- ing File — ► Save All from the menu. Visual Basic creates many files for your project. Always save just before running your program in case the program gets stuck. Running the program With all the controls in place and the code attached to them, we are ready to run the program. You can do this by clicking the Start button next to the Debug box in the toolbar or by selecting Debug — ► Start from the menu, or by pressing the function key F 5 on the keyboard. When you run the program you should see the form you designed open up on the screen. Go into the resist- ance text box and type in a value for the resistance. Immediately you will see the value 0 displayed in the current text box. This is because you have not yet placed any value for the voltage, so the computer considers the voltage to be 0. Now if you go into the voltage box and type a value, the computer will calculate the current and display it in the "current" text box. Also note that if you give a zero value for the resistance then the current goes to infinity. Even if you give a value of zero to both the resistance and the voltage the program will not stop with an error message (division 0 by 0) but it will place a NaN message in the Current text box and continue running. VB2005 elektor electronics If there are syntax errors the system will warn you. Once you run the program successfully Visual Basic Net creates an executable (exe) file which you can use to run the program directly from Windows without having to load the language. You can find this file with the extension .exe if you dig into the path where the project is saved. If you don't specify a different path, this will be found in: C:/My documents/Visual Studio 2005/Projects/ project name/Bin/Debug/project name.exe elektor electronics VB2005 Now on to our second program In this program we shall introduce Variables. Program title: Resistors in series and in parallel. Program specification: 1 . Program to show simple circuits of resistors in series and in parallel. 2. The user to be allowed to enter the values of the resistors and the voltage applied. 3. The program to calculate the equivalent resistance of the cir- cuit and the current passing through it. 11 The INPUT (In the case of the example, the values of the resistance and the voltage applied.) Control Property Setting Place the following controls on the form and size them to suit. • A label for the title of the program. • A picture box showing the resistors in series and in parallel which you can draw using Microsoft Paint. • Four text boxes placed next to the resistors which will be used to enter the values of the resistances. • Three labels R Eq.(Oms), Voltage (V), and Current (A). • Next to the above labels, three text boxes for the R equiva- lent, Voltage and Current for the series circuit and another set of three for the parallel circuit. • Finally a command button END to end the program. Select each one of the above controls in turn and change their properties as shown in the table below. We are omitting the font and background colour properties to save space. Change these to your liking. Label 1 Text Resistors in Series and in Parallel Label 2 Text R Eq. (Ohms) Label 3 Text Voltage (V) Label 4 Text Current (1) Name txtSeriesRl Text Box 1 Text R1 TextAlign Centre Name txtSeriesR2 Text Box 2 Text R2 TextAlign Centre Name txtParallRl Text Box 3 Text R1 TextAlign Centre Name txtParallR2 Text Box 4 Text R2 TextAlign Centre Name txtRSeriesEquiv Text Box 5 Text R Equivalent TextAlign Centre Readonly True Name txtRSeriesVolts Text Box 6 Text Voltage TextAlign Centre Name txtRSeriesCurrent Text Box 7 Text Current TextAlign Centre Readonly True 12 VB2005 elektor electronics Control Property Setting Name txtRParallEquiv Text Box 8 Text R Equivalent TextAlign Centre Readonly True Name txtRParallVolts Text Box 9 Text Voltage TextAlign Centre Name txtRParallCurrent Text Box 1 0 Text Current TextAlign Centre Readonly True Name btnEnd Buttonl Text END TextAlign MiddleCentre Attach the following code to the appropriate controls by double clicking on each control in turn and typing the code inside the subroutines. Code attached to button END 1 2 3 Private Sub Buttonl_Click ( ByVal sender As System. Object, ByVal e As System. EventArgs ) Handles Buttonl . Click End End Sub Code attached to text box txtSeriesRl 4 5 6 7 8 9 10 Private Sub txtSeriesRl_TextChanged ( ByVal sender As System. Object, ByVal e As System. EventArgs ) Handles txtSeriesRl . TextChanged Dim REquivalent, Current As Single REquivalent = Val ( txtSeriesRl . Text ) + Val ( txtSeriesR2 . Text ) txtRSeriesEquiv. Text = REquivalent Current = Val ( txtSeriesVolts . Text ) / Val ( txtRSeriesEquiv . Text ) txtSeriesCurrent . Text = Current End Sub Code attached to text box txtSeriesVolts li 12 13 14 15 Private Sub txtSeriesVolts_TextChanged ( ByVal sender As System. Object, ByVal e As System. EventArgs ) Handles txtSeriesVolts . TextChanged Dim Current As Single Current = Val ( txtSeriesVolts . Text ) / Val ( txtRSeriesEquiv . Text ) txtSeriesCurrent . Text = Current End Sub Code attached to text box txtSeriesR2 16 17 18 19 20 21 22 Private Sub txtSeriesR2_TextChanged ( ByVal sender As System. Object, ByVal e As System. EventArgs ) Handles txtSeriesR2 . TextChanged Dim REquivalent, Current As Single REquivalent = Val ( txtSeriesRl . Text ) + Val ( txtSeriesR2 . Text ) txtRSeriesEquiv. Text = REquivalent Current = Val ( txtSeriesVolts . Text ) / Val ( txtRSeriesEquiv . Text ) txtSeriesCurrent . Text = Current End Sub elektor electronics VB2005 13 Code attached to text box txtParallRl 23 Private Sub txtParallRl_TextChanged ( ByVal sender As System. Object , ByVal e As System. EventArgs ) Handles txtParallRl . TextChanged 24 Dim REquivalent, Current As Single 25 REquivalent = (Val ( txtParallRl . Text ) * Val ( txtParallR2 . Text ) ) / ( Val ( txtParallRl . Text ) + Val ( txtParallR2 . Text ) ) 26 txtRParallEquiv. Text = REquivalent 27 Current = Val ( txtParallVolts . Text ) / Val ( txtRParallEquiv . Text ) 28 txtParallCurrent . Text = Current 2 9 End Sub Code attached to text box txtParallR2 30 Private Sub txtParallR2_TextChanged ( ByVal sender As System. Object, ByVal e As System. EventArgs ) Handles txtParallR2 . TextChanged 31 Dim REquivalent, Current As Single 32 REquivalent = (Val ( txtParallRl . Text ) * Val ( txtParallR2 . Text ) ) / (Val ( txtParallRl . Text ) + Val ( txtParallR2 . Text ) ) 33 txtRParallEquiv. Text = REquivalent 34 Current = Val ( txtParallVolts . Text ) / Val ( txtRParallEquiv . Text ) 35 txtParallCurrent . Text = Current 36 End Sub Code attached to text box txtParallVolts 37 Private Sub txtParallVolts_TextChanged ( ByVal sender As System. Object , ByVal e As System. EventArgs ) Handles txtParallVolts . TextChanged 38 Dim Current As Single 39 Current = Val ( txtParallVolts . Text ) / 14 Val ( txtRParallEquiv . Text ) 40 txtParallCurrent . Text = Current 41 End Sub Notes on the code: • Dimensioning of variables. Refer to line 5 of the code above. Variables are objects which hold data in the memory of the com- puter. You the programmer can choose the names of variables. REquivalent and Current are variables which are declared by the Dim (Dimension) statement to be of type Single. These are decimal numbers of single precision. Other types of variables are Integers, String, Date etc. • Line 6 calculates the value of the equivalent resistance of the series circuit and line 7 places the result into the text box txtRSeriesEquiv. In the same way lines 8 and 9 calculate the Current and the result is placed in the txtSeriesCurrent text box. In effect what is happening here is that the program is changing the text property of the text boxes on the form. When you type the dot after the text box name, Visual Basic opens a window with all the properties available. You choose the one which is applicable. • Notice that variables are declared in each subroutine as their values are valid only within the subroutine in which they have been declared. See lines 12,17,24,31 and 38. Now you can run the code by clicking the Start Debugging but- ton to test the program. elektor electronics Our third program This program will be useful for displaying the values of resistors according to their colour code. In the process we are also going to introduce some neat tricks with colours. Program title: Resistor Values Program specification: 1 . Program to present the user with a picture of a resistor, 2. The user will be prompted to select the colour of the bands on the resistor, 3. Once this is done the program will calculate the resistor value and present it to the user. fBhorml fT]fb]'x| RESISTOR VALUES Place the following controls on the form and size them to suit. • A label for the title of the program, • A picture box for the picture of the resistor, • Four labels for the colour bands of the resistor, • Five command buttons for the control of the colour bands including the END. Select each one of the above controls in turn and change their properties as shown in the table below. Control Property Setting Text Resistor Values Label 1 Font Font size 20 Back Colour Choose from palette Text align Middle Centre Name IblBandl Text Empty (Space) Label 2 Back Colour Red AutoSize False Location and Size Adjust to suit Size Adjust to suit Name lblBand2 Text Empty (Space) Label 3 Back Colour Red AutoSize False Location and Size Adjust to suit elektor electronics VB2005 15 Control Property Setting Name lblBand3 Text Empty (Space) Label 4 Back Colour Red AutoSize False Location and Size Adjust to suit Name lblBand4 Text Empty (Space) Label 5 Back Colour Red AutoSize False Location and Size Adjust to suit Name IblValuel Text Empty (Space) Label 6 Back Colour Select from palette AutoSize False Location and Size Adjust to suit Name lblValue2 Text Empty (Space) Label 7 Back Colour Select from palette AutoSize False Location and Size Adjust to suit Name Text Empty (Space) Label 8 Back Colour Select from palette AutoSize False Location and Size Adjust to suit 6 Name IblTolerance Text Empty (Space) Label 9 Back Colour Select from palette AutoSize False Location and Size Adjust to suit Name btnBandl Button 1 Text Band 1 TextAlign Middle Centre Name btnBand2 Button 2 Text Band 2 TextAlign Middle Centre Name btnBand3 Button 3 Text Multiplier Band TextAlign Middle Centre Name btnBand4 Button 4 Text Tolerance Band TextAlign Middle Centre Name btnEnd Button 5 Text END TextAlign Middle Centre Attach the following code to the Band 1 button by double click- ing the control and typing the code inside the subroutine. 1 Private Sub btnBandl_Click ( ByVal sender As System. Object, ByVal e As System. EventArgs ) Handles btnBandl . Click elektor electronics 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 Static number As Integer number = number + 1 If number > 10 Then number = 1 Select Case number Case 1 lblBandl . BackColor = Color. Black lblValuel . Text = "0" Case 2 lblBandl . BackColor = Color. Brown lblValuel . Text = “ 1 " Case 3 lblBandl . BackColor = Color. Red lblValuel . Text = " 2 " Case 4 lblBandl . BackColor = Color. Orange lblValuel . Text = " 3 " Case 5 lblBandl . BackColor = Color. Yellow lblValuel . Text = "4" Case 6 lblBandl . BackColor = Color. Green lblValuel . Text = " 5 " Case 7 lblBandl . BackColor = Color. Blue lblValuel . Text = “ 6 " Case 8 lblBandl . BackColor = Color. Violet lblValuel . Text = “ 1 " Case 9 lblBandl . BackColor = Color. Gray lblValuel . Text = " 8 " Case 10 lblBandl . BackColor = Color. White lblValuel . Text = "9" End Selec End Sub elektor electronics VB2005 In line 2 the variable number is declared as Integer with the Static statement and not with the Dim statement. Static means that the value of the number will be retained even after exit- ing the subroutine. In this way the colour change of each band will be in sequence even if the user clicks the band but- tons at random. The statement of line 3 increases the value of the variable number by one every time the button is clicked. Line 4 is a conditional statement. As we only have 10 differ- ent band colours we don't want the value of the variable number to increase above the number 10. The If statement simply resets its value to 1 every time that happens. Lines 5 to 36 contain another kind of conditional statement. It is the Select Case statement. The condition is the value of the variable number and you can see for example that if the value is 6 then the program will branch to execute the statements of lines 22 and 23. Line 22 sets the BackColor property of label lblBandl to Green and line 23 places the figure 5 in the label lblValuel . Attach the same code to command button btnBand2 but replace lblBandl with I bl Ba nd2 and lblValuel with lblValue2. You can use Copy/Paste. 17 Attach the following code to command button btnMultiplier. The code is similar except for the difference in the colours and the reference to the labels lblBand3 and IbIMultiplier. Private Sub btnMultiplier_Click ( ByVal sender As System. Object , ByVal e As System. EventArgs ) Handles btnMultiplier . Click Static number As Integer number = number + 1 If number > 11 Then number = 1 Select Case number Case 1 lblBand3 . BackColor = Color. Silver IbIMultiplier . Text = "0.01" Case 2 lblBand3 . BackColor = Color. Gold IbIMultiplier . Text = "0.1" Case 3 lblBand3 . BackColor = Color. Black IbIMultiplier . Text = "1" Case 4 lblBand3 . BackColor = Color. Brown IbIMultiplier . Text = "10" Case 5 lblBand3 . BackColor = Color. Red IbIMultiplier . Text = "100" Case 6 lblBand3 . BackColor = Color. Orange IbIMultiplier . Text = "lk" Case 7 lblBand3 . BackColor = Color. Yellow IbIMultiplier . Text = "10k" Case 8 lblBand3 . BackColor = Color. Green IbIMultiplier . Text = "100k" Case 9 lblBand3 . BackColor = Color. Blue 18 IbIMultiplier . Text Case 10 lblBand3 . BackColor IbIMultiplier . Text Case 11 lblBand3 . BackColor IbIMultiplier . Text End Select End Sub Finally attach the following code to the Command button btnTolerance: Private Sub btnTolerance Click (ByVal sender As System. Object, ByVal e As System. EventArgs ) Handles btnTolerance . Click Static number As Integer number = number + 1 If number > 7 Then number = 1 Select Case number Case 1 lblBand4 . BackColor = Color. Silver lblTolerance . Text = "10%" Case 2 lblBand4 . BackColor = Color. Gold lblTolerance . Text = " 5 % " Case 3 lblBand4 . BackColor = Color. Brown lblTolerance . Text = " 1 % " Case 4 lblBand4 . BackColor = Color. Red lblTolerance . Text = " 2 % " Case 5 lblBand4 . BackColor = Color. Green lblTolerance . Text = " 0 . 5 % " = "1M" = Color. Violet = "10M" = Color. Gray = "100M" elektor electronics Case 6 lblBand4 . BackColor = Color . Blue lblTolerance . Text = " 0 . 25 %" Case 7 lblBand4 . BackColor = Color .Violet lblTolerance . Text = "0 . 1%" End Select End Sub A program to display graphics In this program we are going to see how an oscillating circuit (or its mechanical equivalent vibrating system) behaves by plotting the results on the form using graphics. Program title: Vibration/Oscillation Systems You are now ready to test the program. When clicking the Band buttons you should see the colours of the bands changing and the values of the resistance displayed in the labels. Program specification: 1 . Program to show an LC circuit and its mechanical equivalent spring mass system. 2. The user will be prompted to input values for L and C (or K and M), elektor electronics VB2005 19 3. The program will calculate the behaviour of the system and to display the result in graphical form. Place the following controls on the form and size them to suit. • A label for the title of the program, • A picture box for the picture of the LC circuit and the Spring Mass system, • Two labels for the values of the Inductance and the Capacitance, • Two text boxes for the input of the above values, • Two command buttons for GO and END. Select each one of the above controls in turn and change their properties as shown in the table below. Text Vibration/ Oscillation systems Label 1 Font Font size 1 5 Back Colour Choose from palette Text align Middle Centre Text Inductance L or Mass M Label 2 Font Font size 1 2 Back Colour Choose from palette Text align Middle Centre Label 3 Text Capacitance C or Stiffness K Font Font size 1 2 Back Colour Choose from palette Text align Middle Centre Name IxtL Text Box 1 Text 1 TextAlign Centre Name txtC Text Box 2 Text 1 TextAlign Centre Name btnGo Button 1 Text GO TextAlign Middle Centre Name btnEnd Button 2 Text END TextAlign Middle Centre Attach the following code to the command button GO: 1 2 3 4 5 Private Sub cmdGo_Click ( ByVal sender As System. Object, ByVal el As System. EventArgs ) Handles cmdGo. Click 'Declare variables Dim i, j, x, y, xl, yl, shiftX, shiftY, omega As Single Dim myGraphics As Graphics Dim myPen As New Pen ( Color .White , 2) 20 VB2005 elektor electronics 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 • In lines 2 to 6 we declare the variables and prepare the graphics environment to draw lines on the form. Do not worry if you do not understand some of the statements. (Line 2 is a comment placed to help one to understand the logic behind the code. It is not an executable instruction). • In lines 8 and 9 we define shift values so that the graph is myGraphics = Graphics . FromHwnd ( hwnd : =ActiveForm( ) .Handle) 'shift the position of the graph on the form shiftX = 20 shiftY = 350 xl = 0 + shiftX yl = 0 + shiftY 'calculate the frequency of the vibration omega = Sqrt ( Val ( txtC . text ) / Val ( txtL . text ) ) 'draw axis myPen. Color = Color. Black myGraphics . Dr awLine (myPen, 0 , shiftY, 700, shiftY) 'loop to increment the value of x and calculate the value of y For x = 0 To 80 Step 0.2 y = -(Cos(x * omega) * 100) myPen. Color = Color. White myGraphics . DrawLine (myPen, xl, yl, (x * 10 + shiftX), (y + shiftY)) 'save the previous plot position in xl and x2 xl = x * 10 + shiftX yl = y + shiftY If x * 10 > 650 Then Exit For 'Delay loop For i = 1 To 200000 j = i * i Next Next End Sub elektor electronics VB2005 drawn in the lower half of the form. The origin of the form is at the top left corner. In line 13 the frequency of the oscillation is calculated. Sqrt means the square root. In lines 15 and 16 we draw a horizontal line in black from left to right. Between lines 18 and 30 we program what is called a LOOP. For x = 0 To 80 Step 0.2 means start with a zero value for x and increment by 0.2 until the value of x reach- es 80. Each time all the statements which are between lines 1 8 and 30 will be executed. In line 1 9 the value of y is calculated. This may represent the voltage. Lines 20 and 21 draw a line from the previous plot position ( xl ,yl ) to the new calculated plot position (x, y) in colour white. Notice that the value of x is scaled by a factor of 10 to make the wave visible. In lines 23 and 24 the values of x and y are placed in xl and yl to become the previous plot position for the next loop. In line 25 we have a conditional statement which will stop the loop if the plot position reaches the right hand end of the form. In lines 27 to 29 we program a delay loop with a dummy calculation inside it to delay the computer so the user can see the wave moving. You can change the value of 200000 according to how fast your computer is. Notice that this is a loop within another loop and is called a nested loop. Every time the outer loop is executed, the inside loop is executed 200000 times. 21 • Finally we have not programmed for the clearing of the form to start a new plot. However you will find that if you minimise the form and maximise it back the form is cleared. Something which in other cases would be undesirable in this case it is useful. A program to create files In tnis program we are going to build a database containing information about OP-Amps. Program title: OP-Amp Database OP-AMP Database Program specification: Program to allow the user: 1 To input information about OP-Amps, 2 To add, edit and delete records, 3 To search the database for a particular devise, 4 To display the pin-out diagrams of the devices, 5 To save and load the database records. Place the following controls on the form and size them to suit. • Labels for the title of the program and the headings above the op-amp records, • Command buttons for the ADD, DELETE, LOAD, SAVE, FIND Device, END and Show Pinouts. • A text box for the input of record data, • A Label for the display of the pinout diagram, • A list box into which the database records will be held and displayed. Select each one of the above controls in turn and change their properties as shown in the table below. (Only the important objects and properties are shown). Name IblPinouts Label Image Select from Resources Image align Middle Centre Button 1 Name btnAdd Text ADD 22 VB2005 elektor electronics Button 2 Name btnDelete Text DELETE Button 3 Name btnLoad Text LOAD Button 4 Name btnSave Text SAVE Button 5 Name btnFind Text FIND Device Button 6 Name btnPinouts Text Show Pinouts Text Box Name txtDevice Text Empty List Box Name IstDevice Items Enter some initial data Attach the following code to the appropriate controls by double clicking on each control in turn and typing the code inside the subroutines. Code attached to command button END Private Sub btnEnd_Click ( ByVal sender As Object, e As System. EventArgs ) Handles btnEnd. Click End End Sub Code attached to command button ADD Private Sub btnAdd_Click ( ByVal sender As System. Ob ject, ByVal e As System. EventArgs ) Handles btnAdd. Click 'Add text box content to list box content IstDevice . Items . Add ( txtDevice . Text ) 'Clear text box and place cursor in it ready for next item input txtDevice . Text = "" txtDevice . Select ( ) End Sub Code attached to command button DELETE Private Sub btnDelete_Click ( ByVal sender As Object, ByVal e As System. EventArgs ) Handles btnDelete . Click 'Delete the selected item from the list box IstDevice . Items . Remove ( IstDevice . Selectedltem) End Sub Code attached to command button LOAD Private Sub btnLoad_Click ( ByVal sender As System. Object, ByVal e As System. EventArgs ) Handles btnLoad . Click 'Declare variables and open file dialogue to select file Dim i, count As Integer OpenFileDialogl . ShowDialog ( ) Dim sr As New System. 10 . StreamReader ( OpenFileDialogl . FileName ) 'Read first item which should be the number of items in the file count = Val ( sr . ReadLine ) 'Loop to read the records in the file and add to the list box For i = 0 To count - 1 IstDevice . Items .Add ( sr . ReadLine ) elektor electronics VB2005 23 Next i 'Close the file sr .Close ( ) End Sub Code attached to command button SAVE Private Sub btnSave_Click ( ByVal sender As System. Object, ByVal e As System. EventArgs ) Handles btnSave . Click 'Declare variables and open file dialogue to select file Dim i, count As Integer SaveFileDialogl . ShowDialog( ) Dim sw As New System. 10 . StreamWr iter ( SaveFileDialogl . FileName ) 'Write the number of items in the file count = IstDevice . Items . Count sw.WriteLine ( count ) 'Loop to select records from the list box and write the records in the file For i = 0 To count - 1 IstDevice . Selectedlndex = i sw.WriteLine ( IstDevice . Items . Item( i ) ) Next i 'Close the file sw. Close ( ) End Sub Code attached to command button FIND Private Sub btnFind_Click ( ByVal sender As System. Object, ByVal e As System. EventArgs ) Handles btnFind . Click 'Declare variables Dim DeviceWanted, DeviceListed , DeviceRecord As String Dim count, i As Integer 'Function Trim removes spaces from the string DeviceWanted = Trim( txtDevice . Text ) 'Find the number of items in the list box count = IstDevice . Items . Count 'Loop to compare the records in the list box with the wanted device For i = 0 To count - 1 IstDevice . Selectedlndex = i DeviceRecord = IstDevice . Selectedltem DeviceListed = Trim(Microsoft .VisualBasic .Left (DeviceRecord, 9)) 'If found place the record in the text box and display message If DeviceWanted = DeviceListed Then txtDevice . Text = IstDevice . Items . Item( i ) MsgBox ( "Device found!") 'If found exit search GoTo finish End If Next i 'If device is not found display message txtDevice . Text = "" MsgBox ( "Device not found") finish : End Sub Code attached to command button Show Pinouts Private Sub btnPinouts_Click ( ByVal sender As System. Object, ByVal e As System. EventArgs ) Handles btnPinouts . Click 'Declare counter j as static integer Static j As Integer 'Display the appropriate image in the label Pinouts Select Case j Case 1 lblPinouts . Image = My . Resources . SE1_0P_AMP_P I C Case 2 24 VB2005 elektor electronics The code should be clear given the comments. The operation of the program is also simple. • To add a record type the data in the text box and click the ADD button. • To delete a record select it by clicking on it in the list box and then click the DELETE button. • To load data from a file click the LOAD button. Select the file and click OPEN. Note that the records are added to the existing records in the list box. • To save the records in a file click the SAVE button. • To search the database for a particular device type the des- ignation of the device in the text box ( e.g. 741) and click the Find Device button. • To show the pinout diagram click repeatedly the Show Pinouts button until you find the appropriate diagram. elektor electronics VB2005 Placing additional pinout diagrams. The pinout diagrams will of course have to be drawn using a program like Microsoft Paint. Alternatively if these diagrams can be found from manufacturer's manuals then they can be scanned and saved, each one as a separate file. Once you have the dia- grams stored in files then follow the instructions below to add the diagrams in the resources of the program. This has to be done at program design time: • Double click tAy Projects in the Solution Explorer window, • Click the resources tab in the window opened in the main area, • Click the triangle (arrow) to the right of the Add Resources button, • Select Add Existing File, • In the code for the Show Pinouts button add the addition- al code for the diagrams being added, (do not forget to change the value of the counter / for the total number of dia- grams in the resources, last line before the End Sub). 25 Executable files Once you have debugged the program and you are satisfied that it works, you do not want to go through the process of load- ing Visual Basic Express every time you want to run the program. When you debug and save your program Visual Basic compiles your source code and creates an executable (.exe) file for you. You can find this file if you dig into the directories. This file can then be copied (on your desktop for example) and run by simply double clicking on it. The executable file can be found under the directories where you have saved your program e.g. \OP-AMP-Data\Bin\OP-AMP-Data.exe Please note that executable files may not run on another machine that has not had the NET framework installed on it. The last program we have looked at shows the power of Visual Basic 2005. With less than two pages of code we have imple- mented a program that creates a database with facilities to Add, Delete, Edit, Save, Load, Search and Display diagrams. In this short course on Visual Basic programming you have learned to write programs which: 26 allow the user to input data, process the input data, VB2005 • present the user with results in alphanumeric and in graphi- cal form, • create files on a mass storage device and store data in them, • open files to read data from them. In short you have learned to program the computer to carry out the most important processes that computer programs in general do. elektor electronics 5 a> lectronics Microcontroller Basics Burkhard Kainka ISBN 0-905705-67-X 230 Pages £18.70 / US$ 33.70 Microcontroller Basics Microcontrollers have become an indispensable part of modern electronics. They make things possible that vastly exceed what could be done previously. Innumerable applications show that almost nothing is impossible. There’s thus every reason to learn more about them, but that raises the question of where to find a good introduction to this fascinating technology. The answer is easy: this Microcontroller Basics book, combined with the 89S8252 Flash Board project published by Elektor Electronics. This book clearly explains the technology using various microcontroller circuits and programs written in several different programming languages. In the course of the book, the reader gradually develops increased competence in converting his or her ideas into microcontroller circuitry. Step into the fascinating world of microcontrollers Elektor Electronics (Publishing) / Segment B.V. Regus Brentford 1000 Great West Road Brentford TW8 9HH United Kingdom Tel. +44 (0) 208 261 4509 Order online at: www.elektor-electronics.co.uk lectronics £69.00 /US$112.50 (plus postage) Elektor Hardware & Software Flash Microcontroller Starter Kit Contents of Starter Kit: 89S8252 Flash Microcontroller board (ready-assembled and tested PCB), 300-mA mains adapter, serial cable for COM port an a software bundle on CD-ROM. Article compilation on CD-ROM: • 89S8252 Flash Microcontroller Board (December 2001) • Microcontroller Basics Course parts 1-6 (January through June 2002) • Microcontroller Basics FAQ (September 2002) • Port Line and ADC Extension for 89S8252 Flash Micro Board (December 2002) • Chess Computer using the Flash Micro Board. Elektor Electronics (Publishing) / Segment B.V. Regus Brentford 1000 Great West Road Brentford TW8 9HH United Kingdom Tel. +44 (0) 208 261 4509 Order online at: www.elektor-electronics.co.uk