www.elektor-magazine.com magazine November 2012 r Test, Repair, Analyze, Map, Simulate & Unravel Your Rolling Network Linux Board Mk. 2 LCR Meter V 3.0 Multichannel Temperature Logger USB Thermometer | Bidirectional 4-Channel Audio Selector | LED Lighting for Model Buildings Standards for Coding FPGA US $9.00 - Canada $10.00 Pins Afloat | PCB Milling Master Class • 1935 Audio Spectrometer 25274 24965 7 1 ': '! 00 z~ rs«t« a t ARDUINO UNO The most popular board with its ATmega328 MCU **** r | _* <■)# k.i 4 =».■» 355* Features ■ Micro cun (roller ATmega328 Operating Voltage 5V Input Voltage 7-12V (recommended) Input Voltage (limits) 6-20V Digital 1/0 Pins 14 (of which 6 provide PWM output) PWM Channels 6 Analog Input Pins 6 DC Current per I/O Pin 40 mA DC Current for 3.3V Pm 50 mA Rash Memory 32 KB fol which 0.5 KB used by bootloader) SRAM 2 KB EEPRCM 1 KB Cluck Speed 16MHZ £24.40 • € 27.35 • US $39.70 ARDUINO LEONARDO Especially good for US8 applications Features Microcontroller ATmega32u4 Operating Voltage 5V Input Voltage 7-1 2V (recommended) Input Voltage (Urn its) 6-20V Digital I/O Pins 20 (of which 7 provide PWM output) PWM Channels 7 Analog Input Pins 12 DC Currenl per I/O Pin 40 mA DC Current for 3.3V Pin 50 mA Flash Memory 32 KB fol Which 4 KB used by bootloader) SRAM 2.5 KB EEPRCM 1 KB Clock Speed 16 MHz £22.10 •€ 24.81 • US $36.00 ARDUINO @ektor FeaJiar-es Microcontroller Operating Voltage Input Voltage {recommended) Input Voltage (limits) Digital I/O Pins Arduino Pins reserved Analog Input Pins CG Current per I/O Pin DC Cur rent for 3.3 V Pin Flash Memory SRAM EEPRCM Cluck Speed ATmega32B 5V 7-1 2V 6-2QV 14 (of which 4 provide PWM output) 10 to 13 used forSPI 4 used tor SD card 2 W51 00 Interrupt (when bridged} 6 ■10 mA 50 mA 3? KB [of which 0 5 KG used by bootloader} 3 KB 1 KB 16 MHz Features Microcontroller Operating Voltage Input Voltage [recommended) Input Voltage (limits) Digital I/O Pins Analog Input Pins DC Current per I/O Pin DC Current lor 3.3V Pin Flash Memory SPAM £ EPROM Clock Speed ATrnega?56Q 5V 7-1 2 V 6-20V 54 {ol which 15 provide PWM output) 16 40 mA 50 mA 256 KB (of Which 3 KB used by haul loader) S KB 4 KB 16 MHz lit € 52.77 • US $76.50 ARDUINO DUE 32-bit power thanks to an ARM processor Features Micro corn ru Iter Operating Voltage Input Voltage (recommended) input Voltage (limits) Digital I/O Pins PWM Channels Analog Input Pins Analog Outputs Pins DC Current per I/O Pin DC Current for 3.3V Pin DC Current tor 5V Pin Flash Memory SRAM Clock Speed AT91SAM3XBE 3.3V 7-1 2V 6-20V 54 (of which 12 provide PWM output} 12 12 2 (DAC) 130 mA 600 mA 800 mA 512 KB (all available Tgr Ihe user applications 1 96 KB (two banks: G4KB and 32KB) 84 MHz €52.77* US $76.50 £48.10 *€53.98* US $78.30 H? OFF for and { * 0Lf Members •*A available EMBEDDED I V I ENGINE A REVOLUTIONARY SOLUTION ENABLING HI-QUALITY, HUMAN MACHINE INTERFACES AT A LOWER COST DISPLAY MADE EASY r , \ I w\ mill EBCO ^ EW£32m3l- \ ^ \ J. i. \ 0 Q r V V D 9 Q < DEVELOPMENT ^ SYSTEMS FROM o v << S **' WATCH EVE DEMOS ONLINE FTDICH1P.COM Contents • Community 8 Elektor World * Let Your Brain Do the Thinking * All Smiles • The Internet of Things' Launching Point • That Sounds Good! • Projects 10 CAN Tester The circuit described here has all the features required for conducting various experiments and tests on a CAN bus. In addition there is the option of connecting the tester to an existing CAN bus to mon- itor the data or to track down faults, 18 Elektor Linux Board: New and Improved! The compact and low-cost Elektor Em- bedded Linux board has been available to buy for around a year and a half now. Along with its accompanying series of articles it offers even beginners access to the world of embedded Linux, It is now time for us to update the board based on feedback from the user community. To begin with let's add LAN and RTC 22 Important Update to the Elektor 500 ppm ICR Meter Here we correct two shortcomings liable to interfere with proper operation of the instrument: occasional hang-ups and issues with the Trim actions. 26 Multichannel Temperature Logger This project allows you to log up to six temperature readings over a period of time, complete with time stamps, al! written to a ,csv file stored on an SD card for processing on a PC, Local control is also available in the form of an LCD and a keypad, 32 USB Thermometer When you need to hook up some elec- tronics to an RS-232-less computer, the USB port looks like the only option. The computer however needs a correspond- ing software driver. Here we describe an elegant patch around this problem. 42 Bidirectional Stereo Input Selector Following a recent appeal made in the magazine calling on our readers to send us their own circuit designs— if possible simple and preferably in fields that re- ceive less coverage in Elektor, like audio, for example—we received this suggestion which meets the two main criteria: un- complicated and intended for processing sound signals, 46 LED Lighting for Model Buildings This small module has been designed to individually control five LEDs used to illuminate model buildings. The control signal is sent over a single wire from a PCs RS232 serial port. The design allows for up to 250 modules to be controlled by a single PC, that's almost enough for a small town! 4 | November 2013 | www.elektor-magazine.com Volume 39 No. 443 November 2013 t>BWT • DesignSpark 38 DesignSpark Tip & Tricks, Day #5: generating PCB manufacturing files Today we will generate the Gerber files and BOM information for the design we laid out last time. DesignSpark has excel- lent support for generating these types of files once it's been configured properly. Labs 50 .Labs Tips & Tricks This month we present a selection of projects posted on Elektor.Labs and look- ing for a helping hand to reach the finish line. Can you cheer and/or assist? 52 Standards for Coding Often a lot of time and energy is spent on designing an elegant, well-thought-out and robust circuit Today, the brains of many of those circuits is a microcontrol- ler that needs software to function. Is it unreasonable then to expect a well-de- signed, properly written program to make such a quality circuit work? Appar- ently it is. Let's talk software quality. 58 Keep The Pins Afloat Forget to tick a few boxes and your entire FPGA project fails to work, as our lab workers Found out the hard way. 60 PCB Prototyper Master Class Here's a how-to on an advanced applica- tion of the Flektor PCB Prototyper milling machine. Tech The Future 68 Forze VI: A Hydrogen-Powered Racecar The Forze VI weighs just under 2,000 lbs., achieves a top speed of 138 mph, and accelerates from 0 to 60 mph in 4 seconds. The heart of the racecar is the fuel ceil system. • Industry 64 News & New Products A selection of news Items received from the electronics industry, labs and orga- nizations. • Magazine 70 Retronics: Freystedt's Audio- Frequency Spectrometer The story of finding and restoring the ex- tremely rare 1935 Siemens Spectrometer, a landmark in electro-acoustic measure- ment. Series Editor: Jan Buitlng. 76 Hexadoku Elektor's monthly puzzle. 77 Gerard's Columns: Conscientious Objector A column or two from our columnist Gerard Fonte. 82 Next Month in Elektor www.elektor-magazine.com | November 2013 1 5 Community Volume 39, No, 443 November 2013 ISSN 1947-3753 (USA / Canada d stribution) ISSN 1757-0875 (UK / ROW distribution) www.elektor.com EBektor Magazine is published 10 times a year including double issues in january/February and July/August, concur- rently by Elektor International Media 111 Founders Plaza, Suite 300 East Hartford, CT 06108, USA Phone: 1.860. 289. OSOO Fax: 1.860.461. 0450 and Elektor International Media 78 York Street London W1H 1DP, UK Phone: ( + 44) (0)20 7692 8344 Head Office: Elektor International Media b.v. PO Box 11 NL-6114-ZG Susteren The Netherlands Phone: (+31) 46 4389444 Fax: ( + 31) 46 4370161 USA / Canada Memberships: Elektor USA P.O. Box 462228 Escondido, CA 92046 Phone: 800-269-6301 E-mail: e!ektor(®pcspublmk.com Internet: www.elektor.com/members UK / ROW Memberships: Please use London address E-mail: service@elektor.com Internet: www.elektor.from/meniiber USA / Canada Advertising: Peter Wostrel Phone: 1.978.281.7708 E-mail: peter@smmarketmg.us UK / ROW Advertising: Johan Dijk Phone: +31 6 15894245 E-mail: j.dijk@elektor.com www. el e kto r, com /a d ve rtisi ng Advertising rates and terms available on request, Copyright Notice The circuits described in this magazine are for domestic and edu - cational use only. AH drawings, photographs, printed circuit board layouts, programmed Integrated circuits, disks, CD-ROMs, DVDs, software carriers, ar.d article texts published in cur books and magazines (other than third-party advertisements) are copyright Elektor International Media b.v. arid may not be reproduced or transmitted in any form or by any means, Including photocopy- 'll scam ng and recording, n whole or n part without prior written permission from the Publisher. Suer written permission must also be obtained before any part of this publication is stored n a retrieval system ol any nature. Patent protection may exist n respect of c rcults, devices, components etc. described n this magazine. The Publisher does not accept responsibility for Fari- ng to identify such patent(s) or other protection. The Publisher disclaims any responsibility for the safe and proper function of reader-assembled projects based upon or from schematics, descriptions or information published In or in relation with EFek- tor magazine, © Elektor International Media b.v., 2013 Printed in the USA Printed in the Netherlands Can the CAN Not so long ago you'd be greeted by rust, holes, grime, goo, mushrooms or mice droppings when removing a panel or a cover from a broken down car in order to get access to "the electrics". Today you are bound to encounter electronics of the black box or disposable type. Removing rust or corrosion is a tough but rewarding job that actually helps to get the car on the road again. By contrast, remove any piece of reasonably advanced electronics from a post 2000 vehicle and you may be unable to even switch on the ignition. In- vehicle electronic systems like OBD, ECU and CAN require a total change of mind In terms of repair and maintenance work. There's no denying that these systems are hugely successful and the way forward, but bear in mind that cars with zero- electronics-on-board-except-the-radio are increasingly popular too. The best way to explore the route and workings of a bus is to buy a ticket for a round trip and be kind to the driver. In this edition we present a tool that should help to remove any fears of addressing issues in vehicles that appear related to the CAN bus (if fitted! ). The tool is not just analytic, but educational too as it allows a good deal of messages from CAN devices to be simulated in the comfort of your electronics lab, as opposed to a garage outfit with Orange County Chop- pers on the floor and Lady Gaga on the radio. The actual function of the CAN Tester board is one of about a dozen as determined by the firmware It is running. This month we are again honoring your requests for projects related to measure- merit. In this case it's temperature all round with our Multichannel Temperature Logger (page 26) and the USB Thermometer (page 32). The first reads up to six sensors and writes ,csv files into a spreadsheet— the second has one sensor and writes directly to the PC over a USB link. Besides CAN and temperature measurement the pages ahead present audio, embedded Linux, PCB milling, Modeling, Coding, racing on hydrogen power, restoring a 1935 spectrometer and a hex-coded puzzle challenge. I wonder if that 260 HP Forze VI on page 68 has CAN controlled brakes? Or a radio? Enjoy reading this edition of Elektor, Jan Suiting, Editor-in-Chief The Team Editor-in-Chief: Associate Editor: Publisher / President: Membership Managers: Jan Suiting Thijs Beckers Hugo Van haecke Shannon Barraclough (USA / Canada), Raoul Morreau (UK / ROW) International Editorial Staff: Harry Baggen, Eduardo Corral, Wisse Hettinga, Denis Meyer, Jens Nickel Laboratory Staff: Ton Giesberts, Luc Lemmens, Tim Uiterwijk, Clemens Valens, Jan Visser Graphic Design & Prepress: Giel Do Is, Jeanine Opreij, Mart Schroijen Online Manager: Danielle Mertens Managing Director: Don Akkermans 6 November 2013 www.elektor-magazine.com Our Network USA Hugo Van haecke +1 360-239-0800 h . va n h aec k e pelektor. c o m United Kingdom Don Ak karma ns +31 46 4389444 w. h etti nga @ e I e ktor. com H Germany Ferdinand te Walvaart +49 241 88 9D9-17 f , tewa I ve a rt@e I ekto r. de France Denis Meyer 4 31 46 4339*35 d, meyer@elektor.fr Netherlands Erik Jansen +31 45 4333429 h . b a ggen @elekto r nl Spain Eduardo Corral + 34 91 101 93 95 excrralpelekror.es U ga Italy Maurizio del Carso + 39 2.56504755 m . delcorsc @ i n wa re . i L Sweden Don Akkermans + 31 46 4389444 w. h etti nga @ e l e ktor. com Brazil Joao Martins + 31 46 4389444 j . ma rtfns@ el e kto r. com Portugal Joao Martins + 31 45 4389444 j . ma rti ns@ el e kto r. com India Sunil D. Malekar +91 9833166815 ts@elektor.ln Russia Nataliya Melnikova + 7 (965) 395 33 3b F I e fabstrgam,cQm . .............. .21 ekjiresspcb FTDI FTDI wm \ . ftdichfp. c cm . .3 uUMANDATA HuMANDATA mvw.hdl.co.jp/EU. . , ........... .37 Microchip Microchip www.microdnp.ccm . 34 npoioiu 16b " * BttoM WHW'PQfotuXQm 4 n ■ * Saelig ivmWsae/^xom ..... + + ► I “ * 4 4 - ¥ * « .37 .57 * Software Telco Congress ivww.softtovrptefco-com . .57 ITIXD Not a supporting company yet? Contact Peter Wostrel (peter@smmarketing.us, Phone 1 978 281 7708, to reserve your own space in Elektor Magazine, Elektor«POST or Elektor.com www.elektor-magazine.com November 2013 7 Community Compiled by Wisse Hettinga Elektor World Every day, every hour, every minute, at every given moment designers and enthusiasts are thinking up, tweaking, reverse-engineering and developing new electronics. Chiefly for fun, but occasionally fun turns into serious business. Elektor World connects some of these events and activi- ties — for fun and business. Let Your Brain Do The Thinking ...and the software do the work. Here at the MOSI (Museum of Science and Industry) in Manchester, UK, a group of 20 designers from a selection of companies rally to take the new DesignSpark Mechanics to the limits. The challenge is to develop something life saving' in 48 hours and have it 3D printed! Not an easy task for people who are normally doing many things besides saving the globe, but the ideas that come up are interesting. Currently it's fair to say that the Elektor team's world-saving activities are limited to preventing a few hapless plants from drying out in their office-mt's a start. All Smiles The guys you see smiling are on the the Flowcode designers 1 team, They have every reason to be happy, just having finished Flow- code version 6, a new and excit- ing product. Where other coding programs let you see a blinking LED or a signal level, Flowcode 6 allows you to program and simulate a complete 3D world. Typical 3 D CAD program designs can be imported and brought to life. For example, you can have your 3D printer design first simulate and operate before you start the actual production. In this way this new version of Flowcode is bridging the gap between electronics programming and simulation of real world actions. The team is based in Halifax, UK and I am sure we can expect more applications and developments from them in the near future. Flowcode is available in the Elektor Store, see www.elektor.com/flowcode 8 November 2013 www.elektor-magazifie.com A!! Around the World ... The 'Internet of Things' Launching Point It's a bold but not implausible idea that someday many everyday devices w!3! have embedded sensors that enable them to communicate via an Internet-like structure. Consumer products from cars to household appliances and other elec- tronics would be able to connect through such local and global networks. The impli- cations for individuals and business models are enormous. According to the marketing firm ABI Research, more than 30 billion devices will be connected wirelessly through the so-called Internet of Things (loT) by 2020. And Circuit Cellar magazine has compiled a list of online resources to help individuals and businesses keep up with the evolution of the loT. Whether you're looking for a workshop in Italy on wireless sensor networks, contact information for innovators in the field, or details about new loT applications and breakthroughs, you'll likely find helpful information online in the "Internet of Things (IoT) Resources" feature at circuitcellar.com/featured/iot-resources. And it's a list that's expected to grow. If you know of a resource that should be added, please email it to CJ Abate and Mary Wilson on editor@circuitcellarxom.ome up with proper answers, simple and easy to understand to help you to take the next step on your favorite embed- ded platform. That step is called Arduino.next and will be up & running soon— powered by Elektor, Stay tuned to our communication channels! Follow us on Facebook, www.facebook.conn/arduinonext, and on Twitter, @ arduinonext, and check out the Arduino products already on sale at www.elektorxom. That Sounds Good! ADVANCING THE EVOLUTION OF AUDIO TECHNOLOGY audioxpress.com In the audio electronics domain, Elektor International Media publishes audh oX press, Voice Coii t Loudspeaker Industry Sourcebook t World Tube Direc- tory , books, and more. Those titles were founded in the US by Edward T. Dell (1923-2013) and for over 35 years served the do-it-yourself audio con- structor as well as those working in the audio industry with great articles, projects, tips and technologies. Believing that the work of enthusiasts should serve as a model for the indus- try as far as excellence of design and quality of constructions goes, Ed Dell launched The Audio Amateur in 1970, a magazine devoted exclusively to DIY audio. Ten years later, believing there was sufficient interest in the loud- speaker market, Ed launched a separate magazine in 1980, called Speaker Builder, while a third publication, Glass Audio, responded to the increasing interest in vacuum tube based audio equipment. In 1996, Audio Amateur was renamed Audio Electronics and in 2000, the three magazines were combined into a single, monthly periodical, named audioXpress . In 2011, Ed DeJl sold his company to Elektor International Media. A new editorial team, reinforced by leading authors from the Elektor network, is currently working on a redesign of the pub- lication with an expanded format, addressed towards the global audio engineering community, covering also the R8tD efforts in the industry in many new application areas. The refreshed, restyled audioXpress will be launched at the AES Convention in NY (October 17th - 20th) with a new graphic layout in print and in full digital front, including a regular newsletter to over 30,000 members (at the time of writing). audioXpress is already engaging with the giobaf audio community though Twitter (@audioXP_editor) and Facebook (facebookxom/audioxpresscommunlty). See more at www.audioxpress.com. www.elektor-magaiine.com November 2013 9 Projects CAN Tester With comprehensive features By Hugo (Belgium) circuit described here has all the features uired for conducting various experiments tests on a CAN bus. In addition there the option of connecting the tester to an existing CAN bus to monitor the data or to track down faults. ir to say that modern vehicles (cars, trucks, motor bikes, agricultural vehicles, etc.) have these days become rolling (mobile) networks. The various control systems in these vehicles are connected together with a network used for exchanging messages. In this way it is ensured that the various functions in these vehi- cles are functioning optimally. Many car manufacturers use the CAN bus (Con- troller Area Network) for this. The control units are connected together with two twisted wires (terminated with resistors at the ends) and so form the CAN network. These wires are called CAN High and CAN Low. There may be more than one CAN network in a single vehicle. CAN is a system that works reliably in an envi- ronment with high interference. But because of the complexity of CAN networks it can sometimes be difficult to solve problems. I This is one of the reasons why the Etek- tor CAN Tester has been developed; the other reason is that the CAN Tester is also excellent to gain experience with the CAN bus and offers the possibility of experi- menting with software for CAN circuits. The CAN Tester described here comprises two identical circuit boards (board A and board B), which are only loaded with different soft- ware. Each board can be equipped with a 4x20 size character LCD, The boards communicate with each other according to the CAN protocol. These boards can also be connected to an exist- ing CAN bus. The CAN Tester offers the following options (using the same boards): * Test configuration with boards A and B, for 29-bit and/or 1 1 -bit IDs (automatic); * Reading out of CAN data on the LCD (for example parking brake, odometer reading, etc.); 10 November 2013 www.elektor-magazi ne.com CAN Tester • Examine data using HyperTerminal; • Test functionality with pushbuttons and LEDs; • Simulation of messages, These features will all be discussed in this article, The SJA1000 is a bitstream processor with a transmit and receive buffer. This is controlled and initialized by the ATmegaSSIS, The ATmega851S provides the transmit buffer of the SJA1000 with messages and reads out the receive buffer. The SJA1G0Q is connected to the ATmegaSSIS via a multiplexed address/data bus (PAD - PA7). The hardware We start with a brief description of the hardware that has been used, In Figure 1 this is shown for one circuit board, the other board has an identical design. The circuit consists of the following components: • ATmegaSSIS: 8-bit microcontroller (IC1); • SJA100Q: CAIN protocol controller (IC4); • PCA82C250: CAN transceiver (IC3); • MAX232: RS232 transceiver (IC2, for com- munication with the PC); • 4 x 20 character LCD (LCD1), In addition, there are four control signals that go to the SJA10G0: CS (chip select), ALE (address latch enable), RD (read) and WR (write). CS (chip select) has to be logic Low when the ATmegaSSIS communicates with the SJA1000. The ALE sig- nal has to be logic High when an address is on the bus, and logic Low for data. The RD and WR signals are used to determine whether it Is a Read or Write command from or to the memory in the SJA100G, The interrupt output (INT) of the SJA10Q Is not used here. With the mode connection input pin of Figure 1. Schematic for the CAN Tester. The main ingredients are a microcontroller, a CAN protocol controller and a CAN transceiver. LC01 LCD2QX4 < * 0 yj r— 10 u? ■* ^ □ O Q Q £ ^ £ £ “’’"I vcco— 4-1 L- R12 I ■■"I r-'l s s 1 Tj> GKD 7 F % 4 DB4 5 DBS l DBS 7 □BT S Y PD3 10 PDI 11 r* PBJ 12 Pfi3 11 pru n Y PBS 15 PDG 14 PC 7 17 KtStl 3 t_L3I_!? GND SS H .reset | vcc -o o- o PBD LOClTfl) PBl [T1] PB2 [AIM) PB3 LAIN1J P0i ,?S; PBS |WQ5I) PBG I.WISQJ PB? [SCK| PL: j : "DID! PDi fTOXt P DJ UNTDJ PD3 iiNTl j PC i |XCK! PCM [0C1A[ pcrfi 1W1 PD7 |RG| IC1 PAD (ADD) PAT i'ADT) PA? i'A02) PAS (AD3) PA4(AEJ4) PAS (AOS) PAG (A Ofi) PAT (AOT) PCO |AUj pqi [Asj PC 3 |A 1 P) PCJjAII) PC4 PCS iA 13 ) K 6 JA 14 ) PCTiAIG) ATjnegaBSlS-l&PC PtD l-CPTNrS) PEI (ALE) RESET PEi(KIB) a :Z tA a <. £ I c* Up XI 5 sMKt ^5 Up GND vcc K2 OBI _ W 50 1 2 DB 7 SDK 3 . 4 RESET RESET 5 5 2 VCC 1 MDSl IS PAD IF, PAT > 17 PAI 14 PA3 15 PA4 > 51 PAS > 13 PAG N 13 PA 7 > N 23 21 2 1 M, 21 2i 11 30_ 29 ISP 1 Z 'JL' 09 GND PQI — POD r'" _s L'Fi l ' ~ ondH PC ' PEI QBS ft VCC Cl* vcc IC2 Cl- T1IN T1QUT T2IN T20UT ftIQUT Rllft RIQUT R2IM C2+ MAXHZACPE ci- w gub Hp 14 J K7 14 _1_ € 1 7_ 11 7 J D - . r u s 5 11 Ifl lu Pi VR IN VCC 0 11 RESET 17 L PAQ 21 , PAI 24 . PA2 35 , PA3 26, S P44 27 . PAS 2D . PAG .J S PA7 2 _x s a s £ Jr GPfD cm m MODE > > > ALE RST ADO ACT AD2 AD3 ADI ADS ADC ADT 1CA CS RD WR RK 1 Rxe TXfl TX1 SJA1WWT _ CLROUT INT VSSi -1 ^ VSSJ -£ l — K Cl 2!p X2 ” ■HI-' 14 MHz T GND 3 PEI 4 PC7 S PDT K G PDB ' 2C 19 11 U 1 1 16 21 — : — 22p VCC PCA82C250Y GND 1201K- II www.elektor-magazine.com November 2013 11 Projects the SJA100G, the bus interface can be configured for a microcontroller made by Intel or one made by Motorola. With this CAN tester that is Intel— that is why pin 11 of IC4 is connected to V cc . The ATmega8515 sees the SJA10GQ as an expan- sion of its (internal) RAM. This is the reason why in the compiler settings for Bascom the 'EXTER- NAL ACCESS ENABLE' has to be ticked (see the box 'Program settings'). The PCA82C250T transceiver ensures that the data it receives on its TXD pin (TTL level) is con- verted to the differential signal {as a difference voltage) of the CAN bus (CanH and CanL, with the Can-High and Can-Low wires as a twisted pair, terminated with two resistors of 120 Q). The received differential data is converted by the transceiver to a signal with TTL levels, which goes from its RXD connection to the SJA10OQ. The ATmega8515 runs at a clock frequency of 8 MHz, the SJA10QQ at 16 MHz. The baud rate with the serial connection to the PC operates at a speed of 57,600 baud. The board is fitted with four jumpers (K3 through K6), which are used to select whether the LEDs or the pushbuttons are connected to port D of the ATmega8515. The display is used in 4-bit mode and is connected to port B of the microcontrol ten PI is used to adjust the contrast for the display. The MAX232 is an old acquaintance; it provides for the conversion of the 5-V signals on the board to the 12-V signals of the RS232 bus. K9 is used to enable the termination resistor for the CAN bus. In addition there is a 6-way ISP connector to allow the microcontroller to be programmed while in the board. You can, for example, connect the STK500 programmer to this. The entire circuit is powered from 5 V. You can use a wall adapter with a regulated output for this or a 9-V battery with a separate voltage regulator The current consumption is small, for short-du- ration experiments a battery will be sufficient. The software The software is written in BASCOM (demo ver- sion). The ATmega8515 was programmed with the STK500 (Atmel), This software is based on the examples from BASCOM (third party Lawicel), This software contains the minimum of what is required to send and receive data frames (mes- sages). The software configures the SJA1GO0 in the PELICAN mode. In this mode you can send and receive 11-bit and 29-bit identifiers. The software comprises seven parts: 1. First an address is issued to the registers of the SJA1000 (since the ATmegaBSIS sees the SJA1000 as an external RAM expansion). 2. An identifier (29 bits) is turned into a 'Long' (4 bytes), with an 11-bit identifier this becomes a 'Word' (2 bytes). 3. The 'Do Loop' contains the actions that the program will carry out. From here the subrou- tines TrartscantesEl, Transcntest2 and Receive- cantestl are called, 4. The subroutine 'Initsja' is used to initialize the SJA1000, this contains, among other things, the setting for the bit rate. 5. The subroutines Transcantestl and Transcant- est2 ensure that the data frames (messages) are transmitted, 6. The subroutine Receivecantestl is respon- sible for the reception of the data frames. This subroutine also contains what has to be done with the received data (processing by the ATmega8515), 7. Display of the data on the LCD (4-bit mode). The bit-rate of the SJA10G0 is here set to 250 Kbits/s (the same as the J1939 standard). Other bit- rates can be set in the software, taking into account the dock frequency of the SJA1000 (16 MHz), You can find various 'bit rate calcu- lators' on the Internet for the SJA1Q0G, which wifi give you the values for the registers (tmg_G and tmg_l). Further explanation of how the software is put together can be found in the data sheets and the application notes for the SJA100Q (with respect to the registers in this IC), The software contains comments that provide further explanation for certain program lines. In a separate Word document that you can down- load from [1], you will find an overview of the features of the available software together with some explanation. Construction In Figure 2 we can see the circuit board that has been designed for the CAN Tester. This is fitted with parts on both sides. Most of the components are fitted on the side with the component overlay. On the solder side are the LEDs D1 through D6, the pushbuttons SI through S4 and the 16- way header for the LCD. The circuit was originally designed for ICs with 'norma!' pins, but in the 12 Movember 2013 www.elektor-magazi ne.com CAN Tester meantime two of the ICs used here are now only available in SMD version: the PCA82C250 (IC3) and the SJA1000 (IC4). In order to be able to use these on the existing circuit board we have used small adapter boards (available from [2], among others). For those who buy the prepro- grammed controller we will also supply the two adapter boards with it, so that you can get started immediately* The LCD is not necessary for all of the test con- figurations. It all depends on the firmware used (see also the additional documentation available as a free download [1], There is a sub-D9 connector for the connection to the PC, You can , if necessary, connect a USB/ RS232 adapter cable to this for communicating with a modern computer. All the firmware is of course available as a free COMPONENT LIST Resistors R1,R2,R5-RS = lkQ R4,RU = IGkQ R3,R9,R1G = 120Q R12 = 330ft PI = 10kQ trimpot, e.g. Bourns 3386P-1-1Q3LF, New- ark / Parnell # 9355030 Capacitors C1-C4 = 22pF C5-C9 = IpF 63V radial Semiconductors D1-D6 = LED, red, 3mm IC1 = ATmega8515-i6PC, programmed, Elektor Store # 120195-42a for board A, # 120195-42b for board B IC2 = MAX232ACPE IC3 = PCA82C250 (8-pin DIP) or PCA82C250T (S08, adapter board required) IC4 = SJA100Q (28-pin DIP) or S1A10OGT (S02B, adapter board required) Miscellaneous XI = SMHz quartz crystal X2 = 16MHz quartz crystal LCDi = LCD, 4x20 characters (Elektor Store # 120061-73) K1 = 16-pin pinheader, 0.1" pitch K2 = 6-pin (2x3) pinheader, 0.1" pitch K3-K6 = 3-pin pinheader, 0.1" pitch, with jumper K7 = 9-way sub-D socket, right angled pins, PCB mount KS,K1G = 2-way PCB screw terminal block, 0.2" pitch K9 = 2-pin pinheader, 0,1" pitch, with jumper S1-S5 = miniature pushbutton with make contact, e.g. TE Connectivity 3-1437565-0, Newark / Farnell # 2060813 PCB # 120195-1, see [1] Figure 2. The circuit board contains components on both sides: on one side the LEDs, pushbuttons and the display, on the other side all the other parts. www.elektor-magazine.com November 2013 13 Projects Program settings In BASCOM the compiler has to be configured by selecting under: OPTIONS/Compiler/C 'External Access Enable'. The settings for AVR Studio 4 together with the STK500 are as follows: * m [ AVR Studio Disconnected Mode Open Connection Dialog to Rec**. x 1(0 M 4 Ptogfam i Fuses LockBits | Advanced | Board j Auto Device AT mega 851 5 ~z\ Erase Device Pfogramming mode a isp C" Pardlel/High Voltage Seiial R E rase D evice B elore Progra mmirvg ^ Verify Device After Programming Flash r Lise S milator/ErrsMof FLASH Memory & Input HEX File |E:\Progtann FiesVMCS E lectronicsNB AS COM- Program Verify Read | EE PROM C ij *e C u: i en t Sirr lulatof/Erndlalot EEFRQM Memory Input HEX Fite |E:\Dccumert& and Setting$\Hugo\Miri doeu Program Vetify Read The fuses are set in AVR Studio as follows: Boot Flash section size = 128 Boot start address =$0F80; BOOTZ = 11 Brown-out detection level at VCC = 2.7V; (BODLEVEL = 1) Ext. Crystal/Resonator High Freq.; Start-up time: 16K CK+64ms;(CKSL = 1111 SUT = 11) download from the Elektor website [1], Each application requires a different firmware. In the interest of simplicity, Elektor Store only supplies the preprogrammed microcontrollers for application 4, which is described a little further on (120195-42a and b). Applications for the CAN Tester Here follows a brief description of the various applications, where each time also the necessary firmware versions are mentioned. Application 1: Board A and board B send and receive messages automatically to each other firmware; 120195-40a (hoard A without LCD) 120195-40b (board B without LCD) 120195-413 (board A with LCD) 120195-41b (board B with LCD) Here, both boards send and receive messages to each other with 29-bit IDs, Each message contains 8 data bytes, of which only one data byte used. Board A transmits messages that are only intended for board B, and board B sends mes- sages that are only destined for board A. Mes- sages are received the same way: Board A only received messages from board B and the other way around. The transmitted data byte appears on port D of the microcontroller and is made visible on both boards using the four LEDs, which turn on and off two at a time. This also signals that there is con- tinuous data traffic between the two boards. That therefore also means that the wiring between the boards is correct. You can use this function only to test the wiring of a CAN network. You can connect the boards to any arbitrary point on the network wiring. You connect the boards (A and B) to the ends of that section of wiring that you would like to test. Take into account any termination resistors that are on the CAN network already (and if necessary disconnect them), each board of the CAN -tester has a termination resistor of 120 Q t which you can switch in or out with jumper K9 (the bus impedance is 60 Q). With this setup you can test: * interruption of CanH; * interruption of CanL; 14 November 2013 www.elektor-magazi ne.com CAN Tester Consider your safety! Know what you are doing! When the CAN Tester is connected to a vehicle and you send messages (data frames) on the network, then it is possible for engines to start automatically, vehicles starting to move by themselves, engines to reach high RPM, etc. Take the time to work safely, don't endanger yourself and others* Closely follow the instructions from the manufacturer and the vehicle. And read the SAFETY instructions. • CanH and CanL swapped; • CanH and CanL shorted; • Moisture in the cables (plugs submerged in water). When any of these faults appear or are present, then the LEDs will stop flashing immediately. When the fault disappears the LEDs will start to flash again. In this way you will have a visual indication of a fault. To track down intermittent faults you can shake the wires and plugs about while at the same time keeping an eye on the CAN Tester. The CAN Tester works optimally on an inactive network, in this case the CAN bus is entirely avail- able to the CAN Tester, It also works on an active network, but the LEDs will flash slower in this case because there will also be other data traffic on the bus. When the LEDs flash that means the messages from the boards are sent and received in between the other messages. Application 2: Single CAN Tester with LCD ( handbrake , odometer reading, etc,) Firmware: 120195 -44a (board with LCD , handbrake) 120 195 -44b (board with LCD ; odometer reading) 120195-45a (board with LCD , accefeartor) In this application the CAN Tester only receives messages. These are displayed intelligibly on the 4x20 character LCD. The three examples are: a) status of the handbrake of a truck; b) the odometer (miles counter) reading; c) accelerometer position. These examples show how you can process the received data into a legible result with the aid of a few operations. This can also be used for diag- nostics, for example if you would like to read a certain sensor during a test drive- in this application the CAN Tester is connected www.elektor-magazine.com November 2013 15 Projects to the network of a vehicle that transmits these messages. If you do not have a vehicle available to you, then you can also simulate these messages with another board. To simulate messages you can f for example, use the Tiny-CAN View (see Auto- motive CANtroller, Elektor February 2009 or the CAN Explorer, Elektor February 2008). Application 3: Viewing data using Hyper- Terminal (baudrate = 57,600) This is possible with all version of the firmware The CAN Tester has a MAX232 for communicating with a PC. The software is written in such a way that we can examine the contents of messages on a PC via the serial port. This applies to both the sender and the receiver. The received data can also be stored in a file (via the HyperTerminal program). This can be all messages, or only those that are of interest to you. You can set that yourself in the software. For example, each program contains the part number of the software that is in the microcon- troller at the time. This is very handy when you are using multiple controllers (running different firmware). By connecting them to a PC you can see which program it contains, Application 4: CAN Tester with pushbut- tons and LEDs Firmware: 120195-42a (board A, with LCD) 120195-42b (board B with or without LCD) This application requires two boards (Board A and Board B). The messages have 29-bit identifiers and the bit- rate is 250 Kbits/s (J1939 protocol). We use two pushbuttons and two LEDs, Place the jumpers in the correct positions for this: • Ports D4 and D5 to the pushbuttons (jump- ers K5: 1-2 and K6: 1-2). • Ports D2 and D3 to the LEDs (jumpers K3: 2-3 and K4: 2-3). Both boards (A and B) can receive and transmit messages. Board A: A message is sent on both the press and the release on one or both pushbuttons. This trans- mitted message causes the LEDs on board B to turn on or off (LEDs turn on when pressing the pushbuttons and turn off when released). Only one data byte is sent, with identifier 0C1F134A(H), Board A receives only messages from board B, which consist of one data byte with identifier 0C1F1315(H), Board B: A message is sent on both the press and the release on one or both pushbuttons. This causes one or both LEDs on board A to turn on or off (LEDs turn on when pressing the pushbuttons and turn off when released). Only one data byte is sent, with identifier 0C1F1315(H). Board B receives only messages from board A, which consist of one data byte with identifier QC1F134A(H). The received data byte contains the information of what the LEDs should do. When receiving the messages the identifier has to correspond with the one that is mentioned in the software, otherwise the data is not copied to port D, Board A accepts only the data from board B and the other way around. The LCD shows the state of the pushbuttons and LEDs. You can use the CAN Tester in this application in various ways, for example when testing the wiring of a CAN network. When operating the pushbut- tons on board A the LEDs on board B have to fol- low these pushbuttons, and the other way around. This configuration and software has also been tested in an active network (which also car- ries other messages). This works, but is slower (always check which identifiers you use, these may not be the same as those already in the active network). In this application too, the CAN Tester works best when the wiring of the network does not contain any other activity. Application 5: The CAN Tester as a simu- lator for messages Firmware; 120195-43a (board A with LCD , see additional documenta tion 1 201 95- W). 120195 - 43b 1 (board B with LCD, see additional docu- mentation 120 195 -W), With this firmware it is possible to simulate mes- sages; you program messages In one board and use the other board to show them on the LCD or display them via HyperTerminal. These mes- sages can be transmitted automatically with a certain repetition frequency (repetition time) on the CAN bus. You can also transmit them when 16 Movember 2013 www.elektor-magazi ne.com CAN Tester F a 1 'V M Figure 3, The test setup for application #4. The supply voltage is provided by a 9-V battery and a 7805 voltage regulator* operating the pushbuttons* Firmware 120195-43a: sending messages; firm- ware 120195-43bl : receiving messages* Examples and explanation of messages are at [3]. To test the boards (for displaying data on the LCD), you can again use Tiny CAN View or use the CAN Explorer. Finally The CAN Tester always has to be connected to another board, vehicle or other test setup such as Tiny CAN View or the CAN Explorer from Elek- tor. We wish you much success with your tests and experiments. (120195-1) Internet Links [1] www.elektor.com/120195 [2] www, futudec.com/SHD_Adapters.shtml [3] www.fms-stand3rd.com/down_load/fms_doc- ument_ver02*00vers_l 1_1 1_20 1 0. pdf www.elektor-magazine.com November 2013 17 Projects Elektor Linux Board: New and Improved! Now with LAN and real-time clock Benedikt Sauter [1] The compact and low-cost Elektor Embedded Linux board has been available to buy for around a year and a half now. Along with its accompanying series of articles it offers even beginners access to the world of embedded Linux, It is now time for us to update the board based on feedback from the user community- Many users have pressed the Elektor Linux board (and its cousin, the Gnublin board) into service for logging data such as tem- perature and energy use, and then making the results available over a net- work* Hence it is dear that a built-in network Interface and real-time clock would be useful additions for an update to the board (Figure 1), We have also incorporated other suggestions made by users; for example, the fixing holes are bigger, so that the board can be mounted more easily. Eagle format; a free Eagle viewer is available at [7], and a good book on Eagle at [12]. Network access Is provided using a special-pur- pose device, as the LPC3131 processor does not have its own integrated Ethernet hardware. The Microchip ENC28J60 [8] will be known to some readers as a network adapter popular for use with simple 8-bit processors. It is connected using an SPI port and an interrupt signal. A suitable driver for this device has been available in the kernel archive for some time* The real-time dock (RTC) device chosen is the MCP7940 [9], which requires an external crystal. If a coin cell is added to provide back-up power the RTC will continue to keep time even when the board is switched off. An extra serving of chips The basic circuit of the board has not changed since the first version [2]. Alongside the proces- sor we see 32 MB of RAM, a CP2102-based USB- to-serial adapter, and the power supply circuitry. Also familiar from the first Elektor Linux board will be the 14-way expansion connector, which allows a wide range [3][4] of extension boards (again available from Elektor [5]) to be connected. The circuit diagram and printed circuit board layout can be downloaded from the Elektor website in Configuring the network The first step in using the EMC28J6G LAN device on the board is the command modprobe enc2S]60 irq_pin=12 cs_pin=19 should show the device as interface 'ethQ'. In order to have the board receive an IP address from a DHCP server elsewhere on the network, use the command: 18 November 2013 www.elektor-magazi ne.com ELEKTOR Linux board nnk. 2 USB OTG (devke/host) RJ45 network socket USB power selection USB OTG Relay output terminal block Relay Boot configuration ENC28J60 Reset Console Power source select: USB/external Ex pans Eon connector RTC and coin cell 5D Card Power input, 7 V to 12 V: ground on central pin GND 3,3 V DC output Main memory (32 MB SDRAM) LPC3131 (ARM929, 180 MHz) 1015 1014 1011 GPA1 Figure L The new version of the board includes a network interface and a real-time clock. ifconfig -a should show the device as interface 'ethQ', In order to have the board receive an IP address from a DHCP server elsewhere on the network, use the command: dhcli ent etbe We can now test the interface by pinging any other machine on the network or server on the Internet: ping google.de The output should appear as shown in Figure 2. Stop the 'ping' program in the usual way by pressing control-C. Loading the driver automatically If you would [ike the ENC2816Q driver to be loaded automatically when the system boots up, add the line enc28j60 irq_pin=12 cs_pin=19 to the hie '/etc/modules' in the board's hie sys- tem, This is most easily done from the console. The command echo “enc28j6© irq„pin=12 cs_pin=19” >> / etc/modutes will append the given line to the end of the file. Alternatively, the fife can be edited using the 'nano' text editor: nano /etc/modules Using a fixed MAC address If the board is being issued with a different IP address by the DHCP server each time it is booted the reason is likely to be that the EIMC28J6Q does not contain a fixed MAC address: each time the driver is loaded it is configured with a different address. A fixed MAC address can be specified to get around this problem. Add the following line in the file '/etc/network/interfaces 1 : hwaddress ether MAC-ADDRESS A suitable choice might be the one given to the LAN module the first time its driver is loaded. This can be determined using the command i fconfi g where it Is displayed as the J Hwaddr' as follows: ethe Link encap : Ethernet HWaddr www.elektor-magazine.com November 2013 19 Projects Figure 2. Results displayed by a successful 'ping' command: we are on the Internet! ba : 07 : lb : Gc : 64 : GO Real-time clock A simple command is all that is needed to set the clock: gnublin-rtc ~s “2G13/G1/2G 11:23:12” To read back the time from the device, use the command: gnublin-rtc -g To set the Linux system clock from the RTC, use the command: gnublin-rtc -x Having the Linux dock automatically set from the RTC on each boot-up takes a little more effort First add the following text In the file Vetc/rc.lo- cal', just before the line that reads 'exit O': echo mcp7940 GxSf > /sys/bus/i 2c/devi ces/ i 2c-l/new_device echo “Now setting the date and time.” sleep 1 hwclock — hctosys Second, add an entry to the file '/etc/modules': rtc-mcp7940 And finally, deactivate the hwclock shell script, as this can cause problems with this type of real- time clock device: updste-rc.d hwclock remove && update-rc.d hwclock. s h remove On the next reboot the board will set the system time from the hardware clock, More informa- tion on this subject can be found on the Gnublin wiki [10], The future A new version of the Gnublin installer is avail- able [11], which allows a Linux PC to be used to create an SD card including bootloader, kernel and file system. The new version offers the choice between an 8 MB image and a 32 MB image. This is accompanied by a change to the underlying file system: EXT4 is now used, which is practi- cally fail-safe in the event of loss of power. This avoids the need for time-consuming file system checks required to 'repair' the SD card. We will look further at this and more in an article in the next issue, (130214) Internet Links [ 1] sauter@embedded-projects.net [2] www.elektor.com/120181 [3] www.elektor.com/120596 [4] www.elektorcom/130212 [5] www.elektorxom/gnublin [6] www.elektor.com/130214 [7] www,cadsoftusaxom/down!oad-eagle/ freeware [8] http://wwl.microchip.com/downloads/en/De- viceDocZ39662A.pdf [9] http://wwl.microchip.com/downloads/en/De- viceDoc/22266D.pdf [10] http://en.gnublin.org/index.php/ RTCJ3S13Q7 [11] http://en, gnublin, org/index.php/ Gnublin_Installer [12] www.elektorcom/eaglestarterguide PING google.de (173.194,69,94) 56(84) bytes of data, 64 bytes from bk-in-f94, ielO0.net (173.194,69.94); icmp_req=l ttl=49 time=44.3 ns 64 bytes from bk-in-f94.lel0O.net (173.194,69,94): lonp_req=2 ttl=49 ttme=44,7 ms 64 bytes from bk - in - f94 , lelQO . net (173.194,69.94): Lcmp_req-3 ttl-49 tlme=43 . 3 ms 64 bytes from bk-in-f94.lel00.net (173.194,69.94): icmp req*4 ttl-49 tlme=43.4 ms — google.de ping statistics — 4 packets transmitted, 4 received, 0 % packet loss, time 3004ms rtt min/avg/max/mdev = 43,308/43,968/44.784/0.673 ms 20 November 2013 www.elektor-magazi ne.com Design Your PCS Multi-mode placement, Auto-nudge parts, Pusli and Shove trace editing, Mufti-mode ORC, Blind/Buried vias, Auto spirt plane generation, 1-16 layer autorouter. Jumpers and test points, Rules based copper pour abStream A DownStream Technologies Solution 1 'U Muiti-document interface, Block hierarchy, Dynamic wire reconnect, Symbol wizards, 100K Digi-Key libraries, ERC, Auto- replace parts Price and Order On t anted Now SoloPCB Desian Software (J Soi U'i ST Download the Free Software Projects By Jean-Jacques Aubry (France) Important update to the Elektor 500 ppm LCR Meter Since this project was published in three installments [1], several hundred of the instrument have been built, to the great satisfaction of their users, the author, and Elektor editors alike. The author has now corrected two shortcomings liable to interfere with proper operation under certain conditions. The two points worthy of attention are the fact that the instrument seems to 'hang up' when measuring low resistances (<1 CJ); and the appar- ent impossibility to perform Trim actions. The author has already commented and acted on these problems in the Elektor forums [2], [3], but it's useful to revert to them here. When measuring resistances with a value lower than 1 Q , in order to obtain an adequate mea- suring voltage, the firmware sets the "voltage'' measurement gain to maximum: • range 1 (/? sense = 100 Q. and PGA103 gain at 100 ); ■ final amplification gain dose to maximum (step E or F). Unfortunately, the input offset voltage is strongly amplified as well, and using the circuit published in the March 2013 edition, this is no longer com- pensated. This can lead to the maximum voltage at the input to the analog/digital converter being exceeded all the time. This erratic phenomenon is not systematic and depends to a great extent on the cumulative offset voltage of U6 and U4, and on the (low) resistance (or inductance) being measured. So that's the first one! As for the second, when there is no component connected during the 'TRIM - OPEN-CIRCUIT' operation, here too the 'current' measurement gain is maximum at the frequency of 100 Hz (or 120Hz): • range 8 - 100 kQ and PGA103 gain at 100); • final amplification gain dose to maximum (step E or F). At this point, the 'current' measuring circuit is very sensitive to interference picked up by the measuring leads, particularly from the power line (50 Hz or 60 Hz). The result of the measurement is so erratic that the firmware refuses to display it, and does not validate the 'TRIM", So much for the second one I Two problems^two solutions Depending on whether you are handy with a soldering iron or not, there are two solutions: * Modify the hardware—the best solution— to enable the input offset voltage compensa- tion circuit to be adapted, and at the same time update the firmware (v. 3,0.0) along with the AU2Q11 program (v, 3,0.0). The software will automatically detect the hard- ware modification at runtime, due to the presence of a resistor on the P2.2 port line (LCD_SI) (Figure 1). * Update with the same versions of the firmware (v, 3.0.0) and AU2011 program (v. 3.0.0), without modifying the hardware. Important: Updating the software to version 3.0-0 must be done in either case. The new version is equally compatible with the origi- nal hardware and with the modified version described below. Modifying the hardware As originally designed, input offset voltage com- pensation is achieved by injecting a current into U6 r s input. Unfortunately, the result is too depen- dent on the (DC) resistance of the DUT. The new circuit (Figure 1) applies the correction voltage at the output of U5 (INA12S), and hence 22 November 2013 www.elektor-magazi ne.com 500 ppm LCR Meter V. 3.0.0 the DUT impedance no longer has any effect; this also makes it possible to separate the compensa- tion for the 'current' and Voltage' measurements. To achieve this, US's pin 5 is no longer connected to analog ground, but to a software-adjustable voltage via a low-value resistor. There are four steps to the modification; * remove R34 to disable the original compen- sation. R42 and C35 are no longer used and can also be removed; * replace R46 by a 10 Q resistor (prefers- \ :■ \p*: soi yp*: ■!!> IS VftEFD 41 TIEJI 4 CBOSIfQBI u IS \pi; ~5 yP 4,3 a \- -■ w \flAJj At .41 SUS f:i5 S ? ? S jtali nuSSS ri -5YA Ji CM AT r. lmhj^ 1C ~ \ ti LCD CS 14 LCD RES^ SI _ BtC. C N 4] ECO u ' s ‘ 43 LCD SCL^ 11 LCD SI ^ SI Ll^ ST Si LA^ 15 LCD ''l H X F s irei ? RWM VDD J M~l *■* ■P fl9*i Zl 4 1 Ul VDO BKl. C cs ■“ i CD At ^LCD 4^ 81 L2 IS o & ■Q Q- ■O G- O Q- ■o o- +0 o CKl a n 1) u Hii ^ as? diQf LCD HS j LC 2 SC . JH l£E U Rii DS U . LSI CM J*i Up IS IS vcc VDCltl IVTO* DTR ftTs RJ U13 SLEE? TKDITk FT235RL R^SBT usuoii n L'SKIP mJ □ SO R G5CD t GhD END END AC II si r J IT 55T FOR FHBJflARE UPDATE AT Fa«£fi.O& ;INLi j- TRW MPUi TRIM TP1 Z *5VA m Cm ■::n SI! it RIF [ SC SJ] J GS' ■ II 15 IS.flW 11 1DK. = 24 CIS il h-i; GH il-l HH St. -5VA Iran tfLC U3 74HCT4D£2 D r.RO §H YEE HPO CH 11 Ip Ci nr 4u? R1 VOQ \ '* H tT) Ri mm . TIWEK. I R5 -5VA 1 AV+ BAV193 RSI nr © -5VA R.SELA4 D R EEL A1 Q ±»L*L, n.iii ai> PI? »I1 RJG RE IDA 109ft Ik IMA a a a 4 & a CM ft nr C 12 if C3S iy]p II K=D DS r BAV1W T 11 i l LM.O ' + r ji 3 1 2 SAVigg 04 > 4 -5VA V ic* * rcht* *5VA ©~^T 1, Cl HIS S«M yOO W pin IN WWW CLK ESA DS cm cm TP2 Z T- MR ♦5V A 1 19 MO I t I D^lt t I 0 SAW A1 D O' 1 VK Ufl 74HQT«li3 ■JH& Cm vll 1 i 15 10 ms Rii 1 jm _■ l; C3 E Ri| R15 I JPi Ul SEt JI iEL □ JU e- -5VA BAY I D J Figure 1. Partial schematic with corrections to be made to improve the 500 ppm LCR Meter. www.elektor-magazine.com November 2013 23 Projects Figure 2. Modifications to the offset voltage compensation circuit around U5, Figure 3, Don't try to unsolder pin 5 on UB^you risk disaster! Use a scalpel to isolate it, then re-make the connections using wire* Figure 4, This resistor tells the firmware that the circuit has been modified as shown in Figures 1, 2 and 3. bly 0305), The 10-Q resistor can also be soldered directly across the 680-12 resistor that's already there; • the third step is more tricky: US's pin 5 must be isolated from its present connec- tions and connected to the junction of R45, R46, and R47. It's possible to do this by lifting pin 5, but we advise against this, as you should not take the risk of dam- aging U5. So we suggest instead making a clean cut in the (visible) tracks between U5.5 and C27, U5.5 and C34, and U5.5 and the through-hole adjacent to J14 (Figure 2), You'll then need to reconnect C27 and C34 to the through-hole (analog ground) via small wires (Figure 3); and use a short wire to create the new fink between U5 pin 5 and the junction of R45, R46, and R47; * solder a 4,7 kQ to 10 kQ resistor between pins 9 and 11 of 117, on the opposite side of the PCB (Figure 4)* The presence of this resistor will allow the firmware to detect the modified circuit. New programs [4] The version 3,0,0 firmware (LCR3A_firmware_ V300.hex) supports the new input offset voltage compensation circuit if, and only if, a resistance to ground is detected on pin 9 of J17 This results in a re-arrangement in the menus in the AU2011 program, which also updates to version 3,0.0: the original Input_offset adjustments menu is replaced by two menus Inputs offset^ U adjustment .. and Input_offset_I adjustment .. , the first with the input shorted, the second with it open circuit. For users who do not wish (or are unable) to modify the hardware, the solution consists in limiting the overall gain In range 1. Hand-in-hand with this, similar limiting can be performed in range 8, if there is too much interference in the surroundings, preventing the TRIM ~ OPEN-CIR- CUIT compensation being performed correctly. The gain limiting solution Is valid whether or not the device has been modified. The initial maximum value will be 5 for an unmod- ified device and 15 (step F) for a modified device. Naturally, the value modifications are stored in the device's memory, just like the other settings/ options in the Preferences window. It follows that we also have to add two menus in standalone mode, and modify the Preferences window in PC mode when the access to adjust menus option Is checked (Figures 5 & 6), Other modifications have been made to improve 24 November 2013 www.elektor-magazi ne.com 500 ppm LCR Meter V. 3.0.0 convenience in use, like the appearance of a "Port / Close the Port" menu, handy if you originally chose the wrong port; all you then have to do is select the right port and click the 'Open COM' button in the main window. Measuring high impedances The 'voltage' and 'current' signals are amplified with no low-frequency filtering prior to sampling. It is only after digitizing, by performing the mea- surement over a whole number of AC power- line cycles and taking the average of several measurements, that it is possible to reduce the influence of the stray signals picked up by the measuring device. This means it is possible for the signal applied to the analog/digitai converter (ADC) to briefly exceed this ADC's input range and invalidate the measurement. Consequently, particular care must be taken when measuring high impedances, when the LCR meter is set to range 7 and above all 8; this is the case during TRIM - OPEN-CIRCUIT. • Put the electronics in an earthed metal case (iron is preferable to aluminum at low fre- quencies). Take care if you are using the LCR Meter in standalone mode with a USB supply, or in PC mode with a laptop: in these cases, there is no earth connection and you'll need to make one. The power plug on a USB PSU doesn't have a pin to connect the LCR Meter case to the AC powerline protective earth; and a laptop running on its battery isn't earthed either. • Minimize the length of the measuring cables, and keep away from power cords. To protect the device and the measuring leads from radiated fields, place a grounded metal plate (preferably iron) of adequate size between them and any powerline wiring. • If there is still interference, reduce the gain of the measuring chain to range 8 (Max DACIndex I in standalone mode). To conclude, let's just note that experience has shown that in practice, the 4-BNC measuring unit solution (TONGHUI TH260G1A or HAMEG HZ181) is very much preferable to the Kelvin clip. (130307) Back Light OFF Line freq. 60 Hz Hdj .Max DRC Index U Rdj .Max DRC Index I Figure 5. Two new menus in standalone mode. Internet Links [1] 500 ppm LCR Meter Part 1, Elektor no. 417, March 2013 www.elektor.com/ll 0758 Part 2, Elektor no. 418, April 2013 www. elektor. com/1 30022 Part 3, Elektor no. 419, May 2013 www.elektor.com/130093 [2] www.eiektor.fr/forumLCR (in French) [3] www.elektor.com/forum/elektor-fo- ru m s/fie Id s-of-i nterest/test- measu re - ment. 1 543743. lynkx [4] www.elektor.com/ 130093 Figure 6. The 'access to adjust, menus' option under the Preferences in PC mode. www.elektor-magazine.com November 2013 25 Projects Multichannel Temperature Logger By Ihab F. Riad (Physics Dept., University of Kar- toum, Sudan) (a hot place) This project allows you to log up to six temperature readings over a period of time, complete with time stamps, all written to a .csv file stored on an SD card for processing on a PC. Local con- trol is also available in the form of an LCD and a keypad. Features * Max. six D518S20 1-Wire temperature sensors • PIC18F4520 based * 1 second minimum logging interval • Writes time-stamped .csv data on SD/ MMG card • Local control with LCD and keypad * On-board RTC The main components found in this project are the DS18520 digital temperature sensor, the RTC-DS1338 Real Time Clock, and a microcon- troller type PIC18F4520. Due to the ±0.5 °C tem- perature resolution of the sensors and a minimum logging time of 1 second, this logger is most suitable for environmental monitoring, like your focal temperature at six fixed height intervals above the ground. The sensors First off, you can use a maximum of six DS18S20 temperature sensors to capture an equal num- ber of temperatures at remote locations. If your application requires just two or three sensors, that's fine too. Looking at the schematic in Figure i, the remote sensors are connected to 3-pin connectors K3 through K8 using the 1-Wire system (which actu- ally involves three wires). As opposed to some previous projects like our Thermo-Snake [1], here the DS 18520 is used in standard 1-Wire mode 2 *fj fg 1 4 J [5 □ rather than in 'parasite power' mode. Rather than being connected to a common line or 'bus', each DS18S20 sensor has its own PIC port line RAG- RA5 and associated resistor network (R22/R28 and so on) connected to its DQ (data in/out) line, The DS18S20 being a 1-Wire component, each device ever produced by Dallas Semiconductors has a unique 64-bit identifier stored in ROM. The device sends messages using the format illus- trated in Figure 2, Into the schematic Returning to Figure 1, RTC chip IC1 supplies the time stamps for the logged data to the micro, using PC lines SDA and SCL. The DS1338 has its 26 November 2013 i www.elektor-magazi ne.com Multichannel Temperature Logger K1 £ O O O o ft15 Ft!1 CD. CRJ&32 JF 3V3 0 ■s m a m 7 Vtul VCC *1 m OUT OS133SZ BOA X2 KL GNQ K* R? 00 f ^Topn 5DA SCL T Vfs 3SSS ***■ fill in C5 flh 4-TDn. SI s[ U'J HJi * Si D fM m W HUH 10 Ps 0 G O Q £S O Cl Q LCD1 D0GM1&2 16 * 2 LO Q Z I — l£ u_ Z » d 5 s 3 r r 5 * | S 3 3 1 ■i rvr 3V3 Jr J C# RIB R13 T- CJ iO*i i tg i M B JSL i 06 tit i DT 11 ^J_ •4 i as it ■it 17 n 3* ^ C5_ 32. CD 3i 36 CLK 37 uu A2 01 » □ VOD MCLRiVPP RflflfflTfi RflliTNTI RBalflT? NB3iCCP2 PBl HBSTGli HBEi'PGC RB7.?GD HP HP VJL1 3D* «D1 RDiPSPl R;03iRSPl ROiPSPd FtDS/PSPS ftDBiPSPS R0T,PSP7 1C 2 RPO RP1 RPS.'CCP* RCJ.'SCKfflCL ptumwsoA RCKOQ rcwtxo RCTflXiDT PIC18F4$20 RA5 RM flAJ'AHiHVRS!F+ RA27ANJ RAU.'ANI FUUWAN0 VSS MCI 0&P2 vss D1 1 XI " K J H T | a SNHz a j" i i — 1 m t O AP1117E33G-13 I P 3 * , 5 £ v C ^.CD 9 jc K3 f-Wtte SD Card 120637-11 Figure 1, Schematic of the Multichannel Temperature Logger. Besides yours, some intelligence resides in the PIC18F4520, traditional 32.768-kHz watch crystal, and oper- ates off a 3.0-volt button cell, BT1, or 33 V when the board is powered. A commercial 4x4 matrixed, numeric keypad on microcontroller port lines RDQ-RD7 and connec- tor Kbl is used for setting the time/date and the logging interval. The keypad is also used to start and stop the logging. A 2-line, 16-character (2x16) LCD type DOGM162 (what's in a name?) is used to display the current time and date, as well as the instantaneous temperature from one of the sensors. The LCD's backlight (BL) function is controlled with T1 responding to control lev- els issued by the PIC micro on port line RE2. An SD/MMC card on the 'Cardl' connector holds the logged data. All read/write access and control of the SD card is via five lines on microcontroller port RC. The card can be removed and the file on it read on a PC for processing by your favorite statistics or graph rendering program capable of processing .csv files. Lots of nicely colored graphs in particular work wonders on CFOs, CEOs, CCOs, CYOs, CXYZOs and other non-electronics initiated persons in the audience. The internal fuse settings enable the microcon- troller to be clocked by an external 8-MHz quartz crystal, X2. With the interna] PLL enabled, the PIC's actual CLK is 32 MHz, The crystal is flanked by the www.elektor-magazine.com November 2013 27 Projects Figure 2. 1-Wire message format and pinout of Dallas' DS1852G 1-Wire temperature sensor. M-BIT C Rl MSB SfcRtAL NUMBER LSB MSB LSB ^ BIT FAMILY COD I : (2Kb) MSB LSB DS18S2Q OQ customary pair of 22-pF ceramic load capacitors. A word or two about these apparently paltry little parts. Get these wrong and funny things may hap- pen, Like C or C++ experts and other program- ming gurus fitting "yeah-weEI-something" parts In the "elector" circuit and subsequently spending hours on debugging the code, meanwhile creating long forum threads all across California right up to MIT Boston and across the ocean to Limbricht, all because the micro is running at a speed that's wildly different from what the designer planned, The upshot: get the xtal load capacitors wrong and your PIC oscillator will not work. Back to digitalism, connector K1 is the gateway to the Microchip PICKit. Two LEDs are provided: D2 to show logging activ- ity, and D1 to show card detection. The 3,3-V supply voltage for the entire circuit is furnished by a low-drop regulator, IC3, The maximum input voltage will be about 18 V (but don't push It), the minimum, about 4,6 V, Four AA 1.5-volt dry batteries will last a long time. Applications and how it was developed The first unit was built by the author to monitor the temperature variation at different points in a concrete slab just after the mixture was molded, and during hardening. That was for an M.Eng, student. The unit was primitive at that time with no more than the keypad and the LCD, The fog- ging was done manually every few hours for a couple of days. One member at www.elektoMabsxom suggested putting four sensors on a stick at 1-foot (30cm) intervals above the ground and two sensors in the ground. This will give you a good idea of the temperatures in your garden. The original code was written using PIC MIKROC from Mikroelektronika, Testing and debugging was carried out with the help of an Easypic6 devel- opment board from Mikroelektronika, their RTC2 module, and their MMC/SB board. The author's Petit FAT Fs PetitFAT File System (Petit FATFs) Is written in compliance with ANSI C, and completely separated from the disk I/O layer. It can be incorporated into tiny microcontrollers with a small memory even if the RAM size is less than sector size. Petit FatFs features include * very small RAM consumption (44 bytes work area + certain stack); * very small code size (2-4 Kbytes); * supports FAT32; * single volume and single file; * file write function with some restrictions. In terms of the Application Interface, Petit FATfs provides the following functions: pf_mount (mount/unmount a Volume); pf_open (open a file); pf_read (read file); pf_write (write file); pfjseek (Move read/write pointer); pf_opendir (open a directory); and pf_readdir (read a directory item), PetitFat Fs is completely separated from the disk I/O layer, hence it requires certain lower-layer functions to read the physical disk. The low level disk I/O module is not a part of Petit FatFs module and It must be provided by user. The sample drivers called diskjnitialize, disk_readp (partial) and dlsk_writep (partial) are also available in the resources [4]. Application 28 November 2013 i www.elektor-magazi ne.com Multichannel Temperature Logger original test setup is pictured in Figure 3. While processing the project for publication here, new software was developed by Elektor Labs using their Microchip MPLAB X environment and C18 compiler. The SD card is read, and written to using Petit FatFs, a sub-set of the FatFs module for 8-bit microcontrollers, see inset. The 1-Wire protocol got implemented with the help of a CIS library at [2]* All PIC source code fifes for the project have been packaged into a .zip archive fife to be found at [3] for free downloading. The log file The temperature logger expects a file called Tern- pLog.csv on the SD card. The logger is unable to create a new file or adjust the size of a file. At the start of a new log session this file is opened and overwritten starting from the first record. Con- sequently, some measurement values remain in place if the new session contains fewer samples than the previous one. It is therefore recom- mended to use your PC to write a new, blank file to the SD card prior to a new logging operation. This empty file is included with the free software download from the Elektor website [3]— but can also be created from scratch, see [4], Quick 8t dirty, to create a new log file, type: fsutil file createnew\ < [driveletter >: The default size of our file is 5 MB, but tailor the size to your liking. In terms of measured values appearing on the LCD, T(emp,)0 is the sensor wired to KB (near- est the display), T1 to K7, and so on, up to T7 on K3 at the lower side of the PCB. A new line/record is written into the TempLog. csv file for each new measurement, Columns 1 and 2 contain date and time respectively. In the next columns the measured temperatures appear in order (see above paragraph) of the connected sensors- For example, if only one sensor is con- nected, its output value appears in the third col- umn, regardless of the connector it is wired to or plugged into. So You Think You Can Have a go at changing that 8-MHz existing micro- controller oscillator frequency. Feel free to do so—here's what you're up against in terms of delays that need to be adjusted: * in file Globals.c: adapt delay_ms, delay_ us, setup_io (SSPADD). * in file LCD.c: adapt XLCDdelaylSms, „.4ms, ,.,100us, ...500ns, XLCDdelay. * in file SW_I2C.c: all functions, * in file Onewi re . c: ow_reset, ow_wri te_ Figure 3. This how the project got developed at the author's home using a Mikroelektronika EasyPIC6 development system and some add-ons. www.elektor-magazine.comt November 2013 29 Projects Key Functions The keypad Is basically a DTMF (telephone) type with numbers 0-9, letters A-D, the hash sign £#), and an asterisk (*)* The key functions are summarized below. Keys presses do not produce DTMF sounds, A: Adjust logging interval 0-9: Change number (advances automatically) D: Exit the setting menu Note that after every unit (hour, minutes, seconds), that unit ts updated only— not the rest. B: Start/Stop logging (LED indicates logging In progress) C: Set Clock 0-9: Change number (advances automatically) D: Exit the setting menu Note that after every unit (hour, minutes, seconds), that unit is updated only— not the rest. 0-5: Selects sensor to be displayed on LCD Display Codes: Startup: C L K ■ d wd wd d ■ d mo mo y y R E/U S/N h h mi mi s s Home (x - = sensor number): T X di * wd wd d d mo mo y y (-) T T d T h h mi mi s s Set time: S e I wd wd d d mo mo y y t m e h H mi ml s s Adjust log: S e t 1 0 g i n t e r V a i h i h h m i 1 m m s ■ i- s s byte, ow„read_byte, ow_read_bi t, ow_get_ temper atu re . * in file mmc * c : di sk_i ni ti ali ze, ini t_spi , All done? Then post your results to the commu- nity at www, el ektor-labs.com. Construction The circuit board designed by Elektor Labs for the project is shown in Figure 4, along with the parts list* The board's overall shape and dimen- sions are governed by the LCD and the keyboard installed on top of it. Etchers@home: the PCS ♦ pdf files are at [3]. Apart from a good number of 0,1" pitch pinheaders, a button cell holder and 0*1" pitch socket strips with turned pins, the board contains mostly SMD parts. Of these, the PIC microcontroller will be the most both- ersome to fit, but work calmly and accurately and it can be done. Methods of hand soldering these multi-legged parts successfully have been described many times. The keypad is mounted on four 15-20 mm stand- offs to clear the dip on the battery holder. Finally, the LCD is a fragile device and must be handled and mounted with the utmost care* (120637) 30 November 2013 i www.elektor-magazi ne.com Multichannel Temperature Logger COMPONENT LIST Resistors (SMD 0805) RljR2 r R21,R28,R29,R30,R31,R32,R33 - lOkQ 5% 125mW R3,R4,R5,R6,R7,R8,R13 r R14 = 100ft 5% 125mW R9,R10,R11,R12 = 8>2kft 5% !25mW R15,R16,R17,R22,R23,R24,R25,R26 = Ikft 5% 125mW R18,R19 = 1,5ft 5% lOOmW R20 = 18kn 5% 125mW R27 = 56kft 5% 125mW Capacitors {SMD 0805) C1,C2,C3,C6,C7 = lOOnF 50V 20% C4 = l|jF 16V CS = 470nF 25V C8,C9 = 22pF 50V 5% CIO = IGjjF Cll = 22 ]jF 10V Semiconductors Di r D2 = LED, 3mm, low current T1 = BC850, HPN 45V transistor, SOT-23 IC1 = DS1338, real time clock, SOIC8 IC2 = PIC18F4520-I/PT, 8-bit MCU, programmed, Elektor Store # 120637-41 IC3 = API 117E33G, LDO regulator, 3,3V, SOT223 IC4,IC5,IC6,IC7,IC8,IC9 = DS18S20, 1-Wire tem- perature sensor, T092 (not on board) Miscellaneous Kbl = MCAK1604NBWB, keypad, 4x4 array, Multicomp XI = 32,768kHz quartz crystal, 12.5pF load, 20ppm, 4.1xl.5mm, Abracon ABS09-32.768KHZ-T X2 = 8MHz quartz crystal, 18pF load, 20ppm, 5x3. 2mm, Abracon ABM3-8.00QMHZ-D2Y-T Cardl - uSD {micro SD) connector, Hirose DM3AT-SF-PEJM5(40) BT1 = CR2032, with PCB mount holder LCD! = DOGM162W-A 2x16 character LCD Backlight EA LED 55x3 1-G K1 = 6-pin pinheader, right angled, 0.1" pitch K2 = 2-pin pinheader, right angled, 0.1" pitch K3,K4,K5,K6,K7,K8 = 3-pin pinheader or socket, right angled, 0.1" pitch Socket strip 0,1" pitch, turned prns, for mounting LCD and keypad PCB # 120637 Figure 4, The printed circuit board designed for the project contains chiefly SMD parts. Internet References [1] Thermo-Snake, Elektor June 2008, www. etektor, com/070 122 [2] 1-Wire protocol: http : //psychouLcom/ electronics/l-wire-onewire-cl8-library-2 [3] www,elektor ( com/120637 [4] Create a file of size xx: http://windowsitpro.com/systems-manage- ment/how-can-i-create-file-certainsize-win- dows-xp-and-later [5] PetitFATFs: http : //elm-chan .org/fsw/ff/OOindexj. htm I www.elektor-magazine.comi November 2013 31 Projects By Michael Odenwald (Germany) Figure 1. The USB thermometer circuit is simple. USB Thermometer A simple method to read data from the USB port For many years the serial RS232 computer port could be relied upon as a sort of MacGyver universal port. Nowadays PCs are unlikely to be supplied with this 9-pin sub-D connector. When you need to hook up some electronics to a computer, the USB port looks like the only option. The computer however needs a corresponding software driver. Here we describe an elegant patch around this problem. The development of a software device driver, including adaptation to run in different operat- ing systems, is anything but trivial. Add to this also the niceties of digital signatures for which the device/driver/operating system/application program chain adds additional complexity. The necessary time investment is often unacceptable for small projects. For this reason a virtual COM port is often employed but this brings with it the (configuration) disadvantage and misses out on many of the good USB features. One USB mode that can be relied on to function and also supports prototype development is the USB-HID (Human Interface Device) class. The USB HID usage allows many more devices than just a mouse and keyboard (see The USB HID device class'). The USB standard [1] specifically allows the use of 'other devices' which Include all types of actuators and sensors. Since all of the major computer operating sys- tems already have USB HID drivers there is no reason why you shouldn't use them for your own purposes. You only need to produce a suitable application program to run in your computer's operating system. 32 November 2D13 www.elektor-magazme.com Measure temperature via USB Data capture You can use the USB HID pathway to pass all sorts of external data to a PC. The temperature measurement application is just one example of the process. A small ATtiny microcontroller type ATtiny85-20 {IC1 in the circuit diagram Figure 1) is used here to provide the limited degree of Intelligence' necessary to handle the USB pro- tocol stacks, communications and also to input and format the sensor readings. All components in the design derive their power directly from 5 V available at the USB socket Kl. The microcontroller is clocked at 16.5 MHz from its internal PLL, this gives enough speed to handle USB communications and eliminates an external crystal. IC2 is the DS18B2Q temperature sensor from Dallas semiconductor (now part of Maxim) which uses a 1-wire interface. It operates in so-called Parasitic Power mode [2] where the chip's VDD pin is connected to ground and power is derived from the data signal connection. This method has the benefit of improving accuracy by reducing the effects of self-heating in the chip. The USB data signals are connected via limiting resistors R1 and R3 which restrict current flow from the line drivers in the event of a short circuit. The two 3.6 V zener diodes D1 and D2 ensure that the data signal voltage swing does not exceed the chip's supply voltage. Resistor R2 is used during USB enumeration and signals to the host (in the PC) that a low speed device (1.5 Mbit/s maximum data rate) is connected. Capacitors Cl and C2 provide supply decoupling and buffering of the 5 V feed from the USB socket. K2 is the standard 6-way ISP pin header to pro- gram the controller. LED D3 indicates an active measurement cycle. With the temperature sensor at maximum resolution this takes around 750 ms. Firmware Firmware for the USB thermometer is written in C, The WinAVR development tools [3] are used to compile and burn the program to the microcon- troller's flash memory. The USB stack structure is implemented with the help of V-USB software [4]. Functions used to read the temperature sensor are taken from a library by Martin Thomas [5], After the hardware is initialized the USB soft- ware stacks and USB enumeration process is executed. The firmware then switches to inter- nal operational mode where a state machine is The USB-HID device class The HID (Human Interface Device) device class is a partial definition of the USB standards describing devices which provide input from the user. Typical examples would be a keyboard, mouse or joystick. In addition to these normal types of input devices the USB standard also caters for 'special systems' which can take the form of sensors, measuring equipment or even telephones or headsets. The use of readers, games items and promotional products are also anticipated, USB-HIDs have the benefit that the corresponding system driver is already contained in the computer's operating system (at least for Windows, Linux and OS X) and is therefore automatically loaded, without any input from the user, whenever a new USB HID is connected. The disadvantages of HIDs should also not be overlooked: The data transmission rate is not particularly high and they have a limited number of USB Endpoints, restricting the amount of data which can be transferred. implemented. This Finite-State Machine consists of; USB protocol, read the sensor and then wait. The states are sequentially cycled with a pre- defined delay period. Each complete measurement cycle takes 10 s. The most important e | ement Requests from the host within this period will in the firmware is the USB return the same value, only after each cycle has HID Descriptor: /* * USB HID report descriptor */ PROGMEM char usbHi dReportDescri ptor [33] = { 0X06 J 0X00 , 0 xf f j // 0X09 } 0 X 01 j // 0 xal j 0 x 01 , // 0x15 j 0X00 ? // 0 X 2 6 , 0 xf f J 0X00, // 0x75 , 0X08 3 // 0x85 > 0X03 y // 0x95 j 0X04 } // 0X09 j 0X00 , // 0 xb 2 , 0X02 ? 0X01 , // 0x85 j 0x14, // 0x95 , 0X03 j a 0X09 , 0 X 00 , // 0 xb 2 j 0 x 02 , 0X01 3 // 0XC0 // }; USAGE_PAGE (Generic Desktop) USAGE (Vendor Usage 1) COLLECTION (Application) LOGICAL_MINIMUM (0) LOGICAL.MAXIMUM (255) REPORT_SIZE (S) REP0RT_ID (10) REPORT^COUNT (4) USAGE (Undefined) FEATURE (Data , Var , Abs , Buf ) REPORT_ID (20) REPORT_COUNT (10) USAGE (Undefined) FEATURE (Data , Var , Abs , Buf) END COLLECTION www.elektor*magazine,com November 2013 33 Projects Figure 2. The PCB component placement. COMPONENT LIST Resistors R1,R3 = 68 Q R2 = 1.5kQ R4 = 470Q R5 = lOkQ Capacitors Ci = lOOnF ceramic, 5mm pitch C2 = 25pF 16V, electrolytic, 2.5mm pitch Semiconductors 1C1 = ATtiny85-2GUP, 8-pjn DIL, programmed, Elektor # 120620-41 [6] IC2 = DS18B20, 3-pin T092 case Dl,D2 = ZF3.6, zener diode, 0.5W D3 - LED, green, 5mm Miscellaneous K1 - USB socket, Type A, PCB mount K2 = 6-pin (2x3) pinheader, 0.1" pitch PCB # 120620-1 [6] elapsed will the latest measurement be avail- able. The measurement process is controlled com- pletely by the microcontroller and not by the PC. The measurement interval helps reduce sensor self-heating effects. The Descriptor consists of 33 bytes. It defines the possible report IDs (10 and 20), the application program uses these to communicate with the thermometer. The reports are implemented as so-called 'Feature Reports' with different length information blocks (4 and 10 byte). A feature report allows values to be read from or written The central class for the USB thermometer is then: namespace WindowsApp { /// /// Implementation of the usbDevice with service methods iff based on the class usbGeneri cHidCommuni cati on /// class usbDevice : usbGeneri cHi dCommuni cation { private int tval; /// III Class constructor - place any initialization here III III cparam name=”vid”x/param> //! < pa ram name= H pid"x/param> public usbDevi ce(i nt vid, int pid) : base(vid, pid) { 1 III III USB HiD Temperature Module Method GetTemeratur () III public int GetTemperatur ( ) 34 November 2013 www.elektar-magazme.com Measure temperature via USB to the USB HID system; in this application they are only read. Report ID 10 is used to request the temperature and returns four bytes. Report ID 20 queries an i dent string consisting of 10 bytes giving date information (yyyy-mm-dd). Build then drive The circuit layout is not at all critical and the use of non-SMD components with the PCB designed for this project (see Figure 2) makes construction really easy. The PCB layout hies are also available for free download from the Efektor website for this article [6]. Figure 3 shows the fully popu- lated prototype. The design does not need any set-up or calibration procedure. Once all the components have been fitted and you have double checked your handiwork the firmware can be programmed into the microcontroller Seek out the firmware which is freely available as both a source code file and a directly programmable hex file from [6]. Plug in your AVR-I5P program- Figure 3. mer to connector K2 to program the device. It T ^ e thermometer is important to check that the 'divide by eight' prototype. dock divider option is deactivated and that the correct internal clock is selected. The settings are correct when the low fuse' has the vatue OxEl // Declare an input buffer Byte[] inputBuffer = new ByteTS]; // we expect 5 byte; 1 x ReportID and 4 Byte temperature i nputBuf fer [0] = 10; // Read ReportID 10 // Perform the Read Command bool success; success - getFeatureReport (i nputBuf fer) ; if (success == false) { Debug .WriteLine (“Error during getFeatureReport 51 ) ; return tval; // Error during USB HiD_GetFeature Request so return the old value } tval = i nputBuf fer [T] << 24; tval |= i nputBuffer [2] << 16; tval |= i nputBuffer [3] << 8; tval | - i nputBuffer [4] ; return tval; // Return the new value } > > www.elektor-magazine.com November 2013 35 Projects Figure 4* Temperature displayed by the application program running in Windows, Figure 5. Temperature display using the command line tool. and the 'high fuse' has the value OxDD, Once the microcontroller has been programmed the circuit can be hooked up to the PC using a USB cable. The operating system will detect that a new HID device has been plugged in and will automatically install the HID system driver; it's that simple! It doesn't matter is you are using a 32 or 64 bit version of Windows, OS X or Linux, the HID driver is always available, always digi- tally signed and will always install without any further input from the user, A couple of seconds after plug-in the unit is ready to go. |tv-nnd HRG □ cJxhijnc\HiD Teftjtcrrature notiul\cnjl i '((njl>cFui“tqqr T ^xff — LtiHj.it rrtl ure is: *1^.0625 c:\liontVH iD Tenperatupe HlodulScnri-tool> Ld values in the range -550,000 to +1,250,000, The software divides these values by 10,000 giving a temperature value with a resolution of 12 bits or 0.0625 °C. This level of resolution is not strictly necessary because the sensor itself has an accuracy of only 0.5 °C. The screenshot in Figure 4 shows how the temperature is dis- played in Windows, The Windows compliant source code together with the necessary library is available to down- load for free [6]. In addition to this Windows based program there is a simpler command line tool that returns the temperature reading as text (Figure 5). The corresponding source code, com- piled program and tool for Linux are also avail- able from [6], And so it goes..* The circuit and corresponding software for the USB thermometer demonstrates a simple and practical method to connect your own HID device to a PC, Both can be relatively easily adapted to the needs of your own particular application, giving an (almost) hassle-free pathway to pass data to a PC providing you do not have too much data to send and can accept a relatively mod- est data rate, (120620) The host software The (Windows) application program which inputs and displays the USB thermometer readings Is written in C#. It demonstrates how communi- cation with a generic HID device Is performed. The host software uses the usbGenericHIDDevice functions in the library [7], which interacts with the Windows API functions. The software is com- piled and run using the express version of Visual Studio 2010 [8], The base class usbGenericHid- Communication is key here, from which a class for our own HID device must be derived. In this class the 'method' to be executed is implemented. The HID device is identified and called with the parameters Vendor ID = 0x0C7D and Product ID - 0x0011. The method GetTemperaturQ reads and returns the temperature value. The tempera- ture range of the sensor spans -55 to +125 °C. The sensor sends measurements formatted according to 'signed longint' convention giving Internet Links [ 1] www.usb.org/developers/hidpage/ [2] http://datasheets.maximintegrated.com/en/ ds/DS18B20,pdf [ 3 ] http : //wi na vr, sourceforg e , n et/ [4] www.obdev.at/products/vusb/index, html [5] www,siwawi,arubi,um-kl,de/avr_projects/ tempsensor/index, html [6] www, elektQr.com/12Q620 [7] www, waitingforfriday. com/index, php/Open_ Source_Framework_for_USB_Genenc_HID_ d e v i c es_ b a sed _o n_th e_Pl C 1 8 F n d _ W i n - dows [8] www, microsoft.com/germany/express/prod- ucts/wfndows,aspx 36 November 2D13 www,elektor-magazine.com tfUMANDATA FPGA / CPLD Boards from JAPAN SAVING COSMIME wttli readily available FPGA beards ■ Basic and simple features, single power supply operation ■Same board size and connector layout - AC M/XCM * All stocked items are ready to be shipped immediately ■ Over IDG varieties of F PGA/CP LD boards are available ■ Free download technical documents before purchasing PLCC68 series " FPGA Module 1C socket mountable " 3.3V single power supply * Very small size [25,3 x 25,3 [mm]) XP68-03 Spartan-6 PLCC68 FPGA Module f Spartan- 6 J PLCC 68 X C 6 S LX4-5 -2 C S G 324C 16Mbit Configuration Device Two User LEDs One UserSwitch(Slide) RoHS compliant AP68-04 Cyclone III PLCC68 L PGA Module ■■'iflET tP Sr; ■ a T * Ah i* to , ... fr— q h ■ a PLCC 68 I Cyclon e III EP3C25U256C8N 16Mbit Configuration Device Two User LEDs One User Switch (Slide) RoHS compliant ALTERA FPGA Board 5 W LED I 0:296 Cyclone IV E F780 FPGA hoard ACM-204 series ( Cyclo ne IVE][~ SDRAM ] EP4CE30F29C8N EP4CE40F29C8N EP4CE1 15F29C8N Credit card size [86 x 54 mmt RoHS compliant . Cyclone IV GX F484 FPGA hoard ACM- 108 series "Cyclone IV GX i DDR2 ER4CGX50CF23C8N EP4CGX110CF23CBN EP4CGX150CF23C7N Compact size (43 x 54 mm) RoHS compliant XILINX FPGA Board Spartan-6 FGG484 FPGA board XCM-0 1 9 series fSoartar)-6!i 5V I/O sw LED 1/0:100 XC6SLX45*2FGG484C XC6SLX75-2FGG484C Credit card size [86 x 54 mm) RoHS compliant (gjj^ Vlrtcx-5 FFG676 FPGA board XCM-109 series ( Virtex-SJ; SDRAM XC5VLX30-1FFG676C XC5VLX50-1 FFG676C XC5VLX85-1 FFG676C XC5VLX1 10*1 FFG676C Compact size [43 x 54 mm) RoHS compliant Manufacturing Plots menu. In our case we need the Top Copper, Top Solder Mask, Top Silkscreen, Bottom Copper, Bottom Soider Mask, Drill Data and Drill Ident Drawing plots as shown in Figure 1. Clicking on the Options button will open the Options windows where you can modify all of the settings for Gerbers, drill file and PDF outputs. I personally like to use R5-274-X to embed the aperture information into the Gerber files, and to export everything in metric with four decimals of precision as I've illustrated in Figure 2. Clicking the RS-274-X button will adjust the listed 38 | Movember 2013 ] www.elektor-ma gazine.com Tips & Tricks options to enable the embedded aperture table and clicking the RS-274-D button will disable all of the output options. Circuit board manufacturers also need a drill file or NC (numerically controlled) to know where to drill the holes in the circuit board. There are several different output formats but I personally like to use a metric Excellon format with four decimals of precision, as illustrated in Figure 3. Now that we've configured the output devices, we need to add the board outline to all of the generated plots so that the circuit board man- ufacturer can line up all of the different layers when making the RGB, You do that by clicking on the Layers tab for each plot in the Output Man- ufacturing Plots window, and double clicking on "[Board Outline]" so that a Y is displayed in the Selected column. Once the board outline is added to all of the layer plots, click the Run button to generate all of the output files. After the files have been generated, DesignSpark will display a report summary in Notepad, which you should review to make sure that there weren't any errors. All of the Gerber files will have a .GBR extension, and the drill files will have a .DRL extension, I always toad the Ger- ber and drill files Into a 3 rd party Gerber viewer like ViewMate [1] just to make sure that there aren't any errors. For example, white writing this article I had accidently set some incorrect scaling factors in the Gerber output that became obvi- ous in the Gerber viewer, and were easy to fix. Figure 2, Selecting metrics with 4-decimal accuracy. Figure 3, Four^decimaf precision is also defined for the NC drill data. Bill of Materials A Bill of Materials (BOM) lists all of the compo- nent information in a design so that it can be manufactured, DesignSpark includes the ability to generate BOMs as part of its Reports feature in the Output menu, as shown in Figure 4. The built-in Bill Of Material report will generate a BOM with the following fields: • Ref Name: The reference designator for the component • Qty: The number of components for that line, always 1 • Component: The component name field ■ Value: The component value field • Package: The component PCB footprint type • Manufacturer: The component manufacturer field • MPN: The component manufacturer part number field Built-in Reports BJ Of Materials Dangtng Trades Design status Report Generic Nefcst Schema tic^PCB Check Unconnected Pns Report U$er Reports BiP Of Materials I I Close Options,,. Hew... Qspy... RcnaMfe* Effete Figure 4, Selecting the BOM as a Report. www.elektor-magazine.com [ November 2013 | 39 Figure 5* Editing options for the BOM report generator. Figure 6* One way of composing the BOM. * RS Part Number: The component RS part number field • Description: The component description field The default BOM is fine if you only have one part number per component, but I tike to asso- ciate alternate part numbers to the component so that my BO Ms have ail that information avail- able automatically. I also like to see the same part grouped together instead of a line for each component. For example, I find it better to know that there are two 1 K (kft) resistors in a design instead of having to count them manually in the BOM, Unfortunately DesignSpark cannot group components together on a BOM and display their reference designators in the same report, which means we will have to create two custom BOMs— one that Is grouped for purchasing and another with reference designators for assembly. The first step is to create a new report by click- ing on the New button. A dialog box will pop up where you can give the report a name, and then you will be able to edit the report content. It will look like In Figure 5. What's happening here is that the first line in the report will be the text "Component Report", fol- lowed by Design Spark's standard report header, a blank line and then a list of all the components. The part we have to edit is the Component List, For the purchasing BOM I edited the report col- umns to be Qty, Description, Manufacturer 1, Manufacturer 1 Par Number, Manufacturer 2, Manufacturer 2 Part Number, Manufacturer 3 and Manufacturer 3 Part Number. The assembly BOM is the same as the purchasing BOM, except that it includes the reference designators or Ref Names in DesignSpark. Figure 6 shows the con- figuration I use for assembly BOMs. To add custom report columns like Manufacturer 1 to your report you need to choose Value from the Field dropdown box. This will enable the Values box where you can select one or more component fields to be used for the column. The Caption field will be the column heading in the final report. It's also important to run the BOM reports from the PCB file and not from the schematic— to make sure the BOM is populated properly. Conclusion Today we generated Gerber files and a BOM from our DesignSpark design enabling it to be man- ufactured. Next time well look at some of the online quoting tools built into DesignSpark* (13C24Q) Internet Reference 1* www.pentalogix.com/viewmate.php 40 I November 2013 | www.elektor-magazi ne.com FREE CIRCUIT BOARDS Send your email address to elektor apcircuits.com for a chance to WJ N a 2 or 4 -layer circuit board order! (up to a $500,00 value) DID YOU KNOW? 13^1 l 2- layer boa-ds ready l^r pickup bv 2pfn the next day and masked 2-layer boards arc ready the second day Custom board shaping options can also include ptateri slots and internal cutouts www.apcircuits.com 1.877.APC-1PCB [377.272.1722] 'eofvtwt runt mgntNy ant) eiol ^ ,» of Stpitmixr JO 2013 4 “ The Problem You've got intermittent pulse bursts being generated when they shouldn't be. You can see them on a scope. Mow often and when are they occurring? Or you just want to know what is happening in a longer time period The Solution Use a Cleverscopel Capture a day's worth of samples at 1.5 MSPS. Pan and zoom, really quickly. Accurately identify when events happened. See even very short ps events in a day's recording. Check out http://youtu.be/ 67TU2NAaHGg CS328A-XS 1 4 Bit MSO rscope.com •km 1 GND K3 IC2 I®! 1 - i 1 4 C4 — C2 [ ] u 78L05 0 * lOOu 25V Cl R1 -) took L L C3 IDDp IGOri D1 ESAT85 a o o o □e ■=- a. il. d f = si ^ * E ^ £ § y J u □ (fi £ uj W W □ S “ O ^ JP1 Q Q O Q Q 1 H9 OR ta © ESC 548 £ 5 1 B |rs u vacs GP3WCLR GPQiANO GP1/AN1 GF2fAN2 GPJ/AN3 GPSi'CLKIW VSS S PIC12F575P K2 R3 R4 - | Ik R5 rDi H 4 + M 4 + 130136 - 11 Figure 1, The LED control module schematic. www.elektor-magazine.com 1 November 2013 47 Projects COMPONENT LIST Resistors R1 = lQOkQ R2-RS = lk Q R7 = lOkQ R8,R9 = OQ Capacitors C1,C2 = lOOnF C3 = IDOpF C4 = lOOpF 25V (e.g. Rubycon 25YXF100MEFC6,3X11) Semiconductors Dl ^ BATS 5 T1 = BC548 IC1 = PIC12F675-I/P (Microchip), pro- grammed, Elektor Store # 130136-41 IC2 = 78 LOS Miscellaneous JP1 = 6-pin pinheader Kl,K2 r K3 = 3-pin PCB screw terminal block PCB # 130136-1 [3] 'y' : Hex address low byte of the selected house y = 0 to F 'S': Command S for set 'a': High byte of the selected LEDs (0 or 1) 'b' : Low byte of the selected LEDs (0 to F) 'CR': Carriage Return (enter) to end the sequence. The input sequence is therefore HxySab followed by 'enter", where xy is the addressed module, J 5' represents set and J ab' is the hex value of the LEDs that will be turned on* This value can be in the range 00 to lFh, allowing every combination of the five LEDs to be switched. Example: To turn on LEDs 3 and 5 of module 12, enter the line H12S14 followed by 'enter' at the terminaL Figure 2 * Thru-hole components but a tidy layout nevertheless. J H": House 'F': Hex address High- Byte (F for un prog rammed chip)* T': Hex address Low-Byte (F for unprogrammed chip)* 'P': Command P for programming. 'a' 'a' "5": Safety code required to prevent accidental programming. '5": Safety code required to prevent accidental programming* 'x': High byte (Hex) of the address to be assigned to the module, x = 0 to F. 'y r : Low byte (Hex) of the address to be assigned to the module, y = 0 to F. 'CR': Carriage Return to terminate the sequence. Entering the sequence 'HFFPaaSS' at the termi- nal will cause the chip to switch on all the LEDs, Enter next the desired address (xy) and finally the 'enter' key. The LEDs will now go out and after an off/on power cycle the address will be stored. The same sequence can be used at any time to assign a different address to the module. Example: To allocate the address 23h to a module that has not yet had Its address assigned , enter the sequence / HFFPaa5523 / followed by 'enter'. Switching LEDs Controlling the module 'H f ; House V: Hex address high byte of the selected house x = 0 to F Build it modular Figure 2 shows the PCB for a single module which can be ordered from Elektor* The use of thru-hole components simplifies construction greatly. The two 0 Q resistors R8 and R9 are necessary to bridge some PCB tracks and can be replaced by wire links. Use a socket to mount the controller* All the modules are connected in parallel. Resis- tor Rl in each module ensures that only a very small amount of current is taken from the RXD signal, allowing a large number of modules to be connected without any problem* The RXD signal is generated from pin 3 of the 9-way sub D con- necter on a PC. The earth connection is on pin 5 of the same connector and is linked to the earth wire in the power cord* The pre-programmed microcontroller reference number 130136-41 can be purchased from the Elektor Store. Alternatively you can program the chip yourself if you posses the programming tools* This option is more attractive if you have a large layout requiring many modules* The software is free to download from [3] and includes all the CAD files for the project, viewable using the free CAD program DesignSpark. (130136) Internet Links [ 1 ] wwl .microchip.com/downloads/en/DeviceD- o c/4 1190G.pdf [2] www.microchip.com/pickit2 [3] www.elektor*com/130136 48 November 2013 i www.elektor-magazi ne.com Throw off the 8-bit ball and chain! CFA10036 ARM9 + Linux SOM * fast 454MH2 ARM9 * pSD 4GS lo 64GB * Linux mainline kernel * deep. 12 8/2 56MB * USB/UART/$P!/I^C - GxADC/BxPWM/CAN - wide 91/126 GPIO * debugystatus OLED - S71&G1 to $48®G5QG Get your project to market fast: lay down a standard SODIMM connector, snap in a CFA 10036 System-On -Module and you instantly have access to tons of GPIO and the power of Linux. Leave the 8'bit dark ages behind CFA920-TS 108 mm/ 4 , 25 " This tiny touch -enabled embedded Linux PC is powered by the CFA 10036 * 800x480 color TFT * resistive touch screen ■10/100 Ethernet + USB •24 GPIO on or* * 79 more GPIO on 1mm ■ S-channei accel+gyro * 1140^01 to S1Q5&Q500 18.5 mm 0 . 73 *“ thick Crystalfontz iiti www. cry sta If ont 2 .com +1 509 892 1200 THE OUC INAL S1NCI Designing Tube Amplifiers concept, implementation and assessment best SELLER This new book from Merino van der Veen looks at tube amplifiers from more than just a theoretical perspective. It focuses primarily on the design phase, where decisions must be taken with regard to the purpose and requirements of the amplifier, and it addresses the following questions: How do these aspects relate to subjective and objective criteria? Which circuits sound the best, and why? If you want to develop and market an amplifier, what problems should you expect? What are the significance and meaning of measurements? Are they stiii meaningful, or have they lost their relevance? Menno will give you all the answers! 188 pages • ISBN 978-1-907920-22-6 £29.50 •€ 34.50 • US $47.60 Labs By Clemens Valens (Elektor.Labs) Some people have sound and/or stimulating ideas but do not know how to translate them into working electronic circuits, while others lack the skills and/or the time to complete a project. Below is selection of projects posted on Elektor.Labs and looking fora helping hand to reach the finish line. Can you cheer and/or assist? Electronic Sculpture Original Poster (OP) snap wants to create an electronic sculp- ture capable of producing figures in 3D by individually moving up and down some fifty balls attached to strings. There are some nice videos on YouTube showing such contraptions, just search on "'BMW kinetic sculpture" or words of similar mean- ing. Winding and unwinding the strings can be done with small motors, but how do you control fifty of them in a synchro- nized way without spending too much money or time? The weight of it alt is an important factor too. The OP is looking for help; do you have experience with a similar project? Are you confident with electronics, motors and mechanics? If so, why don't you surf over to www.elektor-labs, com/node/3450 and post a contribution. Photo: BMW Welt Five Cool Projects Outdoor Solar Wireless Wi-Fi/ 3G Webcam www.elektor-labs.com/node/3538 All-You-Can-Eat Bluetooth www, elektor-labs.com/node/3032 PWM Controller For flashlight www.elektor-labs.com/node/3537 RS-485 Sniffer www.elektor-labs.com/node/3S22 Mouse-Friendly Mousetrap www, el ektor-labs.com/node/3433 50 November 2013 wwvv.elektor-magazi ne.com elektor labs GMR-based Current Probe Measuring current with a multimeter is easy; doing the same with an oscilloscope is a bit more involved. You 0 can of course buy special current probes, but they tend to be expensive, which is why OP RolandSautner decided to design his own. Unexceptional current probes use Hall-effect sensors and AC transformers to measure DC and AC currents, but the OP wanted to use another method: giant magnetoresistance, or GMR, Why? Because he had an unused KMZ51 magnetic field sensor lying around and felt that it was a shame not to use it* The OP got pretty far, but finally encountered some problems mainly related to mechanics. Can you help the OP to transform his design into a prac- tical probe? If you can, please go over to www.elektoHabs.com/nQde/3423 and post your ideas and suggestions* Photo: Agilent Frequency Inverter This is about a project that has my personal interest, but I've never gotten round to building one* As always, I am not alone as I saw OP PappaBaer ' s post. A frequency inverter or, to be more correct, a variable-frequency drive (VFD), is a device that can control the rotation speed of an AC motor— usually three-phase, Elektor has published such a device in 1994/1995. The project was very successful right up to being recalled again in Retronics in 2006, but it never saw a successor. The components used in the original design are now hard to find or even obsolete, and a redesign would be welcome. This time with open-source software, of course. Have you ever been involved in such a project? If so, please join us at www.elektor-labs.com/node/3484. Photo: Wikipedia www.elektor-labs.com Trailer Reversing Lamp One of the great things about Elektor. Labs is the wild diversity of the projects posted. There are lots of things to discover thanks to the different interests of the authors. Some time ago PLEG54 posted a project to develop an adapter for old vehicles allowing them to pull modern trailers sporting a reversing lamp or back-up light, ECE regulation R48 imposes this, ECE- R48? I did some research and discovered The World Forum for Harmonization of Vehicle Regulations. This is a working party of the Inland Transport Division of the United Nations Economic Commission for Europe (UNECE), assigned with creating a uniform system of regulations for vehicle design to facilitate international trade* Regulation R48 concerns the installation of lighting and light-signaling devices* This means that the UN decides which lights and reflectors you need to have on your car and trailer, and where. Anyway, this is all very instructive, but the really interesting part is that the OP is stuck and can use some help. You can find him or her at www*elektor-labs. com/node/3360. Photo: Wikipedia Note: OP stands for Original Poster the person who started an online project or discussion, OPs who want to have a chance of appearing in Elektor Maga?ine must (regularly) check the email address they use to access Efektor.Labs, This is our only means of contact. www.elektor-magazine.com November 2013 51 Labs Power your circuit with better software By Clemens Valens (Elektor.Labs) Often a lot of time and energy is spent on designing an elegant, well-thought-out and robust circuit. Today, the brains of many of those circuits is a microcontroller that needs software to function. Is it unreasonable then to expect a well-designed, properly written program to make such a quality circuit work? Apparently it is. Let's talk software quality. It is a well-known fact: bugs kill people and soft- ware bugs are no exception. Every year people die because of failing software. Some fatal airplane, helicopter and car crashes can be attributed to software problems; malfunctioning medical device firmware make victims on a regular basis; build- ings go up in smoke due to bugs, and some peo- ple get hacked to death. Bad software can even sink boats. Believe me, I have seen it happen. A bug-free piece of software doing a meaningful job does not exist. According to Wikipedia, NASA's Software Assurance Technology Centre has man- aged to produce software with less than 0.1 bugs per 1000 lines of code, which is considered to be extremely good. Commercial organizations do not have the time and money to achieve such a level of quality. Apparently Microsoft tries to be at 0.5 bugs per 1000 lines when it releases a new product, so realizing that Windows XP was compiled from 45 million lines of code, you know that it contained more than 22,500 bugs when it was released. It is estimated that programs written in industry for internal use have error rates from 5 to 50 bugs per 1000 lines. Software defects— a more official term for 'bugs'— can have many origins, from badly understood, complex problems to downright sloppy program- ming. Contrary to popular belief, making good software is not easy as it demands extreme pre- cision and care. For every line of code that must be written, at least three things are required: 1. a good understanding of the problem and its solution that the line of code is sup- posed to implement; 2. the capability of expressing this solution correctly in the programming language at hand; 3. not making any typing errors while enter- ing the code. The first point is often the hardest part, espe- cially for large projects. This is why skilful system architects and good specifications are essential to the success of a project. Item 2 is afso a difficult one as it involves the choice of the programming language— not every language is suitable in every situation— and expressing togic reasoning in a non-natural lan- guage without making mistakes. The third point seems moot, but is actually pretty hard to get right. It is very easy to miss a brace or a bracket, swap two symbols or mistype a character. It is only at this point that the pro- gramming tools start helping the developer and only by pointing out syntax errors and maybe compatibility issues and other conflicts between data objects. To reduce the risk of creating future defects due to our line of code, we can add to the list: 4. make sure the code ts written in a dear and understandable way; 5. add comments (and keep them up-to-date) to explain the reasoning behind the line of code; 6. adhere to a coding standard. Item 4 refers to the use of comprehensible names for functions and variables* Although it may require more typing, a variable name like 52 November 2013 www.elektor-magazi ne.com Windows XP was compiled from 45 million lines of code on release it contained more than 22,500 bugs "acceleration" is much more explicit than "acc" or just "a". Item 5 is ignored by many programmers. Not because they are not aware of the comment fea- ture of the programming language they use, but because they are too lazy to use it. The last point is a very important one. Many amateur programmers are not remotely aware of coding standards, while some professional pro- grammers are, but don't care. get.sample () is called and the value it returns is assigned to the variable sample* Now the Boolean if statement will check if the condition between its parentheses is true or false. In C/C++, false equals 0 and true equals not false. Therefore, if sample is non-zero, the condition is considered to be true and the addition will be executed* But maybe the programmer intended this: if (sample"get_sample£) ) sample += 2; But what Is a coding standard? Most software producing companies have house rules or conventions on how their developers should write code. On the internet you can find coding standards for many open source projects like GNU CU or Linux, However, most of the ti me these rules are limited to the formatting of the source code, and their goal is to create uniform source code which can be maintained more eas- tly. Since they concern mostly the appearance of the code, it is better to speak of a coding or programming style, A real coding standard is not a set of rules to make your program look pretty; it is a set of rules to reduce programming errors. It may also be used to achieve compliance with a regula- tory standard. Because today C and C++ are the prevailing programming languages, most coding standards address C/C++, The advantage of con- forming to a standard is that you can use static analysis tools to check the semantics of your code instead of only the syntax, which helps you to identify possible issues a compiler cannot fnd. So, what kind of rules can you expect from a coding standard? Here are a few examples: Ban explicit language features that can hide coding errors In C and C+ + , it is legal to do use the assign- ment operator ' = ' in Boolean expressions. For example, the following expression is legal: if (5ample=get_sample () ) sample += 2; This line of code will add 2 to sample if sample is not equal to 0. Why? Well, first the function The difference, an additional ' = ' character, is subtle. In C/C+ + , the sequence " = = " means "is equal to". So, the value of 2 will be added to sample only if the value of sample is equal to the return value of the function get_sample(). This is dearly not the same behavior as before. Is this a programming mistake or was it intended? Impossible to know. Some compilers can flag this issue, but only if the warning is activated. This is why a coding standard bans this kind of language features* Year 2000, Y2K or Millennium bug (1999) Due to the practice of abbreviating a four-digit year to two digits, many programs risked to calculate wrong dates after 1999. Huge efforts were made to prevent the bug from biting, Worldwide costs are estimated at a whopping 425 billion dollars, but in the end nothing serious happened. Something similar may happen on the 19 th of January 2038 when the UNIX seconds counter will overflow, Only use initialized pointer expressions This is a classic pitfall and the cause of in numer- ous bugs. When a pointer to a data object is not initialized— he, a 'wild' pointer— it can point to anything. Using such a pointer will result in unde- fined behavior of the program. Again, some com- pilers can flag this issue, but only if the warning is activated* Forbidding the use of uninitialized pointers is the only solution* Because pointers www.elektor-magazine.com November 2013 53 1 Labs Ariane 5 Flight 501 (1996) A complete loss of guidance and attitude information 30 seconds after lift-off due to specification and design errors in the software of the inertia I reference system caused the satellite launcher to disin- tegrate. The origin of the crash was a 64-bit floating point value that did not fit in a 16-bit signed integer, resulting in an overflow. The unexpectedly high value was calculated by an algorithm designed for the Ariane 4. Financial loss was esti- at some 400 million dollars. are dangerous, some other programming lan- guages restrict their use. Pointers are closely related to buffer overflows, number 3 in the 2011 CWE/SANS Top 25 of most dangerous software errors (that deals mostly with code security issues) int* p_some_poi rcter ; p_5ome_pointer = address_of_data_obj ect ; p_some_pointer [34] = 3; Although in the above code fragment the pointer Is initialized before being used, one question A8658t-6& SX837 iny Pentium™ ■PROCESSOR Intel Pentium Floating- point Divide (1993) A design error in Intel's brand-new Pentium micro- processor causes small errors when floating-point numbers that occur within a specific range are divided! Although the bug affects few users, it becomes a public relations nightmare and ultimately costs Intel some 650 mil- lion dollars, remains: is the index of 34 valid? If not, it is a buffer overflow error. Strong data typing In C/C++, variables of one type can be assigned to variables of another type as long as the new data type has the same or better precision. For example, assigning an integer variable to a float- ing-point variable will not produce a warning. Going the other way may generate a warning. This means that for instance a character rep- resented by an 8-bit value can be added to a 32-bit floating-point value; the compiler takes care of the conversion. To prevent adding pears and apples, a coding standard will forbid the pro- grammer to mix data types unless an explicit type cast— changing a data type into another— Is provided, like so: float a = 3*14; int b = (i irt) a ; Eliminate unused or unreachable code Normally ail code lines of a program have a function. However, it can happen that, due to a programming error, one or more parts of the program become unreachable because the exe- cution path to those parts is cut off. Take this Arduino sketch: void setup (void) { int a = - 1 ; unsigned inf b - l; if ( a < b ) a +- 2 ; Seri al , begi n ( 115200) ; Seri al , pri ntln (a) ; 1 void loop(void) { } What value will the serial monitor print for the variable a? “1! Why? Because, in C/C+ + , If in a comparison one of the values Is of type unsigned, the other value will be silently 'promoted' to unsigned too, But a 16-bit integer—as In Ardu- ino— holding a value of -1 (i.e, Oxffff in two's complement notation, the way negative values are represented by most processors) is bitwise identical to an unsigned integer holding 65,535 54 Movember 2013 www.elektor-magazi ne.tom (Oxffff), Since 65,535 is larger than 1, the condh tion will always evaluate to false, and the addition is never executed— it is unreachable. Requiring that the programmer removes unreachable code will either force him/her to rethink the algorithm or to simplify the program. Remember, less code means fewer bugs. This example can be made compliant to the cod- ing standard either by removing the if-statement, or by applying the strong data typing rule to variable b, i.e, adding a typecast to temporarily make it a signed integer: if (a< (int) b) a += 2; Place limits on complexity Long functions tend to be complex, and that makes them difficult to comprehend and test. For this reason a coding standard may forbid that a function or method contain more than, say, 200 lines of code. Coding standard verification tools can use other metrics to measure complexity. An example is cyclomatic or conditional complexity that mea- sures the number of independent paths through a function. The more paths there are, the higher the function's complexity. This kind of complexity is difficult to estimate for a human being— let a tool do it for you. Style Although I said earlier that the purpose of a cod- ing standard is not to make your code look pretty, code may include styling rules to make source code easier to read, Easy-to-read source code makes identifying potential defects easier too. Examples of such rules are: • Source lines will be kept to a length of 120 characters or less; • Each expression-statement will be on a sep- arate line; • Tabs should be avoided; • All indentations will be at least two spaces and appear consistent within the same source file; • The statements forming the body of an if, else if, else, while, do-while or for state- ment shall always be enclosed in braces, even if the braces form an empty block; • Braces ("{}") which enclose a block will be placed in the same column, on separate lines directly before and after the block. Many programmers offend against these rules; some programming editors do too by auto- matically inserting tabs. BTW, why avoid tabs? Because they mess up source code formatting when two or more persons do not use the same tab distance. Habits C/C++ compilers come with a large collection of so-called standard libraries. Many program- mers rely on the availability of these libraries, and use them out of habit. Unfortunately, several functions included in these libraries may exhibit Mot counting in-house standards, today the most widespread coding standards are (in order of popularity): MISRA C (and C+ + ) — created by the Motor Industry Software Reliability Association to provide assistance to the automotive industry in the application and creation within vehicle systems of safe and reliable software, A small fee must be paid to obtain the standard, www.misra.org.uk/ CERT C++ (and C) — this initiative from the Software Engineering Institute of the Carnegie Mellon University strives to eliminate insecure coding practices possibly leading to vulnerabilities that may be exploited by malicious entities, www.cert.org/ (note the use of the http secure protocol https. CERT is secure all the way.) HICPP — High Integrity C++, made freely available by PRQA, provides guiding principles for maintenance, portability, readability and safety by placing restrictions on the ISO C++ language standard in order to limit the flexibility it allows. www,codingstandard,com JSF AV++ — the Joint Strike Fighter Air Vehicle C++ Coding Standard by Lockheed Martin, available for free, is intended to help programmers develop code that does not contain defects that could lead to catastrophic failures resulting in significant harm to individuals and/or equipment. (Mot to be confused with the significant harm to individuals and/or equipment caused by military software that is working perfectly fine.) www. jsf . mi I/d o wnioads/docum ents/J SF_AV_C + +_Codi ng_Sta nd ards_ Rev_Cdoc A long list of static analysis tools for many programming languages can be found here: http : //e n .Wikipedia . o rg/ wi ki/ List_of_tools_for_static_code_a n al y sis www.elektor-magazine.com November 2013 55 Labs Patriot Missile Bug (1991) During the first Gulf War, a US Patriot missile system in Saudi Arabia failed to intercept an incoming Iraqi SCUD missile, leaving 28 soldiers dead and injuring around 100 other people The cause was a rounding error in the time calculations done by the software making it ignore some of the incoming targets. * The functions atof , atci and atol from the library shall not be used; * The functions abort, exit, getenv and sys- tem from the library shall not be used; * The time handling functions of library ctime. h> shall not be used. Note the interdiction of the input/output library . Yes, you are supposed to roll your own print f function. In the end it is up to you The example rules listed above— all taken from real coding standards— may seem severe, but they are not written In stone, For many rules coding standards allow exceptions. Other rules are debatable, and it is up to you to decide if software bugs kill people platform -specific, unspecified, undefined, imple- mentation-defined, or otherwise poorly defined behavior. Here are a few rules that prohibit the use of some popular functions and libraries: • The error indicator err no shall not be used; ■ The library and the setlocale function shall not be used; ■ The signal handling facilities of < signal . h > shall not be used; • The input/output library shall not be used; you want to respect them or not. On the Inter- net you can find rather philosophical discussions about certain rules showing that some are even open for interpretation. Even a coding standard is subject to bugs, (130271-1) [1] GIMU Coding Standard: http://www.gnu.org/ p rep/sta nd ards/stan da rds.html [2] Top 25 of most dangerous software errors: http : //ewe, m itre .org/top2 5/ Deadly Radiation Therapy (1985-1987, 2000) Due to buggy software the Therac-25 medical radiation therapy device could miscalculate the radiation doses it should administer. Some patients received up to 100 times the intended dose, which killed at least three of them. A similar bug surfaced in Panama City in 2000, where therapy planning software delivered different doses depending on the order in which data was entered. This bug killed at least five patients. Mr* Li L m flhfti * * then CL ***** bfideHU's. **- ® mo ACM r 56 November 2013 www.elektor-magazi ne.com NOVEMBER 20-21, 2013 I SANTA CLARA, CA Software TELCO Congress Break Free of Hardware Attention Carriers: Plan Your Move to an NFV World • Lower your costs using commoditized hardware • Decrease time to market for new services • Run production, test and reference facilities on the same infrastructure • Leverage pure software companies to pursue new business models • Allocate resources in near real-time • Securely share hardware resources utilizing multi-tenancy • Improve power management by switching off servers during non-peak hours n 4 * * O * i * Learn More at Software Telco Congress. Register with Code ELEKTOR and Save 15% www.softwaretelco.com # software tel co a so ftw a rete I co Labs By Thijs Beckers The Elektor FPGA Development Board published (Elektor Editorial) in the December 2012 issue [1] uses a micro SD card to store the configuration data needed by the FPGA at startup- The card can also be used to store data^ either by the FPGA, the microcon- troller/ or a PC when connected via USB. When working on an application for the board, designer Raymond Vermeulen suddenly ran into troubles using the SD card. After programming the FPGA with freshly written firmware, the whole FPGA board wasn't detected by Windows any- more. Several attempts were made to fix this, like unplugging and reconnecting the USB cable, checking for program errors, et cetera, but to no avail. It seemed like the SD card had suddenly gone faulty. Testing the card in a reader however proved it to be functioning correctly, so the error had to be somewhere else. But where? Every possible design flaw was checked and double checked, every solder joint tested, but everything turned out to be flawless. Retracing his steps, Raymond programmed the FPGA one last time and then It dawned on him: when pro- gramming the FPGA the software development environment requires a fair amount of parame- ters to be set. In the configuration options (see screenshot) unused I/O pins may be configured. In fact, they should. Exactly then Raymond admit- ted to having neglected just what he had been telling all users of the Elektor FPGA Development Board to do: set the unused I/O pins to float. Since the data pins of the SD card are directly connected to both the microcontroller and the FPGA on the Elektor FPGA Development Board, it is mandatory these pins are left floating by the FPGA, when not in use. The development suite defaults unused I/O to pufl down , which in most cases is fine. But in this application it is not, and this setting has to be actively changed to floatl ^ P i ot Pi opeE ties - C o nftgli i at io n 0 ptki ns &**gory General Options Conftgurfltion- Options Options R.eadbatk Options Switch Mane Property htome Mis -g Corfigfcete; CoriT^graEiCMi ftsfce tefatf (1) 3 -g PlogPifK Configuration Pri Program Float V -qOonePtr. Configuration Pin Done Pufl Up - -g TikPii: JTAGPiu TCK Ruil up v JTAG PTi toi M\Jp — hi V -grdoPin: JTAG Pin TOO MUp -q TmsPini JTAG Pin TMS Pull Up V -g UnusedPin: Unused 100 Pns Float v gUserlO; UserlD Cod* (0 Digit H«todtK»nal) Osrrfrrrpr -g DCRiShutdown; fteset DCM if SHUTDOWN & AGHIGH performed Q ; 1 Property dspiay £vef: Stands v g Display Switch names Default After Raymond corrected this setting and repro- grammed the FPGA, the FPGA Dev Board came to life again and Raymond's application worked right off the bat. A clear case of practice what you preach , Raymond! Relieved he found the culprit he turned to me as I just entered the Labs and asked if anyone had an interesting story for this month's .LABS pages... (130036) Internet Link [ 1 ] www .elektor.com/ 1 20099 OK Cancel Apply nap “ l 1 58 Movember 2013 www.elektor-magazine.tom | IQQ Add USB to your next project, w O D it's easier than you might think! DLP-USB1232H: USB 2.0 U ART/FIFO HIGH-SPEED 480Mb/s • Multipurpose: 7 interfaces • Royalty-free, robust USB drivers # No in-depth knowledge of USB required * Standard 18-pin DIP interface; 0.6x1 ,26-inch footprint DLP-IOB-G DLP-IOR4 &-Channel Data Acquisition 4-Channe! Relay Cable DLP-THIb Only $29.95/ 8 I/Os: Digital I/O Analog In Temperature USB Port Powered Single-Byte Commands Temp/Humkiity Cable DLP-RFID 1 HF RFID ReadesfWriter DIP-FPGA USB-to-Xilinx FPGA Module Design www.dlpdesign.com Better Design More Powerful Prototype to Production Amateur to Professional llttp://WH • Free Shipping! The latest on electronics and information technology Videos, hints, tips, otters and more Exclusive bi-weekly! project for GREEN and GOLD members Elektor behind the scenes In your email Inbox each Friday >» J Qektor A. A r™ Register today at www.elektor.com/ news Preferred Suppliers Tel. 1-978-281-7708 Fax 1-978-281-7706 Email Elekt0rUSA@5mmarketing.us Ethernet PLCs for OEMs EkrilMr Ethernet MODBUS TCP/IP Dtgr.al and Analog I/Os PWM/ PI D /Stepper Control *, TRIANGLE ’ RESEARCH INTERNATIONAL Tel : i 877 TRI-PLCS web : www.lr i'pkxcitTi/c*kJi(rri Labs By Aurelien Moulin (Elektor Labs Trainee) \ \ / T o O o \ 0 >AT ri PCB P >t o riOtOty p Clas your pm The Elektor PCB Prototyper [1] is a professional PCB routing machine designed for routing own PCBs with isolation tracks down to 100 width, and drilling holes as smatl as 0,2 mm (,008") in diameter Here at Elektor Labs— in the cellar to be accurate— we use our own PCB Prototyper machine when a PCB is needed in a hurry for build- ing a prototype, or when we want to experiment with PCB shapes. Inspired by our very own TAPIR [2] we looked into the PCB Prototyper's potential for producing custom-shape PCBs, After some fiddling we were able to persuade the machine to produce the shapes we had in mind. To our great satisfaction we even mastered fabricating our own 'multilayer' PCB (see photo). Eager to share our positive experience with you, our esteemed reader and member, allow me to guide you in pictures through the steps we took to master our PCB Prototypes I used Cadsoft Eagle to design an example printed circuit board, and the associated software PCB Module to control the PCB Prototypes If, like me, you are keen to "learn to fly with the Eagle", get the book! [3] (130128) Internet Links [ 1 ] www.elektor.com/PCBprototyper [2] www.elektor.com/tapir [3] www, elektor.com/eagle In Eagle, select the wire tool to draw lines or the arc tool to produce round shapes. Make sure you select layer 20 Dimension and set the width to 0. Mow sketch up your design. 20 Dimension » Width: 0 The green area is not part of the PCB, and has to be cut out. Bright red areas will be cut out from: the inside of the PCB. Export your design using the CAM Processor Select GERBER RS274X and select the Dimension Verify that the lines form dosed polygons, so that each shape delimits an inside and an outside area* layer only* Click on File to save the output (name it 'dimension') and click Process Job. Repeat this for the top layer (select Top , Pads, and Vias; don't forget to rename your file before processing the job). To create the drill file, instead of GERBER^RS274X, select EXCELLON and repeat the process. This concludes the Eagle part. 60 Movember 2013 www.elektormiagazi ne*tom Mow select the Inside tool and apply it to the two shapes to be cut out from the PCB. Note that the 'E' is not properly filled. This calls for some manual fine-tuning. Cancel the last trace ( ctrl+z ), Launch the PCB Module software and open a new project. Click Import Layer, select your top layer and import it into the top layer. Import a second layer and select your dimension file. Import this file into Board Outline/Cut - oofs. Also import the drill file if you need it. Now let's define the inlines and outlines (terms used in PCB Module ). Click the Modify tab and select the Outside tool. You can try to correct this in Eagle (using a wireframe for the form of the character), but this means you have to redo all your CAM processing. Instead we came up with this quick & dirty fix: Draw a polygon (the tool hides behind the Create tab) that roughly follows the center of the character lines and set it to inline using the Inside tool. Put your pointer over the global shape. The color will change from yellow to white, indicating which polygon you're going to set as an outline. Clicking the outline should yield this. Now we need to add some Break-out tabs. Use the Break-out tabs tool from the Create tab and click on a straight part of the outline. The software automatically centers the breakout. The default size is 2 mm (.08") which is fine, but you can adjust this to your liking. A proper end result should look like shown here. Your design is now ready for the usual processing stages (contour; tool list; machining). Happy routing l www.elektor-magazine.com November 2013 61 For complete circuitcellar.c 5j Visit weeklv challenge SPONSORED BY SYSTEMS Each week, you’ll find a new snippet of that contains one error. >>> sample code only If you can find the error, you could be a winner! Follow Circuit Cellar on Facebook and Twitter for information about each week’s challenge, prizes, and winners announcements. ©circuitcellar ©editor cc circuitcellar Take out a GOLD Membership now! Hun' ■Ss- :,S53 * 1 tTa ektor Your GOLD Membership contains: • 8 Regular editions of Elektor magazine in print and digital • 2 Jumbo editions of Elektor magazine in print and digital (January/February and July/August double issues) • Elektor annual DVD-ROM • A minimum of 10% DISCOUNT on all products in Elektor.STORE • Direct access to Elektor.LABS • Direct access to Elektor.MAGAZINE; our online archive for members • Elektor.POST sent to your email account (inch 25 extra projects per year) • An Elektor Binder to store these 25 extra projects • Exclusive GOLD Membership card 1 ■* Mrtl - S . *,-,1 , . Take out your Membership now at www.elektor.com/membersN ) •Industry UX>0 PJk a Cut r ent o 7 km/h wtt Ovn 13SG _ Sensor Oc*pCiv'i CS3 *W fvn ■ ■ 0 lh FTfitvy ?G*C 1JX >n tOlfhPj d>« ZOX T9'C TO G p - — t 14 C 14'C 2SX ■3* ^ s, at o* Do. Vf OW V» 7V Q. ~ ■ {* div dCVvwn 0i* P ® WeatherPro with Sensor Support from Sensirion The new version of WeatherPro for Android 3*0 now also supports sensors integrated in the cell phone, such as the humidity and temperature sensor from Sensirion. The sensor data is displayed In the daily forecast. This enables users to compare the data from their current location with the forecast values, making them better prepared for any weather, David Kaiser, the man in charge of product management for WeatherPro at the MeteoGroup weather service, is pleased to be working with Sensirion: "Many devices, such as the Samsung Galaxy S4, have an integrated sensor from Sensirion, We wanted to make the data generated by the sensors available to our customers in those places where they usually go for their daily weather information. There's not always an official weather station right where an app user happens to be. The sensor data thereby provides interesting comparison values." Andrea Wuest, Market Manager Mobile at Sensirion, believes that measuring the humidity and temperature of the immediate environment gives rise to many new opportunities, "Everyone now has their own individual weather station with them, which, thanks to WeatherPro, is also linked to the latest weather forecasts." The use of such a sensor is only possible thanks to innovative technology in both the hardware and software. The hardware is the smallest humidity and temperature sensor currently available. It was specially designed for mobile end-devices by the Swiss high-tech company Sensirion and optimized to fulfill the industry's unique requirements. The company not only provides the sensor, but also the corresponding software. Without it, the heat generated by the smartphone itself would make any measurement of the ambient temperature impossible, Sensirion is currently the only company to offer an all-in-one solution for ambient sensing of humidity and temperature for smartphones. www.weattierpro.eu www.s mart, sensirion, com (130202-1) MIO Console 5.6 Metric Halo announces the immediate availability of MIO Console v,5.6, a free software upgrade for all users of the Mobile I/O family of audio interfaces, including the award-winning 2882, ULN-2, LIO-8 and UlN-8. Versions, 6 includes the following new features: I/O inserts for accessing external hardware from within the MIO Mixer, ConsoleSync hardware/software synchronization technology, AAX ConsoleConnect plug-in for compatibility with Pro Tools 11, saving of system boot states and support for EuCon 3,0. In addition to these new features, v. 5. 6 continues to improve stability and compatibility with current and future versions of Mac OS X. ConsoleSync is a unique enhancement to the Mobile I/O family that benefits both new and experienced users, ConsoleSync allows MIO Console to read the complete state of any attached hardware seamlessly, automatically and without any disruption of running audio. ConsoleSync auto loads the mixer configuration, complex signal processing chains. Monitor Controller settings, analog I/O configuration and even window layout from the hardware. With ConsoleSync, new users will experience a dramatically reduced learning curve for accessing the power of MIO Console. Experienced users will value the ability to have MIO Console re-connect to the hardware with exact recall of the current hardware state and no disruption of audio. For live sound and monitoring applications this allows the user to disconnect and re-connect the computer or quit and launch MIO Console without being concerned about introducing dropouts to ongoing primary and backup recordings or to the monitoring paths for talent I/O inserts streamline the use of external analog and digital processors within the MIO mixer. This new feature also allows inserting processors that are hosted on the computer directly within the signal flow of the MIO low- latency hardware mixer. This enables the use of host- based reverbs and delays with greatly simplified routing. This free upgrade continues the Metric Halo tradition of adding value to the Mobile I/O platform as well as enhancing the product for new users. A 30 -day money- back guarantee backs Metric Halo's hardware products so you can try them out in your studio with no risk. www.mhlabs.eom (13Q306-VII) 64 | November 2013 | www.elektor-magazi ne.com news & new products Library of Apps for Jupiter Turn-Key DSP Symetrix announces the addition of seventeen new apps for its family of Jupiter app-based turn-key DSPs, The three different hardware units in the series— Jupiter 4 , Jupiter 8, and Jupiter 12— differ only in their input/output counts and are user-controllable from Symetrix ARC wall panel remotes, third-party systems, and Symetrix ARC-WEB browser-based software for smartphones. The addition brings the total number of available Jupiter apps close to one hundred and expands the already impressive range of situations for which the Symetrix Jupiter provides reliable processing at an extremely competitive price point. Six core apps form the heart of the addition and are elaborated according to the input/ output counts of the three Jupiter hardware devices. "BGM Zone Mixer 1" provides background music routing to multiple zones with two levels of priority. "Dual Matrix Mixer 1" provides flexible mixing and routing and allows integrators to assign any input to a mix, assign those mixes to submixes, and route submixes to outputs. "Gain-Sharing Automixer 3" provides a gain-sharing automixer with feedback processing on the outputs together with matrixed outputs. Similarly, "Gating Automixer 3" provides a gating automixer with feedback processing on the outputs together with matrixed outputs, "Priority Zone Mixer 2" provides a multi-zone priority mixer with paging and SPL computing. Finally, "Sound Reinforcement 12" provides heavy input processing and full-range outputs with feedback processing. RECEIVE top quality boards in just days ' DOWNLOAD our free CAD software DESIGN your two or four layer PC board SEND us your design with just a click L eX}3resspcb.conn a The growing library of Jupiter apps are optimized for specific applications and venues including houses of worship, auditoriums, retail and hospitality establishments, sports facilities, and transportation terminals. The time needed to learn the software is zip. With Jupiter turn-key DSP sound contractors end up doing what they do best, which is to dial in really great sound. www* symetrix. com (130202-III) www.elektonmagazine.com | November 2013 | 65 •Industry Quad-Core CPU in Fanless Chassis Logic Supply has released the LGX AU970 Intel® Core™ Fanless Computer. Designed for demanding industrial applications like high-end automation, data collection and surveillance, this tough, wide- tempera tore system takes ruggedized, high- performance computing to a whole new level The AU970 offers high- performance computing for even the most graphics- intensive applications. It supports up to 16 GB dual- channel 1333 DDR3 memory, and comes equipped with a dual- or quad-core third-generation (Ivy Bridge mobile) Intel Core i3/i5/i7 CPU and QM77 chipset. Third-generation Intel Core processors efficiently deliver top-oHhe-line graphics performance while taking up very little space. Logic Supply is among the first to offer this technology in a fanless chassis* A comprehensive array of I/O allows for a wide range of connectivity options, including two eSATA and CFast ports for external storage, a SIM card slot for 3G connectivity in remote deployments, and an 8-bit Digital I/O port The AU97Q has 3 LAN ports (one with Intel iAMT for remote support), 10 USB ports, 4 COM ports and 2 DVI ports for dual independent display. The system has a secure terminal block connector for wide input 9-32 V DC power with remote power-switch capability. The system's heavy-duty heatsink and chassis provide fan less cooling, with a wide operating temperature of -20C to 55 °C The fanless design ensures silent operation, as well as reliability in highly dust- and dirt- prone environments. It also comes equipped with a wall-mounting kit for easy installation. The AU970 is available exclusively from Logic Supply. Also available is the LGX AU972 Expandable Computer, which, in addition to the above, offers dual PCI express expansion slots for a variety of additional I/O— from network port additions to COM ports and specialized hard drive hot-swap bays. www. log i csti p pi y.com (1 303 0 6- VII I) New Temperature Range for KPSI 342 Measurement Specialties has improved the operating temperature range for the KPSI Model 342 submersible level transducer. The 342 transducer can now withstand temperatures up to 85°C for use In hostile fluids providing a 4-2GmA analog output with digital transducer performance. The Model 342 is a small bore (3/4 rH body diameter) submersible hydrostatic I level transducer that combines Measurement Specialties' well known sensor competencies with the latest in Application Specific Integrated Circuit (ASIC) technology. The addition of the ASIC has given the Model 342 digital performance in an analog product over the entire operating range. The Total Error Band specification (±0.25% FS) over the compensated temperature range (-20 to 85°C) eliminates the user having to combine multiple performance specifications to realize the total accuracy of the transducer. While numerically larger, it is a more accurate specification because it defines linearity of the sensors' performance as a total rather than using the traditional definition, which takes the difference between the largest positive and negative linearity values. The Model 342 is available In vented, sealed, and absolute formats to 3GQpsi (700' H 2 0 WC level) full scale output www,meas-spec,com (130202-11) True RMS Self-Powered AC Voltmeter Fits 30.5 mm / 1.20 Inch Round Panel Cutouts Mu rate's Type DMR20-1-AG/ "nanometer" self-powered four-digit bright LED voltmeter can measure the true RMS value of its input from 85 to 264 VAC to within 0.1 V resolution* Designed to be completely self-contained, the low cost two-wire voltmeter requires no additional components or connections apart from the AC voltage it is measuring. It is capable of accurately measuring quasi -sine AC source such as modified, modified 2-step and modified 3-step sine wave in addition to conventional sine, triangle and square wave inputs. The voltmeter fits an industry standard "oil tight" 30 and 30,5 mm / 1.2 inch round panel cutout. The 7.6 mm 66 | Movember 2013 | www.elektor-magazine.eom / 0.3 inch four-digit LED display is housed in a rugged round polycarbonate case that provides protection against dust, moisture, vibration and shock. It is supplied with an EPDM rubber gasket and plastic hex nut that aid protection to IP67 / NEMA6 specification for water ingress. The DMR2G-1-ACV is ideal for measuring the AC line voltage of a wide range of applications such as primary line power, power distribution units and backup power generation sources. The voltmeter consumes a maximum of 30 mA when used at 250 VAC / 60 Hz. Round knockout punch tooling can be ordered with the DMR2Q, Free sample / evaluation units for qualified OEMs are available from stock. www.murata-ps.com (13Q2Q2-1V) PC Oscilloscopes with Deep Buffer Memory and USB 3.0 Superspeed Interface With up to 500 MHz bandwidth on four channels, and an industry-leading 2 G samples of buffer memory, the new PicoScope 6000 Series has both the performance and the advanced analysis capability to speed debug of today's complex electronic designs. The PicoScope 6000 Series employs hardware acceleration and a USB 3.0 interface to acquire and display many megasamples of data per screen update without slowing down. Engineers can observe large portions of their design's electrical behavior at one time, and in great detail, which helps to reduce debug cycles and enables electronic design projects to be completed on schedule. As Alan Tong, Managing Director of Pico Technology, explained, "The PicoScope 6000 Series is the highest-performance USB oscilloscope, with deeper buffer memory as standard than any other oscilloscope, and is capable of detailed circuit analysis. We have provided a suite of advanced debugging tools, included as standard with the scopes, so that engineers who are developing complex electronic systems will find all the functions they need." All models include an integrated function generator or arbitrary waveform generator (AWG), advanced triggering, automatic measurements with statistics, an EFT spectrum analysis mode, comprehensive waveform maths, mask limit testing, and serial decoding for popular industry standards such as PC, 5PI, UART, CAN, LIN and FlexRay. The PicoScope 6000 Series scopes are compact and portable devices that fit easily in a briefcase, and include a five- year warranty as standard. Prices start at €2414 / $3292 / £1995 for the 250 MHz model with function generator, through to €5439 / $7417 / £4495 for the 500 MHz model with arbitrary waveform generator and 2 G samples of buffer memory. A set of four high-quality matched probes is supplied with every scope. www.picotech.com (130202-V) flj prices 6-IN-1 SCOPE * 2-ch 2MSa/s 200KHz il-oit scope - 2-ch spectrum analyzer -2MSa/s 8-bit AWG - Function generator - Networ k a na ly ze r V - PWM/Digitai I/O CSM-IOI $99.95 30MHz SCOPE 2-cn 250MS/S I sample rate 30MHz scope with 8" color TFT- LCD, AUtOScaie ^ ar>a waveform matnmatic functions, FREE carry case Included! SDS5032E $299 60MHz SCOPE SOM HZ 2-cn scope with SdOMSa/s rate & huge lOMSa memory ! 8* color TFT-LCD & FREE carry case! SDS60G2 $3H9 100MHz SCOPE High-end lODMHz 2-ch % IGSa/s Denchscope with IMSa memory ana USB port ■ FREE scope carry case. Super low price! DS1102E $399 100MHz SCOPE 100 MHZ 2-ch scope with 165/ s sample rate ana 8* color TFT Leo. Huge amounts of memory * FREE scope carry case. SDS7102 $H29 o fj caA 100MHz MSO 2-cn loowsa's scope * 8-ch ioglc analyzer, USB 2.0 and 4M sampes storage per channel with advanced triggering & math functions. CS328A $1359 20MHz HANDHELD Fast & accurate handheld 20MHz 1-ch oscilloscope. - 100 M/S sample rate - 3.5 in. color TFT-LCD - 6 nour battery life FREE rugged, impact -resistant caset HDS1021M $269.93 9 "a it, WWyV.SAEUS.COM £ A com 0 -'Tj 0 Bfli aiaetronie* www.elektor-magazine.com | November 2013 | 67 Tech The Future Forze VI: A Hydrogen-Powered Racecar Turrvii^ It fry 3>bwt burkert BAUARD Chroma * ByTessel Renzenbrink (Elektor TTF Editor) The Forze VI, one of the first hydrogen-powered racecars, was unveiled on September 9 at the disused Valkenburg airfield near Katwijk (Netherlands). All components of the car were built by a team of 70 students at the Delft Uni- versity of Technology, The Forze VI and The Team The symbolic value of the location was a good match for the objective of the Forze team, In scarcely less than a century, aviation technol- ogy has radically changed our world and now allows us to travel to the other side of the globe in less than 24 hours. With their hydrogen-pow- ered racecar, the students hope to contribute to another technology-driven revolution, this time in the realm of clean energy. The Forze VI weighs just under 2,000 lbs. (880 kilograms), achieves a top speed of 138 mph (220 km/h), and accelerates from 0 to 60 mph (100 km/h) in 4 seconds. The heart of the racecar Is the fuel cell system, where hydro- gen reacts with oxygen to produce electricity and water. The generated electrical power drives two electric motors, each with a rated power of 190 kW (260 HP), The car can race for 30 min- utes at top speed on the fuel in its two tanks, which together hold three kilograms of hydrogen at a pressure of 350 bar. Sustainability can be coo! In Hanger 2, Edgar van Os— the founder of the Forze team— explained to the audience what moti- vates the students to devote so much time (some- times up to 80 hours per week) to the project* “We want to show that sustainable energy can also be cool Sustainability is always presented in a negative sense: switch off the light, turn down the heating, and so on. Our approach of combining sustainability with racing was radical and pioneering. That is why we also gave a lot of attention to the appearance of the car. It is not a nerdy engineering-student vehicle, since that doesn't interest the general public." Van Os set up the Forze H2 team in 2007 entirely on his own initiative, without any help from spon- sors or professors. The goal was to build a go-cart that could participate in the Formula Zero com- petition in 2008* This first series of races for vehicles powered by hydrogen fuel cells was ini- tiated to foster zero-emission technology "from the source to the wheel". The Forze I vehicle competed against entries from five other uni- versity teams and came out on top. Since then the Forze platform has undergone a number of evolutionary developments, with each 6 8 Mo vem ber 2013 www. el e kto r- m a ga z i n e . to m Hydrogen-Powered Racing team building on the knowledge of its predecessors. Development of a hydro- gen fuel celf designed and built by the team, to replace the ready-made fuel cells used previously, started in 2010. This was installed for the first time in the Forze IV, which also marked the change from a go-kart platform to a small racecsr. Now the team has delivered the first full-size race car in the form of the Forze VI. Hydrogen After the introductory remarks by Van Os, Dr. Bernard Dam, a professor of chem- istry at Technical University Delft, gave a short talk on the benefits of hydrogen fuel systems. "Global warming is a sci- entific fact. It is therefore necessary to reduce C0 2 emissions by 80 to 90 percent by 2050, relative to the level in 1990. Mobility plays a major role in this. Reduc- mg emissions in the industrial sector is difficult, which is why the answer must be found in the transport sector and the urban environment— office buildings, houses, shops and so on," Right now there is a lot of interest in the development of electric vehicles equipped with batteries. If the electricity is gen- erated from renewable energy sources, this results in zero-emission vehicles. A side benefit is that this pool of vehicles can act as a distributed storage system. Wind energy and solar energy deliver a fluctuating yield of electricity, which makes it necessary to create facilities for storing energy. However, according to the professor "it is by no means certain that affordable batteries that allow vehicles to travel a thousand kilometers will become available in the future/' The popularity of electric cars still suffers from "range anxiety": the fear of getting stuck alongside the road somewhere with an empty battery, A hybrid hydrogen-powered car can pro- vide a remedy by using the fuel cell as a range extender. Dr. Dam and his colleagues are working on a method to produce tow -cost, sus- tainable hydrogen in the future. Pres- ently most hydrogen is obtained from natural gas. This process still generates C0 2 emissions, and natural gas is not a renewable resource. The method being investigated by Dr. Dam is called water splitting. This involves first immersing a photo-electrochemical cell in water and then exposing it to sunlight. The resulting chemical reaction splits the water into its constituent elements: hydrogen and oxy- gen. The researchers recently achieved a milestone by attaining an efficiency of 4.9%. This means that nearly 5% of the solar energy is converted into hydrogen. They expect to be able to achieve their efficiency target of 10% within three years, which would make the technol- ogy commercially viable. Water When hydrogen reacts with oxygen in the fuel cell, the only by-product is pure water. The Forze VI produces a liter of water every minute. The water can be stored in the car or discharged onto the road surface. Neither solution is ideal: the first option makes the car heavier, while the second option leads to jeers from other motorists. For this reason, the Delft team came up with an inno- vative alternative. They use the water to cool the brake system, which causes the water to evaporate. The kinetic energy from braking is also converted into electrical energy and fed back into the system. The Forze VI from the student team is a full-fledged racecar that will compete with cars powered by gasoline. It will be entered in 25 events during the 2013- 2014 race season. One of the highlights is an attempt to break the lap speed record for electric vehicles at the Zand- voort track. The record is currently held by the Tesla Roadster, At the famous Ger- man Niirburgnng race circuit, the Forze team hopes to enter the record books as the builders of the fastest hydrogen fuel cell powered car that ever rode on the Nordschleife (North Loop). ( 130203 - 1 ) www.elektor-magazine.comj November 2013 69 •Magazine By Dr. Gotz Corinth (Germany) Figure 1* Block diagram (partial) of the Audio-Frequency Spectrometer Note the photo camera, 'P'. US Patent Office file# 2,159,790, May 1939; Z Tech. Phys. 16 (1935), p, 294 (Freystedt) Freystedt's Audio-Frequency Spectrometer (1935) Restoration of a landmark in electro-acoustic measurement technology As opposed to time consuming mechanical, optical and graphic/mathematical methods, electronic engineering in the mid-1930s brought new possibilities to sound analysis. Filter circuits allow individual frequencies and frequency bands to be stressed or suppressed. The 'search frequency' method allows highest resolution to be achieved at constant absolute bandwidth, but at the expense of analysis speed. A pass-band filter fitted ahead of a multichannel looping oscillograph (in German: Schleifenoszil- lograph) enabled parallel recording of multiple frequency ranges. Attempts at real-time visual assessment remained problematic though. In 1934, Erich Freystedt at Siemens & Halske's Centra] Laboratory improved the process by means of 27 parallel third-octave filters at the input, covering the 30-18,000 Hz human hear- ing range ("analysis with constant relative band- Vi > Fl Fn x-: - • a _r y- r ' ■ // // ’’■i L \ IQ 3 ' J V‘ .- 1 JP ■ " k j £f 7 V \v g 7 jt v;:;> V v V i i D « ■ i » 1C mi n * \ i 30 400 Fr 1 * 1 1 400 IK 21 eqtieney (F K 4K. fz) 1 1 « tin IK % OK The high tension transformer had to be rewound twice until it kept working in the circuit. A spe- cialist firm in Holland overhauled the cathode ray tube, giving it a completely new electron gun and screen. The AF section of the instrument was thoroughly checked, and unsafe components got replaced. The readjustment of many filters was necessary as well as labor intensive (Figure 4), Here the capacitors showed up increased capacitance— probably due to shrinkage of insulating paper over a period of nearly 70 years— ruling out the simple knack of connecting a few small extra capacitances in parallel. Two capacitor decade banks and a computer-controlled sweep genera- tor ("wobbulator") allowed the target pass-band curves to be set up again (Figure 5), The "Siru- tor" cuprite (Cu 2 0; a minor ore of copper) rectifi- ers between the filter and the storage capacitors all proved completely intact. To be able to operate the "new CRT in a vintage envelope" the setting options for the tube's aux- Figure 5. Frequency response of the filter after recalibration, (original recording) 72 | November 2013 ] www.elektor-magazi ne.com .