•magazine May 2013 www.elektor-magazine.com Pull your code from the Embedded Firmware Library From BASIC to Python | Embedded Firmware Library | 500 ppm LCR Meter Part 3 I FPGA Programming | Linux Board Extension ota Triangular Wave Gen i BaroStick • PCB Soldering Pitfalls Ceramic C's Off the Mark • 1963 Tube PSD • The Invisible User Interface US$9.00 - Canada $10.00 25274 24965 7 7 Take out a GOLD Membership now! ^ 7-uP M ,Tri 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 (incl. 25 extra projects per year) • An Elektor Binder to store these 25 extra projects • Exclusive GOLD Membership card ALSO AVAILABLE: The all-paperless GREEN Membership, which delivers all products and services, including Elektor.MAGAZINE, online only. *UMrwt***fm Ikfe. - t. membership Take out your Membership now at www.eleklor.com/membersK www.sensorsexpo.com Sensing Technologies Driving Tomorrow’s Solutions Pre-Conference Symposia: June 4, 2013 Conference & Expo: June 5-6, 2013 Donald E. Stephens Convention Center • Rosemont, IL Innovative Applications. Expert Instructors. Authoritative Content. Tomorrow’s Solutions. Register today to attend one of the world's largest and most important gatherings of engineers and scientists involved in the development and deployment of sensor systems. lpec\a\ What’s Happening in 2013: “I come to Sensors Expo to see new things, learn about new technologies, and get my sensing questions answered.” — Nick Plessas, N.D.P. Visionary Keynotes: Connecting with the Emerging Nervous System of Ubiquitous Sensing Dr. Joseph A. Paradiso Associate Professor of Media Arts and Sciences, Responsive Environments Group MIT Media Laboratory Sensors in Space: The Robotic Exploration of Mars and its Environment Dr. Raymond Arvidson James, S. McDonnell Distinguished University Professor, Washington University Participating Scientist, NASA's Mars Curiosity Rover Mission sS as. Goofed > Tracks: Q Big Data & Analytics pj Cutting-Edge Sensing Applications & Innovations Energy Harvesting Gas Sensing ^ MEMS Novel Approaches to ^ Measurement & Detection Remote Monitoring Sensors (a) Work Wireless Sensing Solutions > Full day Pre-Conference Symposia > Technology Pavilions on the Expo Floor • Big Data & Cloud • Energy Harvesting • Intelligent Systems • MEMS • Wireless > Co-location with Intelligent Systems Source > Best of Sensors Expo 2013 Awards Ceremony > Networking Breakfasts > Welcome Reception > Sensors Magazine Live Theater > And more! Register at www.sensorsexpo.com or call 800-496-9877 OFFICIAL PUBLICATION: INDUSTRY SPONSORS: NEW CO-LOCATION: sensors CIRCUIT CELLAR IntalliQBTt SystBms Sara a *Discount is off currently published rates. Cannot be combined with other offers or applied to previous registrations. Contents r 1-1 .«V Ma-n-iM withflvt ^Lir.HC'fin^uu tflc'#, rn^Mii; iPi Lr »!Lf 3 If EMM* err b *j ' ‘ i- ! i ^-*«*3'* !•*_ >'OC'Cl Community 8 Elektor World • Whip it Up • Return of the Tapir e-smog meter • Into the Nerd Cave • Elektor Labs opens on Lamington Road, Mumbai • Spark your Design • Tech the Future 70 The Invisible User interface There is a strong trend toward us- ability in industrial design and in human-computer interaction. That primarily revolves around efficien- cy, effectiveness, safety and ease of use. In short, the user interface. Projects 10 Embedded Firmware Library The modular EFL (Embedded Firm- ware Library) lets you write ap- plications and modules that can be easily transferred from one board to another. Meaning you are no longer locked in to a single micro- controller manufacturer but rather just write for embedded Linux in general. 18 500 ppm LCR Meter (3) This month we get practical by cov- ering the LCR Meter's circuit board assembly, parts lists, casing, and calibration in just 8 pages. 26 From BASIC to Python Python is a high-level language particularly associated with small computer systems such as the popular Raspberry Pi. The language is marked by clarity and concise- ness. Gone are the brackets and semicolons which gave headaches in Pascal, C and Java, not to men- tion BASIC. 32 Taming the Beast (4) Once you start using virtually the entire FPGA chip for an application written in a hardware description language ( H DL), examining the circuit inside the chip is difficult at best, so simulation is in order 40 Elektor Linux Board Extension ( 2 ) In this second and closing install- ment we look at the hardware and software interaction between the buttons and the LC display on the board — all with a view to learning how to program a well thought out menu. 43 OTA-based Triangular Wave Generator Although many applications of 4 | May 2013 | www.elektor-magazine.com May 2013 Volume 4 - No. 53 OTAs have been described, the basic circuit of a non-sinusoidal oscillator exploiting an OTA's spe- cific advantages is a rare find. This design brief describes a combined triangular and rectangular wave oscillator with two OTA circuits. 46 BaroStick This USB barometric pressure sen- sor uses a Bosch sensor to mea- sure the air pressure and tempera- ture, after which this data can be displayed graphically and stored using Windows software. 50 Program Like the Professio- nals State diagrams see increasing use in software development. This article looks at how you can use them to make your programs more robust and free of bugs • Industry 58 Raspberry Pi: one year later, one million sold An interview with Peter Lomas, a hardware designer behind the Raspberry Pi computer. 62 News & New Products • Labs 54 Sorry about my English Even if your English is fraught with gramatikall miztakez, do submit your project at elektor-labs.com. 56 PCB production pitfalls Some issues to consider when wave soldering SMD components. 57 Ceramic C's off the mark Here's an intriguing phenomenon concerning the value of 150-pF ca- pacitors before and after soldering • Magazine 74 Retronics: Wandel & Golter- mann NE-171 MultiVoltage Tube PSU (ca. 1963) This power supply for science labs and radio/TV repair outfits has just about everything you can desire or dream of when working with tubes. Series Editor: Jan Buiting. 78 Hexadoku Elektor's monthly puzzle with an electronics touch. 79 Gerard's Columns: Credibility A column or two from our colum- nist Gerard Fonte. 82 Next Month in Elektor A sneak preview of articles on the Elektor publication schedule. www.elektor-magazine.com | May 2013 | 5 Community No. 53, May 2013 ISSN 1947-3753 Elektor Magazine is published 10 times a year including double issues in January/February and July/ August at $80 per year, Canada add $15 per year; by Elektor International Media LLC 111 Founders Plaza, Suite 300 East Hartford, CT 06108. Phone: 860.289.0800 Fax: 860.461.0450 www.elektor.com Elektor is also published in French, Spanish, German and Dutch. Together with franchised editions the magazine is on circulation in more than 50 countries. Memberships: Elektor USA P.O. Box 462228 Escondido, CA 92046. Phone: 800-269-6301 E-mail: elektor@pcspublink.com Internet: www.elektor.com Head Office: Elektor International Media b.v. PO Box 11 NL-6114-ZG Susteren The Netherlands Telephone: (+31) 46 4389444, Fax: (+31) 46 4370161 Advertising: Strategic Media Marketing Peter Wostrel 2 Main Street Gloucester MA 01930. Phone: 978-281-7708, Fax: 978-281-7706 E-mail: peter@smmarketing.us Advertising rates and terms available on request. Copyright Notice The circuits described in this magazine are for domestic use only. All drawings, photographs, printed circuit board layouts, programmed integrated circuits, disks, CD-ROMs, DVDs, software carriers and article texts published in our books and magazines (other than third- party advertisements) are copyright Elektor International Media b.v. and may not be reproduced or transmitted in any form or by any means, including photocopying, scanning and recording, in whole or in part without prior written permission from the Publisher. Such written permission must also be obtained before any part of this publication is stored in a retrieval system of any nature. Patent protection may exist in respect of circuits, devices, components etc. described in this magazine. The Publisher does not accept responsibility for failing to identify such patent(s) or other protection. The submission of designs or articles implies permission to the Publisher to alter the text and design, and to use the contents in other Elektor International Media publications and activities. The Publisher cannot guarantee to return any material submitted. © Elektor International Media b.v. 2013 Printed in the USA Call for Papers One of the most frequent questions I get, usually by email but occasionally by telephone or letter (!) too, is "can I contribute to your wonderful publication and if so, what are the requirements and the specific subjects you are interested in?" As of this year, the answer is: "If you have a project to present, please do it at www.elektor-labs.com". To this I usually add a few encouraging words and some help to get started on the Jabs website. Now if this sounds like a straightforward approach to you, you should know that some of our competitors simply do not accept articles from anyone out- side their circle of 'approved authors', which is another way of saying that Elektor is an independent publication with paying members and paid authors. The idea behind using our Jabs website as a project evaluation tool is that the community of Elektor readers and members can actively participate in enhanc- ing the design, hopefully passing from Proposal, through In Progress, right up to Finished — meaning it gets elektorized in all respects. Non-project contributions from companies, researchers and industry workers are also welcomed; these are given the usual evaluation by the team of editors, engineers and consultants. Now, for the solemn bit: about half the article proposals reaching us through all international channels do not make it to publication in the magazine for a variety of reasons. Like uninventive use of components; the use of obsolete components; rehashing manufacturer's datasheets or old Elektor articles (!); vague circuits nicked from websites, and poor electronic design. The rest is gladly considered for publication on the «labs website to begin with, no matter if the piece is poorly written (see page 54) or the prototype built on prototyping board — in general we are good humored with a keen eye for originality. Even if it takes a while for us to get back to you due to the work load here at Elektor HQ, give us a try and eventually see your name (and circuit!) in print — it's by no means difficult, we're here to help. Enjoy reading this edition of Elektor Jan Buiting, Managing Editor The Team Managing Editor: Publisher: Membership Manager: International Editorial Staff: Laboratory Staff: Graphic Design & Prepress: Online Manager: Managing Director: Jan Buiting Hugo Van haecke Shannon Barraclough Harry Baggen, Eduardo Corral, Wisse Hettinga, Denis Meyer, Jens Nickel Thijs Beckers, Ton Giesberts, Luc Lemmens, Clemens Valens, Raymond Vermeulen, Jan Visser Giel Dols, Jeanine Opreij, Mart Schroijen Danielle Mertens Don Akkermans 6 May 2013 www.elektor-magazine.com Our network f§ i=^ USA Hugo Van haecke + 1 860-875-2199 h.vanhaecke@elektor.com United Kingdom Wisse Hettinga +31 46 4389428 w.hettinga@elektor.com Germany Ferdinand te Walvaart +49 241 88 909-17 f.tewalvaart@elektor.de France Denis Meyer +31 46 4389435 d.meyer@elektor.fr Netherlands Harry Baggen +31 46 4389429 h.baggen@elektor.nl Spain Eduardo Corral +34 91 101 93 95 e.corral@elektor.es Italy Maurizio del Corso +39 2.66504755 m.delcorso@inware.it Sweden Wisse Hettinga +31 46 4389428 w.hettinga@elektor.com Brazil Joao Martins +55 11 4195 0363 joao.martins@editorialbolina.com Portugal Joao Martins +351 21413-1600 joao.martins@editorialbolina.com India Sunil D. Malekar +91 9833168815 ts@elektor.in Russia Nataliya Melnikova +7 (965) 395 33 36 Elektor. Russia@gmail.com Turkey Zeynep Koksal +90 532 277 48 26 zkoksal@beti.com.tr South Africa Johan Dijk +31 6 1589 4245 j.dijk@elektor.com China Cees Baay +86 21 6445 2811 CeesBaay@gmail.com Connects you to Supporting Companies AP Circuits www. apcircuits. com 39 ElPololu Pololu a Badrenlisi WWW.polOIU.com Beta Layout www. pcb -pool, com 63 Saelig www.saelig.com 61 ctsvar Cleverscope www. cleverscope. com DLP Design www.dlpdesign.com 67 63 sensors Sensors Expo 2013 r.app-K. sonlcrnrca www. sensorsexpo. com 3 i+prn ExpressPCB www. expresspcb. com EzPCB www.ezpcb.com . . . . 65 39 iitimmum rnimms Front Panel Express www.frontpanelexpress.com ... .67 humanqata. HuMANDATA www. hdl. co.jp/EL/ 64 Not a supporting company yet? Contact Peter Wostrel (peter@smmarketing.us, Phone 978-281-7708, Fax 978-281-7706) to reserve your own space for the next edition of our members' magazine www.elektor-magazine.com May 2013 7 Community Elektor World Compiled by Wisse Hettinga 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 the events and activities — for fun and business. I I Whip it uP If you follow our adventures you know the Elektor employees are not working from one place — the majority of us are located in Holland and we have colleagues in Spain, The United States, Italy, India, France — it's a long list. Clemens Valens is working from France and combines his Elektor Labs managing duties with... writing! In the quiet hours he has been working on a book with an 'edge'; an Arduino edge. In the book he explains how you can use the Arduino platform to 'tease your neighborhood', meanwhile learning to get a command of this interesting hardware platform. Admittedly, when we saw the book he surprised us with the cover — we see a microcontroller (so far, so good), but then there is a female figure using a whip, presumably to get the controller controlled properly. So, this really looks like an edgy book and we decided to have it translated in German and English as well. But that whip!? Kinky. Return of the Tapir e-smog meter Last year we pushed a small project called the Tapir e-smog meter. It was a blast. The design was easy and remarkable with the circuit boards doubling as the housing. This year we have confirmation from Eurocircuits that they will participate in supplying another 1,000 pieces of that wonderful PCBs. This e-smog meter can help you discover the world of Electromagnetism by picking up stray signals and turn them into audio. With no more than an earpiece you can hear the hidden sounds your smartphone or tablet is producing. The Tapir e-smog meter boards and the DIY kit will be available again from the Elektor web shop from the end of May, 2013; follow www.elektor.com/tapir. 8 May 2013 www.elektor-magazine.com All Around the World ... * into the Nerd Cave They are all over the world — attics, cellars, garages, small rooms, stuffed with electronic equipment. They are the treasure troves of electronics where many of you spend hours working, thinking and discovering new applications. Forget the high-tech labs with mega money sponsoring — this is where the true spirit of electronic design dwells! Our sister magazine Circuit Cellar (what's in a name) started printing pictures of the 'nerd caves' where electronics enthusiasts toil. In the picture you see the setup of Vincent Himpe's workspace. Vincent is a veteran electronics designer and writer of Elektor's LabWorX series books. Elektor Labs opens on Lamington Road, Mumbai Every year we need around 200 project designs for our publications. Traditionally we have a team of technicians working close to the editors at Elektor's head office, but the growing number of projects demands more capacity. With the opening of a new Elektor Labs department on Lamington Road, Mumbai, right in the heart of India's biggest electronics market, we invest in capacity to complete our mission: test it first, then improve it, then publish. Lamington Road is packed with shops selling and stocking more electronics components than you can dream of. When our Mumbai designers need a component, they just pop 'round next door — what a great place to work! The Elektor Mumbai Labs team is pictured here. Left to right we have Krishna Chandran, Sunil Malekar, Clemens Valens, Nandini Singh, and Shreenivas G M Shree. 1 tC HHi igt®p3 r ^ com Spark your Design Elektor and RSComponents have entered into a partnership around the DesignSpark brand. First there is DesignSpark magazine. This is the rebranded version of the well-known title eTech and is published to the full RSComponents client database. The new magazine covers the latest developments on the new hardware platforms, and will also host a new series of Elektor projects. The other activity will focus on the launch of a special design-and- build section on the DesignSpark.com website. The project PCBs will be specifically designed using DesignSpark PCB, the free CAD software available at www.designspark.com. In Elektor magazine and on our website www.elektor-labs.com we will carry special pages and activities supporting this new initiative. ( 130051 ) www.elektor-magazine.com May 2013 9 •Projects Embedded Firmware Library Build microcontroller projects faster! By Jens Nickel The modular EFL (Embedded Firmware Library) is not just another library aimed at 'rapid application development'. It lets you write applications and modules in a hard- ware-independent fashion, so that they can easily be transferred from one board to another. This means you are no longer locked in to a single microcontroller man- ufacturer but rather just write for embedded Linux in general. Thanks to its wide range of interface functions covering A/D converters, PWM generators, displays, TCP/IP, SD cards and more, the library is ideal for beginners in (C) programming. Features of the Embedded Firmware Library • Portable in principle to any microcontroller for which an ANSI C compiler exists • 32 KB flash and 2 KB RAM recommended • Well-documented API • Currently supported microcontrollers: ATmega328/324/664 and ATxmega256A3 • Currently supported boards: ElektorBus experimental node, XMEGA web server board [9], Linux extension board [8]; Arduino Uno Rev. 3; further boards in preparation • Simple to port to new boards • Currently available higher-level libraries: LEDs and buttons, A/D converter and multiplexer, stepper motor, ElektorBus, display, WIZnet TCP/IP module, SD card (raw data) • LG PL open source license In 2012 we presented a C library for the Ele- ktorBus microcontroller nodes [1]. One of its distinctive features is the separation between the hardware-specific part and the code mod- ule responsible for implementing the protocols. This makes it easy to adapt the library for other types of microcontroller and other boards: only the hardware-specific part needs to be changed, while the rest remains the same. However, there is more to a typical bus application than just composing messages and sending and receiving them: there are LEDs and relays to be turned on and off, analog values to be read and motors to be controlled. Beyond that it would also be desirable if the microcontroller could easily communicate with other chips, such as a TCP/IP interface module or an SD card. 10 May 2013 www.elektor-magazine.com EFL Parallel programming In the course of programming the library the concept became better developed, and step by step it became more flexible and powerful, with capabilities well beyond what was required for the ElektorBus. I was fortunate to find in reader Michael Busser (a member of the ElektorBus Google group) a co-developer who contributed many clever code modules, functions and ideas. So we could work in parallel on the code in spare moments we uploaded it to the well-known proj- ect hosting site SourceForge [2] under the name 'Embedded Firmware Library (EFL)'. SourceForge is dedicated to open source projects, which fits well with the Elektor philosophy: we chose the LGPL license [3]. The most important feature of the SourceForge platform is its integrated SVN- compatible version control system [4] which can be used under Windows with (for example) Tor- toiseSVN [5]. A click of the mouse is all it takes to upload ('commit') one's changes or to down- load the newest version of the code ('update'). Over time we built up a considerable body of functions, and so we decided to use an auto- mated documentation system. By simply adding comments in a prescribed format to the source code, we can use the open source program Doxy- gen [6] to automatically generate well-organized documentation for all the functions. The docu- mentation is in HTML and so can be viewed in a browser (see Figure 1). Beautiful! The Doxygen EFL documentation can be downloaded from the project web page at [7]. Building blocks The Embedded Firmware Library is designed as a set of building blocks, with the various mod- ules in each layer being interchangeable with one another. There are three distinct layers: the microcontroller code resides in the bottom layer; above that is the 'board' layer and finally there is the 'extension' layer (see Figure 2). The lay- ers correspond to the structure of a real proj- ect design: different (pin-compatible) microcon- trollers can be used on the same board, or the same microcontroller can be used on different boards. A good example of this is the ATmega328, as used on a wide range of Elektor boards as well as on the Arduino Uno. If we define an expansion connector and its pin- out then we can easily combine different micro- controller boards and different expansion boards. An example of this is the Linux extension board | C:VUs*«n\ if mn\ odfVDor umr DflyvanVi htmf arouc u a r tfaoardJ ,0 • C X /' Embedded htrmvaie libtar... * o ti Embedded Firmware Library (EFL) Main Pag# Related Paget Modules Data Structures Files UART Board Functions Ooerd Layer Functions void UARTBiock setBaudrate (uint8 UARTBiocwndex uint3? Baud rale) Set Baudidtc of a UART -block on ttie board. Mote... void UARTBiock Send (umts UARTBlocklndex. uliH8 •DawBuffer ulntG DataLengm) send data via UARt-bkxk. More Detailed Description Function Documentation void UARTBiock Send ( ulnts UARTBlocklndex. uintS * DataBufTer. ulnts DataLengm ) Send data via UART-oiock Puts data in the transmit butter and starts intenupt-dnven sending, the functions returns to the caller Immediately Parameters UARTBlocklndex The Blocklndex of the UARTBiock on the Board DataBufTer The DataBufTer DataLength The length of the data in bytes. void UARTBtock SetBaudrate ( uintS UARTBlocklndex. uint32 Baudrate ) Set Baudrate of a UART mock on tne board Parameters UARTBlocklndex Tne Blocklndex or me UARTBiock on me Board described elsewhere in this issue [8]. This board can be used not only in conjunction with the Ele- ktor Linux board, but also with the XMEGA web server board [9] which we will describe in the June issue (see large picture). The EFL can also be used in a system comprising a motherboard carrying various peripherals into which a range of processor boards can be plugged. There are three different code modules, cor- responding to the microcontroller, the micro- controller board and the extension board. Each Figure 1. The 'Doxygen' tool helps produce clear function documentation. APPLICATION DISPLAY LED BUTTON ELEKTORBUS LIBRARIES UART UDP/TCP/IP EXTENSION BOARD CONTROLLER BOARD- LAYER ?EFL HARDWARE LAYER HARDWARE 120668-15 Figure 2. Thanks to a clearly separated hardware-dependent layer an EFL-base project can quickly be ported to a new platform. This is very useful when hardware changes prove necessary during prototyping. www.elektor-magazine.com May 2013 11 •Projects Figure 3. A greatly simplified block diagram of a typical microcontroller (ATmega328). Figure 4. The board code developer can treat the microcontroller as a 'black box': only its port pin connections need to be known. PCO PCI PC2 PC3 PC4 PC5 PB3 PB4 PB5 G P I 0 FLASH SRAM CPU TIMER /COUNTER TIMER /COUNTER TIMER /COUNTER ADC UART SPI i 2 c G P I 0 PDO PD1 PD2 PD3 PD4 PD5 PD6 PD7 120668 - 11 120668 - 12 module consists of a '.h' header file and a '.c' code file. It is therefore necessary to add the files ControllerEFL.fi/. c, BoardEFL.h/.c and ExtensionEFL.h/.c to your project. The file- names are the same for all the different types of microcontroller and board supported by the EFL. To avoid name conflicts the code download- able at [11] is organized into different subdirec- tories named after the various microcontrollers and boards. More on this can be found in the additional documentation, also available at [7]. The black box principle In the ideal case the three code modules could be written by independent developers: the devel- oper of the microcontroller code should not need to know to what board the microcontroller will be fitted, and the microcontroller board code developer should not need to be aware of what extension boards might be present. The same goes in the other direction, from the highest level of the library to the lowest: the developer of an application should not need to be concerned with the details of how the code works at the next level down. Likewise the micro- controller board code developer should just need the circuit diagram of the board and a description of the microcontroller's port pins and their func- tions, and should not need to worry about the innards of the microcontroller itself (Figure 3), treating it instead as a 'black box' (Figure 4). The designer of an extension board should simi- larly only be concerned with the pinout of the expansion connector via which it communicates with the microcontroller board; and not have to worry about which signals are connected to which pins on the microcontroller (Figure 5). Higher-level libraries Above the hardware layer there are modules that provide higher-level functions, which we call 'libraries'. Examples of this are the mod- ule included in the current code base to drive HD44780-compatible alphanumeric LCD panels, a driver for a WIZnet TCP/IP module, a simple stepper motor driver and a module for reading and writing raw data from and to an SD card. The black box principle extends to these modules too: if you wish to change or extend the LCD library, the display (or perhaps more precisely the display controller) can simply be treated as a block (see Figure 6). There is no need to know which pins on the display are connected to which pins on the microcontroller; and it makes no difference to the developer of the display library whether the display controller is connected in four-bit mode or over SPI, leaving him to concentrate on the HD44780 command and data sequences. Application code The developer of applications has easy access to all the blocks on the board, and only needs to know which blocks are available. Now it is pos- sible that there is a LED block available on both the microcontroller board and on the extension board, perhaps with two LEDs and four LEDs respectively (see Figure 6). The developer can write code which turns on the first LED in block 0 and the third LED in block 1 without having to worry about where they are physically located. Even if an LED, button, relay or other digital I/O 12 May 2013 www.elektor-magazine.com EFL (+0) 10/ADC (+1) 10/ADC (+2) 10/ADC (+3) 10/ADC (+4) 10/ADC (+5) 10/ADC O o o o o o 120668-13 Figure 5. The developer of the code for an extension board only has to know about the connections on the expansion connector and their possible uses. SENSOR #0 SENSOR #1 P P P P #1 RS485 120668 - 14 Figure 6. The application developer only needs a block diagram of the system, and does not need to know the details of how the boards themselves are wired. The two groups of LEDs are addressed via their block numbers, 0 and 1. device is connected via a port expander chip rather than directly to a pin on the microcontroller the same library functions can be used to inter- face to it. Buttons connected to analog inputs, as on the Linux extension board, can also be treated just like real 'digital' buttons (see large picture). A consistent set of functions We only have space here to describe the inter- nal operation of the library as a whole in general terms (see text box). Further information on the hardware layer is available for download at [7]: this documentation will be of use to anyone who needs to modify the hardware layer to support a different board. The underlying principle behind the library is that of a consistent set of functions (or API) exposed by each layer to the layer above it. The micro- controller API always provides the same set of functions (or at least, to the extent that these functions are supported by the microcontroller in question). These comprise firstly set-up functions to initialize the peripheral units integrated into the microcontroller, such as the A/D converter, SPI and UART interfaces, counter/timers and so on, and then functions to set the parameters associ- ated with these units (such as the baud rate of the UART) and finally functions to operate the unit: take readings from the A/D converter, send and receive bytes over the UART or SPI, and so on. For more details see the Table. At the board and extension module level there are low-level functions for talking to the various individual functional units such as the display and stepper motor driver. These functions are needed in order to encapsulate the various pos- www.elektor-magazine.com May 2013 13 •Projects Table: Microcontroller functions (Version of March 2013, omitting set-up and parameter-setting functions ; for updates see [11]) Function ATxmega256A3 ATmega328 Enable/disable interrupts X X Wait... (time delay) X X Set pin X X Read pin X X Read A/D conversion result X X Start A/D conversion X X Set DAC value X - Send UART data (interrupt driven) X X Receive in circular buffer X X SPI master (send/receive byte) X X I2C master Read/write bytes (combined) X X Start/stop timer X X Count pulses on a pin X * Timer-related: - increment X X - call function X X - toggle pin X X - toggle at variable speed X X - measure frequency X * PWM output X * Software PWM * * X: implemented *: planned -: not available sible combinations of interface wiring and proto- cols, such as LCDs driven using a four-bit parallel interface or over SPI. The higher-level librar- ies access these low-level functions to provide a consistent interface to application-level code. Example: display As an example we shall look at controlling an alphanumeric LCD. The application code will put up a simple greeting on the first line of the dis- play by calling the following functions in the dis- play library: Display_LibrarySetup( ) ; Display_WriteString(0, 0, “Welcome!"); The first zero is the index number of the display to be addressed (as conventional in C code, we always count from zero in the EFL). In order to carry out the write command the display library makes several calls to the function void Display_SendByte(uint8 DisplayBlocklndex, uint8 ByteToSend, uint8 DATABYTECOMMANDBYTE) at the board level to send the individual data or command bytes to the display controller. In the case of the XMEGA web server board the display is connected over an SPI bus. In this implementation the function uint8 SPIMaster T ransceiveByte(int8 Handle, uint8 Databyte) at the microcontroller level is used to send a byte to the display. The CS and RS inputs to the dis- play also need to be driven appropriately. Software download The software download available from the web site accompanying this article [7] includes an application example. It is a similar project to [1] : the ElektorBus experimental node [10] is con- nected to an extension board that carries two sen- sors and four extra LEDs (Figure 7). These are built onto half of an Elektor Universal Prototyping Board (UPBS, a.k.a. ELEX), and the download also includes a LochMaster file showing the layout. When the software is opened in Atmel Studio 6 the code files will appear in prescribed (virtual) subdirectories called 'Hardware', 'Common' and 'Libraries' (see Figure 8). You will also see the main code file (ExperimentalNodeEFL.c) that pro- vides the basic framework for an EFL-based appli- cation. It is also possible to see which functions need to be called when the program starts up. The function ApplicationSetup() first provides all the configuration data for the bus (we no longer need the special configuration files ElektorBusNode.h/.c). Then we have the setup functions for the various library modules: usually it is not necessary to change any of their param- eters. The call SwitchLED( 1, 0, ON); turns on the first LED on the extension board to confirm that the program has started up. Pressing the first button on the experimental node toggles the red test LED and the third LED on the extension board. Under control of the bus sched- uler the nodes send the readings from the two sensors to the PC. The second LED on the exten- sion board blinks in synchrony with this activity. The fourth LED is controllable from the PC. 14 May 2013 www.elektor-magazine.com EFL Figure 7. ElektorBus experimental node with extension board (two sensors and four LEDs). The board layer is easily adapted to another board, such as the forthcoming stepper motor interface board. The file ExtensionEFL.c also includes the setup code for a small relay board: which part of the code is actually compiled depends on a #define directive in ExtensionEFL.h. As mentioned above, the project download con- tains the extra documentation for the EFL and the Doxygen output as well as the complete code base, including additional libraries for displays and the WIZnet TCP/IP module, all in source code form. The future This article has only been a brief introduction to the EFL. We are planning a step-by-step article A deeper look inside EFL Port pins The functions associated with digital I/Os (for example to set the output level on a pin) are called with a parameter called 'Portpin', a two-byte unsigned integer ('uintl6'): void IOSetPinLevel ( uintl6 Portpin, uint8 PinLevel) The first byte of the Portpin parameter denotes the port (or group of I/O pins): in the case of an AVR microcontroller zero corresponds to port A, one to port B and so on. This lets the function work out which registers will be affected by the call. The second byte of the parameter specifies the pin within the port: on a typical eight-bit microcontroller this would be a value from zero to seven inclusive. The port pins can be labeled '0.0', '0.1', ..., '1.0', '1.1' and so on in the circuit diagram (see Figure 4). Features, units and handles The various peripheral functions offered by a microcontroller (such as A/D converters, UARTs, SPI interfaces and timer/counters) are called 'features' in the EFL. For each feature there can be several 'units': for example, in the ATxmega256A3 there are three SPI units each providing the SPI feature. Each unit is associated with particular pins on the microcontroller, as specified in the device's data sheet. The board code, however, cannot know anything about the internal numbering of the units or the registers that control the units. So, when a unit is set up the microcontroller-level function is passed the identity of one of the port pins that forms part of the interface. For example, in the case of an SPI unit, the set-up function is of the following form: int8 SPIMaster_Setup(uintl6 Portpin) The set-up function in the microcontroller code determines the unit number of the SPI interface to be used from the specified port pin. From this it can in turn determine which registers need to be initialized. For subsequent access to the port the unit number and port pin are stored in an array called 'Map': the function SPIMaster_Setup returns an index into this array (from zero upwards) as a handle. The board code can now use the handle as required to specify the SPI interface unit when sending and receiving data: uint8 SPIMaster_TransceiveByte(int8 Handle, uint8 Databyte) Other features work in just the same way www.elektor-magazine.com May 2013 15 •Projects (12) (13) (14) (15) (+ 0 ) (+ 1 ) (+ 2 ) (+3) (+4) (+5) (3) (4) (5) ( 6 ) (7) ( 8 ) (9) [4] [ 0 ] [ 2 ] 120668 - 16 Board pins and blocks The individual port pins of the microcontroller are connected to various hardware units on the board, such as LEDs, buttons or an RS-485 driver. The port pins corresponding to these 'blocks' are stored in an array by the board-level code when it is initialized. The indices to this array are called 'board pins'. For example, board pins (0) and (1) are assigned to the LED block in Figure 4; board pins (2) and (3) are assigned to the button block; and board pins (4) to (9) are assigned to the expansion connector. Board pin Port pin (0) 3.4 (1) 3.6 (2) 3.5 (3) 3.7 (4) 2.0 (5) 2.1 (6) 2.2 . . . (9) 2.5 The function Extension_Init() in the extension code module reserves board pins (12) to (15) for the extra LEDs on the extension board (see Figure 5). The corresponding port pins 2.2 to 2.5 are determined indirectly via the board pin entries (6) to (9) for the expansion connector: Blocklndex BlockType First Count [0] BLOCKTYPE_ LED 0 2 [1] BLOCKTYPE_ LED 12 4 [2] BLOCKTYPE_ BUTTON 2 2 ... If a LED library wants to control a particular LED in a particular block, it simply calls the function void SwitchDigitalOutput (uint8 Blocklndex, uint8 Position, uint8 ONOFF) at the board level. The function SwitchDigitalOutput ( ) determines the board pin from the parameter Blocklndex and the position of the LED within the block, and from that determines the actual port pin involved. The Block array also stores whether a high or a low logic level on the port pin is required to turn the connected LED on, as this can differ from board to board. Resources (12) 2.2 // = (6) (13) 2.3 // = (7) (14) 2.4 // = (8) (15) 2.5 // = (9) The board pin array now contains two blocks for LEDs: (0) to (1) and (12) to (15). These ranges (or more precisely the first board pin in the range and the number of pins in the range) are stored in an array called 'Block' for each block, accompanied by a constant indicating the type of block: The great flexibility of the EFL comes at a price: the library takes up not only flash storage for the code itself but also RAM (adjustable from a few hundred to many hundreds of bytes). Performance (speed of program execution) also suffers, in particular for programs that rely on toggling output pins quickly. For this reason we have implemented special functions to switch digital outputs under timer control, removing the need to set the pins high and low with repeated function calls. But in any case performance is good enough for tasks such as dimming several LEDs. 16 May 2013 www.elektor-magazine.com EFL <► ExptrirtKM»INodeEFl AtrrelStu F 4 e Edit View VAniilX Pt eject Bulk) Debuy Took Window Help 3*-al ^ A J - La v • I? ^ **► 3 « 1 *** 0 • i '■*1 ijl 3 Debug - J} bSendmg He* J : 2 J ^ T : t 3 . *!$ - j -J AIme // Application Variables uintH SensorvalueRaw; // This function is called before entering the im in loop // Use it for setup of your application (device -dependent) 3 void ApplicationSetup( ) { // Storing Config Data for the Bus uintH ( ltktoriiuy onf igwiT»[10] • {0, a, e, a, s, a, ia, 1 1 1 Ktnnnii->_vcM mu ill, a, 1 1 1 kiohihis_iiyhri wmoi Jj ConfigInit(); Config_write(®, ElektorBuiConfigDat*. IB); // Setup of t ibmriet LE06utton_Lib<-erySetup(ButtonEventCelibeck); UARTInterface_tibraryS«tup( ) ; bXektorBus_Librarysetup(ProeessPart, PreparePartstorscheduledhessage, UAH 1 Interf ace_send , a, UAHIInterfate_betHlngbuffer(0), 100 % * ' I I 0 ); 3 Solution I iprnmentelNndelH' (1 proji a a ExperimentalNodeEFL a M Dependencies a isl Output Files a 3 Common a j Hardware j|] BeardEFL.c jJ KoardEFl.h g] ControllerEFl.c ControllerfFl.h EieensionfFl e ExtensionEFL.h a IA Libraries EleVtor BusEFLx jj] FlettorBusEF l.h LEDButtcnEFL.c jg] KOtuttonEFL.h UARTlnterfaieEFL.s UARTlnteftaceEFLh c] iipenmentalNodetfl c ^ Sol. Properties * 9 X I MperimentalNodel 1 1 .c File Properties to* Compile Custom Compile File Name Full Path ExperlmenUlNodtE F L C ' U'.er'.gen'.n Djcurr Build Action O 0 Errors 0 Warnings ti, 0 Messages Description Jj Error L«t File Line Column Project Figure 8. Screenshot of an example project in Atmel Studio 6. The code files comprising the project are stored in specified (virtual) folders, which makes it easier to understand its structure. specifically aimed at beginners in C programming. We will also be using the EFL in future Elektor projects, starting with a stepper motor board for the ElektorBus and continuing a.s.a.p. with the XMEGA web server board. Readers will perhaps be interested not just in using the EFL, but also in extending it and adapt- ing it (see the additional documentation at [7]). The author welcomes any suggestions, in particu- lar in the area of the microcontroller API, please email j.nickel@elektor.de, subject: EFL. Exten- sions to support further microcontrollers, boards and peripheral blocks would also be welcomed. Regular updates will be published on the Elektor. Labs website [11]. ( 120668 ) Internet Links [1] www.elektor-magazine.com/120582 [2] http://sourceforge.net/projects/embeddedlib/ [3] www.gnu.org/licenses/lgpl.html [4] http://subversion.apache.org [5] http://tortoisesvn.net [6] www.doxygen.org [7] www. elektor-magazine. com/120668 [8] www. elektor-magazine. com/120596 [9] www.elektor-labs.com/xmegawebserver [10] www. elektor-magazine. com/1 10258 [11] www.elektor-labs.com/EFL RS485, TCP/IP and wireless: ElektorBus and dedicated protocols The hardware independence of the ElektorBus library has been improved by introducing a code module ElektorBusEFL.fi/. c which encapsulates the details of the protocol used. Now it is easy to send and receive messages not just over an RS-485 interface, but also over RS-232, a UART interface at TTL levels or even TCP/IP: we have already tested this with the forthcoming XMEGA web server board and a WIZnet WIZ820io TCP/IP module. Another interesting option would be to use an ISM band (418 MHz; 433 MHz) wireless module. Likewise it is possible to write a replacement protocol library, which in turn would be independent of the communication medium, board and microcontroller. As you can see, there is a huge range of possibilities for experimentation. www.elektor-magazine.com May 2013 17 •Projects 500 ppm LCR Meter (3) Part 3: PCBs, BOMs, assembly, calibration After the flood of theory, design considerations and software descriptions in the first two installments we are ready to tackle practical matters. So now here we are all ready to start building the 500 ppm LCR meter. Most of this article is taken up describing the two boards, but before we finally get down to the nuts and bolts, we need to look again at the circuit diagram. By Jean-Jacques Aubry (France) The correct value for C3 and C9 is 1 pF, not 4.7 pF; this helps reduce noise at very low fre- quencies, attributed to the operation of the MAX7404 itself and revealed when measuring high-capacitance capacitors (1,000 pF and over): on the oscilloscope, looking at the ADC input sig- nal, the mean value of low frequency fluctuates more and more as the capacitor value increases. Inconsistencies and accuracy We actually noticed a number of differences between the circuit published in the March 2013 edition and the final component list in this article. As so often, where there is a doubt, the compo- nent list is the one to believe, but as it hadn't yet been published, no-one was able to tell! In Figure 3 of the first installment [1], the value for crystal Y1 was missing: 24 MFIz. For U2, we need a normal MAX7404CSA (the extended temperature range of the MAX7404ESA is unnecessary here). For U10, we need an LM4040 (and not the LM4050 that I happened to have to hand, and which will also do). The amplifier used for U6 is an OPA365 and not an OPA354, which has too high an offset voltage. And lastly, for U19, it should be an FT232RL and not FT235RL (just a typo). 18 May 2013 www.elektor-magazine.com 500 ppm LCR Meter Specifications The 500 ppm LCR Meter is an automatic impedance measuring bridge. The two guiding principles in designing this unit were maximum measuring accuracy and ease of construction. It measures resistance, capacitance, and inductance for components with impedances from 1 mQ to 1,000 MQ. Measurements can be made at three frequencies: 100 or 120 Hz (50 or 60 Hz power line), 1 kHz, and 10 kHz. Two configurations are possible: • Basic unit, with no display or keypad Works only when connected via USB to a computer running the user program. This program, developed from the Qt libraries, has been tested under Windows XP, Windows 7, Linux ( Ubuntu 11.04), and MacOSX ( Snow Leopard, Lion, and Mountain Lion). • Basic unit + display & keypad extension. Also works stand-alone (without a PC) with an external 5 V supply via the USB cable (which can also be connected to a computer for the power). Finally, we observed that to make one of the adjustments easier, a 10 Q resistor must be fitted for R17, incorrectly shown on the circuit diagram as not fitted (NC). The other components marked NC should only be fitted if the calibration proce- dure requires it — we'll come back to this later. Before plugging in your soldering iron, we suggest you make these corrections carefully on your cir- cuit from the first article. A corrected XL version of this diagram will be put on line for download [3] along with the software and the other docu- ments, including the PCB designs. Construction The layouts for the two PCBs that make up the LCR meter are given in Figures 1-3. Remember that you only need the extension board for the standalone version of the device; other- wise the main board is all you need. If you have the right tools and good experience in soldering SMDs manually, you can solder the components onto the bare boards yourself. You'll be all the more satisfied with the result. However, even though there's no special difficulty, it is a job for a specialist which you should only undertake if you know what you're doing. Adhere scrupulously to the component list — not for the order of the components, of course, but for their values and tolerances. Apart from the four precision resistors, the rest are all standard 1% tolerance. R50 is indeed a 0 Q resistor that makes it possible to link the digital and analog grounds in a single, precise spot; a solder bridge will also do! The tolerances of the various capac- itors is stated in the component list. Make sure you adhere to the dielectric types specified, par- ticularly for the NP0 capacitors. Alongside the crystal, you'll notice a point marked XTAL CASE on the board. This must be connected to the crystal case using a short piece of wire, as the metal screening is only effective if it is grounded. Above all, don't take too long with the soldering iron, to avoid damaging the crystal. Attention: If you solder in the components your- self, the microcontroller will be blank. You'll need to load it with the boot program; to do this, you'll have to use the USB DEBUG ADAPTER from Sil- icon Laboratories [3]. If you go for the standalone version, do pay atten- tion as well to the full part number for compo- nents like the HE10 connector for the flatcable that is soldered directly into the display board (Figure 4). The height of a normal type would stop you mounting the module into the recom- mended case. The graphics display is soldered by a row of fine pins flanked by two normal-sized pins, but this isn't enough to keep it in place; to avoid its lifting accidentally, we secured it at the side opposite the pins with the help of a few spots of hot-melt glue. In order to avoid any misunderstandings about the choice of components, we are making available to you on our site [3] the BOM (bill of materials) which supplements the component list given here. The size of the components and their pin spacing is what will determine the order in which you fit them. Don't forget the components mounted beneath the main PCB. www.elektor-magazine.com May 2013 19 •Projects Those components marked NC will only be fitted (perhaps) later, for the calibration. However, if you are not happy about soldering SMDs or if you don't have the time, all you need do is order the ready-to-use modules from www. elektorPCBservice.com, our professional produc- tion service: you will receive the modules through the mail, and all you'll then have to do is fit them into a case before calibrating them. Like many electronic devices, an LCR meter is sensitive to electromagnetic radiation, in par- ticular from the power line @ 60 or 50 Hz. So you'll need to use a metal case, e.g. the Ham- mond 1455L1601, which is perfect for a 160 x 100 mm board plus the extension, if used. Dimen- sioned mechanical drawings are available from our website [3]. Preparations Drilling the holes for the BNC chassis sockets and LED D6 on one of the small sides pres- ents no problem. For the USB connector and switch SW1 on the opposite side, you'll need a square-section tool... or a good file and some elbow-grease; in fact, for a tidy result, you'll need at least two files, a flat and a rat-tail, and possibly a triangular-section one too. For grounding the main board to the case, you'll also need to drill a hole (3.2 mm 0) in the bottom of the aluminum case, in line with the hole in the PCB located next to J16; use a 12 mm (0.5") M3 machine screw with washer and nut in conjunc- tion with a 5.5 mm (0.2") spacer. COMPONENT LIST Main circuit Resistors (default: SMD 0805 1 %) R1,R16,R17,R28 = 10ft R2,R34 = 820kft R3,R5,R11,R13 = 8.2kft R4,R10,R47,R55 / R56,R71,R72,R78,R81 / R82,R94,R95 = lOkft R6, R58, R59 = 1.8kft R7,R100 = 5kft trimpot (Vishay-Sfernice TS53YJ502MR10) R8, R60, R62 = 16kft R9,R23,R25,R35 / R38,R39,R41,R52,R68 / R69,R70,R87,R88,R96 = 56ft R12,R14 = 5.6 kft R15,R97 = NC (not fitted) R18 = lOkft 0.05% lOppm (Panasonic ERA6ARW103V) R19 = 1ft R20 = lkft 0.05% 10 ppm (Panasonic ERA6ARW102V) R21 = 100ft 0.05% 5ppm (Vishay-Dale TNPU0805100RAZEN00) R22 = lOOkft 0.05% lOppm (Panasonic ERA6ARW104V) R24,R26,R27,R29,R33,R36,R37,R40,R44,R57,R64 = 100ft R30,R61,R76,R77,R80,R101 = 20kft R31 = 750 ft R32,R42,R49,R66,R93 = lOOkft R43,R84,R85,R86,R89 = 2.2ft R45,R73 = 39kft R46,R90,R91 = 680ft R48,R51,R74 = 4.7kft R50 = Oft R53,R65 = 470ft R54 = lkft R63,R98 = 1.6kft R67 = 62ft R75 = 5 kft trimpot (Bourns 3266W-1-502LF) R79 = 4.3kft R81 = 7.5kft R83 = 30kft R92 = 430ft R99 = 2 kft Capacitors (default: SMD 0805) C1,C2,C4,C10,C11 / C12,C20,C26,C27, C28,C29,C31,C33,C34,C35,C36, C37,C40,C41,C43,C44,C45,C46, C47,C48,C49,C50,C51,C53,C54, C61,C63,C65,C78,C80,C86,C87,C88 = lOOnF 10% X7R 25 V C3,C9,C62,C64,C90 = lpF 10% 25 V X7R C5,C13,C18 = 15nF 5% 50V NP0, SMD 1206 C6, C7, C14, C15, C16, C56 = 47nF 5% 50V NPO, SMD 1206 C8, C73, C89 = InF 5% 50V NP0 C17,C21,C23,C55,C60 = NC (not fitted) C19,C25 = 150pF 5% 50V NPO C22,C52,C58,C59 = 1.5nF 5% 50V NPO C24,C32,C69,C72,C74,C75,C81,C85 = 2.2pF 10% 16V X7R C30,C57 = 4.7nF 5% 50V NPO C38,C39,C83,C84 = 33pF 5% NPO C42,C70 = 33pF 6.3 V, tantalum case A (Vishay Sprague 293D336X96R3A2TE3) C66,C71, C82 = lOnF 10% 50V X7R C67,C77, C79 = 4.7pF 10% 10V X5R C68,C76 = 470pF 6.3 V tantalum case D (Kemet T495D477K006ATE100) Inductors LI = 20pH dual coupled (Bourns PM3602-20-RC) L2, L3 = ferrite bead, SMD 0805 (Murata BLM21PG221SN1D) Semiconductors (default: SMD) D1,D2,D3,D4,D5 = BAV199 (SOT23) D6 = LED, green, 3mm, leaded, horizontal mounting (Dialight 551-0207F) D7 = MBR0520 (SOD123) D8, D9 = LED, red, SMD 0805 (e.g. Kingbright KP-2012SURC) D10 = BAT54A (SOT23) U1 = OPA725AIDBV (SOT23-5) (TI) U2 = MAX7404CSA (SOIC-8) (Maxim) U3 = 74HCT4052D (SOIC-16) U4, U20 = TLC2274AID (SOIC-14 (TI) U5 = INA128U (SOIC-8) (TI) U6,U11,U14 = OPA365DBV (SOT23-5) (TI) U7 = PGA103U (SOIC-8) (TI) U8 = 74HCT4053D (SOIC-16) U9 = C8051F061-GQ (TQFP-64) (Silicon Laboratories) U10 = LM4040D25IDBZ (SOT23) (TI) U12 = DAC8811CDGK (MSOP-8) (TI) 20 May 2013 www.elektor-magazine.com 500 ppm LCR Meter To accommodate the display & keypad exten- sion, the extruded aluminum lid will have to be machined and marked up (silk-screened or engraved) with the functions of the buttons (Fig- ure 5). Then use four M3 screws (12 mm / 0.5", countersunk) with nuts and washers, and four 7 mm (0.3") spacers. Note: for fixing the extension, in the absence of spacers, you can use other nuts (and washers): 4 for fixing the 4 screws onto the lid, 4 for setting the 7-mm (0.3") spacing, and lastly 4 more to secure the extension board. Two final remarks about the jumpers: Normally, the firmware is updated by the main program on the computer. Straight afterwards, the circuit ought to work, but if for some reason the firm- ware didn't respond (e.g. in the event of a bug in the new firmware that's just been loaded), it will then be necessary to intervene at the boot- loader stage and tell it that we want to perform an unconditional update. Jumper J17, accessi- ble by removing the back panel, is used to give this information. The update procedure is described in the downloadable documentation [3]. To make sure the measuring probe is firmly con- nected to the measuring point pins J4, J5, J14, it's perhaps not a bad idea to bend them at an angle. All the other jumpers are described in the online documentation. o C3 • “ _ .. □□□□ • ” C 4 □ -on aj n □ ft □ • «£» • PL D 3 hD” 2 i ™ . LI C65 □ ^□ J r]D Rjn ^n □ cs = r U □ (= K) O Ml ft □ 69 □ □ C58 R 13 □ □ □ □ M |J} ! C 11 L J E0V - □ i j a i— ^ >0 c l-k U1 L J 5 io C 7 5 O 2l lD §0n=3oa □ R 1 o RB2 n| □ ‘ C90 □re □0 L 3 — HI 5 □ L 2 □ □ ZU -o -a • • • • □ □□nsr 0 0GND snobs dotLS *fj □ •'* c <3 • <-XTAL CASE 1 Ol n IO . • c n s I — I , n3 1 'J I — ' □ * 1 □= U> DO • -jy D | vl “ Lfl •a L. TJ c= -n cn m H 3) aj w Cj I— » C34 C 0 OSS' Figure 1. The LCR Meter's double-sided main board; component side (a). Don't forget the dozen or so components to be fitted at the underside of the board (b). The absence of silk screen print under the board is deliberate; it is not an oversight or an error. U13 = SN74LVC2G53DCT (SM-8) (TI) U15 = REG102GA-A (SOT223-5) (TI) U16 = LT1611CS5 (SOT23-5) (Linear Technologies) U17 = TPS72325DBV (SOT23-5) (TI) U18 = TLV70030DDC (SOT23-5) (TI) U19 = FT232RL (SSOP-28) (FTDI) Miscellaneous Y1 = 24MHz quartz crystal, fundamental resonance (e.g. Euroquartz 24.000MHz HC49/4H/30/50/40+85/18pF/ATF) SW1 = rocker switch (RS Components 4US1R1020M6RNS, code 734-6934) J1,J2,J3,J6,J7,J8,J17,J21,J22 = 2-pin pinheader, 0.1" pitch (2.54mm) J4,J5,J14 = 1-pin pinheader, bent (see text) J 10,J 11, J12,J13 = BNC socket, horizontal mounting, isolated (e.g. TE Connectivity 1-1337543-0) J15 = 10-pin pinheader HE10 (e.g. Multicomp MC9A12-1034) J16 = 14-pin pinheader HE10 (e.g. Multicomp MC9A12-1434) J17 = 2-pin pinheader, 0.1" (2.54 mm), bent (see text) J19 = USB connector, type B, horizontal (e.g. TE Connectivity 292304-1) K1 = pushbutton (Omron B3F-10xx series) PCB, bare, # 110758-1 alternatively, preassembled module # 110758-91 Case (Hammond 1455L1601 + machining + lettering) Screws, nuts, spacers, misc. hardware www.elektor-magazine.com May 2013 21 •Projects Figure 2. Photo of the prototype. Semi-automatic adjustment Contrary to what we might be afraid of in the light of the devices remarkable accuracy, the adjustment procedure does not require any spe- cial skill or equipment. Apart from a multimeter for checking the supply voltage, no measuring device is required! The software takes care of the semi-automatic calibration. The user has only to carry out a few adjustments themselves, for which they are guided step by step by the program that COMPONENT LIST Display / Keyboard module Resistors (SMD 0805 1%) R1,R2,R3,R4,R10,R11 = 4.7kQ R5,R6,R7,R9 = 56Q R8 = lkQ Capacitors (SMD 0805) C1,C2,C3,C4,C5,C6,C7,C8,C9,C10 = lpF 10% 25V X7R Semiconductors D1,D2,D3,D4 = BAT54A (SOT23) D5 = LED, green, 3mm, leaded, (e.g. Kingbright L-424GDT) Q1,Q2 = N-channel MOSFET (SOT23) (e.g. Fairchild FDV303N) ji AU2011 - Display & Keyboard Rev2 £ r i o- in n tN — I I Q1 <-> u u u u u _ ° □?, ntunu \n -o f* o I — I <*■ tr a. «r — cd >o , D D D „,□□□□ 1 28 K) [N OZ c tK * * * • • • • • K 5 * k 4 K 3 K 2 K1 r i r i L J L J D4 D3 D 2 D 1 □ Miscellaneous U1 = 64128M-FC-BW-3 graphic display (Displaytech) Jl = 14-way HE10 transition header, max. height 5.4mm (Harting 09 18 114 9622) K1,K2,K3,K4,K5 = pushbutton (Multicomp TS0B22) 14-way flatcable connector (e.g. Multicomp MC6FD014-30P1) 14-way flatcable, length (4 in. / 10cm) (3M 3365-14) Figure 3. The design for the double-sided display extension PCB (optional). PCB, bare, Elektor #110758-2 Alternatively, preassembled module, Elektor # 110758-92 22 May 2013 www.elektor-magazine.com 500 ppm LCR Meter performs all the measurements. The procedure is carefully described in a downloadable docu- ment [3], including fitting the NC components when necessary and the jumper configuration. All it takes is a little screwdriver, a little bit of judgment, and patience, as you must read the documentation right through and follow all the instructions to the letter, without skipping over any of them. In the first article, we saw the importance of the measuring cables and their effect on the accu- racy. So depending on what you want to use the LCR meter for, you may use Kelvin clips (Figure 7a) and/or a measuring box with four BNC con- nectors like the type TH26001A, "4 terminal test fixture" from TONGHUI (Figure 7b). They're easy enough to find via an Internet search (keywords LCR test clip, Kelvin clip, TH26001A). Once you have the board you've built, you can power it using a USB supply and check the sup- ply voltages. Since the microcontroller is blank, all its ports are at high impedance and it won't do anything! So there are no signals to measure. You can connect the board briefly to a PC and should see diodes D8 and D9 light: that's the FT232R (U19) communicating with the PC. Once the bootloader has been loaded into the microcon- troller by the FlashUtil program using the DEBUG ADAPTER USB module (Figure 8) connected to J15, the microcontroller is operational. This oper- ation and all those that follow are described in Figure 4a. Pay attention to the exact type of the HE10 connector for the display. Figure 4b. The extension seen from below. Figure 5. Dimensioned mechanical drawings. www.elektor-magazine.com May 2013 23 •Projects Figure 6. Suggestion for front panel, to be engraved or silk- screened. LCR meter S/P/A PARAM FREQ- FREQ + Qektor MENUS Q-D SORTING TRIM detail in the online documentation. The AU2011 program installed on the PC must then establish the software link by opening the port; is it working? Then you're on the right track! All that remains is to load the firmware from the PC via the AU2011 program's Tools/Program update menu. After that, when you re-boot the LCR meter, you should see the (semi-)automatic offset adjust- ments taking place normally as described in the Figure 7a. This set of Kelvin clips with four BNC leads can be found for around $10. 24 May 2013 www.elektor-magazine.com 500 ppm LCR Meter Figure 7b. This test fixture fitted directly to the LCR meter case can be found for around $50. Set-up manual [3]. If yes, there's a 95% chance that everything's OK. Then you will run the mea- surements by clicking on the Start menu on the PC. If the parameters of an open circuit before TRIM are displayed (Figure 9), then your almost 100% sure of success! ( 130093 ) Links & References [1] 500 ppm LCR meter Part 1 www. elektor-magazine.com/1 10758 [2] 500 ppm LCR meter Part 2 www.elektor-magazine.com/1 30022 [3] 500 ppm LCR meter Part 3 www.elektor-magazine.com/1 30093 Online documentation software (bootloader, firmware, and main program) designs for PCBs 1 & 2 component overlay, top 1 & 2 component overlay, underside 1 & 2 complete BOM XL version of circuit diagram mechanical drawing (standalone version with extension) front panel (standalone version only) Set-up and Operating Instructions documents Figure 8. To load the program into a blank microcontroller, you'll need this accessory. Figure 9. If this window with the parameters of an open circuit before TRIM appears, it confirms that the circuit is working correctly. www.elektor-magazine.com May 2013 25 •Projects By Jean-Claude Feltes (Luxembourg) From BASIC to Python (i) A field report Back in the 80s the author's first PC, by chance, had QuickBASIC already installed. That sparked his interest in programming; he later went on to Visual BASIC. With his current Linux platform he went looking for a programming language to perform the same role as BASIC. That turned out to be a real step up; Python is a neat and concise language but also in many respects quite a different animal... Regular readers may be thinking it a bit unusual to find a programming language review in Elektor magazine. Well the reason of course is that Python is a well-structured high-level language particularly associated with small computer systems such as the popular Raspberry Pi. The author was first introduced to Python by a colleague and was immediately intrigued by the language concepts and its contrast to Visual Basic with which he was more accustomed. A study of some source code examples impressed him with their clarity and conciseness. Gone were the brackets and semicolons which always seemed to give headaches in Pascal, C and Java. Further study uncovered many other differences. BASIC versus Python The first important thing to note is that Python is purely an interpreted language. This feature has both advantages and disadvantages. A Python program will generally run more slowly than an equivalent compiled program. The efficiency of the Python library routines however ensures that it is not too much of a disadvantage. The Interpreter along with any used library modules must also reside in the target system memory. An advantage of this approach is that the program can be easily modified when, for example, you need to switch the communication port to a different interface. Quick and dirty hacks can be performed by doing away with any user interface code and simply changing the values of variable directly in the code. Interpreted code also allows you define functions at run time and can be useful when implementing such things as function plotters. Python is very strongly object-orientated. For just a small program this feature is not so important. In the text and with example programs we will make good use of these features. If you are new to object oriented code then some of the concepts may seem difficult at first. One thing that takes a little getting used to is the minimalist layout of the program: Code blocks are not delimited by parentheses or 'begin' and 'end' but instead just by indenting the source code. It can be seen from the short example shown in the box comparing C, BASIC and Python that Python produces very readable and concise code. Another difference is that unlike BASIC, Python code in case sensitive. An attractive feature for engineers is that Python can handle complex variables. Interpreters are available which run in Windows, Linux and OS X environments. Installation Once the Python Interpreter for your chosen OS has been installed it will also be necessary 26 May 2013 www.elektor-magazine.com BASIC to Python C, BASIC and Python C Quick/Visual Basic Python #include Print "Hello world ! " print "Hello world ! " #include For x = 1 To 10 for x in range(0, 11) : If x Mod 2=0 Then if x % 2 == 0: int main(int argc, char *argv[]) Print x; ,l/v 2 = " ; x^2 print x, ,l/v 2 = " , x**2 { Else else : printf ("Hello World\n" ); Print x; "~3 =" ; x~3 print x, "^3 = " , x**3 int i; End If int x; for ( i=0; iApply Default indeototton. Indentation Files Width: [4 : Tools □ Detect width from fie Templates Type: O Tabs Keyblndlngs Spaces Printing O Tabs and spaces Various □ Detect type from file Terminal Auto-indent mode: Current chars : 0 Tab key indents Help Apply Cancel ^ OK I 0 - □ progl.py - /medla/79l0E3FFS8AD40A4/4_JCProg/Python/Doku/Elektor - Geany | File Edit search view Document Pro|ect Build Tools Help lay Change Font Toggle All Additional Widgets Fullscreen fit ✓ Show Message Window ✓ show Toolbar ✓ Show Sidebar ’ -i P> ?§ Symbols ► No tags found Editor * ^ Color Schemes > 1 [ Zoom In Ctrl++ ✓ Show Markers Margin Q Zoom Out Ctrl-F- show Line Numbers €l Normal Siye Ctrl+O •s show White Space 1 1 ^howl ine fndings ^ 1 «/ Show Indentation Guides the necessary files into a subdirectory where they can be used by the Interpreter. This directory name and path depends on the type of operating system in use (7usr/lib/python2.7' for Ubuntu or '\Python27\Lib' for Windows XP). IDE or No-IDE? At the start I missed the IDE that comes with VB to assist program development. Eventually however it did not prove to be too much of a hindrance. For simple programs all you really need is a good Editor, one favorite of mine is the freeware 'Geany' which runs under Windows and Linux. It performs automatic syntax highlighting for files that have a '.py' extension. It also supports code folding and allows a script to be started directly from the editor. Users of OS X need look no further than the Apple Xcode programming environment which supports Python along with many other languages. The 1.65 GB package can be downloaded for free from the Apple App store. A double click on .py extension files will load them into the Xcode Editor. A first program The programs can be written using any text editor, Figure 1 shows how it looks in Geany. In Python the source code layout is very important: you can either use tabs or spaces to generate the indents but do not mix them. The correct Python layout is four spaces per indent. Figure 2 shows how this is set up in the Geany editor. For maximum convenience it is advisable to use the 'show markers' margin, line number display and indent support features as shown in Figure 3. When the simple test program in Figure 1 is run under Windows the result is shown in Figure 4. The program can also be run using the command line statement 'python test.py' if you do not wish to or can't start it in the Editor program. With GUI scripts a double click on the file with the .py extension will work but with text programs like test.py the window closes so quickly after the output that it's difficult to read. When the program is used under Linux it is good practice to insert the following two lines before the start of the source code: #!/usr/bin/env python # coding: utf-8 The first line informs the operating system which 28 May 2013 www.elektor-magazine.com BASIC to Python Interpreter is used and the second line indicates the character set. Programmers raised on BASIC should study the box Python features which compares how the same routine can be written in three programming languages. The Python shell Python can be started using a command line (use the DOS box in Windows or Terminal in Linux or OS X), you should then see the Python triple chevron prompt / >>>'. Now you can enter commands interactively and explore some of the language features: >» s = 'hello' »> s. upper () 'HELLO' Library modules can be imported into the shell: import time Help for any imported module can be accessed by using 'help(module)' at the prompt. Using 'dir(module)' returns a list of all names (variables names and functions etc.) defined in the module. Pitfalls for Python newbies Anyone accustomed to other programming languages will most likely make the same simple errors when starting out with Python. One of the most common is to incorrectly indent the code. Python is particularly fussy, if the interpreter complains of an 'unexpected indent' then you can be sure you've got an incorrect number of spaces or tabs or you have mixed spaces and tabs. Each indent in Python should be four spaces. Pay close attention to how integers, floating point values and variables are written: 3/5 = 0 and only 3. 0/5.0 = 0.6! Python also states that for every subprogram and each Method requires a bracket at the end. Closing the serial interface using just 's. close' generates an error while y s.close()' is accepted. External hardware For engineers and developers one of the most crucial aspects of any programming language is how easily it works with the hardware. Python includes ready written modules to control the PC interfaces: pyUSB, pySerial, pyParallel and pyI2C. As a simple example we will use the serial interface: For communication the port is assigned an instance of the serial objects in the 'serial. Listing 1: ScanSerial.py import serial def scanserial ( ) : """ Scans for available serial ports """ portnames = [] # Windows for i in range(256) : t ry : name = "C0M"+str(i) s = serial . Serial ( name) s . close( ) portnames . append (name) except : pass # Linux for i in range(256) : t ry : name = "/dev/ttyS"+st r(i) s = serial . Serial ( name) s . close( ) portnames . append (name) except : pass # Linux USB for i in range(256) : t ry : name = "/dev/ttyUSB"+st r(i) s = serial . Serial ( name) s . close( ) portnames . append (name) except : pass return portnames # # main portnames = scanserial ( ) for p in portnames: print p Listing 2 : ReadSerial.py """Read and print serial data from C0M1 (9600baud) """ import serial # init serial port C0M1 / ttyS0 sCOMl =serial . Serial (0) sCOMl . set Baud rate (9600) if sCOMl . isOpen ( )==False : sCOMl . open ( ) # read lines of data until user presses while( 1) : line = sCOMl . readline( ) print line sCOMl . close( ) www.elektor-magazine.com May 2013 29 •Projects Figure 5. Python works well with the ElektorBus communication transferring measurement data. [66 . 6020229164 539 67.6988769995 539 67. 594794635 >38 u8 .09163*19888 539 p8. 5876350403 539 p9 . 6835380554 539 69.5794768729 539 pe. 6753819942 539 Ira. S71 299*761 538 In .06/0399666 538 pi. 5628969133 538 M 72.6589376728 539 U7. r , 54746966? 539 126 73.0S1 / 308/1? 539 127 73. 54758OO037 539 128 74.6435419683 539 129 P4. 5394266883 539 136 t5.035?7Q9?93 539 131 l/S. 5317*130859 539 132 p6. 82718997 538 133 P6. 5231289864 cn CD 134 135 |>ass 136 r 137 l 138 139 140 HOgl .Ml 141 »■ " ti.un 142 App( redirect = Pali.) 143 yx. Frame (None , -l, "TfcST term 144 lxtbox= Teminalwindow(frafT>e,Ci 4 5 m(True) 146 i«r«> 147 148 149 156 ixtbox . conoect_i readbytes< ) — py' module. Ports can be addressed by their number or name ('COM1' in Windows or '/dev/ ttySO' in Linux). The simplest method to search for available ports is to try to instantiate a port (Listing 1). When it is successful it indicates that the port exists. Virtual USB ports will also be detected. Listing 2 illustrates how data can be received through a serial port. The data may have originated from an external microcontroller. After the assignment of the object sCOMl to Port COM1 Python features • Variables are declared implicitly by their assignment: x = 5.0 • The For-Next loop structure found in many other languages does not exist in Python. An iteration can performed on the components of an object, like the characters in a string or lines in a file. In place of the classic 'For... Next' the 'for I in range' condition can be used: for i in range (0,5) : print i The iteration is performed on all the components of the object 'range (0,5)' i.e. on the list [0,1, 2, 3, 4]. NB: The end value (5 in this example) isn't part of the list! • Arrays (lists) may contain different objects: x = [0, 3.14, 'Ham' , 'Eggs'] • Functions can return multiple values as a 'tupel': (x, y, z) = myf unction (v) • There are no SUBs, only Functions, as in C. These are declared with 'def...()' and can, as needed, return values or objects. the baud rate is specified (default values for parity and number of stop bits are used) and the port is opened. During software experimentation it often occurs that a program will leave a port open. Next time the program starts it cannot open the port. It is better only to open a port when it is not already open. The program now executes an endless loop until it is terminated using Ctrl-C. A more elegant solution would be to poll a key and terminate the program when a press is detected. This is possible but not so simple because the operating system decides. The Function 'raw_input()' cannot be used in this instance because it will wait until the enter key is pressed. If you plan to add a GUI to your program using wxPython for example, it provides simple methods to detect and react to key presses and other events. With the addition of a little more code (Listing 3) it is possible to make a data logger. Subroutines have been used here to improve code clarity. These are first defined using 'def...()' and the main program comes right at the end. Next in 'show_log()' it checks using (try / except) to find a LOG file, if it exists then the file is read and output. The 'file. read' reads all the text in the file. The serial port is opened and each line of received data is displayed and written to the file. In the pipeline Now that you've got a taste for Python you should be able to install the interpreter yourself along with some libraries and begin to write a 30 May 2013 www.elektor-magazine.com BASIC to Python few simple programs. All the example listings shown here can be downloaded for free from [1]. In the second part of this series we will explore a few engineering niceties such as graphs, Fourier synthesis with a nice user interface. In the third part we switch to practical examples and use a small microcontroller board to send measurement data via the ElektorBus to a PC (Figure 5). (110483) Internet links & Literature [1] Listings etc.: www. elektor.com/1 10483 [2] The author's homepage: http://staff.ltam.lu/feljc/home.html [3] Python documentation: https://pypi.python.org/pypi/RPi.GPIO [4] Python Tutorials: www.awaretek.com/tutorials.html [5] Introduction: J.M. Hughes: Real World Instrumentation with Python Listing 3: ReadSerial2.py """Read and print serial data from C0M1 (9600baud) """ import serial def show_log(): """ show result of last logging""" t ry : file = open ("test. log", "r") text = file . read ( ) file . close( ) print "CONTENTS OF LAST LOG FILE:" print text print "END OF LOG FILE" except : print "NO LOG FILE FOUND" pass def openportlog (port ) : """ open serial port and LOG file""" # init serial port C0M1 sCOM =serial . Serial (port-1) sCOM. set Baud rate (9600) if sCOM. isOpen( )==False: sCOM.open( ) file = open ("test. log", "w") return sCOM, file def receive(sCOM, file ): """ read lines of data until user presses """ while( 1) : line = sCOM. readline( ) print line file .write(line) port=l show_log ( ) ok = rawinput ( "NEW LOG (y/n) ?") if ok== "y": s, f=open_port_log (port ) receive(s, f) # file and port closing done by interpreter at [6] Andrew Pratt: Python Programming and GUIs for Electronic Engineers www.elektor.com/products/books/program- ming/python-programming-and-guis-for- electronic. 1 320886. lynkx The Author Jean-Claude Feltes lectures in electronics at the Lycee Technique des Arts et Metiers in Luxembourg. This college caters for both arts and technical students and provides professional qualifications for apprentices and technicians. He spends much of his free time pursuing his interests in electronics and programming [2]. www.elektor-magazine.com May 2013 31 •Projects Taming the Beast (4) Make-belief with 250 Kgates By Clemens Valens (Elektor.Labs) Simulation is an important part of programming FPGA applications. If your applica- tion involves only a handful of gates, it isn't especially difficult to come up with a properly working design. However, things are different when you use virtually the entire chip for an application written in a hardware description language (HDL). In that case, examin- ing the circuit inside the chip is difficult at best, so simulation is the only real alternative. In this article we look at how you can simulate the design from the previous installments. The problems that arise when you are implement- ing a design in an FPGA are not all due to dumb design errors. The architecture of the chip and the shortcomings of the development tools can also play a role. Especially in applications that work with high clock rates, these factors become significant and sometimes unavoidable. Glitches can occur when the distances and propagation times in the chip become relatively large. For this reason, FPGA programmers run a lot of simula- tions to check whether the design does what it is supposed to do. They also look for signs that it does things it isn't supposed to do. Simulations are used at various stages in the development process. This starts with a functional simulation, which serves to indicate whether the basic design is sound. However, at this point there's still a lot to be done before the design is finished. Each step of the process creates new opportunities for errors, so a simulation after each step is necessary to keep things under control. If the design passes the final simulation after the last implementation step, there's a reasonably good chance that it will work properly. However, there is no guarantee of this, since a simula- tion is just a simulation and real hardware can always throw an unexpected monkey wrench in the works. Starting the simulator To see what it's like, let's simulate the design of the two-digit up/down counter from the previ- ous installments. Start by making a copy of the project from last time, which I named part3 (see installments 3 [3]). I decided to name this copy of the project part4 (can you guess why?). It's 32 May 2013 www.elektor-magazine.com Elektor FPGA Dev Board a good idea to open the new project in ISE now, before you read any further. You can open the ISE simulator at the top of the Design tab, where you see View. In the pre- vious installments you were always working in the Implementation view, but now you need the Simulation view. After selecting the function by clicking Simulation, you will see that the con- tent of the Processes pane has changed. If you look closely, you will also see that a new panel named Behavioral now appears above the Hier- archy pane. Since you're starting with an uncom- piled virgin project, there is only one entry in the Processes pane: Design Utilities. Select top in the hierarchy to display the ISim Simulator process in the Processes pane. Expand this entry by clicking the plus sign. Now select the process Simulate Behavioral Model and click the button all the way to the right, just below the green arrow. Alternatively, you can select Run in the pop-up menu that appears when you right- click the relevant entry, or you can double-click the entry with the left mouse button. ISE will now get busy, and after a little while (assum- ing all goes well) you will see a message in the Console pane telling you that the process com- pleted successfully. You should also see that an ISim window has been opened next to the ISE window, with your signals displayed there on a sort of logic analyzer screen (Figure 1). In the Console pane at the bottom of the ISim win- dow you can see that you are working with the Lite version because you haven't acquired a full license yet. You can also see that the resolution of the simulation here is 1 picosecond (1 ps). At the top of the window you can see that the dura- tion of the entire simulation is 1 ps. Now let's try a few things. Manual simulation Click the Restart button (the blue button with a white right-angle arrow facing left), or restart via the Simulation menu. Then right-click the ce sig- nal in the signals list (there are two of them, but it doesn't matter which one you choose). Alter- natively, you can click the signal on the graphic display. Make sure that only one signal at a time is selected. In the pop-up menu that appears, select Force Constant, since this signal is more or less constant - especially compared with a clock signal. In response, ISim opens the Force Selected Signal dialog, where you can set a num- ber of parameters. Enter "1" in the field Force to Value and "1ms" in the field Cancel after Time Offset. The remaining fields can be left at their default values. Click OK. Now the signal ce will be high when the simulation starts, and it will remain high for 1 millisecond. Repeat this pro- cedure for the signal up down and the signal clr, but with the signal value forced to "0". Next, use a similar procedure for the signal clk_ in, but in this case select Force Clock instead of Force Constant. The Define Clock dialog that appears now is very similar to the Force Selected .. ISim (P.28xd) [Defaultwcfq] “ File Edit View Simulation Window Layout Help 1- 11 A 1 11 xl Df*H| . ^iOIQX® 'oo»|M,a6 t o|j^ E : aM? a iSSrPt r~.|B ► k 1 !!- 00 - Rc k>ur>ch Instances and Processes □ 8 x Instance and Process Name tup.lup_M.h_Uj i Jj) std_logic_1161 Qj«| niunrrtr.ctrt vcomponenti Objects Smutoboo Objects for top_top_seh_tb tc it ££ insure Mrnnwy (^Snirre Object Name Value fc. q[7K>] 00000000 £ ce u LA clkjn u Li dr u lA up_down ^ dupldyl.d u 1 lA display! b 1 u display! _r 1 lA duplayl d 1 lA display! e 1 Ti rlKplayl_f 1 displayl a 0 lA display! a 0 lA d»pldy2_f 1 lA display! c 1 '.A displayed 1 LA d»pldy2_c. 1 display !_ b lA dispiayz.a LA slim 875 1 1 0 11 ledl out 0 J lrrt?_oiit 0 4 rvi * Console |i,.nnn,ncorK y # yy» ps iyyy,yyy ps i,(xxj,uuu ps <* □ B x WARNING; A WEBPACK Scense was found. WARN INC: Please use Xlnx License Configuration Manager to check out a full ISm license. WARNING: I Sun wJ run in Lite inude. Please refer tu die ISnr duujrnerrtaliun fur mure mfurmoUun un die dfTcrenLES between die Lite and die Ful versmri. this is a Lite verswn of ibm Tune resolution is 1 ps SiinJoLur is dung usual riUoiuabon process. Mnished or cut initialization process. ISim> Comphtton log | ♦ Breakpoints ] Find in Ffcs Resrits tk Search Results I ■ Console iim I ime 1,000,000 ps Figure 1. ISim in full glory. There's nothing in particular to see in the simulation pane here because we haven't defined any stimuli yet. www.elektor-magazine.com May 2013 33 •Projects Figure 2. The Define Clock pane. Time intervals without specific units are picoseconds. Signal dialog, but not exactly the same. Enter the values shown in Fig ure 2 and click OK. These values cause the clock signal to start with a rising edge at time 0 and remain active for 1 millisecond, with a duty cycle of 50% and a period of 125. But 125 what? The answer here is 125 ps, since the time resolution is 1 picosec- ond. If you do not specify a unit, ISim uses the default unit. The clock frequency of the FPGA on the board is 8 MHz, which corresponds to a period of 125 ns, so you should enter "125 ns" here instead of "125". Now that you have defined all the input signals, you can start the simulation. If you do this by clicking the Run All button (or via the Simulation menu), the simulation will run until there are no more events or until a breakpoint is encountered. Since you have not defined any breakpoints, the latter possibility is rather unlikely. This means that the simulation will stop only after the defined stimuli expire at the end of 1 millisecond, since a clock signal constantly generates a series of events. You can interrupt the simulation at any time by clicking the Break button (the one with the pause symbol). Note that after a forced stop, ISim open a VHDL source file (this usually top. vhd, but it can also be a test bench) and pushes the Waveform view to the background, where it can be recognized by the wcfg tab. Click this tab to display the Waveform view again. You can also run the simulation in step mode with the Run button (the one with the triangle and hourglass symbols), which is next to the Run All button. Before doing this, you must enter the simulation interval in the box next to the button. For example, you can enter "10ms" here for an interval of 10 ms. After this, the simulation will run for 10 ms each time you click the Run button. When the simulation is stopped, either by itself or forced, you can view the signals (Figure 3). You can zoom in or out, and you can scroll through the signals. You can also change the sequence of the signals by dragging them up or down, in order to group signals together. If you don't see anything changing, check the colour of the four input signals. If any of them is orange instead of green, it is not defined and you have made a mistake somewhere. Once you find the right zoom factor, you can see the clock signal oscillating away or see the other signals changing levels. The current states of bus signals (multi-bit signals, such as q[7:0]) are shown in binary notation. This is the default setting; it can be changed by selecting Radix in the same pop-up menu as Force Constant. This is a convenient way to see whether a counter is actually counting and in which direction. The signal states at the yellow cursor position are shown to the left of the waveforms. On the test bench Simulating a circuit in the manner described above is entertaining, but it's not especially con- venient. If the circuit works okay, this method is reasonable if you just want to look at some- thing, but if your are iteratively modifying a circuit design, you have to define the signals again each time using time-consuming dialogs, and that gets old pretty quickly. If you're a whiz with a key- board, you can enter commands in the Console (for an example, look at the contents of the Con- sole after you close a Force Constant dialog), but first you have to learn all these commands (see the document plugin_ism.pdf, which is available on the Xilinx website). A better way - in fact, the way Xilinx recommends — is to use a test bench to automate the simulation. In this context, a test bench (or a test fixture) is simply a file that you add to the ISE project when the Simulation view is active. You do this in the usual way via New Source (right-click in the Hierarchy pane). This brings up the New Source Wizard, where you can select VHDL Test Bench. Enter a name (such as test_bench ), check that the option Add to project is ticked, and then click Next. Now you have to associate the test bench file with a source file. In this case you want to test the entire circuit, so you should associate it with 34 May 2013 www.elektor-magazine.com Elektor FPGA Dev Board Test bench in Verilog CLKIN = 0; #62.5; end Just as there are various computer programming languages, there are also various FPGA programming languages. In the main article we used VHDL because ISE apparently has a preference for this, but we could have just as easily used Verilog. For the sake of completeness, here we show you how the test bench can be built in Verilog The clock process is implemented in Verilog with an always command (note that unlike VFIDL, Verilog is case sensitive), and it fits on a single line thanks to the invert operator "!". The frequency is set with the "#" symbol, which introduces a delay. In this case the delay is 62.5 ns, since the default time unit here is nanoseconds (although the resolution is still 1 picosecond). always #62.5 CLKIN = ! CLKIN ; Flere the level of clk_in is inverted every 62.5 ns. This works if you assign an initial level to clkin. You could also use the following code to generate the clock signal in the same way as in VFIDL: always begin CLKIN = 1; #62.5; With this code segment, there is no need to initialize clk in. The stimuli are initialized in the initial code block, which is executed only once at the start of the simulation. The syntax is similar to the VHDL syntax, and here again we start with a 100 ns wait time. initial begin # 100 ; CLKIN <= 0; CE <= 1; CLR <= 0; UPDOWN <= 1; end Here you can also use " = " in place of "< = ". Just to be on the safe side, I initialized clk in here. It may not be necessary, but in any case it doesn't hurt. The always and initial code blocks can always be placed together at the end of the Verilog test bench generated by ISE, in place ofthe"ifdef auto init ... endif" code block. All clear? Start simulating! ✓ P r © © i±: ±r * \PPQP LSI ■+! ■ ■*, □ ► 1ms ▼!(#>_= || Re-launch 1ft 1ft ► isa Bn 1ft ce r dk_in 1ft clr 1ft up_down ■8 q[7:0] 1ft ledl_out H led2_out Hg displayl_a 1ft displayl_b lft displayl_c Ijg displayed Ijg displayl_e 1ft displayl f 1ft displayl g 1ft display2 a 1ft display2_b J^L 00111011 1 manual, wcfg — ... X ooi.. . X ooi. . yooi . >;ooi... x “T “L □ n l i I I m top.vhf ► - Figure 3. The waveform pane after a simulation. At the selected scale, the clk in signal changes state so often that ISim shows it cross- hatched. You can right-click a bus signal to change the radix used to show the bus state value. In this figure it is shown in binary notation. www.elektor-magazine.com May 2013 35 •Projects top. After you click Next , the usual summary is displayed. You can usually skip the details here, but in this case it's a good idea to check that the test file has been given the extension ".VHD". This means that it has been converted into a VHDL file. Click Finish to complete the procedure. Now you should verify that you have added the test bench in the Simulation view, not the Imple- mentation view. If you accidentally get it wrong, you can correct your mistake by setting View Association to Simulation in the file properties ( Source Properties ) . Adding a test bench has more consequences than you might think at first glance. For instance, after a little while you will see a new entry in the Hier- archy pane between the chip and top, with the euphonious name "top_top_sch_tb". You will also see that top has changed to UUT - top, where UUT stands for Unit Under Test. The hierarchy thus clearly indicates what is tested and by whom. In order to test the counter, you have to do the same thing in VHDL or Verilog that you previously did manually. You need a clock signal and several levels that are more or less constant. Let's start with the easy part: the constant levels. At the end of the VHDL test bench listing, you will see the following code segment (note that the reserved VHDL commands are written here in capital letters, but this is not essential since VHDL is not case sensitive): tb : PROCESS BEGIN WAIT; END PROCESS; This is more or less the main routine of the test bench, or better put, the main process. This pro- cess, named tb, does nothing — it just waits. A process is a lot like a subroutine in a computer program, but unlike subroutines, processes are Concurrent processing guarantees perfect multitasking At this point the file test_bench . vhd has been opened in the Editor, and as you can see there are all sorts of things in it. Just for fun, you can try adding another test bench, but this time in Verilog instead of VHDL so that you can see the differences between these two languages. The procedure for this is the same as previously described, except that you select Verilog Test Fixture as the source type. After you add this second test bench, you will see that an entirely new hierarchy has been added in the Hierarchy pane. This appears to suggest that you can use several test benches in the same proj- ect, but I couldn't manage to do this. ISE has a clear preference for the VHDL test bench. Note that the Verilog file has the extension ".V" and the icon is not quite the same as the icon for the VHDL file. Since the Verilog and VHDL files have different extensions, you can use the same file name for both test benches if you wish. Whether that's a good idea in practice is something you will have to decide for yourself. Now for a bit of VHDL The test bench only contains a skeleton at first, so you have to add the information necessary to activate the right signals at the right times. executed concurrently (in parallel) instead of one after the other. You could regard this as a sort of perfect multitasking. A process is also executed over and over again unless it is interrupted, as you can see here with the infinite loop WAIT. You need to add the signals ce, clr and updown to this process and assign them levels. The result- ing code looks like this: tb : PROCESS BEGIN WAIT FOR 100 NS; ce <= '1' ; clr <= '0' ; updown <= '1'; WAIT; END PROCESS; Now the process sets the signals ce and up_ down high and the signal clr low before it starts waiting. These instructions are executed con- currently instead of sequentially, so the order of the instructions here has no effect. The line WAIT FOR 100 NS causes the process to wait for 100 ns, giving it time for the reset signal. The ISim Help file recommends doing this, so we do so without asking any questions. 36 May 2013 www.elektor-magazine.com Elektor FPGA Dev Board Its operation is easy to understand: set clkin high, wait for 62.5 ns, set clk in low, wait again for 62.5 ns, and then repeat the process. The result is a sig- nal with a duty cycle of 50% and a frequency of 8 MHz. Since the duty cycle is 50%, this can be done more elegantly by using a constant for the wait time. This constant should be added at the bottom of the SIGNAL list: Generating the clock signal is a bit more compli- cated because you need a separate process for this. This process is executed concurrently with the tb process. clock : PROCESS BEGIN clk in <= ' 1 ' ; WAIT FOR 62500 PS; clkin <= 'O'; WAIT FOR 62500 PS; END PROCESS; This process does not end with an infinite WAIT and it can- not be interrupted, so it is repeated indefinitely. clock : PROCESS BEGIN clk in <= ' 1' ; WAIT FOR clockhalfperiod; clkin <= '0' ; WAIT FOR clockhalfperiod; END PROCESS; CONSTANT clockhalfperiod : TIME := 62500 PS; The constant clock half period is of type TIME and can be used with the WAIT command. The process code is now: Now the test bench is ready and you can start the simulation. Select the test bench in the hierarchy to display the ISim process. Expand this entry to display the following two options: Behavioral Check Syntax and Simulate Behavioral Model. www.elektor-magazine.com May 2013 37 •Projects Figure 4. You can user markers to measure time intervals. The clock period for this simulation was set 250 ps instead of 125 ns. When you select a marker, it becomes the zero reference point and ISim calculates the time intervals to the other markers. You can set the time unit by right-clicking the time axis. Execute the first of these processes to check for typos. This must result in a green check mark before you can go any further. Right-click Simulate Behavioral Model to open the simulation properties, and then tick the option Run for Specified Time. Now the simulation will run until you click Break. Otherwise the simulation will start immediately and run for the specified time. Close the properties window and launch the process Simulate Behavioral Model. This opens the ISim window, but nothing else happens. Click the Run All button, or else Run ( for the time speci- fied on the toolbar), to start the simulation. Let the simulation run until the progress bar shows the desired duration. Then click Break to stop the simulation. Now you can view the signals in the same way as previously described with manual simulation. Bear in mind that the time axis may The fully assembled and tested FPGA development board is available in the Elektor Shop for just $66.89 plus shipping. have a very small time increment, which makes it look like all the signals are static. Use the Zoom to Full View button to display the full simulation, so that you can see the slowly varying signals properly. Then you can easily zoom in on the signals of interest (Figure 4). The signals in the waveform pane are shown in the same order as in the SIGNAL list. You can arrange this list to suit your taste, but make sure the commas are right. Remember that you have to close the ISim window each time you want to run a new or modified test bench, since ISE can't seem to do this for itself and generates an error message. That's all folks! This brings us to the end of our introduction to FPGA programming. You should now be able to set up your own simulations. There are a lot of things that we haven't discussed, and I recommend that you use the Internet and other resources to study this complex topic in more detail. Simulating a design is not especially difficult, but doing this properly requires sound knowledge of program- mable logic, hardware definition languages and development tools. Go for it! ( 130065 - 1 ) Internet Links [1] Part 1: www.elektor.com/120099 [2] Part 2: www.elektor.coml/120630 [2] Part 3: www.elektor.com/120743 [2] Part 4: www.elektor.coml/130065 38 May 2013 www.elektor-magazine.com ■ " ™ ww.ezpcb .OOlIL New Website Is Orilm Better Design More Powerful Easier to Use Prototype to Production Amateur to Professional order now 2L 4 x4 each Free Shipping! http://ww.czpcb.ccm AP CIRCUITS PCB Fabrication Since 1984 As low as... 9.95 each! Two Boards Two Layers Two Masks One Legend Unmasked boards ship next day! www.apcircuits.com VISA III IPC MEMBER r ASSOCIATION CONNECTING f ELECTRONICS INDUSTRIES' Android Apps programming step-by-step ©lector ft Android Apps programming sHrp-by“*P JAVA *' L - w 3 Further information and When it comes to personalizing your smartphone you should not feel limited to off the shelf applications because creating your own apps and programming Android devices is easier than you think. This book is an introduction to programming apps for Android devices. The operation of the Android system is explained in a step by step way, aiming to show how personal applications can be programmed. A wide variety of applications is presented based on a solid number of hands-on examples, covering anything from simple math programs, reading sensors and GPS data, right up to programming for advanced Internet applications. Besides writing applications in the Java programming language, this book also explains how apps can be programmed using Javascript or PHP scripts. ISBN 978-1-907920-15-8 244 pages • $56.40 •Projects Elektor Linux Board Extension (2) Implementing menus on a text display By Benedikt Sauter (Germany) [1] Even on a small display it is possible to show a surprisingly wide variety of param- eters and settings by implementing a well-designed menu system. For ease of use the buttons should preferably be placed adjacent to the display, exactly as we have done on the Linux extension board. In this article we look at the required code. Figure 1. The Elektor Linux Extension Board includes an alphanumeric display and three conveniently-located buttons. Although in the smartphone and tablet markets there is a constant push towards higher and higher resolution screens, there are still many devices that only have a simple text display. Many printers, fax machines, NAS servers and mobile phones offer simple text- based menus navigated using buttons to adjust settings and view status information. In this arti- cle we will give an example of how you can imple- ment something similar in your own projects. Menu structure The Elektor Linux extension board [2] includes a two-by-sixteen character display with three but- tons placed immediately below it (see Figure 1). The board therefore makes an ideal hardware platform for our example. First we have to make a list of the various menu items that we will want to adjust or view through the user interface. A simple menu system might resemble the following: 40 May 2013 www.elektor-magazine.com Microcontrollers User Menu VI. 0 < OK > Configuration < OK > Network < OK > State < OK > Duration back OK > 12:20 OK + Figure 2. Example menu structure. • Configuration - Minimum temperature - Maximum temperature - Daily start time - Maximum duration • Network configuration - IP address: dynamic or static - IP address - Network address - Gateway - DNS server • Status - Current temperature - Processor load - Memory use - System uptime The 'Configuration' menu allows the main set- tings to be adjusted. The minimum and maximum values can be set to control (for example) the switching behavior of the unit. A network connec- tion also requires a few configuration parameters. The first thing to choose is whether the IP address for the connection is dynamically or statically configured: if static configuration is chosen the remaining parameters in the group have to be set. Well-designed software will of course check that all the IP addresses have the correct format. Implementing the menu When implementing the menu you can seek inspi- ration from devices you may already have: you can probably think of some more or less suc- cessful examples. Figure 2 shows a sketch of how the menus that we want to implement might look. This is not the complete set from the list above, but it does provide a representative sample. Having decided what the user will see at each stage we need to decide on the logic that ties the various screens (including the sub-menus) together and on the types of operation that will be supported. Such operations might include: • Static output • Choice between options, with confirmation of selection • Setting numerical parameters (up/down counter) • Setting alphanumeric parameters • Dynamic output (progress bars, live values, time etc.) The easiest of these to implement are the static output and the straightforward choice (for exam- ple between static and dynamic IP addressing). Implementing parameter settings and continu- ously updating dynamic displays is more difficult. The naive approach of jumping in and writing code will typically result in the dreaded 'spaghetti'. The more satisfactory approach is to design a flexible and extensible solution, with the idea of mak- ing it easy to add new menu items to existing code without having to get too deeply involved in the software. Our suggested approach We looked at two possible ways of designing such a flexible and extensible solution. The first is a conventional library that allows the menu to be implemented along the lines of the pseudo- source-code shown in Listing 1. The functions www.elektor-magazine.com May 2013 41 •Projects Listing 1. Pseudocode for constructing a menu. configuration = MainMenu ( "Configu ration" ) network = MainMenu ( "Network" ) state = MainMenu ( "State" ) //Menu Configuration mintemp = SubMenu(configuration, "Min Temp") maxtemp = SubMenu (configuration, "Max Temp") start = SubMenu (configuration, "Start Time") duration = SubMenu (configuration, "Duration" ) //Menu Network ipchoose = SubMenu (network, "IP Address: Dyn/Static" ) ip = SubMenu (network, "IP Address") netaddress = SubMenu (network, "Network" ) gateway = SubMenu (network, "Gateway" ) dns = SubMenu (network, "DNS Server") //Menu State temperature = SubMenu(state, "Temperature" ) cpu = SubMenu(state, "CPU" ) ram = SubMenu ( state, "RAM" ) uptime = SubMenu(state, "Uptime" ) Reg is terMenu (mintemp, MinTempe rat u re) Listing 2. Pseudocode for setting a parameter. Function MinTemperature( ) { mintemp = ConfigRead ( "mintemp" ) switch (button) { case "button left " : mintemp- - case "buttonok" : Back( ) case "buttonright " : mintemp++ } ConfigWrite( "mintemp" , mintemp) Display ( "%s" , mintemp) MainMenu ( ) and SubMenu ( ) allow a tree struc- ture to be built, and it is easy to see how this structure can be extended. When a new node is created a reference to it is returned, and this reference can subsequently be used to create new nodes beneath it in the tree. The function RegisterMenu ( ) allows a function to be associ- ated with a node, such that the function is called whenever the menu item is accessed. Now we come to the implementation of these functions. When a menu sub-item, such as the minimum temperature setting, is selected a menu should appear that allows a numerical value to be adjusted. Pseudocode for this is shown in List- ing 2. For this (and for any other function that allows parameters to be set) we need read and write access to a configuration file or database (ConfigRead ( ) and ConfigWrite ( ) ). The button press is processed in a switch-case construct and the updated temperature value is displayed with a call to Display ( ) . The web pages accompanying this article [3] include an example implementation in C that can be downloaded. An alternative approach An elegant alternative way to implement a menu system is using the (Linux) file system. A direc- tory tree is created mirroring the desired menu structure. Each directory can contain a short piece of code that implements the menu item in ques- tion, and the output of this code can be directly shown on the display. ( 130044 ) Internet Links [1] sauter@embedded-projects.net [2] www.elektor-magazine.com/120596 [3] www.elektor-magazine.com/130044 42 May 2013 www.elektor-magazine.com OTA Wave Gen OTA-based Triangular Wave Generator "Do more with an operational transconductance amplifier" Although many applications of OTAs have been described, the basic circuit of a non-sinusoidal oscillator exploiting an OTA's specific advantages is a rare find. This design brief describes a combined triangular and rectangular wave oscillator with two OTA circuits. An OTA is a wonderful electronic component enabling a circuit to be designed whose the parameters can be changed by setting the J abc bias current without the need to change the parameters of the other components. Many appli- cations of OTAs have been described and may be found in books and articles such as references [1], [2] and [3]. Here we set out to complement this body of knowledge with a generator circuit. How it works The circuit diagram of the generator is shown in Figure 1 . Circuit OTA1 with capacitance C forms an integrator. The capacitance C is supplied from the OTA1 output by a constant current J 01 . Volt- age \/ c is linearly dependent on time t. Circuit OTA2 with resistors R lf R 2 forms a Schmitt trig- ger device. The output current J 02 creates trigger voltage V R2 across the R 2 resistor. When voltage \/ c reaches the threshold value, OTA2's output toggles to the opposite state, causing the output current to change its orientation to -I 02 and the V 2 output voltage polarity to toggle too. Using feedback the V 2 output voltage is fed to the input of the integrator. Its output changes its state to the opposite -I 01 by the V 2 voltage and the By Libor Gajdosik (Czech Republic) www.elektor-magazine.com May 2013 43 •Projects input voltage can be ignored. The OTA input con- sists of the differential amplifier, hence both OTA input currents can be considered low and they are basically the same. Within one period T the capacitance is charged from t= 0 and i/ c =0 until the time t=t lf when \/ c reaches the maximum value V Cm . In an equation: Vcm = ~ J^Ol X df = (1) This value V Cm equals the trigger voltage V R2f so we can write: bn v ^_ C 1 + R 2 Figure 1. Basic elements that go into the making of the generator. Figure 2. Rectangular and triangular waveforms produced by the OTA- based generator. capacitance decreases down to the new value V R2 . The activity of the circuit repeats cyclically. The activity of the generator is based on the fact that under the given operational conditions the OTA output current has positive and negative saturation values, which appear when the input voltage exceeds the linear operational mode of the OTA. The range of the input voltage in the linear mode is usually small, 20 to 50 mV. In cases when the V R2 trigger voltage is much higher than the input voltage for the linear mode, this Tek JL M Pos: 400,0ns MEASURE + CH2 Pli-Pl: 2.80V •:/ V / 1 /"“i \... / .. i iUij 3 CH2 Fie-q mjmz : N yl / CHI Pk-Pk 3.52V \n h CHI None CHI None M 2.50JUS- SI -Oct-11 2VAS Since V 2 is formed across the R x and R 2 resistors by the I 02 current, the following is true: V 2 = I 02 {R l + R 2 ) ( 3 ) Let us insert (3) in (2) and calculate the time * _ ^2 A)2 It is assumed that both values of the OTA output current, negative and positive, are the same. As the triangular waveform is a partly linear func- tion and it is symmetrical both horizontally and vertically, the total period of the oscillations T equals 4 t lf and for the frequency f the following formula is true: 01 abcl 4CR 2 Iq 2 4-CR 2 Iabc2 For saturation and bias currents we have: A)1 ~ label an d A)2 ~ I abcl (6) As the voltage divider on the output is not loaded, the following relation holds for the V Cm amplitude of the triangular waveform: Vcm ~ ^2 „ 2 „ = A)2^2 ~ I abcl^l 0) k { + k 2 44 May 2013 www.elektor-magazine.com The simplifying assumptions for the derivation of formulas are not completely fulfilled. However, they can be used for an approximate estimation of the frequency and the voltage when design- ing the generator. Practical results The measurements were performed with the fol- lowing components: OTA type LM13700, resis- tors R 1 =820 ft; R 2 =2 kft; capacitor C=1 nF. The bias currents were realized by means of resis- tors connected between the bias input and the ground. For J abcl the values R 3 =l Mft,R 4 =10 kft were used. For / abc2 , the value R 5 =15 kft was used throughout, so as to keep a constant value of l/ 2 and V Cm for all measurements. The supply voltage was maintained at ±10 V. The output current *01 was found to be between 14 jiA to 0.87 mA and the frequency, between 3.6 kHz to 160 kHz. The output current I 02 was measured at 0.57 mA. The measured waveforms are shown in Figure 2. ( 120058 ) References [1] T. Parveen, Operational transconductance amplifier and analog integrated circuits , New Delhi, India, I.K. International Publishing House, 2009. [2] R.L. Geiger and E. Sanchez-Sinencio, "Active filter design using operational transconduc- tance amplifiers: A tutorial", IEEE Circuits Devices Magazine, vol.l, pp.20 - 32, March 1985. [3] W.R. Grise. (1998, October). Operational Transconductance Amplifiers (OTA) for syn- thesis of voltage-controlled active-filter tuned oscillators. TECHNOLOGY INTERFACE: The Electronic Journal for Engineering Technol- ogy. Available online: http://technologyinter- face.nmsu.edu/fall98/electronics/grise/gris- eota.html CD IT) CL) > “O S^ ( t ^ \ [ \J GL t CO -i — > L_ CL) > “O “O TD (I M IP rv T ■ N 1 nr y i. j ii « it 04 14 li II M |4 44 Tl >44 M 114 lil Pfl + Two mixed signal triggers + Protocol decoding + Spectrum analysis + Symbolic maths + Custom units + Copy & paste + Signal generator + USB or Ethernet + 8M samples storage + 100 MHz sampling + Dual 14 bit ADC + Ext Trigger, 8 Digita l Inputs + 1.5 MSaisec HD streaming 14 Bits 100 MSPS MSO 11 .cleverscope.com powered by Eurocircuits Elektor Benefit now: Elektor PCB Service offers a permanent 90-day launch discount on new Elektor PCBs! Check www.elektor.com/ocb. for an overview of all Elektor PCBs In •Industry One-resistor tunable timer ICs Touchstone Semiconductor announced it has added four new, high-accuracy, micropower timer ICs to its rapidly expanding family of "NanoWatt Analog™" timer integrated circuits. In addition to all other Touchstone Semiconductor ICs, these new analog timers are all in stock and ready to ship from Digi-Key, Touchstone's authorized distributor. These new, higher-single-supply voltage, second-generation timer ICs to the company's very popular TS3001 and TS3002 operate over a wider supply voltage range (1.55 V to 5.25 V) and consume very little supply current (<2 pA). To set the output frequency (or period) in these new timers, only a single resistor is needed. For the TS3003 and TS3006, the output frequency can be set from 9 kHz to 300 kHz. For the TS3004 and TS3005, an internal 3-bit counter was added that can program the output period from 3.3 ps to 233 s (TS3004) or from 1.7 ms to 33 hrs (TS3005). Three of the timers include a dc-voltage-controlled pulse-width modulation (PWM) output (the TS3003, the TS3004, and the TS3005). All four timers are available in space-saving, low-profile, exposed-backside-paddle TDFN packaging. Key Specifications: Ultra low supply current: TS3003, TS3004, TS3006: 1.9 pA at 25 kHz TS3005: 1.35 pA at 49 Hz Supply voltage operation: 1.55 V to 5.25 V All four timers use (1) single resistor to set F 0UT at 50% Duty Cycle TS3003, TS3006 output frequency range: 9 kHz < F 0UT < 300 kHz Two timers with 3-pin-programmable extended ranges: TS3004: User-programmable F 0UT period: 3.3 ps < t F0UT < 233 s TS3005: User-programmable F 0UT period: 1.7 ms < t F0UT < 33 hr F out period accuracy: 3% F out period drift: 0.02%/°C Separate PWM control and buffered output (TS3003, TS3004, and TS3005) Fouj/PWMout output driver resistance: 160 Q All Touchstone timer ICs are fully specified over the -40°C to +85°C temperature range. Engineers are invited to order free samples and free demo boards. http://touchstonesemi.com/products/timers (130028-V) Universal programmer BPM Microsystems'Model 2800 combines the unrivaled speed of Vector Engine Co-Processor® technology plus true universal device support, resulting in the fastest universal programmer in the industry. The ultra-fast programming speed of the 2800 is attributed to BPM Microsystems' Vector Engine Co-Processor, the same proven technology that established Flashstream® as the fastest flash-dedicated programmer. This technology uses a co-processor design to hardware-accelerate waveforms during the programming cycle. Faster speeds are achieved through synchronous operations that eliminate the dead times so that the device under test no longer waits for the programmer. The result is programming near the theoretical limits of the silicon design — the faster the device, the faster the device is programmed The 2800 supports all device technologies including high-density NAND Flash, NOR Flash, Serial Flash, Managed NAND Flash, EPROM, EEPROM, Flash EPROM, Microcontrollers and more with densities up to an 8Eb theoretical limit. Model 2800 also uses BPM Microsystems' cost-effective, efficient socket cards with receptacle-base socket option. Individual socket cards can be fully utilized and replaced without dramatically affecting programming capacity. With the receptacle-base socket option, customers can purchase only the consumable socket as needed. The design of BPM Microsystems' socket cards increases manufacturing uptime, produces higher first-pass yield and saves replacement costs by as much as 75 percent. www.bpmmicro.com (130028-VII) 68 | May 2013 | www.elektor-magazine.com ELEKTOR Preferred Suppliers Tel. 1-978-281-7708 Fax 1-978-281-7706 Email ElektorUSA@smmarketing.us www.decodenet.com basic overlay board for NTSC PAL ' Supe 'impose graphics qw HI SC or PAL video k Overlay resolution: 480x240/ 480x288 ■ Standard fouls Irom 6x10 to 20x40 pixels ■ Stares custom fonts and bitmap graphics ■ Automatic text scroll and smooth crawl ■ Fasl TTL-232 3 end SPI contio! ports Ultrasonic Distance Sensing Made EZ www.maxbotix.com HRUSB-Max SonaA-EZ ™ - Mulli-sensor opera! on - US8 interface - Easy integration 1 mm resolution -MSRP £49.95 l2CXL-MaxSonar®-EZ™ - Incredible noise immunity - ISC interface -1cm resolution - UAV l s end robotics - Automatic calibration - Starting at $39.95 HRXL-MaxSonar^-WR ™ - IP67 rated - Low power Mu Hi-sensor operation - Easy to use - Great for lank, and bin - MSRP $1 09. 95 measuring Ethernet RLCs for OEMs From 5 119 Built-in Ethernet MODBUS TCP/IP Digital and Analog I/Os PWM/PID/ Step per Control TR *1 TRIANGLE RESEARCH INTERNATIONAL TeJ : 1 377 TRI-PLC5 ■wet : www.tri-pk.CDin/eit.frtm See what's brewing @ Elektor Labs 24/7 Check out www.elektor-labs.com and join, share, participate! elektor Sharing Electronics Projects Home News Proposals X i Finished Active- PajLlar Active Po^iulBf Active Pd puli i ■ - — < m labs r Z7l ' r raJikuKatic - Wwii Reminder Hiigh-cnd prapclli clock 1 1 20 73 2 | tlAlM USB I/O Cable Ele Eiek lor Labs Cnalfl ■ Project Crgjti; j ntw proraUI pt enlc- j utpiuh-ijI ■Sd h t fr . fr iidlHih 6 h s ricir < rv n’ plhtt 1 visi^irs. a fig irflvift: yeu v>i!i act EicWorUcd IftflJ Not ■ member? Vou W3I11 LO post A CWJKI but YOU www.elektor-magazine.com May 2013 69 •Tech the Future The Invisible User Interface By Tessel Renzenbrink (Elektor TTF Editor) "The most profound technologies are those that disappear. They weave them- selves into the fabric of everyday life until they are indistinguishable from it." That's what computer scientist Mark Weiser wrote in his famous article "The Com- puter for the 21st Century," originally published in 1991. Jelle Saldien (getting his teeth into Arduino) with colleague Jolien De Ville. He predicted the emergence of "ubiquitous com- puting" — omnipresent information technology that fades into the background of the human envi- ronment. According to Weiser, this would allow people to ignore the technology and focus on new objectives. The user interface is a major stepping stone on the path toward computer invisibility. "If you look at traditional computer interfaces, such as the keyboard and mouse, you see that people act as a cog in the process. Users have to learn to work with these interfaces because that is the only way to interact with the computer. The trend we see now is that people are looking more and more at the human aspect and how people communicate intuitively. What we are aim- ing for is to teach machines how to understand this human form of communication." The speaker is graduate engineer Jelle Saldien, a research coordinator and teacher of industrial design at the Industrial Design Center in Kor- trijk, Belgium. He is also the project manager of the Tangible Intuitive Interactive Interfaces (Till) project [2]. The objective of the Till proj- ect is to close the gap between the digital and physical worlds, particularly with regard to the user interface. Until recently the keyboard was the only way to get access to the digital world, but an upsurge of new interfaces has started to emerge. The breakthrough of touchscreen dis- play on the Apple iPhone and the popularity of motion sensing game controllers, such as the Kinect and the Wii Remote, show that there is a market for them. However, interface develop- ment has primarily been a game for the big play- ers in the technology sector. The Till platform takes the approach that the current situation in the electronics world makes it possible for rela- tively small companies to participate in interface development. The platform aims to promote this by means of support and cooperation. Usability There is a strong trend toward usability in indus- trial design and in human-computer interaction. That primarily revolves around efficiency, effec- tiveness, safety and ease of use. "This means that people are regarded as part of the machine," according to Saldien. "You focus on how people can perform their tasks as successfully and as efficiently as possible. This means that you look at speed, at how many mistakes they make, and how fast they can learn to click the right things in order to complete their tasks. All of that is part of usability. Ergonomics is also a major factor with products. For example, we look for the shape that best fits the hands of 90 percent of the popula- tion. People are generalized into a mathematical and psychological model with standard dimen- sions and reaction times. Then we try to build our systems so that everything goes as smoothly as possible with people as part of the system." 70 May 2013 www.elektor-magazine.com User Interface User experience The Till project shifts the focus from usability to the user experience, which involves looking at all aspects of the interaction between users and their products. How is the product perceived? How do users learn how to use it? And how does their use of the product change over time? Another factor that is examined is who the user is: where does the user live, what does the user do, and what does the user want? This is a shift from efficiency to experience, and it is an emerging trend in the interface world. Saldien: "In the gaming industry they make interfaces with a focus on entertaining and surprising effects. Sometimes the interface is intentionally made more difficult to make the environment more challenging. If you constantly make the interface easier, simpler and more effi- cient, users may start to feel stupid. It's like an operating system that tries to protect users to the point of annoyance by asking: Do you want to delete this file? Are you really sure?" "The shift toward user experience is also visible in areas outside the high-tech sector. Car mak- ers such as BMW and fashion designers such as Armani or Dolce & Gabbana are catering to user experience much more than before. They focus on aspects such as fun, surprise, image, beauty and esthetics, because these aspects have a major effect on how people experience a product or a fashion line." Emotions Jelle Saldien became interested in interfaces from his background in human-robot interaction. "At the Free University of Brussels we developed the social robot Probo for autistic children [3]. I have also done a lot of research on how to express emotions with a robot and how we can create social communication between people and machines. A lot of the interactions between peo- ple are non-verbal - we communicate with our tone of voice, our facial expressions, our body language and so on. That's something you learn to understand emotionally as a person. Autistic children have difficulty with this." "With the social robot, we can express emotions in a controlled and gradual manner. For example, the robot can always laugh in the same way, or it can change its laugh bit by bit, very gradually. The robot expresses these emotions according to recognizable social scenarios that are explained to the children. This is a specific form of ther- apy, called social story telling. It is certainly not intended as a substitute for a human therapist - which I would like to emphasize, since that would not be possible — but the robot acts as an intermediary or a doll that can mimic social interactions for children." "By studying this, we discovered that there is still a lot to be done in the area of human-machine interaction. How people communicate with each other is very different from how people inter- act with machines. This can be seen with e-mail messages, where misunderstandings can arise very quickly. There we miss the social interac- tions, such as eye contact and emotions, which help us communicate the right meaning. This is why people came up with emoticons, such as the smiley and the sad face. Even though keyboards were never intended to be used to express emo- tions, we humans quickly devise ways to convey emotional content in our messages." "Now we are looking more at how we do this as The social robot Probo. The social robot Ono [4], an open source and DIY- friendly project. www.elektor-magazine.com May 2013 71 Tech the Future Playing with technology in the creative lab Whist: an interactive lamp made from playing cards (inside) Whist: an interactive lamp made from playing cards (outside). people and how machines could pay more atten- tion to human factors. Especially in the academic world, people are already looking at how we can let machines simulate emotions, and in the other direction, how machines can detect human emo- tions. For example, if my computer detects that I am angry, it can adapt the interface accord- ingly. People are also working on this in the car industry. It would be handy if a car could notice that the driver is drowsy and warn the driver. Or if the driver gets aggressive, the car could adapt by slowing its response to driver input." Limits to what is possible Saldien thinks that if you are sufficiently creative, there aren't any technological limits to what is possible with the interface. This is partly due to the impact of the Arduino platform on interfac- ing. "Since this platform is so easily accessible, it allows artists, hackers and hobbyists to start tinkering and playing with technology," he notes. "The software programs for Arduino are called sketches. You're actually sketching with software code. You copy and paste bits of code and try things out. The focus is much more on interac- tion — what you can get the product to do — than on software engineering. This is really prototyp- ing with electronics. That makes it possible to actually start prototyping, shaping, testing and exploring the interface between people and the product, which is very important." Education "Learning to play and be creative with technology is also what we want to emphasize in the Till project. As an educational institution, we believe that education should be more oriented toward this. A large part of innovation consists of cre- ativity and daring, but there is no room at all for these traits in traditional education. Conventional education is mostly about solving problems. You are presented with questions that have only one right answer. The answers are in the back of the book, but you aren't supposed to look. You also aren't allowed to talk with your fellow students, since that's called cheating - but in normal life we call it cooperation. That has to change." "As a teacher, I notice that freedom is very impor- tant for students. You have to give them a good environment and the right tools, so they can get started quickly. But you must also help them get in contact with companies and users quickly. The social aspect is important; you have to get users fully involved in the development process. Talk with them, do tests with them, make something, solder something together, put it on your head, put it on and take it out on the street. Don't keep sitting in front of the computer making models and running simulations to see how it could be, because that's a dead end." Ubiquitous computing "The underlying idea of ubiquitous computing is that in the near future we will have computers all around us without noticing them. This ties in with the advent of the Internet of Things (IoT). All of us are already virtually present on the Internet. Each of us has an e-mail address, an IP number and an online profile. With the IoT, every product will also have a virtual presence on the Internet. Everything will be linked together then. The interface vision is a very important aspect of this, since you can't use a keyboard to interact will all those products. If the products in your surroundings can respond to the input they obtain from your gestures or facial expressions, the boundary between the digital and physical worlds disappears." "This semester we will start having our students integrate sensor for electronics into fabrics. This is an important step in interfacing with electronics. Now we carry our smartphones in our pockets, but we think that in future electronics and interfaces will be incorporated in the products we already have and like, such as clothing, wristwatches, jewelry, tables, chairs, windows and mirrors." "With a bit of luck the future will be nicer, with fewer boxes and cables, fewer new devices, and more integration into existing products. And hopefully with more cooperation between design- ers, engineers and social scientists. That's a good recipe for making nice, attractive and pleasant products." ( 130029 - 1 ) Internet Links [1] www.cse.nd.edu/~cpoellab/teaching/ cse40463/weiser. pdf [2] www.tiii.be/ [3] http://probo.vub.ac.be/ [4] http://io.workspace.howest.be/edubots/ono/ 72 May 2013 www.elektor-magazine.com ADuC841 Microcontroller Design Manual: From Microcontroller Theory to Design Projects If you’ve ever wanted to design and program with the ADuC841 microcontroller, or other microcontrollers in the 8051 family, this is the book for you. With introductory and advanced labs, you’ll soon master the many ways to use a microcontroller. Perfect for academics! Q M li Microcontroller Design Manual Buy it today! www.cc-webshop.com i ■ ■ w ■ ■■■«._ tm t m **§•*»-. Now Just $35.00 •Magazine By Jan Buiting (Managing Editor) Wandel & Goltermann NE-171 Multi Voltage Tube PSU (ca. 1963) It's every radio repair guy's dream Give me a tubed radio built between 1920 and 1965 and it's likely to have prob- lems in the power supply department, the switches, and/or the volume control. The problems in the PSU include worn out rectifiers (tubes or selenium), overheat- ed transformers, blown fuses, dried out electrolytic caps, spider nests, mice drop- pings, and bunt series or bleeder resistors. But you can't solve a problem before you have located it, which at the same time reveals the cause of the malfunction. Just as with most algebra, problems in old radios (or any bit of electronics for that matter) get solved by replacing suspect bits by known-good bits and then checking. That's easy if a power transformer's primary measures milliohms, or if a burnt and broken power resistor is spotted or smelled out, but the real problems are with inter- mittent operation of a power supply, like "this radio will play just fine for a good twenty minutes, then drops silent, then starts to hum, then smoke ... and only on Wednesdays and Sunday evenings when Aunt Mary is not around." These problems, and less grave ones too, require complete dis- connection of the power supply in a radio or tube amplifier, and all of its functions taken over in one fell swoop by a known-good device. The good news is that silencing and effectively uncoupling the radio's built in PSU (or what's left of it) is a matter of unsoldering a few wires (typically the heater voltage and the plate voltages). If you can't locate these wires, do not attempt to repair anything 'tubed & vintage' and stay with more contemporary electronics like Rpi's and iPhones. The bad news: you need a known-good power supply for all voltages and currents required: 50-300 VDC plate, 6.3 VAC or 4 VAC filament, -10 VDC to -100 VDC negative grid — in other words, a Multi Talent. On a positive note again, such equipment exists, and the specifications listed in the inset are not a dream. They pertain to the NE-171 Multi-voltage Adjustable Power Supply with Electronic Stabilization manufactured by the German firm Wandel u. Goltermann. I was given an NE-171 as part of an electronics labora- tory clearance recently, specifically for discussing on these Retronics pages. Made in Germany If Beamers and Mercs have been benchmarks for quality "wheels" from Germany for decades, the name Wandel & Goltermann equals top class pro- fessional electronic test and measurement equip- ment from the post WW1 years right into the 74 May 2013 www.elektor-magazine.com fft.etxanic& IC age (i.e. before being absorbed by Wavetek in 1999). W & G equipment used to be in the top price segment — and still is as prices go on Ebay, which are said to indicate a high collect- ability factor. Two manuals Although some freestyle information on the NE-171 may be found on the Internet at the exquisite Jogi's Rohrenbude [1], nothing beats an original manual in your hands. In luck, I received two manuals with the instrument. The oldest is time stamped 27 June 1958. It covers the 'C' production batch, hence my conjecture that the original design of the NE-171 is older. This hand- book is a crude production, apparently stencil copied from a typewritten original. A later ver- sion of the manual dated September 1962 by W & G, has typeset characters on the pages, which passed") warning sticker, I wasn't in the least concerned that the unit was faulty. For four rea- sons, basically: 1 . It's a genuine Wandel & Goltermann product. 2. It came from an environment were good care and maintenance was exercised by former and current readers of Elektor. 3.1 have an adjustable fully isolated transformer on my workbench to give the instrument a soft start after years in storage. I switched on, breaking the sticker. And indeed the unit worked spot on. Here's two scenarios for a No-Go sticker applied on a working instrument. l.In week 44, 2006, someone from Approval Stickers Dept, duly connected his (her) 2012 Fluke DMM to the 50-300 V adjustable voltage output, and switched on the NE-171. Notic- ing a voltage surge, the test person switched are glossy and printed rather than stenciled. This bright orange colored booklet covers production batches F, G and H. My NE-171 is no. 16432H, putting its date of manufacture in 1962, pos- sibly 1963. "Nicht bestanden" (in June, 2006) Despite its age, my NE-171 is in mint condi- tion on the outside, and just a bit dusty inside. Although the lever of the Power switch was cov- ered by a conspicuous "Nicht bestanden" ("Not off instantly and duly applied the red & white sticker. After the annual equipment status report was filed to the accounts department, the NE-171 was declared 'faulty' and put in storage, waiting to be destroyed or sent to a landfill. Fortunately, after just 8 years it was spotted by a lab worker and Retronics fan of a certain age. I got an email. 2. As 1. above, but: "Noticing no immediate volt- age reading, ..." The plot is explained further on. www.elektor-magazine.com | May 2013 75 •Magazine Compact and powerful For sure many high-voltage adjustable power sup- plies exist from various manufacturers covering roughly 1950-1970, all designed for use with tube equipment, be it experimental in the lab, or for repair jobs. They're all bulky instruments though, like the Van der Heem 8619 tube PSU I discussed in the April 2007 edition of Elektor [2]. Compared to that boatanchor, the W & G NE-171 is a compact lightweight, noting of course it supplies slightly less output current and voltage on the HT adjustable output. I love the form factor of the NE-171 — it's like a thick book, and the perfect companion to many of my repair activities on tube radios. EL156 "2 the max" From an electronics point of view, the design of the adjustable FIT section of the NE-171 is conventional. Only a section of the schematic is shown here. We have a tube series regulator (Rol), a regulating amplifier tube (Ro2), and an array of resistors and a pot to set the output voltage. The -85 V reference voltage furnished by a type 85A2 stabilizer tube is applied to the common rail of the lower resistor array. The crux is not in the basic design but in the choice of the components. Where many other adjustable FIT supplies have a pair of EL34 (6CA7) tubes as the series regulator, here a single EL156 is used in combination with a very 'steep' pen- tode type EF804S. That EL156 gets high marks throughout: cathode current: 180 mA max.; anode dissipation; 40 W max.; anode voltage: 800 V max. The device is one of the most pres- NE-171 Specifications Direct Voltage 1 stabilized, floating, 6 ranges and continuous adjustment. 50 V - 300 V Max. output current (DV2 = 0) 100 mA Internal resistance (175 V; 20-200 mA) <2 ft Output voltage accuracy <1% ±2 V Hum (300 V; 100 mA) approx. 0.1 mV rms Output voltage change (±10% line fluctuation; 300 V; 100 mA) approx. ±300 mV Direct Voltage 2 (50 mA max.) Unstabilized, floating, negative terminal common to DV1 approx. 520 V Max. output current (DV1= 0) 50 mA Internal resistance approx. 1 kft Ripple voltage (50 mA) approx. 0.5 V rms Direct Voltage 3 stabilized, floating, positive terminal on DV1 negative terminal. 0 - -10 V / 0 - -100 V (selectable) Max. output current 0 - - 10 V up to short circuit (approx. 1.5 mA) 0 - - 100 V up to short circuit (approx. 3.5 mA) Flum (1 mA) approx. 20 pV rms Regulation (±10% line fluctuation) approx. ±0.1% Alternating Voltages 3 separate, floating, heater outputs 4 V/ 6.3 V 3 A 6.3 V 3 A 18 V/ 20 V 1 A Tube complement EL156, EF804S, ECC82, 85A2 AC line input 220 V, 45-60 Hz Power consumption (fully loaded) approx. 140 VA Dimensions 140 x 315 x 249 mm Weight approx. 22 lbs (10 kg) 76 May 2013 www.elektor-magazine.com fft.etxanic& tigious tubes developed by the Telefunken com- pany, and a culmination of their awesome exper- tise — just marvel at that datasheet [3]. The EL156 is a great audio power output tube too. The output voltage on the NE-171 is set using a combination of a 6-position range switch with 50-V increments and a pot that gives 0-50 V on top of the range value. In my case, the range switch appears stuck at the 150 V position so I can only set values between 150 and 200 V. I will look into freeing the spindle. Internally, the switch, cam and spring loaded arm appear functional. The 50-300 V adjustable output has a separate (red) on/off switch and a resettable fuse rated at 125 mA. The later NE-171 manual warns users not to switch on the 50-300 V output until the instrument has been on for a minute or so, on penalty of voltage surges, or no voltage at all. So now you know why the "Nicht bestanden" sticker got applied, probably by someone not too familiar with tube equipment ("Nicht verstanden?"), and definitely not by anyone on that kind lab team. No problems were encountered with the three multi-section electrolytic capacitors in the instru- ment. I found that three type BY179 bridge recti- fiers were fitted instead of B250C150 devices as indicated by the schematic. The BY179 is con- spicuously 1970s green! Finally, I should not forget a big asset of the NE-171: all outputs float with respect to the chassis. NE-171 double-team The HT adjustable supplies in two NE-171s can be connected in parallel or in series, to obtain higher output currents (0-200 mA) or higher output voltages (100-600 V) respectively. The parallel configuration requires a plug at the back of the instruments to be pulled from its socket, and a special equipment linking cable to be inserted. The cable can be home made provided you can get your hands on the special 5-way plugs. Practical use Whenever a faulty tube radio lands on my desk, I rigorously disconnect ALL of its power supply circuitry, electrolytics included, and power the radio electronics from the NE-171 — after con- sulting the radio schematics of course. First, I allow the radio tubes to wake up by applying the heater voltage(s) only for 15 minutes or so. This will immediately reveal filament wiring faults and intermittent tube filaments. Next, the plate voltage is applied, starting care- fully at 50 volts and increasing to the nominal voltage (usually 250 volts). In 8 out of 10 cases, the radio will play to an extent. Next, the elec- trolytics are reformed, starting at 50 volts and slowly ramping up to 300 volts, fire extinguisher ready ©. Then I work my way back right up to the rectifier input(s). In case of doubt, a milliam- meter is inserted in the central HT line. The whole procedure can be carried out with total confidence of a known good power supply, which is a reassuring factor. The repairs on the radio's AF, IF and RF sections finished, I'm always a bit sad when it's time to disconnect the NE-171 and redo the connections to the radio's own supply section — step by step, of course, and measuring voltages with one hand in my pocket. ( 130030 ) Internet Links [1] www.jogis-roehrenbude.de/, search NE-171 [2] Adjustable high voltage supply, Retronics, Elektor April 2007, www.elektor.com/075036 [3] www.hifitubes.nl/weblog/wp-content/tele- funken-ell56.pdf IEST B 20041 Retronics is a monthly section covering vintage electronics including legendary Elektor designs. Contributions, suggestions and requests are welcome; please telegraph editor@elektor.com www.elektor-magazine.com | May 2013 | 77 •Magazine Hexadoku Puzzle with an electronic touch For optimum performance the human brain needs regular exercising and stimulating. Although the technical articles in this edition of Elektor should prove pretty effective in that respect, an extra challenge in the form of a puzzle is beneficial. In the puzzle below, enter the right numbers or letters A-F in the open boxes, find the solution in the gray boxes, submit online, and you automatically enter the prize draw for one of four vouchers. The Hexadoku puzzle employs numbers in the hexadecimal range 0 through F. In the diagram composed of 16 x 16 boxes, enter numbers such that all hexadecimal numbers 0 through F (that's 0-9 and A-F) occur once only in each row, once in each column and in each of the 4x4 boxes (marked by the thicker black lines). A number of clues are given in the puzzle and these determine the start situation. Correct entries received enter a prize draw. All you need to do is send us the numbers in the gray boxes. Solve Hexadoku and win! Correct solutions received from the entire Elektor readership automatically enter a prize draw for one Eurocircuits PCB voucher worth $140.00 and three Elektor book vouchers worth $60.00 each, which should encourage all Elektor readers to participate. Participate! Before June 1, 2013, supply your personal details and the solution (the numbers in the gray boxes) to the web form at www.elektor.com/hexadoku Prize winners The solution of the March 2013 Hexadoku is: 48C57. The Eurocircuits $140.00 voucher has been awarded to Yves Printemps (France). The Elektor $60.00 book vouchers have been awarded to Peter Raue (Germany), Arwin J. Vosselman (Netherlands), and Torsten Clever (Germany). Congratulations everyone! 9 4 E 5 6 i 3 2 B A B 0 1 E 2 4 9 D 8 6 1 3 0 C 8 6 A B 4 F C a 3 7 E i 9 2 0 D 7 3 9 E B 6 2 4 B 5 6 9 A 7 5 B c 1 E 4 0 4 a 2 5 2 3 E 7 F E A 4 7 C B 6 5 3 8 C B 5 0 A 1 6 F 4 D F E 2 7 1 3 D 9 E C A 7 4 D 3 A 0 1 5 C The competition is not open to employees of Elektor International 6 F 2 8 c 3 D E 9 0 1 A 7 4 5 B 0 7 9 C F 5 A i B 6 4 2 D E 8 3 1 3 D E B 2 4 8 c 5 7 F 0 6 9 A 4 A B 5 6 7 9 0 8 3 D E c F 1 2 A 8 c 9 0 B 1 3 E F 2 5 4 7 D 6 7 D 3 2 4 F C 5 A 8 0 6 1 9 B E B 0 F 1 7 E 8 6 D 9 3 4 A 2 c 5 E 4 5 6 9 A 2 D i 7 B C F 0 3 8 2 E 0 4 8 c 3 7 F A 9 D B 5 6 1 3 5 6 F 1 D B 4 7 2 C 0 8 A E 9 8 B 7 D 2 9 5 A 4 E 6 1 3 c F 0 9 c 1 A E 6 0 F 3 B 5 8 2 D 7 4 C 1 A 3 D 8 6 9 0 4 E 7 5 B 2 F D 2 8 7 A 0 E B 5 1 F 9 6 3 4 c 5 6 E 0 3 4 F c 2 D 8 B 9 1 A 7 F 9 4 B 5 i 7 2 6 c A 3 E 8 0 D Media, its business partners and/or associated publishing houses. 78 May 2013 www.elektor-magazine.com Gerard's Columns Credibility By Gerard Fonte (USA) It is most frustrating to have a great idea and not be believed. The most common reason for this is lack of credibility. That is, you are not perceived as having the skills nor the experience to be successful. And while you should seriously consider this as being true, you shouldn't blindly accept this supposition, either. Call for Backup Probably the easiest approach is to enlist the aid of some- one who does have credibility. Experts in the field have dem- onstrated their experience and skills and have considerable credibility. Lawyers call "technical experts" as witnesses to present their side — often with different experts testifying to completely opposite things. "Nine out often doctors agree...." shout advertisers. Perhaps the most famous example is physicist Leo Szilard's recruitment of Albert Einstein to write a letter to President Roosevelt in 1939. This helped initiate the formation of the Manhattan Project (the atomic bomb). It should be noted that Einstein was a theoretical physicist and had considerable credibility in scientific circles in that area. But the Manhattan Project was experimental, or applied, physics and Einstein had little scientific credibility there. Roosevelt apparently wasn't aware of the distinction. Szilard did know the difference but was a shrewd student of human nature and understood that the perception of credibility was sometimes more important than actual credibility. (Einstein played no direct role in the development of the atomic bomb.) Unfortunately, the expert is the one who will usually get credit for the successful project. You will only get credit for calling in the expert. This is probably not the outcome that you were hoping for. The Deep End Suppose you are an engineer in a company and you can clearly see that the production floor layout is incredibly inefficient. So you take upon yourself to develop a completely new produc- tion floor layout. You spend a lot of time creating the optimal design. You ask for, and are granted, a meeting with senior staff. There you present your idea for the complete re-struc- turing of the physical layout of the whole production floor. After the end of your presentation, the vice president of production says something like: "Bob, this is a really impressive design. I can see that you spent considerable effort working on this. But for the time being I think we'll keep things as they are. After all, they've been working well for 15 years." Obviously you have no credibility in the development of pro- duction floors. That is not your area of expertise and trying to tackle a major project right from the start just makes things worse. No one really heard what you had to say. They were turned off before the meeting even started. Consider this, you hire a plumber to fix you hot water tank and he says that he can completely re-de- sign your living room for better space utilization. What would you think? Step by Step It's difficult to stop when you have a good idea. You want to develop is as far as you can. That is, the project becomes bigger and bigger. But, it's much easier to sell a small idea rather than a big one. And being successful with small projects gives you credibility that you can leverage to larger projects. Here's a different approach to re-designing the production floor. The first thing to do is take a course in production floor design. Then go to George (the production floor manager) with a very small change that can make a fairly large change in efficiency. But approach him deferentially and refer to your course. "George, I just finished a course in production floor design and it seems to me that if those two work-stations were swapped, the work- flow would be improved. What do you think?" Assuming you are right, he would probably agree. It's a simple and obvious change. (Although he may provide you with information why that is impossible. In this case, you haven't really lost anything and have gained a better understanding of the production system.) Wait for a month after the change and visit George. If things are working out as you expected, ask him to write a note to your boss about your help. Keep up an ongoing relationship with George and make further very small suggestions for improve- ment. It doesn't matter if these improvements will be changed in the final grand re-design. They only have to show incremental progress. The main purpose of these changes it to develop your credibility in this area. The secondary purpose is to get George as an ally. When the time comes to present your full production floor layout, George will be listened to— he has credibility. If he agrees to your ideas they are much more likely to be accepted. In fact, you should enlist George as a co-developer of your idea. While it's nice to get the full credit, it's really not all that important. You will still be recognized as the originator of the idea. And George is very likely to be able to contribute to the design. After all, he's been working there for years and his experience is clearly meaningful. By including George you are acknowledging his importance in moving the project forward. You needed his support, so it's proper to recognize this. The critical aspect is to understand that credibility does not happen overnight. It is developed and cultivated over time. Credibility is the spawn of success. (130138) www.elektor-magazine.com | April 2013 | 79 •Store Limited Time Offer for GREEN and GOLD Members! 13°/o DISCOUNT + FREE SHIPPING www.elektor.com/ may Learning to fly with Eagle E EAGLE V6 EAGLE is a user-friendly, powerful and affordable software package for the efficient design of printed circuit boards. This book is intended for anyone who wants an introduction to the capabilities of EAGLE. The reader may be a novice at PCB design or a professional wanting to learn about EAGLE, with the intention of migrating from another CAD package. This book will guickly allow you to obtain an overview of the main modules of EAGLE, learn to use some of the basic commands in the schematic and layout editor modules, apply your knowledge of EAGLE commands to a small project, learn more about some of the advanced concepts of EAGLE and its capabilities and much more. A free version of EAGLE is available to enthusiasts for their own use. After reading this book while practicing some of the examples, and completing the projects, the reader should feel confident about taking on more challenging endeavors. 208 pages • ISBN 978-1-907920-20-2 $47.60 80 tales of electronics bygones E Retronics Quite unintentionally a one-page story on an old Heathkit tube tester in the December 2004 edition of Elektor magazine spawned dozens of 'Retronics' tales appearing with a monthly cadence, and attracting a steady flow of reader feedback and contributions to the series. This book is a compilation of about 80 Retronics installments published between 2004 and 2012. The stories cover vintage test eguipment, prehistoric computers, long forgotten components, and Elektor blockbuster projects, all aiming to make engineers smile, sit up, object, drool, or experience a whiff of nostalgia. Owners of this book are advised to not exceed one Retronics tale per working day, preferably consumed in the evening hours under lamp light, in a comfortable chair, with a piece of vintage electronic eguipment close and powered up. 193 pages • ISBN 978-1-907920-18-9 $40.00 A whole year of Elektor magazine on a single disk Bl DVD Elektor 2012 The year volume DVD/CD-ROMs are among the most popular items in Elektor's product range. This DVD-ROM contains all editorial articles published in Volume 2012 of the English, American, Spanish, Dutch, French and German editions of Elektor. Using the supplied Adobe Reader program, articles are presented in the same layout as originally found in the magazine. An extensive search machine is available to locate keywords in any article. With this DVD you can also produce hard copy of PCB layouts at printer resolution, adapt PCB layouts using your favorite graphics program, zoom in / out on selected PCB areas and export circuit diagrams and illustrations to other programs. ISBN 978-90-5381-273-0 • $37.90 Display, buttons, real time clock and more , Elektor Linux Board Extension This extension board was developed to further propel our Embedded Linux series of articles and the matching GNUblin board. It has a display, buttons, a real time clock and 16 GPIOs. Linux devotees, switch on your solder irons. The Linux extension board includes everything needed to provide the user interface for a wide variety of projects! Module, SMD-populated and tested board, incl. LCD1, XI, K1-K4, BZ1, BT1 for home assembly Art.# 120596-91 • $50.20 Taming the Beast Ei FPGA Development Board FPGAs are unguestionably among the most versatile but complex components in modern-day electronics. An FPGA contains a maze of gates and other circuit elements that can be used to put together your own digital circuit 80 May 2013 www.elektor-magazine.com Books, CD-ROMs, DVDs, Kits & Modules on a chip. This FPGA developiment board (designed in the Elektor Labs) shows how easy it is for any electronics enthusiast, whether professional or amateur, to work with these programmable logic devices. Module, ready build and tested Art.# 120099-91 See www.elektor.com/fpgaboard LabWorX 2 - Mastering Surface Mount Technology This book takes you on a crash course in techniques, tips and know-how to successfully introduce surface mount technology in your workflow. Even if you are on a budget you too can jumpstart your designs with advanced fine pitch parts. Besides explaining methodology and equipment, attention is given to SMT parts technologies and soldering methods. Many practical tips and tricks are disclosed that bring surface mount technology into everyone's reach without breaking the bank. A comprehensive kit of parts comprising all SMT components, circuit boards and solder stencils is available for readers wishing to replicate three projects described in this book. 282 pages • ISBN 978-1-907920-12-7 $47.60 Sound Secrets and Technology E Electric Guitar What would today's rock and pop music be without electric lead and bass guitars? These instruments have been setting the tone for more than forty years. Their underlying sound is determined largely by their electrical components. But, how do they actually work? This book answers many questions simply, in an easily-understandable manner. For the interested musician (and others), this book unveils, in a simple and well-grounded way, what have, until now, been regarded as manufacturer secrets. The examination explores deep within the guitar, including pickups and electrical environment, so that guitar electronics are no longer considered highly secret. With a few deft interventions, many instruments can be rendered more versatile and made to sound a lot better - in the most cost- effective manner. 287 pages • ISBN 978-1-907920-13-4 $47.60 10 captivating lessons n. PIC Microcontroller Programming Using the lessons in this book you learn how to program a microcontroller. You'll be using JAL, a free but extremely powerful programming language for PIC microcontrollers. Assuming you have absorbed all lessons you should be confident to write PIC microcontroller programs, as well as read and understand programs written by other people. You learn the function of JAL commands such as include, pin, delay, forever loop, while loop, case, exit loop, repeat until, if then, as well as the use of functions, procedures and timer- and port interrupts. You make an LED blink, build a time switch, measure a potentiometer's wiper position, produce sounds, suppress contact bounce, and control the brightness of an LED. And of course you learn to debug, meaning: how to spot and fix errors in your programs. 284 pages • ISBN 978-1-907920-17-2 $47.60 Further information and ordering: www.elektor.com/store Elektor US 111 Founders Plaza, Suite 300 East Flartford, CT 06108 USA Phone: 860.289.0800 Fax: 860.461.0450 E-mail: order@elektor.com www.elektor-magazine.com | May 2013 | 81 •Magazine NEXT MONTH IN ELEKTOR MAGAZINE Universal Wi-Fi Controller Board Although LED control systems exist in many shapes and sizes, surely there's room for one more from Elektor. Next month we'll publish a handy circuit that allows an RGB LED strip to be controlled through a Wi-Fi network. Those of you tired of seeing yet another RGB LED circuits will like the extra features built into the project, like a boot loader, an expansion port and protective diodes. The circuit is easily adapted for Wi-Fi based control of a garage door, a bunch of relays, a robot, a (model) car or even a train. 70 cms 130 mW Wideband FM Transmitter This exciter/driver outputs 130 milliwatts of ultra-clean wideband FM at a user selected frequency within the 430-440 MHz section of the 70 cms amateur radio band. Legal restrictions and your national band plan allowing, this TX lets you set up high quality over-air audio links, even in duplex mode as the 70 cms band should provide enough room to accommodate several channels using directive antennas for point-to-point links. Lithium-ion Battery Charger Properly recycling Lithium-ion batteries and battery packs from junked equipment is not easy because the batteries are usually charged internally, i.e. by the equipment itself. Consequently there is no separate charger that can be recycled also. But then, it is not difficult to build a charging circuit for used (or new) Li-ion cells. This circuit is microcontroller free, and instead employs a special charger IC from Maxim. An array of LEDs indicates the charging progress. Article titles and magazine contents subject to change; please check www.elektor-magazine.com Elektor USA June 2013 edition published May 13, 2013. See what's brewing @ Elektor Labs 24/7 Check out www.elektor-labs.com and join, share, participate! Elatrtw Labs elektor Sharing Electronics Projects ^ labs | (j™n) U>) >ri 1 flirfl j Caler Lfcit Tilth ATmtaaB-ia P (AMuiiVi ea. M ***** Switches 7RDS Replacement THT + * * *y- • I .. .1 >Vu ivjrit to 4 project but y&u st* not a member? T3S0Q O0OD0 □kk liefe to send a description of your project inchrfiFiy J CtlCwH diagram flnd p photograph for evaluation- mavte you will be granted Create a Project ChCJtf a flfw or- a ^pe^ai Gut Mu. PiiPC^jLk 6 . yijtua hc-m uUmi vMlflrt. *iU WBrcbfc Whu will o*t EltlAvi'ifJ kip 1 82 May 2013 www.elektor-magazine.com Ordering Information ORDERING INFORMATION To order contact customer service: Phone: 860.289.0800 Fax: 860.461.0450 Mail: Elektor US 111 Founders Plaza, Suite 300 East Hartford, CT 06108 USA E-mail: order@elektor.com On-line at www.elektor.com/store Customer service hours: 8:30 AM-4:30 PM EST Monday- Friday. Voice mail available at other times. When leaving a message please be sure to leave a daytime telephone num- ber where we can return your call. PLEASE NOTE: While we strive to provide the best possible information in this issue , pricing and availability are subject to change without notice. To find out about current pricing and stock , please call or email customer service. COMPONENTS Components for projects appearing in Elektor are usually available from certain advertisers in the magazine. If diffi- culties in obtaining components are suspected, a source will normally be identified in the article. Please note, however, that the source(s) given is (are) not exclusive. PAYMENT Orders must be prepaid. We accept checks or money orders (in US $ drawn on a US bank only), VISA, Mastercard, Discover, and American Express credit cards. We do not accept C.O.D. orders. We also accept wire transfers. Add $20 to cover fees charged for these transfers. TERMS OF BUSINESS Shipping Note: All orders will be shipped from Europe. Please allow 3-4 weeks for delivery. Shipping and handling via airmail: $20.00 per order. Returns Damaged or miss-shipped goods may be returned for re- placement or refund. All returns must have an RA #. Call or email customer service to receive an RA# before returning the merchandise and be sure to put the RA# on the outside of the package. Please save shipping materials for possible carrier inspection. Requests for RA# must be received 30 days from invoice. Patents Patent protection may exist with respect to circuits, devices, components, and items described in our books and maga- zines. Elektor accepts no responsibility or liability for failing to identify such patent or other protection. Copyright All drawing, photographs, articles, printed circuit boards, programmed integrated circuits, diskettes, and software car- riers published in our books and magazines (other than in third-party advertisements) are copyrighted and may not be reproduced (or stored in any sort of retrieval system) without written permission from Elektor. Notwithstanding, printed circuit boards may be produced for private and personal use without prior permission. Limitation of liability Elektor shall not be liable in contract, tort, or otherwise, for any loss or damage suffered by the purchaser whatsoever or howsoever arising out of, or in connection with, the supply of goods or services by Elektor other than to supply goods as described or, at the option of Elektor, to refund the purchaser any money paid with respect to the goods. MEMBERSHIPS (US & CANADA ONLY) Order memberships on-line at www.elektor.com/members All memberships begin with the current issue. Expect 3-4 weeks for receipt of the first issue. Membership renewals and change of address should be sent to: Elektor US P.O. Box 462228 Escondido, CA 92046 E-mail: elektor@pcspublink.com Memberships may be paid for by check or money order (in US $ drawn on a US bank only). We accept Mastercard, VISA, Discover and American Express credit cards. For gift memberships, please include gift recipient's name and address as well as your own, with remittance. A gift card will be sent on request. Memberships may be cancelled at any time for a refund of all unmailed issues. Does your membership expire soon? Renew it on-line at www.elektor.com/members www.elektor-magazine.com | May 2013 | 83 \ A * 0 * § CIRCUIT CELLAR # ou (iKHMi iwjtpi'.’ii’jp btc*f L 0 MTK 1 N iV.L'J'J LXilJj-. J’-v-j Sum FH.VL 2 J F-l£i 21 THE WORLD'S SOU ft MARCH y . 0 t Issue 272 T*S AORcjr ssC ROBOTICS COMIV: Build a Ci Checkout Hardware with a US: Electronic Thermal A Rotational Inverted Pendulum Monitor Electrical Use in Real Time Ardumo Survival Guide Modern Morse Coding for Engineers Stifhu^lie SifnpfftW! Pc i - n n^r-ct ■: .1 In 3 a A&&r4t<*f Ofn»f*jn ti C-S^r^H-ilkH- CiinJru--: Pii^yjni TV+tny, +p\*L*Ujty, l IWriM .■■ArtilMw* An MCU-B Network C "NmnH'fr ■ ■ ib-LUrY ■ fiLfti Ml I'Wfi EE Design Inspiration >/ Ha rflvM.it re fi Rjoftwnre PToKrtypi™3 // Innovative PSoC- Based Projects // Applkvitiofi r*cle wriwng t ;' And Mora f Kir. frj. MttftlTl 1 fr^, ****«.' kl tt r.F-5 Pnhu vt-i. \ LWATK * Jjirad &■*!** -OUirt.H: JihAdli i.,viT;iih r»u.i. l«inw C*fFi.r t \ Mat. w P*if» i? Subscribe now to the leading computer applications magazine specializing in embedded systems and design! 1 2 issues per year for just Print OR Digital: $50 :: Combo (Print + Digital): $85 www.circuitcellar.com/subscription