FREE DVD OCTOBER 2006 £3.80 www.elektor-electronics.co Simulation Software LUCL [LL’UU L’llLLL Pucl LiU£ ettixe a tcuudiuui lektor v rjj (Tl ' ■" n ,11 # 1 It'S tU 2 Liiiiulituu iudiUii' / for FRE^ c °J^ f r oin ta\o9 ue liters of our 4 ^;,r n o e fau9h-.u9 ^ prices in 4 St9 for’06 Battery Zapper MKII Kit KC-5427 £29.00 + post, packing & VAT This kit attacks a common cause of failure in wet lead acid cell batteries: sulfation. The circuit produces short bursts of high level energy to reverse the damaging sulfation effect. This new improved unit features a battery health checker with LED indicator, new circuit protection against badly sulfated batteries, test points for a DMM and connection for a battery charger. Kit includes case with screen printed lid, PCB with overlay, all electronic components and clear English instructions. Suitable for 6, 12 and 24V batteries • Powered by the battery itself Two-Way SPDIF/Toslink Digital Audio Converter Kit KC-5425 £725 + post, packing & VAT This kit converts coaxial digital audio signals into optical or vice-versa. Use this bit stream converter in situations where one piece of equipment has an optical audio input and the other a coaxial digital output. Kit includes Toslink optical modules, PCB with overlay, case with screen printed lid, all electronic components and clear English instructions. for’06 M Requires 9-12VDC wall adaptor (Maplin #JC91Y £14.99) Theremin Synthesiser MKII Kit KC-5426 £43.50 + post, packing & VAT By moving your hand between the metal antennae, create unusual sound effects! The Theremin Mkll improves on its predecessor by allowing adjustments to the tonal quality and better waveform. With a multitude of controls this instrument's musical potential is only limited by the skill and imagination of its player. Kit includes stand, PCB with overlay, machined case with silkscreen printed lid, loudspeaker, pitch antennae, all specified electronic components and clear English instructions. Requires 9-12VDC wall adaptor (Maplin #JC91Y £14.99) . I / L,s ^ci i n Beach b the classic hit% ys y^ns ood ~ \ S Smart Fuel Mixture Display Kit KC-5374 £8.95 + post, packing & VAT This kit features auto dimming for night driving, emergency lean-out alarm, better circuit protection, and a 'dancing' display which functions 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 (HB-6013) €1.40 each \ We stock 1 ’v an extensive ^range of quality Intelligent Turbo Timer Kit KC-5383 £14.75 + post, packing & VAT This great module uses input from an airflow, oxygen, or MAP sensor to determine how hard the car has been driven. It then uses this information to calculate how long the car needs to idle, reducing unnecessary idle time. The sensitivity and maximum idle time are both adjustable, so you can be sure your turbo will cool properly. Kit supplied with PCB, and all electronic components. Recommended box UB3 (HB-6013) £1.40 each Z. automotive - A-, kits — 1 1\N S III} POST AND PACKING CHARGES: Order Value Cost £20 - £49.99 £5 £50 - £99.99 £10 £100 - £199.99 £20 Max weight 121b (5kg). Heavier parcels POA. Minimum order £20. Order Value Cost £200 - £499.99 £30 £500+ £40 Starship Enterprise Door Sound Simulator Kit KC-5423 £11.75 + post, packing & VAT This easy to build kit emulates the ( / / unique noise made when the cabin ^ ^°r all y Qu doors on the Starship Enterprise ^ re kkie open and close. The 'shut' noise is also ^ duplicated. The sound emulator can be triggered by switch contacts (normally open), which means you can use a reed magnet switch, IR beam or PIR detector. Kit includes a machined silkscreened, and pre- drilled case, speaker and all electronics components with clear English instructions. Requires 9-12VDC wall adaptor (Maplin #JC91Y £14.99) Universal High Energy Ignition Kit KC-5419 £27.75 + post, packing & VAT 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. m Kit supplied with die-cast case, PCB and all electronic components. for’06 Voltage Monitor Kit KC-5424 £6.00 + post, packing & VAT This versatile kit will allow you to monitor the battery voltage, the airflow meter or oxygen sensor in your vehicle. The kit features 10 LEDs that light up in response to the measured voltage, preset 9-16V, 0-5V or 0-1 V ranges complete with a fast response time, high input impedance and auto dimming for night driving. Kit includes PCB with overlay, LEDs, all electronic components and lufLlT clear English W instructions. • Requires 12VDC power for’06 Recommended box UB5 (HB-6015) £0.83 each Log on to www.jaycarelectronics.co.uk/catalogue 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 ^ All prices I aycnr Free 410+ page Catalogue^- Waveform Generator Load up to 32K arbitrary waveform and replay via the onboard DAC (lOMS/s) or a digital pattern from the POD (40MS/s) 8 Channel 40MS/s Logic Analyzer Capture digital signals down to 25nS with arbitrary trigger patterns. 3 Input 100MHz Analog DSO Classic Analog Scope using a standard xl/xlO BNC probe. Additional inputs on the POD for dual channel operation. 8 + 1 Mixed Signal Scope True MSO to capture an analog waveform time-synchronized with an 8 channel logic pattern triggered from any source. Real-Time Spectrum Analyzer See the spectrum and waveform of analog signals simultaneously and in real-time Standard 1M/20pF BNC Input 200uV-20V/div with xIO probe S/W select AC/DC coupling S/W select 50ohm termination Arbitrary Waveform Generator BitScope "Smart POD" Connector 8 logic channels, 2 analog channels Dual channel capture from POD A/B Async serial I/O for external control Logic Pattern generator 32K 40MS/s BUS Powered USB 2.0 Device Single USB cable to your PC Compressed data transmission Simple ASCII control protocol BitScope Scripting Language External/Passthru Power Supply Auto senses an external supply - removes power load from USB for use with unpowered hubs. Supplies up to 500mA via POD Turn your PC or NoteBook into a powerful Scope and Logic Analyzer! See inside your circuit in the analog and digital domains at the same time to make tracking down those elusive real-time bugs much easier. Pocket Analyzer combines a high speed sample-synchronized storage scope and logic analyzer with a programmable waveform and logic pattern generator. Also included is an integrated real-time spectrum analyzer and powered "Smart POD" expansion interface so you've got all bases covered! BitScope and your PC provide an array of Virtual Instruments • Education • Robotics • Lab Scope • Fast DAQ • Service ■ri*e- ■«P#I1 K-3HC * * About the same size and weight as a Pocket PC, this USB powered BitScope needs no bulky accessories. It's the perfect low cost "go anywhere" test and debug solution. BitScope DSO 1.2 software for Windows and Linux Debug BitScope Pocket Analyzer uses highly integrated Surface Mount technology to provide functionality you would expect from scopes many times the size and price. Its programmable Virtual Machine architecture means new functionality can be added via software. For custom Data Acquisition, export directly to your spreadsheet. www . bitscope . com BitScope Pocket Analyzer USB Oscilloscope <& Logic Analyzer The new generation Scope for the age of microelectronics. ading the way Shorter waves — longer (aces Like so many colleagues and, hopefully, Elektor Electronics readers, I marvel at the possibilities of simulating electronic circuits on the PC using today's sophisti- cated software and sleek user inter- faces. About 10 years ago, I started out (half-heartedly I must admit) with Elec- tronic Workbench, connecting up a sim- ple logic circuit that was supposed to count six key presses before lighting an LED. It worked on the screen and I could even prove the operation of a 4093 Schmitt trigger gate by applying not so neat input signals. Nothing destroyed, no components to buy and best of all no solder smell or wire clippings on the workshop floor. Next I slapped together some coils and capacitors into what I was certain to represent a pi-filter for a 144-MHz transmitter, using values I knew were correct as they were actually present in my 2-m QRP transmitter. I showed the file to a colleague far more versed in e-simulation and he told me "you'd better breadboard that, there's no such thing as nanohenries and 1 44 MHz — what's it for anyway?" I insisted on doing a simulation however and was surprised to see the blatant shortcomings of the PC programs when dealing with stray capacitance, induc- tance and the complex output imped- ance of a 2N221 9A transistor in grounded base mode. Spurred into finding circuits that would fool the e-simulation programs of the age, friends and colleagues came up with UHF noise generators, Colpitts oscillators, PCB stripline filters, critically coupled inductor pairs and worst of all — a Gunn diode (which has a negative resistance). It was good fun watching the programs either crash or produce downright idiotic results. One program supplier, in response to a critical letter of a good five pages, was honest enough to reply that "our product is intended to cover the needs of main- stream electronics, and cannot reason- ably be expected to cater for exotic applications like the ones you suggest". Today's simulation programs have vast component libraries and the ability to mimic non-ideal signals to get much closer to real-life electronics. None the less, the intricacies of RF design are insufficiently covered by most 'wide- band' simulation software, which is strange as so much new electronics is wireless in way or another. Now there's a challenge. Jan Buiting, Editor Believe us, several problems have to be resolved in order to properly sample the heart's electrical activity. Here we show you how to make your own ECG reading device from a GameBoy games console. 20 Simulation Programs Dozens of programs are now available for simulating elec- tronic circuits on the PC. The DVD you get free of charge with this issue allows you to decide which one is best suited for you. In this article we give you an overview with a short description of the programs on the DVD. CONTENTS 50 PIC In-Circuit Debugger/Programmer PIC microcontrollers of the 8- bit 1 6F and 1 8F family are a favourite of many Elektor Electronics readers. A must for users is a means of load- ing programs and an In-Cir- cuit Debugger (ICD) for tracking down programming errors. This project shows you how to do it the cheap way. 67 In Control with Eclipse Eclipse is a modern devel- opment environment, which is not only easy to learn but also easily expanded and suitable for the most diverse pro- gramming languages. Furthermore, the package is free and open-source! ■ \ m u ii r- I ri l ifB imu nj! j fH ipqi pviBilr Jn.hl^.JUW ^UIdlHl|! I ■ P !>Ivljt" — ■■Uhl I It-WrLMm' ’ m TiTW .llhHi JHI1DEI I it n hit .Miiiii ■ imlfvnTfiininitnihtfl ■ n pnlj bNhi^ . mmtmmrtL um me hI«w hi a f i ' 1 ■ . w i mwmx nsnuiwiB it n “ ■ l* ■ 1 1 I ■ i an g ■ ti i pv 1 j Volume 32 October 2006 no. 358 know-how 16 The PC as Breadboard hands-on 32 GBECG GameBoy Electrocardiograph 45 ECG using a Soundcard 50 PIC In-Circuit Debugger/Programmer 60 FPGA Course (5) Programmable Laser Lightshow 76 Design Tips Metal film resistor trimming Logarithmic volume control technology 28 The Electronic Doctor 56 Star-point Grounding 67 In Control with Eclipse info & market 6 Colophon 8 Mailbox News & New Products Simulation Programs 48 Electromagnetic Compatibility (EMC) page 64 Software Update for EEDTS Pro 81 Elektor SHOP 84 Sneak Preview infotainment 74 CDP1802- the first micro in space Hexadoku lektor lectronics Volume 32, Number 358, October 2006 ISSN 0268/45 1 9 Elektor Electronics aims at inspiring people to master electronics at any personal level by presenting construction projects and spotting developments in electronics and information technology. Publishers: Elektor 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.elektor-electronics.co.uk. The magazine is available from newsagents, bookshops and electronics retail outlets, or on subscription. 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: 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: Carlo van Nistelrooy Customer Services: 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, 2 East Poultry Street, London EC I A, England Telephone: +44 (0)207 429 4073 UK Advertising: Huson International Media, Cambridge House, Gogmore Lane, Chertsey, Surrey IGM 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 published 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 pho- tocopying, scanning an recording, in whole or in part without prior written permission from the Publishers. Such written permission must also be obtained before any part of this publication is stored in a retrieval system of any nature. Patent protection may exist in respect of circuits, devices, compo- nents etc. described in this magazine. The Publisher does not accept responsibility for failing to identi- fy such patents) 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 activ- ities. 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 Tel: 01635 40347 t nn I C'lr.j iii.'ritr.vLij v.lL-mi ro Lii Nuwtilvy Electronic* Ud r«o4ffn«ri HtiWiFY prwn MwtHirtttee&iiTCLDXLJl; WWW.XGAMESTATiaN.COM ClmScan 5 USB Scon Tool • Diagnose any car with EOBD • Based on the ELM327 1C • Supports all EOBD and OBD-II protocols ✓ ISO 1 5765-4 (CAN) S ISO 1 4230-4 (Keyword 2000) S IS09 141-2 SJI850VPW SJI850 PWM • 9600 or 38400 baud • Supported by more software than any other OBD interface • Inexpensive • Full Speed USB l.l • Automatic protocol detection • Package includes cables, software CD, and Quick Start Guide • Buy from your local UK distributors! 6 elektor electronics - 10/2006 At FTDI, you'll find more than just our acclaimed range of USB Interface Chips. Wn nlio hiivp n y.MriP rnnqp nrfnmpflunplv pnrpri USB mtprfifi modulpi nnri rahlpj Ideal ter impumcncing one-of* designs tfirough to full mats production funs. Our on-liim shup jcuepli imv " 1 ’ I L'v iretl'l cdrcl lie minim uni order rcitrit^ioni dp ply TTL*232tt USB to TLL Serial l/F Caht ■m 31 £11.10 w fer attaining Iv / 3.3* MCU in liSB ■ Fillip 5v ccirnpabfolf! I/O signal levsis 1 3v I/O verson also aM[ dillcrmr ■■ wri n PC. High tech white gloss endasur# &lue UED TX dnd fi>S traffic msficatni^ Gold Plated U5B and DB^ cciinectDis Suppihed m f«tsd p^ckagiftg wdih. driver CD tommunicaliDn rales from iou baud to 1M baud IDcm tan c length, f im version bvaiIiIPI’o at £ 14. SB | UC23 2R-10 Econorvy US 9 RS232 Cable b 10.50 ICKJIT VAMJSr * Mart hniAhp nicely s-zutpied white oiastrE: enebiurp * Sofrpii^d periled ia an enb-etitit hag ■ Wide range pr drivers tlawntDedable from FTDI web nie - Conmitriisisiicn taxes from. 1QD baud to 230k baud ■ 10cm cable length ( im anailabte to special rcaues I only) VcJoiipc L>->: :umI> ik m i M .1 Chip Slop FTDI ^ WAMW Tnees shown entludc a- Nip p^-g DL VAT Over 50 different USB Interface products in stoch at www.ftdichip.com/shop htm INFO & MARKET MAILBOX Better by miles Dear Elektor — referring to 'Antenna Height and Range' in your latest Summer Circuits edition, sometimes the statute mile and feet works better than the meter. If you use 4/3 earth radius and express the distance s in statute miles (1,609 meters) and the height H in feet, the formula reads s = V [2H] In the example, H = 15 meters ~ 50 feet, and the square root of 1 00 = 10. Hence the radio horizon is 1 6 km away. The difference between 16 and 13.8 km is due to the commonly used 4/3 earth profile. It is true that the distance to the radio horizon varies from these theoretical calculations, but the mile/feet formula is much easier to remember and to calculate. Have a nice summer and best regards from Knut. Knut I. Bakke (Denmark) As a rule we print metrical units in Elektor but Knut's remarks cer- tainly deserve a mention. Gharlieplexing update Dear Editor — I read with great interest your Elektor Summer Issue. Again full of interesting circuits. However, I found it disap- pointing that you had includ- ed circuit no. 046, 'Charlieplexing', with incom- plete information. That may easily fool someone to try it out with an inappropriate driver. In order to make such multi- plexing work, it is essential that each pin can be tri-stat- ed, i.e. all dark segments are then represented by hi-Z logic state. Otherwise the setup does not work. Maxim's application note correctly add resses that. Heikki Paananen (Finland) Thanks for this useful bit of infor- mation Heikki. Mini ATMega Board Dear Jan — I write to ques- tion the advisability, from a design perspective, of using JP2 to isolate the R2 resistor array from ground when the switches of SI are not required. With JP2 open, the resistors become interconnect- ed to all of the pins of PortA. The 8 pins of PortA can be configured independently as either a digital input or out- put or as an input to a 1 0-bit A/D converter. The result of interconnecting these PortA pins via the 10-k£2 resistor array elements will be signifi- cant 'contamination' of any analogue signal being meas- ured, particularly if its source impedance is not zero, such as from a bridge. If the adja- cent PortA pin is configured as an output and toggles between +5 volts and ground, an offset of about 25 mV would be imposed on an analogue signal with a source impedance of 100 ohms. Not 'a good look'. The broad design objective could be achieved by plac- ing JP2 on the 'hot' side of the SI switch array instead of the ground side of R2. All of the switches would need to be open when using the A/D converter and a scaling allowance would need to be made for the reduction in the analogue signal due to the voltage divider action of the grounded 10-k£2 resistor with the source impedance of the signal being measured. Keep up the good work. Ross McKenzie (Australia) Thanks for that Ross , our design- ers fully agree and the word is being passed on. Multi Colour LEDs Dear Editor — ref. July/August 2006 issue — project 052 'Multi Colour Flashing LED'. I can't find "i.c. engineering" for supply of LED chips. Can you advise? Many thanks. Adrian Wood (UK) We can. See www.fbice.com or order from Conrad Electronics , item code 1 50700. AA Cell Characteriser Dear Jan — several of my colleagues and myself have built this useful piece of equipment (April 2006, Ed.) and have found that not only does it check the quality of an AA cell but it also checks the amount of charge that dif- ferent chargers put into the cells. I get between 98% and 1 03% of the rated capacity from my cells but one col- league was only getting 70% or so and blamed his cells. A quick swap of cells and charging on my charger pro- duced in excess of 95%. The result is that this tester is a good way of checking that your charger is doing what it is required to do. It is point- less getting higher and high- er capacity cells if your charger is not fully charging them. Geoff Moore (UK) SC Analyser — some feedback Dear Sir — I just wanted to pass on my experience relat- ing to the Article 'SC Analyser 2005' in the April 2005 issue. My thanks to the author M.Waleczek and Mike Doty of M3 Electronix for their help. I love your magazine and have built three kits so far: - DRM Receiver - Electrosmog Detector - SC Analyser 2005 All the kits have worked flaw- lessly. Many thanks. I am a telecom engineer and also teach telecom and electronics related courses at a Engineering Technology poly- technical college in Toronto, Canada. One of my class projects was for the students to build the SC Analyser. They all Drive Drive Drive Drive Drive Drive Drive Drive Drive Pin 8 Pin 7 Pin 6 Pin 5 Pin 4 Pin 3 Pin 2 Pin 1 Pin 0 7 a a o a a 7 — y o a T3 olo d 7 o o o o o /V 1 7 o a "a ala a 7 — o a u u u 8 elektor electronics - 10/2006 Corrections & Updates Multi-Colour Flashing LED July/August 2006, p. 83, ref. 0604014-1 The manufacturer of the LED devices discussed in this article has a website at www.fbice.com. Conrad Electronics is a suggested retailer for the product. I Geiger Counter B July/August 2006, p. 130, ref. 040291-1 B In the circuit diagram, the junction of C 5 and the 220-V winding of TR1 should be connected to the circuit ground line. designed their own boards using an LPKF machine and I programmed their PICs for them. I had several problems using my PICSTART program- mer. Essentially when I read the hex file, if I just pro- grammed the chip it would not work. If I read the hex file, then reset the configura- tion bits as the article stated, then the PICSTART would set both code protect bits to zero and no programming was possible. My procedure is to erase the chip, then set the configuration bits and pro- gram them first. After this, I then import the hex file then only program the program memory. This works around the code protection bits being set. This is a great project for students learning electronics. Jeremy Clark (Canada) Thanks for the feedback Jeremy. All our recent PIC based projects come with configuration bit infor- mation as in many cases the default values supplied by Microchip will not work. In case of problems or older projects , do not hesitate to send an email and one of our in-house designers will help you. Free program for electronic design basics [Screendump 065075-1 1 U] Dear Editor — I have seen that you sometimes publish links to interesting electronic programs. I believe my pro- gram is in that category: Please check the webpage for a description of the pro- gram: www.miscel.dk/MiscEl/ miscel.html The program is a hobby of mine, I have been working on it for many years, when I have spare time. Some years ago I decided to share the program with others and put it on the internet, where everyone can get it for free. Henrik K. Jensen (Denmark) A useful and easy to use bit of software , Henrik , thanks for mak- ing it available to all of us! Piano playing aid Dear Sir — I am in the process of designing a sys- tem that allows a person to learn playing the piano much faster using a visual aid. I already own such a system for guitar playing ( www. fret- light. com ), but a version for the piano does not seem to exist yet. I have already found some sources that are very close to what I need, but I am still thinking about an LED bar with the electronics built in the case and that consumes almost no power or is pow- ered from an USB port. Some sources I came across during my research: www.members.aol.com/ decomidi/index english.htm and www.midiboutique.com showing the MDEC64 inter- face. I am thinking of a sys- tem with a LED bar that you can place on a piano. The circuit then shows what but- tons you have to press with your left and right hand. USB connectivity would be provid- ed and the possibility to wire up a footswitch. Johan Pyfferoen (Belgium) Looking forward to seeing that design Johan! I want to become famous, too Dear Editor — I have some circuits ready to share with Elektor. How can I do this? I can send you a .pdf, a .doc file or the original Protel99SE work. F. M. Gouveia (Portugal) This is one of the most frequently seen questions forwarded to us by email via the Contact form available on our website. The answer is invariably that our Author Guidelines are available for anyone to read at the SER- VICE page of our website (www.elektor-electronics.com). Publication of articles received from free-lance authors is subject to acceptance of the Board of Edi- tors & Designers who meet approximately every month to discuss article proposals. How many E-Weekly clients? Dear Jan — just out of curios- ity, how many people are subscribing to the E-Weekly newsletter you are sending out? I get mine every Friday and particularly enjoy the pieces you write on what's brewing at Elektor. Peter McCullough (UK) Thanks for enquiring Peter. Denis , our web editor tells me that cur- rently 7,200 email addresses are supplied with our free newsletter and that the number is growing at a rate of about 2 percent per month. We recently cleaned our E -Weekly client database addresses, removing duplicate, fake, unresponsive and ' bounc- ing ' email addresses. MailBox 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, 1000 Great West Road, Brentford TW8 9HH, England. 10/2006 - elektor electronics INFO & MARKET NEWS & NEW PRODUCTS Freescale's ColdF re R 32-bit controllers bring wireless connectivity to consumer and industrial applications Home and industrial automation applications increasingly demand control, connectivity and security. With the release of Media Access Controller (MAC) software that supports the IEEE(R) 802.15.4 protocol on the low- power 32-bit ColdFire(R) archi- tecture, Freescale Semiconductor is creating the broadest portfolio of 802. 1 5.4-enabled solutions in the marketplace. According to In-Stat, 802.15.4 chipset sales will surpass 150 million units in 2008. Typical applications include home and building automation, industrial monitoring and control, and wireless sensor networks. Designers have struggled to cre- ate reliable and secure wireless communication links simply and cost-effectively. Freescale now offers the necessary components for wireless design — microcon- troller (MCU), RF and software stack — in 8- and 32-bit chipsets. Freescale's ColdFire devices are designed to enable gateways for wireless connectivity, helping consumers easily keep an eye on their homes, secure their property from intruders and con- trol household appliances with the click of a mouse. The ColdFire family of controllers includes devices outfitted with Ethernet MAC/PHY, large amounts of memory and rigor- ous hardware encryption for security. With a broadband con- nection, Ethernet gateways based on the ColdFire architec- ture simply plug into the Ethernet port of current networks to power wireless connectivity. Freescale offers a wide spectrum of wireless networking solutions, ranging from simple point-to- point and star networks, to sophisticated networks including ZigBee mesh networks. ColdFire MCUs can be coupled with Freescale's MCI 3 191 or MCI 3201 2.4 GHz RF trans- ceivers and SMAC software for applications that do not require mesh networking or critical tim- ing restrictions. When coupled with MCI 3 192 or MCI 3202 2.4 GHz RF transceivers and fully compliant IEEE 802.15.4 PHY and MAC software, Cold- Fire MCUs provide 802.15.4 MAC functionality. Pricing and availability The 802.15.4 software is now available for the MCF5282, MCF5213 and MCF5223x processor families. This compli- mentary embedded software library and the required RF trans- ceivers are available on the Freescale Web site: www.freescale.com/ZigBee. The M52233DEMO demonstra- tion board is available now for the suggested resale price of $99 (USD). The M52235EVB evaluation board is available for the suggested resale price of $299 (USD). The 13192RFC- A00 and 1320XRFC RF daugh- ter cards are also available for suggested resale pricing of $149 (USD) and $79 (USD) respectively. Further information on the new products may be found at www.freescale.com/files/ pr/ cfzi gbee-ready.html . ( 067 1 92 - 4 ) www.freescale.com WirelessUSB™ LP evaluation kit showcases low-power 2.4-GHz wireless radio system-on-chip For design engineers wanting to replace the wires between 'human interface' peripherals such as keyboards, mice, joy- sticks and games consoles with wireless connections, Cypress Semiconductor's WirelessUSB LP device is a popular choice - it is easy to design in, it's cheap and it doesn't consume much power. For these applications, it has many advantages over industry standards such as Bluetooth and ZigBee. Now Cypress has launched an eval kit that allows designers to see for themselves how Wire- 10 elektor electronics - 10/2006 lessUSB performs in the real world, and to experiment with module-driven designs. The CY3630 Evaluation Kit (EVK) showcases the robust, low- power WirelessUSB LP radio, and includes a multiconfigura- tion microcontroller (MCU) socket, radio modules, LCD dis- plays, a large prototyping area, and MCU programming soft- ware. The kit also includes four firmware tutorials as well as a wireless range demo that help users to quickly build familiarity with the features and perform- ance of the radio. WirelessUSB LP offers an unpar- alleled feature set to enable superior interference immunity, low bill-of-materials (BOM) costs, higher data rate applications, and faster time-to-market for key- boards, mice, gaming devices, presenter tools, and remotes, as well as other simple, multi-point- to-point wireless applications. It operates between 1 .8 and 3.6 volts, using advanced power-sav- ing techniques to extend battery life in devices such as wireless mice. The device uses Cypress's patented frequency agile Direct Sequence Spread Spectrum (DSSS) technology to offer best- in-class interference immunity for a 2.4-GHz radio system. This combination of low power con- sumption, interference immunity and low cost make it ideal for wireless HID applications. The CY3630 WirelessUSB LP EVK includes all of the following items: • Microcontroller modules for driving the radio • An Emulation module for in- circuit debugging • WirelessUSB LP radio mod- ules for easy prototyping and evaluation • MiniProg Programmer for in- system serial programming of any Cypress Flash MCU • LCD Modules to display appli- cation data and provide user feedback • CD-ROM with complete kit documentation, tutorials, and sample firmware (067 1 29-6) www.cypress.com Handheld RF spectrum analyzer based on Palm handheld Thurlby Thandar Instruments has developed a handheld RF spec- trum analyzer designed to set a new price point - below € 1 200 (approx. £ 850). The analyzer is based around a Palm hand- held computer which provides the display, control, calculation, mass storage and external inter- face capabilities. The PSA1301T has a high-resolu- tion (480 x 320 pixel) backlit color TFT display capable of dis- playing 65,000 colors but still has a relatively low power con- sumption providing more than 4 hours continuous operation from a single charge. For continuous bench top operation it can be operated from its AC adaptor which also recharges the batter- ies in less than 4 hours. Frequency range is 150 kHz to 1 .3 GHz with selectable resolu- tion bandwidth down to 1 5 kHz. Sweep modes include continu- ous, single, peak hold and aver- age (up to 256 sweeps). Sweep parameters can be set in terms of centre plus span or start plus stop to 1 kHz resolution. A zero span mode with AM or FM demodulation is also provided. Dual markers are incorporated with simultaneous readout of absolute amplitude and fre- quency plus difference values. Markers can be scrolled manu- ally, or set to automatically find and track peaks. A reference trace can be dis- played simultaneously with the live trace, with the two traces clearly differentiated by color. The reference trace is automati- cally shifted and scaled to match the current sweep parameters when they are changed. Any number of waveforms and settings can be stored to perma- nent memory using an SD or MMC flash memory card. Data can be saved under default or user-entered file names as pre- ferred. bitmap images of the whole screen can also be stored for viewing or printing. The PSA 1 301 T can store three types of data: traces, set-ups and screens. Trace data is stored as tables of amplitude against fre- quency in a comma delimited format, which can be recalled to the screen as a reference trace. Screens are saved as complete bit-map images of everything vis- ible at the time (traces, graticule, markers and all annotation). These can then be viewed on the Palm itself or transferred to a PC. PSA 1 301 T data files are stored on removable flash memory cards. A USB linked card reader is supplied which allows files to be transferred to or from a PC using simple drag and drop. Where a wireless connection is available (Bluetooth or WiFi), files may be transferred using email attachments or via a wire- less communications application. PSA1301T trace files have a standard comma separated value (.csv) format which can be imported into other applications such as Excel or MathCad. Con- trol of the analyzer is provided by soft keys created on the touch screen. These are large enough to be finger-operated, eliminat- ing the need for a stylus. Alter- natively, all functions can be operated using the hard keys of the handheld unit. To extend battery life the ana- lyzer can also be set to turn off automatically after a user-defined delay from the last key press. (067 1 29-7) www.tti-test.com 10/2006 - elektor electronics 11 INFO & MARKET NEWS & NEW PRODUCTS FTDI's new Vinculum chip ties USB to other technologies At the Embedded Systems Con- ference in Taipei, Taiwan, Future Technology Devices International Ltd. (FTDI) announced the release of their Vinculum family of embedded USB Host Con- troller devices. The Vinculum USB Host Con- troller ICs not only handle the USB Host Interface, and data transfer functions but owing to the inbuilt 8/32 bit MCU and embedded Flash memory, Vincu- lum encapsulates the USB device classes as well. When interfacing to mass storage devices such as USB Flash drives, Vinculum also transparently handles the FAT File structure communicating via UART, SPI or parallel FIFO inter- faces via a simple to implement command set. Target pricing is $5.00 each @ 10k pieces. The initial product member of the family is the VNC1L device which features two USB Ports which can be individually config- ured by firmware as Host or Slave ports. Key VNC1 L features include: • 8/32 bit V-MCU Core • Dual DMA controllers for hardware acceleration • 64k Embedded Flash Pro- gram Memory • 4k internal Data SRAM • 2 x USB 2.0 Slow / Full speed Host / Slave Ports • UART, SPI and Parallel FIFO interfaces • PS2 legacy Keyboard and Mouse Interfaces • Up to 28 GPIO pins depend- ing on configuration • 3.3V operation with 5V safe inputs • Low power operation (25mA running / 2mA standby ) • Inbuilt FTDI firmware easily updated in the field • LQFP-48 ROHS compliant package • Multi-processor configuration capable FTDI's CEO, Fred Dart said "Vin- culum brings cost effective USB Host capability to products that previously did not have the hard- ware resources available. We anticipate that these devices will be especially popular for adding USB Flash Drive connectivity to a wide range of consumer and industrial products. As Vinculum comes complete with FTDI's in- house developed firmware, there are no USB software stacks to license, indeed, no knowledge of USB is required to use these devices." 'Vinculum' derived from the Latin word 'vincere' means "an entity that binds/ties objects or expres- sions together' — in this case, var- ious USB and other technologies. Complete details for the Vincu- lum VNC1L are located at www.vinculum.com. FTDI's full product line can be found on the main web site at: www.ftdichip.com. (067 1 93-4) Class-D audio reference design International Rectifier, recently introduced the IRAUDAMP3 Class-D audio reference design. The new, compact reference design features the IRS20124S high-voltage analog 1C and IRF6645 DirectFET® power MOSFETs to complete a six-chan- nel 1 20W half-bridge Class D audio power amplifier with no heatsink. The IRS20124S high-voltage 1C incorporated in this reference design features an internal selec- table dead-time generation cir- cuit and is immune to noise and supply voltage fluctuations to help achieve a total harmonic distortion (THD) of 0.01% at 60W, 4 £2 and 94% efficiency at 1 20 W, 4 £1 single channel. Additionally, the 1C has built-in bi-directional current sensing and an integrated shutdown function to protect the output MOSFETs when an over-current condition occurs such as a short- circuited speaker wire. The IRAUDAMP3, which has a footprint of 4.5 square inches for each two channel control and switch function, also utilizes IRF6645 DirectFET power MOS- FETs. The innovative DirectFET packaging technology enhances performance in Class-D audio amplifier circuits by reducing lead inductance to improve switching performance and reduce EMI noise. The higher thermal efficiency enables 120 W operation into 4 ohms, eliminating the need for a heatsink to shrink circuit size, provide greater layout flexibility and reduce overall amplifier sys- tem cost. www.irf.com (067 1 93-2) 12 elektor electronics - 10/2006 Learn A RM7 A complete self-study course in using Philips ARM? microcontrollers i] Keil uVI5ION3 IDE, C/C++ t6K compiler and simulator SI Full Simulation of LPC2000 with peripherals, interrupts Si uLINK JTAG interface ' H - H Fully assembled LPCzixx development board y Insider's Guide complete ARM7 self-study course with CD-ROM based tutorial h Bit. tNC INSiDI® % GUIDE TO Tht Pumps ARM? Baud M icjtacom tcoue is IE itf I.i. l — ! I LPC2129 LPC2103 LPC2140 LPC2130 www.Viitex.co.uk/arm "PHILIPS Dfvf | iJfAilhl k PicoScope 3000 Series PC Oscilloscopes The PccoS c opt 3000 series Dsdtloscdpcs are the latest tiff er mgs from the market lender in PC tiSCihti StapCS combining high band widths with large buffer mempries. Using the latest advances In electronics, the cscillcscapcs connect to the USB port of any modern PC, mailing full use af the PCs processing capabilities, large screens -and familiar graphical u a r i interfaces* * High perfarmanen: 1 QQ[j * aMipfinn rate & 20aMHz bandwidth * 1M© buffer memory - High spEEtf USB 2.0 interface * Advanced display & trigger modes * Compact & portable - Supplied with PicoScope £ PicaLog software Tel: 01480 396395 www. p icotech . com/scope362 HT "V fit four CtaHnHq HHk WH-VM ISIISl ■* v-o.1 J nut, « t -C+t, !*• 0' P £!bK*4| aflf *t«i iwai UXHUl'i 'ilHIMX ■ i ■ [j } B ; 1 1 ■A i 1 ■ L 1 i i V 1 1 r 1 r d < j k f K 5 -G-rph ubi I ■h* I I *mm r . ; Special editions Several suppliers have supplied us with special editions of their programs that have a wider range of functions than their standard demo programs available from their websites. SpiceAge & Spicycle, made by the British firm Those Engineers, are on the DVD as special releases with a limited component library. Apart from that they are fully functional and can be used without a time limit (Spicycle Level 1). Target 3001! from Ing. Buro Friedrich is on the DVD as a special light 7 version with a value of 49 euros (approx. £ 34). This can cope with up to 400 pins/ pads and 2 track layers. You won't be able to use the extra component library from Target, but that doesn't matter too much since the included library contains about 1,000 standard components. We should remind you that all programs are strictly for non-commercial use only. Professional electronics designers have to manage their time very efficiently. Nowadays it is hardly worthwhile to design a circuit on paper and then build one or more prototypes to check that the design functions correctly. The ubiquitous computer (usually a PC) has been pro- moted a long time ago from a simple calculating tool to an intelligent assistant for circuit design, thanks to a number of clever programs. We already know of PCB CAD programs that simplify the design of boards. They have extensive libraries with package details, place the components onto the board automatically and have autorouters that find the best track layout on the board. Human insight and supervision is of course still a neces- sity for a successful design, but it is a huge improve- ment over the manual design of PCB artwork. Engineers also rely more and more on the computer for the design of circuits. The availability of good simulation programs have made it possible to see a realistic simulation of a circuit, once its schematic has been entered. When the circuit in the simulation program functions as expected, it should also do so in practice for 95 to 1 00% of the time. It is then usually sufficient to make a single prototype for a final test. With thanks to... We would like to thank all suppliers for their help in making this DVD, in particu- lar Linear Technology for allowing us to include LTSpice/SwitcherCAD, and Those Engineers and Ing. Buro Friedrich for their special editions. These programs are also very useful for stu- dents and hobbyists. When you have a brainwave you can quickly input a circuit and check that it behaves as expected, all without touching a soldering iron, compo- nents or measuring instruments. Furthermore, you will also gain a better insight in the workings of components and circuits when you create these simulations. J- M % 3> -J m . *■ 1 i i ■§s i sfSK i rrrr^ “T.i/TJ. ... , ] L J** 1 1 I 1 yT — i. ■ ■kLi lf;l W j-ri ;*■ -»T. . E H S»lr l 1 ] 1 filfill™ up |l Uhx miiPiili mi.! frl" MigiV.il >!:■’. i£;ii|ilk .iIiiim a* J How it all started The simulation of electronic circuits on com- puters finds its roots in the creation of SPICE, a program that was developed at Berkeley University. In this issue you'll find an accom- panying article (The PC as Breadboard) that tells you more about the history and work- ings of SPICE. Virtually all current programs are based on this. SPICE can be used to sim- ulate linear and non-linear electronic compo- nents. Following this, the Georgia Tech Research Institute developed XSPICE, which is used to create model libraries with exten- sive component definitions. Both SPICE and XSPICE are completely open source and are therefore ideally suited as a basis for simulation pro- grams. Other well-known developments are Cider (digital simulation) and Ngspice (mixed-mode simulation). Most of the modern simulation programs work under Windows because this is the most common platform these days. The biggest improvement of these programs has been in the user-friendliness of the interface. In older programs this could be a bit of a nightmare (draw a cir- cuit on paper, number all the nodes, search for the cor- rect models and create netlists, then use a different pro- gram module to input what should be calculated at each node, which, if you were lucky, could be shown graphi- cally). These days you can use the mouse with most pro- grams to create a circuit, and a few well-designed menus help you input the simulation settings. This is followed by the display of several clear graphs. The better programs 22 elektor electronics - 10/2006 also have extensive component libraries, which contain the properties of most semiconductors made by the larger manufacturers. There is no longer a need to study for days just to find out how a simulation program works. After a few hours you should be able to use it fairly well. Most programs are so-called mixed-mode simulators, which can be used to simulate analogue, digital and mixed circuits. Types of programs There are several types of simulation program available, and you'll find some of each on the DVD. There are complete design suites that take care of the schematic input, simulation and track layout, such as Mul- tiSim. With these packages you don't need any other software. These programs are usually fairly expensive because of their complexity, but the advantage is that there is a close integration of the various sec- tions, which are controlled sequentially from one program and support is obtained from a single source. Then there are pure simulation programs. Some have a full graphical input and output, such as Micro-Cap, others don't have the graphical input facility but instead make use of a separate schematic capture program (e.g. AIM-Spice). Some programs have been designed in such a way that they can be inte- grated with an existing PCB program (e.g. Easy-Spice in Easy-PC). Lastly, there are inter- face programs, such as iSim, which translate the output of a schematic capture program into a form that can be used by a SPICE pro- gram. hPt ^ «p!i Ttfiri The DVD Now it's your turn! We have done our best to include the most recent versions of the programs on our DVD, but suppliers continually strive to improve their programs. If you are interested in a specific program it is always advisable to look on the supplier's website to see if a more recent version is available. We have tried to include as many simulation programs on the DVD as possible. We obtained permission from various suppliers to distribute about 30 programs on our DVD. The programs on the DVD have been stored in several different folders. The largest num- ber can be found in the Windows folder. Almost all these programs can run under Windows 98/ME/XP. The majority of the programs have an English user interface and a few offer a choice of languages. The Linux folder contains a few interesting simulation programs for Linux, as the name suggests. A few programs from the Windows folder are also found here because they have been made available as a Linux version as well. A separate open-source Win- dows folder contains programs that can be freely used and distributed. The final folder called Extra contains a few special pro- grams that deviate from normal simulation programs, such as a program to simulate magnetic fields and a program to help calculate component values in filters and timers. We'll now give you a short description of the major pro- grams on the DVD, along with any restrictions of the sup- plied version and the amount of space each program takes up on your hard drive. We hope you enjoy trying out the various programs! We have included a list of other interesting products that haven't made it to the DVD for one reason or other (e.g. no permission was given to distribute the soft- ware). It's certainly worthwhile to have a look at these as well. The larger suppliers usually have a national distributor or an organisation that can give you further information about their products, which is more convenient since you can talk to them in your own language. They can also give you details of pricing and support for their software. Finally, we thought we should include the well-known disclaimer: we have tested all Windows programs on several PCs, but we can't guarantee that they will run faultlessly on your system. Should you have problems with the installation or run- ning of programs, please contact the relevant supplier directly. We are unlikely to be able to help you out in these matters! Now it's your turn to try out the collection of software on this DVD and see what potential they have. Simulation is the future, that much is certain. And this DVD is a perfect introduction to this subject. Brought to you free of charge by Elektor Electronics. Wnj I™- U* □ £lLl M B I IH P. £ * H W *4 * •- S* m + + ^ e * « : L ■=■ Lr W &■* JifclUL •I ■ :■ 1 ■ i , . fr MP\ TTIETTFT wj *-w *+* s ftT* £E| -Hflf 'll A Ml ft m + t 10/2006 - elektor electronics 23 INFO & MARKET SIMULATION SSpice 1.22 (14 MB) This program is a graphical shell built around a tradi- tional Spice emulation engine. A schematic editor is used to enter the electronic design, which can then be simu- lated using Spice version 3f4/3f5. The operation is quite simple. The program is not very comprehensive, but can still simulate most types of circuit. The size of the schematic is restricted in the demo version and the numerical output of several types of analysis is not possible. Another restriction is that schematics with logic gates cannot be stored and a demo text is added to all other schematics. AIM-Spice 4.3 (10 MB) This program doesn't have a schematic input, but is just a SPICE-simulator. The software 'suite' consists of two pro- grams: AIM-Spice, with a text editor for editing the Spice netlist and simulation options, and AIM-Postprocessor, which is used to display stored data files graphically. Once you've become used to the textual input for a schematic the program will be easier to use. A large number of simulation parameters can be adjusted. The student version is limited to 150 nodes and a maxi- mum of 30 transistors per circuit. J - A ■ 1 j . .. - •*» ..1 . T ■ ■■■ ■ ■ o. 1 t L 1 A i l ■ 1 "j r "T "T J i HJ 1 j * i*t-i unci Kraut ivm a - iris; - a DDdr D 4 Prm \ ■:£-* t iPrita-J L E smzn T I ’J OirilLi'.i ii|ii || Llhc.i»mnji mil ipll Ir^qV. HI List i . UA;«|ilk .iliiiii D.il.i'ii 1 J B2Spice V5.1.6 (131 MB) This program is of particular interest to Eagle users because Eagle schematics can be directly imported and simulated. You can also draw the schematic with B2Spice itself. The user interface of this program is clear and intu- itive. Simulating is very easy. Virtual instruments are used to place probes onto the schematic in real-time. The trial version can be used without restrictions for 45 days. Boardmaker 3 (134 MB) Boardmaker 3 is a complete CAD package. You can draw schematics, simulate and create print layouts. PCB layouts can even be shown in 3D. The operation of the program is quite complex, mainly due to the many functions it can perform. There are tutori- als in PDF format (they're stored in the same folder where the program was installed, but strangely enough there are no shortcuts to them in the start menu). It is strongly recommended that you go through these before you start using the program. The demo version can't print or store schematics, nor can it output Gerber files. CIRSIM2006 (5 MB) CIRSIM is a fairly straightforward program that is only suitable for simulations with continuous input signals. The description of the schematic can only be entered using SPICE-code, i.e. there is no graphical input. Because the program has only a few functions, its operation is self-evi- dent. Registration of the program is just £1 0. The demo version of the program is severely restricted, with only six nodes maximum. DesignWorks Professional 4 (38 MB) With DesignWorks Professional you can simulate digital circuits in a simple manner. The design can be input as either a schematic or using VHDL. The operation has an intuitive and logical feel to it. However, if you get stuck you can refer to an excellent manual in PDF format. DesignWorks can also be used to create analogue schematics, but these can't be simulated. The demo version has full functionality for 30 days. Easy-Spice (& Easy-PC) Easy-Spice is an enhancement for the print layout pro- gram Easy-PC (both are on the DVD). You should install Easy-PC first, then Easy-Spice. Easy-PC can be used to draw electronic schematics and PCBs, set simulation parameters and start a simulation. The program then creates a netlist and starts Easy-Spice. Easy-Spice automatically opens the netlist and uses it for the simulation. The folder ...\Easy-PC Demo\Examples\SPICE contains a few examples. Both analogue and digital circuits can be simulated. The demo version of Easy-PC can't store files or create CAM outputs. There are no known restrictions in the demo version of Easy-Spice. Both programs require a password to function, which is kp69ny31 for Easy-PC and wa32pk65 for Easy-Spice. eSketch (5 MB) This (small) program has a polished look and is very easy to use. You can draw passive analogue schematics 24 elektor electronics - 10/2006 with it and simulate them. Unfortunately you can't use it to enter logic gates, transistors, diodes or other active elements. You can try out the free version for 1 5 days without restrictions. LTSpice /S wit cherCAD III (77 MB) The program SwitcherCAD III supplied by Linear Technol- ogy can be used to simulate (almost) every switchmode regulator made by LT. The simulation even includes the power-up cycle. Several useful example circuits are included and you can of course input your own circuit as well. The program may not have a polished look, but its functionality leaves nothing to be desired. LTSpice/SwitcherCAD III is completely free of charge. Micro-Cap 8 (22 MB) Micro-Cap is a well-designed simulation program with a schematic capture and a well-sized standard component library. The abbreviations used in the simulation setup are a little bit confusing at the beginning, but once you're used to them they are very easy to work with. The evaluation version of Micro-Cap is limited to 50 com- ponents and 100 equations (nodes, inductors and signal sources). The simulation speed is slower and the number of optimisations, filter designs and 3D plots has been reduced. Multisim 9 (191 MB) Multisim is a complete design suite that comprises schematic capture, simulations and PCB design (Ulti- board). It's one of the most comprehensive packages that we've come across. Smart virtual instruments can be placed onto the schematic, which then show the simu- lated signals. The component library of Multisim is very extensive. The program is now also capable of exchang- ing measurement and simulation data with LabView. The freeware version requires an Internet connection to simulate a circuit. After 45 days the simulation and autorouting functions stop working. Furthermore, the designs are limited to 50 components, 750 pins and 2 layers. OrCAD 1 0.5 (707 MB) This is another comprehensive design suite! OrCAD cre- ates a number of shortcuts for the various programs in the package. The main program is Capture CIS. This pro- gram acts as a type of manager for all the files that make up a design. There is also a tutorial (OrCAD- directory\OrCAD_l 0.5_Demo\tools\capture\tutorial\C APTUTOR.EXE). The simulation section (PSpice A/D) isn't controlled directly by Capture CIS and so you need to point it to your project manually. The many functions of the package make it somewhat difficult to use, so a bit of training is to be expected before you can fully use it. There is no time limit in the demo version, but there are restrictions on the size of designs. ProfiLab Expert 4 (17 MB) ProfiLab Expert looks similar to Labview, but is a lot sim- pler. Various dials, displays and other functional blocks can be added to a design via a clear, well-designed a □ s M\* S. X Y t ^ m. 2 P Si ^ ® ^ T ! in (il 1 r *fl(j Hunt muon i MGQU jt *1 1 i i n i i id (1 1 1 j | i f \ j i i j 1 . i bfk i nr nii i 1 1 1 1 1 ! 1 ,i| l 1 1 1 1 \ 1!, 1 1 1 '1 ■ 1 1 n a i uui It, ■ 1 1 1 ] 1 j I 1 L In \\ a ■ Ijlil \A. r l ' T 1 r . . i I -mm \ ¥ P 1 1 1 1 1 1 i il 11 i j 1 1 V 1 'J 1 1 11 V * V v H j V V V ui? a ns Htf. f* Jil n?K njo Tirrn Ci) screen. The simulation then shows the results for your design. The demo version can be used with a maximum of 10 components. You can't store or compile your designs and the simulation time is limited to 30 seconds. Proteus 6 (11 2 MB) Proteus 6 consists of 2 programs: ISIS 6 and ARES 6. ISIS is used to draw schematics and simulate them; ARES is used to design the PCB layout. It is very easy to simulate a circuit with ISIS (play button at the bottom-left). The help files included are very clear, as is the comprehensive user interface. What makes Proteus special is that mixed- mode simulations can include microprocessors, which have their code executed during the simulation. The demo version does not allow printouts or saving of files. Neither can you input your own microcontroller designs, but you can modify the examples included. SIMetrix 5.2 (34 MB) SIMetrix can be used to input and simulate analogue and digital circuits. Despite the separate program windows the package is easy to use. The various settings are 10/2006 - elektor electronics 25 INFO & MARKET SIMULATION If you want to use the program for switchmode supplies you should choose the SIMetrix/SIMPLIS option during installation. SIMPLIS is between 10 and 50 times faster in simulating these, compared to the extensive Spice simula- tion of SIMetrix. SIMWinXP 1.10(261 MB) SIMWinXP is the little brother of the EDWinXP design suite. It is a standalone program for drawing the circuits that can then be simulated using the included mixed- mode or EDSpice simulator. With EDSpice you can also simulate circuits that have been created in Spice. SIMWinXP can cope with both analogue as well as digi- tal designs. To install SIMWinXP you should run Setup.exe from the SIMWinXP folder. The evaluation version is fully functional, but works for only 30 days. quickly and intuitively found. When installing the program you should choose SIMetrix Intro. SIMetrix uses five characters for extensions and so avoids any potential problems with other programs. The demo version is only limited to the number of compo- nents that can be used. Suppliers 7 websites 5 Spice Analysis Software www.5spice.com Abacom www.abacom-online.de AIM-Software www.aimspice.com AMS www.advancedmsinc.com Beige Bag Software www. beigebag.com Benelux: www.franklin-industries.com Bells-H ill www. be 1 1 s-h i 1 1 . f reese rve .co.uk Cadence www.cadence.com/ oread Cadmigos www.cadmigos.com Capilano Computing www.capilano.com Catena www.catena.uk.com Dolphin www.dolphin.fr Electronics Workbench www.electronicsworkbench.com Erwin Rossler www.win-elektronik.de Inca Systems www.incasystems.fi Ing-Buro Friedrich www.ibfriedrich.com Island Logix www.islandlogix.com Labcenter Electronics www.labcenter.co.uk Linear Technology www.linear.com Number One Systems www.numberone.com Penzar Development http:/ / penzar.com Powersim www. powersim tech .com Schematica Software www.schematica.com Sonnet www.sonnetusa.com Spectrum Software www. spectru m-soft. com Those Engineers Ltd www.spiceage.com Tsien www.tsien.info Visionix www.visionics.a.se Zuken www.zuken.com Smash 5.7.0 (424 MB) Smash is a powerful mixed-mode simulation program without a schematic capture input. The program has some unusual features, such as estimating the power con- sumption of digital circuits and a mixed-mode facility of SPICE and VHDL-AMS. The required netlists can be loaded as .cir, .nsx or .sp files. The program can work with several other popular pro- grams from e.g. Matlab, Keil and National Instruments. We were pleasantly surprised by the large number of PDF documents that were included, with details of various design problems and simulation methods. The evaluation version has a limit of 25 analogue nodes. SpiceAge & Spicyde (49 MB) Before you can install SpiceAge (simulation) and Spicycle (schematic capture) you should copy the complete SpiceAge folder from the DVD to the C:\ drive, including the folder structure. Spicycle is used to draw schematics and PCB layouts. You can start a simulation from Spicycle that is then run in SpiceAge. From SpiceAge you can set many more parameters and can also start different simulations. The user interface is clear and well designed. Most of the control icons can be reached via the menu bar. The demo versions have been specially provided for Elek- tor Electronics and have a limited component library, but are otherwise fully functional and don't have a time limit. Spice Creator Pro V5.12 (39 MB) & Visual Spice (39 MB) These two programs are like peas in a pod. Spice Creator and Visual Spice are used to create and simulate analogue and digital circuits. There is a useful help-browser, which makes it easy to find instructions on using the program. The main program screen overflows with icons, but this can fortunately be reduced. The trial versions have quite a number of restrictions: there is no undo, save, export, print, copy/paste and simulation of edited circuits. Target 3001! VI 2 (61 MB) Target 3001 ! is a CAD program with various extra fea- tures. In the first instance it is a program designed for 26 elektor electronics - 10/2006 inputting schematics and creating print layouts. The design can be simulated and it can also check for EMC issues. It also offers the facility for the design of front panels. To use all of the features to their full potential you will have to read the manual first. Although it is possible to use the program straight from the box, you'll need a bit of study and practice before you can grasp the finer points of this program. A special version has been made available to Elektor Electronics, which offers more than the standard demo version: Target 3001 ! VI 2 light' (400 pins/ pads, 2 track layers, costing 49 Euro), which can't access the component library on the Target server. TopSPICE 7.09g (23 MB) TopSPICE can be used to open both schematic diagrams as well as Spice netlists. Simulations are fast and easy. It is self-evident how to use the program, but if you should get stuck you'll find many 'help' and 'getting started' doc- uments to help you out. There are several limits imposed in the demo version, such as on the size of the schematic, the number of nodes, transistors, top-level components, data points per plot and a maximum data memory of 1 MB. Win-Elektronik 3.1 (1 MB) This simple (German language) program is perfect for checking how an analogue network functions. It is mainly intended for students and schools. It has a limited set of features. The demo version has a maximum of 8 components and 1 opamp. Extras -iSim (14 MB) (& CADStar Express 8 & PSpice A/D 10.5) iSim is an interface between schematics drawn with CADStar and the SPICE simulations in PSpice A/D. You can run iSim from within CADStar Express to start the simulations. The results are then shown by PSpice A/D. This plug-in has been well designed and leaves nothing to be desired. The demo version is limited for use with up to 50 components. PSIM (22 MB) PSIM is intended mainly for simulating power circuits and motor drivers. It consists of two programs: PSIM and SimView. PSIM is used to draw the schematic and to start a simulation. SimView then automatically takes over and shows the simulation graphs. The operation of the programs doesn't really require an explanation. The examples that come with the programs are very useful as they give you a quick insight how the programs work and what they're capable of. Sonnet Lite 10.51 (91 MB) The Sonnet software is suitable for (nearly) all calcula- tions and simulations that are concerned with RF electro- magnetic interference. A few examples of the capabilities of the program are the analysis of PCB track crosstalk, microstrips and coupled transmission lines. The free Lite version has a few restrictions compared with the full ver- sion, but you can still evaluate the latter for 30 days. You can find more information on the supplier's website. ( 060206 - 1 ) Interesting links Altium Designer www.altium.com/Products/AltiumDesigner/ Tina Pro 6 www.designwareinc.com/index.shtml NGSpice http://ngspice.sourceforge.net/ relapp.html AnaSoft SuperSpice www.anasoft.co.uk/ APLAC www.aplac.hut.fi/ aplac/ AKNM Circuit Magic www.circuit-magic.com/ Intusoft ICAP/4 www.intusoft.com/demos.htm PC-ECAP www.cdquickcache.com/ pcecap.htm Digital Simulator www.mit.edu/ people/ara/ ds.html Spice-i- http://spicep.sourceforge.net/ WinEcad www.winecad.com/winecad.htm DxAnalog www.mentor.com/ products/ pcb/expedition/ analysis_verification/dx_analog/index.cfm NGSpice http://ngspice.sourceforge.net/ + GSpiceUI www.geda.seul.org/tools/gspiceui/index.html PSpice 3f4 www.ee.washington.edu/circuit_archive/software/ spice3f4.tar.gz Spice3f4 (Mac) www.kivadesigngroupe.com/Kiva%20Professional/ professionalpage.htm MacSpice 3f5 (Mac) http://newton.ex.ac.uk/teaching/CDHW/MacSpice Pulsonix www.pulsonix.com/index.asp CSiEDA www.csieda.com/ Crocodile Technology 6.01 www.crocodile-clips.com/crocodile/technology/ index601 .jsp Qucs http://qucs.sourceforge.net/ news.html Simplorer Student Version www.ansoft.com/about/ academics/ simplorer_sv/ index, cfm 10/2006 - elektor electronics 27 TECHNOLOGY MEDICAL Haider Karomi A quick and precise diagnosis of a serious medical condition is vital — if a doctor can per- form this remotely it saves both time and money. The Star Trek gadget may not yet be reality but remote patient monitoring is and brings with it some fears of data protection. It was back in the late 1 940s when NASA were planning to put an astronaut into orbit that they began to experi- ment with primates and developed the first system for remotely monitoring vital signs during launch and re-entry into the atmosphere (but rarely, alas, after impact). The term 'Telemedicine' was coined to describe these early monitoring systems which were further refined and went on to provide telemetry data when astronauts finally ven- tured into space and later from the moon. Now, half a century later the installation of wide band- width telecommunications channels in the home and Telemedicine diagram (Source: Paxiva Service / Personal Healthcare Telemedicine) availability of convenient, precision sensors makes it pos- sible for doctors to monitor the health of their patients over great distances. A decision on the patient's course of treatment can be made by experts almost instanta- neously; specialist doctors are able to determine if anom- alies in ECG (Electro Cardiogram) readings taken at home indicate that a patient requires emergency treat- ment or just a change in their medication. Telemedicine offers the possibility of not just diagnosis but also remote therapy and consultation between doctors. 'TeleHome care' is one branch of telemedicine and uses 28 elektor electronics - 10/2006 the Internet to pass physiological readings (Pulse rate, Blood pressure etc.) taken in the patients home to a doc- tor using video conferencing facilities. The table shows how 'TeleHome care' can impact on different aspects of patient care and administration. For and against The 'TeleHome care' system offers a drastically reduced diagnosis response time which in some cases (e.g. heart failure) is vital to the outcome of an episode and can be a life saver. The system offers better efficiency and cost- effectiveness by allowing doctors and health care person- nel to care for more patients in the community without the need for time-consuming routine home visits which can prove costly especially in rural areas. In a society where the numbers of chronically sick and care-dependant are growing the distinction between sickness and health is becoming ever more blurred. Improvements to the quality of life of each individual must be the main goal of health care providers but at the same time the dramatic increase in costs mean that it is vital to be more efficient and tar- get support more precisely so that available funds are not wasted [1]. The concept of 'TeleHome care' also raises questions regarding data protection and the possible misuse of per- sonal information which previously had only passed between doctor and patient but modern encryption tech- niques used for data transfer offer a high degree of secu- rity and provide good protection against third-party eavesdropping. The impact of Tele Home Care 'Clinical' Availability in emergencies. Remote medical advice. Remote consultations. Remote diagnosis. Remote treatment. Monitoring of patient parameters (e.g. ECG). Care & Information Health support Disease prevention. Self help. Training. Administration Electronic patient management. Patient records. Coordination. Coronary care sets the pace Coronary heart disease is the biggest killer in the UK and most European countries, many risk factors have been identified as contributing to the development of the dis- ease. 'TeleHome care' is particularly well suited to iden- tify and manage lifestyle induced risks and remotely supervise the rehabilitation process while enabling the The pros and cons of Tele Home Care Patient monitoring • Improvement in the quality and quantity of patient monitor- ing data. • More patients can be monitored with fewer resources. • Automated diagnostic tools can be used to interpret patient data. Therapy management • Improvement of doctor-patient communication. • Faster response time for therapy evaluation. • Support for patient self-treatment. Remote caring • Fewer hospital/surgery visits. • Simplification of patient information collection. • Patients generally find the autonomy empowering. • Reduction of short and long term complications. Tele Home Care requires organisational changes • The new service requires modifications to existing clinical routine and protocols. • Increased workload for medical personnel in the first stage of implementation. • More patients and Data: Integration of specialised tools/software to analyse data. • Disadvantage: The patient is not in a controlled environ- ment. Source: Telemedizinfiihrer Deutschland 2004 (www.telemedizinfuehrer.de ) 10/2006 - elektor electronics 29 TECHNOLOGY MEDICAL patient to retain their independence and mobility. In recent years several studies have been conducted on heart patients to asses the feasibility and effectiveness of automatic (remote) monitoring of the progress of their condition (telecardiology) and corrective therapy using communication channels provided by modern telecommu- nications. The conclusions broadly indicate that remote patient monitoring is technically possible but relies on close patient cooperation and agreement. Remote moni- toring has the potential to offer the patient a better under- standing of their condition, providing them with more precise information on the progress of their disease and the remedial effects of medication and therapy which often results in a higher level of patient satisfaction. Standardisation Many competing systems are currently being trialled by health authorities around the world (even the term 'telemedicine' is undergoing a 21 st Century makeover and has been called 'e-health'). Personal Healthcare Telemedicine is currently working closely with clinics and health care providers to establish their Paxiva system for the remote monitoring and care of heart patients [2]. This system gives the patient the possibility of taking an ECG (Electro Cardiogram) of their heart at home either on a regular basis or as required and sending the readings over a phone line to the monitoring centre where a diag- nosis can be made and appropriate remedial treatment recommended without necessarily troubling their own doctor. The patients know that the Paxiva monitoring cen- tre is continually manned so this tends to remove the ini- tial reluctance to contact a doctor or call out a para- medic when the first symptoms of a change in their condi- tion occur. Precious minutes can be saved if it turns out that the condition requires emergency treatment. ( 050341 - 1 ) Weblinks [1] Canadian report 'Office of Health and the Information Highway' http:/ / dsp-psd.pwgsc.gc.ca/ Collection/ H21-168-1998E.pdf [2] System Paxiva: www.medical.philips.com/ main/ news/assets/docs/ medica- mundi/mm_vol46_no2/ mampuya.pdf Figure A. Heart function support system INCOR from the company Berlin Heart AG. Blood flow through the implanted pump is managed by the control unit, (illustration: Berlin Heart AG) Telemedicine technology an example The author developed the telematik module in the final year of his degree. The unit can be used by a heart patient fit- ted with a heart support device either in or on their body and allows remote diagnosis/monitoring over the Internet. The unit is currently undergoing further development by the company Berlin Heart AG and should be ready for the mar- ket next year. The microprocessor controlled unit reads data from the heart support system (Figure A). The information including flow rate and pressure difference across the implanted pump together with data from any anomalous heart 'event' are then sent daily using either the analogue modem, Ethernet, RS232, Bluetooth or GPRS (General Packet Radio Service for mobile phone use) port shown in Figure B. A PC inter- face is provided to enable the unit to be configured (IP Address etc.); it is anticipated that future developments will allow data to be displayed on the patients PC or laptop. Figure C shows the internals of the unit, Figure D is the cased prototype. Following much market research and product assessment the RCM3200 core module from Rabbit Semiconductor was cho- sen for the unit, it offers a cost-effective solution with good functionality and sufficient memory capacity for this applica- tion. Dynamic C from Z World was the chosen development environment. The RCM3200 Module (Figure E) has an integrated 10/100Base T Ethernet interface and a 3.3 V core with 5 V tolerant input/output. Six serial ports are also avail- able. The module is based on the Rabbit 3000 8-bit micro- processor running at a clock frequency of 44.2 MHz. It has a 512 Kbyte flash memory, 512 Kbyte program execution SRAM and 256 Kbyte data SRAM, quadrature decoder, PWM outputs and pulse-capture capability. The module 30 elektor electronics - 10/2006 PATIENT AREA SCHNITTSTELLEN MODULE V24 BLUETOOTH DISPLAY KEYPAD INTERNET TELEPHONE MODEM MODULE TC/IP GPRS TELEPHONE/ ISDN 050341 - 12 Figure B. Interfaces of the Telematik module. Figure C. Main blocks of the Telematik unit. also contains a real time clock which can be fitted with a backup battery and has a low power 'sleep' mode. Built-in features including a clock-frequency spectrum spreader ensure that EMI (Electro Magnetic Interference) problems are virtually eliminated. Dynamic C is a user-friendly C language program development environment comprising of an editor, compiler and debugger. A programming cable is used to transfer the application software to the target system and is also used for debugging without the need for a separate emulator. Dynamic C comes with an exten- sive library of routines (TCP/IP stack, serial interface etc.) which helps cuts down program development time. The author can demonstrate the viability of monitoring patients fitted with heart function support devices. It is important to co- operate with the patient and provide basic training in the use of the monitoring unit (cable connections, familiarisation of key- pad and the most important error messages etc.). It is also nec- essary to determine if data can be reliably transferred over a potentially unpredictable Internet connection available at the patient's home. Figure D. The housed unit. Figure E. A Rabbit microprocessor is at the heart of the unit. 10/2006 - elektor electronics Marcel Cremmel D 3 • .ji j 1 B i i l i H P ■ !• | . i I i h B ■i 1 i ■ ■ *i P i p 1 ■ III >1 i - , . i ■ p fa 1 | p ■ i T i fa HI ■ ■ fail .fa . ■§* | | ji fa r "fa j J UiL ■ u_ ■vbJt c E L T RuCr iRf>J [QUILT ■ r RE GAME BOY AQV IMS Lots of electronics hobbyist dream of recording an electrocardiogram (ECG) using a circuit built at home. Usually out of technical curiosity, as numerous problems have to be resolved in order to properly sample the heart's electrical activity. Alternatively, some people require personal medical monitoring while under a cardiologist's care. And then it's great to be able to make your own ECG and show it to your GP or clinical staff. J The idea of using a Nintendo Gameboy games console equipped with a spe- cial cartridge was inspired by the world-famous Elektor GBDSO [1] (a big thank you goes out to Steve Willis for his help with this project). Our electrocardiograph utilizes three electrodes: one on each wrist, the third on the left leg. The electronic device, built on a cartridge that slips into any Gameboy model, processes the sampled signals and produces a very high quality ECG scrolling across the LCD (see the various illustrations). The electrocardiogram implements the method of M. Einthoven (see the inset on the next page). It only uses two active electrodes, a third being used to set the no-signal level of the first two. All leads are single-ended. Despite this simplicity, the results are noticeable and even recognized as usable by a cardiologist. The electro- cardiograph easily meets the initial specifications for which it was designed: to monitor tolerance to the anti-malaria medication. To do that, we measure the QT interval (see Figure 1) which should remain ‘normal’. Figure 1 [2] matches up the electrical activity sampled and the car- diac cycle phases, as follows: P-Wave: Auricular contraction; the blood coming from the veins is pushed into the ventricles. QRS Complex: Ventricular contraction; the blood contained inside is pushed into the arteries. Both of these waves produce the ‘lub- dub’ heartbeat sounds. T-Wave: Repolarisation of the ventri- cles; the ventricular muscle returns to rest. The electronics! After this little ‘dose’ of general knowl- edge, let’s deal with our favourite sub- ject: describing the GBECG electronic structures and making the board. Just as with the GBDSO [1] ( Elektor Electronics October and November 2000), the specific electronics and soft- ware (in Flash memory) are grouped onto a cartridge that slips into the con- sole’s connector. In this way, the Gameboy is transformed into a power- ful electrocardiograph! The electronic device processes the very low voltages sampled between the two active electrodes. The single- ended leads are designated DI, DII and Dill according to their localisation (see drawing in Figure 2). The most common lead is DI. Due to its low peak-to-peak amplitude (of the order of one mV), the EMF (elec- tromotive force) measured is consider- ably amplified (about lOOOx) before it can be converted to 8-bit digital. The sampling frequency selected is 477.84 Hz, compatible with the spectrum of an ECG signal. The digital signal is then taken care of by the console processor. It is then placed in an 8 kBytes cyclic buffer 32 elektor electronics - 10/2006 GameBoy ElectroCardioGraph Characteristics: • Cartridge compatible with Nintendo Gameboy con- soles type Classic, Pocket, Colour or Advance • Single-ended connections using 3 electrodes • Sensitivity: 1 .6 mV full scale • Common mode rejection: 100 dB • Trace memory : 68 s • Scrolling display • Temporal window: 2.6 s in acquisition mode (1 .3 s or 2.6 s in consultation mode) • Heartbeat indicator • Battery power supply required • Approx. 2 hours use from battery power The Electrocardiogram (ECG) It is practically impossible to grasp the operation of this home-made electrocardiograph instrument without a mini- mum of medical knowledge. We deal with the heart of the subject. First of all... A bit of history... In passing, let us pay homage to Willem Einthoven who discov- ered the relationship between electrical phe- nomena and muscular contraction of the human heart about 100 years ago. He received the Nobel Prize in 1924 for that discovery. Willem Einthoven, inventor of the electrocardiograph. and a bit of biology... The heart is an autonomous muscle: it is the only one not controlled by the brain. The 'sinus node', located in the right auricle, triggers nerve flows that control the heart muscles. These contract ('depolarisation' in medical lingo) and relax ('polarisation') in order to make up the blood pump that gives us life. The contraction is caused by a change in elec- trical polarity on each side of the cellular membranes. During the relaxation phases, the electrical charges find their state of equilibrium before being stimulated again. The resulting potentials are transmitted to the skin surface. They can then be sampled by cutaneous electrodes, as the human skin is sufficiently conductive. A wise placement of the electrodes allows a cardiologist to deduce the heart's mechanical behaviour (and its defects!) by analysing the electrical activity. Technology has greatly evolved since the 1 920s. The first patients dipped their hands and feet in basins full of very salty water! String galvanometer. The U-shaped magnet ends are enveloped in water cooling tubes (well before PCs!) Photos : Stichting Einthoven Foundation 10/2006 - elektor electronics 33 HANDS-ON ELECTROCARDIOGRAPH Figure 1 . Relationship between the measured electrical activity and the cardiac cycle phases. Figure 2. These single-pole leads are used to implement the electrocardiograph. memory and reread to show the ECG in real time on the screen, in ‘scrolling’ mode. The analogue part Presenting an adequate signal to the input of the digital analogue converter presents a challenge to the electronics engineer because there are a number of technical problems to analyse and resolve. Differential amplifier The peak-to-peak amplitude of the sig- nals sampled between the electrodes is very low at just 2 mV max. Also, both the human body and the connecting wires to the electrodes are strongly influenced by high noise lev- els radiated by mains wires and other power carrying leads inside buildings. Capacitive coupling, although very low, produces a relatively high voltage (often over 1 V) to appear with respect to ground, despite the relatively low frequency of just 50 Hz or 60 Hz. To begin with, it would seem difficult to isolate the useful signal because its amplitude is 1,000 times lower than all the interference around! Moreover, the mains frequency is included in the use- ful spectrum; so the filtering solution does not work here. However, considering the wavelength of the mains voltage (6,000 km!), it is safe to assume that that each point on the skin receives the same induced potential thanks to its conductivity. Therefore, a common-mode voltage is developed with respect to the elec- trodes. In this case, the solution becomes obvious: we’re going to use a differen- tial instrumentation amplifier with an adequate common-mode rejection ratio (CMRR): Figure 3. Block diagram of the analogue part of the circuit. CMRR> + 5 N dB In this formula: S P = amplitude of the interference: 1 V S EC q = ECG amplitude: 1 mV S/N= signal to noise ratio: 40 dB Or: CMRR > 100 dB. In addition, the amplifier must be characterised by a very high input impedance (> 10 Mfl) and a low offset voltage. Numerous integrated instrumentation amplifiers exist (the AD624, for exam- 34 elektor electronics - 10/2006 + cn < + cn < + cn < Figure 4. The bulk of the work is handled by the ISP flash memory, IC4 and IC3, an A/D converter. Serial I/O. The Gameboy processor handles the processing. 10/2006 - elektor electronics 35 HANDS-ON ELECTROCARDIOGRAPH Figure 5. The transfer function is determined by divider bridge R3/R12. Figure 6. Connector pinout for the Gameboy cartridge (view from above). pie). These are very high-performance devices and need no adjustment. But quality comes at a cost. We decided to make the differential amplifier using more economical oper- ational amplifiers. This also allows sig- nificant savings in cost and power con- sumption. Moreover, these opamps function perfectly with a single 5 V power supply (this is not the case for the AD624). The disadvantage is the presence of an adjustable potentiome- ter to optimise the CMRR. Block diagram and wiring diagram Figures 3 and 4 respectively give the block diagrams for the analogue part and the complete circuit diagram. The references associated with each func- tion (ICx.y) identify the operational amplifiers for the structural diagrams that show the functionality. The instrumentation amplifier is made up of functions FI and F2. Function F3 is a 2nd order low pass filter with a roll-off of 170 Hz and a damping factor m of 0.73 (i.e., near Butterworth). It will faithfully attenuate all unwanted com- ponents outside of the useful fre- quency spectrum and replaces the anti-aliasing filter for the DAC (digital/analogue converter) that fol- lows it. The gain distribution in the circuit is as follows: A1 = 2 lx, A2 = 4.7x and A3 = lOx. The total amplification is 987, in compliance with our objectives. The other functions (F4, F5 and F6) assist the instrumentation amplifier in order to ensure its proper operation. In fact, the operational amplifiers have a sup- ply voltage of between 0 V and 5 V. The ideal no-signal voltage on each of the terminals is 2.5 V. Setting this level is not a problem in most cases: a divider bridge with two resistors is appropriate (R23 and R24). It is harder for the two input amps because we must take care not to compromise their input impedances. The problem is solved using the third, common, ECG electrode (see Figure 3) and the functions of F4 and F5. It can be shown that the voltage S equals half the sum of the voltage (EA + EB). It is compared to the ‘2.5-V’ set- ting, and the error voltage is amplified to produce an ECG signal that can be processed. As there is no current flow in the electrodes, voltages EA and EB are equal to EC (give or take a few mV). In this way, the human skin actu- ally helps to keep EA and EB equal to the target level of 2.5 V That is the goal 36 elektor electronics - 10/2006 we are seeking: the no-signal voltage of the opamps is as desired without reducing the input impedance. Moreover, a natural, but very annoying phenomenon occurs when we place the electrodes: an electromotive force (EMF) contact potential is produced between the skin and the electrode metal. This ‘micro-cell’ is very weak (a few mV) but it is not eliminated by the instrumentation amplifier. On the con- trary, it is amplified! Functions F4 and F5 partially reduce this effect, but the offset in SI and S2 may still reach 1 V in differential mode. This value is unacceptable and is therefore compensated by function F6. F6 compares the average S3 signal value with the 2.5 V setting. The error voltage is integrated (time constant R16C8 = 2.2 s) in order to produce the ZERO signal. This continuous voltage offsets the S3 signal until its average value is stabilised at 2.5 V. To increase the amplitude of this com- pensation, two diode pumps C9-D4- Cll and C12-D5-C13 produce -3 V and + 8 V supply voltages for IC2. The digital part The digital-analogue conversion is per- formed by IC3. It integrates a real dif- ferential amplifier, but requires an external reference voltage. This is sim- ply derived from the 5 V power supply using a potential divider (R23/R24) buffered by Tl. The precision and the stability are average at best, but still sufficient for this application. The divider R3/R12 determines the transfer function (see Figure 4). The asymmetry with respect to 2.5 V is justified by the asymmetrical shape of an ECG in relation to its average value. The DAC provides its NECG results in ‘serial’ format. It is controlled by the CS and CLK signals — the first triggers the conversion (its frequency is 477.84 Hz) and the second clocks the data output (on DO). The PSD813F2 A Gameboy cartridge plugs into a con- nector which accommodates the con- sole’s microprocessor buses: • Addresses: A15 to AO • Data: D7 to DO • Check: ECLK, WR, RD and RESET The first Gameboy games consoles on the market from about 1989 had a microprocessor similar to the old Z80, which explains the size of the buses. The most recent consoles are equipped with much more powerful CPUs, but for commercial reasons the old car- tridges (and even older than those) still operate on the current Gameboys. That is also the case for our electrocardio- graph! The PSD813F2 is an integrated circuit that’s perfectly adapted for making a cartridge for a Gameboy console. Unfortunately, we do not have enough space in this article to describe its complete functionality (see [3]). In summary, the PSD813F2 includes: • a configurable microprocessor inter- face that can be adapted to all 8 -bit microprocessors on the market, • 27 I/O configurable ports; • 2 kBbytes RAM (not used). Moreover, a JTAG interface is used to completely configure the ‘on circuit’ component via connector K3, which should not fail to interest all of you electronics hobbyists. The PSDSoftEx- press development environment can be downloaded for free on the manu- facturer’s website. As you can see from the diagram (Fig- ure 4), the connection between the console bus and the PSD813 is simple: the signals of the same name are con- nected. The only particularity that could be The author The author, Marcel Cremmel, has been a quali- fied teacher in Electrical Engineering (with Electronics option) since 1979 (French National Education state diploma). After having initially taught at the Mohammedia de Rabat Engineering School in Morocco as a participant in the Cooperation pro- gram, he was assigned to the Louis Couffignal High School in Strasbourg in 1982, in the BTS EL section (Certificate, Senior Electronics Technician). Although his profession forces him to deal with all domains of electronics Marcel has a preference for telecommunications, video, microcontrollers (MSP430 and PIC) and programmable logic circuits (Altera). In addition to elec- tronics, his other passion is motorcycles in all forms: touring, races, etc. His personal website is at http://electronique.marcel.free.fr/ including the vintage Z80; 128 kBytes of Flash memory (only 32 kBytes are utilised by the electro- cardiograph object code, which leaves space for extensions or other things...); a complex programmable logic device (PLD) that takes care of the address decoding; a 16-cell sequential Complex Pro- grammable Logic Device (CPLD). It is responsible for the serial-to-paral- lel conversion of the DAC frames to relieve the CPU and produce the squarewave signals required for the diode pumps; interpreted as an error: the data bus connections are crossed! That enabled us to simplify the board layout and the binary file of the GBECG control pro- gram was changed to suit. The software The software is entirely written in assembly language. The author used the ‘Gameboy Assembler Studio’ envi- ronment by Nicklas Larsson (freeware available on the web [4]). The assembly language was necessary because the specifications require a ‘scrolling’ display in real time. That 10/2006 - elektor electronics 37 HANDS-ON ELECTROCARDIOGRAPH Figure 7. Copper track layout and component mounting plan of the double-sided board designed for the GBECG. Soldering of IC3 is particularly difficult, so we're supplying the board with all components pre-soldered. occupies the CPU of the first consoles at a level of 80% due to the ‘old’ man- ner in which the screen memory is organised (separate screen memory and character memory). The software can be thought of as han- dling four tasks: 1. Initialisations This task is executed at switch-on or after a reset, • Initial assignment of variables. • Configuration of I/O ports. • Initialisation of the LCD. The screen has 160 x 144 pixels, but for technical reasons, the useful part is reduced to 160 x 96 pixels. The lower part (160 x 48) is utilised for fixed mes- sages. • Internal timer: this is programmed to produce interrupts at a rate of 477.84 Hz (sampling frequency). • Sound generator: this is pre-pro- grammed to produce a cardiac ‘beep’ when required. 2. Main loop The main loop simply detects the action of certain keyboard keys and modifies the operating mode: • Start: acquisition mode • Select : stop mode • A : zoom _1 in stop mode • V : zoom _2 in stop mode 3. Tinier interrupt program This task is executed a rate of 477.84 times per second. It carries out the fol- lowing functions: • Debounced readout of the keyboard state. In run mode: • triggers a new conversion; • acquisition of the last sample (result of the previous conversion); • all 4 samples (or 119.46 times per second); • calculation of the ‘average sample’ ! COMPONENT | LIST | (all SMD, except K1 ) Resistors (all 0805 case) R1 = 2MD2 1% R2,R1 5,R21 = A7ka R3 = 22ka R4,R1 3 = A7ka 1% R5,R14 = 220kD 1% R6 = 22 ka 1% R7 = 4k 07 1 R8,R 1 1 = lOOkD 1% ■ R9 = 1 Oka ■ R10 = 21 OkD 1% I R 1 2 = 1 2kD I R 1 6 = 2l\Aa2 I R1 7,R1 8,R22,R25 = lOOkfl I R19 = ]ka | R20 = 390kD I R23,R24 = 1 !\Aa I PI = 22 kD preset (Bourns 3314G) Capacitors (all 0805 case except C8 and Cl 9) Cl =560pF5% C2 = 33nF 5% C3-C7,C 1 1 ,C 1 3-C 1 7= lOOnF C8 = 1 |jF (1208) C9 = 470pF CIO = InF Cl 2 = 2nF2 C 1 8 = not fitted Cl 9 = 10fjF (1208P) Semiconductors IC1JC2 = TLV2254AID IC3 = ADC08831 1 M (Analog Devices) orTLC0831CD (Texas Instruments) IC4 = PSD81 3F2A-90M (STMicroelectronics), programmed, order code 050280-41 D1-D5 = BAV99 T1 = BC848B Miscellaneous K1 = Molex connector, 5-way, Dubox 89882-405, Digikey # 90148-1 1 02- ND Programming connections: K3 = Molex connector, 6-way, 1 .25mm lead pitch, type 53261-0671 (Digikey # WM7624CT-ND) Optionally: FlashLink programming connection: Molex 6-way connector, 1 .25mm lead pitch, female (Digikey # WM1 724- ND) 6 wires with pin terminations for Molex connector (Digikey # WM1 775-ND) Electrodes: Cutaneous probes or clips are available from medical supplies outlets 5-way SIL pinheader 4 mm plate (3x) 6 m screened audio cable PCB, with all components ready fitted, tested, order code 050280-91 38 elektor electronics - 10/2006 = average of the last 4 samples; • detection of the R-wave in order to trigger the cardiac ‘beep’; • loading the 8 kBytes cyclic buffer with the average sample. 4. Interrupt program, V-Blank This interrupt is produced at the end of each LCD vertical sweep. The rate is: / v = 59.73 Hz; or every two aver- aged samples. The program also takes care of refresh- ing the display. • Run mode: the LCD shows the last samples (or 320 averaged sampled values on the cyclic buffer), which traces the last 2.68 s on the screen width. • Stop mode: depending on the zoom value: xl or x2, the LCD shows the last 320 or 160 samples, which traces the last 2.68 s or 1.34 s on the screen width. In stop mode, the program also detects action on the > or <] keys allowing the use to move around within the screen memory. During the display of the ECG trace, the program draws the vertical and horizontal scales. The latter moves with the trace in order to improve read- ability. The source code file of the GBECG control program is available as a free download from the Elektor Elec- tronics website, the file number is 050580-11. zip, see under month of publication. Improvements and addi- tions are welcome. Building it The use of SMD components is unavoidable. In fact, the underside of the board must be perfectly smooth (therefore, no through wires or pins) so that it can slip into the cartridge case. To save you the trouble of struggling with (and losing) those tiny SMD parts, we are supplying the GBECG printed circuit board with all components already soldered in place, and the PSD813 programmed, all at an afford- able price (see the inset). The order code is 050280-91. All that is left to do is find an old Gameboy cartridge case and clear out the two half-shells a little. Photo A illustrates the cutouts to make. The wider cutout in the upper half- shell is due to potentiometer PI which otherwise prevents closing the case. Adjustment The only adjustment consists in opti- mising the CMRR of the differential The electrodes A good ECG can only be obtained with good, well-placed and properly-wired electrodes. To limit the effect of undesirable signals, it is recommended that you use shielded cables. Electronically, 'audio' cables are perfectly suited to this function. In practice however they are much too fragile, We therefore propose making small adaptors on which the cable clasps eliminate practically all risk of breaking (see Figure F), You will see that the shielding is only connected at the car- tridge side and that it is isolated on the electrode side in order to avoid any contact with the skin. '4 mm' type plugs make it possible to use commercially avail- able electrodes (Figure G). The clip is very practical and adapted for children. But the price of these two electrodes may discourage many readers (more than £6 each and you will need three off!) Homebrew electrodes can be made from coins as illustrated in the opposite photo. The author used French Florin (FF) coins which are made from nickel. Solder a 4-mm socket and the electrode (Figure H is ready to use. Three rubber bracelets keep them in place on the wrists and the lower calf. These bracelets can be made by cutting rib- bon for straps to the proper length and gluing them to the self-adhesive 'Velcro' tape at both ends. We can also use sections from air chambers from a motorcycle or a scooter. 10/2006 - elektor electronics 39 HANDS-ON ELECTROCARDIOGRAPH amplifier. For that, you need a function generator and an oscilloscope or an AC voltmeter. Begin by making the meas- urement circuit in Figure B (the capac- itor has a capacitance of 10 pF). Top to bottom: EA, EB, EC, GND. Plug the device into the fixed connec- tor Kl, observing the orientation, and only then connect the generator. In this way, we inject a common-mode test signal. Adjust the generator: 50 Hz sine wave with amplitude 1 V. Insert the cartridge in the Gameboy with the upper half-shell removed in order to access the ECG test point. Turn on the power and measure the AC component of the ECG signal. Then adjust PI to minimise the peak-to-peak amplitude. It should be less than 25 mV in order to obtain an S/N ratio in excess of 40 dB. Final check This step is not strictly required. Its purpose is to ensure proper operation of the electrocardiograph by injecting a signal and by verifying the result on the screen. Most benchtop signal generators are incapable of reliably producing the very low levels required for this check. Therefore, we must greatly attenuate the GBF signal. That is what the device shown in Figure C does. The signal is effectively divided by 100. In this way, we inject a 1 Hz sinu- soidal signal and a 140-mV DC ampli- tude signal. These should result in an image on the LCD screen similar to that in Figure D. The sinewave is aligned with the first dotted line and has a DC amplitude of 7 divisions, or 7x200 yL/V = 1.4 mV. The fixed connector Kl on the car- tridge is not very sturdy. To limit the risk of deformation or of it being torn out, restrain the three shielded cables on the cartridge cover with two cable ties, as illustrated in photo E. The cable ties we used on our proto- type of the GBECG do not touch the internal components. They require four 2 mm holes to be drilled which do not significantly weaken the shell. ( 050280 - 1 ) We would like to extend our thanks to Professors Schalij and Moan, Leiden University Hospital, the Netherlands, for their valuable assistance. D Bibliography [1] GBDSO — Gameboy Digital Storage Oscilloscope, Elektor Electronics October and November 2000. Internet references and links [1] http://chem.ch.huji.ac.il/ ~eugeniik/history/ei nthoven.html 40 elektor electronics - 10/2006 Attention ECG acquisition: if the electrodes are properly placed and the patient is calm, the reading The GBECG electrocardiograph described in this article has not received medical approval and is therefore not intended for professional use. The instrument must always be powered by batteries in order to respect protection category III. should be stabilised in a few seconds and look like the one illustrated in Figure I. Operating instructions Placement of the electrodes It is absolutely necessary to clean the skin and the electrodes well with a cotton and ether or alcohol, In this way, the elec- tromotive force EMF on the contacts, which may saturate the amplifiers, are limited considerably. The standard lead is 'Dl': • EA electrode: right wrist • EB electrode: left wrist • EC electrode: left foot (lower calf) Utilisation of 'contact' products based on potassium chloride considerably improve the quality of the measurements. The best ECGs are obtained when the patient is calm and lying down so that the only muscle in action is the heart. Do not use this ECG as a reference; the shapes may vary appreciably from one individual to another. If no trace appears after thirty seconds, clean the skin below the electrodes using a pad and ether or alcohol. Irregularity of the trace may be reduced by using a 'contact' product. • Stop mode: pressing the Select button stops the acquisi- tion. You can then analyse the memory which contains 68.6 s worth of ECG. Operation • Live start-up: welcome screen is displayed. • Go to the acquisition screen: press Start, A, B or Select. A : zoom x 1 V : zoom x 2 (see below) l> : Move ahead < : Move backwards A beep sound will be heard each time an R wave is detect- ed. The volume can be adjusted with the volume button on the console. Attention: The screen memory is erased when power is removed. [2] http://www.e-cardiologie.com/ examens/ex-electro2.shtml [3] http://www.st.com/stonline/prod- ucts/ [4] http://www.devrs.com/gb/ Additional documents and program sources on http://www.elektor.com h ttp : // www. i n f osc i e n c e . f r/ h i sto i re/ biograph/biograph. php3?Ref=l 28 PSD813 datasheet http://www.st.com/ stonline/ products/literature/ds/7833.pdf ADC08831IM datasheet h ttp : // www. ortodoxism.ro/ datasheets2/6/ Orcoikl yuwhxl dj2ogg8wid7sfcy.pdf 10/2006 - elektor electronics 41 HANDS-ON INSTRUMENTATION Medical signal processing Martin Klaper Is it possible to use a computer with an ordinary sound card to record an ECG (electrocardiogram) signal and measure someone's pulse? This question has been researched in a university dissertation and answered convincingly in the positive. The heart monitor described here is the fruit of this work, and the software is available for free download from the Elektor Electronics website. Elsewhere in this issue we describe how to record an ECG signal using a Gameboy games console fitted with a special insertion card. Here we show how it can be done in a more experimental way using an ordinary sound card or the audio input of a laptop computer. For this we need a sensor (see Figure 1), which in the simplest case can be just a tube with contact surfaces at either end that can be gripped like the handlebars of a bicycle. The weak signal that is picked up is amplified by a factor of 1,000 and presented to the audio input of the computer. Subsequent processing is carried out using a Java program. It conditions the signal using a digital filter, stores it and displays it on the screen. The pro- gram also monitors the pulse and auto- matically calculates the pulse rate with a digital display and audio output. The individual readings can be stored in a 42 elektor electronics - 10/2006 Specifications Input impedance: > 1 Mfl Input dynamic range: 5 mVpp Amplifier current consumption: approximately 1 1 mA Optocoupler current consumption: approx. 2.2 mA Common mode rejection ratio (CMRR): > 70 dB Gain: approx. 1 ,000 (60 dB) Bandwidth: approx. 0.4 Hz to 35 Hz (depending on sound card) Recording rate: in practice unlimited, typically 60 kbyte per minute file for later analysis. Test data sets are also available on the Internet [1] from medical databases, and these can also be processed and displayed using the program. ECG As described in detail in the Gameboy ECG article elsewhere in this issue, the heart muscle is controlled by elec- tric currents. This electrical activity can be measured on the surface of the body using electrodes. The resulting plot against time is called an electro- cardiogram, or ECG. Figure 2 shows a typical ECG plot: the exact form of the curve is an important diagnostic aid. We will leave the job of diagnosis to the specialists, and concentrate here on making the measurements. ECGs are normally displayed with 25 millimetres on the horizontal axis rep- resenting one second, or 40 millisec- onds per millimetre. The vertical axis is usually 10 millimetres per millivolt. This means that a 1 mm square on the plot represents 0.04 s in time and 0.1 mV in voltage. There are conven- tions for labelling certain characteris- tic points on the ECG curve with let- ters [2]. The distance from one of the prominent ‘R’ peaks to the next repre- sents exactly the time between two heartbeats: this lets us readily deter- mine the pulse rate. This rate, expressed in beats per minute (or BPM) is displayed by the computer, and the pulse itself can optionally be output as an audio sig- nal. An interesting project would be to compare the measured rate against a preset value and use this to control the braking on an exercise bicycle, in order to maintain a constant pulse rate while exercising. Figure 1. This simple sensor for heart signals consists of a pipe with a contact surface at either end. Figure 2. The interval between two consecutive points marked 'R' in the ECG trace gives the time between heartbeats. Safety The circuit and software are not approved and/or licensed for medical use. They are for private use only, for example for experimental purposes. The circuit must only be used with a battery supply. This also applies to the con- nected computer whose sound card input is being used: the computer must not be connected to the mains supply. In practice this means that a notebook or laptop PC must be used, running on battery power. The mains adaptor must be disconnected! 10/2006 - elektor electronics 43 HANDS-ON INSTRUMENTATION OQ in > rr O) h- o o CO m > rr < in > rr < in > rr Figure 3. Circuit of the instrumentation amplifier, with galvanical isolation between input and output provided by an optocoupler. Signal processing Measuring an ECG using a computer requires demanding real-time pro- cessing, most of which is carried out in software. The hardware takes the form of an instrumentation amplifier (Figure 3) and has the job of ampli- fying the weak signal from the sen- sor (which has an amplitude of approximately 1 mV) by a factor of around 1,000, and attenuating DC, common-mode, and high-frequency components. To obtain an (at least relatively) clean ECG signal it is necessary carefully to filter out any interference. This is done in software using a biquad infi- nite impulse response filter. The filter can be configured for any of the required responses: low-pass, high- pass, band-pass and notch. A 50-Hz rejection filter removes interference originating from the mains, and other interference is attenuated using a fur- ther high-pass filter. Since the signal is obtained from electrodes on the skin it is possible that there will be a slowly-varying offset voltage: this is removed using a DC blocking filter. The main pulse of the ECG can be extracted using a band-pass filter, giving a signal from which it is straightforward to measure the pulse rate. The Java program allows display of either the original signal or the fil- tered version. The various filter func- tions can be selected and configured by the user, and the effect on the processed signal can be clearly seen. The pulse rate is calculated from its autocorrelation function, determining the period by comparing the signal against itself with a time offset. Instrumentation amplifier The circuit (Figure 3) can be divided into two blocks: the instrumentation amplifier itself at the input and the optocoupled isolation amplifier at the output. The signal is amplified by quad opera- tional amplifier IC1, type TL084 (or the lower-noise TL074). IC1.A and IC1.B are non-inverting amplifiers, feeding the inputs of differential amplifier IC1.C. This arrangement is known as an ‘instrumentation amplifier’. PI allows adjustment to obtain best com- mon-mode rejection. Coupling capacitor C3 at the input to the next stage, built around IC1.D, blocks the DC compo- nent of the output of the instrumenta- tion amplifier. To minimise the effect on low-frequency signals the time con- stant of the RC network formed by C3 and RIO is more than three seconds. This means that it will take at least this long for the voltage across the capacitor to stabilise when power is applied: this delay can be avoided by pressing reset button SI. Optocoupler IC3 is driven by IC2. The type TS921 used is a ‘rail to rail’ opamp, which means that it can be driven to either extreme of its supply voltage range. Its output can deliver 44 elektor electronics - 10/2006 | COMPONENTS j i LIST ! Resistors R1 / R2 / R4 / R6 / R7 / R1 9-22 = lOkD R3,R5 = 22kD 1% R8 = 47kD R9 = 42kD2 R 1 0,R 1 1 = 3M£23 R 1 2 = 150kfl R13 =4k 07 R 1 4, R 1 6 = 47k£2 R1 5 = 220£1 R 1 7,R 1 8 = 100£2 R23, R24 = 1M£2 PI = 1 OkD preset Capacitors Cl ,C2 = 27pF 03,010 = 1|jF 63V, 5mm lead pitch (no electrolytic cap) 04 = 1 OOnF C5-C8 = lOOpF 16V radial 09 = InF Cl 1 = 22pF Semiconductors 101 = TL074 DIP 14 102,104 = TS921 or TL071 DIP8 IC3 = IL300 Miscellaneous Two wire links Two 9-V PP3 batteries with connecting clips Two DIL8 1C sockets One DILI 4 1C socket PCB, order code 040479-1 CD-ROM, contains PC software and source code, order code 040479- 81 or free download from www.elektor.com Figure 4. There are no SMDs on the single-sided printed circuit board, and so assembly is straightforward. up to 80 mA, although only approxi- mately 2.2 mA is needed to drive the transmit LED in the optocoupler. The current through the transmit LED is controlled using feedback from one of the receiver diodes in the optocoupler fed in to the inverting input of the operational amplifier. The result is that the voltage across R16 (the bias resis- tor for the second receiver diode) is equal to that across R14 and hence to the voltage at the non-inverting input to IC2. In other words, the voltage at the output of IC1.D appears across R16, but with galvanic isolation. Cll prevents high-frequency oscillation of the driver. The final opamp at the output of the circuit acts as a buffer amplifier. This makes for a low-impedance output, which is also short-circuit proof thanks to the 100 £2 resistors R17 and R18, forming a low-pass filter at the output in combination with 09. About the author Martin Klaper studied electronic engi- neering at the Swiss Federal Institute of Technology in Zurich and worked in vari- ous positions in the telecommunications industry over a period of 20 years. Since 2000 he has been a lecturer in comput- ing and telecommunications, until 2005 at the University of Applied Sciences of Northwestern Switzerland (FHSO), and since October 2005 at the School of Engineering and Architecture (HTA) in Horw, near Lucerne. This project was begun at FHSO and continued at HTA. The author is also a keen radio amateur (callsign HB9ARK) and is currently inter- ested in the ideas behind software defined radio. He is married with two sons. 10/2006 - elektor electronics 45 HANDS-ON INSTRUMENTATION Figure 5. The populated Elektor Electronics prototype board. The 1C not fitted in a socket is the optocoupler, whose pins are splayed out for mounting in order to increase the isolation gap. The complete galvanic isolation between input and output of the circuit provides for extra safety (see the ‘Safety’ text box). The instrumentation amplifier and the output stage should be powered from separate batteries. Components and construction We look first at component selection. For resistors R3, R4 and R5 low-noise metal film types are recommended. CIO provides DC decoupling for the input amplifiers, which, if the sensor shown in Figure 1 is used, prevents weak muscle signals from swamping the signal from the heart. If disposable self-adhesive ECG electrodes are used instead, the capacitor can be replaced by a wire link. If the TS921 should prove hard to obtain, a type TL071 can be substi- ^UIILJLl|t> r t 1 1 _ i „ r t- -I import* import . 1 1 “ — — ■‘■UL-JEunliale^ L _______ . _ _ J Figure 6. The module structure of the PC-based Java signal processing software. tuted at the cost of reducing the dynamic range of the circuit some- what. The 43 kfl resistor (value from the E24 series) can also be replaced by a different value, adjustment of PI compensating for the difference. Assembly of the printed circuit board (Figure 4) should commence with the wire links, since these are easy to overlook if left to a later stage of con- struction. IC3 is supplied with its pins bent at a right angle. To fit the circuit board they should be bent apart (see Figure 5): this is necessary in order to guarantee the necessary isolation gap. PI can be adjusted for best common- mode rejection. Start with it set to its mid-position: the adjustment is not critical and so this will often be ade- quate. For best results connect the inputs of the instrumentation amplifier together and adjust PI to minimise the amplitude at the output of the 50 Hz signal picked up by the circuit. This measurement can be done using the Java program (see Figure 7). The heart signal sensor used by the author consists of two short pieces of conducting tube (zinc- or chrome- plated steel, for example from a vac- uum cleaner head, or a length of water pipe) joined using a piece of insulating pipe. The Elektor Electronics prototype used a longer piece of conducting pipe with insulating tape wound around either end for a distance of about 10 cm. We then wrapped this insulat- ing layer with aluminium foil to provide the two contact surfaces. Tinned cop- per wires wound around the two pieces of foil provide connection to the inputs of the instrumentation amplifier. This sensor construction, illustrated in Figure 1, has the advantage of not requiring any drilling or sawing. Screened audio cable can be used to wire the output of the circuit to a plug suitable for connecting in to an audio line input (or microphone input) of a computer. Most computers use a 3.5 mm stereo jack. Software The Windows-based software is writ- ten entirely in Java. The modular struc- ture of the software (see Figure 6) is designed to provide the following func- tions: • capture the signal from the sound card (labelled ‘io’); • signal conditioning and filtering to 46 elektor electronics - 10/2006 remove interference (‘dsp’); • user interface (‘ecg’). Figure 7 shows the appearance of the user interface, showing the main pro- gram window with the original signal plotted at the top and the processed signal plotted below. The time axis is shown in between the two plots. The BPM meter in the lower right corner of the window shows the pulse rate and the program’s confidence in the dis- played value. The audio output can also be enabled here. The program has many other features which we do not have space to describe here. The source code is available for down- load from the Elektor Electronics web- site. There are several files in the download. The PC program is called ‘EKG-MonitorVl.O.jar’ and can be run with a double click of the mouse. The ‘.jar’ extension indicates that this is a Java executable, analogous to a ‘.exe’ file under Windows. A Java runtime system is required to execute the pro- gram: this can be found at [3]. You will need the version of the JRE (Java Run- time Environment) suitable for your operating system. Figure 7. The main program window shows the original signal (above) and the processed signal (below). In practice The circuit is suitable for use only with sound cards that have a frequency response that extends down to at least 0.1 Hz (at -3 dB). This should not pres- ent a problem if the input is DC cou- pled; however, many are provided with inputs that are AC coupled (i.e. , with an input capacitor). In our laboratory the prototype worked perfectly with the audio input of an elderly laptop. In case of doubt the frequency response of the sound card can be measured using the free program RMAA [6]. Best results are obtained using commer- cial disposable ECG electrodes, but they can be tricky to attach to the skin. The pipe sensor described above and shown in Figure 1 is rather easier to use. The filter (Figure 8) can be configured to minimise interference, and there is plenty of scope for experimentation, improvement, and research. Readers are encouraged to publish their improvements, and the Java software for the project is released under the GNU public licence. As well as compiled hex code and source code, a User Guide is also available for download from the Elektor Electronics website. Look for archive file 040479- 11. zip under month of publication. ( 040479 ) Figure 8. The 'Filter Settings' window allows configuration of the infinite impulse response biquad filter, implemented in software. Links: [1] www.physionet.org/physiobank/ ECG sample data [2] http://en.wikipedia.org/wiki/Electrocardiogram [3] http://java.sun.com/lavase/downloads/index.jsp Java compiler and development environment. The Java Runtime Environment (JRE), current version 5.0, is required to run the program and the J2SE Development Kit (JDK), current version 5.0, is required to compile modified versions of the program [4] www.bluej.org/ download/ download.html Simple Java development environment with tutorial, ideal for beginners. [5] www.eclipse.org/downloads/ Ec ipse is a full-featured Java development environment for professionals. [6] http://audio.rightmark.org/download.shtml RMAA (RightMark Audio Analyser). [7] www.dspguru.com; www.musicdsp.org/archive. php?classid=0 Various topics in DSP. 10/2006 - elektor electronics 47 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 n, 1 W resistor and a 1 0 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 7i -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- filters 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. 48 elektor electronics - 10/2006 !V ■ V, To PCB taiures: # UL Prov^ft RPgh Quattty ISO 9000 CerUfieSted „-* Accept Orders ‘From apes to 1M Pc%< ** _ * . a ^ • «1 * * * # inabilities- m * ■“ . Up to 40 L^yprs ■ . ^ 2. 5mJ "ftficfc/Space ' 0. fftii Hole Size h ' Blind’ And Buried Vias * RaHs.*VVEpE Compliant f 1 » ~ •" * * , umy sau ror spes 4 *T4 2L.. " Only Siaa For jjpes 4' x 4V4lL Only $288 Fp&-3pcs 4^ )f 4' &k' k * ^ c Free § — | 220 Q 1 R15 — | 22QQ h C3 1 1 14 J I 25V +vcc © V + C1 + © IC4 Cl- T20UT T2IN RUN RIOUT R2IN R20UT TIOUT T1IN C2+ MAX232 C2- V SUB D9 16 10 12 11 C5 □ +vcc © | R25 4 R13 R14 T +vcc R2 15 16 17 18 23 24 25 26 33_ 34_ 35 C12 15 C4 n 1 ^ 1 U 25V in T* 100n 36 R8 37 38 39_ 40 11 32 X 1 I © © MCLR/THV RCO RC1 RC2 RC3 RC4 RC5 TX/RC6 RX/RC7 INT/RBO RBI RB2 RB3/PGM RB4 RB5 RB6/PGC RB7/PGD J. osci IC1 PIC16F877 RAO/ANO RA1/AN1 RA2/AN2 RA3/AN3 RA4/T0CKI RA5/AN4 RD7 RD6 RD5 RD4 RD3 RD2 RD1 RDO RE0/RD/AN5 RE1/WR/AN6 RE2/CS/AN7 OSC2 J. R9 D 5 | | D 6 C9 20MHz c Or T J 'busy ( ( 12 13 XI I I 14 R3 _4 5 _6 7 30 29 28 27 22 21 20 19 _8 _9 10 31 +vcc © I I RCO 16 RC1 RC2 +vcc © R19 12 13 VL V+ INI IN2 IN3 IC2 DG411DJ IN4 GND 51 D1 52 D2 53 D3 54 D4 R21 R20 R22 R23 H 6k8 h R24 +VCC © [r 5 a IC3 C14 T 2 100n LI yYYYY 330|aH © I SENS SWI COL TIM CAP DRI COL MC34063A SWI EMI COMP IN 14 15 11 10 VPROG — • CIO ^ToOn R18 D3 -M- 1N5819 R6 R7 R1 C6 □ X 25V 050348 - 1 1 Figure 1. At the heart of the circuit is a 16F877 Controller, which communicates with the PC through its serial interface. 10/2006 - elektor electronics 51 HANDS-ON MICROCONTROLLERS Figure 2. To make component placement easy the layout of the single-sided circuit board is not cramped. ! COMPONENTS LIST Resistors R1 = 68Q R2 / R6 / R13 / R 1 4, R25 = lOkfl R3 = 270D R4 / R7 / R8 / R9.R1 0 = 1 kD R 5 = m R11,R15,R17 = 220D R 1 2,R 1 6,R2 1 ,R22 = 4k^7 R 1 8 = 33Q R 1 9,R23 = 6kD8 R20,R24 = 2kD2 Capacitors C1-C5 = 1 |jF 25V radial C6 = 10 |jF 25V radial C7,C 1 0-C 1 3 = lOOnF C8,C9 = 22pF Cl 4 = InF Inductor LI = 330|jH radial Semiconductors D1,D2 = 1N4148 D3 = 1N5819 D4 = zener diode 5V6 400mW D5 = LED, low-current, 3mm, red D6 = LED, low-current, 3mm, yellow D7 = LED, low-current, 3mm, green IC1 = PIC16F877, programmed, order code 050348-41 IC2 = DG4 1 1 DJZ (Digikey # DG41 1DJZ-ND) IC3 = MC34063ECN (Digikey # 497- 4280-5-ND) IC4 = MAX232 Miscellaneous K1 = 9-way sub-D socket, angled, PCB mount K2 = 6-way SIL pinheader XI = 20MHz quartz crystal PCB, order code 050348-1 Kit of parts including PCB and microcontroller, order code 050348-71 The majority of PIC Controller circuits operate from 5 V power supplies and the ICD module draws just 30 mA, so the first two specifications laid down should pose no problems in many applications. Dispensing with the firmware-determined programming voltage is not an issue either, as cur- rent PIC Controllers use 13 V for this. Replicating the USB interface of the original device is less easy, as the IC employed is hard to obtain. Propri- etary USB drivers can lead to problems from time to time as well. On the other hand there are no difficulties using an RS-232 interface; the only issue is making sure that the FIFO buffers of the COM port used are disabled. This can be set up using the Device Man- ager in Windows. Users who have only a “legacy- free” computer without serial interfaces will require a USB to RS-232 adapter, specifically one with supplied drivers that allow it to operate without using FIFO buffers. If the FIFO buffers can- not be switched off, permanent com- munication errors arise during debug- ging, making it impossible to use this circuit. Circuit At the heart of the circuit in Figure 1 is a 16F877 Controller (IC 1), which com- municates with the PC using a stan- dard RS-232 interface driver MAX232 (IC4). Flow control is achieved using a hardware handshake, although the PC can also reset PIC Controller IC1 using the DTR signal. The programming voltage of nominally 13 V is produced by the switch regula- tor module MC34063A (IC3), which is configured as a step-up converter. The value of the programming voltage is set by voltage divider R6, R7 and R1 as follows: v prog = 1-25 [1 + R6 / (R1+R7)] Precise adjustment of the 13 V voltage is made possible by adjusting the value of Rl. Chip IC2 is a quad analogue CMOS switch. This has the task, in conjunc- tion with the signals RCO, RC1 and RC2, of applying either the program- ming voltage, the operating voltage or else ground to the Reset pin of the host processor. Communication between the Debug- ger and the host processor is achieved across the lines TGT PGD (data) and TGT PGC (timing). The values of the 52 elektor electronics - 10/2006 test and programming module target system (TGT) Figure 3. Five wires provide the connection from the ICD/ICP module to the target system. pull-down resistors R12 and R16 are copied from the original ICD module. The series resistors Rll, R15 and R17 limit the output current of the host hardware under short circuit condi- tions to a value that is not going to cause trouble for IC1. D4 protects the circuit against excessive supply volt- age or reverse polarity. In view of the intentionally restricted functionality of this unit some care is necessary, as D4 may not be able to compete with an laboratory power adjusted to 30 V and 5 A. Analogue inputs RAO, RA1 and RA3 measure the level of the programming voltage and the supply voltage at the Reset pin of the host hardware. The test values are monitored in the devel- opment environment and are displayed in the “Debugger/Settings/Power” window. For absolute precision the voltage divider can be built using 1% (close tolerance) resistors. The LEDs D5 to D7 indicate the pres- ence of the operating voltage, an oper- ation in process in IC1 or a fault condi- tion. As in the Microchip ICD2, the Power LED (D7) is green, the Busy LED (D6) yellow and the Error LED (D5) red. Printed rircuitboard and Bootloader Since the single-sided PCB (Figure 2) is populated using conventional-size components with normal wire leads and is not cramped, construction is possible inside an hour, even for those less skilled at soldering. After fitting the components and making connec- tion to the host hardware as shown in Figure 3 the programming voltage on pin 2 of IC2 should measure in the region of 12.75 to 13.25 V. Precise adjustment of the programming volt- age can be made by altering R1 if nec- essary. In most cases this should not be required, since many PICs can tol- erate levels between 12 V and 14 V. If not already obtained, the current ver- sion of the development environment MPLAB IDE (version 7.40 at time of writing) should be downloaded from the Microchip homepage [1] and installed. Reply ‘no’ to the question about installing custom USB drivers, as the circuit presented in this article uses the serial interface. To enable the development environ- ment to load the PIC Controller IC1 with firmware appropriate to the par- ticular host processor being used, IC1 must be programmed with a Boot- loader. This has been taken care of already in the pre-programmed micro- controller (order code 050348-41) shown in the component list. It is also possible to program the Boot- loader into a PIC16F877 oneself. The Bootloader program BLOlOlOl.hex is part of the development environment MPLAB and can be found in the file ‘\Programme\Microchip\MPLAB IDE\ICD2’. People with no access to a programming device will find in [3] a simple circuit for the parallel port; this can be made up on vero board or hand- wired. The MPLAB Bootloader is written for the 16F877. The more recent 16F877A employs a modified programming algo- rithm and therefore requires a modified Bootloader, available on the Internet at [5] (scroll down the page until you see the word Bootloader) and elsewhere. Using the 16F877A runs a risk, how- ever, that the Debugger will stop work- ing if Microchip replaces the Boot- loader in the MPLAB development environment with a new version in a future firmware update. Ready With the circuit and programmed IC1 chip connected to the PC, the develop- ment environment can be started up. First off the ‘Debugger/Select Tool/MPLAB ICD2’ of Debugger type ICD2 is selected. In the menu ‘Debug- ger/Settings/Communication’ that fol- lows the next task is to nominate the serial interface to which the device is connected. In the same menu the Baud rate is set to 57600. A warning ‘ICD- Warn0034: Please ensure that your sys- tem’s serial FIFO buffers are disabled’ appears when the FIFO buffers have been deactivated correctly — this can be ignored. With the command ‘Debugger/Con- nect’ the development environment opens communication with the Debug- ger, carries out a self-test and displays the result in the ‘Output/MPLAB ICD 2’ window. Curiously the message ‘MPLAB ICD 2 Ready’ appears even if the Debugger is not connected. If no firmware corresponding to the host processor is present in IC1, the development environment will suggest downloading this. If the option Auto- matically download firmware if needed’ has been selected in the ‘Debugger/Settings/Status’ menu, this download takes place automatically. During the download time of about a minute the Busy-LED D6 is lit. After a renewed ‘Connect’ the develop- ment environment displays the result seen in Figure 4 with ‘MPLAB ICD 2 Ready’ on the last line. The device is now ready for use and can now be used either as a Debugger (menu choice ‘Debugger/Select Tool/MPLAB ICD2’ or as a programming device (menu option ‘Programmer/Select Pro- grammer/MPLAB ICD 2’). Practical tips The sample interface between host hardware and Debugging Module shown in Figure 3 using a host proces- sor of type 16F877 can be applied to all PIC computers that support the ICD2 10/2006 - elektor electronics 53 HANDS-ON MICROCONTROLLERS Once bug search operations are com- plete the program should be trans- ferred into the host processor in pro- gramming mode. Lastly we must point out that Microchip understandably does not offer any support for people who make their own copies of their circuitry. Instead you can consult the Elektor Electronics project page for this article, the Forum or the author’s own Home- page [7, in German only]. (050348-1) Figure 4.This message indicates the Debugger/Programmer is ready for action. Debugger and use 5 V power rails. In Debug mode the host processor requires timing signals but these are not necessary in programming device mode. The ‘View/File Registers’ option should be used only exceptionally dur- ing debugging, since otherwise the entire RAM contents are transferred across the serial interface every time the program is halted. In single step operation this leads to long waiting times between individual commands. Programs loaded into the host proces- sor in Debug mode cannot be run with- out the Debug module connected. References [1] www.microchip.com [2] www.elektronik.htw-aalen.de/sge/ labor/ICD2/ICD2-Clone.html [4] www.mcu.cz [3] www.sprut.de [5] http://icd2clone.narod.ru/ [6] www.elektor.com [7] : www.elektronik.htw-aalen.de/ sge/schuele Advertisement BvVac Electronics Cod (Hue H -i LCD illuminated ■— n itc leUe*Hn( can be Tffc rmi luhtt pfQKCU tm from Cool Blur lhi \1 LCD with (h*r serial interface,, ainipUr lest commandi can scroll dfenAay. turn bac*. kitfur on df no. powerful. CtU m SenaL LCD coniftfLe* r w4| control any HPD44780 comfUTiUr dtspLayi. i .2 or 4 lines up IK) tCitaJ fully soft wa rt GOTf i^aWc malic Baud rate rtc. Works from KSZJl port, USB to serial wwrtfr d dn ecsiy irtm 4 nvfnmMto. S*noL* twp character ie*i fommjr.m tw Ml control. Very smalt ML fit behind the display . SCrdUnvg Erii, luncro facility, and much more. IT I, DO ■'j x- * ■ ,.,*>■ * - t 4war mrf. ■ ■ ^ 1 * !J ^ \ IIHBH ■ImIh 1 )- - * l* 4«IjI Dul Mali im Iih coiouf display i ned f freeni r 31mm square, control all tULfD’i with a 4 wir e InUjerface, Lh4 n- simple mu commands. Cl 4. j 1 General ps.-ixr.i* O^ftBl-Aeulofue input output. Co y^ ,r \ sent! tvKt tal \tQ. 4df|PEri I'QamM ■nalDflur input channels, pww. £11 _0f> Control hardware using simple text commands Bee www.bvvacco,uk p DiHMiWBHi «UI*T HM » C.LIWM LE K you arr noi compiet^y Hlufrod., return IN? foods Mhin 304tyi for a ML refund. Pure halt opii&ns' On -Line ai wwh bWK.oo.uii * Telephone 07?05 734 348 email talnHibyvac .tom * Cheq« Of PoMaL Order id: ByVa£ P PO &QX 4Q49 + Pemstoiw, SHEFFIELD, S 3 h feWP PcU aud packing m E3.50 World Wide 0.50 m cap to IHEIU ShElTEMKCLUll£A: icE.fPS.tti mss COLD JR CAMERAS + DVR PACKAGE SYSTEM ShElTEMKCLUll£A: luc-r re JAr-iMA; SYSTEM 4S1. 4 COLOUR CAMERAS + DVR PACKAGE axmm urcw j« war on wtm wm * aa kiHEYCERY GESiT GCSiWATllOW PRICES Wrffi! uUttPAL SYSTEM 4 S3, 4 COLOUR CAMERAS + DVH PACKAGE fHriAHwff UFKH jWJ MfllUE DM* IWFW 4 fJff £489 r huwik, ini - it - All items jtti MVMilabfp s WjPHWJvfr** Caff flaw far i free iraw protfticf M *. » I'ab.iiT.i'M • iq *.<1 Awl it*.*, * pm ■ - — ■ ■ - TY.-jj; ^~| iic 54 elektor electronics - 10/2006 This Issue r.'i \ ■ ' A FREE ELECTRONICS SIMULATION DVD demos - trial versions - fully functional programs Next Issue: SOLDER STATIONS COMPARED 1 5 stations compared for performance Want to know everything each month? Fill out the Order Form with this issue today! Subscription rates and conditions may be found at the back of this issue. * Offer available to Subscribers who have not held a subscription to Elektor Electronics during the last 12 months. Offer subject to availability. TECHNOLOGY LAB TALK Karel Walraven It is assumed that every electronics engineer knows what is meant by ground, earth and safety earth. Nevertheless, these terms still belong to the great myster- ies in the land of electronics. Here is an attempt to lift the veil a little... 56 elektor electronics - 10/2006 Forcing current in the right direction It will not have escaped you that the human race, nor- mally speaking, stands firmly with both feet on the ground. Even those who tend to be on an esoteric plane speak constantly about 'earthing'. The worst thing that could happen to you is that you're not earthed, because then the brakes are gone and you're unprotected and subject to the whims of the surrounding elements. Fortunately it is not quite that bad in practice. You tend to survive a visit to the Eiffel Tower and even flying high above the earth to distant places appears to lead to very few problems. We can conclude from this that it is not that important where you are, as long as your environ- ment is stable. The same is true in the world of electronics when we're talking about the term ground. With the term ground we usually mean some more or less arbitrary point in a circuit. To keep this a little workable, we usu- ally take this point as the negative supply voltage or a point halfway between the positive and negative supply voltage. In our thinking we assume for simplicity that this 10/2006 - elektor electronics 57 TECHNOLOGY LAB TALK these differences as small as possible by cleverly design- ing both the circuit itself and the printed circuit board. It gets even worse when we add another symbol: earth. Now the circuit has got to be stable! We have now, after all, connected it to everything around us! That's done by using a conducting rod that we stick in the 'earth'. Too bad, but this doesn't help us much either. Flowers do quite well in this earth, but our electronics is really not going to be more stable because of this. We have to be convinced that placing the ground sym- bol doesn't really change anything and that it is there only to clarify and make it easier to think about the cir- cuit. Noise sources can (read: will) develop across sig- nal conductors; the ground conductor is made from exactly the same copper trace and the same noise will also occur in it. Let go of the idea that a circuit needs an 'earth' or a 'ground'. There are many battery powered devices that are completely 'floating' and nevertheless work quite well. We are now complete free from 'earth', we float. All interconnections in Figure 1 are cursed with a little resistance, a certain amount of self-inductance and also have some mutual capacitance. To put it briefly, they are not ideal connections, but connections as they are in the real world. The variable current (music) that runs through the loud- speaker will generate variable voltages across the con- nections through which this current also flows. So the power supply voltage to A1 and A2 is influenced and because the current also runs through ground, the ground at the minus terminal of the power supply will not be equal to the ground at the loudspeaker terminal. The resulting problems are obvious at the microphone input. Current flows through the ground connection, which results in voltage changes and these are added to the microphone signal and amplified. ground point provides us with certainty, is stable and is the same everywhere. If only it were true... In Figure 1 is drawn a very simple example that can help us to understand the phenomena that occur. There is a signal source (micr), a pre-amplifier A1 , a power amplifier A2 with a loudspeaker and finally a power sup- ply. A ground symbol is drawn is well, the short, thick, horizontal bar. Advertently or inadvertently we assume that, solely by drawing this symbol, all the parts con- nected to it are suddenly and in a mysterious way at the same potential, irrespective of changes in the surround- ing universe. The reality is different. In the first instance it is not meaningful to talk about potentials, there are only continuously changing voltages and currents. They are dynamic events. So even in the ground conductor there are differences and the only thing we can do is to make It is the current that causes the problem. Make a copy of the schematic and draw the significant currents on it. We will now draw the schematic again, but now we will try to isolate the currents as much as is possible. Just by moving the position of the connections to the power supply we already make a significant improvement, the microphone is now no longer influ- enced by the loudspeaker current (Figure 2). You can now also appreciate why the decoupling capacitor is important. This causes the variable currents to remain local and do not wander all over the circuit (Figure 3). We ultimately end up with a schematic in which the power supplies have star-shaped connections, because with this topology the mutual influence is minimised (Figure 4). For example, there is no longer an interfer- ing power supply current in the signal path between the two opamps (drawn in green). Once you've gone through this exercise, you're actually done. The layout of the PCB is easy based on the re-drawn schematic. More- over, make all loops in the layout as small as is possible (Figure 5). As we have already made clear in the 'PCB design basics' in the February 2005 issue, every PCB is a com- 58 elektor electronics - 10/2006 promise. When you have to choose, for example, whether to favour a signal conductor or another conductor then it is obvious that the trace that carries the signal has priority. Maybe this is labouring the point a bit: the return path is also a signal path, always look for signal current loops. In our example the signal return path is 'coincidentally' ground. Many designers deliberately design it this way because it is easy to think about and straightforward to make measurements. It is always a good idea for a dou- ble -sided PCB to make one side completely ground. But even then you cannot let go of the idea of a star-point ground and if necessary use separated ground planes (Figure 6). However, don't exaggerate these things, sep- arated ground planes can also act as antennas and the cure is then worse than the illness. Safety earth and screening With Class I devices, the circuit is connected to safety earth. This ensures that no dangerously high voltages can appear on parts of the circuit that can be touched. Always be very careful with this, because sizeable cur- rents can flow. This also applies to the screens of cables. Design your PCB in such a way that these types of current that you rather not have around, do not wander all over the PCB. Therefore: a separated earth plane for connec- tions to safety earth and screens and another ground plane for the circuit. Obviously these two planes have to be electrically connected, but do this at only one point so that there is no loop for current to flow. Figure 6 shows an example. All the connectors are together on an earth plane, the star-point is at the regulator 1C and from there one plane for the jiP and one plane for the power stage (the relay). ( 065099 - 1 ) Advertisement Take out a free subscription to E-weekly now Do you want to stay up to date with electronics and computer technology? Always looking for useful hints, tips and interesting offers? Subscribe now to E-weekly, the free Elektor Electronics Newsletter. Your benefits: * The latest news on electronics in your own mailbox each friday * Free access to the News Archive on the Elektor website * You’re authorized to post replies and new topics in our forum Register today on www.elektor-electronics/newsletter uvww co £ Tel. G 1 Z 98 7 D 012 PK d 1 C IMT1 Ml rE JrS-S 'Q r : I m & ji tinuM Hjmhjf i r ill S'iisjrfii Pmri Bi.arn.jii SKI FIJI. UK. "TTti'y am u«ji jJii tMiiJifurftx fttutry t/mtHfVf bern. m h Hi HjJmkihfe prict . " Rtv.Oabbi, PW litppzilitfjP LCR Analyser - Atlas LCR4& » Automatically identify and meaiun inductors. Capacrtors and Resistors * Automatic test frequency selection * Inductors from l|iH (o 1 0H ■ Capacitors from 1 pF lo 1 0.OWHiFl r Re sisters from 1il1o2M£2 ■ 1% Basic accuracy !.735*h « ,F §& Star Pack 0*1 er - Buy bcih anijfw » lot D 2D JP'd Ipijl J I r E ,J 3 Carry L||W B!Td ' WVtK iPQBVttiH 1 f Sfgmtt&ntiuClQr A naiySQf - Atlas DCA$$ m Automatically analyse most 2 and 3 leaded serin ‘s transistors. MGSFETs. JFETs. dwdes. LEDs etc... * Automatically identify al leads Conned any way! « Measures tots of parameters too, such as gam, PN characteristics. MOSFET gale Ihresholds leakage current and rnccjl more I icr+mninqtf 10/2006 - elektor electronics 59 HANDS-ON FPGA Paul Goossens Every embedded system uses a system bus to transport data between the various components. This also applies to systems implemented in an FPGA. However, a different sort of bus system is commonly used in FPGAs. This month's article introduces a bus system that is often used in FPGAs. ym h; i*whgm -ki Kim 1 r — 1 ■ A typical bus system in a ‘normal’ microprocessor circuit consists of a data bus, an address bus and several control signals, such as RD/WR. The peripheral ICs put their data on the bus when requested to do so. During the rest of the time, their inputs are in a high-impedance state to give other ICs a chance to put data on the bus. These data ports are tristate ports, which means they can be set to a high- impedance state. Different In many FPGAs, it is not possible to put internal signals in a high-imped- ance state. In addition, a mistake in the design can cause short-circuits or data corruption on the bus. Tristate ports are thus not used for the system bus in such systems. Another factor is that the peripheral electronics often runs at a different clock speed than the processor. This makes handshak- ing necessary to ensure correct data transport. Several standard system busses have been developed to avoid problems of this sort in FPGA designs. This instal- ment focuses on a system bus called the ‘Wishbone bus’, which is used quite often. It is used a lot at www.opencores.com, a handy site where you can download free designs and subdesigns. Minimum system A minimum Wishbone bus with a sin- gle master and a single slave is shown in Figure 1 . The dual data bus is clearly visible. Each bus is unidirectional - one bus carries data from the master to the slave, while the other bus carries data in the opposite direction. The STB (strobe), CYC (cycle) and ACK (acknowledge) signals provide hand- shaking for each data transmission. The slave can only respond to the Wishbone signals if the STB_I and CYC_I signals are both high. The mas- ter sets WE (write enable) high to indi- cate that it wants to write data to the slave. If this signal is low, it means that the master wants to read data from the slave. When the slave has finished process- ing the data, it signals this by setting the ACK signal high. The master pulls the STB signal low in response. The slave must then return its ACK output to the low state. This handshake protocol makes it pos- sible to connect a slow slave device to 60 elektor electronics - 10/2006 a much faster master, since the slave can set its ACK signal high sometime later. This gives a relatively slow slave enough time to process the data. Fig- ure 2 shows a read operation of this sort, in which the slave needs two extra clock cycles to complete the transaction. Example We have prepared a simple example in exl3. Here the 8051 microcontroller has a master interface for the Wishbone bus. The bus is connected to a simple slave device that enables the master to drive eight outputs. The slave interface causes the ACK signal to appear with a delay of 10 clock pulses. This makes it possible to display the handshake process using the logic analyser built into Quartus. 060025 - 5 - 11 Figure 1 . A minimum Wishbone bus with a single master and a single slave. XKTOR The processor used here (T8052) uses the Wishbone bus for all transactions with XRAM memory in the region starting at address 0x1000. The only extension unit on this Wishbone bus is an 8-bit output named wish_output. This extension also has an internal address decoder. This is normally placed in a separate bit of hardware, but for this simple example we placed it in the core instead. Seven of the eight outputs are con- nected to the LEDs on the extension board. The software causes the LEDs to light up sequentially for a ‘running- light’ effect. Internal Processing the Wishbone signals is fairly simple. The sel signal detects whether the address on the system bus matches the address of the exten- sion (0x8000). The code starting on line 63 causes the outputs to go high after a reset. When a valid address appears ( sel = T) while a valid write cycle is in progress (STB = T, CYC = T and WE = T), the data present at the DAT_I input is stored in the output register by the ris- ing edge of the clock signal. Generating the ACK signal is some- what more complicated in this case because it has to be delayed. The COUNT signal keeps track of how many clock pulses have occurred since the last write operation to this core. When the value of this counter reaches 10, ACK_OK goes high. This signal indicates that an ACK signal can be generated now. The ACK output signal is finally defined in line 101. This core also gen- erates an ACK if an invalid address is placed on the bus [sel = ‘0’). This is designed to prevent the processor from hanging if the software accidentally uses an incorrect address. Note that the ACK signal is an asyn- chronous signal. In other words, it is not generated using a flip-flop. This is one of the requirements of the Wish- 10/2006 - elektor electronics 61 HANDS-ON FPGA swnci ii JAIL I ■liWITCi -2 i ■ ■ i— ^ . i i ■ ■ f i H .- ■ AHJ_ 1 ®I -> ;isii : a r* ■ ■ ,i 3 . i" ^ r ■p Use I 10 TvPfr A i-iruT E NPUT JrjUl UU 1 l-'L E5 jo Lit : i ■ ■ ■ i LCD1 r i r I SWITCHS | ^y r 7 .1 m. . AMJ2IN ■"siwiiiitiw | ^ irtLij i - !■■[■■ ■ p 1 1 ■ -j ■ fc- - 1 - t ■ ■ . a ' 3 .1544 . £ l-U ivpe- K INPUT b NPUT bin lH ITPI > » > > . . i T " P J m §. >'iF; ?ti To | Twe -JJ A INPUT O INPUT ■ V f?IFT S\Ci?tA\ j Ol ITPI IT y ■ jr! SfeF- o ■JTF>JT | LEQ2 , . . JUID2 3U7 OUTPUT I \ LED]: hjl2 Figure 3. A simple design consisting of two YHDL files and a graphic file. bone specification. ACK must go low in response to setting STB or CYC low. Experiment In the software, we send the same value to the output 20,000 times. This slows the running light down to the point that you can observe the effect visually. ACK is delayed by 10 clock cycles in wish_output. If you increase this delay, the running light will also slow down. You can easily make this experiment yourself. Simply change line 87 of wish _out put. vhdl to the following line: IF (COUNT =200) THEN Recompile the project and load it into the FPGA. Now the running light will run quite a bit slower than before. This proves that a slow slave on the Wish- bone bus causes the master to run slower. This slowdown only occurs during read and write operations with the slave. All other instructions in the microcontroller are executed at full speed. Multiple slaves In practice, microcontroller circuits usually have more slaves than just a single I/O slave. All these slaves must communicate with the microcontroller via the same bus. This makes it neces- sary to add another piece of hardware that uses the address to determine which slave is being addressed. In exl4 the microcontroller is con- nected to two slaves. They are nearly the same as the slave used in the pre- vious example. The address input has been omitted because there is only one write register and one read register. The slave also has eight inputs. The job of the address decoder ( wish - bonejdecoder) is to pass the signals to one of the two slaves depending on the address. We use two signals for this purpose (S1_SEL and S2_SEL), which go high when the right address appears on the Wishbone bus. The cor- responding code for S1_SEL is: S1_SEL< = T WHEN ADR_I=x”8000” ELSE ‘O’; In this case address 0x8000 was selected for slave 1. A master-slave transaction can only occur when the CYC and STB signals are both high. It’s easy to generate these signals now for slave 1: S1_STB_0 < = STB_I AND S1_SEL; S1_CYC_0 <= CYC_I AND S1_SEL; The above lines of code ensure that the STB and CYC signals for slave 1 do not go high unless the slave is addressed. Finally, the data bus from the master to the slave has to be modified. If slave 1 is addressed, data must be sent from slave 1 to the master, and of course the same applies to slave 2. This is pro- vided by the following line of code: DAT_0_MASTER < = S1_DAT_I WHEN (S1_SEL=T) ELSE S2_DAT_I WHEN (S2_SEL = T) ELSE x”00”; The same considerations apply to the ACK signal. It is passed on to the mas- ter in a similar manner. Versatile The handshake protocol makes the Wishbone bus very versatile. Besides the features already described, the bus can be extended with other signals such as an error signal, it can be con- figured so several masters can drive a single bus, and so on. If you want to know more about this, you can down- load the bus specification from the Opencores website. There are also several other SoC busses. Most of them also use a hand- shake protocol, which makes it easy to implement a bridge between different bus systems. Hierarchic VHDL Up to now we have used graphic rep- resentations in our course to intercon- nect various blocks. However, you can also describe a complete design in Quartus using only VHDL. We have prepared two examples to show how this can be done in VHDL. The first example [exl5) is a simple cir- cuit consisting of two VHDL files and a graphic file. The graphic file is the ‘top- level entity’, which means it is the high- est level in the hierarchy. The purpose of this file is to couple the subdesigns to each other and link the signals to the outside world (in other words, the FPGA pins). This is the method we have used up to now in all the examples. Figure 3 shows this in schematic form. 62 elektor electronics - 10/2006 The second example ( exl6 ) contains the same design, but here the top-level document has been replaced by a VHDL file. The first statement in the exl6.vhdl file (see inset) is a standard ENTITY declaration. The inputs and outputs of this entity are ultimately connected to the pins of the FPGA, since this is our top-level document. The input and output signals of the AND_2IN subdesign are described in lines 13-19. The signal names in this description must be the same as the names used in the AND_2IN.VHDL file. The same information must be pro- vided for the OR_2IN subdesign. Next we declare the signals used in this design. The signal names are the same as the names already used in example 15. In that example, these sig- nals were drawn and labelled. In VHDL, this corresponds to signals of type STD_LOGIC. A component with the name instl is instanced in line 38. This reference is comparable to the designation TCI’ or the like in a normal schematic dia- gram. The type of component to be placed here is described after the colon ( : ). In this case it is the component AND_2IN. Finally, the inputs and outputs of this component are connected to signals starting with line 41. If you compare the two examples, the principle involved will quickly become apparent. Compatible The advantage of describing a design entirely in VHDL is that the resulting source code is compatible with other CAD programs. Such a design can thus be used with the software of a differ- ent FPGA manufacturer without too much trouble. It’s even possible to pro- duce a real ASIC using exactly the same source code. Another advantage is that it is often faster to modify a VHDL file than to make the corresponding changes in a graphic design, especially if there are a lot of signals between the various subdesigns. ( 060025 - 5 ) Web links Opencores homepage: www.opencores.org Wishbone specification: www.opencores.org/projects.cgi/web/ wishbone/wbspec_b3.pdf Listing exl6.vhdl LIBRARY ieee; USE ieee . std_logic_1164 . all; ENTITY exl6 IS PORT ( SWITCH1, SWITCH2 , SWITCH3 , SWITCH4 : IN STD_LOGIC; LED1, LED2, LED3 : OUT STD_LOGIC ) ; END exl6; ARCHITECTURE arch OF exl6 IS COMPONENT AND_2 IN PORT ( A, B : IN STD_LOGIC; OUT_S IGNAL : OUT STD_LOGIC ) ; END COMPONENT; COMPONENT 0R_2 IN PORT ( A, B : IN STD_LOGIC; OUT_S IGNAL : OUT STD_LOGIC ) ; END COMPONENT; SIGNAL INI, IN2, IN3, IN4 : STD_LOGIC; SIGNAL AND 1_0UT , AND 2_0UT , OR_OUT : STD_LOGIC; BEGIN INI <= SWITCH1 ; IN2 <= SWITCH2; IN3 <= SWITCH3; IN4 <= SWITCH4 ; instl : AND_2 IN PORT MAP ( A => INI, B => IN2, OUT_S IGNAL => AND1_0UT ); inst2 : AND_2 IN PORT MAP ( A => IN3, B => IN4 , OUT_S IGNAL => AND2_0UT ); inst3 : 0R_2IN PORT MAP ( A => AND1_0UT, B => AND2_0UT, OUT_S IGNAL => OR_OUT ); LEDl <= AND1_0UT ; LED2 <= OR_OUT ; LED3 <= AND2_0UT; END; 10/2006 - elektor electronics 63 INFO & MARKET EEDTS PRO SOFTWARE Enhanced features in Version 2.0 Main photo: RailEurope EEDTS Pro is undoubtedly a highly successful DIY model railway control system. Thou- sands of enthusiasts have used this to control their model railway. The EEDTS Pro designer hasn't been resting on his laurels though. Here we introduce you to the latest version of his control software: EP 2.0. The versatile EEDTS Pro has been with us for several years now, but it still works well with current model rail- ways because of its regular hardware and software updates. The PC control software is definitely the part of EEDTS Pro that has the shortest life cycle. In the computer world developments follow each other in quick succession, so a new version is essential every three or four years just to keep up to date. And this is the reason for the release of version 2.0. A modern program does have bigger system require- ments. In order to run version 2.0 you need a PC with 64 elektor electronics - 10/2006 Windows 98SE/ME or XP, a minimum of 256 MB RAM and at least a 1 GHz processor. Users with larger dis- plays (e.g. 1 600 x 1 200 pixels) will now be able to clearly view very large track layouts. Improvements Apart from several interesting additions, many sections of the program have been enhanced. The result should sat- isfy the needs of most digital railway modellers. Existing designs made with EP (an abbreviation of EEDTS Pro) 1 .2 can be loaded using EP 2.0, although the pro- gram lines need to be removed. The capabilities of the faster controller with version 1 .2 of the firmware really come to the fore when used with EP 2.0. As yet there is no need for an updated controller. It makes sense to wait with adapting the controller until the new Marklin System has been released and all of its features are known. The EEDTS Pro control software can be used to 'draw' a track layout onto the screen using a range of symbols. This set of symbols is sufficient to create even the most complex track layouts on the screen. This control screen looks very similar to the control panels that are in use in the railways. Even so, this program lets you design, correct and maintain layouts with ease. Apart from the on-screen control of turnouts and signals, it is also possible to control up to 240 trains, define block sections and program the running of the trains (Figure 1). Main menu There are six options on the main menu of the program: 7 . Build control panel The first step is to create the track layout by dragging a range of building block symbols onto the screen. There are building blocks for straight and curved tracks, turnouts and signals and for detector buttons. Detector buttons are rectangular symbols that are included in the track layout and which show the train address, but they can also act as the start or end point of a block section. A new feature in version 2.0 is the support for 3 types of turntable, with 8, 1 2 or 1 6 track connections (Figure 2). These turntables are usually controlled in one of 3 ways: • Time related control. • Control via an EP decoder with feedback. • Marklin turntable decoder. 2. Decoder addresses In this step the (decoder) addresses for the active compo- nents (turnouts, signals) and the (decoder) addresses for the train (address) detector modules are defined. Version 2.0 also has the facility to read the status of reed switches. This will be particularly useful to those of you who have an outdoor track in the garden. A block segment Figure 1. The new version of EEDTS Pro offers plenty of room for large track layouts. Figure 2. Three types of turntable are supported. can then be defined by reed switches at the beginning and end, which are activated by a permanent magnet. 3. Block sections From this menu option you can define block sections. You have to choose two detector buttons, which are at the ends of the block section and click on them with the mouse. When you click on everything between these two buttons, you've made your block section. The status of the turnouts and signals that are in this section block can be changed by clicking on them. In version 2.0 it is possible to get the software to gener- ate a block section automatically. After clicking on a start and end point the software will attempt to find a route between these two points. When you are adding block sections this can save a lot of time. The maximum length of block sections has been increased from 25 to 35 elements in version 2.0. 4. Soft controllers From this menu option the train decoders can be pro- grammed and a matching symbol can be chosen for the direction dependent function. From here you can choose between the new and old Motorola format. If you select the new format then you can control 4 extra functions, as well as the direction dependent function. The software can program up to 240 controllers. Since it would take up a lot of screen space to show 240 con- 10/2006 - elektor electronics 65 INFO & MARKET EEDTS PRO SOFTWARE Figure 3. This is how an IR receiver can be connected to an RS232 port. TSOP17xx SFH506-XX n 1 3 -II II* + 2 SFH506-XX TSO P 1 7XX 050373 - 1 4 K1 RS232 SUB D9 trailers (and not many people have 240 trains), we've added radio buttons that can select blocks of 20 con- trollers at a time. 5. Programming A module has been added that lets you automate the run- ning of trains with the help of a few mouse clicks. With this it is fairly easy to create shadow stations, train timeta- bles and automatic control of block sections. There is a built-in protection against train crashes. The program- ming has been implemented such that the trains deter- mine when events occur. The program lines are therefore linked to the return or detection buttons that are activated by the train. Before version 2.0 the program lines were linked to a detector button. This program acted on all trains with the result that only relatively few program lines were needed to control many trains. The disadvantage was that this setup was fairly complex and abstract. In version 2.0 the trusty method is used whereby each train has a complete program for itself. This does mean that many more program lines are needed, but since ver- sion 2.0 has improved editing facilities (you can copy&paste the program lines), this isn't really a problem. An additional advantage of this setup is that the trains are closely tracked, making it unlikely that a train gets lost. Since each train has its own program, it's possible to enable or disable these programs individually (in version 1 .2 you could only enable or disable all programs at the same time). Version 2.0 also lets you enable or disable a train pro- gram wherever a train is on the track (as long as it's in a position that occurs in the program). In version 2.0 you can now see how the train runs: when Figure 4. Remote controlled functions are show extra-large on the screen. you click on a program line you'll see on the screen where the action takes place. You'll also see the start and end points of the block section that is opened by the pro- gram line. When several program lines are selected all the affected areas will be shown. 6. Run From here the user can operate the model railway. From the screen you can operate turnouts and signals, start trains or change their direction of travel, and turn their auxiliary functions on and off. The manual control of block sections is also possible. Track occupancy is reported and the train detector shows which trains pass through. Each train can have its individ- ual program enabled or disabled. Each track layout and its properties can be stored onto the hard drive. The current state of the system is also stored at the moment you stop controlling it. If the program is used with a display that has a higher resolution than 640x480, a picture of the train can be shown on the screen when a controller is selected. This visual aid is not only pleasing to the eye, but it also makes the system easier to operate (see Figure 1). These images can be either your own photos or photos found on the Internet (jpg format). A very fascinating new feature of EP V2.0 is the infrared remote control. Virtually any TV or video remote control can be used in conjunction with a small IR receiver that is connected to a spare RS232 port (Figure 3). To add this facility to the system we've used a program called Winlirc, because it returned very good results. The functions provided by such a remote control are I : • Controlling up to 240 trains and their auxiliary func- tions • Controlling 4x100 electromagnetic functions. Because the screen is at a greater distance when the sys- tem is controlled remotely the remote functions are shown prominently on the screen, providing clear confirmation of the received commands (see Figure 4). The programming menu for the loco decoder has been expanded in version 2.0, so that every speed step of the loco decoder can be set individually. We had to remove the programming options for Lenz and Uhlenbrock decoders because it became almost impossible to keep supporting these. The EEDTS Pro software 2.0 is available on CD-ROM under number 050373-81 (refer to the Magazine and SHOP pages on www.elektor-electronics.co.uk). The CD also contains a PDF file with a full description of the software. The future We decided to release version 2.0 of the software first and consider an upgrade to the controller later, because version 1 .2 of the controller works perfectly well in con- junction with version 2.0 of the software. As we mentioned at the beginning of the article, the MFX decoder and Marklin Systems have only just been released and we don't yet know enough about the proto- cols used. However, we'll keep an eye out for further developments. ( 050373 - 1 ) 66 elektor electronics - 10/2006 DEVELOPMENT ENVIRONMENT TECHNOLOGY A modern development environment with many options Thijs Schoonbrood 1 > ■ U- ■ -4 . - ■ . ” l * y uii avi ilsrn i So you would like to start a new programming project — the whole idea is clear in your mind and you already have an eye on a programming language. But then things get harder, because which development environment will you use this time? One is too com- plicated to allow a small program to be written quickly, and another is too limited for large projects. Eclipse is a modern development environment, which is not only easy to learn but also easily expanded and suitable for the most diverse programming lan- guages. Furthermore, the package is free and open-source! Figure 1. This is what Eclipse looks like most of the time. IT 5 * ri! » ib "it ■ ■ — * jL F Jr. V-T'iF ■ } )m*mr-mm mm ■s m * ■ i IS mi ■n* liM ■ ^■■1 I BB| « I ipmi, 1 1* SL- 1 I Uti B | * pIup* « ■>] iu).^i|iiii.nn.TMilj| uqftaiH mg 11 ii|u H if«ni»> i u i j XU Inu. !' ..i i ii mi ijiiui ThiiHj iux'ii flam ii j Inapi rniId|iHiUi iai flam i i ji ui u"fBi runEaim ■. ■ ui f laflii iij liiiljji u ui ui j |il iuhbijh i.u am ii Tipi u r ii ■ ir » i Ml |P , I I iff LU kn u pa ■ IWr bu n u-i iu innlBBrM m. .B.-IBI ia IX- B r mi iljjji ri( . | U 1 -J j I ■ ■ r. IBBBBI kll |B 1 Jll Ijdl lil ■vk i !■■!<■! imi hpH !!■■■ I pikpj ui u ua i ■■m hUi ' JTT VT A* ■ Jaaii ujj|i f|i r ■■ iu ibi jii Vm I anu lpi iu Ijiii ihn triip./Bi ^KllHbUlllaHill. r JUHIMI IFlI.f B |l |K L * fa pIjBBipi UB |PI fl| . hibii ■ ibA n I i iii i inf I J .!■ ii I ■ 1 1 ki pjn f.i I m.i iml-ia ■"! a a r i < rm t vm 1-i*rrw — ■Irr -— pi . Kp .fa PI Eclipse is an open-source and platform independent soft- ware-framework for the development of rich-client appli- cations. The software is used frequently as a Java IDE (Integrated Development Environment) and is viewed by many as the best of its type. Eclipse is nevertheless also eminently suitable for other programming languages. Although IBM initiated the development, for several years now the non-profit Eclipse Foundation has continued to maintain Eclipse, with support from, among others, IBM and Borland. The current (stable) version of Eclipse is 3.1 . This one, as well as all previous versions, can be found at www.eclipse.org. The size of this package compared to other IDEs can be considered modest: a little more than 1 00 MB. This is caused, in part, by the fact that much of the functionality of Eclipse resides in separate plug-ins, which we will describe a little further on. After completing the download, we can get started imme- diately, since Eclipse does not need to be installed. Sim- ply unzip the file and Bob's your uncle! After starting the program, you choose the so-called workspace, the folder that will contain all our projects. After that we arrive at the welcome screen, where we can choose from several tutorials or examples, or go straight to work. Different perspectives We now end up at the so-called workbench. This work- bench consists of several perspectives. The idea behind perspectives is that when developing a program several different tasks can be distinguished, such as among other things, programming (creating source code), debugging 10/2006 - elektor electronics 67 TECHNOLOGY DEVELOPMENT ENVIRONMENT Figure 2. The package explorer offers an overview of all the elements in a project. (fixing errors) and adding or maintaining code from oth- ers. Because much information relating to a particular task is not pertinent to another task, it is only presented when carrying out the relevant activity (read: in the relevant per- spective). This way the screen remains uncluttered and only the relevant information is presented. Each perspec- tive, in turn, is itself built up from different views and edi- tors. An editor is usually in the middle of the screen and is used to change the code. A view gives additional infor- mation over (or the properties of) a particular part in a graphical way. Although the concept of perspectives can look rather abstract at first glance, you will get used to it quickly once you start to work with it. Within each per- spective just about everything can be configured as desired, such as the selection, position, arrangement of the different views and editors. In this way you always have the appropriate information at your fingertips that is the most relevant to you at that time. Getting started with Java Eclipse is eminently suitable as a development environ- ment for Java-applications. With this there is a central role for the Java-perspective. At the far left we find the so- called Package Explorer. This is a kind of explorer, which shows the contents of all the projects in the workspace selected earlier. Think for example about source code, graphics and configuration files, but also imported libraries and information regarding the Java Runtime Environment being used. From the Package Explorer we select which files we want to view or edit. For more information regarding the open file in the editor, we can use the outline-view. Three separate parts can be distinguished in here: at the top we can see the package that contains the class. Underneath that is a list with import declarations, which can be collapsed to make room for the rest. The last part is the most interesting of these three. It provides a detailed overview of the con- struction of the relevant class. This includes all variables and methods together with all accompanying information. A helping hand Eclipse has a feature with the name 'auto completion', which will show all relevant options within a class. It suf- fices to type the letters 'get' and hit the Ctrl key and space bar to list all the methods that begin with 'get'. And if this is not enough, a separate pop-up screen also displays the accompanying java-documentation. The handy auto-completion window is also used in a dif- ferent context, where the feature is called 'quick assist'. This is mainly useful to quickly change the code when the compiler has found an error or has issued a warning. All errors and warnings are, incidentally, also clearly pre- sented in the 'Problems'-view. With the key combination 'Ctrl-i-1 ', Eclipse immediately proposes a number of pos- sibilities for solving the problem. Tracking down errors No matter how clever a development environment is, a sizable amount of code will always contain a few errors. Once we've established that there is an error it becomes the objective to determine the cause and that is where the debug-environment comes in. Debugging is so important that a separate perspective is dedicated to this activity. By doing so, space is made available for information that is indispensable while debugging. Nat- urally we find here everything with connection to actual values of variables, breakpoints that have been set, etc. It also presents all running threads and their states. We can terminate, continue or restart threads as we please. 68 elektor electronics - 10/2006 But it gets really interesting when we start to use condi- tional breakpoints. Want a breakpoint in a loop that activates on the seventh iteration? Not a Problem! Or only when a variable has a predetermined value? That is also possible. Cooperation with version control Programmers who work on projects with other develop- ers generally make use of some form of version control system. The option of storing the different source code versions at a central location is then essential. The sys- tem that is used most frequently for this is the so-called Concurrent Versions System, better known as CVS. This is supported natively by Eclipse; there is a special per- spective for the management of CVS-repositories. In addition to the usual checking out and synchronising of projects, this perspective is also used to manage tags and branches. Using an external diff-application is redundant, because this functionality is also built into Eclipse, just as there is also a view to display the resource history of a file. The management of tags and branches is child's play. Plug-ins for additional functionality As was already mentioned earlier, the functionality of Eclipse can be enhanced with plug-ins. There is a large selection of plug-ins available and these can be roughly divided into two categories. The first category com- prises a relatively small number of plug-ins developed under the banner of the Eclipse organisation. In this cat- egory belong, among others, the C/C++ and Visual Editor plug-ins, which will be discussed a little further on. These can be found at www.eclipe.org/tools. The second category is much larger and contains all the third-party plug-ins. Many of these plug-ins are able to keep themselves up-to-date with the aid of the built-in update-manager of Eclipse. C for yourself An IDE only becomes really interesting to developers when it is able to handle multiple programming lan- guages without loosing much of the functionality. That is why within the Eclipse Foundation the CDT project (C/C++ Development Tools) has sprung into life (you can find details at www.eclipse.org/cdt). As the name implies, this plug-in changes Eclipse into a development environment that knows how to deal with C and C++ code. This means that once again we can make use of the functionality of CVS, the debugger, auto completion, etc. In contrast to developing in Java, this plug-in does not provide a built-in compiler. This is of course a little bit more complicated with C and C++ considering the strong platform dependency. If you work in Linux, then there will almost never be a problem. Just about every distribution contains a version of GCC (GNU C com- piler), which can be used by Eclipse without any trouble. Via CygWin (http://cygwin.com), GCC together with a selection of other Linux-features can be used in Windows. If you're not that keen on all that Linux-functionality, then MinGW (www.mingw.org) may be a good alternative. User-interface illustrated with the Visual Editor If you build many applications in Java, you will then also regularly have to design and implement a GUI (Graphical Figure 4. Just on the plug-in website of Eclipse alone we can find nearly 1000 plug-ins. User Interface). Of course, you could do this in the same way as any other programming task: enter all the code yourself and frequently check the result by running the application. But particularly when implementing graphical elements the so-called 'What you see is what you get'- method (or: WYSIWYG) is quickly becoming popular. This approach makes it possible to assemble the GUI in a graphical interface, while at the same time the correspon- ding source code is generated in the background. In Eclipse this functionality is contained in the plug-in called Visual Editor (VE) (seewww.eclipse.org/vep). Finally As you have seen, it is possible to use Eclipse for a wide range of tasks and programming languages. And we didn't even mention COBOL, PHP, designing with UML/UML2 or database development. All these projects are free and are continuously being developed further. In this way there is practically always a configuration of Eclipse available that meets your requirements. And in the unlikely event that this is not the case, you can always just develop a plug-in yourself. ( 060018 - 1 ) H-3 ^Ck+I CJC— Dmi-rtiNr om l p