www.elektor.com September 2009 AUS$ 13.90 - NZ$16.90 - SAR 99.95 £4.65 electronics & microcontrollers The Most Popular 8-bit Microcontrollers! The Best Customer Support. The world's most popular 8-bit microcontroller family has the best customer support and the industry's shortest leadtime - 3-4 weeks! 24/7 Support With over 400 different variants, there is an 8-bit PIC® microcontroller for every design. Microchip's 8-bit family now includes microcontrollers with the smallest form-factor, industry-first peripherals and up to 16 MIPS performance. • Only Microchip offers full support 24/7 • Increased Field Application Pin- and code-compatibility ensure easy migration across the 8-bit family and up to 16-bit designs and Microchip's MPLAB® IDE is absolutely free, and supports ALL of Microchip's 8-, 16-, and 32-bit microcontrollers — from 6 to 100 pins! Engineer support team • Increased Customer Application With over 7 Billion PIC microcontrollers shipped worldwide and increased investment in product development and customer support, you can count on Microchip to be here for you - especially through the tough times. Comprehensive support starts with the Microchip Advanced Part Selector (MAPS) and extends throughout the design cycle with free or low-cost development tools, online and regional training and 24/7 technical support. • Smallest form-factor, lowest cost - PIC10 and PIC12 MCUs • Advanced peripherals - PIC16 MCUs • Highest-performance - PIC18 MCUs Engineer support team • Increased Customer Training Support through Regional Training Centers (RTCs) HereSHelp YOU Now&Tomorrow... d For the best product support and availability - think Microchip! microchip www.microchip.com/8bit & Microchip The Microchip name and logo, the Microchip logo, MPLAB and PIC are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. All other trademarks mentioned herein are property of their respective companies. © 2009, Microchip Technology Incorporated. All Rights Reserved. ME223Eng/02.09 Microcontrollers Digital Signal Analog Serial Controllers EEPROMs DISCOVER THE FUTURE WITH ERSYPIC6 Everything you’ve always wanted from a development tool Experience the ease of creating your own electronic devices! Thanks to many new features, you can start creating your own devices immediately. EasyPIC6 supports 8-, 14-, 18-, 20-, 28- and 40- pin PIC microcontrollers. The mikrolCD (Hardware In-circuit Debugger) enables very efficient step by step debugging. Examples in C, BASIC and Pascal are provided with the board. H-CInCLUT "rrrir rtf n Hardware In-Circuit Debugger for step by step debugging at hardware level Port Expander provides easy I/O expansion (2 additional ports) using serial interface Full-featured and user-friendly development board for PIC microcontrollers High-Performance USB 2.0 On-Board Programmer On-Board 2x16 Serial LCD Display Keypad enables easy and fast data entry L\V ■ ir i ■ ON SALE NOW! pQ|_g Find your distributor: http ://www. m i kroe . co m/e n/d i str i b utors/ mikroElektronika SOFTWARE AND HARDWARE SOLUTIONS FOR THE EMBEDDED WORLD www.mikroe.com lekto r electronics & microcontrollers Electromobile This month's focus is on automotive and I believe the subject is covered from a number of interesting angles. The main project, for example, is our new pocket-size OBD2 Analyser with an extensive range of features. Fully DIY to Elektor standards, the instrument should be compatible with all modern cars having OBD connectivity. The built-in analyser will faithfully read and display engine data and any error codes you or Edd the mechanic will want to clear by matching repair work on the vehicle. A graphic display ensures a clear readout with plain-language descriptions. Those of you keen to use Google Earth, a regular USB memory stick and your PC to trace the actual route you have followed by car, bike or on foot will find the GPS Datalogger on page 30 an awesome project, if only because it's modular and the software is ever so easy to adapt to personal requirements. RU ready boots (or wheels)... start logging! The article on technological develop- ments in electric cars concentrates on energy sources available (and desir- able) to power these vehicles. Which sources are likely to be used by future generations and what are all these car and battery manufacturers doing in their labs and on their test tracks? Our ElektorWheelie self-balancing electro scooter is covered in two articles, one on the mechanical assembly of the kit parts and your careful first attempts to ride the vehicle, and another on a symmetri- cal battery charger developed as a premium alternative to the charger normally supplied with the kit. Of course, it's not all vehicles and batteries in this issue. With all 'wheels' safely parked or connected to a charger, why not play a game of chess against our ATM1 8 Mini Chess Computer, or explore how an R32C microcontroller drives an OLED display. Finally, I'm happy to announce a new four-page section in Elektor called E-Lobs Inside. These pages are firmly positioned in the centre of the maga- zine, just like the real Elektor Lab is at the centre of our publications and many of our products. E-Labs Inside reports on what our lab staff have run into during the month — you can expect to read about techie problems and workarounds, equipment to drool on, gizmos, burnt PCBs, techno-gos- sip, tips and tools of the trade. Happy reading! 1 6 The Road to Battery Power Development of electric vehicles continues apace and the enormous potential is clear. The key to the success of electric vehicles lies, contrary to early expectations, in lithium-ion cells rather than in fuel cells. This article has an overview of current and future technologies. 22 OBD Analyser NG The compact OBD2 Analyser in the June 2007 issue was an enormous success. Now, it's enhanced with a graphical display, Cortex M3 processor and an Open Source user interface, the next generation (NG) of Elektor's standalone analyser sets new standards for a DIY OBD2 project. MENU s tart Diagnose System Information [ Configuration CONNECTING lUTM-Wf-H iTfciJ 5^ iso-91 WKWP?enn sk ">!f I Wlj. m . JlfiGNOSE MENU 3-ISO j i \ 1 T Sensor Data DTOO £1*1:10 i , r roublecodes Vehicle Identification + Jan Buiting Editor CONTENTS Volume 35 September 2009 no. 393 30 GPS Datalogger This project allows you to log the path of a bike or car trip and load the data into GoogleEarth™ using a common USB memory stick. The hardware is based on the famous Parallax Basic Stamp and open for further development. 22 30 36 48 54 58 64 68 72 16 roiects OBD Analyser NG GPS Datalogger R32C Application Board Battery Monitor ATM 18 Mini Chess Computer Getting Started with Em- bedded C (part 3, final) ElektorWheelie construction and driving Power Charger for ElektorWheelie Design Tips: Quantum Die technolo The Road to Battery Power 48 Battery Monitor E-labs inside 43 Ad irt cheap mobile phone 44 Double-sided soldering in reflow oven! This circuit can be used in any application where batteries are charged and discharged. The circuit uses an LPC2103 microcontroller connected to a 22-bit A/D converter to measure charge and discharge currents, battery voltage, charge status (or available capacity) and the instantaneous power being supplied to or drawn from the battery. Til take it" Yokogawa 2054 oscilloscope info & market 6 Colophon 8 Mailbox News & New Products Elektor PCB Service — FAQ 80 Elektor SHOP 84 Coming Attractions infotainment 76 Hexadoku 77 Retronics: Leak coaxial trough-line VHF FM stereo tuner (1 962) ELECTRONICS WORLDWIDE elektor international media Elektor International Media provides a multimedia and interactive platform for everyone interested in electronics. From professionals passionate about their work to enthusiasts with professional ambitions. From beginner to diehard, from student to lecturer. Information, education, inspiration and entertainment. Analogue and digital; practical and theoretical; software and hardware. Volume 35, Number 393, September 2009 ISSN 1 757-0875 Elektor aims at inspiring people to master electronics at any personal level by presenting construction projects and spotting developments in electronics and information technology. Publishers: Elektor International Media, Regus Brentford, 1000 Great West Road, Brentford TW8 9HH, England. Tel. (+44) 208 261 4509, fax: (+44) 208 261 4447 www.elektor.com The magazine is available from newsagents, bookshops and electronics retail outlets, or on subscription. Elektor is published 1 1 times a year with a double issue for July & August. Elektor is also published in French, Spanish, American English, German and Dutch. Together with franchised editions the magazine is on circulation in more than SO countries. International Editor: Wisse Hettinga (w.hettinga@elektor.nl) Editor: Jan Buiting (editor@elektor.com) International editorial staff: Harry Baggen, Thijs Beckers, Eduardo Corral, Ernst Krempelsauer, Jens Nickel, Clemens Valens. Design stct Antoine Authier (Head), Ton Giesberts, Luc Lemmens, Daniel Rodrigues, Jan Visser, Christian Vossen Editorial secretariat: Hedwig Hennekens (secretariaat@elektor.nl) Graphic design / DT Giel Dols, Mart Schroijen Managing Director / Publisher: Paul Snakkers Marketing Carlo van Nistelrooy Subscriptions: Elektor International Media, Regus Brentford, 1000 Great West Road, Brentford TW8 9HH, England. Tel. (+44) 208 261 4509, fax: (+44) 208 261 4447 Internet: www.elektor.com/subs 6 elektor - 9/2009 Elektor PCB Service y Your professional PCBs and Prototypes Elektor PCB Service is a new service from Elektor. You can have your designs converted into a professional- quality PCBs via the www.elektorpcbservice.com website. Elektor PCB Service is intended for prototype builders and designers who want to have their PCBs made to professional standards, and for users who want customised versions of Elektor PCBs. If you need a couple of y protos' with fast turnaround or a batch of 5 to 50 units, we can meet your needs at a favourable price. r J B 1 ■ T ^ * L — J "JH ■ I l ’ M The advantages at a glance • The PCBs are professional quality. • No film charges or start-up charges. • There is no minimum order quantity or charge for this service. • Available to private and commercial customers. • Well first check if your project is producible. We'll let you know within 4 hours! • In order to supply two PCBs, we make three. If the third board is also good, you receive it as well - free of charge. • You can use our online payment module to pay easily, quickly and securely with Visa or Master- Card. Procedure: Create Place your account . your order Your project is checked Payment Your order is shipped lektor PC B Stpvlct Now available for everybody at www.elektorpcbservice.com Email: subscriptions@elektor.com Rates and terms are given on the Subscription Order Form. Head Office: Elektor International Media b.v. P.0. Box 1 1 NL-61 1 4-ZG Susteren The Netherlands Telephone: (+31 ) 46 4389444, Fax: (+31 ) 46 43701 61 Distribution: Seymour, 2 East Poultry Street, London EC1A, England Telephone:+44 207 429 4073 UK Advertising Huson International Media, Cambridge House, Gogmore Lone, Chertsey, Surrey KT1 6 9AP, England. Telephone: +44 1932 564999, Fax: +44 1932 564998 Email: r.elgar@husonmedia.com Internet: www.husonmedia.com Advertising rates and terms available on request. Copyright Notice The circuits described in this magazine are for domestic use only. All drawings, photo- graphs, printed circuit board layouts, programmed integrated circuits, disks, CD-ROMs, software carriers and article texts published in our books and magazines (other than third-party advertisements) are copyright Elektor International Media b.v. and may not be reproduced or transmitted in any form or by any means, including photocopy- ing, scanning an recording, in whole or in part without prior written permission from the Publisher. Such written permission must also be obtained before any part of this publication is stored in a retrieval system of any nature. Patent protection may ex- ist in respect of circuits, devices, components etc. described in this magazine. The Publisher does not accept responsibility for failing to identify such patent(s) or other protection. The submission of designs or articles implies permission to the Publisher to alter the text and design, and to use the contents in other Elektor International Media publications and activities. The Publisher cannot guarantee to return any mate- rial submitted to them. Disclaimer Prices and descriptions of publication-related items subject to change. Errors and omissions excluded. © Elektor International Media b.v. 2009 Printed in the Netherlands 9/2009 - elektor 7 INFO & MARKET MAILBOX ■ ■» * • - I - - - r * i-P. »> ' Invasion of the Trochotrons In response to my call for information on ' trochotron ' tubes in Mailbox , April 2009, I received the following email from Elektor reader Nick de Smith. Hi Jan — Regarding the note in Elektor April 2009, I have several examples of an Haydu 6700 (NIB), Burroughs BD-301 & BX-1000 (NIB with original data sheets). I'm perfectly happy to lend you a bunch of these — if you want to light them up, please have a go — they are not very expensive, just a bit rare — they are so esoteric that collectors haven't yet forced the price too high... I'll have my office ship some later this week — I'm just pleased they will be used... A selection of the trocho- trons kindly sent by Rick is pictured here: a VS10B from TEL (red plastic encap- sulated device), a BD-301 from Burroughs (light metal encapsulated device) and a BX 1000 ' Beam-X ' from Burroughs (bare tube). The VS10B was noticed for its very strong mag- nitc field. A further response was received from Roly Roper, a long standing Elektor reader from Melbourne, Australia: Dear Jan — the name 'Trochotron' derives from the trochoidal (spiral) path the electrons follow in crossed magnetic and electrostatic fields, and is confusingly applied to at least three different devices; some forms of mass spectrometer, non-dis- playing decade counters, and one displaying counter. Trochotron counters are hard vacuum cathode-ray Beam Switching Tubes which were initially developed for telephone service c. 1 950 where they seem to have been used as ten- way analogue switches, possibly as (de)multiplexers, but soon evolved into the fastest counting devices available. The speed of gas tubes is limited to kilocounts/s by the long de-ionisation time, while vacuum tubes are mainly limited by inter-electrode capacitance allowing Mc/s operation. Their main application as counters seems to have been in neuclion- ics, so while cross-licensed to other manufacturers most were something of a 'special' only produced in limited numbers. With a single exception these tubes came encased in a strong ring magnet [1] and require special handling and mounting [2]. Because of their magnetic fragility it is unlikely that any of this type are still functional. The unique excep- tion is the El T which is fully electrostatic (thus has no magnet and is as robust as any valve), and displays as well as counts. Developed at Philips Netherlands it featured in their PW4032 Counter. [3] Ronald Dekker's excellent website [4] has extensive information on the history, development, operation, and application of the El T. Contrary to some opinion, Ronald shows these are not particularly difficult to drive, and his 40-year-old samples still work perfectly. It is worth noting his efforts to preserve these rare historic items in working order, such as using a reduced voltage constant-cur- rent heater supply. As it happens I do still have the four GS10C decatrons (deka- trons?) with sockets, and four E1T trochotrons I bought from Proops over 40 years ago with the vague teenage dream of building an 8-digit counter/scaler. Instead I took only 25 years to finish my TTL+Numitron [4] counter that still serves on the bench. 1. www.tubecollector.org/vs 10g.htm 2. www.ekco-radar.co.uk/hubbard/nucleonics.php 3. www.es. ubc.ca/~hilpert/e/edte/PhilipsPW4032/index.html 4. www.dos4ever.com/trochotron/TROCH.html V & I Calibrator challenged Hi Elektor — I'm impressed with the simple voltage/current calibrator in the May 2009 issue, and plan to build one. A note of caution though: com- bining multiple high precision components (in this case each with 0.1% precision) inevitably results in a net precision which is significantly degraded. The extent of the lost precision depends on the statistical dis- tribution of the errors, but as a simple example, combining 4 components (e.g. the voltage reference, R2, R3 and R5) each of which is 0. 1 % away from its nominal value could (if unlucky) result in a 0.4% error; more generally an error of approximately 0.2% could be expected. Another point is that the nominal values for the 1 .9 V resistor divider actually deliver a voltage which is about 1 .7 mV too high (i.e. almost 0.1 %). But all in all a very nice little circuit! Neill Conway (UK) The author of the article , Dr Tho- mas Scherer, responds: Although accuracy is a nice subject for really long discus- sions, it is also within the realms of calculation. It is, after all, not that simple. I will give it a try. Theoretically, tol- erances add up in worst case conditions. For the voltage, the effect is most pronounced at 1 .9 V. The 'worst case' then translates into R2 being R2+ 0. 1% or 3.9039 kQ, and at the same time the sum of R4A and R4B -0. 1 % off the mark, 1. e. at 3.37662 k Q instead of 2.7 kQ + 0.68 kQ = 3.38 kQ. Now we stir in a -0. 1 % error on part of the LM4050 supply- ing 4.09 1 904 V, causing a reference voltage of 8 elektor - 9/2009 4.091904 V/ 7.28052 kQ x 3.37662 kQ = 1.89777203 V resulting in an error of 1.9 V/ 1.89777203 V-l = + 0 . 1171263 % Conversely, with the LM4050 deviating +0.1% = 4.100096 V, R2 at -0.1% = 3.8961 kQ and (R4A + R4B) at 0. 1 % = 3.3838 kQ we get 4.100096 V/ 7.280523904 kQ x 3.3838 kQ = 1.901575537 V instead of the desired 1 .900000 V; an error of 1.9 V/ 1 .901 575537 V = - 0 . 08285432 % A far cry from the dreaded 0.4% and proving how dull theory can become when it is oversimplified = incorrectly used. For the sake of completeness the worst case offset voltage of the op amp should be calculated in (max. 1.2 mV). The negative error then becomes 1 .89657203 V (-0.14586781%) and the positive error, 1 .902775537 V (+0.1 807456%). Only with the current measure- ment (/), the worst case error is cumulative and would amount to total positive and nega- tive errors of +0.343% and -0.308% respectively. All this is based on a worst case scenario. In reality differ- ent values can be expected, the tolerance on the compo- nents follows the Gaussian (bell) curve and an overall tolerance of 0.035% is safe to assume. Now we also need to con- sider that statistical errors do not add linearly. As a rule of thumb, two sources E and E k with the same error produce a cumulative error E as in E + E, = 1 .4 E a b Realistically the error at 1 .9 V should be of the order of ±0.06% (estimated, not cal- culated), because the typical offset voltage of the op amps is 0.22 mV, equating to an error of 0.01 3%. For the / (current) calibra- tor, we should anticipate an error of 0.08%, which for all practical purposes becomes the typical error. Extremes may occur, naturally, but still within the bounds described above. Memory effect in Hi-Fi audio transistor amplifiers Dear Sir — the Lavardin Technologies IT Hi-Fi amplifier was introduced in 1997 and has achieved worldwide rec- ognition as an amplifier with incomparable performance. Lavardin claim the perform- ance was achieved by the removal of memory effect from their design. I have checked with five of the major manufacturers of high performance audio transis- tors and none of them know anything about memory effects in silicon. I have attached two papers from the Audio Engineer- ing Society (AES) describ- ing memory effect and its measurement. The Lavardin products have the part numbers removed from the transistors and ICs, and other parts of the circuits are potted. Do Elektor engineers have any knowledge of memory effect? Would Elektor like to develop a test arrangement for the measurements of memory effect? Dr Louis D Thomas (USA) Neither of our in-house audio experts Harry Baggen and Ton Giesberts was aware of Lavar- din's claim or the phenomenon it is reportedly based on. Considering the publication date of the articles and the fact that no widespread discussion appears to have been triggered , at least not in JAES, we are lead to believe that it's a market- ing ruse and audio enthusiasts can not be bothered. None the less we are inviting interested readers to respond with their viewpoints. Robohockey Dear Editor — I write regard- ing an article published in Elektor's April 2009 edition called 'OkISEC: Multiplayer Online Robohockey'. The credits printed are some- how incomplete because there where six persons involved in the project, the ones listed in the article plus Nuno Paiva, Daniel Bastos and myself. In the paper submitted to a • Publication of reader's orrespondence is at the discretion of the Editor. • Viewpoints expressed by correspondents are not necessarily those of the Editor or Publisher. • Correspondence may be translated or edited for length, clarity and style. • When replying to Mailbox robotics conference the project was originally named HorolSEC but we changed the name after a professor's suggestion. At http://horoisec.07x.net, if you follow the link to the team ('Equipa' in Portuguese) every- one who worked on the project is duly listed. Ricardo Faria (Portugal) Thanks for that Ricardo , credit's due where credit's due. correspondence, please quote Issue number. • Please send your MailBox correspondence to: editor@elektor.com or Elektor, The Editor, 1 000 Great West Road, Brentford TW8 9EHEH, England. Corrections & Updates 7 / .MU mv « : Data Logger "deluxe March 2008, p. 26-31, ref. 070745 The firmware for this project has been upgraded to version 2.00. The new version has a number of bug fixes and adds some new functions, including a programmable recording interval (1 to 9999 seconds or 1 to 9999 minutes), and sup- port of the CSV file format. A summary of modifications and enhancements is contained in the download found on the project webpage at www.elektor com/070745. Bathroom Fan Controller July & August 2009, p. 97, ref. 090078 The value of R5 is erroneously shown as 1 kQ and should be changed to 1 00 kQ for the circuit to operate properly. r LM335 IC2 = LM358 IC3 = LM393 MailBox Terms 9/2009 - elektor 9 INFO & MARKET NEWS & NEW PRODUCTS Digital radio tuner for DAB and FM signals integrates fast RSSI Maxim Integrated Products recently introduced the MAX2172 dig- ital radio tuner for FM and dig- ital audio broadcast (DAB) sig- nals, with a high sensitivity for the FM, VHF, and L-band frequency ranges. This device integrates all components necessary to imple- ment a complete tuner solution, including LNAs, mixers, an IF fil- ter, and a fully synthesized local oscillator. Additionally, the 1C inte- grates a front-end tracking filter to eliminate interference between the UHF, VHF, and FM bands. An on-chip received-signal-strength indicator (RSSI) and temperature sensor ensure fast, accurate scan and seek functions. The RSSI pro- vides ±2 dB accuracy and outputs the measured level in digital form through the l 2 C bus. FM sensitivity is an outstanding -1 1 ldBm (typ), and FM adjacent-channel perform- ance meets ETSI EN 55020. Draw- ing 61 mA (typ.) from a single 3 V supply, the MAX2172 strikes an excellent balance between per- formance and power consumption, making it ideal for consumer and automotive applications. The MAX2172 utilizes a standard 2.048 MHz IF frequency that is compatible with most DAB digital demodulators. The device is pack- aged in a lead-free, 6x6 mm, 40-pin TQFN, and is fully speci- fied over the -40 degrees Celsius to +85 degrees Celsius extended temperature range. An evaluation kit is available to speed designs. http://www. maxim-ic.com/IVlAX2172 (090568-11) Parallax TSL1401-DB Linescan Imaging Daughterboard The Parallax TSL1 401 -DB Linescan Imaging Daughterboard provides one-dimensional sight to almost any microcontroller. It is designed for plug-in compatibility with Paral- lax's BS2pe Motherboard but can be used with other Parallax BASIC Stamp modules, the Parallax Pro- peller, the SX, PICs, and AVRs, to name just a few. It is a platform suitable not only for evaluating the TAOS (Texas Advanced Optoelec- tronic Systems) TSL1401R linear array sensor, but also for incor- poration into enthusiast's, robotic, laboratory, and educational platforms. The TSL1401-DB includes the TAOS TSL1 401 R 1 28-pixel sensor chip, a 7.9 mm focal length imaging lens, and control electronics to aid in capturing images for evaluation. It produces a clocked analogue data output, whose voltage levels correspond to the light intensity at each pixel. By means of an ana- log ue-to-digita I converter (or just a digital logic threshold), image data are easily transferred to a microcontroller to detect objects, follow lines, locate flames, ana- lyse motion, and read simple barcodes. Com- bined with Par- allax's BS2pe Motherboard, Board of Education, or BOEBot, and the free down- loadable software, a com- plete imaging system can be built sim- ply and eco- nomi- cally. The TSL-1401- DB retails at $49.99. www.parallax.com (search "TSL1401") (090568-III) 10% off micro RFID Module for Elektor readers APDanglia have announced the release of the RFIDREAD series of three low cost 125 kHz RFID reader/writer modules including a PCB with RS232 and one R/ mically add an RFID rea- der/writer to their own products without the need for lengthy research and development cycles. W PCB with UART tx/rx ttl O/P. Intended for OEM's and enthusi- asts alike, these small profile modu- les complete with built in antenna allow users to quickly and econo- Each module comes com- plete with a simple to use set of commands for per- forming the standard functions required for accessing the popular EM4100 and T5557 transponders avai- lable on the market. Dimensions of the fully encapsulated microRFID module are only 25x25x1 0mm inclu- ding antenna. Mounting to a PCB is via convenient .1" pin out header. These modules are ideal for all embedded applications. For a limited period only APD are offering Elektor readers a generous 10% introductory discount on these pro- ducts. To take advantage go to the /offer url below. A free R/W software download and more details of all their RFID products are available at ADP's homepage. www.apdanglia.org.uk/ offer.html www.apdanglia.org.uk (090568-IV 10 elektor - 9/2009 Norfolk Amateur Radio Club wins prestigious award training Norfolk Amateur Radio Club (NARC) has won a prestigious national award from the Radio Society of Great Britain (RSGB) for its amateur radio and electron- ics training programmes. The club was presented with the RSGB's Kenwood Trophy for out- standing contribution to amateur radio training at the society's AGM in Newcastle. NARC holds its meetings at Eaton CNS School in Norwich on Wednesday evenings and runs Foundation, Intermediate and Advance courses for prospective radio hams, typically 5-6 a year. It also runs a 'Bright Sparks' pro- gramme to teach youngsters to sol- der and build electronic circuits, and many have gone on to get their full amateur radio licences. The RSGB were so impressed with Bright Sparks that they may use it as a model for a nationwide initiative. Other activities include direction- finding foxhunts where members have to track down hidden trans- mitters with equipment they have built themselves, special event sta- tions where contacts are made with other radio amateurs around the world and an annual two-day Radioactive Weekend with lec- tures, hands-on sessions, a barbe- Unofficial Propeller Expo West June 27th and 28th 2009 marked the first West Coast Unof- ficial Propeller Expo (UPE) event. This event held at Parallax Inc. in Rocklin, California was full of exciting projects, presentations, and the highly innovative, good- natured users the Propeller chip naturally attracts. The 'unofficial' expo is the brain child of Jeff Ledger, a Propeller customer and active Parallax forum member, known as 'OBC' (Oldbitcollector) on the Parallax Propeller Forum. In 2008 Ledger came up with the Propeller expo as a way for Propeller fans and like minds to get together to show off their latest projects. "When I started this, I figured we might find 30 people to meet for an afternoon to eat pizza and dis- cuss Propeller projects" says Ledger. Fast forward to a year later and the expos are now wildly popu- lar. Over 150 people from around the world attended the West Coast Expo at Parallax, still jok- ingly referred to as "unofficial." The event attracted people ages 1 0 years to 60+ whose experience ranged from the hobbyist to the Ph.D. The presentations were awe- some examples of the flexibility of the Propeller chip. Everything from autopilot flight controls, microcom- puter systems, robotics, and sailing was presented. The level of excite- ment around each project and presentation was intoxicating. In a not-too-distant room, attend- ees were greeted with free Pro- peller boards from SchmartBoard (www.schmartboard.com) and were encouraged to sit down and solder up their own surface mount Propeller chip using this easy-to-use system. A live webinar with Chip Gracey (President, Parallax Inc.), Jeff Martin (Software Engineer, Par- allax Inc), and Hanno Sander (Pres- ident, MyDanceBot.com), included both present and remote attendees and was aimed at answering many questions covering a wide range of Propeller topics. Announcements on future UPE events, videos and more pictures of Propeller Expo West may be found at the website below. The Piezo speakers replay music and voice with flat frequency response The latest addition to Mu rata 's family of piezoelectric ceramic speakers is ultra-thin, just 1 .2 mm in thick- ness, with side ven- tilation in its sturdy metal housing help- ing to keep the thickness down. The VSLBP1 91 3E series' unique rectangular shape improves its frequency response and minimises 'dead-space' in handheld devices. The series' flat frequency response makes it suitable for the replay of voice and music in today's thin and stylish mobile phone handsets. Since piezoelectric ceramic speaker actuators have no mag- netic parts such as magnets or coils, they are almost entirely EMI- free. Moreover, as piezo speakers are primarily a capacitive load, they can dramatically reduce power consumption, especially in the voice band. Frequency response of the new rectangular speakers is much improved over circular diaphragms as the rectangular ones are multi- modal - multiple oscillation modes can be generated along the long and short sides of the diaphragm, to create as many 'peaks' on the frequency axis as possible. Another improved feature of the next expo will be hosted in Norwalk, Ohio on Saturday, August 22 nd , 2009. As on the West event, every attendee will receive a free copy of Elektor USA magazine. www.Parallax.com / event (090568-1) VSLBP1 91 3E series is the soft and flexible resin film the diaphragm is mounted on. This film reduces the primary resonant frequency and damps resonant characteristics of the piezo ceramic, contributing to flattening the frequency character- istic. The diaphragm's multi-lay- ered piezo ceramic construction creates powerful sound, up to a sound pressure level (SPL) of 90 dB maximum (measured at 1 kHz, 5.0Vrms, sine wave, at 0.1 m, 0 dB:20 |jPa). www.murata.eu (090568-IX) 9/2009 - elektor 1 INFO & MARKET NEWS & NEW PRODUCTS Nl uses Xilinx FPGA technology for hands-on learning National Instruments has intro- duced a digital learning device that gives high school, university and vocational students hands-on experience with digital logic and field-programmable gate array (FPGA) technology. The Nl Digital Electronics FPGA Board, which integrates with the Nl Educational Laboratory Virtual Instrumentation Suite (Nl ELVIS) II and Nl ELVIS 11+ educational design and prototyping platforms, combines analogue and digital design instruction into one affordable, easy-to-use platform. When combined with Nl ELVIS, this system eliminates the need for multi- ple sets of instrumentation to teach analogue and digital electronics concepts, thus saving money and space for educational institutions. The new board is a result of the Nl collaboration with Xilinx, the world's largest supplier of pro- grammable logic devices and inventor of FPGA technology, and has already been slated for adoption by Project Lead The Way (PLTW), one of America's leading provid- ers of pre-engineering and science curricula. The FPGA-based hardware is designed to be programmed with both the Nl LabVIEW graphical programming environment and Xilinx ISE tools. With its adoption by PLTW, the FPGA board will be incorporated into U.S. high school technology curricula, and thou- sands of students will gain expe- rience that correlates directly to real-world industrial and scientific applications of FPGA program- ming. The board's widespread adoption, ease of use and cost- effectiveness make it ideal for engi- neering education. The centrepiece of the Nl Digital Electronics FPGA Board is a Xilinx Spartan- 3E FPGA, which can be programmed using either Nl LabVIEW or the Xilinx ISE webPACK, a free, downloadable software toolkit. Through the Nl Developer Zone, educa- tors can view related tuto- rials and download free curricula written to use with both LabVIEW and Verilog. Readers can view a webcast about the Nl Digital Electronics FPGA Board at the url below. www.ni.com/defpga (090568-V) RoweBots: ultra-tiny embedded-Linux™ RTOS for Renesas micros Waterloo, Canada based RoweBots Research, Inc. recently released DSP- nano, Version 2, and Unison™, Ver- sion 4. These two ultra-tiny embedded- Linux compat- ible RTOSs open Renesas Technology Corp.'s R8C, M16C and R32C/100 microcontroller (MCU) families to Linux and POSIX compatible development for the first time. DSPnano is the functional equiv- alent to an ultra-tiny embedded- Linux RTOS for Renesas' 8- and 16-bit MCUs, including the R8C and M16C. DSPnano, used with the HEW IDE, increases embedded development productivity and reli- ability. Typical appli- cations range from tiny printer engines to demand- ing automotive control. Unison, the 32-bit RTOS, is ide- ally suited to home automation and networking applications. Uni- son increases embedded develop- ment productivity and reliability for R32C/100 developers by sub- stantially reducing the difficulties of developing complex systems. Com- plete networking protocols are also available. The ultra-tiny Linux offerings provide seamless support including: • Integrated MCU RTOSs with full POSIX and Linux capabilities in a tiny footprint to minimize training time and processor size • Risk mitigation • Free development and source code • Complete off-the-shelf I/O includ- ing networking and file systems • Seamless integration with the Renesas HEW IDE •20 DSP features • Complete indemnification • Seamless migration between MCU products without code changes • Low-cost deployment licenses Unison V4 and DSPnano V2 are hosted on Windows® XP and Vista® for x86 platforms. Sup- port, training and consulting for the entire Renesas R8C, M16C and R32C/100 MCU line are available. www.rowebots.com (090568-VII) New generation lOOV-rated ceramic chip capacitors Using dielectric thin-layer and multi-layering technologies, TDK has reduced the gaps between the ceramic dielectric layers of a news series ofd capacitors by 40% com- pared to earlier products. In addi- tion, sintering conditions were opti- mised to maintain the reliability needed for capacitors in automo- tive applications, while also ena- bling package size reductions and increased capacitances. As a result, TDK's new mid-voltage ceramic chip capacitors are around 50% smaller than the previous gener- ation of devices at equivalent capac- itance values. The new capacitors are available in a range from the smallest Cl 005 device (0402 size; 0.01 jjF) to the largest, the C5750 (2220 size; 1 0 pF). The devices are all rated for 100V operation. TDK's new mid-voltage capaci- tors feature X7S temperature char- acteristics (temperature range of between -55°C and 125°C, capacitance variance of ±22%). This makes them ideal for use in automotive engine compartments and in the switching power-sup- ply smoothing circuits required in industrial equipment. These capacitors are expected to be widely adopted in new environ- mentally-friendly electronic prod- ucts, such as eco-friendly cars that use less fuel and emit less carbon dioxide. These green efforts have been supported by the increased use of electronic equipment which in turn has increased market demand for smaller on-board elec- tronic components. www.tdk.de (090568-X) 12 elektor - 9/2009 S 0845 226 9451 Your source for MikroElektronika Development Tools and Accessories in the United Kingdom We can supply all MikroElektronika development tools including compilers, development boards, add-on boards, programmers and starter packs. We aim to keep all products in stock for same-day dispatch and can offer next-day delivery within the UK as well as insured delivery by airmail post or courier worldwide. EasyPIC5 PIC Development Board - £89 BIGPIC5 PIC Development Board -£119 LV18FJ PIC Development Board - £89 Get off to the best start with PIC microcontrollers with the EasyPIC5. Supports 8, 14, 18, 20, 28 and 40-pin PIC10F/12F/16F/18F devices and features built- in USB programmer, in- circuit debugger and useful I/O devices. LCD displays sold separately. An advanced development board for 64 and 80-pin PIC microcontrollers in the 18F family, the BIGPIC5 provides on-board USB programmer, in-circuit debugger plus extensive I/O devices and communications interfaces. LCD displays and SD card- sold separately. Designed for low-voltage PICs in the LV18FxxJxx family with on-chip Ethernet connectivity, the LV18FJ incorporates USB program- mer, in-circuit debugger and useful I/O devices and supports 64, 80 and 100-pin MCUs. LCD displays and SD card sold separately. EasyPIC5 Starter Packs also available comprising EasyPIC5, character and graphic LCDs, touch panel, tem- perature sensor and either BASIC, C or Pascal compiler. BIGPIC5 Starter Packs also available comprising BIGPIC5, character and graphic LCDs, touch panel, temperature sensor and either BASIC, C or Pascal compiler. LV18FJ Starter Packs also available comprising LV18FJ, character and graphic LCDs, touch panel, temperature sensor and either BASIC, C or Pascal compiler. EasydsPIC4A dsPIC Development Board - £89 dsPICPR04 dsPIC Development Board - £149 LV24-33A PIC/dsPIC Development Board - £99 A versatile development board for 18, 28 and 40-pin digital signal controllers in the dsPIC30F family, the EasydsPIC4A provides built-in USB programmer, in-circuit debugger and useful I/O devices. LCD displays sold separately. The new dsPICPR04 is an advanced development board for 64 and 80-pin dsPIC30F devices with built- in USB programmer, in-circuit debugger and extensive I/O features and communications interfaces. LCD displays and SD card sold separately. Easily develop 16-bit PIC24 and dsPIC33 applications with the LV24-33A. Features USB programmer and in- circuit debugger plus useful I/O devices and supports 64, 80 and 100-pin low-voltage devices. LCD displays and SD card sold separately. EasydsPIC4A Starter Packs also available comprising EasydsPIC4A, character and graphic LCDs, touch panel, temperature sensor and either BASIC, C or Pascal compiler. dsPICPR04 Starter Packs also available comprising dsPICPR04, character and graphic LCDs, touch panel, temperature sensor and either BASIC, C or Pascal compiler. LV24-33A Starter Packs also available comprising LV24-33A, character and graphic LCDs, touch panel, temperature sensor and either BASIC, C or Pascal compiler. EasyAVR5A AVR Development Board - £89 BIGAVR2 AVR Development Board - £89 Easy8051B 8051 Development Board - £89 Get off to the best start with Atmel’s Flash 8051 micro- controllers with the Easy8051B. Supports 14, 16, 28, 32, 40 and 44-pin 8051s and features on- board USB programmer and useful I/O devices. LCD displays sold separately. Get off to the best start with AVR microcontrollers with the EasyAVR5A. Supports 8, 14, 20, 28 and 40-pin AVRs and features on- board USB programmer and useful I/O devices. LCD displays and SD card sold separately. Work with 64, 80 and 100-pin AVR microcontrollers with the BIGAVR2 development board. Includes built-in USB programmer and range of on- board I/O devices. LCD displays and SD card sold separately. EasyAVR5A Starter Packs also available comprising EasyAVR5A, character and graphic LCDs, touch panel, temperature sensor and either BASIC, C or Pascal compiler. EasyARM ARM Development Board -£109 Easily develop for NXP’s 32-bit ARM microcontrollers with the EasyARM. Includes on-board USB programmer and useful I/O devices and supports 64 and 144-pin devices. LCD displays and SD card sold ’ ■ separately. Compilers BIGAVR2 Starter Packs also available comprising BIGAVR2, character and graphic LCDs, touch panel and either BASIC, C or Pascal compiler. EasyPSoC4 PSoC Development Board - £89 Learn about and develop for Cypress’s exciting PSoC mixed-signal array devices with the EasyPSoC4. Features built-in USB programmer and advanced I/O devices and supports 8, 20, 28 and 48-pin PSoCs. LCD displays and SD card sold separately. Add-on Boards Easy8051B Starter Packs also available comprising Easy8051B, character and graphic LCDs, touch panel, tem- perature sensor and either BASIC, C or Pascal compiler. UNI-DS3 Universal Development Board - £99 With the UNI-DS3 you can easily work with a number of popular microcontrollers from different manufacturers simply by buying optional plug-on MCU cards. Devices sup- ported include PIC, dsPIC, AVR, 8051, ARM and PSoC. MCU cards, LCD displays and SD card sold separately. Starter Packs mikroBASIC, mikroC and mikroPascal compilers now available in versions for PIC, dsPIC, AVR and 8051 microcontrollers. All feature user-friendly development environments, built-in library routines and easy integration with MikroElek- tronika’s programmers and debuggers. We stock an extensive range of add-on boards that plug straight onto Mikro- Elektronika’s development boards including A/D, D/A, RS-485, CAN, LIN, Ethernet, IrDA, RTC, EEPROM, Compact Flash, SD/MMC, MP3, Bluetooth, ZigBee, RFid, stepper motor driver and many more. wi' M Save money by buying one of our Starter Packs. Each includes a development board with options such as LCD displays, touch panel, temperature sensor and come with a full version of either mikroBASIC, mikroC or mikroPascal. Available for PIC, dsPIC, PIC24/dsPIC33, AVR and 8051. NEW PRO versions just released for PIC and AVR - existing mikroBASIC, mikroC and mikroPascal customers can upgrade free-of-charge! Contact us for details. NEW range of GSM/GPRS and GPS add-on boards and accessories just released. Contact us for details. NEW PIC and AVR Starter Packs now come with PRO versions of mikroBASIC, mikroC or mikroPascal. Please see our website at www.paltronix.com for further details of these and other products We also stock components, control boards, development tools, educational products, prototyping aids and test equipment Paltronix Limited, Unit 3 Dolphin Lane, 35 High Street, Southampton, S014 2DF | Tel: 0845 226 9451 | Fax: 0845 226 9452 | Email: sales@paltronix.com Secure on-line ordering. Major credit and debit cards accepted. Prices exclude delivery and VAT and are subject to change. INFO & MARKET NEWS & NEW PRODUCTS ARM Cortex-M3 based SAM3U micro gets IAR support IAR Embedded Workbench for ARM and IAR PowerPac for ARM now feature full support for the Atmel ARM Cortex-M3-based SAM3U microcontroller (MCU) family. In close cooperation with Atmel, IAR Systems has added new configuration files, flash load- ers and project examples to IAR Embedded Workbench for ARM for Atmel's new SAM3U Cortex-M3 based microcontroller. The device specific support achieved by these additions makes it quick and easy to get started with a project and allows the user to concentrate on application development tasks. The latest update of IAR PowerPac includes the new Board Support Packages (BSPs) for the SAM3U as well as the new SAM3U evalu- ation kit available from Atmel and IAR Systems. The BSPs include all the drivers and low level routines needed for the operating system and communication software to interface the hardware and access the peripherals on the boards. The IAR PowerPac USB stack takes full advantage of the 480 Mbps High Speed USB Device controller and benefits from the advanced DMA supported bus and memory architecture in the SAM3U device. The SDIO/SD-card interface is fully supported in the popular PowerPac File system with its powerful Multi- media support. IAR Embedded Workbench for ARM is a set of highly sophisti- cated and easy-to-use development tools. It incorporates an ARM Cor- tex-M3 C/C++ compiler, assem- bler, linker, librarian, text editor, project manager, and debugger combined in an integrated devel- opment environment (IDE) for pro- gramming embedded applications. In addition to supporting debug- ging through the JTAG port, IAR Embedded Workbench also sup- ports Serial Wire Output (SWO), which is part of CoreSight, the on-chip debug and trace solution used in the Cortex processor fam- ily and in the Atmel SAM3U. The user has full freedom to configure the types of packets sent over the SWO channel that should be dis- played by IAR C-SPY debugger. Additionally, debug log messages from a printf output can be also displayed by IAR C-SPY, without having to halt the execution. Atmel's SAM3U device is the industry's first ARM® Cortex™- M3 Flash microcontroller integrat- ing high speed (480 Mbps) USB Device-and-Transceiver, 4-bit 192 Mbps SDIO/SDCard 2.0, 8-bit 384 Mbps MMC 4.3 Host and 48 Mpbs SPI interfaces on-chip. This connectivity, together with the SAM3U's 96 MHz/1 .25 DMIPS/ MHz operating frequency, makes the SAM3U the unique Cortex-M3 device suited to applications with intensive communications require- ments, such high speed gate- ways in industrial, medical, data processing and consumer appli- cations. The introduction of the SAM3U expands Atmel's 32-Bit MCU portfolio consisting of ARM and AVR32 products. www.iar.com (090568-VIII) New name, new generation products revitalize embedded software ■ > a fit tit "a«Ja ■ J U £ I Monitor # -c-gg-f J Jv J I I fcXM 1 Th J if) I nn ■ 1 |j»] Nww tip* V#H iff* 1- [ / f - 41B1VL1? * L Cl 4 1pi4 ij J J f — | > i ■ 11 |\/ Sh- 1 company's focus on optimising embedded systems for internatio- nal markets. Leading Crosshairs Embedded next generation product line-up is the new Functional Debugger ver- sion 1.1. By allowing businesses to debug, monitor and optimise their /% iwr# 1 -Jr A change of name signals the dynamic, fresh approach Cros- shairs Embedded is bringing to revitalising embedded software. The company offers customers invaluable insight through precise software solutions, with a new generation of products to deliver that promise. Formerly Active DSP, the change to Crosshairs Embedded reflects the operating systems in real time, while they're running, it reduces downtime, helps increase effici- ency and leads to greater profits. Businesses will quickly find the Functional Debugger vl.l is reliable and highly cost-effective. It's especially valuable for organi- sations with international opera- ting systems, as it allows seamless, remote non-intrusive testing and monitoring of embedded systems even at large distances. It's also easy to use, and more dependable and adaptable than 'home-brew' software testing solutions. Crosshairs Embedded Functional Debugger vl.l is officially laun- ched at Embedded Systems Con- ference (ESC) Boston, 2009. The company's next new generation product, the powerful Interface Designer, will follow shortly. www.CrosshairsEmbedded.com (090568-XIII) 14 elektor - 9/2009 Memory «, Discover Deep Memory Performance. Du* to memory constraints, traditional digital stooge oscilloscopes do not haw iJhe capability of displaying a complete electronic signal at a high samplp #at*. The GD5-1QQQA Series uses Memory Prime technology to overcome ihe problems assoc lated with memory constants- By displaying com pie?* signals with greater detail, the GD5-1000A Series can maintain a high sample rate over a wider horizontal range, without affect ing performance. Challenge yourself to go deeper P CDS1M0A I CDS 1000A Series Digilnl Storage Osci loscope * 1 50/1 CM/60 MHz Bandwidth, 2 Input Chamets * Sample Rales up to tCSa/s Real-Time Maximum, 2SGsa/s Equivalent Time ■ 2M Points Record Length MaKrnwnli * ImV^IOV Vertical Scale,! ns-ifts Horizontal! Range ■ Up to 27 Automatic Measurements ■ USB mi SD ruterlace Supported ir'-armiiicn jtuHji Ihr ardvanlajc^of MemfryP^rneEKhnn 1 ^. %na-«l O'jr A.P&5. «e ,.| w^-^n-e^&ry-pr-irc.cfir'. ur coni.ultrwj r k-:jl d^Lribol^f. |buy CDFI-nrrir-. fir L a lirnilvd li^clitwPTJfTinLT & a cornplimefihor SO card reader \ GOOD WILL INSTRUMENT CG. P LTD. Ho. 7 - 1 , fiaad, TuC^tSIf Clft Oipti C^yFYffrJJG. Uiwj- r «fH4-U£frti)£9 f4U3rZHI G^mSTEK Wrtde to Measure sh=f rjjt www.gwins1ek.com TECHNOLOGY AUTOMOTIVE At the beginning of the twentieth century the internal combustion engine started to take over from electrically-powered vehicles. Now, a hundred years later, electric vehicles are slowly but surely making a come-back. Development continues apace and the enormous potential is clear. The key to the success of electric vehicles lies, contrary to early expectations, in lithium- ion cells rather than in fuel cells. It was an electric vehicle, driven by Belgian Camille Jenatzy, that was first to break the magical 60 mph (about 1 00 km/ h) barrier in 1 899. His torpedo-shaped car (Figure 1) was accelerated to 105.88 km/h by 200 V lead-acid batter- ies powering two 25 kW motors. Although not lacking in power, the vehicle fell rather short when it came to endur- ance. No less an individual than Ferdinand Porsche, work- ing at the Lohner company in Vienna, was inspired by this to try to overcome the disadvantages of electric drive by combining it with a petrol engine, thereby inventing the first hybrid vehicle. The design was also the first to feature an electric hub motor and all-wheel drive (Figure 2). From then on the onward march of the motor car, first with internal combustion petrol engines and then with diesel engines, seemed unstoppable. The most significant factor in their rise was the ready availability of cheap crude oil from which fuel could be made. A century later, conditions have changed for the internal combustion engine. Oil is becoming scarcer and more expensive, and there is pres- sure to reduce C0 2 emissions significantly. In today's hybrid 16 elektor - 9/2009 vehicles the benefits now work in the opposite direction: the electric drive serves to help overcome the disadvantages of the internal combustion engine. And the prospects for these vehicles improve as batteries improve; ultimately the internal combustion engine may disappear altogether. This article presents an overview of current developments and the prospects for battery technologies in future electric vehicles. Paving the way for hybrid vehicles Hybrid electric vehicles (HEVs) have been in mass produc- tion since the introduction of the Toyota Prius I in 1997. They have shown that the electric drive train is suitable for mass production and reliable. With the manufacture of some two million HEVs in Japan, and simultaneous rapid progress in the development of lithium ion batteries, it is inevitable that companies all over the world are racing to produce the electric vehicles of the future. The next develop- ment is the so-called plug-in hybrid electric vehicle (PHEV), with a socket to allow its battery to be charged, and an increased range in purely electric operation. The first PHEV, the F3DM from BYD in China, is already being made in small quantities and being sold to governmental organisa- tions. BYD ('Build Your Dream') is the world's biggest pro- ducer of mobile phone batteries and also makes vehicles, most recently in a joint venture with Volkswagen. The Chevrolet Volt (and the Opel sister model, the Ampera) are expected to be the first mass-market PHEVs, available at the end of 2010. Current reports indicate that Toyota and others will join the market in 201 2. In the next three years the mass production of pure electric vehicles (EVs) is also likely to begin. Current models, manufactured on a relatively small scale, include the Tesla Roadster, made in California, and the Norwegian THINK. The i-MiEV is expected to go into production this year: this compact car, announced as the first mass-production pure electric vehicle, is the result of collaboration between Mitsubishi in Japan and PSA Peugeot Citroen in France. The PSA group is still the biggest maker of EVs, having sold more than ten thou- sand units, but the situation is changing rapidly. Besides its PHEV line, Toyota has also announced an EV version of the new iQ for 201 2, and in the same year Nissan expects to sell one hundred thousand units of its EV model, to be unveiled at the Frankfurt Motor Show in September 2009 or perhaps even earlier. One left over Until recently hybrid vehicles used exclusively NiMH bat- teries: manufacturers committed to the technology for three to five years and built capacity to suit. However, NiMH is a mature technology and its development seems to have reached its limits; for modern PHEVs and EVs it does not offer a compelling proposition in terms of cost and energy density. From the point of view of cost the stalwart lead-acid bat- teries are hard to beat. Recent technological developments have made them suitable for use in hybrid vehicles. With the explosive rate of development in lithium ion batteries, how- ever, lead-acid technology seems to be being left behind. Th ere is little that can be done to improve energy density and, in the world of electric vehicles, its use is confined to low-cost scooters. Supercapacitors, although unmatched in terms of cycle life, store too little energy to be useful, and industry will likely not wait for the capacitors announced by Eestor, with an enormous claimed energy density, to materialise: devices suitable for use in electric vehicles are Figure 1. Back to the future: 112 years ago the electric vehicle was the leader of the pack. In 1899 Camille Jenatzy reached a top speed of 105.8 km/h (66.1 mph) in a vehicle powered by lead-acid batteries delivering 50 kW. Figure 2. The 1900 Lohner-Porsche was a hybrid car: a petrol engine drove a DC generator to produce power for the electric hub motors. at least three years from mass production. The current best-selling battery for electric vehicles is manu- factured in great secrecy: the ZEBRA battery, which uses a NaNiCl chemistry, is relatively low-cost (around £/€ 500 per kWh) but has the disadvantage of an operating tem- perature of around 300 °C and thermal losses of 100 W, making it not ideally suited to private vehicles. A significant advantage, however, is that it is highly insensitive to ambi- ent temperature. The high-temperature units are available as an option on the THINK city electric car; the alternatives available are A123 cells with a Lithium Iron phosphate (Li FeP0 4 ) chemistry, and the EnerDel LiMn 2 0 4 spinel cells. For future electric vehicle development it would appear that lithium ion cells offer the best prospects, and that ZEBRA cells will occupy only a small market niche. Indeed, lithium UlNem-lon trailer mariflgeniwt system rarrige ram conn^cUon hijfr village lerrnnal ceil wolage monitoring Figure 3. The Mercedes S400 Hybrid is the first mass-production hybrid car to use a lithium ion battery. The battery is completely sealed and temperature-controlled. Picture: Daimler Benz AG. 9/2009 - elektor 17 TECHNOLOGY AUTOMOTIVE Carbon footprint and power consumption Although electric vehicles are themselves zero-emission, the generation of power may of course produce C02. The average kWh of electricity generated in the UK produces about 540 g of C02; in countries such as Norway (which has a lot of hydroelectric generation) and France (which has a lot of nuclear generation) the figure is rather lower. However, even at 540 g per kWh an efficient electric car like the i-MiEV has an advantage: a journey of 60 miles (100 km) might use around 10 kWh of electricity, making the total carbon emission 100 g C02 per mile ( 60 g per km), less than any petrol-engined car. The carbon footprint can of course be further reduced by generating a greater fraction of our power from zero-emission sources. An interesting possibility here is the use of biomass. If we translate the energy available per hectare per year (in central Europe) into distance we find that using a biomass-to-liquid (BTL) process and powering a car's engine directly from biofuel gives about 60,000 kilometres per hectare per year (about 1 5,000 miles per acre per year), whereas using photovoltaic panels to produce electricity for an electric car gives 1 ,000,000 kilometres per hectare per year (about a 250,000 miles per acre per year). The extra electricity demand created by electric cars is less than often supposed. If all private cars were electrically powered, the electricity companies would only sell about 1 5 % to 20 % more power; and the oil companies would only be supplying die- sel for lorries. Mitsubishi i-MiEV In mass production from the end of 2009. This electric version of a small car popular in Japan has an under-floor battery made from prismatic lithium ion cells by Yuasa. Energy stored is 1 6 kWh with a nominal battery voltage of 330 V, giving a 1 00 mile (1 60 km) range. The battery can be charged from an AC power outlet in seven hours, or fast charging is poss- ible at specially-equipped stations. The present and the near future Tesla Roadster Manufactured since 2008 in small quantities. Total energy storage is 53 kWh in 6,831 notebook-style lithium ion cells (375 V overall voltage); maximum range 220 miles (360 km); maximum power 225 kW. In May 2009 the Daimler Group (which includes Mercedes) acquired a 10 % stake in Tesla. Chevrolet Volt In mass production from the end of 2010. General Motors are pinning their hopes on this first mass production plug-in hybrid. A petrol engine is used to recharge the battery from time to time via a 53 kW generator, extending the range of the vehicle. When fully charged via its socket, the 1 6 kWh lithium ion battery is good for a range of 40 miles; with the petrol en- gine this is increased to 400 miles (600 km). Originally A1 23 were to supply the cells, but for mass production the cells will be made by LG Chem of Korea. The petrol engine is a 1.4 li- tre four-cylinder model made at the Opel plant in Vienna, and Opel has considerable involvement in the design of the Volt. The Opel (European GM) version will be called the Ampera and is expected to appear in 2011. 18 elektor - 9/2009 ion cells are already found in the first mass-produced Euro- pean hybrid car: the Mercedes S400 Hybrid has an electric drive rated at 15 kW and is classed as a 'mild hybrid'. The lithium ion battery is from Johnson Controls/Saft and has a capacity of 6.5 Ah at 1 20 V, for a total energy stored of 0.78 kWh (Figure 3). An interesting aspect of the design is that the car's air conditioning system is used to help sta- bilise the temperature of the battery. Chemistry set The common features of all lithium ion cells are that, in the charged state, one electrode contains lithium, and that charge is transported across the cell by lithium ions. A sig- nificant advantage of lithium-based cells is their high termi- nal voltage and good capacity-to-weight ratio. A wide range of recipes is available for the electrode mate- rial itself, each having its characteristic terminal voltage and other properties (see Figure 4). The other factors affecting characteristics and cost are the choice of electrolyte and of separator. Liquid electrolytes based on organic solvents and conductive lithium salts can be used, as can solid or gel film electrolytes (as in lithium-polymer, or 'LiPo' cells). LiPo cells have a particularly high energy density and are available in a range of shapes; however, they do not perform well at low temperatures. The choice of separator is an important factor in both the manufacturing cost and the safety of the cells. An interest- ing recent development is a ceramic separator called Sepa- rion® by Evonik (formerly Degussa), already in use in cells by German battery maker Li-Tec. The separator can with- stand high temperatures, and can thus help to prevent an internal short-circuit in the cell. This is a particularly impor- tant aspect as fully-charged lithium ion cells, in contrast to NiMH cells, cannot continue to be accept current without damage, including risk of explosion. The other side of this coin is the very high efficiency of the cell (90 % to 95 % Safer types are the lithium iron phosphate (LiFeP0 4 ) cel from A123 and GAIA, at the cost of around 10 % less energy density and terminal voltage. Power and life Figure 5 shows a comparison of specific power and energy for the storage technologies described above using various types of lithium ion cells. The gap between high- power lithium ion cells and high-energy cells is striking. Table 1 shows an overview of the typical characteristics of these two product types. High power output is important for hybrid vehicles, which need to draw or store large amounts of energy over short time periods. Figures of 200 A (20C) are typical for a 10 Ah cell. For very high power applica- tions such as hybrid Formula 1 racing cars, cells with spe- cific power as high as 6 kW/kg are available. In pure electric vehicles the battery is relatively larger than it is in hybrid vehicles. A charge or discharge current of liquid Li-Ion cathode material anode material long life, safety risk highest safety risk, good performance poor life cycle, safety better as Co & Ni popular add-on material to optimize features great diversity in add-on materials ‘3.3 V material’, economic and safe base material Hard Carbon LiC 6 ‘3.7 V material’, low full-cycle values Graphite ‘3.7 V material’, costly, Lic e high full-cycle values Titanate ‘2.2 V material’ safe, Li 4 Ti 5 0 12 low energy density Silicon ‘3.7 V material’, Li 22 Si 6 high energy density, research status 090498 - 1 1 Figure 4. There is a wide range of recipes for the electrode materials used in lithium ion cells, all with different characteristic properties. Source: ISEA, RWTH Aachen University 100000 10000 CD > CD CD O a> o Q. o 'o CD Q_ CD 1000 100 10 0 20 40 60 80 100 120 140 160 180 200 specific energy in Wh/kg (cell level) 090498-12 Figure 5. Power density and energy density of commercial lithium ion cells compared to other energy storage technologies. Source: ISEA, RWTH Aachen University Figure 6. Theoretical energy density of metal-air cells. Rechargeable systems of this type remain a long way off. Source: ISEA, RWTH Aachen University around 3C is a reasonable value to give acceptable accel- eration and braking. The problem here is chiefly one of energy density: a battery might have an energy density of around 1 90 Wh/kg, some six times smaller than that of pet- rol (1 154 Wh/kg). Notwithstanding the regular announce- ments of magical new nanomaterials promising five- to ten- fold increases in energy density, Dirk Uwe Sauer, professor at the Institute for Power Electronics and Electrical Drives, RWTH Aachen University, believes that energy densities of up to 300 Wh/kg should be possible using 5 V cath- Table 1. Ratings of high-energy and high-power lithium ion cells High Energy High Power Power density (25 °C) 200 to 400 W/kg 2000 to 4000 W/kg Energy density 1 20 to 1 60 Wh/kg 70 to 1 00 Wh/kg Efficiency approximately 95 % approximately 90 % Self-discharge < 5 % per month (at 25 °C) < 5 % per month (at 25 °C) Cycle life up to 5000 complete cycles 1 06 cycles (at 3.3 % DOD) 9/2009 - elektor 19 TECHNOLOGY AUTOMOTIVE Figure 7. At very low temperatures the power output of a lithium ion cell falls markedly. Source: ISEA, RWIH Aachen University Figure 8. Cell life as a function of discharge depth and temperature for NiMH cells. The characteristics of lithium ion and lead-acid cells are similar. Source: Varta/ Johnson Control Figure 9. Evolution of energy density (ratio of energy to volume or weight) and cost of lithium ion laptop batteries (standard cell size 18650). Source: Institute of Information Technology, AABC 2004, San Francisco ode materials such as LiCoP0 4 or LiNiP0 4/ or silicon-based anode materials such as LiSi 5 . The only theoretically feasi- ble option for energy densities above 1000 Wh/kg is the metal-air cell (Figure 6), although a rechargeable cell of this type looks rather unlikely to appear within the next ten years. Of course, it is always possible to revert to the old plan of exchanging one's metal-air battery at the filling sta- tion, with the old batteries being regenerated on an indus- trial scale. So, to return to the present and lithium ion cells: an impor- tant factor in their operation is temperature. Excessively high temperatures can be dangerous, leading to thermal runa- way; operation at somewhat elevated temperatures reduces a cell's life, and operation at low temperatures reduces the power. The loss is noticeable at 0 °C and at -30 °C the output power is reduced to less than 10 % of that at room temperature (Figure 7). Some kind of temperature man- agement system, such as that used in the Mercedes S400 Hybrid as we mentioned above, is a good idea. An EV for use in Alaska needs to be plugged into a power supply not just to charge the battery, but also to keep it warm. The life of the battery depends chiefly on three factors: temperature, depth of discharge (DOD) and age. As Fig- ure 8 shows, deep cycles cause such wear and tear on the cell that the degradation with temperature is negligible, and with shallow cycles (DOD of a few percent) the situa- tion is reversed. What the illustration does not show is that the cells deteriorate gradually over time so that a little-used cell will, after a few years, become completely 'kaputt', as Professor Sauer puts it. The operating life requirements for HEV batteries are from 8 years to 1 2 years, and spend most of their life between 40 % and 60 % charged. In pure EVs the DOD is typically around 80 % (charge level varying from 20 % to 100 %). Costs and resources The special high-energy batteries used in EVs are not yet made in large quantities and so prices remain correspond- ingly high at around £/€ 1 250 per kWh. By way of com- parison, Kokam has LiPo batteries available in quantity at under £/€ 500 per kWh; lithium ion high- energy batteries are available from China at around £/€ 250 per kWh (they are used in elec- tric bicycles, of which some twenty million are made every year); and lithium ion laptop batter- ies have fallen in cost by a factor of five over the ten years from 1995 to 2005 (see Figure 9), and now cost around £/€ 200 per kWh. Experts at RWTH Aachen University believe that with mass production high-power batteries could fall in price to £/€ 500 per kWh and high-energy batteries to £/€ 250 per kWh. Estimates from Japan of £/€ 1 50 per kWh are somewhat more optimistic. Opinions also differ on the question of long-term availability of supplies of the raw material lith- ium. Lithium is more abundant in the earth's crust than either lead or tin, but most of the economi- cally exploitable reserves are concentrated in a small number of countries, chiefly in South Amer- ica. This brings a number of new risks, and a spike in demand could quickly lead to shortages and price hikes. The difficulty can be ameliorated by careful planning of production capacity and early construction of recycling facilities for lithium batteries. Small is beautiful Although there has been much popular interest in pure EVs with plenty of power and range, such as the Tesla Roadster, Professor Sauer thinks a better approach is to move towards vehicles with smaller batter- ies. He sees the idea of PHEVs equipped with rather small batteries as the best way of replacing petrol with electricity as quickly as possible There are many arguments in favour of this 'small is beautiful' position. - The larger the battery, the more expensive the vehicle, and so fewer vehicles will be sold. This is not the way to move quickly towards the widespread use of electric vehicles. - In industrialised countries the average distance travelled by a car is around 25 miles (40 km) per day. A battery providing a 120 mile (200 km) range (about 30 kWh) will remain 80 % unused, but this unused fraction of the battery 20 elektor - 9/2009 must still be paid for and its weight must be carried around by the vehicle. A PHEV with a 30 mile (50 km range on battery power (5 kWh to 10 kWh) might spend two-thirds of its time in electric mode. Coupled with the increased effi- ciency of the hybrid drive this leads to a reduction of 70 % in petrol usage. - The only EVs with a significant chance of a large market are small city cars, especially in developing markets such as India and China. In 2006 in China more electric vehicles were sold than any other type, mostly scooters and bicycles. There would be a natural 'upgrade path' to an electric Tata Nano, and the Chinese government has announced fund- ing for the development of electric vehicles to the tune of around a billion pounds. As Professor Sauer says: 'prices will fall as a result of mass production, not as a result of waiting'. The long view Taking into consideration the effects of C0 2 emissions on the climate, it seems that if we want to maintain the level of personal transport (or, as in China and India, increase it) the only practical approach in the medium term is to switch to electric vehicles. The two-car household of the next decade will likely own a medium-sized PHEV for fam- ily trips and a small EV with a range of 30 to 50 miles (50 to 90 km). Further into the future, experts see the possibil- ity of using a fuel cell as a substitute for the petrol engine in plug-in hybrid vehicles, so that private cars run on two- thirds electricity and one-third hydrogen rather than on pet- rol or diesel. A widespread take-up of electric vehicles is expected in countries such as India and China. A study by management consultants McKinsey predicts the market for electric cars in China to be worth well over a billion pounds in 2030. ( 090498 ) The new PicoScope 4000 Series high-resolution oscilloscopes Technology "*■ h ■■ _i L " 1Q - The PicoScope 4224 and 4424 High Resolution Oscilloscopes have true 12-bit resolution inputs with a vertical accuracy of 1%. This latest generation of PicoScopes features a deep memory of 32 M samples. When combined with rapid trigger mode, this can capture up to 1000 trigger events at a rate of thousands of waveforms per second. • PC-based - capture, view and use the acquired waveform on your PC, right where you need it Software updates - free software updates for the life of the product USB powered and connected - perfect for use in the field or the lab Programmable - supplied with drivers and example code Resolution 12 bits (up to 16 bits with resolution enhancement) Bandwidth 20 MHz (for oscillscope and spectrum modes) Buffer Size 32 M samples shared between active channels Sample Rate 80 MS/s maximum Channels PicoScope 4224: 2 channels PicoScope 4424: 4 channels Connection USB 2.0 Trigger Types Rising edge, falling edge, edge with hysteresis, pulse width, runt pulse, drop out, windowed www.picotech.com/scope1029 01480 396395 9/2009 - elektor 21 AUTOMOTIVE DIAGNOSTICS Analyser NG Next-generation handheld with graphical display, ARM Cortex M3 controller and Open Source user interface By Folker Stange and Erwin Reuss (German The compact 0BD2 Analyser in the June 2007 issue was an enormous success — not surprising for an affordable handheld onboard diagnostics device with automatic protocol recognition and error codes explained in plain language. Now enhanced with a graphical display. Cortex M3 processor and an Open Source user interface, the next generation of Elektor's standalone analyser sets new standards for a DIY 0BD2 project. The key advantage of the OBD2 Ana- lyser NG is that it’s self-contained and can plug into any OBD diagnostic port. It is handheld and lightweight, requires no batteries and works without a note- book computer, making it far more practical than a PC adapter. A glance at the comprehensive Features panel indicates that this new gizmo has plenty more to offer. The source codes for the firmware of the controller are clearly identified, providing readers keen on programming with com- plete control over the configu- ration of the GUI, the way that process 22 elektor - 9/2009 results are displayed and all manner of other functions. The hardware offers plenty of scope for expansion too, with the PCB already laid out for adding extra options such as a flash memory data recorder, a USB interface and a real-time clock (provision), in case you wish to implement an additional data logging function. DXM These days OBD diagnostic chips are based increasingly on CAN-capable processor platforms and can exchange data in various ways via protocol scan. The diagnostic chip ‘pings’ protocols sequentially and links up with the engine management system once the correct protocol has been recog- nised. The 8-bit PIC or AVR control- ler used as the hardware platform does, however, require rather a lot of additional hardware to meet the demands of all the multiple proto- cols. This makes the time ripe for a more efficient solution using a modern controller. This was the motivation for developing the Diamex DXM module [1], which is used in our OBD2 Analyser NG. The DXM module comprises an ARM Cortex M3 controller and the necessary surface- mount device (SMD) circuitry on a small printed circuit board (PCB). This module (Figure 1) reduces exter- nal circuitry requirements to a mini- mum and offers a unified yet versatile hardware basis for developing com- pact OBD2 projects. Designed as a universal OBD2 diagnostics and control unit with its own dedicated firmware, it can be connected direct to a vehicle’s diagnostics port. A high-speed (up to 250,000 Baud) serial interface provides an external con- nection. At the heart of the module is the 32-bit ARM Cortex M3 CPU with a clock frequency of 72 MHz, 64 KB of flash memory and 20 KB of RAM. The environment comprises a K line pro- tection IC, a CAN driver, MOS transis- tors for the PWM-based protocols, two signal lines and a dedicated power supply with over-voltage protection (Figure 2). The available I/O ports offer many possibilities over a modest number of lines, such as connection to a standard LCD display (SPI inter- face), which can even use dedicated text strings. Firmware updates can be applied via the serial interface, so that standardi- Features Hardware Handheld Analyser: • Full graphics display 1 32 x 32 pixels • RGB backlighting • Convenient four press button control • Power supply taken from onboard diagnostics port (12 V car battery) • Uses standard OBD cable • Convenient size (1 26 mm wide x 68 mm tall x 25 mm deep) • Weight approx. llOg Hardware and software DX module (DXM-PCB): • Hardware for onboard OBD2 control • Firmware for onboard OBD2 control • 3V3 tx-rx level • Cortex M3 CPU (32-bit controller) • 72 MHz internal clock rate • Onboard 3V3 power supply for external device - max. 55mA • Jumperless • Bootloader • LED indicators for onboard Connect and Data Stream • Analogue battery voltage measurement • AT control set • Supports all currently implemented protocols: PWM, VPWM, IS09141-2, ISO 14230-4 (KWP2000), ISOl 5765-4 (CAN, 1 1/29 Bit , 250/500 kBaud) • Firmware update via ISP interface • Rapid OBD connection Open Source firmware functions: • Graphical user control interface display • Selection of vehicle data, PID list, error code list, VIN, MIL status • Selection menu for active transmission control system (for vehicles with multiple transmis- sion options, e.g. automatic gearbox) • Saved error store (freeze-frames) for previous faults • Expandable memory bank for sample error codes • Erasable error store • Live display of sensor data • Acoustic signals • Selection menu for scan mode (automatic or manual) • Menu text in English • Choice of direction (rotatable through 1 80 degrees) • Controllable RGB backlight brightness • Battery voltage measurement Expansion options: • USB port for data transfer or supporting use with PC • Real-time clock (RTC) for data recording (e.g. time and date stamping) • Adequate checklist flash memory (1 , 2 or 4 MByte) for data logging functions Open Source: • Open Source firmware for the controller • ISP interfaces accessible for AT90CAN1 28 and AT90USB162 • Other firmware can be substituted if required • Demo firmware for 'Speedometer with warning functions' 9/2009 - elektor 23 AUTOMOTIVE DIAGNOSTICS f t n s v v up; •MU ' £"H ‘T i r| * ‘ ' Js 3# Wmm ™ p ■sss?; f 1 tfrti „ J t * s ft » 3 n 'r' _ . — ® « ^ « :=r gy O * * g Sli WiS* * " - - v K-3 "»<■**> ** > : — >s^? : ; ? *• «fi»w *-« *-* »f? r: >• » i H ^H.SSg, • *J.q/£' 1 11 li'^ ^ li fL-A gh '/**, ^ ,-.1? £ *“ \ # ^N ^ if ^ if ^ t< «i ?? w ' Figure 1. The DXM module equipped with ARM Cortex M3 processor used in the new OBD analyser. sation alterations or new functions can be made without difficulty at a later stage. The module is built on a four-level multi-layer PCB (20 mm x 34 mm) using surface-mount technology. The pitch of the connector pins is 1.9 mm, arranged in two rows of 13 and 17 pins. These pins carry 12 V and ground, the OBD2 lines, the serial lines RX, TX, RTS and CTS, the SPI interface, the 8 MHz clock frequency, the 3.3 V sup- ply voltage together with some control wires. An 18 V suppressor diode pro- tects against voltage surges from the vehicle. In parallel with the two status LEDs it is possible to connect additional out- board low-current LEDs using a series resistor of 220 Q to the cathodes and 3.3 V to the anodes. The red LED comes Is your car equipped for diagnostics? Whether and to which extent OBD2 diagnostics will work depends on your car. Generally speaking, you're OK if you run a 2000-model (or newer) petrol car or a diesel built since 2003, although there are plenty of exceptions. You will find several checklists online, such as the one compiled by Florian Schaffer [9]. OBD2 can talk to a whole range of test devices, but only if they use controllers and components designed to be compatible with OBD2. The engine management system and elements of the exhaust system are crucial to this. In many new vehicles switching on the ignition ac- tivates the engine management system and also the automatic trans- mission system. On vehicles equipped with multiple management systems the OBD2 handheld described here may well be able to select the particular active management system to be analysed. OBD2 does not support safety- critical components, in-car convenience (comfort and entertainment) electronics or maintenance reminders. As a result, you cannot use the diagnostics interface to reset airbag indications or ABS lights. Commands for this kind of equipment simply have not been standardised and each car manufacturer invents its own procedures. Maintenance intervals are also model-specific and cannot be unified. Convenience features are a key differentiator be- tween cars so there is no commonality among the control and com- mand sets either. Note that maintenance interval warnings are reset in the workshop (the handbook will give full details). Setting up convenience features generally calls for special tools. Safety features are enabled over the remaining pins of the diagnostics port in ways that differ according to the make and model. Figure 2. Block diagram of a simple 0BD2 adapter with the DXM module. on when a connection has been estab- lished with the engine management system and the green LED flashes dur- ing data transfer. Since the beginning of 2000 most Euro- pean vehicles have used the protocol IS09141-2 or KWP2000, using just one communication wire for data transfer. This makes it very simple to create a diagnostics adapter: just connect the K line and the car’s onboard supply ( + 12 V and ground) to the DXM and make the connection to the PC or Note- book via a MAX3232 level converter (Figure 3) to start the diagnostics process. A simple terminal program [2] is perfectly adequate for this. Con- necting up to the other wires or lines makes other protocols readable. A spe- cial OBD software package such as ‘moDIAG express’ [3] rounds this off. The comprehensive command set of the DXM is largely backwards-com- patible with older diagnostics chips 24 elektor - 9/2009 Safety tips and e-approval According to the legislation in some countries, diagnostic interfaces without e-approval cannot be used in a moving vehicle. Drivers should not allow them- selves to be distracted by OBD2 diag- nostics during test drives on private land either. Safety must come first when it comes to diagnostic tests. Figure 3. Basic circuit for an 0BD2 interface with the DXM module. OBD2 (OBD-II) explained OBD, as you must have guessed, stands for On Board Diagnostics and in this particular context relates to a vehicle's self-diagnostic and reporting capability. OBD2 (also written as OBDII) is an enhancement to the original specification, improving both capability and standardisation. OBD systems provide vehicle owners and repair technicians access to state of health in- formation for various vehicle sub-systems. Although basic OBD systems appeared in the 1970s, it is only in recent times that protocols and connectors have become standardised and made mandatory. Within the UK OBD became mandatory for all new UK car designs in 2000, existing cars in 2001 and diesels in 2004 (although most manufacturers imple- mented it before these dates, since many cars were also sold in the US, where the state of California began to require emission control systems on 1966 model cars). Further informa- tion at http://en.wikipedia.org/wiki/On-board_diagnostics, http://en.wikipedia.org/wiki/ Obd2#OBD-ll and http://www.obd-codes.com. like AGV and ELM but will not toler- ate slow processing, since process- ing the many AT commands involved is very time- and processor-inten- sive. A comprehensive data sheet giv- ing the AT commands and the Eagle Library ‘footprint’ for the DXM can be downloaded gratis from [6]. This web- site also has information on the ‘tran- sit’ mode, which enables proprietary PC software to talk to the vehicle’s onboard electronics via the K line with- out involving an OBD2 connection. An ‘extended’ version of the DXM module additionally offers a CAN low-level mode, which in conjunction with spe- cialist software (‘Can-Hacker’ [2]) can Figure 4. Block diagram of the new handheld 0BD2 analyser. Flash memory, RTC and USB connector are optional extras. 9/2009 - elektor 25 AUTOMOTIVE DIAGNOSTICS be used to analyse CAN data traffic. Handheld analyser puts DXM through its paces Simply amazing results are achieved when you put an AVR or PIC controller in command of the DXM board. Conse- quently the new OBD2 analyser (Fig- ure 4) employs an AVR controller plus command software written in C as an Open Source project. That’s the rea- son why the somewhat cryptic slogan ‘handheld open’ appears on the front panel of the case. As already mentioned in the introduc- tion, the power supply is taken from the car’s battery, which is connected to the OBD2 diagnostics port at Pin 16 (12 V) and 4/5 (ground). It’s easy then to keep the device in the glove com- partment or in the tool kit, ready for use whenever it is needed. The hard- ware is competitively priced and very effective. Equipped with a full graphic display and four touch switches inside a compact and robust ABS case, it is highly intuitive and ergonomic in use. The most important components on the circuit diagram (Figure 5) are the microcontroller AT90CAN128 used for controlling operations, the 132x32 pixel graphic display, an 8 MHz crys- tal, four touch switches for operations, a micro loudspeaker, an ISP program- ming port, the PWM control for the backlight LEDs, a switching regula- tor and a low voltage-drop regulator for the power supply, plus of course the DXM module itself. The switch- ing regulator IC2 provides 5 V for the backlight LEDs. The low drop regula- tor LD1117 supplies 3.3 V for the AVR controller, its peripherals and the DXM board. The diagram also shows, in the section marked off, the optional components for expansion with an additional data logging function (see panel Expansion Components). Construction... All components are fitted to the printed circuit board (Figures 6 and 7). Since the circuitry cannot be realised with- out using surface mount devices, these are already fitted on the PCB. Not included, however, are the SMD Figure 5. The DMX module lies at the heart of the handheld analyser's circuit. components required for the optional expansion (the ‘Expansion Compo- nents’), which are not shown in the component list either. The switching regulator IC2 is func- tional once you have fitted the 220- 9 \ LLINE 8 ^ PWMP 7 \ PWMM 6 1 \ PWMP 2 V PWMM 3 4 \ BOOTO ^ RST DXM 11 12_ +3V3 1 3_ 14 15_ 16_ \ PB1 17 +12V © D1 1 N4007 +12V CANL / KLINE / CANH / DXM 12V PWMP PWMM GND 9_ 10 3V30UT BOOTO RESET LED1 LED2 3V3IN LCD OSCOUT PB1 LLINE KLINE CANH CANL EEPINIT MODE1 MODE2 RTS CTS RXD TXD MOSI MISO PA8 SCK CS AO LLINE / 33 KLINE / 32 CANH / 31 CANL / 30 29 28 27 _RTSy 26 _cjsy 25 DXM RX / 24 23 22 21 20 J9 18 R16 DXM jxA +3V3 © EXPANSION PORT i J2 i J1 +5V © V SDA "vj -o V RST_DXM -C\ V RESET S. DXM RX V DXM TX vJ V BOOTO S, CAN-RX "vJ V CAN-TX w -o SCL X +3V3 © R1 C4 RESET ^ToOn 21 20 33_ 34_ 43_ 18_ 19 54 o- 55 r\ 56 r\ 57 58 r\ 59 60 o- 61 +3V3 © J3 SV1 V DXM TX 1 ^ RESET 3_ 5 V SCK 7 \ DXM RX 9 o o o o o o o o 62 10 AVR m AT90CAN128 +12V © 52 64 VCC VCC AVCC RESET IC3 PA7(AD7) PA6(AD6) PA5(AD5) PA4(AD4) PA3(AD3) PA2(AD2) PAI(ADI) PAO(ADO) NC PGO(WR) PGI(RD) PG2(ALE) PG3(TOSC2) PG4(TOSC1) PB7(OCOA/OC1 C) PB6(OC1 B) PB5(OC1 A) PB4(OC2A) PB3(MISO) PB2(MOSI) PBI(SCK) PBO(SS) PC7(A15/CLK0) PC6(A14) PC5(A13) PC4(A12) PC3(A11) PC2(A10) PC1(A9) PC0(A8) AT90CAN128 PF7(ADC7/TDI) PF6(ADC6/TDO) PD7(T0) PD6(RXCAN/T1 ) PF5(ADC5/TMS) PD5(TXCAN/XCK1) PF4(ADC4/TCK) PF3(ADC3) PF2(ADC2) PFI(ADCI) PFO(ADCO) AREF GND GND XTAL1 PD4(ICP1) PD3(TXD1/INT3) PD2(RXD0/INT2) PD1(SDA/INT1) PD0(SCL/INT0) PE7(ICP3/INT7) PE6(T3/INT6) PE5(OC3C/INT5) PE4(OC3B/INT4) PE3(OC3A/AIN1 ) PE2(XCK0/AIN0) PEI (TXDO/PDO) PE0(RXD0/PDI) XTAL2 GND C3 lOOn 22 53 C2 22p 24 Q1 I I 8 MHz 23 Cl 22p 9 9 9 9 44 45 46 47 48 CS FLASH 49 50 51 17 "\ 16 15 14 13 MISO / 12 MOSI / 11 SCKy 10 CS DISP / 42 41 40 39 38 37 36 _PBiy 35 32 RST DISP / 31 CAN-RX / 30 CAN-TX / 9 RST DXM / 8 BOOTO / 7 BUZZER / _CTSy _RTSy 3 DXM RX / 2 DXM TX / 63 -o S2 i S4 I, ^S1 |-| I — © a Si +3V3 © Tr18 | R19 28 TXD1 27 RXD1 26 SDA / \SDA 25 SCL / V SCL R3 TR 2 " ^C10^ | C8 *-* \ BUZZER R17 D3 LSI llOOn |4 I • I 3: 47 u 35V r 5 r 6 rC |~ |~Tk5 VCC SWC SWE IC2 SENS COMP MC34063 DRC TIMC GND 1N4148 C9 IC1 LD1117-3V3 R4 470p | • • A 26 elektor - 9/2009 ji/H choke (LI). LI needs to be angled round by 90 degrees to face the centre of the PCB. The next placement task is to solder the DXM module precisely into position on the main board. Begin by soldering just one pin. Make sure PAD LED5V1 LED1 LED2 LED3 fl| G U B\_ X X X R7 R8 — s' L B 1 1 1 1 R9 RIO i R11 -o o PAD R LED R R12 U-+ R13 T R14 R15 — O O ^Jjl ~BCR108 PAD_G LED G -6 O ^Jj2 PAD_B LED B T3 RGB BACKLIGHT BCR108 -©> ~BCR108 1 I R20 I O I o I R21 Ik 10 11_ 12 13_ 2 24 5 26 25 1 C19 lOOn \ i i 27 32 4 31 UCAP AVCC VCC UVCC PDO(OC. OB/INTO) PB0(SS/PCINT0) PD1(AINO/INT1) PB1(SCLK/PCINT1) PD2(RXD1/AIN1/INT PB2(PDI/MOSI/PCINT2) PD3(TXD1/INT3) PB3(PDO/MISO/PCINT3) PD4(INT5) PB4(T1/PCINT4) PD5(XCK/INT12) ^ PB5(PCINT5) PD6(RTS/INT6) PB6(PCINT6) PD7(CTS/HBW/T0/ INT7) AT90USB162 SV2 1 3_ 5 "VJ _r\ rv 14 RESET vj- r\. 15 SCLK 7 kj- r\. 16 MOSI 9 vj vj- _r\ r\. 17 MISO 18 AVR !£ 20 J C21 USB PB7(PCINT7/OCOA/ OC1C +3V3 © 10 PC0(XTAL2) PCI (RESET) PC2(PCINT11) PC4(PCINT10) PC5(PCINT9/OC1 B) XTAL1 D-/SDATA D+/SCK PC7(INT4/IC1P/CLK0) PC6(PCINT7/OC1 A) GND UGND 28 r 2x PGB0010603 OPTIONAL EXTENSIONS +3V3 © R24 MOSI 1 1^ CS FLASH 4 / ' SCK 2 /■ SI cs SCK VCC IC6 so WP RST AT45DBXXX GND MISO \ \ \ \ \ +3V3 ©- 25 24 C13 1 u 23 C14 1 u 22 Cl 6 1 u 21 C17 1 u v a. a. Q. in o o C/5 C/5 in cn Q Q o — o 1— if) < C/5 o cc 34 35 36 37 38 39 40 Q Q > Q Q > — -I o C/5 O < C/5 V4 V3 V2 VI VO m DSP1 LC DISPLAY 132 x 32 C/5 C/5 > C/5 C/5 > CL < o 0. z T- CM CL CL < < o o CL CM CL < o CL co CL < o A1 Cl A2 C2 3 o > C18 1 u 26 33 30 C11 1 u 29 27 C15 1 u 28 31 20 19 32 C12 STANDARD BACKLIGHT +5 V © R25 1 1 CC CO i — ! — T T5 BCR108 090451 - 11 the module lines up properly, so don’t solder everything solidly straighta- way. Just a brief and sensitive touch of the soldering iron with the minimum of solder is best. When all the unsol- dered pins line up exactly with their holes, then the other pins can be sol- dered firmly and the solder on the first pin reflowed to relieve any tension. Before mounting the graphic display we need to install the backlight. This is not difficult: just separate the sub-board already fitted with SMD LEDs (LED1, LED2, LED3) from the main board by breaking it away gently and carefully. Then plug it into the recess provided. The LEDs should face the centre of the board on the display side. The four pads should be soldered together (see Fig- ure 8). After this fit the touch switches flush against the PCB, so that a clean pressure point can be felt. Now we need to embed the satin- finish acrylic sheet diffuser into the laser-cut packing material supplied (the edges should be bent up first and let into the slots in the diffuser) and fixed at the four corners with narrow (3 mm wide) pieces of adhesive tape (Sellotape or similar). The diffuser is positioned on the PCB and the display placed above, after first removing the protective film. The display is the centrepiece of the unit, so solder only one pin to begin and check all round that it fits properly. Once soldered into place, it is very dif- ficult to adjust afterwards and is eas- ily damaged. The Sub-D connector is slid onto the board sideways and aligned accu- rately (Figure 9). Before you do this, make sure the stand-off sleeves have been screwed tight onto the connector. Last in line is the micro loudspeaker, the opening of which should face in the direction of the backlights. Assembling the case is very simple by comparison. Four aluminium plungers are set above the touch switches and the PCB is affixed with the screws sup- plied. Finally the case lid is placed on top and screwed together. ...and commissioning To begin we can apply a voltage of 12 V at the Sub-D connector (Pin 9 = 12 V; Pin 1 or 2 ground). The interface boots up and draws around 100 mA of current. Current requirement varies according to the brightness setting of the backlight, as this draws the most juice. A certain amount of warmth is completely nor- mal with high-brightness LEDs. Shift- 9/2009 - elektor 27 AUTOMOTIVE DIAGNOSTICS Figure 6. Component side of the prototype board. ing the default values alters the current consumption measured. Now we can start the in-vehicle test. The most important requirement is an OBD2-capable vehicle with the 16- pin connector (see panel Is your car equipped for diagnostics?). To avoid any problems start the car first and only then connect the OBD2 Ana- lyser to the vehicle’s diagnostics port. The background to this is the timeout of five seconds embedded in the ISO and KWP protocols, which prevents con- nection with the engine management system if you get the sequence wrong. It is best to begin with an automatic scan. Please pay careful attention to the advice in the panel Safety Tips. Operation of the Open Source firmware (available free) has been structured to be entirely intuitive. Consequently, since the display can be turned through 180 degrees, there is little COMPONENT LIST SMD components (prefitted on board): Cl ,C2 = 22pF C3,C4 = lOOnF C5 / C6 / C1 1 — C 1 8 = 1a/F R1 = 1 OkD R2,R3 = ID R4 = 1 kQ R5,R6 = 1.5kQ R7,R1 0,R1 3 = 110Q R8,R1 1 ,R1 4 = 68D R9,R1 2,R1 5 = 47D R16 = 330D R1 7 = 33Q R1 8,R1 9 = 4.7kD Q1 = 8MHz quartz crystal D1 = 1N4007 D2 = B0530WS D3 = 1N4148 T1J2J3 = BCR108 IC1 = LD1117 3V3 IC2 = MC34063 IC3 = AT90CAN1 28 LED1 / LED2 / LED3 = RGB LED, Kingbright type KAA-3528SURKVGAPBA Components to be fitted separately: DSP1 = LCD 132x32 DXM = OBD module J1,J2 = 1 0-way SIL pinheader J3 = 2-way pinheader LI = 220/iH (choke coil) LSI = miniature loudspeaker S1-S4 = pushbutton SV1 = 1 0-way boxheader XI = 9-pin sub-D plug with solder buckets Fastenings and accessories: 4 x pushbutton plungers 4 x case screws 5 x PCB screws Diffuser Cardboard packaging Case with front panel Sub-D connector fixings Standard OBD2 cable Sources of supply: Component set # 090451 -71 available from the Elektor Shop contains all necessary components and the PCB with SMD compo- nents pre-fitted together with the case (with custom front overlay), fixings and the stand- ard OBD2 cable. See Elektor Shop adver- tisement at the back of this issue and www. elektor.com/090451 . Figure 7. On the other side of the board are just four touch switches, the display LCD and the miniature loudspeaker. point in labelling the touch switches. The buttons to the left of the (visible) display are ‘UP’ and ‘DOWN’, at upper right ‘CANCEL’ (ESC) and below this ‘INPUT’ (OK). This makes navigation nice and simple. From a software per- spective the buttons can of course be programmed differently and used in other ways. With a view to worldwide usability the menu text of the software starts in English. All details like this are accessible in the source code, so it is easy to alter the user language. Wide open for further development The disclosed firmware [4] of the AVR controller is a good basis for automo- tive diagnostics. There is already free ‘speedometer firmware’ available, which transforms the analyser into an accurate speed measuring device with presettable 28 elektor - 9/2009 Figure 8. This is how the LEDs for the display backlight are fitted. Figure 9. The Sub-D connector needs to be soldered on both sides of the PCB. threshold values that actuate acoustic and optical alarms. This sample software demonstrates that the analyser hardware is not restricted to diagnostics. As the firmware is Open Source, users are free to alter and expand this themselves, also make enhancements available to other users. A commercial approach is also fea- sible, perhaps for LPG gas conversion or additional convenience features, such as speed-dependent central locking or audi- ble warning of speed. Other ideas include a stopwatch function, GPS navigation, GPRS redirection, event-driven relay functions or even a dynamometer, an acceleration meter and a small onboard computer. The expansion port could be used to scan additional sensors (e.g. temperature). Average fuel consumption is another popular subject, with an inter- esting approach to be found at [5]. A C0 2 monitor and an ‘eco -meter’ would make very topical projects to support greener motoring. The programming connections of the AVR are available via an Atmel-con- formant 10-pin ISP interface. You need to set jumper J5 if the programming adapter is expecting a supply voltage on Pin 2. The authors used a low-cost programmer [6] for this. A data bank of error codes is already included in the firmware but this too can be altered, for instance to expand the information already entered. The only limitation is the amount of flash memory available in the controller. Fur- ther tips can be found among the com- ments included in the source code. New firmware can be burnt in rapidly using an ISP programmer and a com- patible GUI using AVR Dude [6], for which the original program is available as hex code. Many of the development ideas have already appeared on the DXM Plat- form [1] and in a forum [7]. This and the Elektor forum [8] are great places for swapping ideas and suggestions, also finding construction help and application tips. ( 090451 - 1 ) [1] www.dxm.obd-diag.net (in German only, use Google to translate) [2] www.er-forum.de/obd-diag-dl (starts up in German but will display in English if you register [click on Login and select Register] and set Sprache to English) [3] www.modiag.de (in German only, use Google to translate) [4] www.elektor.com/090451 [5] www.lightner.net/lightner/bruce/ Lightner-1 83.pdf [6] www.stange-distribution.de (English version available) [7] www.forum.obd-diag.net (German), www. obdii.com/forums/ubbthreads.php and www.obd-codes.com/forums/ (English) [8] www.elektor/forum [9] http://carlist.blafusel.de (English version available) Expansion components You have the option of equipping the board with a number of addi- tional components ready for future developments: • RTC - Real-time clock RTC8564 with I2C Interface. A 3-V lithium battery is connected at J3. Using the type provided with solder tags, solder it with two wires to J3 (check polarity) and sleeve the battery with heatshrink tubing. With the battery protected like this, you can fix it to the back of the case with duct tape. The RTC8564 is connected to the controller via the Interrupt line in order to trigger time-controlled events (time- stamp facility). • Dataflash AT45DBXXX Choice of 1 .2 or 4 MB memory capacity. A USB connection to an AT90USB1 62 processor would make sense if you are contemplating using professional software [3] to diagnose or transfer the stored data. A B-type USB connector needs to be retrofitted in this case, fit- ted at right angles. Mechanical stability is assured by soldering the screen to the circuit board. The casing is not deep enough for fitting it the normal way round. * Expansion port 20-way expansion port for additional features with all connections from Port F, the I2C lines SDA and SCL, together with the CAN Bus connections from the host controller. For fixing the optional SMD components the authors recommend: 1 . Tinning the pads with 0.5 mm solder (Sn60Pb40) and putting the part into place approximately. 2. Using a gas soldering iron fitted with a hot air jet, heat the pins and align the component into the correct po- sition with a watchmaker's screwdriver. Practise this technique first on scrap PCBs, such as a defective CD-ROM drive. The use of these optional components assumes that suitable software has been optimised for them (the current Open Source firmware does not yet have any expansion capabilities implemented). 9/2009 - elektor 29 By Chris Savage (USA) There are plenty of projects out there that deal with GPS and microcontrollers, many of which make use of the data for such things as navigation. The Robo-Magellan competition is one such application. But what if you wanted to visualise the path your robot took through such a course? Better yet, what if you wanted to log the path of a bike or car trip? Here's how. Sure, you could export the data for process- ing into some other application that does this, but you could also make use of a very popular application called Google™ Earth. Plotting a course Google Earth is a virtual globe pro- gram that can show you, at a conti- nent, state, city or even street level, various locations on the planet, based on satellite images. You can follow streets as well as see popular loca- tions. Provided your area’s been photo- graphed recently by one of those low- orbiting birds, using Google Earth, you should be able to see houses, includ- ing gardens in the back yard in your neighbourhood. One interesting thing about Google Earth is that it’s available free and supports Keyhole Markup Language (KML) which is an XML-based lan- guage for expressing geographic anno- tation, maps and even 3D objects. One feature of KML is the ability to plot a path using GPS coordinates. So if you have a source of coordinates, such as a GPS module, you can create a KML file with a little help from a BASIC Stamp® microcontroller module and a Parallax Memory Stick Datalogger. The author took a short drive around the vicinity of the Parallax home base in Rocklin, CA. A screenshot of the Google Earth plot of the journey is shown in Figure 1 . The KML file of this trip can be downloaded with the source code and is called LOGDATA. KML. You can load it into Google Earth for a detailed look at the trip or you can open it using Notepad to see the structure of the KML data. Note that due to the margin of error in accu- racy of GPS as well as differences in the Google Earth terrain map, at some points it looks like the car was driven off the road or in the oncoming lane. Rest assured it was driven safely! Data Portability On a PC with Google Earth installed you need only double-click a KML file and Google Earth will launch and plot the data. The trick is getting the data from your mobile GPS system into the PC in the correct format. Parallax man- ufactures a Memory Stick Datalogger, which is essentially a USB host bridge using the Vinculum chip from FTDI. The Memory Stick Datalogger allows you to use a portable storage device such as a USB thumb drive to store the GPS data. Since the FAT (file allocation table) system happily is supported, you can save the file in the native for- mat and it will be directly readable by the PC and Google Earth. Since KML is an XML-based language there are a lot of tags similar to those used in HTML. For now we’ll simplify things by saying that the important parts of the file we are creating are pretty much always going to be the same. Decoding KML Google has an extensive specification for KML at [1] so no need to go into all the 30 elektor - 9/2009 details here. The language is very pow- erful and warrants a look if you’re inter- ested in creating files for Google Earth. For our purposes we will only want to create paths. In order to do this we will need three pieces of information: 1. First we will need what’s best called the ‘header information’. This is essentially all the infor- mation Google Earth will need to know, such as the version of the language, source URL, line types and colours, mode, etc. 2. Next, we need the coordinates themselves. Oddly Google Earth expects the data as Longitude, Latitude, then Altitude. Con- versely, [2] uses Latitude then Longitude. In any event this will be the part of the data we will be supplying as we go. 3. Finally the file will need the clos- ing tags, called the ‘footer data’ here. The trick now is to get a BASIC Stamp to put all this data onto a USB thumb drive so it can be read by a PC. Figure 1. Screenshot from Google Earth of a car trip around Parallax Inc. in the Rocklin CA industrial area, as recorded with the GPS logger. BASIC Approach to KML For an understanding of the discussion below, you will find it useful to refer to the ‘GPS Datalogger v. 1.0’ code list- ing contained in archive file # 081079- 11. zip at [3]. The program is very straightforward and includes many pieces of code from other programs the author wrote for the various hardware used. The BASIC Stamp module has 2 K of EEPROM available for program and data to be stored. The original concept of doing this by hard-coding the data into SEROUT statements was put to the test. However, this left no room for making the program do anything other than writing the data straight from the GPS Module, so it was decided to create a data table in EEPROM of all the header data used to create the KML file. In order to do this, quotation marks had to be coded into ASCII val- ues since quotes are used to enclose text. To trim a few more bytes, instead of using a CRLF (carriage return / line feed; remember?) for each line a sin- gle null (zero) byte was used, being replaced by the program whenever encountered. There was also a need to change the Altitude mode eas- ily. After trying several methods it was ultimately decided to hard code the text section of that one command based on a mode constant being 0 or 1. Since this creates a break in the header block the value 255 is used to separate blocks of KML code, see Listing 1. Building the GPS Datalogger Figure 2 shows the schematic for the GPS Datalogger. For the sake of com- pleteness the drawing includes the parts on the Parallax Super Carrier Board used for building the proto- types. Use the Component List to do your shopping. Figure 3 shows the constellation of boards that make up the logger. In Figure 4 you can see the ‘user I/O’ parts (switches, resistors, Practical use The Parallax Memory Stick Datalogger and Parallax GPS Modules are used, so the first thing that happens is the program initial- ises and establishes communication with the Datalogger. A bi-colour LED is used to indicate status and blinks green while the Datalogger is initialised. If no USB drive is connected the program will wait until it is connected before moving on. Once the Datalogger is initialised and the drive is identified the program will write out the KML header data. This will take several seconds since it is being read byte-by-byte from EEPROM and written out to the drive. While this is happening the LED will be fast- blinking red. Once the data is written the program will attempt to get the satellite signal status from the GPS module to see if the signal is valid. During this process, which may take up to 2 minutes to complete, the LED will slow- blink red. Once the satellite signal is valid the LED will turn solid green to indicate that the system is ready to start logging data. There are two pushbuttons on the GPS Datalogger Board. Pressing the yellow one (SW2 on port line PI 5) until the LED turns red will start the logging process. The GPS Datalogger writes data to the USB drive at a fixed rate of about one sample every three seconds. If the GPS signal is lost dur- ing logging, the last coordinates are written at the same rate. This makes it possible to determine how long the data was accumu- lated, even during times when the signal is not valid. At any time once the USB drive has been initialised you can hold down the red but- ton (SW3 on port line PI 2) until the LED starts blinking red. This will write out the KML footer data and close the file. When it is safe to remove the USB drive the LED will blink red/green alternately. It is not advis- able to remove it at any point before this, since corruption of the data or even the file system is possible. 9/2009 - elektor 31 Figure 2. GPS Datalogger schematic. The yellow area indicates the Super Carrier board. COMPONENT LIST Parallax part numbers in brackets Super Carrier Board (#27130) (optional, see text) BASIC Stamp 2 Module (#BS2-IC) GPS Module (#28146) Memorystick Datalogger (#27937) 2x 1 OkD resistor 220Q resistor 2x tactile switch (#400-00002) Bi-Colour LED (#350-00005) Optional components 1 rubber foot (included with Super Carrier board) 1 1 2mm (0.5") M3 threaded PCB standoff (US: F-F, 4-40) 2 M3 screw (US: 4-40, 1/4") (#700-00028) 4-pin SIP Socket (#450-00401 ) LED standoff (#350-90000) bicolour LED) soldered in place on the prototyping area of the Super Carrier. Also note that a mounting hole was pre-drilled for the GPS Module and a 4-pin SIP socket was installed. While not required, this is recommended. You will also need a 12 mm (0.5”) threaded standoff between the board and the GPS Module. A rubber foot from the Super Carrier Board was cut in half and used as a pad to hold up one end of the Memory Stick Datalogger so that there is extra support when inserting a USB drive into it. At this point it is a good idea to run the test programs included in the source code package. The programs allow you test individual subsystems of a project while building it to simplify debugging if there is an issue. There are programs for testing the GPS, Datalogger, LED and buttons. The ‘GPSTest.bs2’ file is a modified version of the GPS Demo program. The ‘DataloggerTest.bs2’ file is a modified version of the Datalogger Demo pro- gram and the ‘ButtonLEDTest.bs2’ pro- gram was quickly written for the pur- poses of testing those components. Downloading the ‘ButtonLEDTest.bs2’ program will blink the bi-colour LED red 5 times, green 5 times, then alter- nate red/green 5 times. After that it will report whenever either of the but- tons is pressed. You should run these programs to make sure all the hard- ware is functioning before moving on. A hungry client Once everything is assembled you can download the file ‘GPS Datalogger V1.0.bs2’ and start logging data. The Super Carrier Board powers everything from its own 5 volt regulator, so for testing a cable which plugs into a cig- arette lighter or auxiliary connector in a car is conveniently used to power the board. Note that the cigarette lighter socket normally does not supply power when the ignition is switched off. Placing the board up in the centre of the dashboard nearest the window will yield the best results and you will rarely lose signal. Our advice is if you’re going to test it like we did, get some Velcro® or temporarily tape it in 32 elektor - 9/2009 Listing 1. GPS datalogger code (extract) Write_Header : SEROUT TX\CTS , Baud, [$07, $20, GOSUB Get_Data SEROUT TX\CTS , Baud, [ $ 0 9 , $20, GOSUB Get_Data counter = 0 DO TOGGLE LEDA READ Header + counter, ioByte IF ioByte = 0 THEN SEROUT TX\CTS , Baud, [ $ 0 8 , ELSEIF ioByte = 255 THEN EXIT ELSE SEROUT TX\CTS , Baud, [ $ 0 8 , ioByte, $ 0D] END IF counter = counter + 1 GOSUB Get_Data LOOP logdata . kml" , CR] ' Delete File ' Purge Receive Buffer "logdata . kml" , CR] ' Create File ' Purge Receive Buffer ' Reset Byte Counter ' Blink Red LED ' Get Next Byte From EEPROM ' Replace 0 Bytes w/CRLF $20, $00, $00, $00, $02, $ 0D , $ 0D , $ 0A, $ 0D] ' End Of Data Block $20, $00, $00, $00, $01, $ 0D , ' Increment Pointer ' Purge Receive Buffer \\ place. All regulations in force in your country governing minimum unob- structed windscreen area should be observed. The whole system consumes about 200 mA of current depending on the USB drive used. This causes the volt- age regulator on the Super Carrier Board to become quite warm. Be care- ful of grabbing the board near the reg- ulator. Another note about this is due to current consumption this unit can- not be powered from a regular 9 volt battery. You will need a high capacity power source, or if used in a car or on a motorcycle you can use the cigarette lighter or auxiliary connector and you should be okay. For a bicycle a genera- tor may even be possible. Final Thoughts The code as supplied for the project (downloadable at [3]) is relatively large and uses all but six bytes of the EEP- ROM space. The main reason is the number of very verbose DEBUG state- ments, which are not needed and can be taken out or commented out. Many people like to see some feedback when testing things for the first time and the author was inclined to provide that although DEBUG statements (or any- thing with added text) use a lot of pro- gram memory. Note that by default the data logged ignores elevation (altitude) data. If you wish to enable this you can change the mode constant toward the beginning Advertisement An Entire Community Under One Hat With eight 32-bit processors in one chip and deterministic control over the entire system, the Propeller microcontroller is just plain inspiring. Coupled with our free online community support, downloads and resources, progress is only a click away. Online Propeller Communities: • Discussion Forums - http://forums.parallax.com t • Propeller Object Exchange - http://obex.parallax.com Propeller Expo (pictured above) - Show off your project in person to other Propeller users at the next expo. With guest speakers, prizes, and more, you won’t want to miss it! For the latest http://www.parallax.com/propeller & / FMl±/1XZ www.parallax.com Friendly microcontrollers, legendary resources . Milford Instruments www.milinst.com Spinvent www.spinvent.co.uk 9/2009 - elektor 33 of the program from 0 to 1. Be warned that GPS modules don’t always match the elevation maps used by Google Earth and this can sometimes cause your path to disappear under the ter- rain, making it invisible. This will cause breaks in the path. It was also noted sometimes it looked like the vehicle was several meters above the ground (must be a flying car). You can also change the mode in the KML file directly by using notepad. If you change the word ‘clampToGround’ to ‘absolute’ and reload it into Google Earth it will now show altitude data. This data is shown as a line extruded from the virtual ground. More buttons may be added to this project, adding flexibility to the hard- ware for those (we know) are going to do more with this. One possible appli- cation would be tracking a child driver when borrowing the family car. The code and hardware could be slightly modified to start logging when the ignition is on. Currently time/date stamping is not supported, but in reviewing the KML specifications it seems it is available as an option to use that data and it is readily available from the GPS Module. Perhaps we will see what some of you come up with. You can post your find- ings and improvements to the discus- sion forums at www.elektor.com. Drive carefully! (081079-1) Internet Links [1] http://earth.google.com [2] http://maps.google.com [3] www.elektor.com/081 079 VS5 o PCOO PCI o Ydd P Rstp PC 1 P e i3f- - + ■ 1 ■ i- Sou - - Tii- * Sr Vm Si;™ E3 Rn J 2; Vss nfigrjtJ imr Rsi Ye:*- J Vdd j§ p i3 _ -?& PT2 2 ^ J PIS P5f iS §= * P13 R9 g.rM'Pfl Pl5 J- C-^ -J 4 jjGp i * PU * ■ P i J C C-* ;■ * Afc pf? i #• • /fttpoo ## « * * pio »*### * P9 Ct o J? » v « * ® fr PB pf OO CSC V i K~ \ Vb ft m pa c cj>c e t* 5 ;i ■ ■ pi c o 4' — - - , ■ a A/sh&r. A' 1 *i * UnP PO O W .'Oc fr-* 4 * vdd o ... o t # r |S tt :t] ^ v, l | jQ Dl SC i. < x Rocklin. Cfc • — Pi o - . it-rHMEl ‘ ** i pi t*’ tf*. 4 i »5J| ****** “"5 - « d c 0 * - ■■ 4 ? - r i& BASIC Stomp Super Carreer • fflon + uoSSiS IT-.J-Drnl^xom - 0i3J £f}3CH>7 4~V Figure 3. The prototype less USB stick normally plugged on to the data logger. m p 6 H *M 4 ? p i Mil J , ; nj 5 35S1 5 • p -5 I ril _ si iSt- * 5 « m 2 L iLitL li. c. pui §= ^ P 1 2 =£ ft pi | |l ft PTC ft pg ps z o o PH O C^Q PU P12 ©COC ' PH Q$(v’ CiS^ PIO P9 ev opr P8 ** P7 PG P5 »«»« 9C r p^ P3 = Th P2 ? V* n PI C-O ‘ PC Vdd i S * , » 20 19 BASIC Stamp ■'W* frnroiloK.con f o89«(il ^ OfiCfcf O « © * b 4. " V €! ® "■ _ w ©o : ' p- V« . f ® “ -T *!? 'J >4 V “ i - * * * t • 8^ * 4 4 ■ H ir :4 ? fl * "" -.MJ R Jin' 1 7 ■ m « •f.Vss terrier ^ 1(0200? <*■, /I ■ l:'l'!uT jp ™ T rf^Plf *' ** Figure 4. A closer look at how the "bare bones 7 user interface is built on the Super Carrier board. For your convenience everything except the prototyping area has been greyed out. Note the PCB standoff used to secure the GPS module to the board. BASIC Stamp programming Programming the BASIC Stamp (BS) plug-in module is no Rocklin Science and based on a free tool called Basic Stamp Windows Editor, which is also available in Mac and Linux fla- vours. The latest version may be found at http:// www.parallax.com/tabid/477/Default.aspx. Basically, all you have to do is connect the BS dev board to the PC using a standard RS232 cable, run the BS Windows Editor program, load the file you want to transfer to the BS (it has the .bs2 extension), run a quick syntax check on it, and if all is beyond reproach (message: 'Tokenize Successful'), download it to the BS. 4 BASIC Stump W;\ REDACTIE\MATERIAL\08 xaxx\081 x*xY 081079 l\GPS DutuloggarVCPS Dululoeewr V1.0.bs2 ED@B t o 0610781 . npi n7Qj • 1^1 IJri 1 11 / ^*1 tJ CPIj OutalnggM v < - _ > BUNori£OT etib>2 ••""•J rrngrftTn IJP.srripr. inn J ———————————————————————————— — ——— ————————— ——— — — — — 0«l-stjyjetTpi).ln2 • This program at Iona you to log data from a Parallax OPf! Module (#2f)14fi) GPS D«»«lugyei V1.8b»2 • to a Parallax Memory Sttrlc Datalogger (ft?. 7937) in Ooogle Earth KMI. GPSTert.BS2 ' format . V RA.SIC Stump Hu |* hi! * hut.-* hi?.-* huv* hut ▼ < l> I rkenrti '.jurr/tulii 34 elektor - 9/2009 Don 'P jnsP PesP IP... ...Analyse IP/ Special Offer prices for limited period or while stocks last! electronic design ltd The New Atlas ESR Plus, Model ESR70 This new model of the famous Atlas ESR offers all the great features of the ESR60 but with extended measurement range and audible alerts. This is the Atlas ESR Plus\ • Capacitance from luF to 22,000uF. • ESR from 0.01 ohms to 40 ohms. • Great for ESR and low resistance measurements (short tracing etc). • Automatic controlled discharge. • Audible Alerts (for good ESR, poor ESR, open circuit and more). • Gold plated croc clips. Atlas SCR - Model SCR100 Connect Triacs or Thyristors any way round. Auto part+pinout identification Check gate lOOuAto 100mA. Measures gate voltage drop. Regulated load test conditions m © Identify network cabling type. Identify many fault types. Tests sockets and cables. Complete with all this: Tl 4 I « + ■ 1>! I El £69T00’irTc'VAT (E60.00+VAT) Atlas ESR - Model ESR60 Capacitance and ESR! Capacitance luF to 22,000uF ESR O.OIohms to 20 ohms Gold plated croc clips £75.00 inc VA3 (£65.21 +VAT) Atlas DCA - Model DCA55 The famous Peak Atlas! Now with premium probes. Connect any way round to identify semiconductor type, pinout and lots of parameters Transistors Darlingtons MOSFETs Diodes LEDs and more. £53.83 i (£46.81 Atlas LCR - Model LCR40 Passive component analyser. Identify inductors, capacitors and resistors. Auto frequency selection. Removable probes. Atlas Star Pack (LCR/DCA) Includes the Atlas LCR, Atlas DCA and a premium padded carry case, with extra spare battery. £T2:4.99 inc VAT (£108?6^VATj Peak Electronic Design Ltd, West Road House, West Road, UK: Please add £2.00 p&p per order. Buxton, Derbyshire, SKI 7 6HF. Prices include UK VAT. tel. 01298 70012 www.peakelec.co.uk sales@peakelec.co.uk See website for overseas prices. /O ( y PCBC0RE China PCB Supplier (Prototype thru Production) / 1 -layer up to 30-layer / Cost and quality / On time delivery / Dedicated service / Instant Online Quote & Order Day and Night No minimum quantity - 1 piece is welcome Check our low price and save big $$$... 86(571 )86795686 sales@pcbcore.com www.pcbcore.com VINCULUM VINCULUM VNC1L EMBEDDED USB HOST CONTROLLER 1C ■ Handles USB host interfaces and data transfer functions using the in-built 8 or 32-bit V-MCU. ■Configurable options to interface via UART, FIFO or SPI slave interface. ■ 2x USB 2.0 Slow speed or Full speed host or Slave ports. ■ Royalty free firmware field upgradable over UART or USB. BB Development modules and programmer are available. Chip Future Technology Devices International Ltd. Unit 1,2 Seaward Place Centurion Business Park Glasgow, G41 1HH , UK Tel: +44 (141)429 2777 Fax: +44 (141)429 2758 E-Mail (Sales): sales1@ftdichip.com Now available to order at www.ftdichip.com 9/2009 - elektor 35 MICROCONTROLLERS R32C Application Board Ready-to-use 32-bit microcontroller and OLED display By Marc Oliver Reinschmidt (Germany) and Jens Nickel (Elektor Germany Editorial) We recently announced that we would bring you an R32C starter kit project, including not only its own power supply, I2C and SD card interfaces, but also an OLED display panel. Here we deliver on our promise: see for yourself with our example oscilloscope project! Most Elektor readers will surely remem- ber our R8C project [1]. The super low cost kit included the processor board and a toolchain by download, and the series continued with an application board in March 2006 [2]. This mother- board, onto which the processor board could readily be mounted, greatly simplified the development of a wide range of applications. In May of that year the series continued with a simple oscilloscope application [3]. As well as being a slightly unusual project, it clearly demonstrated the great poten- tial of the microcontroller. What could be more appropriate than an update of that project as part of our series on the R32C? This 32-bit device offers considerably more processing power than its forebear, while still remaining largely code-compatible with it. New is a floating-point unit, which makes dealing with measured quantities much simpler and faster. And finally we have the OLED panel, whose operation we discussed in the May 2009 issue of Elektor [4], which does a splendid job of displaying our oscilloscope traces. Power supply Looking at the circuit diagram (Fig- ure 1), anyone familiar with micro- controllers will quickly recognise the main features of our R32C application board. Let us start with the power sup- ply: voltage regulator IC3 produces the 3.3 V operating voltage for both the microcontroller and for the OLED panel supply circuit. +3V3 K10 co > CO + 1 2 AN00 y 3 AN01 y 4 AN02 y 5 AN03 J 6 K5 GND h. GND 8 +3V3 o-T VCC 10 GND K3 +5V...+7V5 - - a3 -o D6 MBRS130 GND VDC1 NSD CNVSS / \ XCIN XCOUT / \ / \ RESET XOUT / \ XIN / \ 11 WIZ A1 / \ 12 WIZ_A0 13 WIZ INT / 14 PWR_EN 15 EPM 16 CE. 17 WIZ_WR 18 RESETB y y PWR_EN 14 19 E RDB 20 WIZ RD 21 WIZ_SCS. 22 WIZ_SCLK. 23 WIZ_MISO. 24 WIZ.MOSI 25 TXD1 26 RXD1 27 CLK1 28 CTS1 29 P33 30 SDA2. 31 SCL2 32 P30 PWR EN PWR EN 11 +3V3 O— < > C3 4u7 EN |C1 VS VOUTP PVIN FBN AVIN NCP5810D o a VREF ~z.~z.Ci CD CD Z < S- CD SWN C9 4u7 — i ► CIO 4u7 C7 4u7 OLED_VDD -O OLED_VSS -O VDC1 NSD CNVSS XCIN XCOUT RESET XOUT XIN WIZ A1 11 WIZ_A0 12 WIZJNT 13 EPM 15 CE 16 WIZ_WR 17 RESETB 18 E RDB 19 WIZ_RD 20 WIZ SCS 21 WIZ_SCLK 22 WIZ MISO 23 / \ WIZ_M0SI 24 / V y \ TXD1 RXD1 _25 26 CLK1 CTS1 / \ P33 SDA2 SCL2 P30 _27 _28 _29 _30 _31_ 32 +3V3 1 o o > VDC1 VDCO NSD TB3IN/P93 CNVSS AVCC IC2 VREF XCIN/P87 AN0/P100 XCOUT/P86 AVSS RESET AN1/P101 AN2/P102 XOUT AN3/P103 AN4/P104 XIN AN5/P105 AN6/P106 NMI/P85 AN7/P107 INT2/P84 7NT1/P83 AN00/P00 INT0/P82 AN01/P01 U/TA4IN/P81 AN02/P02 U/TA4OUT/P80 AN03/P03 R32C111 TA3IN/P77 INT3/P15 TA30UT/P76 INT4/P16 W/TA2IN/P75 INT5/P17 W/TA20UT/P74 V/TA1IN/P73 AN20/P20 V/TA10UT/P72 AN21/P21 TB5IN/P71 AN22/P22 TA0OUT/P70 AN23/P23 AN24/P24 TXD1/P67 AN25/P25 RXD1/P66 AN26/P26 CLK1/P65 AN27/P27 CTS1/P64 TA1IN/P33 TB0IN/P60 TA10UT/P32 TB1IN/P61 TA30UT/P31 TB2IN/P62 TA0OUT/P30 TXD0/P63 CO > RIO GND K4 C4 4u7 vCLKI 1 v CNVSS 3 vTXDI t 5 o m 7 vCTSI 9 v RXD1 11 RESET 13 R11 I O O o o o o o o o o o o o o 10 12 14 E8a debugger GND NSR0320MW2 T GND 64 63. 62. 61_ 60_ 59. 58. 57. 56_ 55 54 53. 52 51_ 50. 49 48 47. 46_ 45 44 £1 42_ 41 _ 40. 39. 38. 37 36. 35 34 33 s. VDCO P93 AVCC VREF WIZ CS AVSS SI. §2 S3 LED1 LED2 LED3 LED4 / S. / / s. / V / / / s. / V / / / AN00 AN01 AN02 AN03 RS RWWRB CSB DB1 DB2 DB3 DB4 DB5 DB6 DB7 DB8 y y y y SSO y CLKO y RXDO y TXDO y EPMyl K6 VDCO 1 P93 2 AVCC 3 VREF 4 WIZ CS 5 AVSS 6 SI 7 S2 8 S3 9 LED1 10 LED2 11 LED3 12 LED4 13 _r\ AN00 14 AN01 15 AN02 16 y-\ AN03 17 _r\ RS 18 V RW_WRB 19 CSB 20 V DB1 21 _r\ DB2 22 V DB3 23 _r\ DB4 24 V DB5 25 V DB6 26 V DB7 27 V DB8 28 V SSO 29 V CLKO 30 RXDO 31 TXDO 32 0+3V3 36 elektor - 9/2009 Features • socket for R32C processor board • all pins available on headers • power supply via mains adaptor • three buttons and four LEDs • 8 digital I/O pins • 4 analogue inputs • SD card interface controlled over SPI • l 2 C connection • 2.4 inch OLED panel with integrated controller (240 by 320 pixels), and on-board power supply • socket for Ethernet and TCP/IP daughter board • connection for E8a debugger oo OO' OOOuJuw Jk/v u ■-> 1 'J / d i 0LED_VDD O +3V3 O SI S2 S3 « Hj GND GND 090209 - 11 Power is made available on the various headers on the board that the R32C uses to communicate with the outside world. These can provide power to I 2 C slave devices or any more sophisti- cated interface circuits that you might design. Circuits can be constructed on the prototyping area provided on the board. We will look at the interfaces in more detail later, but for now we just note that under no circumstances should the R32C be powered over the USB socket on the processor board when it is mounted on the application board! This would lead to 5 V rather than 3.3 V appearing on all the power supply pins, likely causing irreversible damage to components. In order to isolate the board from the 5 V supply present on the USB con- nector when it is used to program the microcontroller, it is essential to remove jumper SJ7, a solder bridge located on the underside of the proces- sor board (see Figure 2). Before using the application board, therefore, use a soldering iron and a little desoldering braid to break the connection to pre- vent the risk of the high voltage per- manently damaging the board. Figure 1. Circuit diagram of the application board. The R32C processor is mounted on a daughter board, although for clarity we have omitted these connectors and shown the processor as directly connected to the peripherals. 9/2009 - elektor 37 MICROCONTROLLERS Figure 2. It is essential to open this solder bridge before fitting the processor board to the application board. Interfaces No development board is complete without pushbuttons and LEDs, of course; the R32C application board is no exception, sporting three push- buttons and four LEDs. Each of these devices is connected to an I/O port pin on the microcontroller, making them ideal for use in simple programming experiments. In more advanced appli- cations they can be used as part of the user interface or for status indication. Eight digital I/O pins are made avail- able on header K9. It seems a pity to use so many of the microcontroller’s own I/O pins for a simple port like this when they are better employed driving the OLED display panel and for other purposes we will describe later; and so we have instead employed an I 2 C port expander device. The port expander is connected to USART3 of the R32C, one of whose modes of operation is as an I 2 C interface. Being implemented in hardware the interface is fast and its configuration is flexible. To sim- plify programming, C functions are available for download from the web pages accompanying this article [5] that allow simple writing and reading of the I/O pins. These days there are many devices available that are controlled over an I 2 C port. We have therefore made the I 2 C bus signals available on RJ11 connec- tor Kl, which offers enormous scope for further expansion. Next door is the SD card slot. Writing to and reading from an SD memory card is done over the microcontroller’s hard- ware SPI interface. Further details can be found on the Internet [6]. Header K10 allows up to four analogue signals (from 0 V to 3.3 V) to be read by the microcontroller. OLED and more By far the most important feature of the application board is the 2.4 inch colour graphic OLED display. In the May 2009 issue of Elektor we showed how to draw simple geometric fig- ures on the display and how to show images loaded from a file. The small, freely-downloadable C graphics library [4] provides these functions and also allows text to be displayed on the panel. The May 2009 article also described how the OLED is driven. What we did not show in that article was how to power the OLED panel. The controller in the device requires a 3.3 V supply, and the display itself needs a symmetrical 4 V supply. We cannot generate a negative voltage using a linear regulator, and so we have selected a device from ON Semi- conductor, specifically designed for powering OLED panels. The details of how to use the device are covered in its datasheet [7]. Connector K4 allows the connection of the E8a debugger, which we briefly described in an article in April 2009 [8]. This relatively inexpensive hardware tool makes debugging a more pleas- ant experience than using the KD100 software-only debugging solution that forms part of the starter kit and which was also described in the April 2009 article. One final neat feature: headers K7 and K8 will accept the WIZ812MJ Ethernet module. This elegant little daughter board, made by WIZnet [9], provides a network interface and even imple- ments the higher network protocol lay- ers. This ‘network card for microcon- trollers’ includes the special-purpose W5100 IC, an RJ45 socket, the neces- sary transformer, and status LEDs. It provides the R32C with the ability to send e-mails or act as a web server. FTR UDP and many other protocols are supported. We do not have the space to give a detailed description of the module and its software here, but we hope to devote a whole article to the device towards the end of this year. Oscilloscope Now we come to the main course: a two-channel oscilloscope example oooooooooooooof ooooooooooooool ooooooooooooooooc OOOOOOOOOOOOO ooooooooooooo OOOOOOOOOOOOO — OOOOOOOOOOOOO OOOOOOOOOOOOO OOOOOOOOOOOOO ‘ OOOOOOOOOOOOO OOOOOOOOOOOOO ‘ H OOOOOOOOOOOOO ' | OOOOOOOOOO _ OOOOOOOOOOS * < ■ f— i OOOOOOOOOO?* ■ OOOOOOOOOO?* X * OOOOOOOOOO!* X * [— \ oooooooooo?’ Oly b) OOOOOOOOOO?’ ||\ • K) oooooooooo bi oooooooooooo ■ ! , oooooooooooo , , * WIZ612HJ H JCMkU % ,, V 3 » 4 f -frfl 09 0082-1 U110 Elektor v Z 13 ^ P ■*» Figure 3. The board sports pushbuttons, LEDs, an I2C interface, an OLED panel, an SD card interface and a socket for an Ethernet module. 38 elektor - 9/2009 Figure 4. There is plenty of space on the board for further expansion. application to show off the power of the R32C. The software is available for free download from the web pages accompanying this article [5]. The software only emulates a few of the basic functions of an oscilloscope, and can of course be extended and modified as the fancy takes you. The analogue-to-digital (A/D) converter in the R32C offers a conversion time of 2.06 jl/s and thus a maximum sam- ple rate of 480 kHz. According to the Nyquist-Shannon sampling theorem, the available bandwidth is equal to half the sample rate, in this case 240 kHz. Although this may not seem very impressive, it is worth remem- bering that we are using the micro- controller’s built-in converter rather than a special-purpose A/D converter IC. If higher sample rates are required, an external device can be connected, using the SPI or a similar port. When using an external device it is also eas- ier to suppress noise by providing the converter with a power supply free of interference from the circuitry inside the microcontroller. The program When the program starts it carries out all the necessary initialisations, in par- ticular of the R32C’s clock generator and of the display. The function library COMPONENT LIST Resistors (all SMD0805) R8 = on R3 / R4 / R5 / R6 = 470Q R7 = 2.4kQ R 1 ,R2,R9,R 1 0,R 1 1 = 4.7kD Capacitors Cl 1 = lOpF Cl / C2 / C5 / C6 / C8 / C1 5-C22 = 1 pF 25V (SMD0603) C3,C4,C7,C9,C10 = 4.7pF 10V (SMD0603) Cl 4 = lOOnF (SMD0603) Cl 2, Cl 3 = 47|jF 1 6V tantalum (SMD7343) Inductors LI 42 = 4.7|jH (VLF301 0AT-4R7MR70) Semiconductors D1 = NSR0320MW2 D2,D3,D4,D5 = LED, red (SMD0805) D6 = MBRS1 30 IC1 = NCP5810D IC2 = socket: 2 pcs 32-pin SIL socket strip (Fischer SL1 series), R32C processor board comprised in R32C Starter Kit # 080928-91, see below IC3 = LF33CV IC4 = PCF8574T Miscellaneous K1 = RJ1 1 socket K2 = OLED connector (Hirose FH23-61 S-0.3SHW(05)) K3 = DC adaptor socket, PCB mount K4 = 1 4-way boxheader K7,K8 = 20-way DIL socket strip (Fischer BL2 series) K5,K6 = 32-way SIL pinheader (Fischer SL1 series) K9 = 10-way SIL pinheader (Fischer SL1 series) K1 0 = 6-way SIL pinheader (Fischer SL1 series) K 1 1 = SD card socket (Multicomp SDCMF-1 09 1 5W0T0) S1,S2,S3 = pushbutton OLED, CMEL type C0240QGLA-T R32C starter kit, Elektor Shop # 080928- 91 , see [5], [8] PCB # 080082-2, see [5] 9/2009 - elektor 39 MICROCONTROLLERS PO - P2 090209-12 Figure 5. After an A/D conversion the results are found in registers ADOO and AD01. hwsetup.c includes an easy-to-use clock set-up function: the PLL param- eters and division ratios are config- ured in the accompanying header file. All the OLED display driver functions, as described in the May 2009 issue [4], are also included in this library For the oscilloscope demonstration software pins AN00 and AN01 (A/ D port 0) are used. These inputs are made available on connector K10. The A/D converter supports a range of dif- ferent modes, including a single-shot mode and repeat modes. Since in a two-channel oscilloscope two sets of readings need to be taken, we config- ure the converter so that the two inputs are sampled alternately (the relevant registers are shown in Figure 5). The results end up in separate registers: the R32C has eight buffer registers per A/D port. In this case our readings will be found in registers ADOO and AD01. So that the data can be processed quickly, the values in these registers are transferred to separate RAM buff- ers after each conversion cycle using DMA (direct memory access). The DMA process can copy data from one memory area to another without inter- vention from the processor. Indeed, the only effect on the processor is that the internal bus is occupied briefly while the transfer takes place. The transfer is triggered by the end-of-conversion sig- nal from the A/D converter. The next conversion begins immediately. The DMA process continues to run, com- pletely automatically, until all the sam- ples required for the trace have been obtained and stored. The DMA engine requires the following parameters to be set: • source address (where the data come from, in this case the A/D converter); • destination address (where the data go to, in this case a RAM buffer); • trigger source (what initiates a trans- fer, in this case the A/D converter); • transfer count (how many data items are to be transferred). Listing 1 shows how the relevant reg- isters are initialised. Image construction Now that we have all our data sitting in RAM, we are in a position to con- struct the display image. First we must erase any previous trace on the screen. Iterating over the entire image would take rather a long time, so instead we make the optimisation of only clear- ing to background colour those pixels that were set in the previous image. We then set the appropriate pixels for the new trace. This process is very quick as only 320 pixels (the width of the display) need to be addressed in each of the two passes; a full re-write of the display screen would address 320x240 =76800 pixels. In fact, because of the display graticule and other background symbols, it is not enough to simply reset the pixels of the old trace to the background colour. Instead, the required background pixel colour is loaded from a table located in the R32C’s flash memory. In order to maintain a steady trace on the display, it is necessary to imple- Listing 1: Initialisation void measurement_init (void) { // Init A/D-Converter adOconO = OxBO; // conversion stopped | timer trigger | single sweep ad0con2 = 0x25; // Trigger Timer B2 | AN0_0 Group | with sample & hold adOconl = 0x38; // VRef connected | lObit resolution | sweep ANO & AN1 ad0con3 = 0x01; // DMAC ENABLED ! ! ! ! ad0con4 = 0x00; // // Init Timer B2 tbOmr = 0x4 0 ; // Timer Mode f8 tb2 = 0x0030; // Timer Value 0x30 // Init DMAC dmdO = 0x00; // Disable all functions dmOsl = 0x18; // ADO -interrupt dm0sl2 = 0x00; dsaO = &ad00; // source is ADOO dmOic = 0x02; // interrupt priority 02 (DMA) adOic = 0x01; // interrupt priority 01 (ADC) tb2ic = 0x01; // interrupt priority 01 (Timer Bl) 40 elektor - 9/2009 Listing 2: Rendering the oscilloscope trace /******************************************************************** * DRAWING * ******************************************************************** * Parameter * - channel * - data: * - offset: * - yoffset * * describes the channel which should be drawn reference to the data buffer offset for the measured values position of base line: channel 0 : 0 channel 1: -100 * * * * * * ******************************************************************** / void oszi_draw_data (unsigned char channel, unsigned int *data, unsigned int offset, signed char yoffset) { unsigned int pos, ypos, ypos_ref, ypos_prev, ypos_draw, data_pos; // set offset for data buffer // the values of both channels are alternating data_pos = offset * 2 + channel; // calculate the first value ypos_prev = 105-yoffset- ( (unsigned int ) (data [data_pos] ) %1024 ) *100/1023 ; // calculate all 309 values and draw the connection lines for(pos=l; pos<=310 ; pos++ ) { // calculate the new position for data buffer data_pos = (pos+offset) * 2 + channel; // calculate new Y-position ypos = 105-yoffset- ( (unsigned int ) (data [data_pos] ) %1024 ) *100/1023 ; // calculate the average of old and new Y-position ypos_ref = (ypos_prev + ypos) / 2; // draw falling or horizontal connection lines if (ypos_prev >= ypos) { // draw line starting from first X-value of the old Y-position to the reference (half height) for (ypos_draw=ypos_prev;ypos_draw>=ypos_ref ; ypos_draw- - ) setPixel (ypos_draw, 315-(pos-l), 0x3F, (channel==0) ?0x00 : 0x3F, 0x00); // draw line starting from the second X-value of the reference to the new Y-position. for (ypos_draw=ypos_ref ; ypos_draw>=ypos ; ypos_draw- - ) setPixel (ypos_draw, 315-pos, 0x3F, (channel==0) ?0x00 : 0x3F, 0x00); } // draw rising connection lines else { // draw line starting from first X-value of the old Y-position to the reference (half height) for (ypos_draw=ypos_prev;ypos_draw<=ypos_ref ; ypos_draw++) setPixel (ypos_draw, 315-(pos-l), 0x3F, (channel==0) ?0x00 : 0x3F, 0x00); // draw line starting from the second X-value of the reference to the new Y-position. for (ypos_draw=ypos_ref ;ypos_draw<=ypos ; ypos_draw++) setPixel (ypos_draw, 315-pos, 0x3F, (channel==0) ?0x00 : 0x3F, 0x00); } // store Y-position as the old Y-position ypos_prev = ypos; } } ment some kind of trigger function. The trigger condition in the demonstration software is based on the rate of change of the input signal. The display is only refreshed when the trigger condition is satisfied. The relevant C function has a loop that checks the incoming readings until it finds a point where the trigger condition is satisfied. The trace is plotted from this point on (see Listing 2). For this approach to work, it is of course necessary to have enough input data available. Rather than fetch- ing just 320 samples, which would be enough to fill the width of the screen, we therefore fetch twice that number. This guarantees that if a suitable trig- ger point is found there will be enough data to render a complete trace. As you can see in our main photo- graph, the final result looks rather impressive. ( 090209 - 1 ) Internet Links [1] www.elektor.com/r8c [2] www.elektor.com/0501 79-3 [3] www.elektor. com/0501 79-5 [4] www.elektor.com/081 029 [5] www.elektor.com/090209 [6] www.captain.at/electronic-atmega-mmc.php [7] www.onsemi.com/pub_link/Collateral/ NCP5810-D.PDF [8] www.elektor.com/080928 [9] www.wiznet.co. kr/en 9/2009 - elektor 41 Quasar Electronics Limited PO Box 6935, Bishops Stortford CM23 4WP, United Kingdom Tel: 01279 467799 Fax: 01279 267799 E-mail: sales@quasarelectronics.cor Web: www.quasarelectronics.com Postages & Packing Op tions (Up to 0.5Kg gross weight): UK Standard i i 3-7 Day Delivery - £4.95; UK Mainland Next Day Delivery - £9.95; P Europe (EU) - £8.95; Rcsst of World - £12.95 (up to 0.5Kg) SOrder online for reduced price UK Postage! EUROCABD We accept all major credit/debit cards. Make cheques/PO’s payable MasteiCam to Quasar Electronics. Prices include 15.0% VAT. Please visit our online shop now for details of over 500 kits, V , SA projects;, modules and publications. Discounts for bulk quantities. | Electron | Maestro QUASAR electronics The Electronic Kit Specialists Since 1993 127 Credit Card 467*799 otor Drivers/Controllers I Controllers & Loggers ■i" 1 3: lere are just a few of our controller and river modules for AC, DC, Unipolar/Bipolar tepper motors and servo motors. See /ebsite for full range and details. Computer Controlled / Standalone Unipo- lar Stepper Motor Driver Drives any 5-35Vdc 5, 6 or 8-lead unipolar stepper motor rated up to 6 Amps. Provides speed and direc- ■ tion control. Operates in stand-alone or PC- controlled mode for CNC use. Connect up to six 3179 driver boards to a single parallel port. Board supply: 9Vdc. PCB: 80x50mm. Kit Order Code: 3179KT - £15.95 Assembled Order Code: AS3179 - £22.95 Computer Controlled Bi-Polar Stepper Motor Driver Drive any 5-50Vdc, 5 Amp bi-polar stepper motor us- ing externally supplied 5V levels for STEP and DI- RECTION control. Opto- isolated inputs make it ideal for CNC applica- tions using a PC running suitable software. Board supply: 8-30Vdc. PCB: 75x85mm. Kit Order Code: 3158KT - £23.95 Assembled Order Code: AS3158 - £33.95 Bi-Directional DC Motor Controller (v2) Controls the speed of most common DC motors (rated up to 32Vdc, 10A) in both the forward and re- verse direction. The range of control is from fully OFF to fully ON in both directions. The direction and speed are controlled using a single potentiometer. Screw terminal block for connections. Kit Order Code: 3166v2KT - £22.95 Assembled Order Code: AS3166v2 - £32.95 DC Motor Speed Controller (100V/7.5A) Control the speed of almost any common DC motor rated up to 100V/7.5A. Pulse width modulation output for maximum motor torque at all speeds. Supply: 5-15Vdc. Box supplied. Dimensions (mm): 60Wx100Lx60H. Kit Order Code: 3067KT - £17.95 Assembled Order Code: AS3067 - £24.95 i lost items are available in kit form (KT suffix) r assembled and ready for use (AS prefix). Here are just a few of the controller and data acquisition and control units we have. See website for full details. Suitable PSU for all units: Order Code PSU445 £7.95 8-Ch Serial Isolated I/O Relay Module Computer controlled 8- channel relay board. 5A mains rated relay outputs. 4 isolated digital inputs. Useful in a variety of control and ^“sensing applications. Con- trolled via serial port for programming (using our new Windows interface, terminal emula- tor or batch files). Includes plastic case 130x100x30mm. Power Supply: 12Vdc/500mA. Kit Order Code: 3108KT - £64.95 Assembled Order Code: AS3108 - £79.95 Computer Temperature Data Logger 4-channel temperature log- ger for serial port. °C or °F. Continuously logs up to 4 separate sensors located 200m + from board. Wide range ot tree software applications for stor- ing/using data. PCB just 45x45mm. Powered by PC. Includes one DS1820 sensor. Kit Order Code: 3145KT - £19.95 Assembled Order Code: AS3145 - £26.95 Additional DS1820 Sensors - £3.95 each Rolling Code 4-Channel UHF Remote State-of-the-Art. High security. 4 channels. Momentary or latching relay output. Range up to 40m. Up to 15 Tx’s can be learnt by one Rx (kit in- cludes one Tx but more avail- able separately). 4 indicator LED ’s. Rx: PCB 77x85mm, 12Vdc/6mA (standby). Two and Ten channel versions also available. Kit Order Code: 3180KT - £49.95 Assembled Order Code: AS3180 - £59.95 DTMF Telephone Relay Switcher Call your phone num- ber using a DTMF phone from anywhere in the world and re- motely turn on/off any of the 4 relays as de- sired. User settable Security Password, Anti- Tamper, Rings to Answer, Auto Hang-up and Lockout. Includes plastic case. Not BT ap- proved. 130x110x30mm. Power: 12Vdc. Kit Order Code: 3140KT - £74.95 Assembled Order Code: AS3140 - £89.95 iX !L i ' ■ f- -fii B 1 i Hr m: w m Infrared RC Relay Board Individually control 12 on- board relays with included infrared remote control unit. Toggle or momentary. 15m+ range. 112x122mm. Supply: 12Vdc/0.5A Kit Order Code: 3142KT - £59.95 Assembled Order Code: AS3142 - £69.95 New! 4-Channel Serial Port Temperature Monitor & Controller Relay Board 4 channel computer serial port temperature monitor and relay con- troller with four inputs for Dallas DS18S20 or DS18B20 digital ther- mometer sensors (£3.95 each). Four 5A rated relay channels provide output control. Relays are independent of sensor channels, allowing flexibility to setup the linkage in any way you choose. Commands for reading temperature and relay control sent via the RS232 interface using simple text strings. Control using a simple terminal / comms program (Windows HyperTerminal) or our free Windows application software. Kit Order Code: 3190KT - £69.95 PIC & ATM EL Programmers We nave a wide range of low cost PIC and ATMEL Programmers. Complete range and documentation available from our web site. Programmer Accessories: 40-pin Wide ZIF socket (ZIF40W) £14.95 18Vdc Power supply (PSU120) £19.95 Leads: Serial (LDC441) £3.95 / USB (LDC644) £2.95 USB & Serial Port PIC Programmer USB/Serial connection. Header cable for ICSP. Free Windows XP software. Wide range of supported PICs - see website for complete listing. ZIF Socket/USB lead not included. Supply: 16-18Vdc. Kit Order Code: 3149EKT - £49.95 Assembled Order Code: AS3149E - £59.95 USB 'All-Flash' PIC Programmer USB PIC programmer for all ‘Flash’ devices. No external power supply making it truly portable. Supplied with box and Windows Software. ZIF Socket and USB lead not included. Assembled Order Code: AS3128 - £49.95 See website for full range of PIC & ATMEL Programmers and development tools. No.1 S KITS www. auasare/ectron/cs. co Secure Online Ordering Facilities • Full Product Listing, Descriptions & Photos • Kit Documentation & Software Downloads Dy Jens INICKei On the PCB we can see the SIM card holder, USB connector for bat- just when you thought mobile tery charging, the battery connections, loudspeaker and micro- phones couldn’t get much smaller Elektor Labs phone. At this point Antoine looked genuinely surprised ‘Wow, spotted one the size of a credit card and priced just under 1 7 euros that’s so tiny’. Despite its diminutive size the microphone provides or about 25 dollars. No contract, no SIM card lock or restrictions! surprisingly good speech quality. The Simvalley RX-80 Pico comes with a 1 .2” LCD, SMS messaging, Keypad backlighting is essential at night and in this phone a few telephone directory and even a back-lit keypad. Intrigued, we took LEDs provide the necessary glow. We took the opportunity to pow- a closer look! er up using a three volt supply (see picture above right). Further circuitry is tucked away behind a plate which provides RF It’s not just the price but also the size and weight of the ‘Simvalley shielding. The hot-air gun wasn’t much use here so we set to work RX-80 Pico’ from Pearl Diffusion that is astonishing. At 50 x 80 x 1 0 with a Dremel tool. mm and tipping the scales at just 44 g this phone can be easily The largest 1C is a Flash memory from the Taiwanese company Eon stashed in a wallet or purse. Heiko Loy, the press spokesman for Pearl, told us that the 1 7 Euro mobile phone is mass produced in China. Antoine Authier the head of our laboratory here at Elektor took a closer look at the phone. Armed with a plastic tool designed to open iPods he quickly separated the two halves of the case. The PCB is retained by clips in the lower half of the case (screws would be way too expensive!). A short length of adhesive tape holds the display to the PCB, this is quickly removed as Antoine wields a hot-air gun. The 1 .5 mm thick display is connected via 14 pins to the PCB. We searched for any identification marks on this component but sadly were out of luck this time. Silicon Solution [2]. It is most likely used to store SMS texts, phone directory, caller information and multiple versions of the menu text in every language option. The second chip carries the inscription SKY7751 8-21 identifying it as a dual-band GSM front end module from Skyworks Solutions [3]. The third chip (inscribed 7880 1 .3G FC G091 4) is probably some variant of the old 7880 GSM baseband processor marketed by Infi- neon. As always we value your feedback, if you have more informa- tion on this device don’t hesitate to get in touch! [1 ] www.pearl.fr [ 2 ] www.eonssi.com [3] www.skyworksinc.com (090502-1) 9/2009 - elektor 43 E-LABS INSIDE soldering in reflow oven! Double-sided All a matter of accuracy - but it’s child’s play ! By Antoine Authier (Elektor Labs) Many readers are eager to find out just what our reflow oven is ca- pable of have often asked me if they could solder components on both sides of their boards. My initial answer was certainly yes — at least in theory; so I started looking around for a project to demon- strate in practice that double-sided soldering is possible. I settled on the USB-I 2 C interface published in February 2009, as a PCB hadn’t yet been designed for this project, and the prototype we had certainly wouldn’t win any prizes for elegance. To my way of thinking, a dongle ought to be compact and have a neat appear- ance; it contains a handful of passive components and a few ICs. While I was about it, I thought I’d add an electronic serial number function using a DS2401 , along with ESD protection (yet another Maxim chip). These devices are all available in SMD packages ideal for a double-sided board, and so meeting my criteria. Of the three through-hole components, I kept only the RJ1 1 connector, partic- ularly to give me an excuse for mentioning the order for solder- ing through-hole components with respect to the surface-mount devices. Get together the component layout, component list, and the com- ponents themselves. You need to solder the ‘underneath’ SMD components first. Start 44 elektor - 9/2009 by applying soldering paste to the solder pads, then a small drop of SMD adhesive between the pads, preferably in the centre of the lo- cation for the component being soldered. When heated, the epoxy- based SMD adhesive polymerizes and holds the component — it’s like magic! Now place the components in their positions and solder in the oven using your favourite/usual reflow program. Tip: before starting the soldering process, check one last time that the compo- nents haven’t shifted while being moved to the oven. The soldering method is simple Leave to cool down, and get ready for the next step: apply the sol- dering paste, this time to the ‘top’ pads, then place the SMD com- ponents. Here, there’s no need for adhesive. Solder in the oven us- ing your favourite program. The underneath components won’t fall off, as they are glued. Once the board has cooled down, all that’s left to do is solder the through-hole components using a conventional soldering iron. The notions of ‘underneath’ and ‘top’ are arbitrary — you can of course start by soldering the top components and finish with the underneath ones; the important thing is to glue the components for the first soldering operation, so they are held on the board while the second side is being soldered. To decide which side to glue, as I see it there are three main criteria. The first one is strategic: glue preferably passive components, to avoid as far as possible soldering the more valuable ICs twice. The second criterion is a practical one: you should glue as few large components as possible, since in the event of a mistake, the smaller components are the easiest to unglue. The last criterion is an economic one: it’s better to use the adhesive on the side with fewest components. It’s also important to take these considerations into account when designing the board, so as to distribute the components sensibly between the two sides. So we can deduce that on the glued side, there should be as few components as possible, and preferably all passive ones. One last small detail: to unglue a component, all you have to do is hold it firmly using tweezers, heat it up (preferably with a hot-air gun) and push it gently away from its position in order to break the blob of adhesive. Now let’s get cooking! ( 090570 - 1 ) 9/2009 - elektor 45 E-LABS INSIDE Chris Vossen LucLemmens It’s not every day that our lab engineers Luc and Chris have an op- Why do you want it? portunity to work with an oscilloscope that costs around €1 2,000. Thanks to the generosity of the scope manufacturer, Yokagawa, we Frequency bandwidth: 500 MHz had a DLM 2054 available on loan in the lab for a few months. The Analog input channels: 4 only question was: who would get to use it? A/D resolution: 8 bit (25 LSB/div) Real time sampling mode : interleave off : 1 .25 GS/s interleave on: 2.5 GS/s Maximum record length: Repeat / Single / Single Interleave 12.5 M/ 62.5 M/ 125 Mpoints Maximum sampling rate: 1.25 GS/s Trigger modes: Auto, Auto level, Normal, single, N-single Trigger types (excerpt): Edge, State, Pulse width, State width, l 2 C, SPI, UART, CAN Display: 8.4 inch TFT LCD Built-in printer USB peripheral connection terminal USB PC connection terminal Ethernet External dimensions: 226 (W) x 293 (H) x 1 93 (D) mm Weight: approx. 4.2 kg (090572) A scope is indispensable in the lab; we use them every day for all sorts of measurements. The DLM 2054 is remarkably easy to use. The menu is intuitive, which is just right for me. The amount of memory in the scope is important. This in- strument comes standard with 1 .8 GB of memory, so it can hold a lot of signal history. And it has a sampling rate of 2.5 gigasamples per second, with a bandwidth of 500 MHz and four channels. am Of course, you have to consider what you want to use it for. With I2C circuits, the special trigger modes are a real help. And it has a built-in printer, which is handy when you need to check something quickly. If you can put down the 1 2,000 euros, I can certainly use the scope. Maybe we should just say that we need more time to try it out. But I’m the one who wants it! Website of the DLM2000 series (starting price around 3,300 Euros) from Yokogawa: www.dlm2000.net studied Electronics at Heerlen Polytechnic and afterwards worked in a small company for a number of years where he designed data logging equip- ment. He has worked as a designer here at the Elektor lab since 2005. He spe- cialises in larger microcontroller projects for example the recent R32C and the ATM18 project series. studied Electrical Engineering at Eindhoven Technical University and has been a fixture here at Elektor. for the last 19 years where he works as a develop- ment engineer and technical editor. Luc’s expertise is in measurement technigues and microcontroller circuits. He is also responsible for selecting smaller projects and for example the choice of designs for our special Summer Circuits edition. 46 elektor - 9/2009 offer a wide choke &f mput voyage* enrt bil pr-oiiles lor our soltf-ehng irofi ramuge A N T E X U/LJLJLJLJ 60 + years of experience It may surprise you bul buying -an Ante* soldoring iron costs loss than you Ihmk in the lon-q run,. British made to exaclinLf standards,, I hey last significantly longer than many imported brands, w^h a wide range of ciwnvdLy haianced medals, >inn remper^turt controlled irons. too H you can always he- u i rr- tn firvd un ir&n chat irieeti your noeds. A large range of replaccniDnt trps are available for most irons, and technical hrfp is cm hand from our oFfices lin Devon UK. Buy Online Our iH'rt WpJjMl f 1 1 1 As .ill of fiur irOJli . and Holding 4p .Ire'S And 4«iHfCiw available 24h*s a day- Most items. an shipped ne»l day. Why rtrH give? ianlttx.co-uk ii try ! An l^x Electronics ltd 2 Westb ridge Industrial Estate Tavistock, Devon PS.19 SDE, UK Tel: -+44(0)1522 6T3565 Fa xl +44(0)1822 617598 Email: irex.co.uk We?b: wwvv.anSttx.co.uk We add value to PCBs when others just sell it. 310 ca, for 5pcs VxA v 2L Free Solder Mask & Silkscree Free Component Components Pcbs Enclosul.es Fpcs Keypads V | 1 i-jr rt -. a hj j | jg [T L "'ijdfaSft zj. kj _ a m "a □ ? i -t | ■ — . P , B iNWW.EiPCB.cam Ents II; s a les O^fliPE b.n-nm Please Wail «ww mach mepier.co-m for Machining 9/2009 - elektor 47 INSTRUMENTATION Everything under control Steffen Graf (Germany) This circuit was originally designed for monitoring the charge status of the batteries in a solar-powered water feature. However, it can be used in any application where batteries are charged and discharged. The circuit uses an LPC2103 microcontroller connected to a 22-bit analogue-to-digital (A/D) converter to measure charge and discharge currents, battery voltage, charge status (or available capacity) and the instantaneous power being supplied to or drawn from the battery. There are various ways of providing rechargeable battery packs with an indication of their charge status. The most widespread uses a simple volt- age measurement; however, NiMH and NiCd cells have a rather flat voltage discharge curve and so the method is not particularly accurate in this case. A better approach is also to measure the current into or out of the battery. This allows calculation of the flows of power and charge, and hence (if the initial state is known) also the available bat- tery capacity. The module described 48 elektor - 9/2009 here offers all these features and can be used to monitor batteries or more generally to meter voltages, currents and power in any DC supply system. The author uses the module to monitor a small solar-powered installation. The unit can work over a wide volt- age range, from 6 V to 42 V, and so can be used in typical lead-acid bat- tery applications at 6 V, 12 V, 24 V or 36 V. The current range is also very wide; despite this, resolution is high, with measurements accurate to around 1 mA. A 50 mQ SMD shunt resistor, rated at 2 W, makes for a compact con- struction and allows currents of up to 6 A to be measured. Overview The microcontroller used is the LPC2103, a 32-bit ARM7-based RISC device from NXE It differs in only minor details from the LPC2106 device used in the ARMee development board described in the April 2005 issue of Elektor and in the article Automatic Running-in Bench’ published in April 2009. Both are based on the 32-bit ARM7TDMI core, which we described in an article in the March 2005 issue. The LPC2103’s internal A/D converter has a resolution of only 10 bits: this is enough for our voltage measurement, but not enough for the current meas- urements we want to make. Further- more, since we want to be able to measure current flow in either direction (charge and discharge) we need an A/ D converter with a differential input. We therefore use the internal A/D con- verter only for voltage measurement, and employ an external converter for current measurement. We selected the Microchip MCP3550-50, which was briefly described on page 87 of the Summer Circuits (July/ August) 2008 issue of Elektor. This remarkable IC (see text box) is a 22-bit delta-sigma converter with differential inputs and an SPI port, available in a reasonably easy-to-solder SMD package. An important aspect of this project is the generation of the various supply voltages. The circuit requires 5 V for the LCD, 3.3 V for the A/D converter and for the microcontroller, 1.8 V for the microcontroller core and 1.2 V as a reference for the A/D converter. All these voltages must be generated These devices require minimal exter- nal circuitry. The input side of IC6 (the MCP3550) is simply connected across the shunt resistor to measure the bat- tery current: the shunt is connected directly between the input and output terminals on the printed circuit board. The board is inserted in the line to the battery using these terminals, and hence can monitor current flows into and out of the battery. Terminal K1 also provides the power supply for the cir- cuit via 5 V switching regulator IC1, and, via the voltage divider formed by R3, PI and R8, provides the volt- Features • Display of current (in mA or A), voltage (mV), capacity (Ah) and power (mW or W) • Suitable for monitoring all types of rechargeable battery • Suitable for battery voltages from 6 V to 42 V • Maximum measured current: ±6 A • High precision: voltage resolution 76 mV, current resolution 12 juA (internal), 1 mA (displayed) • Low power consumption due to use of high-efficiency step-down converters: <200 mW (backlight off), <300 mW (backlight on) • Module takes into account its own power consumption in calculating current and capacity • Display update rate 1 Hz • Over- and under-voltage fault LED • Backlit 2-by-1 6-character LCD • Compact construction • Serial interface for outputting measured values • Firmware available for free download from Elektor website efficiently from a highly variable input supply (between 6 V and 42 V). That demands a switching converter to pro- vide a 5 V regulated supply directly from the input. A second switching converter drops the 5 V supply to 3.3 V, and the remaining voltages (1.8 V and 1.2 V) are generated from the 3.3 V supply using linear regulators. Even at high input voltages the power dis- sipation of the circuit is low, removing the need for a bulky heatsink. Circuit and construction The complete circuit is shown in Fig- ure 1 . Out of the total of six ICs, four are voltage regulators. The switching regulators (IC1 and IC2) can be iden- tified by the inductors connected to them, while the linear regulators (IC3 and IC4) just have decoupling and smoothing capacitors. The meter cir- cuit itself comprises just the LPC2103 (IC5) and the A/D converter (IC6). age measurement input. The divider reduces the voltage to a level suitable for input to the A/D converter built in to the LPC2013, which can only accept voltages from 0 V to 3.3 V. The poten- tial divider can be set up in two differ- ent ways: 1. use 0.1 % tolerance components for R3 and R8, in which case PI can be dispensed with; 2. use normal (1%) resistors and then calibrate the measured voltage by adjusting PI. R8 is then omitted. If the input voltage is over 40 V then adjustment of PI will be necessary in any case for best accuracy; and if the input voltage is over 42 V adjustments to the software are also needed. Jumper JP2 allows the unit’s 5 V sup- ply to be taken from the programming interface. This allows the microcontrol- 9/2009 - elektor 49 INSTRUMENTATION Figure 1. Circuit diagram of the battery monitor. Out of the total of six ICs, four are voltage regulators. The meter circuit proper consists of a 32-bit ARM7 microcontroller (IC5) and a 22-bit A/D converter (IC6). ler to be programmed without a battery being connected. If a battery is con- nected while power is being supplied over the programming interface, IC1 will only draw a few milliamps from it: the rest of the circuit will still take its power from the programming inter- face. Don’t forget to change the jumper back to battery power after program- ming the microcontroller. Alternatively, if the ability to power the unit over the programming interface is not needed, JP1 can be replaced by a wire link join- ing + 5 V BATT and + 5 V. The LCD panel used has a backlight. In the interests of reducing power con- sumption the light can be turned on and off. Button SI, connected to port pin P0.2 on the microcontroller, controls a routine in software that causes a PWM signal to appear on pin P0.9. This in turn drives MOSFET T1 to provide a dimmable backlight. If the ability to turn the backlight off is not needed, RIO can be replaced by a 220 Q resis- tor (instead of 0 Q) and the MOSFET replaced by a wire link joining source and drain. R9, as well as R6 and SI, can be dispensed with. If the backlight is not required, all the related compo- nents (SI, R6, R9, RIO and Tl) can be dispensed with. In order to make the module no larger than the LCD, the printed circuit board (Figure 2) is almost entirely populated with SMD components. This demands a certain amount of deftness with the soldering iron, especially when it comes to the LPC2103 in its LQFP48 package. Despite the 0.5 mm lead pitch, it is lining the device up with the pads on the board that is the tricky part of assembly, not the soldering itself. The easiest way to solder the device is to melt solder over all of the leads on one side at a time (not wor- rying about short circuits) and then remove excess solder using braid. It is helpful to use a little flux. It is best to mount the microcontroller first so that the other components do not get in the way of the action. Then solder all the other ICs and finally the other SMD components. Finally mount the leaded components. Figure 3 shows our prototype board, which differs in minor details from the final layout shown in Figure 2. 50 elektor - 9/2009 Figure 2. The printed circuit board is mostly populated with SMD components and is the same size as the LCD panel. COMPONENT LIST Resistors: (SMD0805, 0.1 25W, 1% unless otherwise indicated) R1 = 0D05 2W 1% (SMD shunt resistor, 5mm x 0.3mm, e.g. Vishay/Dale) R2,R5,R6,R7 = lOkD R3 = 1 00 kD (see text) R4 = 1 kQ R8 = 8k£225 (see text) R9,R1 0 = OD (or T ^2, RIO also 220D, see text) PI = 10l<£2 multiturn preset, 19mm (see text) P2 = 100kD preset, horizontal mounting, 1 Omm Capacitors Cl = 1 OO/iF 63V 20%, aluminium, SMD (G) or axial wired C2 = 3 3 OyL/ F 25V 20%, aluminium, SMD (F) or axial wired C3 = 1 00jL/F 1 6V 1 0%, tantalum SMD (7343-31) C4 = 1 0jL/F 1 6V 1 0%, X5R, multilayer SMD 1210 C5,C6,C9,C1 0,0 3-C1 7 = 100nF50V10 %, XR7, multilayer SMD 0805 C7 = 1 OnF 50V, 1 0%, XR7, multilayer SMD 0805 C8 = lyL/F 16V 10 %, XR7, multilayer SMD 0805 Cl 1 ,C1 2 = 22pF 50V 5%, multilayer SMD 0805 Inductors LI = 330/^H, 590mA, 20%, SMD 10mm x 10mm (e.g. EPCOS) L2 = 22jL/H, 925 mA, 30%, 5mm x 35mm (e.g. WE-TPC, Wurth) Semiconductors D1 = 3A Schottky diode, 100V, 620mV, SMC case, e.g. 30BQ100TRPBF (Vishay, IRF) D2 = LED, red, low current (2mA) T1 = 2N7002 (N-channel MOSFET, 60V 1 15mA, Fairchild, SOT-323) IC1 = TL2575HV-05 (5V 1 A step-down switch-mode regulator, Tl, T0263) IC2 = TPS62007 (step-down switch-mode regulator, Tl, MSOP10) IC3 = TPS791 1 8 (LDO regulator, 1 .8V 1 00 mA, Tl, SOT-23-5) IC4 = MAX6520 (1 .2V voltage reference, Maxim, SOT23-39 IC5 = LPC21 03FBD48 (70MHz ARM7, 1 6KB Flash, 8KB RAM, NXF) LQFP48) IC6 = MCP3550-50 (22-bit delta-sigma ADC, Microchip, SOIC08) Miscellaneous XI = 1 4. 7456MHz quartz crystal, 18pF load capacitance, 30ppm SI = SPNO pushbutton, PCB mount (e.g. Omron B3W-1000) K1,K2 = PCB screw terminals, 16A, pitch 5mm K3 = SIL 6-way right-angled pinheader K4 = SIL 1 6-way socket strip, for LCD mounting JP1 = 2-way pinheader for jumper JP2 = 3-way pinheader for jumper LC display, 2 lines of 16 characters, with backlight; see text (e.g. Elektor Shop # 030451-72) 2 jumpers, pitch 2.54 mm 4 standoffs M2. 5, I = 15mm PCB no. 080824-1 from the Elektor Shop Software The ARM core used in the LPC2103 offers plenty of processing power to extend the capabilities of the unit. The firmware is written in C and source code is available for free down- load from the Elektor web pages for the project [1]. The program is easy to understand and modify. Only the start-up code has to be in assembler (for which thanks to Alexander Graf, who wrote that code). The free GCC C compiler is used. The microcontroller runs in an infinite loop, and once per second calls a func- tion which performs the measurement process and displays the results. To obtain the one second period, Timer 0 is configured so that its counter is incremented every millisecond. The infinite loops tests to see whether the counter has reached 1000 (as 1000 * 1 ms = 1 s). The calculation routine first reads a value from the A/D converter to obtain a current reading. This is relatively straightforward as there is no need to send any data to the MCP3550: it is simply a matter of taking its chip select signal /CS low. It is then nec- essary to wait while the conversion takes place. The MCP3550 signals that the conversion is complete by taking the data output line low. We need to switch the port to the correct mode in order to detect this event. Once the conversion is complete the data bits can be read out. There is a total of three eight-bit data blocks, which are logically ORed into the appropriate positions in a variable. The twenty-second bit gives the polarity of the voltage measured at the device’s input: if the bit is a ‘1’ the value is negative and the collected value must be suitably modified: the two’s complement is taken by calcu- lating a bitwise (ones’) complement (ad_current = ~ad_current;) and then incrementing by one. Since we only want the least significant 22 bits of the result we mask off the remain- der using a logical AND operation: ad_current &= 0x3fffff;. Now we can compute the actual cur- rent flowing. To avoid floating-point 9/2009 - elektor 51 INSTRUMENTATION The MCP3550 A simple and accurate delta-sigma A/D converter The MCP3550 is a rather slow, but thrifty and accurate analogue-to-digital convert- er. Its current consumption is just 1 1 0 /jA\ The MCP3550-50 was selected for this project because it has a differential input and a notch filter for suppressing 50 Hz mains hum. Its innards, as shown in the block diagram, appear simple. At the input is a 'gain and offset calibration' circuit. This compensates for offset and slope errors in the rest of the circuit. The actual A/D conversion is performed, with the help of the reference voltage, by the 'third order delta-sigma modulator', a one-bit converter that produces at its output a stream of bits at a high sample rate. The digital decimation filter then reduces the sample rate of this stream while simultaneously increasing its word length (and hence precision) to 22 bits. The dig- ital circuitry is clocked from an internal oscillator, operating at 102.4 kHz in the case of the MCP3550-50. Integrator Quantizer Even simpler is the block diagram of a first-order delta-sigma modulator. The input signal forms one input to a voltage subtractor. The other input to the subtractor comes from a 1 -bit D/A converter fed from the output of the modulator, forming a negative feedback loop. The output of the subtractor can be thought of as an error signal, being the difference between the output of the modulator and its input. The error is integrated and quantised to form the output of the modulator. This loop operates at a much higher frequency than the quoted overall sample rate of the A/D converter and produces a high-frequency bitstream. The MCP3550 uses a third-order delta-sigma modulator, which is an extension of the idea described above. Instead of one subtractor and integrator stage there are three connected in series. There is a quantiser after the final stage which feeds back to all three stages. The bitstream produced is digitally filtered to produce a usable signal. In the MCP3550 this is a fourth-order modified sine filter. A sine filter (that is, a filter whose impulse response takes the form of a sine function) has an ideal low-pass characteristic. It is here that the 50 Hz notch filtering also takes place. The output of the filter is a high-resolution representation of the input voltage, which can be read out over the SPI port. operations we work with currents in nA and voltages in jL/V. The resulting error in the measured result is negligi- ble, deviating from the exact value by less than the tolerance of the reference voltage or voltage divider. All the displayed information is also output over the serial port in the fol- lowing format: Voltage: 12599mV Current: -0050mA Power: -0629mW Capacity: -0035mAh The output data can be fed to a data logger for subsequent analysis. If two of the units are used it is possible to make simple and accurate measure- ments of the efficiency of switching power supplies. Programming The battery monitor has a serial inter- face which uses TTL voltage levels rather than RS-232 voltage levels. Despite its 3.3 V supply, the ports of the LPC2103 are compatible with logic powered from 5 V. The serial interface is used for upload- ing firmware to the device as well as for outputting readings. To program the device over USB the USB-to-TTL serial cable described in the June 2008 issue of Elektor [2] can be used: this is avail- able from the Elektor shop (order code 080213-91). The pinout of the cable is compatible with that of K3 on the printed circuit board. Of course, you can equally well read the pinout of the connector from Figure 1 and use your own serial adaptor cable, as long as it uses 5 V logic levels. When the circuit has been assembled the firmware must be flashed into the microcontroller. Close jumper JP1 and then apply power to the circuit. If the circuit is to be powered over the USB-to-TTL cable, JP2 must be set to position 2-3 (linking +5 V and + 5 V USB ). At this point only the first row should appear on the display: if it is not visible, adjust the contrast using P2. The firmware can be downloaded using the free Flash Magic software [3]. Figure 4 shows how this program is configured: only the COM port to be used and the path need to be set. If you wish to avoid the fuss of pro- gramming the microcontroller your- self, it is available ready-programmed from the Elektor shop (order code 080824-41). 52 elektor - 9/2009 Start-up When programming has success- fully completed, remove JP1 and check that JP2 is correctly set ( + 5 V linked to +5 V BATT ). Connect a bat- tery (rechargeable or not), or a bench power supply with an output voltage between 6 V and 40 V, to Kl. If a volt- age source was already connected to terminals Kl, it will be necessary to remove it briefly to reset the circuit. The LCD should now show a brief message and then display the meas- ured values. If nothing appears, check the contrast setting (P2) again. If the welcome message does not disappear from the display, it is likely that there is a fault in the connection to IC6. If everything is working as expected the LCD should show the current con- sumption of the meter module and the nn * ISA hi bn vo a ^ v a 1 'ilep 1 • LwrimjwrflJhxi i COM F«t |C0M 1 — Baud Rse: |l 15200 3 rutvira- |IPT?1IK 13 IrWeif-K*: |Ncr» |1SPJ Dacian Fraa WHa* fl4 — 3 Gim block 2 |BK2flHHbi2FFFl bkjgk3flMPIJWlk3FFFl fcia™ bkM.1 4 (UkoWlIHhoW-FF | C.’fl it bfc